"GetIsImmune" for a damage type - how to?
sippelmc
Member Posts: 45
Hi all,
I'm looking for a scripting way to determine if a creature has a damage type immunity. GetIsImmune doesn't seem to work for damage types, e.g., fire. Is there any quick way to check? I'm just wondering if there is a command I am not finding - or is the best way to just cycle through effects, probably with a helper function?
My use case is I want a script against dragons, and check their immunities / vulnerabilities via script, e.g., if there is a red dragon I want to be able to discover via script it has 50% immunity to DAMAGE_TYPE_FIRE, and optionally a bonus would be if I could also discover its 50% vulnerability to DAMAGE_TYPE_COLD. Thanks so much!
I'm looking for a scripting way to determine if a creature has a damage type immunity. GetIsImmune doesn't seem to work for damage types, e.g., fire. Is there any quick way to check? I'm just wondering if there is a command I am not finding - or is the best way to just cycle through effects, probably with a helper function?
My use case is I want a script against dragons, and check their immunities / vulnerabilities via script, e.g., if there is a red dragon I want to be able to discover via script it has 50% immunity to DAMAGE_TYPE_FIRE, and optionally a bonus would be if I could also discover its 50% vulnerability to DAMAGE_TYPE_COLD. Thanks so much!
0
Comments
You can use object oSkin = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oCreature) to get oCreature's skin item. Then use an item property loop such as:
itemproperty ipImmunity = GetFirstItemProperty(oSkin);
while (GetIsItemPropertyValid(ipImmunity))
{
//do item property checks here
ipImmunity = GetNextItemProperty(oSkin);
}
You'll first need GetItemPropertyType(ipImmunity) which returns a like number in I think itempropsdef.2da which should be 20 for damage immunity and 24 for vulnerability, then GetItemPropertySubtype(ipImmunity) should return the type of damage immunity in iprp_damagetype.2da. Finally using GetItemPropertyCostTableValue(ipImmunity) returns the id for the amount. Looking in itempropsdef.2da we see that 5 is the cost table for damage immunity and 22 for damage vulnerability. In iprp_costtable.2da we can see 5 refers to iprp_immuncost.2da and 22 refers to iprp_damvulcost.2da. So looking in each file we find that 1 = 5%, 2 = 10%, 3 = 25%, 4 = 50%, 5 = 75%, 6 = 90%, 7 = 100% for damage immunity levels, and damage vulnerability seems to have the same values. So GetItemPropertyCostTableValue(ipImmunity) will return one of those values for either vulnerability or immunity.
Depending on how you want to structure it that should give you all the information you need. The item property type is either immunity or vulnerability, the sub type is fire or cold or bludgeoning etc. and the cost table value should be percentage of immunity/vulnerability.