Author Topic: Protection from Petrification  (Read 528 times)

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Protection from Petrification
« on: July 15, 2011, 02:14:14 am »


               This one is giving me trouble and believe me I know it's ugly too...
It seems to work except for beholders. they plow right through and your done (I run it on a PW and hardcore so when your petrified your stuck unless someone can help, and many of my players are loners)

so I wanted to make a ring of protection from petrification but me and effect stacking and removing are difficult for my fragile mind.
thus i have (tagbased script)
/////////////////////////////////////////////////////

#include "x2_inc_switches"
void main()
{
  object oPC = GetPCItemLastEquippedBy();
  int nEvent = GetUserDefinedItemEventNumber();
  if (nEvent == X2_ITEM_EVENT_EQUIP)
      {
    effect eEffect1 = EffectSpellImmunity(SPELLABILITY_TOUCH_PETRIFY);
    effect eEffect4 = EffectImmunity(EFFECT_TYPE_PETRIFY);
    effect eEffect2 = EffectSpellImmunity(SPELLABILITY_GAZE_PETRIFY);
    effect eEffect3 = EffectSpellImmunity(SPELLABILITY_BREATH_PETRIFY);
    effect eEffect3 = EffectSpellImmunity(SPELLABILITY_BREATH_PETRIFY);
    effect eStoned1 = SupernaturalEffect(eEffect1);
    effect eStoned2 = SupernaturalEffect(eEffect2);
    effect eStoned3 = SupernaturalEffect(eEffect3);
    effect eStoned4 = SupernaturalEffect(eEffect4);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eStoned1, oPC);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eStoned2, oPC);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eStoned3, oPC);
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, eStoned4, oPC);
      return;
       }
   else if (nEvent == X2_ITEM_EVENT_UNEQUIP)
      {
      object oPC = GetPCItemLastUnequippedBy();
      effect eStoned = GetFirstEffect(oPC);
             while (GetIsEffectValid(eStoned))
               {
               if (GetEffectType(eStoned) == EFFECT_TYPE_SPELL_IMMUNITY|| GetEffectType(eStoned) == EFFECT_TYPE_IMMUNITY)
               RemoveEffect(oPC, eStoned);
               eStoned = GetNextEffect(oPC);
               }
       }
}
now I know this also removes all other immunitys on given character...but thats another story 'Image..
so could you all maybe help me understand why it doesnt work for beholder rays..I feel like my players might pillage and burn my town'Image because i have merchants that sell this crap for a boatload of *cha-ching*
help..
               
               

               
            

Legacy__six

  • Hero Member
  • *****
  • Posts: 1436
  • Karma: +0/-0
Protection from Petrification
« Reply #1 on: July 15, 2011, 02:57:15 am »


               If you look in the library x0_i0_spells, at the function spellsIsImmuneToPetrification, just adding a check for the item by tag on the target oCreature should work for pretty much any spell. Return true if the item is a valid object.

The beholder's petrify ray effect references that function, as well as the SoU spells and abilities. It will mean recompiling all of the relevant spell scripts too, though, for the library changes to take effect. You could also add the check into those spell scripts manually if you wanted, but that'd have the same effect.

Either way will fix the removal of immunity bug, since immunity effects wouldn't be necessary at all. In fact, all the standard function does is return true if the creature appearance type is one of several non-fleshy creatures such as golems. Rather than blocking the effect itself, it actually causes the spells to never apply a petrify effect anyway.
               
               

               


                     Modifié par _six, 15 juillet 2011 - 02:00 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Protection from Petrification
« Reply #2 on: July 15, 2011, 03:12:15 am »


               _six beat me to it.   His responce is the best answer in my book.  

To answer your original question however be for the beholder you would need to use.  
EffectSpellImmunity(778); // BEHOLDER_RAY_PETRI

also you would want to link all the effects so that if one was removed they all would be removed at the same time.   That is all moot point however.  _Six has your solution.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Protection from Petrification
« Reply #3 on: July 15, 2011, 03:34:06 am »


               Of cource another option would be to just give them immunity to the entire Spell School (Transmutation )  

