HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trigger and AI: 2 questions

02-24-2009, 01:53 PM#1
Michael Peppers
1. I need to trigger something (using only GUI) that can change a player's color in a multiboard according to its real color. That sounds simple, but I'd want to avoid huge code like this:

Trigger:
For each (Integer userCurrent) from 0 to 3, do (Actions)
Collapse If (all conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Color of userPlayers[userCurrent] equal to Red
Collapse Then - Actions
Collapse If (all conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(userPlayers[userCurrent]) equal to (Player (Red))
Collapse Then - Actions
Multiboard - set the color for (Last created multiboard) item in column 1, row 2 to (100%, 0%, 0%) with 0.00% transparency
Collapse Else - Actions
Collapse If (all conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(userPlayers[userCurrent]) equal to (Player (Blue))
Collapse Then - Actions
Multiboard - set the color for (Last created multiboard) item in column 1, row 3 to (100%, 0%, 0%) with 0.00% transparency
Collapse Else - Actions
Collapse If (all conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(userPlayers[userCurrent]) equal to (Player (Teal))
Collapse Then - Actions
Multiboard - set the color for (Last created multiboard) item in column 1, row 4 to (100%, 0%, 0%) with 0.00% transparency
Collapse Else - Actions
Collapse If (all conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(userPlayers[userCurrent]) equal to (Player (Purple))
Collapse Then - Actions
Multiboard - set the color for (Last created multiboard) item in column 1, row 5 to (100%, 0%, 0%) with 0.00% transparency
Collapse Else - Actions
Do Nothing
Collapse Else - Actions
(repeat above for color blue)

This for 12 colors and repeated unknown times.
Any ideas? (I accept also "there are no other ways in GUI to do this")

2. Don't worry with this, I found out that explaining why, giving examples etc. on this question takes me more time than finding a solution by myself.
Don't worry

A good suggestion for a Deathmatch AI (starts with 5000 gold and 2500 lumber), it needs only 2 buildings (except the hall) (are a Barracks and a Spellcaster's Den) to have its full potential (so all heroes, units, upgrades etc.). I have a small idea in regard to this but it seems more a bug-peeper than a good idea. Let me know.

02-24-2009, 06:48 PM#2
ShadowWolf
I'm assuming you meant to change each color to the player's respective color? In your sample code they were all set to red. Unfortunately GUI doens't have switchcase statements which would make things like this a lot easier, so instead you just have to copy paste 12 similar if/then/elses.
Trigger:
blah
Events
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
If ((Integer A) Equal to 1) then do (Multiboard - Set the color for (Last created multiboard) item in column 1, row ((Integer A) + 1) to (100.00%, 0.00%, 0.00%) with 0.00% transparency) else do (Do nothing)
If ((Integer A) Equal to 2) then do (Multiboard - Set the color for (Last created multiboard) item in column 1, row ((Integer A) + 1) to (0.00%, 0.00%, 100.00%) with 0.00% transparency) else do (Do nothing)
Etc.
02-24-2009, 06:52 PM#3
Michael Peppers
Quote:
Originally Posted by ShadowWolf
I'm assuming you meant to change each color to the player's respective color? In your sample code they were all set to red. Unfortunately GUI doens't have switchcase statements which would make things like this a lot easier, so instead you just have to copy paste 12 similar if/then/elses.
Trigger:
blah
Events
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
If ((Integer A) Equal to 1) then do (Multiboard - Set the color for (Last created multiboard) item in column 1, row ((Integer A) + 1) to (100.00%, 0.00%, 0.00%) with 0.00% transparency) else do (Do nothing)
If ((Integer A) Equal to 2) then do (Multiboard - Set the color for (Last created multiboard) item in column 1, row ((Integer A) + 1) to (0.00%, 0.00%, 100.00%) with 0.00% transparency) else do (Do nothing)
Etc.

The example was meant to give just a 1/12 of all the work (since writing all of that would be an enormous waste of space).

For your answer: (slap in the face) Why I ALWAYS get the most complicated way? Thanks. + Rep incoming.

EDIT:
Just found out that my multiboard trigger isn't flexible enough (because player number is variable in this map) to use a solution like ShadowWolf's, so (AAGGHH!) I have to use the big bunch of code.
02-24-2009, 07:53 PM#4
ShadowWolf
What do you mean, player number is variable? You're not using fixed player settings? If you elaborate, I still may be able to assist you.
02-24-2009, 08:20 PM#5
Michael Peppers
Quote:
Originally Posted by ShadowWolf
What do you mean, player number is variable? You're not using fixed player settings? If you elaborate, I still may be able to assist you.

The number varies from 2 to 4 players, and also the players are variable (2 players can be player 3 and 4, or player 1 and 3 etc.), and with this also the row position of a player's name. I guess I just found out something that may help me in this (to avoid too much doubling):

Trigger:
-Player 1
Collapse If (all conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player (Red) slot status) equal to In game
Collapse Then - Actions
Set RedInGame = 1 (default is 0)
Collapse If (all conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Color of Player (Red)) equal to Red
Collapse Then - Actions
Multiboard - set the color for (Last created multiboard) item in column 1, row 2 to (100%, 0%, 0%) with 0.00% transparency
Collapse Else - Actions
(Here I have to copy the next 11 colors)
Collapse Else - Actions
Do Nothing
-Player 2
Collapse If (all conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player (Blue) slot status) equal to In game
Collapse Then - Actions
Set BlueInGame = 1 (default is 0)
Collapse If (all conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Color of Player (Blue)) equal to Red
Collapse Then - Actions
Multiboard - set the color for (Last created multiboard) item in column 1, row 2 + RedInGame to (100%, 0%, 0%) with 0.00% transparency
Collapse Else - Actions
(Here I have to copy the next 11 colors
Collapse Else - Actions
Do Nothing

etcetera. For every next player, the row will have a new variable depending on other players' slot statuses (ex: player 3's row will be "2 + RedInGame + BlueInGame"). That's still a great bunch of work, but a little thinner (I guess using "For each" etc. has unfortunately no purpose here, like no one can have "Pick Every Player")
02-24-2009, 09:43 PM#6
ShadowWolf
Oh, mentioning that there were only four players would have made things easier.

The lazy but easiest way to do it would be to have it always set items 2-5 to their respective colors, the way I initially showed you, but check if each player is playing, and if that player isn't playing, then change that player's name on the multiboard to <Not Playing> or something like that. This method requires you to check "Fixed Player Settings" in Force Properties. In perspective, Player 1 is always Red, Player 2 is always Blue, etc. It would make things a lot easier on you unless you really want people to be able to pick whatever color they want while being a specific player number.
02-24-2009, 09:57 PM#7
Michael Peppers
Quote:
Originally Posted by ShadowWolf
Oh, mentioning that there were only four players would have made things easier.

The lazy but easiest way to do it would be to have it always set items 2-5 to their respective colors, the way I initially showed you, but check if each player is playing, and if that player isn't playing, then change that player's name on the multiboard to <Not Playing> or something like that. This method requires you to check "Fixed Player Settings" in Force Properties. In perspective, Player 1 is always Red, Player 2 is always Blue, etc. It would make things a lot easier on you unless you really want people to be able to pick whatever color they want while being a specific player number.

Unfortunately, I started modifying the trigger today from something very similar to this, (red for 1, blue for 2 etc.) (exception for items always 2-5) so I think I won't turn back now since I modified 50+% of the trigger now.

It's a great bunch of (almost) useless code, but it seems to work (for now). Thanks anyway for the interest (without your aid today probably I wouldn't have thought about the pair of variables that now are shortening my code (and saving my life XD))