CivMyWay: Combat Calculations

CivMyWay

Warlord
Joined
Mar 7, 2009
Messages
218
I'm writing my own civ-variant at the moment (see screenshot, terrain graphics from the wesnoth project, unit graphics modified slightly by me, from ambrox62).

I need some smart people to give some ideas on how I should structure combat (e.g. does the defender only use defence-value?).

The variables I foresee as possibly being part of the calculations are:
For both the attacker and defender:
melee attack value
range attack value
melee defence value
range defence value
moves remaining in current turn
number of healthy troops in unit
number of sick troops in unit
terrain value
improvement (e.g. fortification) value
morale value
discipline value
modifiers (veterancy, ...)

I can post more details on any of these later.
 

Attachments

  • snapshot3.jpg
    snapshot3.jpg
    23.8 KB · Views: 131
Come up with a list of all the variables for combat that you want, and then assign for them a maximum and minimum value (for each type of combat if applicable), i.e. how much they will influence combat. Then, for each unit, assign each of these values. Then, for each individual battle, see which are applicable, and apply them, before seeing who has the highest number. Then, for battle possibilities, I think the simplest way would be to divide each individual units' overall value, by the sum of the two units' values.
 
Thanks for the input.
More, to above:
- Sick troops will only fight at 50% the capacity (attack and defence) of a healthy unit. They will also die first, and have only a 25% chance of successfully retreating.
- Terrain will give bonuses to both the attacker and defender (depending on terrain type). For example an archer on a mountain receives a bonus if attacking a unit on the plain.
- Whatever the calculation ends up being it will be divided by the moves remaining.

Anyway, enough forum surfing... it's time to code!
 
Go back to what Civ3 did, seperate attack and defense values, and work it out from there.
 
I'm writing my own civ-variant at the moment (see screenshot, terrain graphics from the wesnoth project, unit graphics modified slightly by me, from ambrox62).

I need some smart people to give some ideas on how I should structure combat (e.g. does the defender only use defence-value?).

The variables I foresee as possibly being part of the calculations are:
For both the attacker and defender:
melee attack value
range attack value
melee defence value
range defence value
moves remaining in current turn
number of healthy troops in unit
number of sick troops in unit
terrain value
improvement (e.g. fortification) value
morale value
discipline value
modifiers (veterancy, ...)
imho melee is a fine attribute before-gunpowder units, but after it's pretty much useless. and drop morale and discipline [which can be incorporated(tied) into experience attribue] for starter. and add them later.

in civ2 the attacker' [modified] attack and defender's [modified] defense where added together and a number was rolled. if it was not higher than the attacker's attack then the defender suffered damage equal to the attacker's firepower, otherwise the attacker suffered damage equal to the defender's firepower. this was iterated until 1 of the units died.
i remember actually making units with 60-70hp and 1 firepower and enjoying some satisfying combat as they tore each other apart.:D

for battle possibilities, I think the simplest way would be to divide each individual units' overall value, by the sum of the two units' values.
you want to give spearmen a chance?:D
 
imho melee is a fine attribute before-gunpowder units, but after it's pretty much useless. and drop morale and discipline [which can be incorporated(tied) into experience attribue] for starter. and add them later.

You raise good points, Hail and I agree with you (at least about the melee being more pre-gun powder). This is true, melee weaponry became fairly much defunct (at least as soon as multi-shot weapons were developed).

The main example I thought of for splitting these was for the greek-style phalanx; they are very versatile at melee defence (but their defence against an archer, is well, non existent).

(You don't know my plans, so this certainly isn't an argument against what you say, just more information...)

I am trying to develop my version of civ to be less historically accurate and more self deterministic. e.g. the player gets to create their own civ (with a high degree of flexibility), not just a copy of a civ that has been before.

For starters, I hope to make each epoch of the game richer - so theoretically you could spend a lot longer in the game where melee weapons are more useful than currently.

I am hoping (although my idea still waivers as to if this is a good idea) to have a SMAC like unit builder. So for example, you can choose to give your "spearmen" soldiers a sidearm sword if you want. You can decide how you are going to arm your civilisation.

I'm going to add elements of an RPG on a civ-level (so you can gradually over time make your people smarter or stronger or better skilled at various tasks). YOU shape your people.

If you decide you want to maintain slavery indefinitely of subjugated people, then you should be allowed to do so. Sure, the other civs might disapprove, but if enough people agree with you then why should it be an atrocity? YOU shape your civilisation.

Also, I will be having futuristic weapons/techs - so it's always possible that high powered melee will be resurgent in the future.

