- Joined
- Sep 24, 2007
- Messages
- 283
Update: forgot one library action
i dont know why but when i cast spell nothing happens
after some changes my JassHelper stoped to work and it can't be saved. I call it WTF!?
here's the code
[/code]
JASS:
library Dash initializer InitDash uses IsTerrainWalkable
globals
private constant real speed = 12
private constant integer distance = 400
private constant integer dpl = 120
private constant integer ID = 'A001'
private constant integer BID = 'B000'
timer T = CreateTimer()
real x
real y
real x2
real y2
endglobals
struct Movement
unit u
real angle
real dis
real sp
static Movement array Index
static integer Total
static method Move takes nothing returns nothing
local Movement dat
local integer i = 0
loop
exitwhen i >= dat.Total
set dat = dat.Index[i]
set x = GetUnitX(dat.u)
set y = GetUnitY(dat.u)
set x2 = x + (Cos(dat.angle * bj_DEGTORAD)*(dat.sp+40))
set y2 = y + (Sin(dat.angle * bj_DEGTORAD)*(dat.sp+40))
if IsTerrainWalkable(x2,y2) then
call SetUnitX(dat.u, x + (Cos(dat.angle * bj_DEGTORAD)*dat.sp))
call SetUnitY(dat.u, y + (Sin(dat.angle * bj_DEGTORAD)*dat.sp))
else
set dat.dis = -150
endif
set dat.dis = dat.dis - dat.sp
set dat.sp = dat.sp + 1
if dat.dis <= 0 then
call SetUnitPathing(dat.u, true)
call PauseUnit(dat.u, false)
call UnitRemoveAbility(dat.u,BID)
call dat.destroy()
set dat.Total = dat.Total - 1
set dat.Index[i] = dat.Index[dat.Total]
set i = i - 1
endif
set i = i + 1
if dat.Total == 0 then
call PauseTimer(T)
endif
endloop
endmethod
static method Start takes nothing returns nothing
local Movement dat = Movement.allocate()
if dat.Total == 0 then
call TimerStart(T,0.02,true,function Movement.Move)
endif
set dat.u = GetTriggerUnit()
set dat.angle = GetUnitFacing(dat.u)
set dat.sp = speed
set dat.dis = distance+(120*GetUnitAbilityLevel(dat.u,ID))
call SetUnitPathing(dat.u, false)
call PauseUnit(dat.u, true)
set dat.Index[dat.Total] = dat
set dat.Total = dat.Total + 1
endmethod
endstruct
private function Check takes nothing returns boolean
return GetSpellAbilityId() == ID
endfunction
private function InitDash takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i =i+1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddAction(t, function Movement.Start)
call TriggerAddCondition(t, Filter( function Check))
endfunction
endlibrary
i dont know why but when i cast spell nothing happens
after some changes my JassHelper stoped to work and it can't be saved. I call it WTF!?
here's the code
JASS:
[code=jass]ibrary Dash initializer InitDash uses IsTerrainWalkable
globals
private constant real speed = 12
private constant integer distance = 400
private constant integer dpl = 120
private constant integer ID = 'A001'
private constant integer BID = 'B000'
private constant string SFX = "Abilities\\Spells\\Other\\StrongDrink\\BrewmasterMissile.mdl"
timer T = CreateTimer()
real x
real y
real x2
real y2
rect r
endglobals
struct Movement
unit u
real angle
real dis
real sp
static Movement array Index
static integer Total = 0
static method Move takes nothing returns nothing
local Movement dat
local integer i = 0
loop
exitwhen i >= dat.Total
set dat = dat.Index[i]
set x = GetUnitX(dat.u)
set y = GetUnitY(dat.u)
set x2 = x + (Cos(dat.angle * bj_DEGTORAD)*(dat.sp+40))
set y2 = y + (Sin(dat.angle * bj_DEGTORAD)*(dat.sp+40))
if IsTerrainWalkable(x2,y2) then
call SetUnitX(dat.u, x + (Cos(dat.angle * bj_DEGTORAD)*dat.sp))
call SetUnitY(dat.u, y + (Sin(dat.angle * bj_DEGTORAD)*dat.sp))
call IssueImmediateOrder(dat.u, "stop")
call DestroyEffect(AddSpecialEffect(SFX,x,y))
set r = Rect( x2 - 200*0.5, y2 - 200*0.5, x2 + 200*0.5, y2 + 200*0.5 )
call EnumDestructablesInRect(r, null, function Movement.KillDestruct)
else
set dat.dis = -150
endif
set dat.dis = dat.dis - dat.sp
set dat.sp = dat.sp + 1
if dat.dis <= 0 then
call SetUnitPathing(dat.u, true)
call UnitRemoveAbility(dat.u,BID)
call dat.destroy()
set dat.Total = dat.Total - 1
set dat.Index[i] = dat.Index[dat.Total]
set i = i - 1
endif
set i = i + 1
if dat.Total == 0 then
call PauseTimer(T)
endif
endloop
endmethod
static method Start takes nothing returns nothing
local Movement dat = Movement.allocate()
if dat.Total == 0 then
call TimerStart(T,0.02,true,function Movement.Move)
endif
set dat.u = GetTriggerUnit()
set dat.angle = GetUnitFacing(dat.u)
set dat.sp = speed
set dat.dis = distance+(120*GetUnitAbilityLevel(dat.u,ID))
call SetUnitPathing(dat.u, false)
set dat.Index[dat.Total] = dat
set dat.Total = dat.Total + 1
endmethod
static method KillDestruct takes nothing returns nothing
call KillDestructable( GetEnumDestructable() )
endmethod
endstruct
private function Check takes nothing returns boolean
return GetSpellAbilityId() == ID
endfunction
private function InitDash takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i =i+1
endloop
call TriggerAddAction(t, function Movement.Start)
call TriggerAddCondition(t, Filter( function Check))
endfunction
endlibrary
Attachments
Last edited: