New combat system - modifying how withdrawal works?

Exel

Prince
Joined
Nov 25, 2001
Messages
440
Location
Finland
I want to make units able to withdraw from combat regardless of if they are attacking or defending. I'd also like to change the damage threshold that triggers their withdraw, so that instead of withdrawing at 1 str they'd attempt withdrawing already at, say, 20% of their maximum str. In addition I'd want to limit the defending unit's ability to withdraw to only when it has movement points left. Are any of these possible to code?

With those changes to combat dynamics I'd also want to change the behavior of the Flanking promotion. Instead of increasing withdrawal chances I'd like it to reduce the enemy's withdrawal chance. Possible?

I'm trying to achieve a combat system that would eliminate much of the kamikaze roulette element of Civ4 combat by making defeats more survivable. These changes would take it a long way, though more input is welcome to take the idea further.
 
I really like your suggestions :).

Combat rules can be changed quite easily with few SDK changes.
Much bigger problem is reprogramming the AI; if we limit the defender's ability to withdraw to only when it has movement points left, AI must not move it's units in case that there are superior enemy units which can attack them in the next turn.

Therefore as first step I suggest very simple mod which I can implement in few days:

  • Attacker withdraws with probability:
    100% + attacker_withdrawal_chance% - defender_withdrawal_chance%
  • Defender withdraws with probability (even if it has no movement points left):
    100% + defender_withdrawal_chance% - attacker_withdrawal_chance%
  • Attacker or defender cannot withdraw if its strength is lower than some threshold (e.g. 20%).
  • Defender cannot withdraw if it is last unit defending given square/city/fort (maybe in the future I will implement selection of withdrawal square for last defender).
  • No changes to flanking promotion (it will still increase withdrawal chance). But now it will affect both attacker and defender.
With these changes will attacker need at least twice as many units to completely wipe out all defenders in given square in single turn (if every attack succeeds and every defender withdraws from its first combat).

I hope that AI still can still play it with these rules as I don't plan to do any AI changes in first version. AI should not be affected too much; it only needs to move all damaged units out of reach of attacker to heal.
 
Therefore as first step I suggest very simple mod which I can implement in few days:

  • Attacker withdraws with probability:
    100% + attacker_withdrawal_chance% - defender_withdrawal_chance%
  • Defender withdraws with probability (even if it has no movement points left):
    100% + defender_withdrawal_chance% - attacker_withdrawal_chance%
  • Attacker or defender cannot withdraw if its strength is lower than some threshold (e.g. 20%).


  • Interesting approach, looks good. I'd like to try it out too once you get it done.

    A further development might be to link the base withdrawal chance to relative unit strengths so as to ensure that a greatly underpowered unit wont have as good a withdrawal chance (think Archer vs Tank). Don't know what formula would be good for it though.
 
The other question is: should a withdrawing defender actually move to another tile or simply break combat? And if it moves, where does it move to?? And if it moves, does the attacking unit then take it's former location?
 
Perhaps a defender should only be able to withdraw if there are other units from the same civ in the tile. In essence, it retreats to the cover of its other units.

Maybe it still do so if defending a city/fort.

Otherwise it should probably retreat to another tile or not be able to retreat at all. If you're running away, you can't very well hold your ground at the same time.
 
EmperorFool said:
Perhaps a defender should only be able to withdraw if there are other units from the same civ in the tile. In essence, it retreats to the cover of its other units.
Yes, this is exactly what I'm thinking about (and it is easiest way how to implement it ;) ).
Simple rule is: defending unit will stay in the tile if attacking unit cannot advance to this tile after combat. This way also unit of allied player in the same tile can be used as cover for retreat.

EmperorFool said:
Maybe it still do so if defending a city/fort.
I think that we can use same “cover” rules here as for open field combat.

EmperorFool said:
Otherwise it should probably retreat to another tile or not be able to retreat at all. If you're running away, you can't very well hold your ground at the same time.
Yes, this I have suggested too. Last unit defending given square cannot retreat because no unit can be used as cover.


BTW: I made slight changes to my withdrawal formulas:

  • Attacker withdraws with probability:
    attacker_health_before_combat% * (100% + attacker_withdrawal_chance% - defender_withdrawal_chance%)
  • Defender withdraws with probability:
    defender_health_before_combat% * (100% + defender_withdrawal_chance% - attacker_withdrawal_chance%)

Idea is that damaged unit often lacks cohesion to perform successful retreat maneuver.

Exel said:
A further development might be to link the base withdrawal chance to relative unit strengths so as to ensure that a greatly underpowered unit wont have as good a withdrawal chance (think Archer vs Tank). Don't know what formula would be good for it though.

I’m not sure whether attacker/defender relative strength should affect withdrawal chances because then flanking promotion lacks usage and various combat promotions can be used instead. I also like that also units without real combat strength can be used to slow down attack via various “tricks”.
 
I think that we can use same “cover” rules here as for open field combat.

What I meant to say is that if the last unit is defending a city or fort, perhaps they should be able to hold their ground even when they retreat because they have the cover of the buildings. So the attacker must kill the last unit in a fort/city in order to enter the plot.
 
Simple rule is: defending unit will stay in the tile if attacking unit cannot advance to this tile after combat. This way also unit of allied player in the same tile can be used as cover for retreat.

This should definitely make for interesting battles where you have to fight for a single tile (or city) for multiple turns unless you hugely outnumber the enemy - real prolonged sieges and WWI style trench warfare... can't wait to get to try that out. :cool:

