Code: Select all
function IsImmunedFromThisDamageType( who, byref dmg, attack_type )
var immunities := GetObjProperty( who, PROPID_MOBILE_ATTACK_TYPE_IMMUNITIES );
if( !immunities )
return 0;
endif
if( attack_type & DMGID_NO_RESIST )
return 0;
endif
var attack_amount := 0;
var is_immuned_amount := 0;
foreach bit in { DMGID_FIRE, DMGID_AIR, DMGID_EARTH, DMGID_WATER, DMGID_NECRO, DMGID_HOLY, DMGID_POISON, DMGID_ACID, DMGID_PHYSICAL, DMGID_MAGIC, DMGID_ASTRAL }
if( attack_type & bit )
attack_amount := attack_amount + 1;
if( immunities & bit )
is_immuned_amount := is_immuned_amount + 1;
endif
endif
endforeach
if( !attack_amount || attack_amount = is_immuned_amount )
return 1;
else
dmg := Cint( dmg * Cint(attack_amount-is_immuned_amount) / attack_amount );
return 0;
endif
endfunction-PROPID_MOBILE_ATTACK_TYPE_IMMUNITIES is an integer stored in a CProp on the mobile. That CProp is either i256 or i639. No other values appear in any npc definitions.
At the top of the function there exist some declarations:
Code: Select all
const DMGID_FIRE := 0x0001;
const DMGID_AIR := 0x0002;
const DMGID_EARTH := 0x0004;
const DMGID_WATER := 0x0008;
const DMGID_NECRO := 0x0010;
const DMGID_HOLY := 0x0020;
const DMGID_POISON := 0x0040;
const DMGID_ACID := 0x0080;
const DMGID_PHYSICAL := 0x0100;
const DMGID_MAGIC := 0x0200;
const DMGID_ASTRAL := 0x0400;
const DMGID_NO_RESIST := 0x0800;These constants are also the values which the variable attack_type can take.