Author Topic: Removing an encounter by using the OnDeath  (Read 456 times)

Legacy_briscanlon

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Removing an encounter by using the OnDeath
« on: August 14, 2010, 07:57:56 am »


               Morning everyone.  Finally got round to creating a module in NWN.  Only taken a few years.... '<img'>

I'm looking to see if it's possible to remove an encounter through a script.

I've used a script in the OnDeath section of an object, so when it's destroyed it removes the encounter.

This is what I've used:

void main(){
object oPC = GetLastKiller();
if (!GetIsPC(oPC)) return;
object oTarget;oTarget = GetObjectByTag("et_TapestryWarriors");
DestroyObject(oTarget, 0.0);
}

But the encounter is not removed.  Is it the script, where I'm using it, or the fact that you cannot remove an encounter?  Would I be better to get the encounter to run only if a local variable is set?  And on the destruction of the item, the variable is then changed?

I'll hopefully start to get my head around this scripting business. 

Cheers all.

Bri.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Removing an encounter by using the OnDeath
« Reply #1 on: August 14, 2010, 09:45:37 am »


               I'm pretty sure that encounters can not be destroyed. Instead use the SetEncounterActive function to turn it off:

void main()
{
object oPC = GetLastKiller();
if (!GetIsPC(oPC)) return;
object oTarget = GetObjectByTag("et_TapestryWarriors");
SetEncounterActive(FALSE, oTarget);
}

Hope that helps. Good luck.
               
               

               


                     Modifié par GhostOfGod, 14 août 2010 - 08:46 .
                     
                  


            

Legacy_briscanlon

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Removing an encounter by using the OnDeath
« Reply #2 on: August 14, 2010, 12:01:12 pm »


               That's perfect.  Thank you very much.



Bri.