Found another bug (v1.1)…
When I have multiple items giving me a damage immunity equaling more that 100%, the immunity is cancelled (i.e. no immunity).
The problem was residing in the “clangfix_equip” script.
I changed this portion of the script…
void FixIMM(object oPC)
{
object oEQUIP;
effect eFX;
int nEQUIP;
int nITEM;
int nTOTAL;
int nELEMENT = 1; //DAMAGE_TYPE_BLUDGEON is 1, the first of the valid damage types.
while (nELEMENT < 2050) //DAMAGE_TYPE_SONIC is 2048 and they progress as power of 2.
{
nEQUIP = 0;
nTOTAL = 0;
while (nEQUIP < 18)
{
oEQUIP = GetItemInSlot(nEQUIP, oPC);
nTOTAL = nTOTAL + GetLocalInt(oEQUIP, "CLANGFIX_ELEMENT_" + IntToString(nELEMENT));
nEQUIP = nEQUIP + 1;
}
if (nTOTAL > 99) eFX = EffectLinkEffects(eFX, EffectDamageResistance(nELEMENT, 9999));
else if (nTOTAL > 0) eFX = EffectLinkEffects(eFX, EffectDamageImmunityIncrease(nELEMENT, nTOTAL));
else if (nTOTAL < 0) eFX = EffectLinkEffects(eFX, EffectDamageImmunityDecrease(nELEMENT, -nTOTAL));
nELEMENT = nELEMENT * 2;
}
ApplyEffectToObjectFaster(oPC, eFX, -1.0, SUBTYPE_SUPERNATURAL, CLANG_FXEQUIP);
}
To this…
void FixIMM(object oPC)
{
object oEQUIP;
effect eFX;
int nEQUIP;
int nITEM;
int nTOTAL;
int nELEMENT = 1; //DAMAGE_TYPE_BLUDGEON is 1, the first of the valid damage types.
while (nELEMENT < 2050) //DAMAGE_TYPE_SONIC is 2048 and they progress as power of 2.
{
nEQUIP = 0;
nTOTAL = 0;
while (nEQUIP < 18)
{
oEQUIP = GetItemInSlot(nEQUIP, oPC);
nTOTAL = nTOTAL + GetLocalInt(oEQUIP, "CLANGFIX_ELEMENT_" + IntToString(nELEMENT));
nEQUIP = nEQUIP + 1;
}
if (nTOTAL > 0) eFX = EffectLinkEffects(eFX, EffectDamageImmunityIncrease(nELEMENT, nTOTAL));
else if (nTOTAL < 0) eFX = EffectLinkEffects(eFX, EffectDamageImmunityDecrease(nELEMENT, -nTOTAL));
nELEMENT = nELEMENT * 2;
}
ApplyEffectToObjectFaster(oPC, eFX, -1.0, SUBTYPE_SUPERNATURAL, CLANG_FXEQUIP);
}
EffectDamageResistance was causing the issue. So I removed it and just used the EffectDamageImmunityIncrease, which appears to cap at 100%, which is what we want.
Needs confirmation.
FYI - EffectDamageImmunityDecrease appears to cap at -100%. This is used for Damage Vulnerability.
On a side note - If you have both Damage Immunity and Damage Reduction, the immunity percentage is taken into account first. I wasn’t sure if that was the case. But while testing this, it was indeed.