Author Topic: Appearance Modifier Crashing Server  (Read 369 times)

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Appearance Modifier Crashing Server
« on: January 26, 2013, 11:26:10 pm »


               Reciently we added Scarface's appearance modifier to our module. I liked the character head appearance changer, so I decided to adapt the scripts to our version of cep2.2c. After much work, I got the scripts to show every cep2.2c head available for each race and some subraces. I had also changed the scripts so that it would only show the heads, and not show the headless heads.

The scripts worked pretty well, and offered a lot of new cep head choices for our players. However the scripts are also causing random server crashes. I thought it may be some buggy heads, but the scripts for wings and tails also caused the random crashes.

I'm not sure what could be causing the problem. I've seen these appearance changers on other servers, and they worked without any problems.

Here are my modified scripts from Scarface's appearance modifier. I'm posting the next head and prev head scripts for the head appearance modifier. Any help would be greatly appreciated.

My next head script:

// Created By Scarface
// Modified by Sadira
void main()
{
object oPC = GetPCSpeaker();
    if (GetSubRace(oPC)== "Wemic")
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 2)
            {
                nHead = 1;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 4)
            {
                nHead = 1;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetSubRace(oPC)== "Brownie")
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 36)
            {
                nHead = 1;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 32)
            {
                nHead = 1;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetSubRace(oPC)== "Fairy")
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 36)
            {
                nHead = 1;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 32)
            {
                nHead = 1;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetRacialType(oPC)==RACIAL_TYPE_DWARF)
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 27)
            {
                nHead = 1;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 28)
            {
                nHead = 1;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetRacialType(oPC)==RACIAL_TYPE_ELF)
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 186)
            {
                nHead = 1;
            }
            if ((nHead > 43) && (nHead < 46))
            {
                nHead = 46;
            }
            if ((nHead > 49) && (nHead < 101))
            {
                nHead = 101;
            }
            if ((nHead > 103) && (nHead < 111))
            {
                nHead = 111;
            }
            if ((nHead > 112) && (nHead < 122))
            {
                nHead = 122;
            }
            if ((nHead > 122) && (nHead < 179))
            {
                nHead = 179;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 39)
            {
                nHead = 1;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetRacialType(oPC)==RACIAL_TYPE_GNOME)
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 20)
            {
                nHead = 1;
            }
            if ((nHead > 10) && (nHead < 15))
            {
                nHead = 15;
            }
            if ((nHead > 15) && (nHead < 18))
            {
                nHead = 18;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 39)
            {
                nHead = 1;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetRacialType(oPC)==RACIAL_TYPE_HALFLING)
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 176)
            {
                nHead = 1;
            }
            if ((nHead > 15) && (nHead < 161))
            {
                nHead = 161;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 169)
            {
                nHead = 1;
            }
            if ((nHead > 26) && (nHead < 160))
            {
                nHead = 160;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetRacialType(oPC)==RACIAL_TYPE_HALFORC)
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 23)
            {
                nHead = 1;
            }
            if ((nHead > 15) && (nHead < 18))
            {
                nHead = 18;
            }
            if ((nHead > 18) && (nHead < 21))
            {
                nHead = 21;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 36)
            {
                nHead = 1;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 191)
            {
                nHead = 1;
            }
            if ((nHead > 49) && (nHead < 100))
            {
                nHead = 100;
            }
            if ((nHead > 115) && (nHead < 132))
            {
                nHead = 132;
            }
            if ((nHead > 134) && (nHead < 140))
            {
                nHead = 140;
            }
             if ((nHead > 144) && (nHead < 147))
            {
                nHead = 147;
            }
            if ((nHead > 152) && (nHead < 155))
            {
                nHead = 155;
            }
            if ((nHead > 160) && (nHead < 168))
            {
                nHead = 168;
            }
            if ((nHead > 168) && (nHead < 172))
            {
                nHead = 172;
            }
            if ((nHead > 172) && (nHead < 175))
            {
                nHead = 175;
            }
            if ((nHead > 175) && (nHead < 180))
            {
                nHead = 180;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) + 1;
            if (nHead > 165)
            {
                nHead = 1;
            }
            if ((nHead > 49) && (nHead < 100))
            {
                nHead = 100;
            }
            if ((nHead > 113) && (nHead < 115))
            {
                nHead = 115;
            }
            if ((nHead > 123) && (nHead < 132))
            {
                nHead = 132;
            }
            if ((nHead > 132) && (nHead < 135))
            {
                nHead = 135;
            }
            if ((nHead > 135) && (nHead < 138))
            {
                nHead = 138;
            }
            if ((nHead > 138) && (nHead < 140))
            {
                nHead = 140;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
}


