JASS:
scope FetalBody initializer init
private function True takes nothing returns boolean
return true
endfunction
private function condition takes nothing returns boolean
return GetRandomInt(0, 100) <= 15 and IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetAttacker())) and GetUnitAbilityLevel(GetTriggerUnit(), 'A004') > 0
endfunction
private function action takes nothing returns nothing
local unit me = GetTriggerUnit()
local unit dum = CreateUnit(GetOwningPlayer(me), 'h001', GetUnitX(me), GetUnitY(me), 180.0)
call UnitAddAbility(dum, 'A003')
call SetUnitAbilityLevel(dum, 'A003', GetUnitAbilityLevel( me, 'A004'))
call IssueImmediateOrder(dum, "fanofknives")
call KillUnit(dum)
set dum = null
set me = null
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i>15
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ATTACKED, Filter(function True))
endloop
call TriggerAddCondition( t, Condition(function condition))
call TriggerAddAction(t, function action)
endfunction
endscope
The code above is what I try to create an passice ability that if unit that has this ability has been attacked, i will has 15% chance to deal damage to enemy around.(use custom fan of knives) but when I test I find it lag everytime I got attacked. I just in process of practicing so may I ask what create that lag? Thanks.
EDIT: Sorry, This is solved.
Last edited: