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

Flanking(the new ability for mounted units to kill siege weapons) how does it work?

Discussion in 'Civ4 - Strategy & Tips' started by oyzar, Dec 2, 2008.

  1. oyzar

    oyzar Have quit civ/forums

    Joined:
    Oct 7, 2006
    Messages:
    6,923
    Location:
    Norway
    Ya, if you can damage the units first flanking can be pretty brutal...

    I didn't have much cannons though
     
  2. vicawoo

    vicawoo Chieftain

    Joined:
    Feb 12, 2007
    Messages:
    3,226
    So flanking promotions increase the chance of hitting an individual siege unit, and collateral damage increases the damage (and chance) of flanking attacks. In addition to what they already do.
    I think fireaxis should change flanking to a set number of flanking attempts, not flanking successes.
     
  3. Elkad

    Elkad Emperor

    Joined:
    Mar 26, 2007
    Messages:
    1,044
    Wandering OT, but where did you get the "verbose combat help" hover mod?
     
  4. Duke Blackstone

    Duke Blackstone John Marchman

    Joined:
    Mar 26, 2008
    Messages:
    1,121
    Location:
    Dallas
    I agree. It's overpowered. And maby melée units in the stack could be given variable chances to block? I.E. Spear 30%, Ax and GunPowder 20%, Sword 15%? :) and Phlanx 50 because the unit is underpowered.
     
  5. vicawoo

    vicawoo Chieftain

    Joined:
    Feb 12, 2007
    Messages:
    3,226
    Technically, spears reduce the flanking damage. Unfortunately the way phalanxes are balanced to just be a little stronger than knights, and rifles a little stronger than cavalry, they're not a strong enough counter to stop the flanking damage. Mounted counters have to really overpower to minimize flanking damage.
     
  6. oyzar

    oyzar Have quit civ/forums

    Joined:
    Oct 7, 2006
    Messages:
    6,923
    Location:
    Norway
    Well war elephants at least stop horse archers, as outlined above ;).
     
  7. DanF5771

    DanF5771 Emperor

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    That was self-made -- a few extra lines of code added to CvGameTextMgr::setCombatPlotHelp() plus recompiling the dll. The following code also includes the needed rounds to kill/retreat for the attacker / defender:

    Spoiler :
    Code:
    [SIZE="3"]int iAttackerStrength  = pAttacker->currCombatStr(NULL, NULL);
    int iAttackerFirepower = pAttacker->currFirepower(NULL, NULL);
    int iDefenderStrength  = pDefender->currCombatStr(pPlot, pAttacker);
    int iDefenderFirepower = pDefender->currFirepower(pPlot, pAttacker);
    FAssert((iAttackerStrength + iDefenderStrength)*(iAttackerFirepower + iDefenderFirepower) > 0);
    
    int iAttackerOdds      = ((GC.getDefineINT("COMBAT_DIE_SIDES") * iAttackerStrength) / (iAttackerStrength + iDefenderStrength));
    int iStrengthFactor    = ((iAttackerFirepower + iDefenderFirepower + 1) / 2);
    int iDamageToAttacker  = std::max(1, ((GC.getDefineINT("COMBAT_DAMAGE") * (iDefenderFirepower + iStrengthFactor)) / (iAttackerFirepower + iStrengthFactor)));
    int iDamageToDefender  = std::max(1, ((GC.getDefineINT("COMBAT_DAMAGE") * (iAttackerFirepower + iStrengthFactor)) / (iDefenderFirepower + iStrengthFactor)));
    
    int iExperience; 
    if (pAttacker->combatLimit() < 100)
    {
    	iExperience        = GC.getDefineINT("EXPERIENCE_FROM_WITHDRAWL");
    }
    else
    {
    	iExperience        = (pDefender->attackXPValue() * iDefenderStrength) / iAttackerStrength;
    	iExperience        = range(iExperience, GC.getDefineINT("MIN_EXPERIENCE_PER_COMBAT"), GC.getDefineINT("MAX_EXPERIENCE_PER_COMBAT"));
    }
    int iNeededRoundsAttacker = (pDefender->currHitPoints() - 1 - pDefender->maxHitPoints() + pAttacker->combatLimit())/iDamageToDefender + 1;
    int iNeededRoundsDefender = (pAttacker->currHitPoints() - 1)/iDamageToAttacker + 1;
    
    szTempBuffer.Format(L"for %d XP -- " SETCOLR L"%d*%dHP" ENDCOLR L" / " SETCOLR L"%d*%dHP" ENDCOLR L" Odds: %.1f%%", 
    					  iExperience, TEXT_COLOR("COLOR_POSITIVE_TEXT"), iNeededRoundsAttacker, iDamageToDefender, TEXT_COLOR("COLOR_NEGATIVE_TEXT"), iNeededRoundsDefender, iDamageToAttacker, float(iAttackerOdds)/10.0f);
    
    szString.append(NEWLINE);
    szString.append(szTempBuffer.GetCString());[/SIZE]
     
  8. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    I finally got around to learning how to mod this in, and I just wanted to say thank you for posting this! :goodjob:

    I have no idea how I'll go but I hope to add some more functionality to this tool.
     
  9. DanF5771

    DanF5771 Emperor

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    :cool: - I actually just implemented this for some quick tests, but found it very useful and kept it in since then.
    E.g. I learned that my Chariots can attack barb Warriors in the open at 99.1% combat odds and get 2XP, or that it's better to wait and attack these barbs with your Axes if they are on forested hills to get a similar E[XP]...

    So what else do you have in mind?
     
  10. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    -The obvious ones, for me at least, are E[HP attacker] and E[HP defender] (or just as good, the E[Attacker HP lost] and E[Defender HP lost]).

    -Perhaps changing the XP to a non-integer, so you can see if you're near a xp jump. (or including both)

    -Again, a personal preference, but I'd like to remove all the percents and use decimal proportions for probabilities.

    -Ultimately what I would like to see, but which would take far more skill than I'll possibly have, is to have something on the interface which gives you two very simple graphs of the discrete probability distributions for the HP to each combatant (after battle obviously). They could be set up on the same axes... It could be done with just numbers, but a chart/graph would be a lot more impressive. I'm not sure how much it would take to draw them, but the calculations are not too intensive I don't think, especially not if I've already calculated E[A HP] and E[D HP] earlier.

    -Defender XP could be put in.

    -E[hammers lost] and E[hammers killed], which would need to refer specifically to the hammer cost of each unit, but would probably have to ignore promotions.

    Just some ideas at this stage. For the time being I'm happy using this compiled in with Better AI :). I guess I've officially created my first mod! :lol:
     
  11. oyzar

    oyzar Have quit civ/forums

    Joined:
    Oct 7, 2006
    Messages:
    6,923
    Location:
    Norway
    It is not terribly hard to see if you are close to a break point from the damage dealt and the total hp of the attacker / defender though... expected values means pretty little, but the probability of winning a given round is nice to have...
     
  12. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    Good for you. Would you care to enlighten us how you do this via a simple calculation in your head? Does it take you more than 5 seconds?

    You say expected values mean pretty little... What are you basing this on? This is your opinion and I think (i.e. my opinion is) you're mistaken. It's often the case that expected values are more useful than straight victory odds. More often however, having the two paired together gives a much better indication of how a battle turns out.

    Here is a real example:
    Two units attacking a city.

    Unit1
    99.0% odds
    E[Attacker HP] = 93.6
    E[Defender HP] = 0.2
    Attacker XP = 3

    Unit 2
    99.4% odds
    E[Attacker HP] = 76.8
    E[Defender HP] = 0.2
    Attacker XP = 1

    Moreover, Unit1 has an 83.5% chance to not take a hit (come out of battle with 100HP). Unit2 has only a 30.4% chance to not take a hit.


    I would find all this information useful.

    Based on these results, which unit would you attack with? Is the decision obvious to you?

    Final example, a mace attacks infantry. Tell me, how much damage can you expect the mace to deal? How many maces would you probably need to take the infantry down? If you can tell me these things using just the combat odds of 0.1% I'd be very interested in seeing how you worked it out.

    Thanks
     
  13. oyzar

    oyzar Have quit civ/forums

    Joined:
    Oct 7, 2006
    Messages:
    6,923
    Location:
    Norway
    Divide the HP by the damage dealt then find the reminder and divide that by number of hits. (HP%damage)/(HP/damage(integer division)) this tells you how much more damage you need to get one more hit in.

    @ Expected value, sure the second one is better, but that is a rather rare case with massive amount of first strikes but i concende the point that it might be useful to have it displayed in some way.
     
  14. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    Seems pretty hard to do in less than 5 seconds if you ask me, unless you're a maths wiz. Doing things modulo numbers near 20 eg. modulo 17 and modulo 23 I don't consider to be very quick in-head calculations. Do you suggest most people can do this quickly?

    Also, I feel some things need qualifying.

    "this tells you how much more damage you need to get one more hit in."

    Without mention of attacker or defender it's very hard to figure out what you even mean. And get one more hit in for what? Wouldn't you be trying to change the ratio so you need one less hit rather than one more hit? Perhaps it would be clearer if you gave an example?

    You could, for example, use the notation dA for damage dealt by attacker, and HA as hitpoints of attacker and use the subscript D for the same values for the defender.

    Hmm I would have called the first one better. Keeps more hitpoints and gains more XP for only a minor decrease in odds. The first unit does have 4-7 first strikes but it's not rare if you play a Protective leader. If you consider it rare then it's probably only rare with the way you use promotions on your units or for the leaders you play. People who use drill in particular, but also people who have other units with first strikes (keshiks, samurai, Cho Ko Nu (and crossbows more generally), modern armour etc., definitely could see the effects of first strikes in games.
     
  15. CivCorpse

    CivCorpse Supreme Overlord of All

    Joined:
    Nov 15, 2005
    Messages:
    1,930
    I am a bit confused. Why wouldunit1 with more hit points than unit2 have a better chance of winning?
     
  16. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    You may not have understood what I meant by the notation E[Attacker HP] and E[Defender HP]

    E[Attacker HP] := The expected (i.e. average) hitpoints the attacker will have after the battle. Similarly for E[Defender HP].

    Since these units are attacking, I had assumed we have full health 100HP units.

    Note that because both units are very very likely to kill the defender, that is why the expected defender hitpoints are so low (less than 1HP!).

    Whenever I write E[something] I mean expected value of something.
     
  17. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    Sorry for another bump, but I'm just letting anyone who read my above posts know that probably tonight or tomorrow I'll be uploading the first version of an Advanced Combat Odds mod or interface.

    Here's a peak at what it will do in the first version...



    @DanF,
    Spoiler :

    Can I suggest you make the following change to your code so it does not depend on COMBAT_DIE_SIDES? If you fiddle with COMBAT_DIE_SIDES by making it something like 2 or 3 you will see why this is important. When the die has 1000 sides it's hard to notice anything wrong.

    Code:
    int iDefenderOdds = ((GC.getDefineINT("COMBAT_DIE_SIDES") * iDefenderStrength) / (iAttackerStrength + iDefenderStrength));
    int iAttackerOdds = GC.getDefineINT("COMBAT_DIE_SIDES") - iDefenderOdds;
     

    Attached Files:

  18. TheMeInTeam

    TheMeInTeam Top Logic

    Joined:
    Jan 26, 2008
    Messages:
    25,708
    It's the variance between combat promotions and first strikes.
     
  19. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    TMIT you are right about the first strikes there but that example did not include Combat promotions necessarily.

    That example was meant to demonstrate the simple fact that having more first strikes gives greater combat odds at the same time as further increasing odds of surviving unhurt and leaving XP earned constant.

    Without first strikes, the only way to affect combat odds is by changing one or the other combatant's modified strengths which in turn affects XP earned.
     
  20. Anomander Rake

    Anomander Rake Warlord

    Joined:
    Sep 4, 2008
    Messages:
    207
    Location:
    London
    This looks really good!

    Can you include install instructions for a newbie please?

    I used the Installer for BAT/BUG and Blue Marble Gold, but I am confident enough to be able to extract it and put it the right folder. I used to run a lot of WOW addons and maintained a Fubar starter pack for ages (I can't believe people are STILL downloading it!)

    I'm hoping it integrates, or at least works nicely with BAT/BUG
     

Share This Page