//CONFIGURABLES
function AotC_HeroAbility takes nothing returns integer
return 'A000'//Hero ability raw code
endfunction
function AotC_UnitAbility takes nothing returns integer
return 'A001'//Buff ability raw code
endfunction
function AotC_DazeAbility takes nothing returns integer
return 'A002'//Daze ability raw code
endfunction
function AotC_AbilityBuff takes nothing returns integer
return 'B000'//Buff ability raw code
endfunction
function AotC_UnitId takes nothing returns integer
return 'u000'//Caster unit rawcode
endfunction
function AotC_LearnSpellOrderId takes nothing returns integer
return 1093677104//Id of the order learn the ability
endfunction
function AotC_TurnOn takes nothing returns integer
return 852177//Id of the order "immolation"
endfunction
function AotC_TurnOff takes nothing returns integer
return 852178//Id of the order "unimmolation"
endfunction
function AotC_UnitAOrder takes nothing returns string
return "bloodlust"//Buff ability order
endfunction
function AotC_DazeOrder takes nothing returns string
return "slow"//Daze ability order
endfunction
function AotC_Preload takes nothing returns boolean
return true
endfunction
//END OF CONFIGURABLES
function AotC_Action2 takes nothing returns boolean
local unit c = GetTriggerUnit()
local unit u
local integer i
if GetUnitAbilityLevel(c, AotC_AbilityBuff()) > 0 then
set i = GetUnitAbilityLevel(c, AotC_HeroAbility())
set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), AotC_UnitId(), GetUnitX(c), GetUnitY(c), 0)
call UnitAddAbility(u, AotC_DazeAbility())
call SetUnitAbilityLevel(c, AotC_DazeAbility(), i)
call IssueTargetOrder(u, AotC_DazeOrder(), c)
call UnitApplyTimedLife(u, 'BTLF', .5)
set u = null
endif
set c = null
return false
endfunction
function AotC_Action1 takes nothing returns boolean
local unit c = GetTriggerUnit()
local unit u
local integer i
if GetIssuedOrderId() == AotC_TurnOn() then
set i = GetUnitAbilityLevel(c, AotC_HeroAbility())
set u = CreateUnit(GetTriggerPlayer(), AotC_UnitId(), GetUnitX(c), GetUnitY(c), 0)
call UnitAddAbility(u, AotC_UnitAbility())
call SetUnitAbilityLevel(u, AotC_UnitAbility(), i)
call IssueTargetOrder(u, AotC_UnitAOrder(), c)
call UnitApplyTimedLife(u, 'BTLF', .5)
set u = null
elseif GetIssuedOrderId() == AotC_TurnOff() then
call UnitRemoveAbility(c, AotC_AbilityBuff())
elseif GetIssuedOrderId() == AotC_LearnSpellOrderId() and GetUnitAbilityLevel(c, AotC_AbilityBuff()) > 0 then
set i = GetUnitAbilityLevel(c, AotC_HeroAbility())
call UnitRemoveAbility(c, AotC_AbilityBuff())
set u = CreateUnit(GetTriggerPlayer(), AotC_UnitId(), GetUnitX(c), GetUnitY(c), 0)
call UnitAddAbility(u, AotC_UnitAbility())
call SetUnitAbilityLevel(u, AotC_UnitAbility(), i + 1)
call IssueTargetOrder(u, AotC_UnitAOrder(), c)
call UnitApplyTimedLife(u, 'BTLF', .5)
set u = null
endif
set c = null
set u = null
return false
endfunction
function InitTrig_AotC takes nothing returns nothing
local trigger t = CreateTrigger()
local unit u
if AotC_Preload() then
set u = CreateUnit(Player(0), AotC_UnitId(), 0, 0, 0)
call UnitAddAbility(u, AotC_UnitAbility())
call UnitAddAbility(u, AotC_DazeAbility())
call RemoveUnit(u)
endif
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
call TriggerAddCondition(t, Condition(function AotC_Action1))
set t = CreateTrigger()
call TriggerRegisterVariableEvent(t, "udg_DamageEvent", EQUAL, 1)
call TriggerAddCondition(t, Condition(function AotC_Action2))
set t = null
set u = null
endfunction