Unfortantly that also would not catch the beholder ray.  which was somehow placed in the Enchantment  school ( That is a Bug to me.)
               
               

               
            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Protection from Petrification
« Reply #4 on: July 15, 2011, 05:30:02 am »


               I am still having difficulty here, I tried adding the check to x0_i0_spells and rebuilt my test mod.
i created a simple ring with the tag "protpetrify"

i edited the chunk of code in the above
/////////////////////////////////
// * returns true if the creature has flesh
int spellsIsImmuneToPetrification(object oCreature)
{
int nAppearance = GetAppearanceType(oCreature);
if (GetTag(GetItemInSlot(INVENTORY_SLOT_RIGHTRING, oCreature)) == "protpetrify" || GetTag(GetItemInSlot(INVENTORY_SLOT_LEFTRING, oCreature)) != "protpetrify")
{
int bImmune = TRUE;
}
switch (nAppearance)
{
case APPEARANCE_TYPE_BASILISK:
case APPEARANCE_TYPE_cockatrice:
case APPEARANCE_TYPE_MEDUSA:
case APPEARANCE_TYPE_ALLIP:
case APPEARANCE_TYPE_ELEMENTAL_AIR:
case APPEARANCE_TYPE_ELEMENTAL_AIR_ELDER:
case APPEARANCE_TYPE_ELEMENTAL_EARTH:
case APPEARANCE_TYPE_ELEMENTAL_EARTH_ELDER:
case APPEARANCE_TYPE_ELEMENTAL_FIRE:
case APPEARANCE_TYPE_ELEMENTAL_FIRE_ELDER:
case APPEARANCE_TYPE_ELEMENTAL_WATER:
case APPEARANCE_TYPE_ELEMENTAL_WATER_ELDER:
case APPEARANCE_TYPE_GOLEM_STONE:
case APPEARANCE_TYPE_GOLEM_IRON:
case APPEARANCE_TYPE_GOLEM_CLAY:
case APPEARANCE_TYPE_GOLEM_BONE:
case APPEARANCE_TYPE_GORGON:
case APPEARANCE_TYPE_HEURODIS_LICH:
case APPEARANCE_TYPE_LANTERN_ARCHON:
case APPEARANCE_TYPE_SHADOW:
case APPEARANCE_TYPE_SHADOW_FIEND:
case APPEARANCE_TYPE_SHIELD_GUARDIAN:
case APPEARANCE_TYPE_SKELETAL_DEVOURER:
case APPEARANCE_TYPE_SKELETON_CHIEFTAIN:
case APPEARANCE_TYPE_SKELETON_COMMON:
case APPEARANCE_TYPE_SKELETON_MAGE:
case APPEARANCE_TYPE_SKELETON_PRIEST:
case APPEARANCE_TYPE_SKELETON_WARRIOR:
case APPEARANCE_TYPE_SKELETON_WARRIOR_1:
case APPEARANCE_TYPE_SPECTRE:
case APPEARANCE_TYPE_WILL_O_WISP:
case APPEARANCE_TYPE_WRAITH:
case APPEARANCE_TYPE_BAT_HORROR:
case 405: // Dracolich:
case 415: // Alhoon
case 418: // shadow dragon
case 420: // mithral golem
case 421: // admantium golem
case 430: // Demi Lich
case 469: // animated chest
case 474: // golems
case 475: // golems
bImmune = TRUE;
}
////////////////////////////////////////////

but its still not working, at least for Gorgans breath petrify which was the first one I tested...
gorgan, medusa, beholder, basilisk, cockatrice
               
               

               


                     Modifié par lordofworms, 15 juillet 2011 - 04:30 .
                     
                  


            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Protection from Petrification
« Reply #5 on: July 15, 2011, 05:41:53 am »


               if (GetTag(GetItemInSlot(INVENTORY_SLOT_RIGHTRING, oCreature)) == "protpetrify" || GetTag(GetItemInSlot(INVENTORY_SLOT_LEFTRING, oCreature)) != "protpetrify")

one is "==" and the other ring checks "!=".  I'd assume by that code if the ring was on the left hand it would return false.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Protection from Petrification
« Reply #6 on: July 15, 2011, 01:10:48 pm »


               my patch allows to make a creature complete immune against all petrify effects just via variable

this is however possible to use only if yours spells are not heavily modified (or at least flesh to stone and all other petrify spellscripts)
               
               

               
            

Legacy__six

  • Hero Member
  • *****
  • Posts: 1436
  • Karma: +0/-0
Protection from Petrification
« Reply #7 on: July 15, 2011, 01:34:31 pm »


                I don't think standard scripts will compile unless you actually edit the scripts manually (and thus create a module copy). Building the module will only affect scripts that exist in the module.
               
               

               


                     Modifié par _six, 15 juillet 2011 - 12:34 .
                     
                  


            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Protection from Petrification
« Reply #8 on: July 15, 2011, 02:06:53 pm »


               Hellow ShadoOoW, I haven't modified any of my spells so I will take a look at your solution..

@Six, thank you for explaining that, I wouldnt mind altering all the petrify spell scripts but I dont even know the names of them..lol
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Protection from Petrification
« Reply #9 on: July 15, 2011, 02:08:42 pm »


               Six's solution would work, but you would have to compile ALL scripts that use the spellsIsImmuneToPetrification function from x0_i0_spells. So, since you have to edit the scripts anyway....

What I would do is edit the various scripts that apply petrification so that if the target has the ring equipped then the script aborts.

You could also do this via spellhook to an extent, but the s1 and s2 series of spell effect scripts aren't routed through the spellhook.

You can find the names of the scripts by looking in the spells.2da. I think there are only about a half dozen that apply petrify effects (including the beholder ray attack).
               
               

               


                     Modifié par Pstemarie, 15 juillet 2011 - 02:49 .
                     
                  


            

Legacy__six

  • Hero Member
  • *****
  • Posts: 1436
  • Karma: +0/-0
Protection from Petrification
« Reply #10 on: July 15, 2011, 03:18:00 pm »


               

Pstemarie wrote...

Six's solution would work, but you would have to compile ALL scripts that link to x0_i0_spells. So....


No you wouldn't. Scripts just copy over the stuff from the include on compile. Editing an include won't affect any scripts that you don't compile in any way. And since the changes won't affect anything that doesn't call the edited function, compiling wouldn't change them regardless.

The scripts I can find are:
x0_s1_petrbreath
x0_s1_petrgaze
x0_s1_petrtouch
x2_s1_petrgaze
x2_s1_beholdray

All I did to find these out was look for "petr" to open in the script editor (with the exception of x2_s1_beholdray which I knew about from messing with anyway). spells.2da is also a good place to look if you find any spell scripts missing from that.
               
               

               


                     Modifié par _six, 15 juillet 2011 - 02:22 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Protection from Petrification
« Reply #11 on: July 15, 2011, 03:47:14 pm »


               I meant all the petrify scripts that linked back to x0_i0_spells. I'll fix my post now '<img'>

I generally prefer (at least at present) not to modify the default libraries (includes) if I can help it. Its far safer to dupe the function in your own include, modify it, then modify whatever scripts you need to use the new function.
               
               

               


                     Modifié par Pstemarie, 15 juillet 2011 - 02:54 .
                     
                  


            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Protection from Petrification
« Reply #12 on: July 15, 2011, 03:56:24 pm »


               Thnx everyone! I finally got it working I added this check to all the above scripts Six mentioned as well as.

x0_i0_petrify

if (GetTag(GetItemInSlot(INVENTORY_SLOT_RIGHTRING, oTarget)) == "protpetrify" || GetTag(GetItemInSlot(INVENTORY_SLOT_LEFTRING, oTarget)) == "protpetrify")
   {
   FloatingTextStringOnCreature("DEBUG:Called petrify effect", oTarget, FALSE) ;
   return;
   }


Thank you all !!! very painless to setup!! for once...lol
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Protection from Petrification
« Reply #13 on: July 15, 2011, 04:02:14 pm »


               Flesh to Stone spell: x0_s0_fleshsto
               
               

               
            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
Protection from Petrification
« Reply #14 on: July 15, 2011, 08:50:54 pm »


               Thanks Failed.Bard *wink*
just added that one to the mix as well