Name | Type | is_array | initial_value |
isWalkable | boolean | No | |
TempPoint | location | No |
//TESH.scrollpos=33
//TESH.alwaysfold=0
//------------------------------------------------------------------------------------------
// 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 CheckWalkabilityInit
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_16 = '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
endglobals
//---------------------- initialization function -----------------------------------------------------
function CheckWalkabilityInit 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)
endfunction
//------------------------ main function -------------------------------------------------
function 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
return false
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Checking_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A001'
endfunction
//------------
function Trig_Checking_Actions takes nothing returns nothing
local real x = GetLocationX(GetSpellTargetLoc())
local real y = GetLocationY(GetSpellTargetLoc())
local string p1 = "Point (" + I2S(R2I(x)) + ", " + I2S(R2I(y)) + ") "
local string s1
local string s2
local string s3
if CheckPathing(x,y,COLLISION_SIZE_16) then
set s1 = " |cff00ff00[16]walkable|r, "
else
set s1 = " |cfffa8072[16]NOTwalkable|r, "
endif
if CheckPathing(x,y,COLLISION_SIZE_32) then
set s2 = " |cff00ff00[32]walkable|r, "
else
set s2 = " |cfffa8072[32]NOTwalkable|r, "
endif
if CheckPathing(x,y,COLLISION_SIZE_48) then
set s3 = " |cff00ff00[48]walkable|r, "
else
set s3 = " |cfffa8072[48]NOTwalkable|r, "
endif
call DisplayTextToForce( GetPlayersAll(), p1 + s1 + s2 + s3)
set p1=null
set s1=null
set s2=null
set s3=null
endfunction
//===========================================================================
function InitTrig_TestSpellTargetPoint takes nothing returns nothing
set gg_trg_TestSpellTargetPoint = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_TestSpellTargetPoint, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_TestSpellTargetPoint, Condition( function Trig_Checking_Conditions ) )
call TriggerAddAction( gg_trg_TestSpellTargetPoint, function Trig_Checking_Actions )
endfunction