Aller au contenu

Photo

Polymorph OnEquip


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

#1
Thayan

Thayan
  • Members
  • 244 messages

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.



#2
Shadooow

Shadooow
  • Members
  • 4 471 messages

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


  • WhiteTiger aime ceci

#3
henesua

henesua
  • Members
  • 3 882 messages

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.



#4
Thayan

Thayan
  • Members
  • 244 messages

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.



#5
Shadooow

Shadooow
  • Members
  • 4 471 messages

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


  • WhiteTiger aime ceci

#6
Thayan

Thayan
  • Members
  • 244 messages

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.



#7
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

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.