- Joined
- Feb 22, 2006
- Messages
- 960
Hi there,
i have a problem, for my map i need a triggered casting system, that means the casttime should be decided by the trigger. Is there a way to do this?
Can be gui or jass i don't mind.
Would be nice if someone could help.
So i have it
here my solution
Update, added another trigger which sets a boolean true if the unit moves or something else.
the if construction cuts the rest of the trigger and clean leaks
i have a problem, for my map i need a triggered casting system, that means the casttime should be decided by the trigger. Is there a way to do this?
Can be gui or jass i don't mind.
Would be nice if someone could help.
So i have it
here my solution
Update, added another trigger which sets a boolean true if the unit moves or something else.
the if construction cuts the rest of the trigger and clean leaks
JASS:
function cast_cond takes nothing returns boolean
return GetSpellAbilityId() == 'A002'
endfunction
function cast_actions takes nothing returns nothing
local unit dummy
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local integer tempint = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
local location locunit = GetUnitLoc(caster)
local timer t = CreateTimer()
local real tleft
set udg_casttime[tempint] = 2.20
call TimerStart(t,udg_casttime[tempint],false,null)
loop
set tleft = TimerGetRemaining(t)
exitwhen tleft == 0
if udg_castboolean[tempint] == true then
call IssueImmediateOrder(caster,"stop")
call RemoveLocation(locunit)
set caster = null
set target = null
set dummy = null
set locunit = null
set t = null
return
endif
call TriggerSleepAction(0.02)
endloop
call IssueImmediateOrder(caster,"stop")
set dummy = CreateUnitAtLoc(GetOwningPlayer(caster),'h000',locunit,0)
call UnitAddAbility(dummy,'A003')
call IssueTargetOrder(dummy,"thunderbolt",target)
call UnitApplyTimedLife(dummy,'BTLF',2.0)
//clean up
call RemoveLocation(locunit)
set caster = null
set target = null
set dummy = null
set locunit = null
set t = null
endfunction
function InitTrig_triggered_casting takes nothing returns nothing
local trigger casttrig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(casttrig,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(casttrig,Condition(function cast_cond))
call TriggerAddAction(casttrig,function cast_actions)
set casttrig = null
endfunction
Last edited: