Jump to content

soldiers ignoring enemy while automatically attacking building


grepmaster
 Share

Recommended Posts

One word: prioritization. Immediate threats/incidents should recieve higher priority in the command queue, wouldn'cha say?

if someone trying to kill you will you're trying to bring down someone's home, would you just let them kill you first? There won't be a second wouldn't it?

no offense buddy, just my two cents.

Link to comment
Share on other sites

Agreed. The ideal automated attack order would be:

* Enemy warriors

* Enemy offensive buildings (town center, tower, fortress)

* Enemy women

* Enemy non-offensive buildings (house, barracks, farms etc)

* Enemy unharmful buildings (walls/ gates)

If there was something more important in sight, your units would go and attack it.

That said, you should always be able to overwrite their target, and have it stay. A bug at the moment means you might be being attacked, and ty to retreat, but it won't retreat properly. Your units will turn around and try to fight again.

I think:

* If a unit is given an order, then a unit tries to attack it, it'll ignore said order and defend itself

* If a unit is in a fight, then given an order, that unit should follow that order no matter what (even if it means he's being killed from behind while attacking a wall).

Seems that, to implement this, you'd need three things:

* You'd need a dynamic property on the units, "command_forced" or similar, and set to true if unit is fighting when he receives an order (i.e. you tell him to retreat).

* Adjust the nearby unit detection code to automatically attack units, sorted by priority (as above), except if command_forced is true.

* Adjust the unit code to set command_forced to false when the unit finishes the command he was told to do (so he goes back into defensive mode).

Link to comment
Share on other sites

That sounds sensible in terms of static decision-making, but when should units switch to a new target? Assuming no human is overriding the behaviour: If a unit is attacking a building, then an enemy archer comes near (into their vision range? into their attack range? into some other range?), should they immediately switch to target the archer? or should they wait until the archer attacks them? When they chase the archer (who will run away), if they run into a line of enemy melee units who surround them and start killing them, should they switch to attack their new attackers, or continue chasing the archer futilely forever? If they'll continue chasing forever, it seems you could trick an enemy's whole army into chasing a single fast unit and then trap and slaughter them without them ever fighting back. If they should switch when attacked, then if they're chasing the archer but get shot by a second archer, should they switch to the second archer, and potentially keep alternating?

(I don't have answers to any of this - I think I'm mostly uncertain about how to make units responsive to their environment (i.e. visible enemies and attackers) without making them so indecisive that they never follow a target long enough to kill it, and I don't know how to precisely define the right balance.)

Link to comment
Share on other sites

If a unit is attacking a building, then an enemy archer comes near (into their vision range? into their attack range? into some other range?)
Well, that right there is introducing stances. Aggressive = vision range, stand ground = attack range, and defensive = only if they attack first. But assuming both aren't implemented at the same time, the initial work should be within the closer attack range.
should they immediately switch to target the archer? or should they wait until the archer attacks them?
Again, stances will change this. But for now, if an enemy is within the attack range, go for him (excludes animals of course)
When they chase the archer (who will run away)
Not by default, but if the other player makes it retreat, sure.
if they run into a line of enemy melee units who surround them and start killing them, should they switch to attack their new attackers, or continue chasing the archer futilely forever?
Depends how complicated it is to find if the path to a unit is blocked. If it's simple to find out if the path is blocked (that is, they can't get to it without going into FOW, which also means enemy units who disappear into FOW stop being chased), then you retarget to the nearest, strongest enemy. Ideally, they'd know right away if they are blocked, but given the slowness of the path finder, in the case where the archer disappears in FOW because the units are surrounded and can't get to him, then the moment he's gone, they change target. That should suffice for now.
it seems you could trick an enemy's whole army into chasing a single fast unit and then trap and slaughter them without them ever fighting back.
Correct, and they're clever tactics, which will encourage people to focus on their units when making an attack, instead of just leaving them.
If they should switch when attacked, then if they're chasing the archer but get shot by a second archer, should they switch to the second archer, and potentially keep alternating?
If they are not forced (i.e. user has not specifically told them to attack that archer while they were attacking something else, command_forced = false), then they should target the stronger unit. If archer 2 is stronger than archer 1 they are pursuing, then they attack archer 2 if within range. If archer 2 is weaker, they continue with archer 1. If the units are forced to attack archer 1 (command_forced = true), then they ignore archer 2 until archer 1 is dead, at which point, the command_forced is then false (as the command was completed) and they retarget the strongest unit.

Each attack scenario I play in my head works as I think it should using the above defined patterns and the use of the command_forced flag. I think, if implemented, it'd make the combat portion of the game much more enjoyable and useful.

Then when stances are implemented, it'd just be some minor tweaks to what was implemented to make the above work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...