- Joined
- Dec 11, 2014
- Messages
- 2,004
JASS:
function godown takes nothing returns nothing
local integer i = 1
loop
exitwhen i > udg_Slide_i
if udg_Slide_u[i] != null then
call SetUnitFlyHeight(udg_Slide_u[i], 0, (GetUnitFlyHeight(udg_Slide_u[i]) / udg_Slide_r[udg_Slide_i]))
set udg_Slide_u[i] = null
endif
set i = i + 1
endloop
endfunction
function slide takes unit u, real height, real dur, location where returns nothing
local location l = GetUnitLoc(u)
local real ddur = dur / 2
local timer t = CreateTimer()
local real dx = GetLocationX(where) - GetLocationX(l)
local real dy = GetLocationY(where) - GetLocationY(l)
if height > 0 then
if height != 0 then
set udg_Slide_i = udg_Slide_i + 1
set udg_Slide_u[udg_Slide_i] = u
set udg_Slide_r[udg_Slide_i] = ddur
call SetUnitFlyHeight(u, height, height / ddur)
call TimerStart(t, ddur, false, function godown)
endif
set udg_Knockback2DAngle = bj_RADTODEG * Atan2(GetLocationY(where) - GetLocationY(l), GetLocationX(where) - GetLocationX(l))
set udg_Knockback2DTime = dur
set udg_Knockback2DDistance = SquareRoot(dx * dx + dy * dy)
set udg_Knockback2DUnit = u
call TriggerExecute(gg_trg_Knockback_2D)
endif
call RemoveLocation(l)
set l = null
set t = null
endfunction
JASS:
function Look takes unit u, real startx, real starty, real startz, real endx, real endy, real endz, real dur returns nothing
local location l = Location(startx, starty)
local unit dum = CreateUnitAtLoc(Player(15), 'n000', l, 270)
local real dx = GetLocationX(Location(endx, endy)) - GetLocationX(Location(startx, starty))
local real dy = GetLocationY(Location(endx, endy)) - GetLocationY(Location(startx, starty))
set udg_Knockback2DAngle = bj_RADTODEG * Atan2(GetLocationY(Location(endx, endy)) - GetLocationY(Location(startx, starty)), GetLocationX(Location(endx, endy)) - GetLocationX(Location(startx, starty)))
set udg_Knockback2DTime = dur
set udg_Knockback2DDistance = SquareRoot(dx * dx + dy * dy)
set udg_Knockback2DUnit = dum
call TriggerExecute(gg_trg_Knockback_2D)
call SetUnitFlyHeight(dum, startz, 0)
if dur == 0 then
call SetUnitFlyHeight(dum, endz, 0)
else
call SetUnitFlyHeight(dum, endz, endz / dur)
endif
call SetUnitLookAt(u, "bone_head", dum, 0, 0, 0)
set udg_LookDum_Int = udg_LookDum_Int + 1
set udg_LookDum[udg_LookDum_Int] = dum
call RemoveLocation(l)
set l = null
set dum = null
endfunction
In these examples I have 2 Problems:
When a unit is near my Knockbacked unit, it will be swiped to the so they wont collide, what I want it to be the opposite (Walking timed into a gate and the gate moves XD or even when looking somewhere the target slowly moves XDer)- Is the Distance doubled? Do I have to use a
n / 2
Before allset udg_Knockback2DDistance = SquareRoot(dx * dx + dy * dy)
? Or maybe this has problems (which is weird if so)?
JASS:// Yea, this is DistanceBetweenPoints(locA, locB) local real dx = GetLocationX(locB) - GetLocationX(locA) local real dy = GetLocationY(locB) - GetLocationY(locA) return SquareRoot(dx * dx + dy * dy)
Any help is appreciated.