First of all, I've got a trigger that causes the computer to build a random upgrade every ~2 minutes of game time (time is not accurate, and sometimes it researches after 20 seconds, but that's not the issue). What I'd like to know, is how can I set up my trigger so that the computer doesn't try to build an upgrade that it already has?
Trigger 1:
Level 1 Upgrades P1
Events
Timer - Every 120.0 seconds of Game Time
Local Variables
Conditions
(Player 1 Minerals) >= 10
(Controller of player 2) == User
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Protoss Ground Weapons Level 1 count for 1, counting Complete) == 1
(Protoss Ground Armors Level 1 count for 1, counting Complete) == 1
(Protoss Shields Level 1 count for 1, counting Complete) == 1
(Protoss Air Weapons Level 1 count for 1, counting Complete) == 1
(Protoss Air Armors Level 1 count for 1, counting Complete) == 1
Then
Trigger - Turn Level 2 Upgrades P1 On
Trigger - Turn (Current trigger) Off
Else
General - While (Conditions) are true, do (Actions)
Conditions
Or
Conditions
(Protoss Ground Weapons Level 1 count for 1, counting Complete) == 0
(Protoss Ground Armors Level 1 count for 1, counting Complete) == 0
(Protoss Shields Level 1 count for 1, counting Complete) == 0
(Protoss Air Weapons Level 1 count for 1, counting Complete) == 0
(Protoss Air Armors Level 1 count for 1, counting Complete) == 0
Actions
Variable - Set UpgradeLvL[1] = Forge - Upgrade Ground Weapons Level 1
Variable - Set UpgradeLvL[2] = Forge - Upgrade Ground Armor Level 1
Variable - Set UpgradeLvL[3] = Forge - Upgrade Shields Level 1
Variable - Set UpgradeLvL[4] = Cybernetics Core - Upgrade Air Weapons Level 1
Variable - Set UpgradeLvL[5] = Cybernetics Core - Upgrade Air Armor Level 1
Variable - Set RandomUpgrade = (Random integer between 1 and 5)
Variable - Set UpgradeLvL[6] = UpgradeLvL[RandomUpgrade]
Data Table - Save UpgradeLvL[6] as "RandomUpgrade" in the Local data table
Unit - Order Unit to (gv_upgradeLvL[6]) (Replace Existing Orders)
Trigger - Turn (Current trigger) Off
General - Wait 120.0 Real Time seconds
Trigger - Turn (Current trigger) On
Trigger 2 (and 3) looks exactly the same, only it's level 2 (and 3) of all the upgrades. So, how can I make it so it won't try to build the same upgrade more than once? Obviously with this, it causes the randomness to occasionally try to build the same thing again, which becomes a bit of a problem around the last 2 upgrades.
Either make a multiple if then else and check if an upgrade has already been researched and if so then find a random upgrade of the remaining ones.
Or set a boolean array which contains data about if an upgrade has already been researched and put all those actions of your trigger into a while loop which checks if the randomly chosen upgrade is already researched (via the boolean array) and if so will loop again (continue...) before actually ordering the unit to upgrade.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I'm going to try to ask this as best as I can..
First of all, I've got a trigger that causes the computer to build a random upgrade every ~2 minutes of game time (time is not accurate, and sometimes it researches after 20 seconds, but that's not the issue). What I'd like to know, is how can I set up my trigger so that the computer doesn't try to build an upgrade that it already has?
Trigger 1:
Level 1 Upgrades P1
Events
Timer - Every 120.0 seconds of Game Time
Local Variables
Conditions
(Player 1 Minerals) >= 10
(Controller of player 2) == User
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Protoss Ground Weapons Level 1 count for 1, counting Complete) == 1
(Protoss Ground Armors Level 1 count for 1, counting Complete) == 1
(Protoss Shields Level 1 count for 1, counting Complete) == 1
(Protoss Air Weapons Level 1 count for 1, counting Complete) == 1
(Protoss Air Armors Level 1 count for 1, counting Complete) == 1
Then
Trigger - Turn Level 2 Upgrades P1 On
Trigger - Turn (Current trigger) Off
Else
General - While (Conditions) are true, do (Actions)
Conditions
Or
Conditions
(Protoss Ground Weapons Level 1 count for 1, counting Complete) == 0
(Protoss Ground Armors Level 1 count for 1, counting Complete) == 0
(Protoss Shields Level 1 count for 1, counting Complete) == 0
(Protoss Air Weapons Level 1 count for 1, counting Complete) == 0
(Protoss Air Armors Level 1 count for 1, counting Complete) == 0
Actions
Variable - Set UpgradeLvL[1] = Forge - Upgrade Ground Weapons Level 1
Variable - Set UpgradeLvL[2] = Forge - Upgrade Ground Armor Level 1
Variable - Set UpgradeLvL[3] = Forge - Upgrade Shields Level 1
Variable - Set UpgradeLvL[4] = Cybernetics Core - Upgrade Air Weapons Level 1
Variable - Set UpgradeLvL[5] = Cybernetics Core - Upgrade Air Armor Level 1
Variable - Set RandomUpgrade = (Random integer between 1 and 5)
Variable - Set UpgradeLvL[6] = UpgradeLvL[RandomUpgrade]
Data Table - Save UpgradeLvL[6] as "RandomUpgrade" in the Local data table
Unit - Order Unit to (gv_upgradeLvL[6]) (Replace Existing Orders)
Trigger - Turn (Current trigger) Off
General - Wait 120.0 Real Time seconds
Trigger - Turn (Current trigger) On
Trigger 2 (and 3) looks exactly the same, only it's level 2 (and 3) of all the upgrades. So, how can I make it so it won't try to build the same upgrade more than once? Obviously with this, it causes the randomness to occasionally try to build the same thing again, which becomes a bit of a problem around the last 2 upgrades.
Two ideas:
Either make a multiple if then else and check if an upgrade has already been researched and if so then find a random upgrade of the remaining ones.
Or set a boolean array which contains data about if an upgrade has already been researched and put all those actions of your trigger into a while loop which checks if the randomly chosen upgrade is already researched (via the boolean array) and if so will loop again (continue...) before actually ordering the unit to upgrade.