- Joined
- Apr 29, 2013
- Messages
- 21
Hello guys,
I would ask you to help me please by my own Knockback-System. I've constructed it for my project, cuz I want to make as much as possible by myself.
this is the code
I know that points leak and I'll change this until it work.
If globals don't selfexplain themselves(logically they don't ):
KU -> Knocked Unit
KCL -> Location of the Knocking Unit
KTL -> Location of the KU(maybe a bit unnecessary)
KD -> Max Knockback Distance
KA -> Angle(for PolarProjection maybe unnecessary too)
KIndex -> I think this is selfexplaining
KT -> the running Timer
I thank in advance for your help. I watched yesterday and today over it, but couldn't find the mistake. Maybe school is too stressy at the moment^^.
I would ask you to help me please by my own Knockback-System. I've constructed it for my project, cuz I want to make as much as possible by myself.
JASS:
library Knockback initializer OnInit
globals
unit array KU
location array KCL
location array KTL
real array KD
real array KA
integer KIndex
timer KT
endglobals
private function CleanArray takes integer i returns nothing
local integer x = 0
loop
exitwhen x > KIndex
if(x >= i and x < KIndex) then
set KU[x] = KU[x+1]
set KCL[x] = KCL[x+1]
set KTL[x] = KTL[x+1]
set KD[x] = KD[x+1]
set KA[x] = KA[x+1]
elseif(x == KIndex) then
set KU[x] = null
call RemoveLocation(KCL[x])
call RemoveLocation(KTL[x])
set KD[x] = 0.
set KA[x] = 0.
set KIndex = KIndex - 1
endif
set x = x + 1
endloop
endfunction
private function KnockLoop takes nothing returns nothing
local location l
local integer i = 0
loop
exitwhen i > KIndex
if(DistanceBetweenPoints(KCL[i], KTL[i]) < KD[i]) then
set l = PolarProjectionBJ(KTL[i], 25., KA[i])
set KTL[i] = l
call SetUnitPositionLoc(KU[i], l)
call RemoveLocation(l)
else
call RemoveLocation(l)
call CleanArray(i)
endif
set i = i + 1
endloop
endfunction
function Knockback takes unit c,unit t,real d returns nothing
set KCL[KIndex] = GetUnitLoc(c)
set KTL[KIndex] = GetUnitLoc(t)
set KD[KIndex] = d
set KA[KIndex] = AngleBetweenPoints(KCL[KIndex], KTL[KIndex])
set KU[KIndex] = t
set KIndex = KIndex + 1
endfunction
function OnInit takes nothing returns nothing
set KT = CreateTimer()
call TimerStart(KT, .03, true, function KnockLoop)
endfunction
endlibrary
this is the code
I know that points leak and I'll change this until it work.
If globals don't selfexplain themselves(logically they don't ):
KU -> Knocked Unit
KCL -> Location of the Knocking Unit
KTL -> Location of the KU(maybe a bit unnecessary)
KD -> Max Knockback Distance
KA -> Angle(for PolarProjection maybe unnecessary too)
KIndex -> I think this is selfexplaining
KT -> the running Timer
I thank in advance for your help. I watched yesterday and today over it, but couldn't find the mistake. Maybe school is too stressy at the moment^^.