hey so I'm new to JASS and this is my first spell. It works perfectly just wanted to check if there was a more efficient way or if there are any leaks in it.
EDIT: by more efficient im refering to the loop and the fact that it cycles through it every .01 seconds until the condition is met
What is happening is a projectile is shot, and the target is put to sleep when hit!
EDIT: by more efficient im refering to the loop and the fact that it cycles through it every .01 seconds until the condition is met
What is happening is a projectile is shot, and the target is put to sleep when hit!
JASS:
function HauntJASS_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A01G039;
endfunction
function Trig_HauntJASS_Actions takes nothing returns nothing
local unit Caster = GetTriggerUnit()
local unit Target = GetSpellTargetUnit()
local integer AL = GetUnitAbilityLevel(Caster, 039;A01G039;)
local unit DCS
loop
if(GetUnitAbilityLevel(Target, 039;B00J039;) > 0) then
set DCS = CreateUnit(GetOwningPlayer(Caster),039;e001039;,GetUnitX(Caster),GetUnitY(Caster),270)
call UnitApplyTimedLife(DCS,039;BTLF039;,0.25)
call UnitAddAbility(DCS,039;A01H039;)
call SetUnitAbilityLevel(DCS,039;A04Y039;,AL)
call IssueTargetOrderById(DCS,OrderId("sleep"),Target)
call SetUnitPathing(DCS,false)
call SetUnitInvulnerable(DCS,true)
return
endif
call TriggerSleepAction( 0.01 )
endloop
endfunction
//===========================================================================
function InitTrig_HauntJASS takes nothing returns nothing
local trigger gg_trg_HauntJASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_HauntJASS, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition ( gg_trg_HauntJASS, Condition (function HauntJASS_Conditions) )
call TriggerAddAction( gg_trg_HauntJASS, function Trig_HauntJASS_Actions )
endfunction