Hi, I'm having trouble with a waypoint system. Basically what's supposed to happen is a hero enters an area, a dialog pops up and they can teleport to other places (similar to diablo 2). The problem is that whenever a hero enters the area, the dialog box pops up for all players in the game, not just the owner of the triggering hero. Also, there is another trigger that creates a unit and shifts all items from the old one to the new one then destroys the old unit. When this occurs it is also popping up with the dialog box. There may be a couple other instances where the box is popping up unexpectedly (as far as I can tell it's usually related to a hero being created, it doesn't fire off dummy casters).
On an unrelated note, does anyone know of a good tutorial explaining the differences and workings of the various data attachment systems, I'm only familiar with handlevars but have heard of half a dozen others.
JASS:
library WaypointSystem initializer WP_Init
globals
trigger dial_action
trigger wp_action
button array buttons
rect array wp_locations
rect array wp_enters
dialog wp_d
endglobals
function DialogAction takes nothing returns nothing
local integer i = 0
local button b = GetClickedButton()
loop
exitwhen buttons[i] == b or i >9
set i = i + 1
endloop
call DialogDisplay(GetTriggerPlayer(), wp_d, false)
if i <6 then
call SetUnitX(udg_Heroes[GetPlayerId(GetTriggerPlayer())], GetRectCenterX(wp_locations[i]))
call SetUnitY(udg_Heroes[GetPlayerId(GetTriggerPlayer())], GetRectCenterY(wp_locations[i]))
call SetUnitX(udg_Backpacks[GetPlayerId(GetTriggerPlayer())], GetRectCenterX(wp_locations[i]))
call SetUnitY(udg_Backpacks[GetPlayerId(GetTriggerPlayer())], GetRectCenterY(wp_locations[i]))
call IssueImmediateOrder(udg_Heroes[GetPlayerId(GetTriggerPlayer())], "stop")
endif
set b= null
endfunction
function MakeWPDialog takes nothing returns nothing
local integer i = 0
set wp_d = DialogCreate()
call DialogClear(wp_d)
set buttons[0] = DialogAddButton(wp_d, "Town", 1)
set buttons[1] = DialogAddButton(wp_d, "Spider Forest", 2)
set buttons[2] = DialogAddButton(wp_d, "Twin Peaks", 3)
set buttons[3] = DialogAddButton(wp_d, "Forest", 4)
set buttons[4] = DialogAddButton(wp_d, "River", 5)
set buttons[5] = DialogAddButton(wp_d, "Taehl's Gauntlet", 6)
set buttons[6] = DialogAddButton(wp_d, "DONT CLICK", 7)
set buttons[7] = DialogAddButton(wp_d, "More...", 8)
set buttons[8] = DialogAddButton(wp_d, "Cancel", 9)
call DialogSetMessage(wp_d, "Where do you want to go?")
endfunction
function Waypoint_Event takes nothing returns nothing
local player p = GetOwningPlayer(GetTriggerUnit())
call DialogDisplay(p, wp_d, true)
endfunction
function WP_E_Cond takes nothing returns boolean
return IsUnitType(GetEnteringUnit(), UNIT_TYPE_HERO)
endfunction
function WP_Init takes nothing returns nothing
local integer i = 0
local rect r
set dial_action = CreateTrigger()
set wp_action = CreateTrigger()
call TriggerSleepAction(0.15)
call MakeWPDialog()
set wp_enters[i] = gg_rct_WP_To_Enter
set wp_locations[i] = gg_rct_WP_To_Tele
set i = i + 1
set wp_enters[i] = gg_rct_WP_SF_Enter
set wp_locations[i] = gg_rct_WP_SF_Tele
set i = i + 1
set wp_enters[i] = gg_rct_WP_TP_Enter
set wp_locations[i] = gg_rct_WP_TP_Tele
set i = i + 1
set wp_enters[i] = gg_rct_WP_Fo_Enter
set wp_locations[i] = gg_rct_WP_Fo_Tele
set i = i + 1
set wp_enters[i] = gg_rct_WP_Ri_Enter
set wp_locations[i] = gg_rct_WP_Ri_Tele
set i = i + 1
set wp_enters[i] = gg_rct_WP_TG_Enter
set wp_locations[i] = gg_rct_WP_TG_Tele
loop
exitwhen i < 0
if wp_enters[i] != null then
call TriggerRegisterEnterRectSimple(wp_action, wp_enters[i])
endif
set i = i - 1
endloop
call TriggerRegisterDialogEvent(dial_action, wp_d)
call TriggerAddAction(wp_action, function Waypoint_Event)
call TriggerAddCondition(wp_action, Condition(function WP_E_Cond))
call TriggerAddAction(dial_action, function DialogAction)
endfunction
endlibrary
On an unrelated note, does anyone know of a good tutorial explaining the differences and workings of the various data attachment systems, I'm only familiar with handlevars but have heard of half a dozen others.