Recent changes Random page
GAMING
Gaming
 
WoWWiki
Halopedia
FFXIclopedia
Age of Conan
Warhammer Online
Grand Theft Wiki
See more...

Reset a generic trigger for a persistan world

From NWNWiki

Jump to: navigation, search

Contents

[edit] Reset a generic trigger for a persistan world

This depends a lot on how they are "de-activated" and how you want them to "re-active". I will cover the most common way to do it and it will work just fine in a PW.

[edit] Deactivate a Trigger

To Deactivate a trigger, and never need it again: This is mostly used in a Solo / Multiplayer Game. Simply add DestroyObject(OBJECT_SELF,1.0); at the end of your trigger script.

To Deactivate a Trigger once it is entered, but still be able to reactivate later. This is most often used in play when you want something to trigger only once, and not trigger again until a quest is compleat or some other condition. You would want to include this in your trigger script.

void main()
{
    // Check to see if the trigger is ready
    if(GetLocalInt(OBJECT_SELF,"READY") != 1)
      {
      // Set Ready to 1, so it don't trigger again
      SetLocalInt(OBJECT_SELF,"READY",1);
      // Rest of your script here
      }
}

[edit] Reactivate The Trigger

Now, to re-activate that trigger ready for use again you would need something like this in your script

void main()
{
    // Get the trigger in question
    object oTrig = GetObjectByTag("TAG_OF_TRIGGER");
    // Set it's "READY" state back to 0
    SetlocalInt(oTrig,"READY",0);
}

[edit] Start with a Deactivated trigger

To Start with a Deactivated trigger, so it can be activated at a latter time. An example of this would be not to spawn the hord that needs destroyed until a quest is finished.

void main()
{
    if(GetLocalInt(OBJECT_SELF,"READY") == 1)
      {
      // Deactivate the trigger
      SetLocalInt(OBJECT_SELF,"READY",0);
      // Rest of script here
      }
}

Now when a condition is met, you activate that trigger with,

void main()
{
    object oTrig = GetObjectByTag("TAG_OF_TRIGGER");
    SetLocalInt(oTrig,"READY",1);
}

[edit] Make a Trigger Reset itself

To make a trigger "rest itself" after a specified time. This is most often used for creature spawns.

void main()
{
    // set the delay time to reactivate
    int fReset = 120.0; // 2 min.
    // Check to see if it is ready
    if(GetLocalInt(OBJECT_SELF,"READY") != 1)
      {
      // Disable trigger
      SetLocalInt(OBJECT_SELF,"READY",1);
      // Reactivate it after fReset time has passed
      DelayCommand(fRest,SetLocalInt(OBJECT_SELF,"READY",0));
      // rest of script here
      }
}

Thats the basics of it all. Again, it really depends a lot on what you are specificaly doing, but this will cover it for the most part. Also there is a dozen ways to do it, this is just a few.

Rate this article:
Share this article: