-
-------- Detect Targets Defense type --------
-
Custom script: set DefenseTypeTemp = BlzGetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_DEFENSE_TYPE)
-
Custom script: if (DefenseTypeTemp == 0) then
-
Set VariableSet DEFENSE_TYPE_LIGHT = True
-
Custom script: elseif (DefenseTypeTemp == 1) then
-
Set VariableSet DEFENSE_TYPE_MEDIUM = True
-
Custom script: elseif (DefenseTypeTemp == 2) then
-
Set VariableSet DEFENSE_TYPE_HEAVY = True
-
Custom script: elseif (DefenseTypeTemp == 3) then
-
Set VariableSet DEFENSE_TYPE_FORTIFIED = True
-
Custom script: elseif (DefenseTypeTemp == 4) then
-
Set VariableSet DEFENSE_TYPE_NORMAL = True
-
Custom script: elseif (DefenseTypeTemp == 5) then
-
Set VariableSet DEFENSE_TYPE_HERO = True
-
Custom script: elseif (DefenseTypeTemp == 6) then
-
Set VariableSet DEFENSE_TYPE_DIVINE = True
-
Custom script: else
-
Set VariableSet DEFENSE_TYPE_UNARMORED = True
-
Custom script: endif
-
-------- Detect Targets Armor type --------
-
Custom script: set ArmorTypeTemp = BlzGetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_ARMOR_TYPE)
-
Custom script: if (ArmorTypeTemp == 1) then
-
Set VariableSet ARMOR_TYPE_FLESH = True
-
Custom script: elseif (ArmorTypeTemp == 2) then
-
Set VariableSet ARMOR_TYPE_METAL = True
-
Custom script: elseif (ArmorTypeTemp == 3) then
-
Set VariableSet ARMOR_TYPE_WOOD = True
-
Custom script: elseif (ArmorTypeTemp == 4) then
-
Set VariableSet ARMOR_TYPE_ETHEREAL = True
-
Custom script: elseif (ArmorTypeTemp == 5) then
-
Set VariableSet ARMOR_TYPE_STONE = True
-
Custom script: else
-
Set VariableSet ARMOR_TYPE_NONE = True
-
Custom script: endif
-
-------- Detect Attack Type --------
-
Custom script: if udg_DamageEventAttackT == ATTACK_TYPE_NORMAL then
-
Set VariableSet ATTACK_TYPE_SPELLS = True
-
Custom script: elseif udg_DamageEventAttackT == ATTACK_TYPE_MELEE then
-
Set VariableSet ATTACK_TYPE_NORMAL = True
-
Custom script: elseif udg_DamageEventAttackT == ATTACK_TYPE_PIERCE then
-
Set VariableSet ATTACK_TYPE_PIERCE = True
-
Custom script: elseif udg_DamageEventAttackT == ATTACK_TYPE_SIEGE then
-
Set VariableSet ATTACK_TYPE_SIEGE = True
-
Custom script: elseif udg_DamageEventAttackT == ATTACK_TYPE_MAGIC then
-
Set VariableSet ATTACK_TYPE_MAGIC = True
-
Custom script: elseif udg_DamageEventAttackT == ATTACK_TYPE_CHAOS then
-
Set VariableSet ATTACK_TYPE_CHAOS = True
-
Custom script: elseif udg_DamageEventAttackT == ATTACK_TYPE_HERO then
-
Set VariableSet ATTACK_TYPE_HERO = True
-
Custom script: endif
-
-------- Detect Damage Type --------
-
Custom script: if udg_DamageEventDamageT == DAMAGE_TYPE_UNKNOWN then
-
Set VariableSet DAMAGE_TYPE_UNKNOWN = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_NORMAL then
-
Set VariableSet DAMAGE_TYPE_NORMAL = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_ENHANCED then
-
Set VariableSet DAMAGE_TYPE_ENCHANCED = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_FIRE then
-
Set VariableSet DAMAGE_TYPE_FIRE = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_COLD then
-
Set VariableSet DAMAGE_TYPE_COLD = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_LIGHTNING then
-
Set VariableSet DAMAGE_TYPE_LIGHTNING = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_POISON then
-
Set VariableSet DAMAGE_TYPE_POISON = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_DISEASE then
-
Set VariableSet DAMAGE_TYPE_DISEASE = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_DIVINE then
-
Set VariableSet DAMAGE_TYPE_DIVINE = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_MAGIC then
-
Set VariableSet DAMAGE_TYPE_MAGIC = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_SONIC then
-
Set VariableSet DAMAGE_TYPE_SONIC = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_ACID then
-
Set VariableSet DAMAGE_TYPE_ACID = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_FORCE then
-
Set VariableSet DAMAGE_TYPE_FORCE = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_DEATH then
-
Set VariableSet DAMAGE_TYPE_DEATH = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_MIND then
-
Set VariableSet DAMAGE_TYPE_MIND = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_PLANT then
-
Set VariableSet DAMAGE_TYPE_PLANT = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_DEFENSIVE then
-
Set VariableSet DAMAGE_TYPE_DEFENSIVE = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_DEMOLITION then
-
Set VariableSet DAMAGE_TYPE_DEMOLITION = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_SLOW_POISON then
-
Set VariableSet DAMAGE_TYPE_SLOW_POISON = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_SPIRIT_LINK then
-
Set VariableSet DAMAGE_TYPE_SPIRIT_LINK = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_SHADOW_STRIKE then
-
Set VariableSet DAMAGE_TYPE_SHADOW_STRIKE = True
-
Custom script: elseif udg_DamageEventDamageT == DAMAGE_TYPE_UNIVERSAL then
-
Set VariableSet DAMAGE_TYPE_UNIVERSAL = True
-
Custom script: endif
-
-------- Detect Weapon Type --------
-
Custom script: if WeaponType == WEAPON_TYPE_METAL_LIGHT_CHOP then
-
Custom script: set WeaponTypeIndex = 1
-
Set VariableSet WEAPON_TYPE_ML_CHOP = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_METAL_MEDIUM_CHOP then
-
Custom script: set WeaponTypeIndex = 2
-
Set VariableSet WEAPON_TYPE_MM_CHOP = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_METAL_HEAVY_CHOP then
-
Custom script: set WeaponTypeIndex = 3
-
Set VariableSet WEAPON_TYPE_MH_CHOP = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_METAL_LIGHT_SLICE then
-
Custom script: set WeaponTypeIndex = 4
-
Set VariableSet WEAPON_TYPE_ML_SLICE = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_METAL_MEDIUM_SLICE then
-
Custom script: set WeaponTypeIndex = 5
-
Set VariableSet WEAPON_TYPE_MM_SLICE = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_METAL_HEAVY_SLICE then
-
Custom script: set WeaponTypeIndex = 6
-
Set VariableSet WEAPON_TYPE_MH_SLICE = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_METAL_MEDIUM_BASH then
-
Custom script: set WeaponTypeIndex = 7
-
Set VariableSet WEAPON_TYPE_MM_BASH = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_METAL_HEAVY_BASH then
-
Custom script: set WeaponTypeIndex = 8
-
Set VariableSet WEAPON_TYPE_MH_BASH = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_METAL_MEDIUM_STAB then
-
Custom script: set WeaponTypeIndex = 9
-
Set VariableSet WEAPON_TYPE_MM_STAB = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_METAL_HEAVY_STAB then
-
Custom script: set WeaponTypeIndex = 10
-
Set VariableSet WEAPON_TYPE_MH_STAB = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_WOOD_LIGHT_SLICE then
-
Custom script: set WeaponTypeIndex = 11
-
Set VariableSet WEAPON_TYPE_WL_SLICE = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_WOOD_MEDIUM_SLICE then
-
Custom script: set WeaponTypeIndex = 12
-
Set VariableSet WEAPON_TYPE_WM_SLICE = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_WOOD_HEAVY_SLICE then
-
Custom script: set WeaponTypeIndex = 13
-
Set VariableSet WEAPON_TYPE_WH_SLICE = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_WOOD_LIGHT_BASH then
-
Custom script: set WeaponTypeIndex = 14
-
Set VariableSet WEAPON_TYPE_WL_BASH = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_WOOD_MEDIUM_BASH then
-
Custom script: set WeaponTypeIndex = 15
-
Set VariableSet WEAPON_TYPE_WM_BASH = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_WOOD_HEAVY_BASH then
-
Custom script: set WeaponTypeIndex = 16
-
Set VariableSet WEAPON_TYPE_WH_BASH = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_WOOD_LIGHT_STAB then
-
Custom script: set WeaponTypeIndex = 17
-
Set VariableSet WEAPON_TYPE_WL_STAB = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_WOOD_MEDIUM_STAB then
-
Custom script: set WeaponTypeIndex = 18
-
Set VariableSet WEAPON_TYPE_WM_STAB = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_CLAW_LIGHT_SLICE then
-
Custom script: set WeaponTypeIndex = 19
-
Set VariableSet WEAPON_TYPE_CL_SLICE = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_CLAW_MEDIUM_SLICE then
-
Custom script: set WeaponTypeIndex = 20
-
Set VariableSet WEAPON_TYPE_CM_SLICE = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_CLAW_HEAVY_SLICE then
-
Custom script: set WeaponTypeIndex = 21
-
Set VariableSet WEAPON_TYPE_CH_SLICE = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_AXE_MEDIUM_CHOP then
-
Custom script: set WeaponTypeIndex = 22
-
Set VariableSet WEAPON_TYPE_AM_CHOP = True
-
Custom script: elseif WeaponType == WEAPON_TYPE_ROCK_HEAVY_BASH then
-
Custom script: set WeaponTypeIndex = 23
-
Set VariableSet WEAPON_TYPE_RH_BASH = True
-
Custom script: else
-
Set VariableSet WEAPON_TYPE_NONE = True
-
Custom script: endif
-
-------- End Damage Type Detecting --------
The trigger reeks of if-then statements (There are too many of them). As far as code inspection goes, all of that
set WeaponTypeIndex
fiasco can be reduced to
set WeaponTypeIndex = GetHandleId(WeaponType)
Given the current setup, if a new damage type, attack type, or armor type would be introduced (unlikely, though), the system will have to be updated to accommodate for that. This would be tedious to maintain or update if any bug arises, in conjunction with using the system or due to the system itself.
Considering the way weapon type is modified, it would appear that when changing the weapon type, the weapon type with the smallest index will be assigned to the damage instance, as opposed to the latest weapon type taking precedence. As shown below (this is assuming that there are at least 2 triggers modifying weapon type).
-
Set VariableSet WEAPON_TYPE_ML_CHOP = true
-
-------- Some other trigger running --------
-
Set VariableSet WEAPON_TYPE_MM_CHOP = true
This would apply the first weapon type WEAPON_TYPE_ML_CHOP (index 1), as opposed to WEAPON_TYPE_MM_CHOP (index 2). In this case, the most recent assignment to the weapon type is not respected. Doing the same thing with Bribe's Damage Engine:
-
[B] [/B]Set VariableSet DamageEventWeaponT = WEAPON_TYPE_ML_CHOP
-

-------- Some other trigger running --------
-

Set VariableSet DamageEventWeaponT = WEAPON_TYPE_MM_CHOP
The weapon type will be assigned as WEAPON_TYPE_MM_CHOP (index 2), the more recent assignment, as opposed to WEAPON_TYPE_ML_CHOP (index 1).