Aller au contenu

Photo

Chance to spawn onenter


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

#1
Nasher_AOB

Nasher_AOB
  • Members
  • 35 messages

Hi!

 

I'm using this script for NWN1 and it works fine, but it won't for NWN2. It has a 50% chance to spawn the npc "poe" when the player enters the area. Even if I set to <=100 the spawn won't fire.

location lTarget;
object oSpawn;
object oTarget;

void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));

if (DoOnce==TRUE) return;

SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);

if (d100()<=50)
   {
   oTarget = GetWaypointByTag("poe_inicio");

   lTarget = GetLocation(oTarget);

   oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "poe", lTarget);

   }

}

Can you guys please tell me how to make this work for NWN2? Thanks.



#2
kevL

kevL
  • Members
  • 4 052 messages
looks okay t'me. What event-slot are you using? iirc, NwN2 has an additional onEnter slot compared to NwN

OnClientEnter is your best bet. Also recheck tag_of_waypoint, resref_string, etc.


CreateObject() with a slight delay can help also

and If you really want to check whether a script (or codeblock) is firing, add a debugline:
SendMessageToPC(GetFirstPC(FALSE), "fire script");


#3
Nasher_AOB

Nasher_AOB
  • Members
  • 35 messages

Hey KevL,

 

I think the problem was with the blueprint. Instead of copying, I created a new blueprint, so no base scripts were attached to the creature. I copied instead and it's working now.

 

And it works OnClientEnter and OnEnter. Thanks!



#4
kevL

kevL
  • Members
  • 4 052 messages
ko!