Thank you for any help you can offer.
               
               

               


                     Modifié par Sadira of Tyr, 26 janvier 2013 - 11:36 .
                     
                  


            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Appearance Modifier Crashing Server
« Reply #1 on: January 26, 2013, 11:39:11 pm »


               Here is the script for prev head appearance:

// Created By Scarface
// Modified by Sadira
void main()
{
object oPC = GetPCSpeaker();
    if (GetSubRace(oPC)== "Wemic")
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 2;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 4;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetSubRace(oPC)== "Brownie")
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 36;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 32;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetSubRace(oPC)== "Fairy")
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 36;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 32;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetRacialType(oPC)==RACIAL_TYPE_DWARF)
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 27;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 28;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetRacialType(oPC)==RACIAL_TYPE_ELF)
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 186;
            }
            if ((nHead > 43) && (nHead < 46))
            {
                nHead = 43;
            }
            if ((nHead > 49) && (nHead < 101))
            {
                nHead = 49;
            }
            if ((nHead > 103) && (nHead < 111))
            {
                nHead = 103;
            }
            if ((nHead > 112) && (nHead < 122))
            {
                nHead = 112;
            }
            if ((nHead > 122) && (nHead < 179))
            {
                nHead = 122;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 39;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetRacialType(oPC)==RACIAL_TYPE_GNOME)
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 20;
            }
            if ((nHead > 10) && (nHead < 15))
            {
                nHead = 10;
            }
            if ((nHead > 15) && (nHead < 18))
            {
                nHead = 15;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 39;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetRacialType(oPC)==RACIAL_TYPE_HALFLING)
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 176;
            }
            if ((nHead > 15) && (nHead < 161))
            {
                nHead = 15;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 169;
            }
            if ((nHead > 26) && (nHead < 160))
            {
                nHead = 26;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else if (GetRacialType(oPC)==RACIAL_TYPE_HALFORC)
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 23;
            }
            if ((nHead > 15) && (nHead < 18))
            {
                nHead = 15;
            }
            if ((nHead > 18) && (nHead < 21))
            {
                nHead = 18;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 36;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
    else
    {
        if (GetGender(oPC) == GENDER_FEMALE)
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 191;
            }
            if ((nHead > 49) && (nHead < 100))
            {
                nHead = 49;
            }
            if ((nHead > 115) && (nHead < 132))
            {
                nHead = 115;
            }
            if ((nHead > 134) && (nHead < 140))
            {
                nHead = 134;
            }
             if ((nHead > 144) && (nHead < 147))
            {
                nHead = 144;
            }
            if ((nHead > 152) && (nHead < 155))
            {
                nHead = 152;
            }
            if ((nHead > 160) && (nHead < 168))
            {
                nHead = 160;
            }
            if ((nHead > 168) && (nHead < 172))
            {
                nHead = 168;
            }
            if ((nHead > 172) && (nHead < 175))
            {
                nHead = 172;
            }
            if ((nHead > 175) && (nHead < 180))
            {
                nHead = 175;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
        else
        {
            int nHead = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) - 1;
            if (nHead < 1)
            {
                nHead = 165;
            }
            if ((nHead > 49) && (nHead < 100))
            {
                nHead = 49;
            }
            if ((nHead > 113) && (nHead < 115))
            {
                nHead = 113;
            }
            if ((nHead > 123) && (nHead < 132))
            {
                nHead = 123;
            }
            if ((nHead > 132) && (nHead < 135))
            {
                nHead = 132;
            }
            if ((nHead > 135) && (nHead < 138))
            {
                nHead = 135;
            }
            if ((nHead > 138) && (nHead < 140))
            {
                nHead = 138;
            }
            SetCreatureBodyPart(CREATURE_PART_HEAD,  nHead, oPC);
        }
    }
}


