HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with trigger - Ally selection system

06-11-2006, 07:37 PM#1
moyack
Hi everybody:

I'm working in a Ally selection system for my map. because my map has teams preselected (unfortunately I can't change this) I decided to set the alliance among players by dialog boxes. The first trigger shows the dialog for the user who type -SetAlly and the second one is who makes the alliance.

Variables:
  • AllyDialog: Dialog Array (4)
  • AllyDialogButton: DialogButton Array (16)
  • SelecterPlayer: Integer Array (4) //Stores the player number who selects
  • SelectedPlayer: Integer Array (4) //Stores the selected player number that SelecterPlayer has choosen
  • CounterUnits: local Integer
  • PlayerNumber: local Integer

The first Trigger work fine, the second one has problems, the game crashes when I select a player. I know that this happens when you try to call or set a player(0), but I browsed the code several times and I can't find any mistake. Any help will be apreciatted.

Create dialog selection:
Create dialog selection
Collapse Events
Player - Player 1 (Red) types a chat message containing -SetAlly as An exact match
Player - Player 2 (Blue) types a chat message containing -SetAlly as An exact match
Player - Player 3 (Teal) types a chat message containing -SetAlly as An exact match
Player - Player 4 (Purple) types a chat message containing -SetAlly as An exact match
Collapse Conditions
ChangeAlliance[((Player number of (Triggering player)) - 1)] Equal to True
Collapse Actions
Dialog - Clear AllyDialog[((Player number of (Triggering player)) - 1)]
Dialog - Change the title of AllyDialog[((Player number of (Triggering player)) - 1)] to Ally Selection
Collapse Player Group - Pick every player in (All players matching ((((Matching player) slot status) Equal to Is playing) and ((Player number of (Matching player)) Less than or equal to 4))) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Picked player) Not equal to (Triggering player)
Collapse Then - Actions
Dialog - Create a dialog button for AllyDialog[((Player number of (Triggering player)) - 1)] labelled (PlayerColors[((Player number of (Picked player)) - 1)] + (Name of (Picked player)))
Set AllyDialogButton[((4 x ((Player number of (Triggering player)) - 1)) + ((Player number of (Picked player)) - 1))] = (Last created dialog Button)
Else - Actions
Dialog - Show AllyDialog[((Player number of (Triggering player)) - 1)] for (Triggering player)
Ally Selected:
Ally Selected
Collapse Events
Dialog - A dialog button is clicked for AllyDialog[0]
Dialog - A dialog button is clicked for AllyDialog[1]
Dialog - A dialog button is clicked for AllyDialog[2]
Dialog - A dialog button is clicked for AllyDialog[3]
Conditions
Collapse Actions
Custom script: local integer udg_CounterUnits
Collapse For each (Integer CounterUnits) from 0 to 15, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to AllyDialogButton[CounterUnits]
Collapse Then - Actions
Set PlayerNumber = (CounterUnits mod 4)
Set SelecterPlayer[PlayerNumber] = (PlayerNumber + 1)
Set SelectedPlayer[PlayerNumber] = ((1 + CounterUnits) - (4 x (SelecterPlayer[PlayerNumber] - 1)))
Game - Display to (Player group((Player(SelectedPlayer[PlayerNumber])))) the text: ((PlayerColors[SelecterPlayer[PlayerNumber]] + (Name of (Player(SelecterPlayer[PlayerNumber])))) + |R wants to make an alliance with you. You have 10 seconds to accept.)
Player - Make (Player(SelecterPlayer[PlayerNumber])) treat (Player(SelectedPlayer[PlayerNumber])) as an Ally with shared vision
Set ChangeAlliance[SelecterPlayer[PlayerNumber]] = False
Set CounterUnits = 16
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player(SelectedPlayer[PlayerNumber])) is an ally of (Player(SelecterPlayer[PlayerNumber]))) Equal to True
Collapse Then - Actions
Game - Display to (All players) the text: (((PlayerColors[((Player number of (Player(SelecterPlayer[PlayerNumber]))) - 1)] + (Name of (Player(SelecterPlayer[PlayerNumber])))) + ((|R and + PlayerColors[((Player number of (Player(SelectedPlayer[PlayerNumber]))) - 1)]) + (Name of (Player(SelectedPlayer
Skip remaining actions
Else - Actions
Wait 10.00 seconds
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player(SelectedPlayer[PlayerNumber])) is an ally of (Player(SelecterPlayer[PlayerNumber]))) Equal to False
Collapse Then - Actions
Game - Display to (Player group((Player(SelecterPlayer[PlayerNumber])))) the text: ((PlayerColors[((Player number of (Player(SelectedPlayer[PlayerNumber]))) - 1)] + (Name of (Player(SelectedPlayer[PlayerNumber])))) + |R Has not accepted to be your ally.)
Player - Make (Player(SelecterPlayer[PlayerNumber])) treat (Player(SelectedPlayer[PlayerNumber])) as an Enemy
Set ChangeAlliance[SelecterPlayer[PlayerNumber]] = True
Else - Actions
06-11-2006, 07:46 PM#2
MercyfulJester
Hmm that AllyDialog(0) and all those might cause some problems, so why not just use larger numbers i.e 1-4.
06-11-2006, 07:58 PM#3
Captain Griffen
Several problems. Those triggers may cause it to call Player(0) in several ways, such as:

Trigger:
Set SelectedPlayer[PlayerNumber] = ((1 + CounterUnits) - (4 x (SelecterPlayer[PlayerNumber] - 1)))
Game - Display to (Player group((Player(SelectedPlayer[PlayerNumber])))) the text: ((PlayerColors[SelecterPlayer[PlayerNumber]] + (Name of (Player(SelecterPlayer[PlayerNumber])))) + |R wants to make an alliance with you. You have 10 seconds to accept.)

Also, you have a wait and then call upon a global variable, which may cause problems.