Hello, I have a group of enemy units that spawn, and all I want them to do is try their best to annihilate a player, let's say Player 1, units and buildings and all. What is the best way to accomplish this? Right now after my enemies spawn I have:
Unit: Order all units in (Last created units) to (Attack targeting units in (Any units in (Entire Map) owned by player 1 matching (No value), with at most Any Amount)) (Replace existing orders)
This seemed to work fine at first but if, while the enemies are running toward me (player 1), I attack him, they don't fight back. They just keep running towards my original position. What I want is to have them run towards my base while at the same time attacking any of my units that get in the way. So the ultimate goal is to destroy my hatchery, but if I start attacking them or they see other units/structures that I own, have them attack those. Ideally, this behavoir would apply against any user (i.e. if there are 3 players, the enemies will try to destroy all of them). Any help is appreciated. Thanks.
make a new trigger with a periodic event: "every x seconds" (smaller x = more reactive cpu, but may cause lag)
actions:
1) units group - select all units in entire map owned by cpu
1.1) unit - attack the position of ( the closest unit from ( the position of ( the selected unit ) in entire map which is enemy of cpu
if you read it the other way around you have:
1.1 will do (from the inner brackets to the outers)
- get the position of the cpu controlled unit
- get the closest enemy unit from the position of the selected cpu unit
- attack the ground point of the position of the unit enemy you got
1 will iterate this for every cpu unit
I believe the way you did, they attack a certain unit rather then the position of that unit, that will cause them to go straight to that particular unit without caring about anything (you are emulating the in game right click). If you do like i wrote, they will attack the position of the closest enemy unit (emulate the in game attack a point command)
Thanks, that's a pretty smart way to do it. The only potential issue I see is that perhaps it would be better if the enemies had some kind of priority in what they were attacking, for example a group of enemy marauders would probably want to focus down a spine crawler that was in range as opposed to a couple zerglings, but since the lings would be closer, they would attack the lings instead. I'm not sure if the Melee AI is that advanced but if so it would be better to get some of that integration going. I did mess around with the AI/Advanced AI Triggers a tad but I didn't get anything to work. I noticed you could create Attack Waves, but when I tried adding the enemies to an attack wave and then sending out the attack wave, they just stood there.
Perhaps your suggestion would be sufficient, but I do wonder about adding some additional options. Maybe I could do my own custom AI, assuming the triggers allow you to set priorities. Any additional help is appreciated, thanks.
if selected unit is a marauder - then select the closest spine - if the spine position minus marauder position is less then 10, attack spine else (next check)
(next check) if selected unit is baneling - then select the closest unit with light armor - if the unit position is less then 10 away from bane then attack that unit, else (next check)
(etc)
(last check) ..... else attack the closest unit
this way u set a number of "special actions" if they all fail the unit will just attack the closest one
Ok so I would have to do it manually, huh? That's okay - I just figured there might have been a way to do it using the built-in AI. Anyways, thanks for the help.
What I do is create a point where my target base is, then use "issue order to unit group" ordering all enemy units in the map to attack the target point. It's like issuing a move-attack order manually, they move towards that location and attack any enemy targets in their path prioritizing them based on the default AI.
Yeah, I think the problem is attack unit order. That will bypass any units to get at the unit targeted. If you use attack point, they'll attack everything on their way to the point.
make a new trigger with a periodic event: "every x seconds" (smaller x = more reactive cpu, but may cause lag) actions:
It could work, but it's not perfect. If the enemy attacking you has few units, and you have plenty, the few units attacking will be ordered to attack too often and, in the end, will spend their time attacking from point to point without actually reaching the many targets (because the trigger will give them a new one too often). If the units to attack are spread through the whole map, it's a nightmare to reach a random unit every X seconds... It could never occur.
To be sure it would work better, you need to add a "wait for condition" at the beggining of the actions list, which will check if the unit you want to order to attack is idle. When it is, it means it's not already attacking something/someone. When it isn't, it means the unit was just spawned, or it has finished its previous task (either attacking a building or making its way through the map). This way, you will never have an attacking unit change its target while already ordered to attack one. In the case it is attacking a building and you send units to stop them, they might even turn against your units. I'm not 100% sure, but a little test will tell.
By the way, in this case the "attack unit" might be better than the "attack position of unit". Attacking position means it saves the current position of the unit it targets, before attacking it. But if the targeted unit moves, the order still applies to the point saved. It will look weird in this case, especially if they wait long while idle before receiving a new order. Using "attack unit" is the only way I know of to ensure the attack order will update in real-time.
yeh that's the problem, in my game the users will be able to create fortifications all over the map, so having the enemies attack a pre-existing point will work for the beginning, but not for the end of the game. Although the ultimate goal of the enemy is to destroy one point, so maybe it would work. I'll give this attack point method a shot and if it doesn't suit my needs I'll have to continue with the custom ai stuff. Thanks for the help so far!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello, I have a group of enemy units that spawn, and all I want them to do is try their best to annihilate a player, let's say Player 1, units and buildings and all. What is the best way to accomplish this? Right now after my enemies spawn I have:
Unit: Order all units in (Last created units) to (Attack targeting units in (Any units in (Entire Map) owned by player 1 matching (No value), with at most Any Amount)) (Replace existing orders)
This seemed to work fine at first but if, while the enemies are running toward me (player 1), I attack him, they don't fight back. They just keep running towards my original position. What I want is to have them run towards my base while at the same time attacking any of my units that get in the way. So the ultimate goal is to destroy my hatchery, but if I start attacking them or they see other units/structures that I own, have them attack those. Ideally, this behavoir would apply against any user (i.e. if there are 3 players, the enemies will try to destroy all of them). Any help is appreciated. Thanks.
make a new trigger with a periodic event: "every x seconds" (smaller x = more reactive cpu, but may cause lag) actions:
1) units group - select all units in entire map owned by cpu
1.1) unit - attack the position of ( the closest unit from ( the position of ( the selected unit ) in entire map which is enemy of cpu
if you read it the other way around you have:
1.1 will do (from the inner brackets to the outers) - get the position of the cpu controlled unit - get the closest enemy unit from the position of the selected cpu unit - attack the ground point of the position of the unit enemy you got
1 will iterate this for every cpu unit
I believe the way you did, they attack a certain unit rather then the position of that unit, that will cause them to go straight to that particular unit without caring about anything (you are emulating the in game right click). If you do like i wrote, they will attack the position of the closest enemy unit (emulate the in game attack a point command)
hope will help ;)
@eddiestyle: Go
Thanks, that's a pretty smart way to do it. The only potential issue I see is that perhaps it would be better if the enemies had some kind of priority in what they were attacking, for example a group of enemy marauders would probably want to focus down a spine crawler that was in range as opposed to a couple zerglings, but since the lings would be closer, they would attack the lings instead. I'm not sure if the Melee AI is that advanced but if so it would be better to get some of that integration going. I did mess around with the AI/Advanced AI Triggers a tad but I didn't get anything to work. I noticed you could create Attack Waves, but when I tried adding the enemies to an attack wave and then sending out the attack wave, they just stood there.
Perhaps your suggestion would be sufficient, but I do wonder about adding some additional options. Maybe I could do my own custom AI, assuming the triggers allow you to set priorities. Any additional help is appreciated, thanks.
get all cpu units and do
if selected unit is a marauder - then select the closest spine - if the spine position minus marauder position is less then 10, attack spine else (next check)
(next check) if selected unit is baneling - then select the closest unit with light armor - if the unit position is less then 10 away from bane then attack that unit, else (next check)
(etc)
(last check) ..... else attack the closest unit
this way u set a number of "special actions" if they all fail the unit will just attack the closest one
@eddiestyle: Go
Ok so I would have to do it manually, huh? That's okay - I just figured there might have been a way to do it using the built-in AI. Anyways, thanks for the help.
@rymonator: Go
What I do is create a point where my target base is, then use "issue order to unit group" ordering all enemy units in the map to attack the target point. It's like issuing a move-attack order manually, they move towards that location and attack any enemy targets in their path prioritizing them based on the default AI.
Yeah, I think the problem is attack unit order. That will bypass any units to get at the unit targeted. If you use attack point, they'll attack everything on their way to the point.
It could work, but it's not perfect. If the enemy attacking you has few units, and you have plenty, the few units attacking will be ordered to attack too often and, in the end, will spend their time attacking from point to point without actually reaching the many targets (because the trigger will give them a new one too often). If the units to attack are spread through the whole map, it's a nightmare to reach a random unit every X seconds... It could never occur.
To be sure it would work better, you need to add a "wait for condition" at the beggining of the actions list, which will check if the unit you want to order to attack is idle. When it is, it means it's not already attacking something/someone. When it isn't, it means the unit was just spawned, or it has finished its previous task (either attacking a building or making its way through the map). This way, you will never have an attacking unit change its target while already ordered to attack one. In the case it is attacking a building and you send units to stop them, they might even turn against your units. I'm not 100% sure, but a little test will tell.
By the way, in this case the "attack unit" might be better than the "attack position of unit". Attacking position means it saves the current position of the unit it targets, before attacking it. But if the targeted unit moves, the order still applies to the point saved. It will look weird in this case, especially if they wait long while idle before receiving a new order. Using "attack unit" is the only way I know of to ensure the attack order will update in real-time.
yeh that's the problem, in my game the users will be able to create fortifications all over the map, so having the enemies attack a pre-existing point will work for the beginning, but not for the end of the game. Although the ultimate goal of the enemy is to destroy one point, so maybe it would work. I'll give this attack point method a shot and if it doesn't suit my needs I'll have to continue with the custom ai stuff. Thanks for the help so far!