Author Topic: Concept: OnPolymorphed and OnUnPolymorphed events without NWNX  (Read 250 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Concept: OnPolymorphed and OnUnPolymorphed events without NWNX
« on: February 20, 2013, 05:42:06 pm »


               I was solving some issues with skin and polymorph on my module and noticed consistency in the equipping and unequipping order. Found out that it would be possible to determine when PC just polymorphed and unpolymorphed from this without using NWNX.

The advantage of this is that the polymorph is removed and reapplied every time a PC is saved by the game and this is hard to catch using other ways like possible pseudo-hb. I for example applying base itemproperties on polymorph skin and if a player gets save while under polymorph, they get erased. Unfortunately I wasnt able to remove the temp HPs as those are reapplied as well each time player gets re-polymorphed. The temp HPs are shown as an icon, but cannot be retrieved within GetFirst/NextEffect.

To do it:

Put this code into OnPlayerEquipItem:

object oPC = GetPCItemLastEquippedBy();
object oItem = GetPCItemLastEquipped();
 if(GetHasEffect(EFFECT_TYPE_POLYMORPH,oPC) && !GetLocalInt(oPC,"Polymorphed"))
 {
 SetLocalInt(oPC,"Polymorphed",1);
 ExecuteScript("ev_mod_poly",oPC);
 }

And this code into OnPlayerUnEquipItem:

object oPC = GetPCItemLastUnequippedBy();
object oItem = GetPCItemLastUnequipped();
 if(GetHasEffect(EFFECT_TYPE_POLYMORPH,oPC) && GetLocalInt(oPC,"Polymorphed"))
 {
 SetLocalInt(oPC,"Polymorphed",0);
 ExecuteScript("ev_mod_unpoly",oPC);
 }

You will need to
#include "x0_i0_match"
as GetHasEffect function is not a standard function

change the name of the scripts as you need fit. You can call the same script and decide which event it is based on Polymorphed variable value too, your choice.

I havent tested it thoroughly and Im not sure this will work when PC leaves game (in this case the polymorph is also reapplied) and enter the game again. Its possible the scripting above will need adjustion for these cases. I decided I will stick with NWNX for this so its up to you to foolproof this.
               
               

               
            

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
Concept: OnPolymorphed and OnUnPolymorphed events without NWNX
« Reply #1 on: February 21, 2013, 05:22:55 pm »


               I like the idea. It's too bad there isn't an event that fires before a polymorph happens (before a PC's items are unequipped and so on). That might allow some attempt to prevent spell slots from being wiped, etc., without changing/recompiling all of the shildshape/shifting impact scripts.

BTW, did you plan to check that
oItem
has the BASE_ITEM_CREATUREITEM base item type, or to use
oItem
somewhere?
               
               

               


                     Modifié par MrZork, 21 février 2013 - 05:28 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Concept: OnPolymorphed and OnUnPolymorphed events without NWNX
« Reply #2 on: February 21, 2013, 08:39:42 pm »


               

MrZork wrote...

I like the idea. It's too bad there isn't an event that fires before a polymorph happens (before a PC's items are unequipped and so on). That might allow some attempt to prevent spell slots from being wiped, etc., without changing/recompiling all of the shildshape/shifting impact scripts.

yea that would be good, I made a script that solves this for a sorc a wiz characters, but it does only prevent the loss of the slots from ability bonus not from an items. And the same solution (aply an int/cha bonus permanently before polymorph and remove when unpolymorph) is not useable for a wis based characters as that might modify their AC, will...

anyway, I did that without this event, applied it righ beforre polymorph in all poly abilities scripts, and then ran pseudoHB i think to remove it if player is not in poly anymore - i can share if you want

BTW, did you plan to check that

oItem
has the BASE_ITEM_CREATUREITEM base item type, or to use
oItem
somewhere?

why? anyway, feel free to modify it and post an update if you think its it better to check item base type. Actually that usage reason I wrote above is nonsense. The unequip/equip event will fire for each item all the time so in order to copy item properties one does not need this event, so not sure for what purpose this might be used. I am also locking all classes with a variable with polymorph and unlock them later, but that can be also done without this, if you dont mind using pseudohb etc.
               
               

               


                     Modifié par ShaDoOoW, 21 février 2013 - 08:47 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Concept: OnPolymorphed and OnUnPolymorphed events without NWNX
« Reply #3 on: February 21, 2013, 09:11:26 pm »


               hmm but what would be possible to do with this event is to solve the temp HP stacking issue

simply rename the collumn for tempHP in polymorph.2da -> this will remove the default temp HPs each time player (re)polymorph and add an unlinked tempHPs manually in the script for each poly ability. And then remove these temp HPs in OnUnPolymorph event.
               
               

               


                     Modifié par ShaDoOoW, 21 février 2013 - 09:12 .