i would like to have a feedback on my cast system..
it works fine for me but i dont know if it is really efficient..
That is the script, and this is how to use:
this is still not finished, it still prevents the unit to cast but its easy to fix..i just want it to prove if it works really..
it works fine for me but i dont know if it is really efficient..
JASS:
library Cast initializer onInit
globals
private integer PLAYER_ID
private string interrupted
boolean array busy[1] //this is a checker
endglobals
function Cast takes real casttime, unit caster returns nothing
local real i = 0
local real UnitX = GetUnitX(caster)
local real UnitY = GetUnitY(caster)
local real UnitAcq = GetUnitAcquireRange(caster)
set PLAYER_ID = GetPlayerId(GetOwningPlayer(caster))
set busy[PLAYER_ID] = true
set busy[PLAYER_ID] = false
debug call BJDebugMsg(I2S(PLAYER_ID))
call SetUnitAcquireRange(caster, 0.0)
call IssueImmediateOrder(caster, "holdposition")
loop
if GetUnitX(caster) != UnitX or GetUnitY(caster) != UnitY or busy[PLAYER_ID] != false then
debug call BJDebugMsg(interrupted)
call SetUnitAcquireRange(caster, UnitAcq)
call IssuePointOrder(caster, "attack", GetUnitX(caster), GetUnitY(caster))
set caster = null
return
endif
call TriggerSleepAction(0.1)
set i = i + 0.1
exitwhen i == casttime
endloop
debug call BJDebugMsg("done!")
set caster = null
endfunction
private function onInit takes nothing returns nothing
set interrupted = "Interrupted!"
endfunction
endlibrary
JASS:
scope Spell initializer my
globals
private constant integer MY_SPELL = 'A000'
endglobals
private function action takes nothing returns nothing
local unit caster = GetTriggerUnit()
local real casttime = 2.0
call Cast(casttime, caster)
//actions later
set caster = null
endfunction
private function condition takes nothing returns boolean
return GetSpellAbilityId() == MY_SPELL
endfunction
private function my takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerAddAction(t, function action)
call TriggerAddCondition(t, function condition)
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
endfunction
endscope
this is still not finished, it still prevents the unit to cast but its easy to fix..i just want it to prove if it works really..