Please see attached map and code screenshot. I'm trying to create a situation where I'm watching four computer players fight each other. I've tried many different things, including other AI scripts (like Mimic), AIDefaultEconomy, etc and I can't seem to get them to work in my map setup. If you fire up the attached map (which is a very simple approximation of a map I'm working on), you'll notice that sometimes computer players will send their workers to another start location to harvest. This is unpredictable however. I believe many of the problems here could be caused by the fact that I'm starting these players in arbitrary locations (not their "starting location" as in their player property). I can't seem to set this player property without going into the Player Properties dialog in the editor...which is not what I want anyway since I need to choose starting locations programmatically...not sure if that's the problem though.
Any help or insight on how I can get computers to fight each other with even dumb ai using the fewest lines of code possible, that would be great. This is just to test camera controls...I don't even really need it to actually be good AI...I've spent so much time on this compared to other features it's ridiculous.
Update: Two things. (1) Switching Neutral player to Neutral control enabled the correct placement of works (in between town hall and minerals) when spawned...also seemed to unlock other AI functionality. (2) Explicitly setting starting positions in Map > Player Properties enabled true melee AI. See attached map.
Does anyone know what the deal with (1) is? And does anyone know how I can change starting positions (same as Map > Player Properties) using code during runtime?
I was trying to crack the same problem. I tried to move the start locations with the Move Point trigger but it seems that either the game doesn't follow the starting locations, or they don't move at all. Either way, it doesn't work.
So now I'm back to trying to get the AI to act as normal melee AI and placing the starting units at run time manually with triggers.
I see it's been awhile since you posted this, but if you see this, lemme know if you've found anything more on this.
I moved the start location BEFORE. And still nothing. I tested a basic trigger on a blank map to move a starting point just to see, and it does not work period. anyways, it appears I found a workaround...
I used the Give Player standard melee units trigger (it's in the melee trigger field) instead of "give all players..." just give each player the units individually - then in a trigger after that, issue the 'start all melee ai for all comp. players'. I'll do some more testing, but so far, it looks like that does the trick.
Alright, so as it turns out, I just lucked out with the random placements of the comps that last test of mine. My guess is that if you have actual starting location points on the map (and since the comps default starting positions are random) that they mine at wherever their randomly selected starting point was even if they didn't start the game in that spot?
I only guess that, because I'm trying to figure out if there's a way to maybe have an actual starting location point at each place as well as a regular point (that im using for players via triggers) and then somehow blocking them so comps can't start there if players are in those lobby slots forcing the comps to spawn only in the remaining ones?
Set Main Town looks for an integer to assign as the main town. Any idea on what that's looking for? or how to originally set a town? I'm going to try the ' AI Advanced - Set the center of player globalPlayerInLobbySlot[localPlayerCounter] town -1 to be at point globalStartingPoint[localPlayerCounter] because -1 was the default entry. we'll see what that does.
okay so with that, I'm able to use the starting locations points instead of the regular points just to keep things cleaner.. but the ai is still acting goofy sometimes. I tested it 4 times, and 2 of the times, 2 computer players just mined, and did nothing else for about 20 minutes. the 3rd comp, actually worked tho. he built stuff accordingly with his difficulty setting in the lobby.
It's a single For Each trigger used to determine what starting units they all get so there's no reason why 1 computer would work and the others wouldn't. I don't see what else could possibly be different between them all.
I had a bunch of really stupid, random, and weird problems with AI on my map, and it seems it was partly due to the lack of cliffs and LoS blockers... The AI wouldn't expand to the center base, but they would long-range mine it, until I put a bunch of the curtain doodads on it. But I dunno about them only mining...
Okay, so as far as I can tell, it works sometimes and it doesn't work other times. I've been over the triggers I have several times now and the only variable between trials is the fact that in the Player Properties menu, all the default starting locations are listed as Random. When it works, it's because the comps are spawning randomly in the correct location. When it doesn't work, the melee AI sends it's drones to their 'random' starting point even if it's not at it's own base. And once they do that, something is preventing them from continuing their builds - so they pretty much just stick to mining. That's what I've found so far. Hopefully either this is fixed, or a better work around is found at some point because it's pretty sloppy. I want to be able to play with comps at any point but as it looks right now, it's a crap shoot each time hoping they are given the same spots i gave them via triggers.
Okay, so here's a development. i changed all the default starting locations to player1 = start location 1, p2 = 2... etc. instead of 'random' (in the player properties menu)... and it still did NOT work... but THEN, in the lobby, when you add comps to it, if you MOVE the comps around so they're in the default color order, it works every time. The comps build and play like normal. I just did it 4 games in a row, and it worked each time.
So now I'm wondering if maybe changing players colors ingame would fix it? I'm going to keep testing it, but so far, at least it works with a little effort in the lobby.
I know this is a billion years old, but I figured something out here.
To get the computer to build at a location other than it's starting location:
Place command center and scv's manually not on starting location, set computer to terran.
Start AI.
Create a new town at point where command center is.
Set town 2 to be the main town for that player.
Wait 30 seconds.
Set the center of that player's town 2 to be where the command center is.
This works if there are resources near that command center. I don't know why it works, lots to test, but this is a starting place.
To set the starting locations of the AI you should create your own custom scripts for starting the AI based on the default scripts found in the Editor Console -> Browse.
Copy the BaseAI.galaxy functions for starting the campaign and melee AI and replace any reference to the PlayerStartLocation(int player) function with your start locations.
Now call these functions to start the AI instead.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Please see attached map and code screenshot. I'm trying to create a situation where I'm watching four computer players fight each other. I've tried many different things, including other AI scripts (like Mimic), AIDefaultEconomy, etc and I can't seem to get them to work in my map setup. If you fire up the attached map (which is a very simple approximation of a map I'm working on), you'll notice that sometimes computer players will send their workers to another start location to harvest. This is unpredictable however. I believe many of the problems here could be caused by the fact that I'm starting these players in arbitrary locations (not their "starting location" as in their player property). I can't seem to set this player property without going into the Player Properties dialog in the editor...which is not what I want anyway since I need to choose starting locations programmatically...not sure if that's the problem though.
Any help or insight on how I can get computers to fight each other with even dumb ai using the fewest lines of code possible, that would be great. This is just to test camera controls...I don't even really need it to actually be good AI...I've spent so much time on this compared to other features it's ridiculous.
Update: Two things. (1) Switching Neutral player to Neutral control enabled the correct placement of works (in between town hall and minerals) when spawned...also seemed to unlock other AI functionality. (2) Explicitly setting starting positions in Map > Player Properties enabled true melee AI. See attached map.
Does anyone know what the deal with (1) is? And does anyone know how I can change starting positions (same as Map > Player Properties) using code during runtime?
@jcraigk: Go
I was trying to crack the same problem. I tried to move the start locations with the Move Point trigger but it seems that either the game doesn't follow the starting locations, or they don't move at all. Either way, it doesn't work.
So now I'm back to trying to get the AI to act as normal melee AI and placing the starting units at run time manually with triggers.
I see it's been awhile since you posted this, but if you see this, lemme know if you've found anything more on this.
@playpong: Go
Well, did you move the start location before or after you started the melee AI and whatnot?
@DeProgrammer: Go
I moved the start location BEFORE. And still nothing. I tested a basic trigger on a blank map to move a starting point just to see, and it does not work period. anyways, it appears I found a workaround...
I used the Give Player standard melee units trigger (it's in the melee trigger field) instead of "give all players..." just give each player the units individually - then in a trigger after that, issue the 'start all melee ai for all comp. players'. I'll do some more testing, but so far, it looks like that does the trick.
I've run into this issue too...
Computer players won't behave properly (with melee settings) unless their original CC is a their starting location
@PirateArcade | I make games | Ask me things on Discord
You might be able to fix that particular issue by using a trigger to set their main town.
@DeProgrammer: Go
Hmmm. Playing around with this I've gotten all computers to begin mining normally. But they don't build anything. Not even more drones.
@PirateArcade | I make games | Ask me things on Discord
@greythepirate: Go
Alright, so as it turns out, I just lucked out with the random placements of the comps that last test of mine. My guess is that if you have actual starting location points on the map (and since the comps default starting positions are random) that they mine at wherever their randomly selected starting point was even if they didn't start the game in that spot?
I only guess that, because I'm trying to figure out if there's a way to maybe have an actual starting location point at each place as well as a regular point (that im using for players via triggers) and then somehow blocking them so comps can't start there if players are in those lobby slots forcing the comps to spawn only in the remaining ones?
I dunno - i'll keep playing with it.
@DeProgrammer: Go
Yeah okay, I'll start messing with that and see if that helps.
Set Main Town looks for an integer to assign as the main town. Any idea on what that's looking for? or how to originally set a town? I'm going to try the ' AI Advanced - Set the center of player globalPlayerInLobbySlot[localPlayerCounter] town -1 to be at point globalStartingPoint[localPlayerCounter] because -1 was the default entry. we'll see what that does.
It's looking for the index of the town. Try Declare Town Specific Slot with an index of 0 and the start location you want, and then Set Main Town 0.
@DeProgrammer: Go
okay so with that, I'm able to use the starting locations points instead of the regular points just to keep things cleaner.. but the ai is still acting goofy sometimes. I tested it 4 times, and 2 of the times, 2 computer players just mined, and did nothing else for about 20 minutes. the 3rd comp, actually worked tho. he built stuff accordingly with his difficulty setting in the lobby.
It's a single For Each trigger used to determine what starting units they all get so there's no reason why 1 computer would work and the others wouldn't. I don't see what else could possibly be different between them all.
I had a bunch of really stupid, random, and weird problems with AI on my map, and it seems it was partly due to the lack of cliffs and LoS blockers... The AI wouldn't expand to the center base, but they would long-range mine it, until I put a bunch of the curtain doodads on it. But I dunno about them only mining...
Okay, so as far as I can tell, it works sometimes and it doesn't work other times. I've been over the triggers I have several times now and the only variable between trials is the fact that in the Player Properties menu, all the default starting locations are listed as Random. When it works, it's because the comps are spawning randomly in the correct location. When it doesn't work, the melee AI sends it's drones to their 'random' starting point even if it's not at it's own base. And once they do that, something is preventing them from continuing their builds - so they pretty much just stick to mining. That's what I've found so far. Hopefully either this is fixed, or a better work around is found at some point because it's pretty sloppy. I want to be able to play with comps at any point but as it looks right now, it's a crap shoot each time hoping they are given the same spots i gave them via triggers.
Okay, so here's a development. i changed all the default starting locations to player1 = start location 1, p2 = 2... etc. instead of 'random' (in the player properties menu)... and it still did NOT work... but THEN, in the lobby, when you add comps to it, if you MOVE the comps around so they're in the default color order, it works every time. The comps build and play like normal. I just did it 4 games in a row, and it worked each time.
So now I'm wondering if maybe changing players colors ingame would fix it? I'm going to keep testing it, but so far, at least it works with a little effort in the lobby.
I know this is a billion years old, but I figured something out here. To get the computer to build at a location other than it's starting location: Place command center and scv's manually not on starting location, set computer to terran. Start AI. Create a new town at point where command center is. Set town 2 to be the main town for that player. Wait 30 seconds. Set the center of that player's town 2 to be where the command center is.
This works if there are resources near that command center. I don't know why it works, lots to test, but this is a starting place.
To set the starting locations of the AI you should create your own custom scripts for starting the AI based on the default scripts found in the Editor Console -> Browse.
Copy the BaseAI.galaxy functions for starting the campaign and melee AI and replace any reference to the PlayerStartLocation(int player) function with your start locations.
Now call these functions to start the AI instead.