- Joined
- Apr 7, 2007
- Messages
- 48
Ok, so i have a spell, its a charging-type spell that is supposed to move you forward until you either bump into an enemy (in which case you grab them and do a piledriver . . . errm thingy . . . to them) or bump into some other impassable area. The problem is, I'm very new to JASS, so as tradition I have to pick the hardest frikin spell i can imagine to try. Well ... I don't move, at all, I use a struct to transfer the data from the starting to the movement timer but something isnt right and it well, doesnt work.
I used Vexorian's check pathability function and DiscipleofLife's attacthment system, they were recommended to me earlier.
JASS:
struct Rush_Data
unit u
real d
effect e
real cos
real sin
endstruct
JASS:
function TimerStartWithUserData takes timer t, real timeout, integer data, boolean periodic, code handlerFunc returns nothing
call TimerStart(t, timeout+data/67108871., periodic, handlerFunc)
endfunction
function GetTimerUserData takes timer t, real timeout returns integer
return R2I((TimerGetTimeout(t)-timeout)*67108871.+0.5)
endfunction
JASS:
function RushMove takes nothing returns nothing
local timer t = GetExpiredTimer()
local Rush_Data rd = GetTimerUserData(t,.003)
local real x = GetUnitX(rd.u) + 3 * rd.cos
local real y = GetUnitY(rd.u) + 3 * rd.sin
local group g = RushGroup(GetOwningPlayer(rd.u),rd.u)
if CountUnitsInGroup(g) >= 1 then
call RushFinal(rd.u,GroupPickRandomUnit(g))
call DestroyEffect(rd.e)
call Rush_Data.destroy(rd)
call DestroyGroup(g)
call DestroyTimer(t)
return
endif
if CheckPathability(x,y) == false or rd.d <= 0.0 then
call PauseUnit(rd.u,false)
call SetUnitPathing(rd.u,true)
call SetUnitInvulnerable(rd.u,false)
call DestroyEffect(rd.e)
call Rush_Data.destroy(rd)
call DestroyTimer(t)
endif
call SetUnitX(rd.u,x)
call SetUnitY(rd.u,y)
set rd.d = rd.d - 3.0
endfunction
function RushStart takes unit u, location p returns nothing
local Rush_Data rd = Rush_Data.create()
local timer t = CreateTimer()
call PauseUnit(u,true)
call SetUnitInvulnerable(u,true)
call SetUnitPosition(u, GetUnitX(u), GetUnitY(u))
call SetUnitPathing(u,false)
call SetUnitFacing(u, AngleBetweenPoints(GetUnitLoc(u),p))
call AddSpecialEffectTarget("units\\human\\phoenix\\phoenix.mdl",u,"head") //funny hat
set rd.cos = Cos(GetUnitFacing(u) * bj_DEGTORAD)
set rd.sin = Sin(GetUnitFacing(u) * bj_DEGTORAD)
set rd.e = GetLastCreatedEffectBJ()
set rd.d = RushLvLValues(GetUnitAbilityLevel(u, RushAbility()))
call TimerStartWithUserData(t,.003,integer(rd),true,function RushMove)
endfunction
I used Vexorian's check pathability function and DiscipleofLife's attacthment system, they were recommended to me earlier.