Hi fellas. I'm trying to get an NPC to spawn in an area when the PC enters that area and some predefined integer variable reaches a certain value. I placed this script in the area's Properties --> Events --> OnEnter window:
if((GetLocalInt(GetPCSpeaker(), "violet99") == 3))
{
location angelaappearshere = GetLocation(OBJECT_SELF);
CreateObject(OBJECT_TYPE_CREATURE, "Angela", angelaappearshere);
SetLocalInt(GetPCSpeaker(), "violet99", 4);
}
Here 'angelaappearshere' is the tag of a waypoint I placed in the area and 'Angela' is the NPC's tag. 'violet99' is an integer-type variable declared beforehand in the 'variables' section under Module Properties --> Advanced. What I'm trying to do is tell the game:
When my PC enters this area, check if the value of 'violet99' is 3. If yes, spawn the specified NPC at the waypoint specified. Then change the value of 'violet99' to 4, so that later when my PC leaves and then returns yet again no second copy of the NPC will be spawned.
The script compiled without any errors, but didn't work.
'> Why? What did I do wrong? How do I make it work? Any help will be appreciated. Thanks in advance!