Aller au contenu

Photo

Missing Body Parts


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Sydious

Sydious
  • Members
  • 59 messages
I'm useing a couple scripts to spawn random NPCs. One script to spawn them, and one to make them Random at onSpawn.

Everything seems to work great, except sometimes some of the NPCs loose body parts. no arm, no thigh, both arms gone, and so on.

I didn't script anything to do with thier bodies other then the Pheno. (Skinny - Heavy)

Why might they be loosing thier parts?

Here are the scripts:

spawn the crowd of NPCs near a spawn point.
#include "x0_i0_position"
void main()
{

    object oSpawn;
    object oSpawnPoint;
    oSpawnPoint = GetWaypointByTag("SP_COMMONER_01");
    int iCrowd_Size = GetLocalInt(oSpawnPoint, "crowd_size");
    //Locate the area we are in
    object oArea = GetArea(OBJECT_SELF);
    //Locate where in the are we are
    vector vPosition = GetPosition(oSpawnPoint);
    //Identify the direction we are facing
    float fOrientation = GetFacing(oSpawnPoint);
    //Create Crowd
    int i;
    for (i = 0; i < iCrowd_Size; i++)
    {
        float fMaxDistance = 5.0; // max dist from waypoint where random loc will end up.
        vector vRandom = VectorNormalize( AngleToVector( IntToFloat( Random( 3601 )) /10.0 ));
        vRandom *= fMaxDistance;
        vRandom += GetPosition( oSpawnPoint );
        location myLocation = Location( oArea, vRandom, GetFacing( oSpawnPoint ));
        int iGender = d2(1);
        CreateObject(OBJECT_TYPE_CREATURE, "commoner00" + IntToString(iGender), myLocation, FALSE, "commoner_" + IntToString(i));
    }
}


And here is the OnSpawn for the NPCs:

//Random NPC Script, put on spawn
#include "x0_i0_anims"
#include "x2_inc_switches"
void main()
{
//Random Head
SetCreatureBodyPart(CREATURE_PART_HEAD, Random(12)+1, OBJECT_SELF);
//Random Skin and Hair Colors
SetColor(OBJECT_SELF, COLOR_CHANNEL_HAIR, Random(174)+1);
SetColor(OBJECT_SELF, COLOR_CHANNEL_SKIN, Random(6)+1);
//Random Pheno
int iPheno;
switch(Random(2))
{
case 0: iPheno = 0; break;
case 1: iPheno = 2; break;
}
SetPhenoType(iPheno, OBJECT_SELF);
//Random Clothes
string sclothes_resref;
switch(Random(12)+1)
{
    case 1: sclothes_resref = "nw_cloth001"; break;
    case 2: sclothes_resref = "nw_cloth002"; break;
    case 3: sclothes_resref = "nw_cloth003"; break;
    case 4: sclothes_resref = "nw_cloth004"; break;
    case 5: sclothes_resref = "nw_cloth009"; break;
    case 6: sclothes_resref = "nw_cloth013"; break;
    case 7: sclothes_resref = "nw_cloth019"; break;
    case 8: sclothes_resref = "nw_cloth021"; break;
    case 9: sclothes_resref = "nw_cloth022"; break;
    case 10: sclothes_resref = "nw_cloth023"; break;
    case 11: sclothes_resref = "nw_cloth024"; break;
    case 12: sclothes_resref = "nw_cloth025"; break;
    case 13: sclothes_resref = "nw_cloth027"; break;
    case 14: sclothes_resref = "nw_cloth028"; break;
}
CreateItemOnObject(sclothes_resref, OBJECT_SELF,1 ,"my_clothes");
object oClothes = GetItemPossessedBy(OBJECT_SELF, "my_clothes");
ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST);
SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);
SetAnimationCondition(NW_ANIM_FLAG_IS_CIVILIZED);
SetAnimationCondition(NW_ANIM_FLAG_CONSTANT);
SetAnimationCondition(NW_ANIM_FLAG_IS_MOBILE_CLOSE_RANGE)

}

All clothes are standard pallet items.

#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Might have similar problems from a thread that was just posted not long ago. Read through this and see if it helps you.
social.bioware.com/forum/Neverwinter-Nights-1/NwN-1-Builders---Scripting/Random-NPC-Heads-Script-FIXED-7716910-1.html

#3
kalbaern

kalbaern
  • Members
  • 824 messages
If it happens repeatedly with the same appearances and only on the heavy pheno, then most likely you are missing the parts for that phenotype. If using the CEP or many other haks with clothing/armor additions, they notoriously are missing parts either based on race and often for other phenos other than normal.

#4
Sydious

Sydious
  • Members
  • 59 messages

kalbaern wrote...

If it happens repeatedly with the same appearances and only on the heavy pheno, then most likely you are missing the parts for that phenotype. If using the CEP or many other haks with clothing/armor additions, they notoriously are missing parts either based on race and often for other phenos other than normal.


Thats sounds like the issue. I am using CEP 2.4.

I tired to stick to the standard pallet. I had just started debuging with having the NPC speak it's outfit resref so i could see if it was an outfit issue. I will have to keep an eye on pheno also.

Thanks for the adivce.

#5
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Off topic to your question,  But doing this:

CreateItemOnObject(sclothes_resref, OBJECT_SELF,1 ,"my_clothes");
object oClothes = GetItemPossessedBy(OBJECT_SELF, "my_clothes");

 is pointless.  It is not only pointless but there is no garrentee that it is retrieving the correct item.   Use: 

 object oClothes =   CreateItemOnObject(sclothes_resref, OBJECT_SELF,1 ,"my_clothes");

Or even get rid of the var all together and Just equip the Item created: 

ActionEquipItem(CreateItemOnObject(sclothes_resref, OBJECT_SELF,1 ,"my_clothes") , INVENTORY_SLOT_CHEST);

#6
Sydious

Sydious
  • Members
  • 59 messages

Lightfoot8 wrote...

Off topic to your question,  But doing this:

CreateItemOnObject(sclothes_resref, OBJECT_SELF,1 ,"my_clothes");
object oClothes = GetItemPossessedBy(OBJECT_SELF, "my_clothes");

 is pointless.  It is not only pointless but there is no garrentee that it is retrieving the correct item.   Use: 

 object oClothes =   CreateItemOnObject(sclothes_resref, OBJECT_SELF,1 ,"my_clothes");

Or even get rid of the var all together and Just equip the Item created: 

ActionEquipItem(CreateItemOnObject(sclothes_resref, OBJECT_SELF,1 ,"my_clothes") , INVENTORY_SLOT_CHEST);




Thanks for the guidance Lightfoot8, Just getting my head back around NWscript. It has been a few years. Relearning and guidance like this is a huge help!

Thanks!

Now...if I can only figure out how not to have to goto work each day so I can do nothing else but dink with NWN.....

Modifié par Sydious, 13 juillet 2011 - 09:58 .


#7
kalbaern

kalbaern
  • Members
  • 824 messages
I forgot, many times "sex" is an issue as well.

I have a dozen or so outfits for my generic commoners in my own module. I did them as seperate male/female versions. I then dropped my male assortment into the inventory of a male PC and equipped one. Then, you can in the toolset, switch phenos and change races and see if the outfit glitches or not. You can even toggle between male and female to see if it works for both.