1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

New combat mechanics suggestion

Discussion in 'Civ4 - General Discussions' started by vincentz, Nov 30, 2015.

  1. vincentz

    vincentz Programmer

    Joined:
    Feb 4, 2009
    Messages:
    3,556
    Gender:
    Male
    Location:
    Denmark
    I once read someone suggested that combat shouldnt be random, and I remember disagreeing, but lately I was feeling the current mechanism being somewhat broke.
    Especially when a lucky/unlucky streak hits like the first encounter (the lowest one)
    Spoiler :

    Imho its a bit silly that my ship escapes completely unharmed with the first encounter, and while it might be "semi-realistic" for ships, its becomes worse with 2 land armies.
    Even though I like random combat, it becomes too random.

    So I thought about turning it around. Instead of each unit take a round and the winner of that round (by random) deals damage, Im thinking about each unit deals damage per round, but the damage done is the random part.

    That would mean that each unit would take a hit from combat, still very much depending how strong it is, and result would still very much be random, though it would be rarer with the "extreme" luck where one unit would walk away unharmed.

    So... pros and cons? good or bad

    another (and by far quicker and easier to mod) is simply do the damage part random, and while random+random should be MuchMoreRandom, giving that it would increase the number of rounds, the odds for a "lucky strike" would decrease.
     
  2. Testhero

    Testhero Warlord

    Joined:
    Jan 17, 2015
    Messages:
    178
    Gender:
    Male
    Location:
    Dublin
    Can you have two combat mechanisms in a mod and switch between them in preferences ? eg.
    Realistic Combat Results [x]

    A big cause of some of the more :spear: results are due to the round by round arrangement with only one side dealing damage. I think that that is tucked away in the engine and will be difficult to change. but if you could change to a single round with both sides potentially dealing damage the results would be smoother.
    You could even perhaps enact some kind of nominal distribution.
    The withdrawal ability will however be changed significantly as will first strikes
    There is a guide to this in the S&T section that goes into the actual numbers in exhaustive detail. I remember stat runs and graphs too. Might be worth a look.

    Another thing a lot of people look at is a straight additive combat advantage system where all bonuses add to the attacking unit rather than the present system where some promotions/ability's subtract from the defender instead.
    As I understand it those behaviors are in the XML and could be changed more easily.
    however this will require a good bit of re-balancing for each unit that uses one of the affected promotions/abilities
    I think the gains in a additive system would also be less significant.


    Imho its a bit silly that my ship escapes completely unharmed with the first encounter, and while it might be "semi-realistic" for ships


    This is a kinda skewed example as itis perfectly valid for a frigate to wax a sailing ship with no damage. But I get what you are saying it is improbable that cavalry will suffer no losses fighting a roman legion especially as there is no surprise in civ land warfare.

    Another (and by far quicker and easier to mod) is simply do the damage part random, and while random+random should be MuchMoreRandom, giving that it would increase the number of rounds, the odds for a "lucky strike" would decrease.


    If I recall correctly there is a set maximum number of rounds (+ first strikes) so potentially the opponents will stalemate more often too.

    Good luck with all your tinkering
     
  3. whitelaughter

    whitelaughter Warlord

    Joined:
    Oct 21, 2008
    Messages:
    269
    Location:
    Canberra, Australia
    The way to fix the combat system is to reward interesting tactics, rather than punishing them.

    Frex in CivIII, mounted units and those in forts could damage passing units; so SODs could be wiped out by luring them past a line of forts. So that was removed...returning fighting to mere chance.
    Rather than abolishing good ideas, build on them. So in this case, mounted units could do damage to units they went past, allowing you to soften up the enemy at the cost of pulling units out of your own SOD, and representing the real world desire to turn the opponent's flank.
     
  4. vincentz

    vincentz Programmer

    Joined:
    Feb 4, 2009
    Messages:
    3,556
    Gender:
    Male
    Location:
    Denmark
    Well, I tried to mess around with the randomness per hit, and it really didnt have the wanted effect.
    Instead I halved the per-hit damage. Usually a battle would be from 5-7 rounds, but with the halved damage it is not uncommon to get 15-20 rounds, which, while still favoring the strongest, it levels out a bit and especially removes the lucky strikes for both strong and weak (it is easier to get 5 hits in a row than to have 10 hits in a row.)

    The result is that a strong vs weak will be more efficient, though not always damage free, and two equals will both be somewhat equally damaged.

    edit : crap! back to the drawing boards
    Spoiler :
     
  5. Testhero

    Testhero Warlord

    Joined:
    Jan 17, 2015
    Messages:
    178
    Gender:
    Male
    Location:
    Dublin
    You are on the right track the current problem is as William's East Indiaman is damaged its strength rating drops and its probability of winning the next round tanks.
    with this setup first strikes will be very powerfull
     
  6. Ambidexter

    Ambidexter Edjumacated Idjit

    Joined:
    May 22, 2007
    Messages:
    388
    Location:
    Connecticut
    I read this and was reminded of a tradition in the British Navy before going into battle to say the Shorter Grace from the Anglican Book of Common Prayer: "For what we are about to receive may the Lord make us truly thankful."
     
  7. vincentz

    vincentz Programmer

    Joined:
    Feb 4, 2009
    Messages:
    3,556
    Gender:
    Male
    Location:
    Denmark
    Well, thinking out loud here.
    To get who hits its :
    if (GC.getGameINLINE().getSorenRandNum(GC.getDefineINT("COMBAT_DIE_SIDES"), "Combat") < iDefenderOdds)
    and defenderOdds being :
    iDefenderOdds = ((GC.getDefineINT("COMBAT_DIE_SIDES") * iDefenderStrength) / (iAttackerStrength + iDefenderStrength));
    and COMBAT_DIE_SIDES being 1000...

    so without modifiers two axemen str 6 would be something like :

    Attacking axeman would hit if:
    Random(1000) < 1000 * 6 / (6+6) =>
    Random(1000) < 500
    That seems fair enough. 50/50 chance of hitting with equal units (damage done per round is another story, and isnt the main issue imho).

    edit:
    mmmh. I must be missing something, coz the higher the defender strength the higher chance the attacker gets???
    f.ex. a str 10 unit attacks a str 5 unit :
    RND1000 < 1000 * 5 / (5+10) => RND1000 < 333 or 33% hit while the other way around it would be
    RND1000 < 1000 * 10 / (10+5= => RND1000 < 666 or 66% chance of hitting.... It should be reverse???

    edit edit:
    it is ofcourse the opposite: the higher number the better chance of defender to hit, the lower the number the better chance of attacker to hit.

    if instead, to normalize the attacks, it was RND1000 < 450 + Defenderodds/10 the odds of a hit would lie between 450-550 instead of 1-1000
    f.ex.:
    RND1000 < 450 + (1000*5 / (5+5)) / 10 => 50%
    RND1000 < 450 + (1000*10 / (10+5)) / 10 => 51.7% instead of 66.6%
    maybe its too little, but the strength difference would still make the stronger one win.

    editeditedit :
    This might be better scaled for a mod with higher than normal unit strengths, and should prolly be changed to 40-60% instead of the 45-55% it is now, but seen on the last one, a strong unit will still crush the weaker even though the weaker still hits the car. The middle is vs strength 22 grenadier.
    Spoiler :


    eeeedit :
    Just in case a modder wants to try it out ;)
    Since DefenderOdds is 1-1000, dividing it with 5 gives 1-200 and adding 400 gives 401-600 instead of 1-1000.
    PHP:
    //        if (GC.getGameINLINE().getSorenRandNum(GC.getDefineINT("COMBAT_DIE_SIDES"), "Combat") < iDefenderOdds)
            
    if (GC.getGameINLINE().getSorenRandNum(GC.getDefineINT("COMBAT_DIE_SIDES"), "Combat") < 400 iDefenderOdds 5// Vincentz New Combat
    the /2 at the end is the change (to get more rounds)
    Code:
    iOurDamage = std::max(1, ((GC.getDefineINT("COMBAT_DAMAGE") * (iTheirFirepower + iStrengthFactor)) / (iOurFirepower + iStrengthFactor))/2);
    iTheirDamage = std::max(1, ((GC.getDefineINT("COMBAT_DAMAGE") * (iOurFirepower + iStrengthFactor)) / (iTheirFirepower + iStrengthFactor))/2);
    
     
  8. lindsay40k

    lindsay40k Emperor

    Joined:
    Mar 13, 2009
    Messages:
    1,671
    Gender:
    Female
    Location:
    England
    The 'spearman beating tank' issue is overblown. Of course things can go wrong. If an engine stalls or terrain turns out to be muddy, a bunch of lads can outflank a AFV and Molotov the engine. I suspect 99% odds seeing the RNG favour the 1% happen far less than IRL turnabouts. And whilst it may be frustrating when it does happen to your one guy holding a hill, you can bet you're not going to see an Isandlwana.
     
  9. vincentz

    vincentz Programmer

    Joined:
    Feb 4, 2009
    Messages:
    3,556
    Gender:
    Male
    Location:
    Denmark
    The modification I was aiming for is not to remove spear vs tanks, but the opposite, where a slight lead would result in no damage done to the strongest, while still maintaining it's superiority. This way, by giving the weakest unit a relative higher chance to score a hit, two units close in strength would result in a more even battle. the spear vs tank is still possible, though while with lesser chance of winning the battle it have much higher chance of consequentially making damage.
    F.ex before a str 10 unit vs are 5 would often lead to str 10 unit walking away unharmed due to the much higher hit chance as well as higher damage. Now the hit chance is more even and the rounds are increased, the units chance to win might be somewhat around the same, but the chance of it being damaged are much higher.
     
  10. Testhero

    Testhero Warlord

    Joined:
    Jan 17, 2015
    Messages:
    178
    Gender:
    Male
    Location:
    Dublin
    Sure but we don't want to see a Rourks drift where all the Zulu's are killed by a single unit of redcoats who don't receive a scratch.(or could even carry enough ammo)

    I apologize unreservedly for even bring up :spear: it was only mentioned in corraly to Vingenz's example in the OP spoiler And we can now all move on after having admired the cool smiley.

    Your example 3 there seems to have the exact result you are looking for the armoured cars annihilate the archers but not before a couple of crafty archers do a minuscule amount of damage to them.

    Your limiting of the results by constraining <450 seems to be worth exploring.

    Galleons with 22 strength wow! I am never invading your mod from vanilla my puny transports might as well scuttle themselves to deny you the xp!

    How do Armoured cars go Vs Airships?

    As far as I know two units with no special abilities/promotions fight untill one is eliminated. Hardly realistic, even the Persians at marathon had some survivors despite being slaughtered at 15:1. Historically the unit that perceives that it is loosing attempts to withdraw before it is annihilated yet in civIV at the moment every fight is a battle of Cammaron, hill of Shiroyama or Battle of Pasir Panjang do you have any thoughts as to having battles not leading to total elimination.
     
  11. vincentz

    vincentz Programmer

    Joined:
    Feb 4, 2009
    Messages:
    3,556
    Gender:
    Male
    Location:
    Denmark
    do you have any thoughts as to having battles not leading to total elimination

    .At barracks all units receive a promotion giving them 30% withdrawal rate. Added with the modcomp "defender withdrawal" it makes for some interesting battles imho. I also changed the sieges to rangestrikers instead of suiciders, so enemy stacks are a bigger challenge
     
  12. Mizar

    Mizar IM

    Joined:
    Mar 26, 2007
    Messages:
    356
    The more realistic version of combat panzer general style where a unit just deals a certain amount of damage brought us the 1-UPT Civ5 which doesn't work on a strategic map, only on a wide tactical panzer general map.

    Not all concepts that are good individually work when combined.
    Combat is more abstract in a strategic game like civ4, you sacrifice some realism to get an overall better and smoother strategic game.
     
  13. lindsay40k

    lindsay40k Emperor

    Joined:
    Mar 13, 2009
    Messages:
    1,671
    Gender:
    Female
    Location:
    England
    Can withdrawal be set to be attempted at a higher HP than 'nearly dead'?
     
  14. TalladegaKnight

    TalladegaKnight King

    Joined:
    Feb 3, 2013
    Messages:
    916
    Location:
    Ohio
    Agree. Civ was never meant to be a strategy war game. Why they went this route is mind boggling.
     
  15. vincentz

    vincentz Programmer

    Joined:
    Feb 4, 2009
    Messages:
    3,556
    Gender:
    Male
    Location:
    Denmark
    yup. here:
    PHP:
        if (getDamage() + iAttackerDamage >= maxHitPoints() && GC.getGameINLINE().getSorenRandNum(100"Withdrawal") < withdrawalProbability())
    It basically says that if the damage done to the unit + 1 more round that hits it, is more than its hitpoints AND the roll of a 100 dice is smaller than the units withdrawal rate.

    so if iAttackerDamage is replaced with something else. Could be 2 times attackerdamage or could be if unit lost half its health. If added a counter it could also be after X battlerounds.
    it could even be changed to/(or added as an extra check) : if I lost x% of my strenght and enemy only lost y% of his strenght, then try to retreat.

    actually, you just gave me an idea. Maybe have a modifier from Civics influence the withdrawal:
    "Hey dude! We are pacifist! no more fighting!" (early withdrawal)
    vs.
    "In the name of our religious belief/ideology, we will not retreat!" (no withdrawal)

    edit (thinking out loud ;))

    Something like this for Theocracy :
    PHP:
        int WDModifier;
        if (
    GET_PLAYER(this->getOwnerINLINE()).isNoNonStateReligionSpread())
        {
    WDModifier 0;}
        else
        {
    WDModifier 1;}
    if (
    getDamage() + iAttackerDamage >= maxHitPoints() && GC.getGameINLINE().getSorenRandNum(100"Withdrawal") < withdrawalProbability() * WDModifier)
    which would just leave withdrawalrate at 0 meaning no withdrawal whatsoever. Its a bit hard though, maybe half withdrawalrate is better.

    Thinking maybe War Weariness could be used as a factor as well.
     
  16. Testhero

    Testhero Warlord

    Joined:
    Jan 17, 2015
    Messages:
    178
    Gender:
    Male
    Location:
    Dublin
    As wars drag on casualty rates often pick up rather than diminishing.
    Most people think that as a war drags on and one side knows it is beaten that they ease off to preserve themselves but that doesn't happen for various reasons like fanatical adherents stiffening resolve (in many ways) lack of room to retreat and bitterness from the winning side veteran troops Vs Cannon fodder.

    I like the idea of political ideology driving withdrawal but it is already gamed a lot by shifting to theocracy and fudal vassalage when you go to a war building economy would it make it just as silly or even more silly to shift civics to stiffen troops resolve.
    although it might make police state more apealing.
     
  17. vincentz

    vincentz Programmer

    Joined:
    Feb 4, 2009
    Messages:
    3,556
    Gender:
    Male
    Location:
    Denmark
    the warweariness wasnt meant as warweariness, but simply a way to catch a civic in the C++ without having to make a new Tag.
    I agree with what you wrote.

    I tried for fun/testing changing the withdrawalrate to half when Theocracy and make units withdraw really early when attacking at Pacifism even if unit might win the battle eventually.
     
  18. Testhero

    Testhero Warlord

    Joined:
    Jan 17, 2015
    Messages:
    178
    Gender:
    Male
    Location:
    Dublin
    Wow where the heck did that come from Mizar.
    I have never and likely will never support the 1UPT format for CivIV. As you say go play SSI's Panzer series or CivV if that is what you want.

    I just wanted Vincenz thoughts on weather to make normal combats not be a final stand battle every time.
    Vincenz has already addressed this by having his barracks give every trained military unit a very generous 30% withdrawal chance.

    Sure the Combat in CivIV is abstract. However it doesn't have to be unrealistic.
    Not having to spend resources to reconstitute (heal) units is increasingly unrealistic once industrial age units are in use.

    Heck 30% might even be to much as it is so easy in BtS start with two or three promotions.
    Starting cavalry with a base 30% and 30% more from flanking I & II could lead to very hard to dispatch mounted units.
    I hate to think how slippery subs are with a 50% starting withdrawal +30% from Flanking makes 80% and another 30% more from the Tactics promotion a Great General like Großadmiral Karl Donitz and you have an unsinkable sub fleet. :eek:
     
  19. elmurcis

    elmurcis Emperor

    Joined:
    Feb 16, 2011
    Messages:
    1,136
    Location:
    Latvia
    Thinking about combat mechanics I can't forget real world war actions from some historical events...when A side general is ready to face B side army (somewhere in B side teritory, still some distance from any serious town)... fortified against counter-attacks, well rest/supplied and ready to attack.... But B side general simply was too drunk to wake up early enough to start planned counter-attack from his side (he had no idea that side A has sent into battlefield extra units). That 1 accident (too many wine/beer/vodka) saved more than 10000 men and turned around war outcome :)
     
  20. Testhero

    Testhero Warlord

    Joined:
    Jan 17, 2015
    Messages:
    178
    Gender:
    Male
    Location:
    Dublin
    Elmurcis don't be afraid to link to the real world event.
    Unusual things happen in wars.
    And did it really happen that way or is that just the cover story to preserve the life of the spy who passed on that (that side A has sent extra units into the battlefield) information?
     

Share This Page