I'm now having some trouble with a variable. I attempt to have 2 players duel, and I create two unit vars, challenger and challengee. I want to apply some exceptions to these characters, like they're the only units allowed in the arena, and they can't leave it, etc. My problem seems to occur whenever i go to a new trigger, the editor forgets the variables, so no one wins the duel and the arena is closed for the rest of the game. Any easy solutions for this?
you have to be a bit more specific, maybe a copy of the triggers...
cause the game will only 'forget' about variables if they are designated local to a trigger, which, all variables created through the GUI editor are not local
so the only way for the variables to change is if something else changed them again after they had been initially set and before the 'other' trigger got to them, or that something else is wrong to begin with
can't be much more specific though without knowing more
Here is the first trigger, this one seems to work fine:
challenge Events Player - Player 1 (Red) types a chat message containing -challenge as An exact match Player - Player 2 (Blue) types a chat message containing -challenge as An exact match Player - Player 3 (Teal) types a chat message containing -challenge as An exact match Player - Player 5 (Yellow) types a chat message containing -challenge as An exact match Player - Player 6 (Orange) types a chat message containing -challenge as An exact match Player - Player 7 (Green) types a chat message containing -challenge as An exact match Player - Player 9 (Gray) types a chat message containing -challenge as An exact match Player - Player 10 (Light Blue) types a chat message containing -challenge as An exact match Conditions Actions Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions Set challenger = (Picked unit) Unit Group - Pick every unit in (Units in arena <gen> owned by (Triggering player)) and do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Picked unit) Equal to challenger Then - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions ((Triggering player) is an ally of Player 1 (Red)) Equal to True Then - Actions Dialog - Clear challenge Dialog - Change the title of challenge to Challenge: If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Player 2 (Blue) slot status) Equal to Is playing Then - Actions Dialog - Create a dialog button for challenge labelled (Name of Player 2 (Blue)) Set challenge1 = (Last created dialog Button) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Player 3 (Teal) slot status) Equal to Is playing Then - Actions Dialog - Create a dialog button for challenge labelled (Name of Player 3 (Teal)) Set challenge2 = (Last created dialog Button) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Player 9 (Gray) slot status) Equal to Is playing Then - Actions Dialog - Create a dialog button for challenge labelled (Name of Player 9 (Gray)) Set challenge3 = (Last created dialog Button) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Player 10 (Light Blue) slot status) Equal to Is playing Then - Actions Dialog - Create a dialog button for challenge labelled (Name of Player 10 (Light Blue)) Set challenge4 = (Last created dialog Button) Else - Actions Do nothing Dialog - Create a dialog button for challenge labelled Cancel Set challengecancel = (Last created dialog Button) Dialog - Show challenge for (Triggering player) Else - Actions Dialog - Clear challenge Dialog - Change the title of challenge to Challenge: If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Player 1 (Red) slot status) Equal to Is playing Then - Actions Dialog - Create a dialog button for challenge labelled (Name of Player 1 (Red)) Set challenge1 = (Last created dialog Button) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Player 5 (Yellow) slot status) Equal to Is playing Then - Actions Dialog - Create a dialog button for challenge labelled (Name of Player 5 (Yellow)) Set challenge2 = (Last created dialog Button) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Player 6 (Orange) slot status) Equal to Is playing Then - Actions Dialog - Create a dialog button for challenge labelled (Name of Player 6 (Orange)) Set challenge3 = (Last created dialog Button) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Player 7 (Green) slot status) Equal to Is playing Then - Actions Dialog - Create a dialog button for challenge labelled (Name of Player 7 (Green)) Set challenge4 = (Last created dialog Button) Else - Actions Do nothing Dialog - Create a dialog button for challenge labelled Cancel Set challengecancel = (Last created dialog Button) Dialog - Show challenge for (Triggering player) Else - Actions Game - Display to (All players matching ((Matching player) Equal to (Triggering player))) the text: You must be in the ... Trigger - Turn off (This trigger)
This second one works too, but I had to readd picking of the triggering player's units because I noticed it didn't list the owner of unit in the game message:
set contest Events Dialog - A dialog button is clicked for challenge Conditions (Clicked dialog button) Not equal to challengecancel Actions Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions Set challenger = (Picked unit) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions ((Triggering player) is an ally of Player 1 (Red)) Equal to True Then - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Clicked dialog button) Equal to challenge1 Then - Actions Unit Group - Pick every unit in (Units owned by Player 2 (Blue) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions Set challengee = (Picked unit) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Clicked dialog button) Equal to challenge2 Then - Actions Unit Group - Pick every unit in (Units owned by Player 3 (Teal) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions Set challengee = (Picked unit) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Clicked dialog button) Equal to challenge3 Then - Actions Unit Group - Pick every unit in (Units owned by Player 2 (Blue) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions Set challengee = (Picked unit) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Clicked dialog button) Equal to challenge4 Then - Actions Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions Set challengee = (Picked unit) Else - Actions Do nothing Else - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Clicked dialog button) Equal to challenge1 Then - Actions Unit Group - Pick every unit in (Units owned by Player 1 (Red) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions Set challengee = (Picked unit) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Clicked dialog button) Equal to challenge2 Then - Actions Unit Group - Pick every unit in (Units owned by Player 5 (Yellow) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions Set challengee = (Picked unit) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Clicked dialog button) Equal to challenge3 Then - Actions Unit Group - Pick every unit in (Units owned by Player 6 (Orange) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions Set challengee = (Picked unit) Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Clicked dialog button) Equal to challenge4 Then - Actions Unit Group - Pick every unit in (Units owned by Player 7 (Green) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions Set challengee = (Picked unit) Else - Actions Do nothing Game - Display to (All players) the text: ((Name of (Owner of challenger)) + ( has challenged + ((Name of (Owner of challengee)) + to a duel!))) Game - Display to (All players) the text: (Sorry, this is unr... Unit Group - Pick every unit in (Units in arena <gen> matching ((Matching unit) Not equal to challenger)) and do (Actions) Loop - Actions Unit - Move (Picked unit) instantly to (Center of city center <gen>) Unit - Move challenger instantly to (Center of arena1 <gen>) Unit - Move challengee instantly to (Center of arena2 <gen>) Unit - Set life of challengee to 100.00% Unit - Set life of challenger to 100.00% Unit - Set mana of challengee to 100.00% Unit - Set mana of challenger to 100.00% Trigger - Turn on buffer in <gen> Trigger - Turn on buffer out <gen>
Here's where I notice problems. It allows both players to leave the arena, and the other doesn't allow anyone, even the fighters in:
buffer out Events Unit - A unit leaves arena <gen> Conditions (challenge <gen> is on) Equal to False Actions Game - Display to (All players matching ((Matching player) Equal to (Owner of (Triggering unit)))) the text: You cannot leave th... Unit - Move (Triggering unit) instantly to (Center of arena <gen>) Unit - Cause (Triggering unit) to damage (Triggering unit), dealing 25.00 damage of attack type Chaos and damage type Normal
buffer in Events Unit - A unit enters arena <gen> Conditions And - All (Conditions) are true Conditions (Triggering unit) Not equal to challengee (Triggering unit) Not equal to challenger Actions Game - Display to (All players matching ((Matching player) Equal to (Owner of (Triggering unit)))) the text: Do not interfere in... Unit - Move (Triggering unit) instantly to (Center of city center <gen>) Unit - Cause (Triggering unit) to damage (Triggering unit), dealing 100.00 damage of attack type Chaos and damage type Normal
And this next one just plainly doesn't work:
reset challenge Events Unit - A unit Dies Conditions Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Dying unit) Equal to challenger Then - Actions Game - Display to (All players) the text: ((Name of (Owner of challengee)) + has won the challenge!) Unit - Set life of challengee to 100.00% Unit - Move challengee instantly to (Center of city center <gen>) Trigger - Turn on challenge <gen> Trigger - Turn off buffer in <gen> Trigger - Turn off buffer out <gen> Else - Actions Do nothing If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Dying unit) Equal to challengee Then - Actions Game - Display to (All players) the text: ((Name of (Owner of challenger)) + has won the challenge!) Unit - Set life of challenger to 100.00% Unit - Move challenger instantly to (Center of city center <gen>) Trigger - Turn on challenge <gen> Trigger - Turn off buffer in <gen> Trigger - Turn off buffer out <gen> Else - Actions Do nothing Set challengee = No unit Set challenger = No unit
And I'll add the last one, but I don't think it's important:
cancel challenge Events Dialog - A dialog button is clicked for challenge Conditions (Clicked dialog button) Equal to challengecancel Actions Trigger - Turn on challenge <gen>
Well, is that any help? Also, if you know anyway to streamline this thing, please let me know. Thanks for any help you all provide.
i hope this does help you, even though i did not use enough time to doublecheck everything by typing it...
variables boolean - challenging dialogue - dlg_challenge array - dialogue button - dlg_btn_challenge area - arena triggers initDialogue event: map init cond: action: create dialogue titled 'choose oponent' set dlg_challenge = last created dialogue for Integer A = 1 to 12 do if cond: and player(Integer A) slot status = playing player(Integer A) contoller = user act: add button titled(playername(Integer A)) to (dlg_challenge) set dlg_btn_challenge[Integer A] = last created dialogue button endif endfor
StartChallenge event: player(1 to 12) types -challenge cond: action: if challenging = false then set challengeing = true show dialog dlg_challenge to triggering player else Display Text to Player(triggering player, "challenge already running"
PickOponent event: dialog button clicked for dlg_challenge cond: event: for Integer A = 1 to 12 if (clicked dialog button) = (dlg_btn_challenge[Integer A]) then set challenger = GetRandomUnit(triggering player, matching(unit = hero)) set challenged = GetRandomUnit(player(Integer A), matching(unit = hero)) endif endfor move unit challenger to arena move unit challenged to arena
LeaveArena event: unit leaves region(arena) cond: or unit = challenger unit = challenged endor action: move unit(triggering unit) instantly to (point with polar offset - position of triggering unit with polaroffset towards center of(arena) by 200)
EntersArena event: unit enters region(arena) cond: and unit not = challenger unit not = challenged endand action: move unit(triggering unit) instantly to (point with polar offset - position of triggering unit with polaroffset towards center of(arena) by -200)
EndChallenge event: unit dies cond: or unit = callenger unit = challenged endor action: if unit = challenger then set life(challenged) = 100% set mana(challenged) = 100% move (challenged) = <whereever you want> else set life(challenger) = 100% set mana(challenger) = 100% move (challenger) = <whereever you want> call set udg_challenged = null call set udg_challenger = null set challenging = false
InitDialogues ... create dialogue 'oponent from team 1' set dlg_challenge[1] = last created create dialogue 'oponent from team 2' set dlg_challenge[2] = last created
for Integer A = 1 to 6 do add button 'playername(Integer A)' dlg_challenge[2] set dlg_btn_challenge[Integer A] = last created endfor
for Integer A = 7 to 12 do add button 'playername(Integer A)' dlg_challenge[1] set dlg_btn_challenge[Integer A] = last created endfor
PickOponent event: btn is clicked for dlg_challenge[1] btn is clicked for dlg_challenge[2] //rest as before