- Joined
- Aug 21, 2010
- Messages
- 17
Hi, I have this huge problem and I can't figure out how to solve it: I'm currently developing an AI for an altered melee map. At the beginning of this scenario, the human players choose a race through a dialog window, then the following trigger is run:
The trigger which sets the global variable all_ai_spawned is the following:
In each AI script the harvesting priority is more or less the same: send 4 or 5 workers to harvet gold, then 5 more to harvest lumber.
What happens is that sometimes the AI randomly chooses to send 5 workers to harves lumber, just like a "hidden AI" takes command and forces them to harvest lumber.
My first thought was the AI started before having a town with a mine, so having found none, it started harvest lumber, but now the trigger is checking the AI has at least one building before running the script.
Do you have any idea why?
-
GameStart
- Events
- Conditions
-
Actions
- Countdown Timer - Start countdown as a One-shot timer that will expire in 5.00 seconds
- Countdown Timer - Create a timer window for (Last started timer) with title Game starting in:
- Wait until ((Remaining time for countdown) Less than or equal to 0.00), checking every 0.10 seconds
- Countdown Timer - Hide (Last created timer window)
- Set game_started = True
- Trigger - Run Timer Board <gen> (ignoring conditions)
- Game - Display to (All players) the text: The battle has begu...
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- debugMode Equal to True
-
Then - Actions
-
Player Group - Pick every player in (All players controlled by a Computer player) and do (Actions)
-
Loop - Actions
- Unit - Create 1 Undead Citadel for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Unit - Create 4 Specter for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- AI - Start melee AI script for (Picked player): LodUndeadDemo.ai
-
Loop - Actions
-
Player Group - Pick every player in (All players controlled by a Computer player) and do (Actions)
-
Else - Actions
-
Player Group - Pick every player in (All players controlled by a Computer player) and do (Actions)
-
Loop - Actions
- Set aiRandInt = (Random integer number between 1 and 6)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- aiRandInt Equal to 1
-
Then - Actions
- Unit - Create 1 Undead Citadel for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Unit - Create 4 Specter for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Set ai_rand_list[ai_rand_list_index] = 1
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- aiRandInt Equal to 2
-
Then - Actions
- Unit - Create 1 Demon Gate for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Unit - Create 4 Demon Raider for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Set ai_rand_list[ai_rand_list_index] = 2
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- aiRandInt Equal to 3
-
Then - Actions
- Unit - Create 1 Argonian Command Center for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Unit - Create 4 Barbarian slave for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Set ai_rand_list[ai_rand_list_index] = 3
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- aiRandInt Equal to 4
-
Then - Actions
- Unit - Create 1 Eternal Tower for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Unit - Create 4 Elemental Worker for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Set ai_rand_list[ai_rand_list_index] = 4
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- aiRandInt Equal to 5
-
Then - Actions
- Unit - Create 1 Imperial Village for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Unit - Create 4 Citizen for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Set ai_rand_list[ai_rand_list_index] = 5
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- aiRandInt Equal to 6
-
Then - Actions
- Unit - Create 1 Bug Den for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Unit - Create 4 Ratling for (Picked player) at ((Picked player) start location) facing Default building facing degrees
- Set ai_rand_list[ai_rand_list_index] = 6
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Set ai_rand_list_index = (ai_rand_list_index + 1)
-
Loop - Actions
- Set ai_rand_list_index = 0
- Wait until (all_ai_spawned Equal to True), checking every 0.10 seconds
-
Player Group - Pick every player in (All players controlled by a Computer player) and do (Actions)
-
Loop - Actions
- Set aiRandInt = (Random integer number between 1 and 6)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ai_rand_list[ai_rand_list_index] Equal to 1
-
Then - Actions
- AI - Start melee AI script for (Picked player): LodUndeadDemo.ai
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ai_rand_list[ai_rand_list_index] Equal to 2
-
Then - Actions
- AI - Start melee AI script for (Picked player): LodDemonDemo.ai
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ai_rand_list[ai_rand_list_index] Equal to 3
-
Then - Actions
- AI - Start melee AI script for (Picked player): LodArgonianDemo.ai
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ai_rand_list[ai_rand_list_index] Equal to 4
-
Then - Actions
- AI - Start melee AI script for (Picked player): LodInquisitionDemo.ai
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ai_rand_list[ai_rand_list_index] Equal to 5
-
Then - Actions
- AI - Start melee AI script for (Picked player): LodEmpireDemo.ai
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ai_rand_list[ai_rand_list_index] Equal to 6
-
Then - Actions
- AI - Start melee AI script for (Picked player): LodBugDemo.ai
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Set ai_rand_list_index = (ai_rand_list_index + 1)
-
Loop - Actions
-
Player Group - Pick every player in (All players controlled by a Computer player) and do (Actions)
-
If - Conditions
- Set defeatEnabled = True
- Wait 1.00 seconds
- Trigger - Run InactivePlayers <gen> (ignoring conditions)
The trigger which sets the global variable all_ai_spawned is the following:
-
ChekAISpawn
-
Events
- Time - Every 0.10 seconds of game time
-
Conditions
- game_started Equal to True
-
Actions
- Trigger - Turn off (This trigger)
- Set all_ai_spawned = False
-
Player Group - Pick every player in (All players controlled by a Computer player) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Count structures controlled by (Picked player) (Exclude incomplete structures)) Greater than 0
-
Then - Actions
- Set all_ai_spawned = True
-
Else - Actions
- Set all_ai_spawned = False
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
- If (all_ai_spawned Equal to True) then do (Do nothing) else do (Trigger - Turn on (This trigger))
-
Events
In each AI script the harvesting priority is more or less the same: send 4 or 5 workers to harvet gold, then 5 more to harvest lumber.
What happens is that sometimes the AI randomly chooses to send 5 workers to harves lumber, just like a "hidden AI" takes command and forces them to harvest lumber.
My first thought was the AI started before having a town with a mine, so having found none, it started harvest lumber, but now the trigger is checking the AI has at least one building before running the script.
Do you have any idea why?