MasterOfRa
New Member
- Reaction score
- 10
I'm trying to detect a rally place so i can do something when it happens. Either that or I need another way to detect right/left clicks
JASS:
library Terrain initializer Init
globals
private constant integer BLACK_TERRAIN = 039;Ydrt039;
private constant integer WHITE_TERRAIN = 039;Ydtr039;
private constant integer ICE_TERRAIN = 039;Yrtl039;
private constant integer BLACK_HERO = 039;Hblk039;
private constant integer WHITE_HERO = 039;Hwht039;
private constant integer ICE_HERO = 039;Hice039;
private integer terrainAoe = 1
private integer terrainShape = 0 // 0 is circle
endglobals
private function Periodic takes nothing returns nothing
local integer count = 0
local integer tType = 0
local real x
local real y
loop
if Escapers[count] != null then
if isAlive[count] then
set x = GetUnitX( Escapers[count])
set y = GetUnitY( Escapers[count])
set tType = GetTerrainType(x,y)
if tType == WHITE_TERRAIN then
call KillUnit(Escapers[count])
set isAlive[count] = false
call DestroyEffect(AddSpecialEffect(FID_frostnova,x,y))
elseif tType == ICE_TERRAIN then
call DestroyEffect(AddSpecialEffect(FID_skate,x,y))
endif
endif
endif
set count = count + 1
exitwhen count >= MAX_PLAYERS
endloop
endfunction
//===========================================================================
private function ActionsRally takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local location targetLoc = GetSpellTargetLoc()
local real x = GetLocationX(targetLoc)
local real y = GetLocationY(targetLoc)
if GetUnitTypeId(caster) == BLACK_HERO then
call SetTerrainType(0,0, BLACK_TERRAIN, -1, terrainAoe, terrainShape )
elseif GetUnitTypeId(caster) == WHITE_HERO then
call SetTerrainType(0,0, WHITE_TERRAIN, -1, terrainAoe, terrainShape )
elseif GetUnitTypeId(caster) == ICE_HERO then
call SetTerrainType(0,0, ICE_TERRAIN, -1, terrainAoe, terrainShape )
endif
call RemoveLocation(targetLoc)
set targetLoc = null
endfunction
//===========================================================================
private function ConditionsRally takes nothing returns boolean
call BJDebugMsg("Spell "+I2S(GetSpellAbilityId())+" cast")
call BJDebugMsg("Spell Tested For"+I2S(AID_RALLY))
return GetSpellAbilityId() == AID_RALLY
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition( trig, Condition( function ConditionsRally ) )
call TriggerAddAction( trig, function ActionsRally )
set trig = null
call SetTerrainType(0,0, BLACK_TERRAIN, -1, 8, 0 )
call TimerStart(NewTimer(),TT_PERIOD,true,function Periodic)
endfunction
endlibrary