BTW: I made slight changes to my withdrawal formulas:

  • Attacker withdraws with probability:
    attacker_health_before_combat% * (100% + attacker_withdrawal_chance% - defender_withdrawal_chance%)
  • Defender withdraws with probability:
    defender_health_before_combat% * (100% + defender_withdrawal_chance% - attacker_withdrawal_chance%)

Idea is that damaged unit often lacks cohesion to perform successful retreat maneuver.

Looks even better. Under-strength units should definitely have a reduced withdrawal chance.

I’m not sure whether attacker/defender relative strength should affect withdrawal chances because then flanking promotion lacks usage and various combat promotions can be used instead.

With the addition of strength % modifier I don't think we need that either. I was only worried about units getting a 100% withdrawal chance if the enemy doesn't have Flanking. It should be high in any case, but maybe not 100% all the time. With the health modifier that's fixed, and it makes softening attacks that much more important.

I think we'll see the importance of the Flanking promotion soar up as well, to make city grabbing and stack killing easier. Which is good, since it's really been underused thus far.
 
What I meant to say is that if the last unit is defending a city or fort, perhaps they should be able to hold their ground even when they retreat because they have the cover of the buildings. So the attacker must kill the last unit in a fort/city in order to enter the plot.

Withdrawals should, at least at first, probably be to the same tile only. Later we could add withdrawal to an adjacent square for units that have movement points left, if that's possible. In the latter case it should indeed be so that units don't abandon cities or forts but die defending them.
 
I support this changing of how battle works. I don't like how I have to unit spam nearly every battle.

I like the idea of a battle finishing before any unit dies. Is it possible to do that in how much damage a unit can give in one 'session' or will the unit attack and attack until it or the target is dead? My thoughts on an alternative to the withdrawal function.


Also, victory the unit should stay in the square it started in (i.e, give the option if you want to move into the square or not)
 
Withdrawals should, at least at first, probably be to the same tile only. Later we could add withdrawal to an adjacent square for units that have movement points left, if that's possible. In the latter case it should indeed be so that units don't abandon cities or forts but die defending them.

Yeah, I played a mod that had withdrawal for defending units before, and one of the things that annoyed me is that even when winning, my units might bolt from the city and the enemy would just waltz right in.
 
Units would withdraw after killing the attacker? That's weird. "They're dead! Run away!!!"

Well, not after combat. In the middle of combat but when the enemy was losing.
 
moctezuma: Is that code of yours working as intended? Could you share the full code you are using?
 
moctezuma: Is that code of yours working as intended? Could you share the full code you are using
Yes, it works :D

Here is very first version (BTS only). Sources are included (search for "SURVIVABLE COMBAT").

http://forums.civfanatics.com/uploads/5028/Survivable_Combat.zip

It's not yet really tested so I expect many bugs. However basic retreat/flanking mechanic should be there.

Everything is hard-coded for now (e.g. health limit for defender retreat is 20%). In the future I plan to put various variables to xml file.

I would like to know whether combat feels better than in vanilla and how AI reacts to new combat rules. I expect that AI will be really bad, because it was not adjusted to new rules yet.

Any suggestions are welcome.
 
Warhammer Fantasy battles has this in the mod. It is a little annoying, you can defeat an enemy but they are barely hurt and retreat next to your lightly defended city or onto a valuable improvement.

It is cool, but you need to have retreating units take additional damage if they are the defenders to represent a route and subsuquesnt loss of materiel supplies, etc.
 
Edit: Nevermind. I just realized that solo defenders aren't supposed to be able to withdraw. :p

The withdrawal combat calculations do work correctly. There's a minor glitch with the combat odds display though. It is set to display 0% withdrawal odds for the defender whenever the attacker can advance to the defender's tile after combat (ie. when there aren't other combat units in the tile). This is fine as such, but produces an erroneous combat prediction during peace time, always displaying 0% withdrawal odds for the defender.

In any case that's a minor issue, and the combat itself works as intended. I'll proceed to test AI behaviour and combat dynamics in a full game and see how it affects gameplay.
 
Warhammer Fantasy battles has this in the mod. It is a little annoying, you can defeat an enemy but they are barely hurt and retreat next to your lightly defended city or onto a valuable improvement.

It is cool, but you need to have retreating units take additional damage if they are the defenders to represent a route and subsuquesnt loss of materiel supplies, etc.

Actually a different mechanic and not much elaborated since the creator lost interest. It involved psychology checks on a moral value during combatrounds. The main problem was that units were able to flee more than once during a turn. I asume that couod have been fixed easily but I just don't know how.
 
I was just going to mention Lord Olleus's stuff. Moctezuma's got some interesting material going on here, but I'm curious about the formulas used.

I'm certain I'm not getting the math right, but which is calculated first? Defender withdrawal chance or attacker?

For a hypothetical situation:

A healthy attacker with no withdrawal chance vs. a healthy defender with no withdrawal chance

100% * (100% + 0% - 0%) = 10000% ?

I've got to be doing the math wrong. This, as with Lord Olleus's morale code, I see as the relative training of the units involved -- the veteran unit forcing the inexperienced unit to retreat.
 
100% * (100% + 0% - 0%) = 10000% ?

I've got to be doing the math wrong.


I suck at maths, but I'm fairly certain that 100% * 100% is not 10000%, but 100%. However the code uses plain numbers - does the engine read them as percentages?
 
Back
Top Bottom