Azlier
Old World Ghost
- Reaction score
- 461
I'm making a private system to quickly create teleporting "doors". You know, step in one rect, come out another.
For some reason, it's teleporting me to unpredictable places, as if I mixed up x and y somewhere. I use rectwraps (see signature), and debug messages are telling me that those are acting correctly. However, I can't find where I went wrong...
[EDIT]
Well, found the problem. I tried to turn a rectwrap directly into a stairway. My bad.
[/EDIT]
For some reason, it's teleporting me to unpredictable places, as if I mixed up x and y somewhere. I use rectwraps (see signature), and debug messages are telling me that those are acting correctly. However, I can't find where I went wrong...
[EDIT]
Well, found the problem. I tried to turn a rectwrap directly into a stairway. My bad.
[/EDIT]
JASS:
library Stairs initializer Init requires Main, rectwrap
globals
private constant integer STAIR_ID = 039;B002039;
endglobals
struct Staircase
private rectwrap Entrance
private rectwrap Exit
private real ExitX
private real ExitY
private real EnterX
private real EnterY
private trigger EnterTrig = CreateTrigger()
private trigger ExitTrig = CreateTrigger()
private static method EnterStairs takes nothing returns boolean
local thistype this = GetTriggeringRectwrap()
local unit u = GetTriggerUnit()
local integer i = GetPlayerId(GetOwningPlayer(u))
if i < 12 and i > -1 then
call SetUnitX(u, .EnterX)
call SetUnitY(u, .EnterY)
endif
set u = null
return false
endmethod
private static method ExitStairs takes nothing returns boolean
local thistype this = thistype(GetTriggeringRectwrap().userData)
local unit u = GetTriggerUnit()
local integer i = GetPlayerId(GetOwningPlayer(u))
if i < 12 and i > -1 then
call SetUnitX(u, .ExitX)
call SetUnitY(u, .ExitY)
endif
set u = null
return false
endmethod
static method create takes rect E, real EX, real EY, rect X, real XX, real XY returns thistype
local thistype this = thistype.allocate()
set .Entrance = rectwrap.wrap(E)
set .Exit = rectwrap.wrap(X)
set .EnterX = .Entrance.cenX + EX
set .EnterY = .Entrance.cenY + EY
set .ExitX = .Exit.cenX + XX
set .ExitY = .Exit.cenY + XY
call .Entrance.registerEnter(.EnterTrig)
call .Exit.registerEnter(.ExitTrig)
call TriggerAddCondition(.EnterTrig, Filter(function thistype.EnterStairs))
call TriggerAddCondition(.ExitTrig, Filter(function thistype.ExitStairs))
set .Entrance.userData = this
set .Exit.userData = this
return this
endmethod
method enable takes nothing returns nothing
call EnableTrigger(.EnterTrig)
call EnableTrigger(.ExitTrig)
endmethod
method disable takes nothing returns nothing
call DisableTrigger(.EnterTrig)
call DisableTrigger(.ExitTrig)
endmethod
endstruct
private function EnumStairs takes nothing returns boolean
if GetDestructableTypeId(GetFilterDestructable()) == STAIR_ID then
call SetDestructableAnimation(GetFilterDestructable(), "stand alternate")
endif
return false
endfunction
private function Init takes nothing returns nothing
call Map.enumDestructables(Filter(function EnumStairs), null)
endfunction
endlibrary