Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


New Premium Module: Tyrants of the Moonsea! Read More
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

"GetIsImmune" for a damage type - how to?

sippelmcsippelmc 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!


  • badstrrefbadstrref Member Posts: 120
    feasible with loops, and 2da's

  • TerrorbleTerrorble Member Posts: 74
    If it is a select few dragon types and you know what they will be then you could determine immunities and weaknesses by appearance.

  • FreshLemonBunFreshLemonBun Member Posts: 751
    First you have to understand what you're looking for. In the case of dragons the energy type immunities are item properties of the creature skin worn in the creature skin slot. So what you need to look for are the item properties.

    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.

  • sippelmcsippelmc Member Posts: 45
    edited May 2018
    Thanks all. I was trying to keep it simple in my example with dragons as I have other creatures and various immunities I'd like to check for; it looks like I'll have to cycle through itemproperties on creature skins. Was hoping for a quick win but alas! Thanks again for the replies and thanks FreshLemon for the great headstart.

Sign In or Register to comment.