Jump to content

Home

Globals in scripting


HdVaderII

Recommended Posts

Okay...

I know how to make a script that checks if a global has been set, and make it return true or false, but how do I combine that with a script to make somebody spawn if the global script returns true, and make nothing happen if it returns false?

Link to comment
Share on other sites

Attach this script to an npcs heartbeat in the area you want the npc to spawn.

void main() {  



if ((GetGlobalNumber("global_tag")  == 1) && !GetLocalBoolean(OBJECT_SELF, 40))





{

SetLocalBoolean(OBJECT_SELF, 40, TRUE);

vector vPos;
       float fAngle;

       vPos.x = 106.24; 
       vPos.y = 238.01; 
       vPos.z = 17.15;
       fAngle = 0.0; 
               CreateObject(OBJECT_TYPE_CREATURE, "npc_tag", Location(vPos, fAngle));




}
}

Hope it helps :D

Link to comment
Share on other sites

You can also add this sort of thing to a dialog. A new branch at the top of the dialog tree, with starting conditional as above, then if the condition is met (ie the global is correct) then the dialog will follow the new upper path and spawn the NPC, if you don't want to use NPC heartbeats. This is useful if it’s not a whole new module and you want to change just small things in an existing module.

 

Piggy-backing scripts off dialog is awesome.

 

~Pap~

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...