wraithseeker
Tired.
- Reaction score
- 122
JASS:
library Knockback initializer Init requires BoundSentinel, TimerUtils, DestructableLib
globals
private integer Count = 0
private integer array Knocker
endglobals
private struct Knock
unit source
unit target
real x
real y
group g
real cos
real sin
real distance
real speed
real decrement
timer Timer
effect mode
static method create takes unit source, unit target, real angle, real initialspeed, real decrement, real distance returns Knock
local Knock d = Knock.allocate()
set d.source = source
set d.target = target
set d.speed = initialspeed
set d.decrement = decrement
set d.distance = distance
set d.sin = Sin(angle)
set d.cos = Cos(angle)
set d.Timer = NewTimer()
return d
endmethod
endstruct
private function Update takes nothing returns nothing
local Knock d = Knock(GetTimerData(GetExpiredTimer()))
local unit u
local integer i = Count - 1
local real sx
local real sy
local real tx
local real ty
loop
exitwhen i > Count
set u = d.target
set sx = GetUnitX(u)
set sy = GetUnitY(u)
if d.speed <= 0 then
call d.destroy()
set Count = Count - 1
if Count > 0 then
call ReleaseTimer(d.Timer)
set Count = 0
else
set Knocker<i> = Knocker[Count]
endif
else
set tx = sx * d.speed * d.cos
set ty = sy * d.speed * d.cos
call SetUnitPosition(u,tx,ty)
set d.speed = d.speed - d.decrement
set i = i - 1
endif
endloop
set u = null
endfunction
public function KnockTarget takes unit source, unit target , real angle, real initialspeed, real decrement , real distance returns boolean
local data d = 0
if target == null or source == null or initialspeed == null or distance == null or decrement == null then
call BJDebugMsg("Invalid Values!")
return false
endif
set d = Knock.create(source,target,angle*0.01745328,initialspeed,decrement,distance)
set Count = Count + 1
if Count == 1 then
call SetTimerData(d.Timer,integer (d))
call TimerStart(d.Timer,0.03,true,function Update)
endif
return true
endfunction
private function Init takes nothing returns nothing
endfunction
endlibrary</i>
Right now , it says in KnockTarget , d is not a type that allows synax.
I am sure that you will notice many errors in this code. This is my first system and I hope I can finish this without my brain turning into flames.