Aller au contenu

On Exit Kill All NPC's In Area-Script


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

#1
Guest_NWN Dragon-Blade_*

Guest_NWN Dragon-Blade_*
  • Guests
I'm not sure how to do this, I've been using lilacs script generator for most scripting but this I could not do with it.
i'm trying to kill all NPC's In the area on exit (to destroy some NPC's from a wild-life script from on enter) Or Maybe could It be done with the Specific spawns from the on enter like the cardinals or whatnot? I'll lsit their tags below...

MEDFOREST_VIPER
ZEP_BIRD_004
ZEP_BIRD_003
ZEP_GAZELLE
ZEP_SKUNK
ZEP_WEASEL

#2
420

420
  • Members
  • 190 messages
Do you want to "kill" them or simply destroy the objects? Also, I'm guessing that you only want this to happen if there are no other PCs in the area (in the case of a multiplayer game).

-420

#3
Guest_NWN Dragon-Blade_*

Guest_NWN Dragon-Blade_*
  • Guests
Yes, No PC's in area, Destroy would probablt be better since wouldnt want corpses or somthing please :)

#4
420

420
  • Members
  • 190 messages

//Goes in area's OnExit event

void main()

{

object oPC = GetExitingObject();

object oTarget;

string sTag;



//If the exiting object isn't a PC end script

if(!GetIsPC(oPC)) return;



//Check to make sure no PCs are in the area

oPC = GetFirstObjectInArea(OBJECT_SELF);

if(GetIsPC(oPC)) return;

else if(GetIsObjectValid(GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oPC))) return;



//Area has no PCs clean up the NPCs

oTarget = GetFirstObjectInArea(OBJECT_SELF);

while(GetIsObjectValid(oTarget))

    {

    sTag = GetTag(oTarget);

    if(sTag == "MEDFOREST_VIPER" ||

       sTag == "ZEP_BIRD_004" ||

       sTag == "ZEP_BIRD_003" ||

       sTag == "ZEP_GAZELLE" ||

       sTag == "ZEP_SKUNK" ||

       sTag == "ZEP_WEASEL")

        {

        DestroyObject(oTarget, 1.0);//Delay destroy while in a loop

        }

    oTarget = GetNextObjectInArea(OBJECT_SELF);

    }

}



#5
Xovian

Xovian
  • Members
  • 87 messages
I use this one, as it ignores tags and just destroys creatures.

void main()
{
object oPC = GetNextObjectInArea();
if(GetIsPC(oPC)==TRUE)return;
object oExiting = GetExitingObject();
if (GetIsPC(oExiting))
{
//SendMessageToPC(oExiting, "Area cleanup event fired.");
object oObjectToClean = GetFirstObjectInArea(OBJECT_SELF);
while (GetIsObjectValid(oObjectToClean))
{
if (
!GetIsPC(oObjectToClean) &&
!GetIsDM(oObjectToClean) &&
!GetPlotFlag(oObjectToClean) &&
GetObjectType(oObjectToClean) == OBJECT_TYPE_CREATURE
)
{
//SendMessageToPC(oExiting, "Destroying " + GetName(oObjectToClean));
DestroyObject(oObjectToClean, 0.1);
}
oObjectToClean = GetNextObjectInArea(OBJECT_SELF);
}
}
}


Modifié par Xovian, 27 février 2011 - 07:20 .


#6
Guest_NWN Dragon-Blade_*

Guest_NWN Dragon-Blade_*
  • Guests
Thankyou, To both of you :)