Author Topic: Polymorph OnEquip  (Read 388 times)

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Polymorph OnEquip
« on: February 25, 2014, 03:07:07 pm »


               

I have an armor equipping code, in the module OnEquip script, that makes a PC uncommandable for a certain amount of time while they are equipping armor. It works as I like it to with one exception: when someone leaves/cancels polymorph, it fires for them. I'd like to stop that from happening, but I've not really been having any luck determining if someone has just left a polymorphed state. I'd also really prefer not to have to go through and modify the polymorph scripts (especially all those for shifters) to set variables or start some pseudo-heartbeat or something.


 


So I'm wondering if anyone has some clever ideas to either determine when a person has just left a polymorphed state or otherwise stop the script in the OnEquip event from firing based on other criteria that a recently polymorphed PC might trigger.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Polymorph OnEquip
« Reply #1 on: February 25, 2014, 03:10:44 pm »


               

check this, nonNWNX way to do that, if you use NWNX then nwnx_events might be better choice for you



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Polymorph OnEquip
« Reply #2 on: February 25, 2014, 05:51:10 pm »


               

why not edit your on/unequip script to react only to armor? is this impossible? if it is and you've tried this route already, I appologize.



               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Polymorph OnEquip
« Reply #3 on: February 25, 2014, 06:46:56 pm »


               

Well, the portion of the script that equips armor only reacts of the item triggering the event is armor/clothing. But my problem is that whenever someone comes out of polymorph they trigger the OnEquip event - at least for the armor slot. So this means coming out of polymorph in combat a very bad idea right not because they get froze in place when that portion of the script fires to simulate them re-equipping armor that was already in the armor slot when they entered the polymorphed state.


 


Shadooow, your idea seems interesting. I'll have to test out some variants of it as I'm not sure I totally get it, but if the OnEquip event always fires immediately after someone is polymorphed that at least gives me a hook to mark them as polymorphed.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Polymorph OnEquip
« Reply #4 on: February 25, 2014, 07:12:28 pm »


               


Well, the portion of the script that equips armor only reacts of the item triggering the event is armor/clothing. But my problem is that whenever someone comes out of polymorph they trigger the OnEquip event - at least for the armor slot. So this means coming out of polymorph in combat a very bad idea right not because they get froze in place when that portion of the script fires to simulate them re-equipping armor that was already in the armor slot when they entered the polymorphed state.


 


Shadooow, your idea seems interesting. I'll have to test out some variants of it as I'm not sure I totally get it, but if the OnEquip event always fires immediately after someone is polymorphed that at least gives me a hook to mark them as polymorphed.




actually looking at my script it looks that you only need to check GetHasEffect(EFFECT_TYPE_POLYMORPH,oPC) as it looks PC is always in polymorph when these events fire


               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Polymorph OnEquip
« Reply #5 on: February 25, 2014, 07:37:03 pm »


               

Hmmm - I'm not sure if that is the case. I did have this line in my module OnEquip script, but it was not stopping the armor equipping code below it from running when a PC left a polymorphed state:



//If this is a polymorphed creature, or a creature coming out of polymorph don't do any of the armor equipping code below

  if (GetHasEffect(EFFECT_TYPE_POLYMORPH, oPC)) return;

However, once i changed it to this, it appears now to be working:



  //If this is a polymorphed creature, or a creature coming out of polymorph don't do any of the armor equipping code below

  int iIsPolymporphed = GetHasEffect(EFFECT_TYPE_POLYMORPH, oPC);

  int iWasPolymporphed = GetLocalInt(oPC, "Polymorphed");

  if (iIsPolymporphed || iWasPolymporphed) {

    if (iIsPolymporphed && !iWasPolymporphed) SetLocalInt(oPC, "Polymorphed", TRUE);

    if (!iIsPolymporphed && iWasPolymporphed) DeleteLocalInt(oPC, "Polymorphed");

    return;

  }

if anyone can spot any holes or problems with this bottom solution though, I'd love to hear them.



               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Polymorph OnEquip
« Reply #6 on: February 27, 2014, 12:05:15 am »


               

Correct me if I'm wrong,  But you can not change armor if you are in combat correct?


 


If Armor can not be manually changed in combat and the on Equip event is firing for armor in combat then it must be because a polymorphic event has taken place.  


 


Therefore it seems to me that the solution should be to make one change in the OnEquip module event to bypass the TBS from firing if the PC is in combat and the item firing the event is armor.