I wanted to ask someone to help me with the function that checks whether the remaining dash distance is bigger than the length of the not walkable path. The idea of this function is to have a check for knockback and dash spells, so they stop the movement if they can't cross a walkable path, similar to LoL. As far as I understand, the system should use the same algorithm in order to avoid problems: Bresenham Pathchecker. Unfortunately, I don't really understand it to rebuild another system.
Here is my previous attempt, but it does not account for NonWalkablePath properly:
Here is my previous attempt, but it does not account for NonWalkablePath properly:
JASS:
library IsRemaningDistMoreThanObject /*
*/uses /*
*/TerrainPathability
globals
private integer ACCURACY = 64
endglobals
function IsRemaningDistMoreThanObject takes real xMove, real yMove, real angle, real speed, real distLeft returns boolean
local real deltaX
local real deltaY
local real traveled
local real x
local real y
local real x1 = xMove + ModuloReal(xMove, ACCURACY)- ACCURACY/2
local real x2
if xMove > x1 then
set x2 = x1 + ACCURACY
else
set x2 = x1 - ACCURACY
endif
if not IsTerrainWalkable(xMove, yMove) and not IsTerrainWalkable(x1, yMove) and not IsTerrainWalkable(x2, yMove) then
set deltaX = Cos(angle * bj_DEGTORAD) * ACCURACY
set deltaY = Sin(angle * bj_DEGTORAD) * ACCURACY
set traveled = speed
set x = xMove
set y = yMove
loop
exitwhen traveled >= distLeft or (IsTerrainWalkable(x, y) and IsTerrainWalkable(x1, y) and IsTerrainWalkable(x2, y))
set x = x + deltaX
set y = y + deltaY
set x1 = x + ModuloReal(x, ACCURACY)- ACCURACY/2
if xMove > x1 then
set x2 = x1 + ACCURACY
else
set x2 = x1 - ACCURACY
endif
set traveled = traveled + ACCURACY
endloop
debug call BJDebugMsg("[Shunpo] Distance Remaning" + R2S(distLeft))
debug call BJDebugMsg("[Shunpo] Traveled Distance " + R2S(traveled))
return traveled >= distLeft
endif
return false
endfunction
endlibrary