I decided to include this script, since I noticed more crashes when selecting previous heads.
               
               

               


                     Modifié par Sadira of Tyr, 26 janvier 2013 - 11:39 .
                     
                  


            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Appearance Modifier Crashing Server
« Reply #2 on: February 04, 2013, 11:05:29 am »


               Ok, I guess there is nothing wrong with these scripts. Probably they just use too many resources.

Is there an easy way to have the player type in the number of the head appearance they want?

That would make for less head changing, and less resources used by the scripts.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Appearance Modifier Crashing Server
« Reply #3 on: February 04, 2013, 05:05:55 pm »


               Whatever is crashing you is not related to the number of module resources. Scripts only use two resources each (.nss and .ncs). Likewise, if you meant too many cycles, NWN has a built-in instruction limit, and making too much for a mod to handle would take a lot more than a single script. If I had to guess, I would say that either a) your're actually crashing a client, not the server, with an appearance it doesn't have, and the server is then resetting when empty, or 'B)' there's an issue with SetBodyPart. The latter seems unlikely, though

I would first make sure that your server is not set to reset when empty, and then try to pinpoint the source of the crash - what appearance number is killing it? You can add debug code to have the appearance numbers SpeakString-ed or logged, as you prefer.

Funky
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Appearance Modifier Crashing Server
« Reply #4 on: February 05, 2013, 02:11:47 am »


               I was told by the host that the server machine locked up, and had to be manually reset.

It was gnome head number 15 that made it crash, but that head works fine on my copy of the module. I will have to compare my head numbers with the server heads and see if thaey are the same. Perhaps that is the problem.

Thank you for helping.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Appearance Modifier Crashing Server
« Reply #5 on: February 05, 2013, 03:11:52 am »


               I see. Ruling out the server reset via client crash, then, it's likely the edit caused an issue with the bicfile. Certain changes to characters will cause crashes, though my experience with that relates solely to people doing it deliberately to crash servers on login. Unless the issue has been reported by others on Scar's system's vault page, my next best guess is a mismatch between client and server 2das, as you surmise.

Good luck, and please let us know what the issue was, if you solve it.

Funky
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Appearance Modifier Crashing Server
« Reply #6 on: February 05, 2013, 11:07:09 am »


               Oops, I got the number wrong. It was the female gnome head number 10 actually. It was the head that I had started with. I had not like the gnome head choices, and was scrolling back to my starting head, when it crashed. When I am playing, I use an override to allow me to choose cep heads when creating my character. Could this override cause any conflicts with the scripts from the server? I remove the override when I am using the toolset.

I checked the head files between my copy of the module and the server, and everything was the same. I am not sure what else could be the problem. There were no problems reported on Scarface's Vault page. The original script was made for cep2.0, and was set to give heads 0 to 34 for all races. I just adapted it for cep2.2, and to remove the headless choices. The head that caused the crash would have been in the original script as well.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Appearance Modifier Crashing Server
« Reply #7 on: February 05, 2013, 04:46:49 pm »


               Your question now seems outside my expertise. You might have better luck in the custom content forums, if you haven't posted there already. I did find some references to this issue in the Omnibus, but no resolution (which is why it's so important to post when you figure out what was happening '<img'> ).
 Omnibus entry:
/////////////////////////
Alwarren
Hi.
I keep having a weird problem with
SetCreatureBodyPart. I have an OnSpawn script that chooses a head from a list of
possible heads for a guard.
However, I keep having strange effects from this.
For example, it might be that a guard spawns with only a head and no body, or
the server (not the client) crashes outright. It seems to happen across all
platforms, including Linux and MacOS.
There is even more to it. A dedicated
server started this way refuses to let me log in via direct connect. I can log
in via "Join LAN Game" or "Join Internet Game", but direct connect (either via a
shortcut nor via the button) seems to work.
Now, I am well aware this might
be an issue for just myself, but if there is someone that knows this problem and
knows a solution, I'd be glad to hear about it.
Thanks!

////////////////////////

I know that problems with models can cause client crashes, but little more. Modelers are likely to have more insight for you.

Funky
               
               

               


                     Modifié par FunkySwerve, 05 février 2013 - 04:47 .
                     
                  


            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Appearance Modifier Crashing Server
« Reply #8 on: February 06, 2013, 01:10:38 am »


               Ok, I will do that. Thank you very much for helping me. 'Image