Aller au contenu

Photo

Unspawn NPC?


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

#1
Knight_Shield

Knight_Shield
  • Members
  • 444 messages
I found a nice script in old forums axe murderer made to spawn npc's onenter.
I think this will help reduce lag ?
I was wondering ...how do I despawn the npc if noone is in the area ..I dont think the clean up script will sense that is for encounters.Posted Image

#2
Mudeye

Mudeye
  • Members
  • 126 messages
If you have kept track of the objects (NPCs) you want to get rid of then you can make a script for the   OnExit event of the area that cleans them up.

When the PC leaves the area the OnExit event fires it would be something like this for an npc tagget "npctag":

void main()
{
   object pc = GetExitingObject();
   if( GetIsPC( pc ) )
   {
      object npc = GetObjectByTag("npctag");
      if( npc != OBJECT_INVALID ) DestroyObject(npc);
   }
}

#3
ffbj

ffbj
  • Members
  • 593 messages
You need two while loops to destroy all the npc's if it's a multiplayer campaign. The above script will only destroy one npc.



The first while loop would check if there are any pc's in the area, using get firstpc and the get next pc, then return the script if there is still a pc in the area. If no pc's in the area then start the second while loop destroying the npc's one by one as long as there is one remaining.

#4
Knight_Shield

Knight_Shield
  • Members
  • 444 messages
Posted Image

Modifié par Knight_Shield, 08 octobre 2010 - 09:52 .