- Joined
- Mar 24, 2008
- Messages
- 184
So, i made this Pathability Check function for my charge spell, it seems to work fine, except in the case where there are items on the ground. Even though i made a check for items, the checked area is too big but if i reduce it even by 1, it doesn't work anymore in some points...
The problem is if i make an area covered by items, and put a wall in the middle of this items covered area, then it counts the wall as walkable area (in my charge spell, the caster will charge through the walls, which shouldn't happen). I know is a very unlikely to happen situation, but this bug pisses me up
I'm posting the code, the pathchecker unit is a dummy unit invulnerable, locusted and with no model, plus it has a permanent windwalk casted on it.
Any idea on how to improve this function?
You can see the function at work here (if you move on the right part of the map i put another hero and an area covered with items just for testing this feature): http://www.hiveworkshop.com/forums/spells-569/vjass-charge-0-92-a-135134/
The problem is if i make an area covered by items, and put a wall in the middle of this items covered area, then it counts the wall as walkable area (in my charge spell, the caster will charge through the walls, which shouldn't happen). I know is a very unlikely to happen situation, but this bug pisses me up
I'm posting the code, the pathchecker unit is a dummy unit invulnerable, locusted and with no model, plus it has a permanent windwalk casted on it.
Any idea on how to improve this function?
You can see the function at work here (if you move on the right part of the map i put another hero and an area covered with items just for testing this feature): http://www.hiveworkshop.com/forums/spells-569/vjass-charge-0-92-a-135134/
JASS:
//**************************************************************************
// ** **
// ** Check Pathability Function **
// ** ————————————— **
// ** **
// ** A Function that checks if a unit can walk over a certain area **
// ** (Ignores other units but not buildings, trees and other obstacles) **
// ** **
// ** By: Majin **
// **
// ** **
// **************************************************************************
library Walkable initializer init requires ChargeConfig
globals
unit pathchecker
boolean iteminrect=false
endglobals
function GetItems takes nothing returns nothing
set iteminrect = true
endfunction
function IsPointWalkable takes real x, real y returns boolean
local integer i=65
local rect r
local boolean b
call SetUnitPosition(pathchecker,x,y)
set b=(RAbs(GetUnitX(pathchecker)-x)<=1) and (RAbs((GetUnitY(pathchecker)-y))<=1)
if (b==false) then
set r=Rect(x-i,y-i,x+i,y+i)
call EnumItemsInRect(r,null,function GetItems)
set b=iteminrect
set iteminrect=false
call RemoveRect(r)
set r=null
endif
return b
endfunction
function init takes nothing returns nothing
set pathchecker=CreateUnit( Player(PLAYER_NEUTRAL_PASSIVE), PATHCHECKERID, 0, 0, 0)
call UnitAddAbility(pathchecker, SPELLPATHID)
call IssueImmediateOrder( pathchecker, "windwalk" )
endfunction
endlibrary