Aller au contenu

Photo

Problems detecting damage immunity item property


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

#1
manageri

manageri
  • Members
  • 394 messages
This should be simple but for some reason it just won't work. What I'm doing is raising all of a creature's damage immunity stats to 50%, as in making it only take half damage from all sources. That works fine unless a creature already has some damage immunity, because for some reason, it seems that if you raise damage immunity over 100%, the creature starts taking extra damage from that source. This causes problems against, for example, fire elementals, who already have 100% fire immunity in their creature hide.

To avoid this I'm trying to have the script scan all the target's equipped items for 100% damage immunity effects, and if it finds one, change my script's matching damage immunity effect to EffectDarkVision (randomly picked useless effect). As far as I can tell, the problem is detecting the damage immunity item property. I've checked that the script does look through the equipped items and their properties, it just won't detect the fire immunity iprop on the elemental I've been testing with (yes, I did make sure the elemental has a hide with fire immunity), so the script still keeps applying the default +50% fire damage immunity effect on it and making it take extra fire damage. What am I doing wrong here? I'll only the post the parts relevant to the problem:

int nDamageImmunityPercent = 50;
effect eDamageImmunity1 = EffectDamageImmunityIncrease(DAMAGE_TYPE_ACID, nDamageImmunityPercent);
effect eDamageImmunity2 = EffectDamageImmunityIncrease(DAMAGE_TYPE_BLUDGEONING, nDamageImmunityPercent);
// Same thing with all possible damage types, won't post all. Skipping to relevant part

for(nSlotNum = 0; nSlotNum < NUM_INVENTORY_SLOTS; nSlotNum++)
       {
       oItem = GetItemInSlot(nSlotNum, oTarget);
       if(GetIsObjectValid(oItem))
          {
          iProp = GetFirstItemProperty(oItem);              
          while (GetIsItemPropertyValid(iProp))
                 {
                        if (iProp == ItemPropertyDamageImmunity(DAMAGE_TYPE_ACID, 100)) 
//Here's the problem
                        {
                        eDamageImmunity1 = EffectDarkVision();
                        }
                    else if (iProp == ItemPropertyDamageImmunity(DAMAGE_TYPE_FIRE, 100))
                        {
                        eDamageImmunity6 = EffectDarkVision();
                        }
                        // All damage types again...

                        iProp = GetNextItemProperty(oItem);
                 }
          }
    }
            eLink = eDamageImmunity1;
            eLink = EffectLinkEffects(eLink, eDamageImmunity2);
            eLink = EffectLinkEffects(eLink, eDamageImmunity3);
            // all damage types again...
            eLink = SupernaturalEffect(eLink);    
            eLink = SetEffectSpellId(eLink, nSpellId);
                        
               ApplyEffectToObject(DURATION_TYPE_PERMANENT, eLink, oTarget);

Modifié par manageri, 02 octobre 2013 - 10:27 .


#2
manageri

manageri
  • Members
  • 394 messages
I think I figured it out.

#3
-Semper-

-Semper-
  • Members
  • 2 259 messages
what about posting your solution here to help others who run into this wall later? or to remind you how you did it if you forget it someday?

#4
manageri

manageri
  • Members
  • 394 messages
Sure. So I changed...

if (iProp == ItemPropertyDamageImmunity(DAMAGE_TYPE_ACID, 100))

...which didn't work for whatever reason, to...

if (GetItemHasItemProperty(oItem, ITEM_PROPERTY_IMMUNITY_DAMAGE_TYPE) 
	  && GetItemPropertySubType(iProp) == 8)

The number 8 there is the row from the iprp_dmgtypes.2da, in this case fire. Using the typical DAMAGE_TYPE_* constants won't work for item properties, it would seem. This wasn't a perfect fix for my problem since it also detects and changes any damage vulnerabilities on the creature. For example it sees a fire elemental's cold vulnerability as a damage immunity effect and won't reduce the cold damage it takes like I'd want. I also had it falsely identify divine, bludgeoning and piercing immunities on the creature, which I suspect is just something being broken with the function as everything else works and uses identical code. Luckily very few (probably no) creatures should ever have any damage immunity against those damage types (just reduction or resistance) so I simply commented those lines out, meaning the initial +50% goes through.