//------------------------------------------------------------------------------------------
// Check Walkability 1.08 (by ZibiTheWand3r3r)
// Thanks Almia, IcemanBo, Chaosy, BPower for help and tips.
//
// This snippet allows to check if given point is walkable for 48-size unit, 32-size unit and 16-size unit.
// It uses 3 dummy units + 1 custom ability. It checks walkability by: SetUnitPosition + Blink ability.
//
// How to import:
// 1. Copy this this trigger to your map.
// 2. From Object Editor copy custom ability named: Blink-PathChecker (A000) and
// three custom units: Dummy16 (o000), Dummy32 (o001) and Dummy48 (o002).
// 3. Use Ctrl+D to check copied units/ability numbers. If they differ from those given in ()
// then modify in globals section.
//
// --API--
// function CheckPathing takes real x, real y, integer collisionSize returns boolean
// use argument collisionSize: COLLISION_SIZE_16 or COLLISION_SIZE_32 or COLLISION_SIZE_48
// function returns true if point (x, y) is walkable for given-size units
//------------------------------------------------------------------------------------------
library CheckWalkability// initializer Init
globals
// user configuration: use Ctrl-D in ObjectEditor to see id of ability:
// if Blink-PathChecker ability id diffrent then A000, then type here the actual value:
private constant integer ABILITY_ID = 'A000'
// if Dummy16(peon) unit id diffrent then o000, then type here the actual value:
private constant integer DUMMY_ID = 'zsmc'//'o000'
// if Dummy32(grunt) unit id diffrent then o001, then type here the actual value:
//private constant integer DUMMY_ID_32 = 'o001'
// if Dummy48(tauren) unit id diffrent then o002, then type here the actual value:
//private constant integer DUMMY_ID_48 = 'o002'
//----------------------- don't change anything below -------------------------------------------
//constant integer COLLISION_SIZE_16 = 16
//constant integer COLLISION_SIZE_32 = 32
//constant integer COLLISION_SIZE_48 = 48
//private unit array checker
private unit u=null
endglobals
//------------------------ main function -------------------------------------------------
function IsPointWalkable/*CheckPathing*/ takes real x, real y/*, integer collisionSize*/ returns boolean
/*debug if checker[collisionSize] == null then
debug call BJDebugMsg(" Invalid argument, allowed is 16, 32, 48, use pre-defined keys to avoid malfunction")
debug return false
debug endif
call SetUnitPosition(checker[collisionSize], x, y)
if RAbsBJ(x-GetUnitX(checker[collisionSize])) <= 0.02 then
if RAbsBJ(y-GetUnitY(checker[collisionSize])) <= 0.02 then
call SetUnitX(checker[collisionSize], 0.00)
call SetUnitY(checker[collisionSize], 0.00)
return IssuePointOrder(checker[collisionSize], "blink", x, y)
endif
endif*/
call SetUnitPosition(u,x,y)
if(RAbsBJ(x-GetUnitX(u))<=.02 and RAbsBJ(y-GetUnitY(u))<=.02)then
//if RAbsBJ(y-GetUnitY(checker[collisionSize])) <= 0.02 then
call SetUnitX(u,0)
call SetUnitY(u,0)
return IssuePointOrderById(u,852525,x,y) and IssueImmediateOrderById(u,851973)//IssuePointOrder(u, "blink", x, y)
//endif
endif
return false
endfunction
//---------------------- initialization function -----------------------------------------------------
private module Init
static method onInit takes nothing returns nothing
/*set checker[COLLISION_SIZE_16] = CreateUnit(Player(15), DUMMY_ID_16, 0.00, 0.00, 0.00)
set checker[COLLISION_SIZE_32] = CreateUnit(Player(15), DUMMY_ID_32, 0.00, 0.00, 0.00)
set checker[COLLISION_SIZE_48] = CreateUnit(Player(15), DUMMY_ID_48, 0.00, 0.00, 0.00)
call UnitAddAbility(checker[COLLISION_SIZE_16], ABILITY_ID)
call UnitAddAbility(checker[COLLISION_SIZE_16], 'Avul')
call ShowUnit(checker[COLLISION_SIZE_16], false)
call UnitAddAbility(checker[COLLISION_SIZE_32], ABILITY_ID)
call UnitAddAbility(checker[COLLISION_SIZE_32], 'Avul')
call ShowUnit(checker[COLLISION_SIZE_32], false)
call UnitAddAbility(checker[COLLISION_SIZE_48], ABILITY_ID)
call UnitAddAbility(checker[COLLISION_SIZE_48], 'Avul')
call ShowUnit(checker[COLLISION_SIZE_48], false)*/
set u=CreateUnit(Player(15),DUMMY_ID,0,0,0)
call UnitAddAbility(u,ABILITY_ID)
call UnitAddAbility(u,'Avul')
call UnitRemoveAbility(u,'Aatk')
call ShowUnit(u,false)
endmethod
endmodule
private struct i extends array
implement Init
endstruct
endlibrary