Hey, I'm developing my entrance-exit-and-respawn system. I'm stuck in the entrance yet. Take a look at the code:
The problem is: the region is not detected (I enter the region with my hero but it doesn't work - not even the message appears. Does anyone understands about regions here? I really need this system, it will make my life a lot better. Thanks in advance
JASS:
library RegionsAndRespawn initializer onInit
globals
private rect array DUNGEON_GRAVEYARD_RECT
private rect array DUNGEON_ENTRANCE_RECT
private rect array DUNGEON_ENTERED_RECT
private rect array DUNGEON_RECT_RECT
private rect array DUNGEON_EXIT_RECT
private region array DUNGEON_GRAVEYARD
private region array DUNGEON_ENTRANCE
private region array DUNGEON_ENTERED
private region array DUNGEON_RECT
private region array DUNGEON_EXIT
private integer DUNGEON_COUNT = 1
endglobals
private function DungeonEnter takes nothing returns nothing
local unit u = GetEnteringUnit()
local integer i = 0
local real x
local real y
call BJDebugMsg("Unit entered region")
loop
if GetTriggeringRegion() == DUNGEON_ENTRANCE[i] then
set x = GetRectCenterX(DUNGEON_ENTERED_RECT[i])
set y = GetRectCenterY(DUNGEON_ENTERED_RECT[i])
call BJDebugMsg("x: " + R2S(x) + "...... y: " + R2S(y))
call SetUnitPosition(u, x, y)
endif
exitwhen i >= DUNGEON_COUNT - 1
set i = i + 1
endloop
set u = null
endfunction
private function DungeonEnterCondition takes nothing returns boolean
local unit u = GetEnteringUnit()
return IsUnitType(u, UNIT_TYPE_HERO) and GetPlayerController(GetOwningPlayer(u)) == MAP_CONTROL_USER
endfunction
private function onInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
//DUNGEONS SETTINGS
set DUNGEON_RECT_RECT[0] = gg_rct_dung01
set DUNGEON_GRAVEYARD_RECT[0] = gg_rct_dung01gy
set DUNGEON_ENTRANCE_RECT[0] = gg_rct_dung01entrance
set DUNGEON_ENTERED_RECT[0] = gg_rct_dung01entered
set DUNGEON_EXIT_RECT[0] = gg_rct_dung01exit
loop
call RegionAddRect(DUNGEON_RECT[i], DUNGEON_RECT_RECT[i])
call RegionAddRect(DUNGEON_GRAVEYARD[i], DUNGEON_GRAVEYARD_RECT[i])
call RegionAddRect(DUNGEON_ENTRANCE[i], DUNGEON_ENTRANCE_RECT[i])
call RegionAddRect(DUNGEON_ENTERED[i], DUNGEON_ENTERED_RECT[i])
call RegionAddRect(DUNGEON_EXIT[i], DUNGEON_EXIT_RECT[i])
call TriggerRegisterEnterRegion(t, DUNGEON_ENTRANCE[i], null)
exitwhen i >= DUNGEON_COUNT - 1
set i = i + 1
endloop
call TriggerAddAction(t, function DungeonEnter)
call TriggerAddCondition(t, function DungeonEnterCondition)
set t = null
endfunction
endlibrary
The problem is: the region is not detected (I enter the region with my hero but it doesn't work - not even the message appears. Does anyone understands about regions here? I really need this system, it will make my life a lot better. Thanks in advance