-------- Copy the Cheat Death Ability from Object Editor into your map and set the following variable respectively: --------
Set Variable Set DamageBlockingAbility = "A003"
-------- Copy the Detect Spell Damage Ability from Object Editor into your map and set the following variable respectively: --------
Set Variable Set SpellDamageAbility = "A002"
-------- You can add extra classifications here if you want to differentiate between your triggered damage --------
-------- Use DamageTypeExplosive (or any negative value damage type) if you want a unit killed by that damage to explode --------
Set Variable Set DamageTypeExplosive = "-1"
Set Variable Set DamageTypeCriticalStrike = "1"
Set Variable Set DamageTypeHeal = "2"
Set Variable Set DamageTypeReduced = "3"
Set Variable Set DamageTypeBlocked = "4"
Custom script: call ExecuteFunc("InitDamageEvent")
Custom script: endfunction
Custom script: function DmgEvAmplifyCheck takes nothing returns nothing
-------- The next if/else blocks handles magic damage modification --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
(DamageEventTarget is Ethereal) Equal to True
(DamageEventTarget is A Hero) Equal to False
Set Variable Set DamageEventAmount = (DamageEventAmount x 1.67)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
(Level of Elune's Grace for DamageEventTarget) Greater than 0
Set Variable Set DamageEventAmount = (DamageEventAmount x 0.80)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
(DamageEventTarget is A Hero) Equal to True
(DamageEventTarget has an item of type Runed Bracers) Equal to True
Set Variable Set DamageEventAmount = (DamageEventAmount x 0.67)
Custom script: endfunction
-------- The next conditions let you filter out units you don't want detection for. By default, units with Locust will not pass the check. --------
Custom script: function DmgEvFilter takes nothing returns boolean
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
(DmgEvUnit is A structure) Equal to False
Custom script: return GetUnitAbilityLevel(udg_DmgEvUnit, 'Aloc') == 0
Custom script: return false
Custom script: endfunction
Custom script: function DmgEvResetVars takes nothing returns nothing
Set Variable Set DmgEvRecursionN = (DmgEvRecursionN - 1)
Set Variable Set DamageEventPrevAmt = LastDmgPrevAmount[DmgEvRecursionN]
Set Variable Set DamageEventAmount = LastDmgValue[DmgEvRecursionN]
Set Variable Set DamageEventSource = LastDmgSource[DmgEvRecursionN]
Set Variable Set DamageEventTarget = LastDmgTarget[DmgEvRecursionN]
Set Variable Set IsDamageSpell = LastDmgWasSpell[DmgEvRecursionN]
Set Variable Set DamageEventType = LastDmgPrevType[DmgEvRecursionN]
Custom script: endfunction
Custom script: function CheckDamagedLifeEvent takes nothing returns nothing
Set Variable Set NextDamageOverride = "false"
Set Variable Set NextDamageType = "0"
Custom script: if udg_DmgEvTrig != null then
Custom script: call DestroyTrigger(udg_DmgEvTrig)
Custom script: set udg_DmgEvTrig = null
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
IsDamageSpell Equal to True
Unit - Set life of DamageEventTarget to (Max(LastDamageHP, 0.41))
Custom script: if udg_LastDamageHP <= 0.405 then
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DamageEventType Less than 0
Unit - Make DamageEventTarget Explode on death
Trigger - Turn off DamageEventTrigger
-------- Kill the unit --------
Custom script: call UnitDamageTarget(udg_DamageEventSource, udg_DamageEventTarget, -999, false, false, null, DAMAGE_TYPE_UNIVERSAL, null)
Trigger - Turn on DamageEventTrigger
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
(Level of DamageBlockingAbility for DamageEventTarget) Greater than 0
Unit - Remove DamageBlockingAbility from DamageEventTarget
Unit - Set life of DamageEventTarget to LastDamageHP
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DamageEventAmount Not equal to 0.00
Set Variable Set AfterDamageEvent = "0.00"
Set Variable Set AfterDamageEvent = "1.00"
Set Variable Set AfterDamageEvent = "0.00"
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DmgEvRecursionN Greater than 0
Custom script: call DmgEvResetVars()
Custom script: endfunction
Custom script: function DmgEvOnExpire takes nothing returns nothing
Set Variable Set DmgEvStarted = "false"
Custom script: call CheckDamagedLifeEvent()
Custom script: endfunction
Custom script: function OnDmgEv takes nothing returns nothing
Custom script: local boolean clear = false
Custom script: local boolean override = udg_DamageEventOverride
Custom script: local code c = function CheckDamagedLifeEvent
Custom script: call CheckDamagedLifeEvent() //in case the unit state event failed and the 0.00 second timer hasn't yet expired
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DmgEvRunning Equal to True
Set Variable Set DmgEvRecursionLevel = (DmgEvRecursionLevel + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DmgEvRecursionLevel Less than 16
Set Variable Set LastDmgPrevAmount[DmgEvRecursionN] = DamageEventPrevAmt
Set Variable Set LastDmgValue[DmgEvRecursionN] = DamageEventAmount
Set Variable Set LastDmgSource[DmgEvRecursionN] = DamageEventSource
Set Variable Set LastDmgTarget[DmgEvRecursionN] = DamageEventTarget
Set Variable Set LastDmgWasSpell[DmgEvRecursionN] = IsDamageSpell
Set Variable Set LastDmgPrevType[DmgEvRecursionN] = DamageEventType
Set Variable Set DmgEvRecursionN = (DmgEvRecursionN + 1)
-------- Delete the next couple of lines to disable the in-game recursion crash warnings --------
Cinematic - Clear the screen of text messages for (All players) .
Game - Display to (All players) for 999.00 seconds the text: WARNING: Recursion error when dealing damage! Make sure when you deal damage from within a DamageEvent trigger, do it like this: Trigger - Turn off (This Trigger) Unit - Cause... Trigger - Turn on (This Trigger)
Set Variable Set DmgEvRunning = "true"
Custom script: set clear = true
Set Variable Set DamageEventAmount = (Damage taken)
Set Variable Set DamageEventSource = (Damage source)
Set Variable Set DamageEventTarget = (Triggering unit)
Set Variable Set DamageEventPrevAmt = (Abs(DamageEventAmount))
Set Variable Set DamageEventType = NextDamageType
Set Variable Set NextDamageType = "0"
Set Variable Set DamageEventOverride = NextDamageOverride
Set Variable Set NextDamageOverride = "false"
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DamageEventAmount Equal to 0.00
Set Variable Set DamageEvent = "0.00"
Set Variable Set DamageEvent = "2.00"
Set Variable Set DamageEvent = "0.00"
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DmgEvStarted Equal to False
Set Variable Set DmgEvStarted = "true"
Custom script: call TimerStart(udg_DmgEvTimer, 0.00, false, function DmgEvOnExpire)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DamageEventAmount Less than 0.00
Set Variable Set DamageEventAmount = (0.00 - DamageEventAmount)
Set Variable Set IsDamageSpell = "true"
Custom script: call DmgEvAmplifyCheck()
Set Variable Set IsDamageSpell = "false"
Set Variable Set DamageModifierEvent = "0.00"
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DamageEventOverride Equal to False
Set Variable Set DamageModifierEvent = "1.00"
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DamageEventOverride Equal to False
Set Variable Set DamageModifierEvent = "2.00"
Set Variable Set DamageModifierEvent = "3.00"
Custom script: set udg_DamageEventOverride = override
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DamageEventAmount Greater than 0.01
Set Variable Set DamageModifierEvent = "4.00"
Set Variable Set DamageModifierEvent = "0.00"
Set Variable Set DamageEvent = "0.00"
Set Variable Set DamageEvent = "1.00"
Set Variable Set DamageEvent = "0.00"
Custom script: call CheckDamagedLifeEvent() //in case the unit state event failed from a recursive damage event
-------- Process damage modification --------
Set Variable Set DmgEvLife = (Life of DamageEventTarget)
Custom script: set udg_DmgEvTrig = CreateTrigger()
Custom script: call TriggerAddCondition(udg_DmgEvTrig, Filter(c))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
IsDamageSpell Equal to False
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DamageEventAmount Not equal to DamageEventPrevAmt
Set Variable Set DmgEvLife = ((DmgEvLife + DamageEventPrevAmt) - DamageEventAmount)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
(Max life of DamageEventTarget) Less than DmgEvLife
Set Variable Set LastDamageHP = (DmgEvLife - DamageEventPrevAmt)
Unit - Add DamageBlockingAbility to DamageEventTarget
Unit - Set life of DamageEventTarget to (Max(DmgEvLife, 0.42))
Trigger - Add to DmgEvTrig the event (DamageEventTarget's life becomes Less than (Max(0.41, (DmgEvLife - (DamageEventPrevAmt / 2.00)))))
Set Variable Set LastDamageHP = (Max life of DamageEventTarget)
Set Variable Set DmgEvPrevLife = DmgEvLife
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
(DmgEvLife + (DamageEventPrevAmt x 0.75)) Greater than LastDamageHP
Set Variable Set DmgEvLife = (Max((LastDamageHP - (DamageEventPrevAmt / 2.00)), 1.00))
Unit - Set life of DamageEventTarget to DmgEvLife
Set Variable Set DmgEvLife = ((DmgEvLife + LastDamageHP) / 2.00)
Set Variable Set DmgEvLife = (DmgEvLife + (DamageEventPrevAmt x 0.50))
Set Variable Set LastDamageHP = (DmgEvPrevLife - (DamageEventPrevAmt - (DamageEventPrevAmt - DamageEventAmount)))
Trigger - Add to DmgEvTrig the event (DamageEventTarget's life becomes Greater than DmgEvLife)
Custom script: if clear then
Set Variable Set DmgEvRunning = "false"
Set Variable Set DmgEvRecursionLevel = "0"
Custom script: elseif udg_DamageEventPrevAmt == 0.00 then
Custom script: call DmgEvResetVars()
Custom script: endfunction
Custom script: function CreateDmgEv takes nothing returns nothing
Custom script: local code c = function OnDmgEv
Custom script: set udg_DamageEventTrigger = CreateTrigger()
Custom script: call TriggerAddCondition(udg_DamageEventTrigger, Filter(c))
Custom script: endfunction
Custom script: function SetupDmgEv takes nothing returns nothing
Custom script: local integer pdex = udg_UDex
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
UnitIndexEvent Equal to 1.00
Set Variable Set DmgEvUnit = UDexUnits[UDex]
Custom script: if DmgEvFilter() then
Set Variable Set UnitDamageRegistered[UDex] = "true"
Trigger - Add to DamageEventTrigger the event (DmgEvUnit Takes damage)
Unit - Add SpellDamageAbility to DmgEvUnit
Custom script: call UnitMakeAbilityPermanent(udg_DmgEvUnit, true, udg_SpellDamageAbility)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
UnitDamageRegistered[UDex] Equal to True
Set Variable Set UnitDamageRegistered[UDex] = "false"
Set Variable Set DamageEventsWasted = (DamageEventsWasted + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
DamageEventsWasted Equal to 32
Set Variable Set DamageEventsWasted = "0"
Custom script: call DestroyTrigger(udg_DamageEventTrigger)
Custom script: call CreateDmgEv()
Set Variable Set UDex = UDexNext[0]
Custom script: exitwhen udg_UDex == 0
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
UnitDamageRegistered[UDex] Equal to True
Trigger - Add to DamageEventTrigger the event (UDexUnits[UDex] Takes damage)
Set Variable Set UDex = UDexNext[UDex]
Custom script: set udg_UDex = pdex
Custom script: endfunction
Custom script: function InitDamageEvent takes nothing returns nothing
Custom script: local code c = function CheckDamagedLifeEvent
Custom script: set udg_ClearDamageEvent = CreateTrigger()
Custom script: call TriggerAddCondition(udg_ClearDamageEvent, Filter(c))
For each (Integer A) from 1 to 16 , do (Actions)
Player - Disable SpellDamageAbility for (Player((Integer A)))
Custom script: call CreateDmgEv()
Custom script: set c = function SetupDmgEv
Set Variable Set UnitIndexerEnabled = "false"
Custom script: set udg_DmgEvUnit = CreateUnit(Player(15), 'uloc', 0, 0, 0)
Set Variable Set UnitIndexerEnabled = "true"
Unit - Add DamageBlockingAbility to DmgEvUnit
Unit - Add SpellDamageAbility to DmgEvUnit
Unit - Remove DmgEvUnit from the game
Custom script: call TriggerAddCondition(GetTriggeringTrigger(), Filter(c))
Trigger - Run (This trigger) (checking conditions)
Countdown Timer - Start DmgEvTimer as a One-shot timer that will expire in 0.00 seconds
Trigger - Turn off ClearDamageEvent