function Trig_FOKS_Action_Conditions takes nothing returns boolean
if ( not ( GetUnitAbilityLevelSwapped('A03B', GetAttacker()) > 0 ) ) then
return false
endif
return true
endfunction
function FOKS_Damage takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit hero = GetEventDamageSource()
local location point = GetUnitLoc(u)
call CreateNUnitsAtLoc( 1, 'h001', GetOwningPlayer(hero), point, bj_UNIT_FACING )
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', GetLastCreatedUnit() )
call UnitAddAbilityBJ( 'A03C', GetLastCreatedUnit() )
call SetUnitAbilityLevelSwapped( 'A03C', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A03B', hero) )
call IssueImmediateOrderBJ( GetLastCreatedUnit(), "fanofknives" )
call RemoveLocation(point)
set point = null
endfunction
function Trig_FOKS_Action_Actions takes nothing returns nothing
local trigger t = CreateTrigger()
local unit attacker = GetAttacker()
local triggeraction taction = TriggerAddAction(t, function FOKS_Damage)
local integer chance = GetRandomInt(1, 100)
local timer tx = CreateTimer()
if ( chance <= ( 15 + ( GetUnitAbilityLevelSwapped('A03B', attacker) * 5 ) ) ) then
call TimerStart(tx,4,false,null)
call TriggerRegisterUnitEvent(t,GetAttackedUnitBJ(), EVENT_UNIT_DAMAGED)
loop
exitwhen (TimerGetRemaining(tx)<=0) or (GetTriggerEvalCount(t) == 1)
call TriggerSleepAction(1.0)
endloop
endif
call DestroyTrigger(t)
call DestroyTimer(tx)
set taction = null
set attacker = null
set t=null
set tx = null
endfunction
//===========================================================================
function InitTrig_FOKS_Action takes nothing returns nothing
set gg_trg_FOKS_Action = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_FOKS_Action, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_ATTACKED )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_FOKS_Action, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_FOKS_Action, Condition( function Trig_FOKS_Action_Conditions ) )
call TriggerAddAction( gg_trg_FOKS_Action, function Trig_FOKS_Action_Actions )
endfunction