- Joined
- Jan 11, 2009
- Messages
- 3,414
Hi, i'm making a little charge ability for a map of mine but I'm encountering some problems regarding passing information through a function called by a timer.
I guess it sounds a bit fancy, but have a look at this code:
Now, this script is not complete; though i want to know how to pass the variables - that would say the target point and casting unit - to the function, before i complete it. I have a version that uses TriggerSleepAction, but that works really awkward with such short intervalls.
I really don't want to use H2I here either, since the new patch is coming.
What do i need to make this work?
EDIT: I realize many things in this code simply doesen't make sense since i mostly copied it from the other code i did. Don't worry about the uninitialized variables and so on.
I guess it sounds a bit fancy, but have a look at this code:
JASS:
function moveUnit takes nothing returns nothing
local location loc = GetUnitLoc(u)
local location p
local group g = CreateGroup()
local unit temp
local real length = 0
if length<300
//Move
set loc = GetUnitLoc(u)
call SetUnitAnimation( u, "stand ready" )
set p = PolarProjectionBJ(GetUnitLoc(u), 20, AngleBetweenPoints(GetUnitLoc(u), targ))
if IsTerrainPathable(GetLocationX(p), GetLocationY(p)) then
call SetUnitPositionLoc(u, p)
call RemoveLocation(p)
endif
set length = length+20
//Bash
call GroupEnumUnitsInRangeOfLoc(g, loc, 60., null)
set temp = FirstOfGroup(g)
if IsUnitEnemy(temp, GetOwningPlayer(u)) then
call CreateUnitAtLoc(GetOwningPlayer(u), 'h000', loc, 0.)
call UnitAddAbility(GetLastCreatedUnit(), 'a001')
call IssueTargetOrder( GetLastCreatedUnit(), "thunderbolt", temp)
call UnitApplyTimedLife( GetLastCreatedUnit(), 'BTLF', 2.00 )
else
//Clean up
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
call RemoveLocation(loc)
call DestroyGroup(g)
set g = null
set loc = null
set temp = null
set p = null
//return
endfunction
function chargeAura2 takes unit u returns nothing
local timer t = CreateTimer()
call TimerStart(t, 0.03, true, function moveUnit())
//return
endfunction
Now, this script is not complete; though i want to know how to pass the variables - that would say the target point and casting unit - to the function, before i complete it. I have a version that uses TriggerSleepAction, but that works really awkward with such short intervalls.
I really don't want to use H2I here either, since the new patch is coming.
What do i need to make this work?
EDIT: I realize many things in this code simply doesen't make sense since i mostly copied it from the other code i did. Don't worry about the uninitialized variables and so on.