Aller au contenu

Photo

Trap's OnTrigger ruin the trap


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

#1
DFDark

DFDark
  • Members
  • 9 messages
Recently, I have been working on some trap system for our PW. What's keep bugging me is, that whenever i put script onto "OnTriggered" event of the trap, trap ends up not doing anything. It just pops "Trap Triggered" and then it disappears and nothing happened. At first, I though it was some error on script side, but then I tried this:

// Trap's OnTriggered Event
void main()
{
}

And the result was the same, the trap disappeared but no damage was inflicted. Is this just one of issues which remain in NWN2, or did I forget to do something?

Any help appreciated,
DFDark

#2
Guest_Chaos Wielder_*

Guest_Chaos Wielder_*
  • Guests
I imagine that the game thinks your 'on triggered' event is supposed to be what the real trap is so it doesn't want to "double up", so to speak, and have two traps go off at the same time.

#3
BigfootNZ

BigfootNZ
  • Members
  • 131 messages

Chaos Wielder wrote...

I imagine that the game thinks your 'on triggered' event is supposed to be what the real trap is so it doesn't want to "double up", so to speak, and have two traps go off at the same time.


I believe its more or less this, OnTrigger overrides any of the traps pre assigned script it has listed in the Traps.2da. So if you want it to do its regular effect plus your own extras you'd have to make a copy of the original traps script and add your extras to it and then use that in the OnTrigger event.

#4
The Fred

The Fred
  • Members
  • 2 516 messages
However, you could make a small piece of code which finds out which script is supposed to be run, and then runs if for you. As Bigfoot says, the default script is specified in the 2da file, so you could use that to find the script and then fire it. I haven't tested this, but here's a skeleton which should work:

void main()
{
    //Fire the default script
    string sScript = Get2DAString("traps", "TrapScript", GetTrapBaseType(OBJECT_SELF));
    ExecuteScript(sScript, OBJECT_SELF);

    //Fire a custom script
    sScript = GetLocalString(OBJECT_SELF, "MyOnTriggeredScript");
    ExecuteScript(sScript, OBJECT_SELF);
}

Then, you can make a custom script and set the variable "MyOnTriggeredScript" on the trap to it's name. Of course, you could just replace the bottom half of this script with your own behaviour, but this way you can mix and match default and custom scripts easily using this one thingy.

Modifié par The Fred, 31 octobre 2010 - 01:29 .