Any good idea how to help AI players to protect whole base easily? Its very annoying problem on my maps. If player is attacking on west side of base and AI has lot of units on east side of base AI won't send those units to defend west side. I know there are many triggers for AI but don't really know what is best solution. I'm trying to do some kind of general "protect whole base" trigger that I can use on specific region. Good ideas are welcome!
Idk if this is what you are looking for but i made a trigger that when a unit gets attacked all units in a limited range respond and move to the location of the attacked unit. you might be able to adapt it to an area instead of range based or just give you an idea on where to go with it.
Event: TriggerAddEventUnitAttacked(null)
Variables: None but depending on what you need it to do you may need some.
Conditions: i have a few to make sure that it detects who owns the unit being attacked and a few others so it doesn't interfere with other commands IE my taunt ability
Actions: UnitGroupIssueOrder((UnitGroup(null, "the player that controls the unit attacked goes here", (RegionCircle((UnitGetPosition((EventUnit()))), 12.0)), Excluded: Missile, Dead, Hidden, 0)), (OrderTargetingPoint("attack", 0, (UnitGetPosition((EventUnitTarget()))))), c_orderQueueReplace)
this is code taken directly from my trigger so you will need to alter it to suet your needs but it should help you get an idea.
On my trigger I'm using "Entire map" region but you can use any region. Thats the basic idea at least.'
One more note: Change "Worker: Excluded" so AI wont send SCVs to defend :)
EDIT: Improved version of trigger
I also included "Structure" tag because it caused mess with attack waves. (AI sent more units to defend unit who were attacking -> they sent all units owned by player...)
I have one more problem with this trigger: If I drop Marine on high cliff near enemy buildings AI sends units to attack those units but they have no line of sight and can't attack. Any idea how to prevent this?
EDIT:
Great, found solution for this by myself. I added condition "((Damaging unit) is visible to player 2) == True" and it works fine.
glad you solved your issue. i haven't played much with the AI commands mostly because so far all my maps are quite basic when it comes to that. (or i just do it this way cause its what i know)
Thanks for posting your trigger i may use it if i end up needing something like what your issue was.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Any good idea how to help AI players to protect whole base easily? Its very annoying problem on my maps. If player is attacking on west side of base and AI has lot of units on east side of base AI won't send those units to defend west side. I know there are many triggers for AI but don't really know what is best solution. I'm trying to do some kind of general "protect whole base" trigger that I can use on specific region. Good ideas are welcome!
Idk if this is what you are looking for but i made a trigger that when a unit gets attacked all units in a limited range respond and move to the location of the attacked unit. you might be able to adapt it to an area instead of range based or just give you an idea on where to go with it.
Event: TriggerAddEventUnitAttacked(null)
Variables: None but depending on what you need it to do you may need some.
Conditions: i have a few to make sure that it detects who owns the unit being attacked and a few others so it doesn't interfere with other commands IE my taunt ability
Actions: UnitGroupIssueOrder((UnitGroup(null, "the player that controls the unit attacked goes here", (RegionCircle((UnitGetPosition((EventUnit()))), 12.0)), Excluded: Missile, Dead, Hidden, 0)), (OrderTargetingPoint("attack", 0, (UnitGetPosition((EventUnitTarget()))))), c_orderQueueReplace)
this is code taken directly from my trigger so you will need to alter it to suet your needs but it should help you get an idea.
Thanks for respond. That makes some sense. I will do some testing and post again when I have some results. I'm going to use event "Unit is attacked".
Found solution.
On my trigger I'm using "Entire map" region but you can use any region. Thats the basic idea at least.'
One more note: Change "Worker: Excluded" so AI wont send SCVs to defend :)
EDIT: Improved version of trigger
I also included "Structure" tag because it caused mess with attack waves. (AI sent more units to defend unit who were attacking -> they sent all units owned by player...)
I have one more problem with this trigger: If I drop Marine on high cliff near enemy buildings AI sends units to attack those units but they have no line of sight and can't attack. Any idea how to prevent this?
EDIT:
Great, found solution for this by myself. I added condition "((Damaging unit) is visible to player 2) == True" and it works fine.
glad you solved your issue. i haven't played much with the AI commands mostly because so far all my maps are quite basic when it comes to that. (or i just do it this way cause its what i know) Thanks for posting your trigger i may use it if i end up needing something like what your issue was.