FIXED/SOLVED THANKS!
ive been wanting a knockback system for some of the skills on my map, and the one that seemed easiest and was explained well enough was this one http://www.hiveworkshop.com/forums/f280/coding-efficient-knockback-vjass-41418/
but im having problems with it and im not sure if i just typed it out wrong, or im calling it incorrectly or just missed where to put it.
currently it sets in the map header (on trigger page where the map name is) and i am using the latest JASS NewGen
EDIT: going to look at an alternative method do doing this, see a few posts later.
i had to do some slight changing because it wouldnt save correctly without the changes but essentially it's the same.
i believe the skill should take the unit and knock him back a distance of 1000 in direction 5 radians, over 100 executions of a .04 timer. yes?
my major questions are the Radians "a" and "w" which should be how long it takes them to get knocked back.
can anyone spot my problem or can explain what im missing?
sorry for asking, i know it's somewhere in the forums but my last few searches didn't effectively answer my questions hope ill get better results this way.
Thanks for reading YO_MA_MA
ive been wanting a knockback system for some of the skills on my map, and the one that seemed easiest and was explained well enough was this one http://www.hiveworkshop.com/forums/f280/coding-efficient-knockback-vjass-41418/
but im having problems with it and im not sure if i just typed it out wrong, or im calling it incorrectly or just missed where to put it.
currently it sets in the map header (on trigger page where the map name is) and i am using the latest JASS NewGen
EDIT: going to look at an alternative method do doing this, see a few posts later.
JASS:
library Knockback
struct Knockback_Data
unit u
real a
real d1
real d2
real sin
real cos
real r
string s = ""
effect e = null
endstruct
globals
timer Tim = CreateTimer()
Knockback_Data array Ar
integer Total = 0
item I = CreateItem('ciri', 0, 0)
// boolexpr Filter
endglobals
function CheckPathabilityTrickGet takes nothing returns nothing
set bj_rescueChangeColorUnit = bj_rescueChangeColorUnit or GetEnumItem() != I
endfunction
function CheckPathabilityTrick takes real x, real y returns boolean
local integer i = 30
local real X
local real Y
local rect r
call SetItemPosition(I, x, y)
set X = GetItemX(I) - x
set Y = GetItemY(I) - y
if X * X + Y * Y <= 100 then
return true
endif
set r = Rect(x - i, y - i, x + i, y + i)
set bj_rescueChangeColorUnit = false
call EnumItemsInRect(r, null, function CheckPathabilityTrickGet)
call RemoveRect(r)
set r = null
return bj_rescueChangeColorUnit
endfunction
function CheckPathability takes real x, real y returns boolean
local boolean b = CheckPathabilityTrick(x, y)
call SetItemVisible(I, false)
return b
endfunction
function Knockback_TreeFilter takes nothing returns boolean
local integer d = GetDestructableTypeId(GetFilterDestructable())
return d == 'ATtr' or d == 'BTtw' or d == 'KTtw' or d == 'YTft' or d == 'JTct' or d == 'YTst' or d == 'YTct' or d == 'YTwt' or d == 'JTwt' or d == 'JTwt' or d == 'FTtw' or d == 'CTtr' or d == 'ITtw' or d == 'NTtw' or d == 'OTtw' or d == 'ZTtw' or d == 'WTst' or d == 'LTlt' or d == 'GTsh' or d == 'Xtlt' or d == 'WTtw' or d == 'Attc' or d == 'BTtc' or d == 'CTtc' or d == 'ITtc' or d == 'NTtc' or d == 'ZTtc'
endfunction
constant function Interval takes nothing returns real
return 0.04
endfunction
function Knockback_Execute takes nothing returns nothing
local Knockback_Data kd
local integer i = 0
local real x
local real y
local rect r
local boolexpr b
loop
exitwhen i >= Total
set kd = Ar[i]
if kd.s != null and kd.s != null then
set x = GetUnitX(kd.u)
set y = GetUnitY(kd.u)
call DestroyEffect(AddSpecialEffect(kd.s, x, y))
set x = x + kd.d1 * kd.cos
set y = y + kd.d1 * kd.sin
else
set x = GetUnitX(kd.u) + kd.d1 * kd.cos
set y = GetUnitY(kd.u) + kd.d1 * kd.sin
endif
if kd.r != 0 then
set r = Rect(x - kd.r, y - kd.r, x + kd.r, y + kd.r)
set b = Filter(function Knockback_TreeFilter)
call EnumDestructablesInRect(r, b, function Knockback_TreeFilter)
call RemoveRect(r)
call DestroyBoolExpr(b)
endif
if CheckPathability(x, y) then
call SetUnitX(kd.u, x)
call SetUnitY(kd.u, y)
endif
set kd.d1 = kd.d1 - kd.d2
if kd.d1 <= 0 or not CheckPathability(x, y) then
if kd.e != null then
call DestroyEffect(kd.e)
endif
call PauseUnit(kd.u, false)
set Ar[i] = Ar[Total - 1]
set Total = Total - 1
call kd.destroy()
endif
set i = i + 1
endloop
if Total == 0 then
call PauseTimer(Tim)
endif
endfunction
function Knockback takes unit u, real d, real a, real w, real r, integer t, string s, string p returns Knockback_Data
local Knockback_Data kd = Knockback_Data.create()
local integer q = R2I(w / Interval())
set kd.u = u
set kd.a = a
set kd.d1 = 2 * d / (q + 1)
set kd.d2 = kd.d1 / q
set kd.sin = Sin(a)
set kd.cos = Cos(a)
set kd.r = r
if s != "" and s != null then
if t == 2 then
if p != "" and p != null then
set kd.e = AddSpecialEffectTarget(s, u, p)
else
set kd.e = AddSpecialEffectTarget(s, u, "chest")
endif
elseif t == 1 then
set kd.s = s
endif
endif
call SetUnitPosition(u, GetUnitX(u), GetUnitY(u))
call PauseUnit(u, true)
if Total == 0 then
call TimerStart(Tim, Interval(), true, function Knockback_Execute)
endif
set Total = Total + 1
set Ar[Total - 1] = kd
return kd
endfunction
function KnockBEZ takes unit u, real d, real a, real w returns Knockback_Data
return Knockback(u, d, a, w, 0, 0, "", "")
endfunction
endlibrary
-
Magic Bullet gui test
-
Events
- Unit - A unit Starts the effect of an ability
-
Conditions
- (Ability being cast) Equal to test knockback yep the test
-
Actions
- Custom script: local unit Knocked = GetTriggerUnit()
- Custom script: call Knockback(Knocked, 1000, 5, 100, 0, 0, "", "")
-
Events
i believe the skill should take the unit and knock him back a distance of 1000 in direction 5 radians, over 100 executions of a .04 timer. yes?
my major questions are the Radians "a" and "w" which should be how long it takes them to get knocked back.
can anyone spot my problem or can explain what im missing?
sorry for asking, i know it's somewhere in the forums but my last few searches didn't effectively answer my questions hope ill get better results this way.
Thanks for reading YO_MA_MA
Last edited: