Author Topic: Setting a variable on PC which lasts as long as a polymorph?  (Read 386 times)

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Setting a variable on PC which lasts as long as a polymorph?
« on: February 24, 2014, 01:55:52 pm »


               I want to set a variable on a PC if he/she polymorphs into a water elemental. The task of this variable is to make him breathe underwater as long as he remains in this shape.
While setting a variable temporarily, as long as the duration of the polymorph, would not be difficult, I don't want it to persist if the effect lasts shorter for some reason, i.e. if the PC cancels the polymorph.

Is there an easy way to do this?
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Setting a variable on PC which lasts as long as a polymorph?
« Reply #1 on: February 24, 2014, 02:05:54 pm »


               There is a way to do this, but what about the other way? Check for the appearance first, then for variable.

Im not sure whether you use CPP 1.71 or not, but in case you would then you can use the function int spellsIsImmuneToDrown(object oCreature) from #include "70_inc_spells"
basically any creature that can breath underwater is immune to the drowning so its the same thing

this function is defined as this:


int spellsIsImmuneToDrown(object oCreature)
{//undead, construct and any creature that doesn't breath or can breath water are immune to the drown effect
   switch(GetRacialType(oCreature))
   {
   case RACIAL_TYPE_UNDEAD:
   case RACIAL_TYPE_CONSTRUCT:
   case RACIAL_TYPE_ELEMENTAL:
   case RACIAL_TYPE_OOZE:
       return TRUE;
   }
   switch(GetAppearanceType(oCreature))
   {
   case APPEARANCE_TYPE_WYRMLING_BLACK:
   case APPEARANCE_TYPE_WYRMLING_GREEN:
   case APPEARANCE_TYPE_WYRMLING_BRONZE:
   case APPEARANCE_TYPE_WYRMLING_GOLD:
   case APPEARANCE_TYPE_DRAGON_BLACK:
   case APPEARANCE_TYPE_DRAGON_GREEN:
   case APPEARANCE_TYPE_DRAGON_BRONZE:
   case APPEARANCE_TYPE_DRAGON_GOLD:
   case APPEARANCE_TYPE_SAHUAGIN:
   case APPEARANCE_TYPE_SAHUAGIN_CLERIC:
   case APPEARANCE_TYPE_SAHUAGIN_LEADER:
   case APPEARANCE_TYPE_SEA_HAG:
   case APPEARANCE_TYPE_MEPHIT_OOZE:
   case APPEARANCE_TYPE_MEPHIT_WATER:
   case APPEARANCE_TYPE_SHARK_GOBLIN:
   case APPEARANCE_TYPE_SHARK_MAKO:
   case APPEARANCE_TYPE_SHARK_HAMMERHEAD:
       return TRUE;
   }
   return GetLocalInt(oCreature,"IMMUNITY_DROWN");
}


               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Setting a variable on PC which lasts as long as a polymorph?
« Reply #2 on: February 24, 2014, 02:10:31 pm »


               Whoa, clever. I didn't think about appearance type fullfilling the role of a variable, but hey, why not?
That's even better, because I don't need to modify all the water elemental blueprints (including summonings) to make them immune to drowning.

I'm using 1.70, is full release of 1.71 out yet? If so, I gotta check it out. I want to download a full version once it's out, as I'd like a Polish translation included in it. Until then, I'm fine with 1.70. '<img'>

Anyway, thanks!
               
               

               


                     Modifié par Grani, 24 février 2014 - 02:11 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Setting a variable on PC which lasts as long as a polymorph?
« Reply #3 on: February 24, 2014, 02:16:38 pm »


               Why not just check to see if the PC is polymorphed instead of setting a variable?
 
EDIT:  oops to late.
               
               

               


                     Modifié par Lightfoot8, 24 février 2014 - 02:17 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Setting a variable on PC which lasts as long as a polymorph?
« Reply #4 on: February 24, 2014, 05:31:46 pm »


               Another way to handle this is to create a custom 2DA which is linked to appearance. I created appearance_x, and added a bunch of additional columns for data I wanted associated with each appearance: AQUATIC, SOFTBODIED, FLYING and so on.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Setting a variable on PC which lasts as long as a polymorph?
« Reply #5 on: February 24, 2014, 06:22:47 pm »


               

henesua wrote...

Another way to handle this is to create a custom 2DA which is linked to appearance. I created appearance_x, and added a bunch of additional columns for data I wanted associated with each appearance: AQUATIC, SOFTBODIED, FLYING and so on.


Interesting. I've been debating the best way to do a GetIsFlier function. I still think appearance is likely the way to go, since you're going to wind up modifying it if you add new appearances to your mod, and it's probably simpler and easier to access that information in code (though probably not much faster, these days).

Funky
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Setting a variable on PC which lasts as long as a polymorph?
« Reply #6 on: February 25, 2014, 03:49:05 am »


               

For me its just a matter of when I want to manage the information, and whether I want others to have the ability to modify it.


 


Also i am not using CEP, and I mess with custom content a lot, so in my case its easier to manage the data when the creature is imported into the HAKs. I go over all of the appearance 2da at once, and then I'm done.