As for discipline and morale; I think they have always been present on the battlefield, and always will be. One of the reasons why the romans won was through discipline and training of the troops. The veterancy level of the unit will effect the following items:
  • Combat bonus (%) – this is applied as a multiplier to the A/D value (after all other modifiers)
    Morale hit (%) – morale hit is the morale decrease that occurs to a unit when something bad happens. The morale hit is always expressed as ‘this is how bad it would be to a normal person’. (Note: good morale factors are not modified at all by veterancy). (Thus a lower moraleHit is good)
  • Awe (%): When units visit a city, they may inspire the populace (+recruiting, +chance of parade). This can occur once every 10 turns.
  • Skill slot (#): When a unit gains veteran level they gain an ability slot (max: 2), which lets them select a special bonus. This bonus will give them a further +20% bonus in certain situations. (The same skill cannot be selected more than once per unit).
 
There should be no 'skill', this is for individuals, and Civ is a strategy game (or it was, but that's beside the point). You could bring the units to a military base (or barracks, if you like), and then give them special training; but no 'skill'.
 
There should be no 'skill', this is for individuals, and Civ is a strategy game (or it was, but that's beside the point). You could bring the units to a military base (or barracks, if you like), and then give them special training; but no 'skill'.
Isn't veterancy, or combat experience, all "on the job" training?
 
Yes. What I am saying is: Units can and should gain experience from combat, but the experience should fit the situation. For example, a player should not be able to give a unit experience against gunpowder units when it just finished a battle with a cavalryman.
 
you want to give spearmen a chance?:D

Square it, and then do the same. That would eliminate a lot of the difference. Although, you could just make the initial difference between a tank and a spearman to be greater.

Units can and should gain experience from combat, but the experience should fit the situation. For example, a player should not be able to give a unit experience against gunpowder units when it just finished a battle with a cavalryman.

This is a bit of an iffy area. The game's time scale is such that the people who fought a battle last turn would not be the same people that fight a battle next turn, although they are organised to comprise the same unit. So, the idea of unit experience is fairly devoid anyway, unless you change it to be experience gained as a whole by a civ, contributing to overall improvements in that civ's military units.
 
It was just the makers addition to try to pull in a different kind of player. In my opinion, they shouldn't have done it.
 
This is a bit of an iffy area. The game's time scale is such that the people who fought a battle last turn would not be the same people that fight a battle next turn, although they are organised to comprise the same unit. So, the idea of unit experience is fairly devoid anyway, unless you change it to be experience gained as a whole by a civ, contributing to overall improvements in that civ's military units.
I almost completely agreed with you, but then your argument applies also to great leaders (not being alive, and unit health etc etc etc) - I think the only way to really enjoy the game is to keep a comfortable layer of ambiguity - something which I am CONSTANTLY battling against with my game design; wanting specifics AND trying to maintain ambiguity.

However your thoughts sparked in me what I think is a good idea and I have modifications to my model, making veterancy in-part civ-based and in-part unit based. Here it is:
  • Each unit has a 'class' these may be "Light Infantry", "Heavy...", Cavalry, Modern Infantry etc etc.
  • A unit gains experience in each battle they survive and when they reach the magic Veterancy level, they gain the next level of veterancy.
  • At the same time (as above), each time they gain a veterancy it becomes slightly easier for other units of the same class to gain that level of veterancy.
In practicality that means if you are winning a lot of battles with cavalry, you are going to more easily get higher-veterancy level cavalry. This is sort of the civ being "well known" for their cavalry units. Obviously:
  • Balance will need to be considered
  • There is a maximum that the levels can be lowered.
  • If you stop using cavalry as much, you lose that civ-familiarity with it.
 
What a good idea! I haven't even thought about that. A good addition to that is whaat training you give the unit before you send it out if the city.
 
So do I :) I've been dreaming about making a civ for years, so it has to have a reasonable chance...
 
I finally got most of it hashed out....thoughts?
== Combat Calculations ==
Please note:
* This is only iteration 1, and only deals with unit vs unit as opposed to unit[] vs unit[], and it only deals with units occupying the same z-index. It contains detail (which may be too much for milestone 1).
* For calculation shorthand; a is attacker and d is defender.
* At the end of each battle results should be displayed (if desired by the user) which show a breakdown of losses.
* See also: [[Game Concepts: Units#Discipline]], [[Game Concepts: Units#Morale]], [[Game Concepts: Units#Specialist(s)]] and [[Game Concepts: Units#Item in Custody]]

=== Initiative: Who gets to attack? ===
It is random whether the attacker (aggressor) or the defender gets to assault the other unit first. This randomness it based on their combat experience points, such that:

Attacker chance = a.combatExp / (a.combatExp + d.combatExp)

Defender chance = defender.combatExp / (attacker.combatExp + defender.combatExp)

This is then modified:
#. A unit must have at least a FIGHTING_CHANCE (e.g. 5%)
#. A unit may have an ability which gives them right to attack for the first 1 (or 2) times (regardless of randomiser).
#. A unit may have an ability which negates #2.
#. When an ambush scenario occurs (unit hiding on a tile, and an enemy unit moves onto same tile, hiding unit selects attack) the attacker gets '''undisputed''' first attack.

For adjusting the attack/defense strengths:
#. In an ambush scenario defender gets only 1/2 defence on the first round of attack.
#. The tile may give modifiers to attack and/or defence
#. A tile improvement may give modifiers to attack and/or defence
#. A unit may have a bonus against the type of the other unit (e.g. phalanx vs cavalry)
#. A unit may have a bonus because of the tile (e.g. Chariot on plain)
#. A unit with Prisoners of War in their "item" slot can only fight @ 25% normal attack/defence values.

=== Damage calculations ===

Total manpower = number of healthy units + (number of sick units / 2)

The attackers manpower is then:
Attacker Manpower = attacker.totalManpower * (movement points remaining in current turn / total movement points)

The defender does not have an equivalent calculation.

The damage done to the attacked unit (see Initiative) is :

damage = (a.attackValue * a.manpower * (a.morale / 2) + 40) / (d.defenceValue * d.manpower * (d.discipline / 2) + 40))

''(+40 so that even if morale/discipline is only 50 out of 100, you still don't get penalised too heavily''

numEffected = d.totalMen * damage (due to calculations, battles will likely be short)

Now when damage is done, the individual "men" represented by the unit are either a) killed, b) injured or c) captured. By default it will be 50% kill, 25% injure and 25% capture. (These numbers are based on variables, so they can be altered by techs etc).

Please note: Any existing wounded at the start of the round are subtracted from numKilled before any healthy are converted to sick/dead.

The ratio of killed/injured/captured, exceptions below:
#. An attacker may have an attribute which means 100% death rate for those hurt (can still capture).
#. A defender may have an attribute which lessens the death rate; leaving more injured, or lessening the injury rate, leaving more healthy. (A dead person cannot go from dead to healthy).


===Capturing Thy Enemy===
In the Military Advisor panel you have an option per-civ which you can check, so you don't take prisoners of that civ. (i.e. all killed). There is also a global checkbox "Confirm taking prisoners"

If this option is NOT ticked and Confirm is, then a dialog box will ask if you want to take x prisoners. If you select no, they are killed (this will effect that civs view of you moreso than if they were killed on the field). If you select yes, then 1 of your healthy soldiers for every 4 PoWs are split off from the main group and entrusted with the prisoners. A unit with Prisoners of War cannot initiate attack (effectively reducing your fighting force).

If you capture PoWs and have an interrogation team as military specialist, you have the option of interrogating the unit (in that turn). The discipline value of the captured units will determine if information is given, and how many "POWs" will die in torture. The information given is random (may repeat):
* details of how many enemy troops left alive before the round they were captured in.
* details of morale/discipline of the unit
* details of home city (location [if unknown], naming a building etc).

Torture negatively effects how other civs see you (if they disagree with it).

===Fortitude check===
BEFORE the first round, and AFTER every subsequent attack-round, both units have a fortitude check, at which point they may lose more strength as "men" routing. (They are effectively "dead", but are reported under AWOLs).
* "Men" cannot route when they are on the sea.
* "Men" cannot be captured unless it is the last round (unit dead) in a sea battle.
* Both units may have an attribute or military specialist that will increase their own morale or discipline, or decrease the enemies.

If (a.totalTroops >= d.totalTroops * 2) then --d.discipline

If either unit loses >= 1/2 of totalTroops before round, --morale

If lots of men flee, morale further decreases

(With each round of being attacked there is 20% chance that one of the fatalities will be a military specialist attached to the unit).



====Reinforcing your Troops===
* A unit can be replenished with men by going to a city and using the "replenish" action. This uses the normal barracks queue and is subject to waiting period, asset costs etc. A single unit will be resupplied with the same number of men.
* A unit which is within its home cities' wider borders (but not in the city tile itself), can replenish without moving to the city.
* When in friendly territory, you can use a "Draft" option to get recruit "green" troops from among the peasants. (This should have a higher effect on war weariness).

When you add new troops to your unit, they will decrease or increase proportionally your units combat experience, according to the number of troops you are adding.

Units can also merge on-the-field.
 
Back
Top Bottom