I am trying to make a teleporting trigger and I can't get the teleporting trigger to accept the variables stored by another trigger.
The trigger that is supposed to store the variables in global arrays looks like this:
Please ignore the commented BJDebugMsg's. Using them as function debugging as I'm fairly new to JASS and really new to vJASS.
Next is the trigger that is supposed to use the stored variables: (trigger is part of a larger scope hence no scope - endscope)
So, any help and explanation would be appreciated greatly.
Please just take into account, that I'm nowhere near any decent level of utilizing JASS and vJASS yet.
The trigger that is supposed to store the variables in global arrays looks like this:
JASS:
globals
unit array OrderedUnit
real array OrderX
real array OrderY
integer array OrderID
endglobals
scope OrderDetection initializer Init
private function EventFilter takes nothing returns boolean
if not( IsUnitType( GetFilterUnit(), UNIT_TYPE_HERO ) ) then
//call BJDebugMsg("Ordered unit is not a hero.")
return false
else
endif
return true
endfunction
private function Actions takes nothing returns nothing
local integer A = ( GetPlayerId( GetOwningPlayer( GetOrderedUnit() ) ) + 1 )
set OrderedUnit[A] = GetOrderedUnit()
set OrderX[A] = GetOrderPointX()
set OrderY[A] = GetOrderPointY()
set OrderID[A] = GetIssuedOrderId()
//call BJDebugMsg( "Player Nr: " + I2S(A) )
//call BJDebugMsg( "Unit: " + GetUnitName(OrderedUnit[A]) + ". Order: " + OrderId2String(Order[A]) + "." )
//call BJDebugMsg( "OrderX: " + R2S(OrderX[A]) + ". OrderY: " + R2S(OrderY[A]) + "." )
set A = 0
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer I = 0
loop
exitwhen I == 8
call TriggerRegisterPlayerUnitEvent( t, Player(I), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, Filter( function EventFilter ) )
set I = I +1
endloop
call TriggerAddAction( t, function Actions )
set t = null
endfunction
endscope
Please ignore the commented BJDebugMsg's. Using them as function debugging as I'm fairly new to JASS and really new to vJASS.
Next is the trigger that is supposed to use the stored variables: (trigger is part of a larger scope hence no scope - endscope)
JASS:
globals
real EnterId = 0
real ExitId = 0
endglobals
private function TpConditions takes nothing returns boolean
local unit tester = GetEnteringUnit()
if not( IsUnitEnemy(tester, Bayus) ) then
//call BJDebugMsg("Can not teleport; unit not enemy of Bayus")
set tester = null
return false
else
endif
if not( IsUnitType(tester, UNIT_TYPE_HERO) ) then
call BJDebugMsg("Only heroes can teleport")
set tester = null
return false
else
endif
set tester = null
return true
endfunction
private struct TpData
string FxA = null
string FxB = null
unit U = null
real Xa = 0
real Ya = 0
real Xb = 0
real Yb = 0
player P = null
boolean Selected = false
endstruct
private function AfterWait takes nothing returns boolean
local TpData d = TpData(KT_GetData())
call DestroyEffect(AddSpecialEffect( d.FxB, d.Xb, d.Yb))
call SetUnitPosition( d.U, d.Xb, d.Yb )
call SetUnitInvulnerable( d.U, false )
call PauseUnit( d.U, false )
call ShowUnit( d.U, true )
if d.Selected == true then
if (GetLocalPlayer() == d.P ) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call ClearSelection()
call SelectUnit( d.U, true)
else
endif
else
endif
call IssuePointOrderById( OrderedUnit[A], OrderID[A], OrderX[A], OrderY[A] ) //<-- This won't so anything because the variables null and 0 respectively.
call d.destroy()
//set A = 0
return true // No returning false for a simple wait, it only fires one time.
endfunction
private function TpActions takes nothing returns nothing
local TpData d = TpData.create()
local real Id = GetHandleId(GetTriggeringRegion())
local integer A = ( GetPlayerId( GetOwningPlayer( GetEnteringUnit() ) ) + 1 )
if TpConditions() then
if Id == ExitId then
call BJDebugMsg("Your hero is exiting town")
set d.FxA = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl"
set d.FxB = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl"
set d.U = GetEnteringUnit()
set d.Xa = GetUnitX( d.U )
set d.Ya = GetUnitY( d.U )
set d.Xb = GetRectCenterX( gg_rct_TpHeroCageDest )
set d.Yb = GetRectCenterY( gg_rct_TpHeroCageDest )
set d.P = GetOwningPlayer( d.U )
set d.Selected = IsUnitSelected( d.U, d.P )
call SetUnitInvulnerable( d.U, true )
call PauseUnit( d.U, true )
call DestroyEffect(AddSpecialEffect( d.FxA, d.Xa, d.Ya))
call ShowUnit( d.U, false )
call KT_Add(function AfterWait, d, 1.3)
else
endif
if Id == EnterId then
call BJDebugMsg("Your hero is entering town")
set d.FxA = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl"
set d.FxB = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl"
set d.U = GetEnteringUnit()
set d.Xa = GetUnitX( d.U )
set d.Ya = GetUnitY( d.U )
set d.Xb = GetRectCenterX( gg_rct_TpTownDest )
set d.Yb = GetRectCenterY( gg_rct_TpTownDest )
set d.P = GetOwningPlayer( d.U )
set d.Selected = IsUnitSelected( d.U, d.P )
call SetUnitInvulnerable( d.U, true )
call PauseUnit( d.U, true )
call DestroyEffect(AddSpecialEffect( d.FxA, d.Xa, d.Ya))
call ShowUnit( d.U, false )
call KT_Add(function AfterWait, d, 1.3)
else
endif
else
endif
call BJDebugMsg( "Player Nr: " + I2S(A) )
call BJDebugMsg( "Unit: " + GetUnitName(OrderedUnit[A]) + ". Order: " + OrderId2String(OrderID[A]) + "." )
call BJDebugMsg( "OrderX: " + R2S(OrderX[A]) + ". OrderY: " + R2S(OrderY[A]) + "." )
set Id = 0
endfunction
private function RegisterTp takes nothing returns nothing
local trigger t = CreateTrigger()
local region enter = CreateRegion()
local region exit = CreateRegion()
call RegionAddRect( enter, gg_rct_TpEnterTown )
call RegionAddRect( exit, gg_rct_TpExitTown )
set EnterId = GetHandleId(enter)
set ExitId = GetHandleId(exit)
call TriggerRegisterEnterRegion( t, enter, null)
call TriggerRegisterEnterRegion( t, exit, null)
call TriggerAddAction( t, function TpActions )
set t = null
endfunction
So, any help and explanation would be appreciated greatly.
Please just take into account, that I'm nowhere near any decent level of utilizing JASS and vJASS yet.