1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Stack Attack... Attack.

Discussion in 'Civ4 - Creation & Customization' started by Mylon, Feb 18, 2009.

  1. Mylon

    Mylon Amateur Game Designer

    Joined:
    Nov 4, 2005
    Messages:
    1,013
    So, again I turn my eye to modding Civ4 and adressing one of the meatier issues of the game: The overly simplistic combat model.

    But it's tough deciding how to handle combat as part of a stack attack model. So far I've devised this:

    Attacker starts the combat.
    Attacking artillery fires
    Defending Artillery fires
    Defending archers fire (this is one of the few cases the defender gets the initative)
    Attacking archers fire
    Attacking cavalry go.
    Defending Cavalry go.
    Attacking infantry go.
    Defending infantry go.
    Nearby artillery "arrives"
    Nearby cavalry "arrives"
    Repeat cycle
    Nearby archers and infantry arrive
    Repeat until victory is determined. If victory is determined before any nearby units arrive, they are not affected by the combat.
    Any units reduced to 10% will fall back.

    For the specifics, units of equal strength, all factors considered, will do 20% damage to one another (how this varies, or if it will vary at all, will come in later iterations). However, if one side is outnumbering the other, that side will suffer a 50% penalty ratio for proportion he outnumbers the opponent. To detail this, if one person attacks a single unit with two units, both of the attacking units will be at 75% effectiveness in terms of attacking: For the purpose of taking damage, they will still be at full effectiveness.

    If this damage puts a unit below 10% or into death, health gets set to 10% and the unit is flagged as "wounded" and moved back one square. Wounded units can be killed. Calvary will have the opportunity to take a promotion to bypass this step for units they damage.

    Units with an advantage versus another unit type will have a 50% chance of attacking their favored foe, if one exists in the battle. Units can take tactics promotions that increase this chance of attacking their favored foe and decrease their chance of being attacked by their counter. Infantry (and certain ships) may also take the guard ability which allows them to be selected instead of another unit. The way this will proceed:

    Unit's turn (attacker or defender) comes up to attack. It rolls to see if it gets to attack a favored foe (if it has one). Upon success, the target unit is checked for a tactics promotion. If the original roll would not have been a success with the defender's modifier, the target is picked at random (treated as a failure). The targetted unit may be re-targetted, however. Upon success, the defender's units are polled to see if any have the guard promotion. If any do, a check is made for intervention and the best possible guard is selected. If that guard stands a better chance than the original targetted unit, the guard is now the defending unit. At this point the attacking unit has a 20% chance of attacking the guard unit, again modified by tactics, otherwise will select a unit at random. This part seems to involve a lot of steps, so I may need to revise this process of target selection.

    When nearby units are pulled in, their location is polled versus that of the enemy. If an enemy unit is pincered (enemy units on both sides) units will get a boost when entering combat to assist. Example: Tiles A B C. Player 1 is in tile B, is attacking tile C. When units from A arrive (after a couple of rounds into combat, depending), those units will have a boost, so player 1 better be able to take out units in tile C quickly.

    The advantage of this system is that it allows units to fight as a stack, as well as hold ground or a line (the system used in Alpha Centauri), as well as gerally making the system more tactical. Units will hopefully live longer and allow a player to recover from a mistake and/or recover from being massively outnumbered and, ideally, give the defender an advantage in the form of attrition (defender regenerates, attacker does not).

    Options? Suggestions? I need to make sure I have a solid "flowchart" of sorts before I start programming.
     
  2. Ajidica

    Ajidica Nerevarine

    Joined:
    Nov 29, 2006
    Messages:
    16,869
    I'd reccomend taking a look at Dales Combat Mod. It does basicly everything you wanted.
     
  3. Mylon

    Mylon Amateur Game Designer

    Joined:
    Nov 4, 2005
    Messages:
    1,013
    I'm not seeing any details about how Dale's mod resolves the stack attack. I suppose I'd have to dig into the thread to get that info.
     
  4. Ajidica

    Ajidica Nerevarine

    Joined:
    Nov 29, 2006
    Messages:
    16,869
    IIRC, stack attack is done with any fighters attacking each other. All non-destroyed fighters provide ground support. Artillers fire is then exchanged, the ranged. Melee troops hold the line while mounted troops go around the flanks to atttack the artillery and archers. It is alot more complicated than this with opportunity attacks, and such. All of this is done in one combat, so you see a big clash. How you want combat done would require a complete (not just modding) of the source code, and possible expand into the unreachable parts of the game code. If you want combat as complex as you described, I would reccomend the Total War games.
     
  5. Mylon

    Mylon Amateur Game Designer

    Joined:
    Nov 4, 2005
    Messages:
    1,013
    I've fiddled with the code and I've almost made a stack attack mechanism for the space mod in this game, though I would dip into Dale's and steal (and tweak) the code he uses for the graphical part of the attack. The actual process isn't too difficult to program, I merely need to have a set in stone process laid out for the actual before, otherwise I'll wander around and not get anything done.
     
  6. Ajidica

    Ajidica Nerevarine

    Joined:
    Nov 29, 2006
    Messages:
    16,869
    I know nothing about C++ coding (it is likely hell will freeze over before I know how) but a major portion of Dales challenge is getting the AI to understand it and ranged bombardment.
     
  7. Mylon

    Mylon Amateur Game Designer

    Joined:
    Nov 4, 2005
    Messages:
    1,013
    Aye, that is a challenge, but for the most part, as long as the AI uses a decent mix of units and moves them around in a big stack it should be fine.
     

Share This Page