Support Fire

Gerikes

User of Run-on Sentences.
Joined
Jul 26, 2005
Messages
1,753
Location
Massachusetts
Warning: This patch breaks previous save-games!

Ok, here's my first attempt at the Support Fire system. I'll explain briefly how it works, the math that it uses, and the XML you can use to affect it. Note that I can change this up if you want, I'm just putting down everything I have so that things can be changed if needed.

This thread can be used for questions about the Support Fire system, as well as, if you wish, a place to discuss any balance changes related to Support Fire that you might wish to have in the future (unless you have a seperate thread for that).

Support Fire (SF) is the ability for a unit in a plot being attacked that is not the defender to do collateral damage to all units where the attacker is striking from that is not the attacker.

SF is an ability that can be given to units via XML tags. Each unit has three tags that can be added to it's info:

  • iSupportFireDamage: The strength of the unit when doing SF. This is recognized as a percentage value of the unit's typical strength. Thus, when this value is 100, the unit's strength doing SF collateral damage is the same as normal. At 200, the unit's strength is double that than normal. All unit's default to zero, meaning they have strength zero, which means they can't do supporting fire damage.
  • iSupportFireDamageLimit: The maximum amount of damage that the unit's SF damage can do to the unit. This is an over-time value. Thus, if this value is 50, then at any time the damage done to the unit from SF can not go over 50% of the unit's strength.
  • iSupportFireDamageMaxUnits: The maximum amount of units that can be harmed during SF.

These tags follow the same pattern as normal collateral damage XML tags.

As well, there is a defined variable (placed in GlobalDefinesAlt.xml) that defines SUPPORT_FIRE_DAMAGE. This is the base amount of damage a support fire unit will do during a round of support fire.

Determining Support Fire Values:

Just using what you know about the XML values should be enough, raising and lowering each until they're right. However, this should help you in determining what values you want.

In a nutshell, this is how it works. Targets are randomly picked from the defending plot (with targets that have higher amounts of HP left more likely to get picked). Each of these units is dealt damage (see below). Only a certain number of units will be affected, with the max being the iSupportFireDamageMaxUnits value for the SF unit. Each unit is dealt it's damage, but will not have damage dealt higher than the unit's iSupportFireDamageLimit, just like normal collateral damage.

How damage is calculated:

First off, the damage dealt starts at the value for SUPPORT_FIRE_DAMAGE, located in the GlobalDefinesAlt xml file.

This number is modified to actually be higher or lower, depending on how powerful the SF unit is to the target. The two are compared by the SF unit's Collateral Strength (it's base strength hightened or lowered by using the iSupportFireDamage value) and the Target unit's base strength.

So, when determining the values, here is my suggestion without having to worry too much about math:

1.) Start with a SUPPORT_FIRE_DAMAGE value. I've made it 10. This means, by default, if the SF unit's iSupportFireDamage value is 100 (default), and the SF unit and target unit have equal strength, than the target unit will recieve 10 damage. This is where you start from: how much damage do you want an equally-matched unit to deal against an equally matched unit.

2.) To make unit more/less powerful, heighten or lower the iSupportFireDamage value for that unit. Lowering it means that the unit will do less damage. Making it 50 means approx a 20% drop in damage against equally-strengthed unit, about a 33% drop in damage against unit twice as strong, and about a 38% drop in damage against a unit three times as strong.

As you can see, the higher the difference in the strengths, the less change is done. This means that making the value for a unit 200 (double it's typical strength) will not double it's damage, nor will making it's value 1000 make it do 10x the damage (in fact, at 1000 it wil only do about 70% more damage than normal against similarly-strengthed units).

So, don't be afraid to raise it very high, or drop it very low, as the farther from 100 you go the less change it will make. The drop from 100 to 80 makes a bigger difference than from 80 to 60.

3.) To make a unit more/less powerful without having to worry about these factors, you can also change the other two values. These are probably good for making later-era units more powerful than early-era while still maintaining a level amount of damage being dealt in one blow.


How SF Works and it's Calculations

If you really want to get to the nitty gritty, I've put all the math below:

Spoiler :


SF follows the same exact way of calculating collateral damage as done typical collateral damage, with the exception being where in normal collateral damage the defending plot and it's occupants are affected, in SF the plot that the attack is launching from is affected.

First, a unit attacks a plot. The plot goes through it's typical phase to find the best defender. This process is unchanged.

After the defender is selected, there is then a check made to find the best SF-capable unit in the group. (Note: The function to determine the "best" support fire unit is still to be determined. Currently, it just takes one of them). Then, that one unit does it's SF damage.

The damage is calculated like Collateral damage, so if you know how that works you can use that as your guide. First, each unit in the plot is checked to see if it can be affected by SF. A unit is considered available to be a target of SF if that unit...

  1. Not the attacking unit.
  2. At war with the SF unit's team.
  3. Not invisible.
  4. is a defendable unit. (i.e. Not a worker / Settler/ Other non-defenable unit)

Each one of these units is given a random number between 1 and 1000, and that number is multiplied by their total strength. This gives each unit a "Target Value".

Next, the targets to be hit are choosen. The number of targets "hit" will be the SF unit's "iSupportFireDamageMaxUnits" value. If the number of possible targets is less than or equal to this amount, then all the possible targets are hit. Otherwise, only the top N targets are hit (with N being the "iSupportFireDamageMaxUnits).

The amount of damage done to any unit is then determined in according to this series of formulae (warning: math ahead):

---

Collateral Strength = (SFBS * SFD) / 100

This is basically the strength of the unit for these calculating purposes after being modified by the unit's iSupportFireDamage value. (Thus, a "100" for "iSupportFireDamage" means the unit's iCollateralStrength will be their base strength. A 200 means it will be double their base strength, etc)

SFBS = SupportFireBaseStrength, the base strength of the SF unit (if it's an air unit then the SFBS is their base air strength).

SFD = The unit's iSupportFireDamage value.

---

StrengthFactor = ((CollateralStrength + TBS + 1) / 2)

This is the "strength factor" against any one target that the SF unit is dealing damage to. It is used to determine

CollateralStrength: Computed above.

TBS: Target's Base Combat Strength

---

Support Fire Damage
The way that it is actually computed is otherwise, but thought this formula which I factored to was more aesthetically pleasing.

Code:
                     2(CollateralStrength) + TBS + 1
SupportFireDamage =  ------------------------------ * SUPORT_FIRE_DAMAGE
                     2(TBS) + CollateralStrength + 1

What this basically means is that the amount of damage done to a unit from SF will basically rely on the Collateral Strength and the Target Unit's base strength. Thus, if the SF unit's Collateral Strength and the target unit's base strength is equal, the amount of damage done will be SUPPORT_FIRE_DAMAGE.

CollateralStrength: Collateral Strength of the SF against the Target Unit (Calculated above)
TBS: Target's Base Strength
SUPPORT_FIRE_DAMAGE: A constant (defined in GlobalDefinesAlt).

---

Target's Final Damage = max(TCD, min(TCD + SupportFireDamage, SFDL))

This basically means that the Target's Final damage is going to be at least it's current damage, and at most the limit of damage that the SF unit can do.

TCD = Target's Current Damage
This is the value of the unit's "damage" (0 being not damaged, 100 being dead) before the SF occured.

SFD = Support Fire Damage
This is the value of the Support Fire Damage that is done to the unit. Calculated Above.

SFDL = Support Fire Damage Limit
This is the SF unit's iSupportFireDamageLimit.


Other Notes on Support Fire

Every unit can only do one support fire shot per turn. This value is completely independent of whether or not that unit has movement points left or not. Once a unit uses it's support fire shot, it does not regain the ability to use that support fire shot until it's next turn (which means the beginning of the player's turn).

A unit does not use up it's support fire shot per turn if the unit that is attacking is attacking from a plot that has no units in it, or if the units that are in it can not be targetted for support fire (such as if the units are all already at their limit).

Finally, the patch

This is obsolete. Support Fire is now included into the game.
 
sounds nice! hope it works out well ingame
 
Ok, some questions, because I am a big fan of exactness:

1.) Should there be somewhere in the interface that shows how many support fire shots are left for each unit? If a way of subtly showing somewhere that the unit has a support fire shot left can be implemented, then that would be extemely helpful to the player who might be thinking about an attack. Also, if that is shown there should probably be shown something that says that the unit has the support fire ability, but just doesn't have any shots left.

I'm thinking a small icon, similar to the sword icon, that can be put into the info pane for plot info next to the unit's info. Even if that icon is just the letters "SF" or a picture of something that would represent Support Fire. Perhaps if a unit has used it's support fire, then you have that icon with the "no sign" on it. The only problem with this is if you want to later on allow for multiple support fire shots (say as a promotion) then this "on/off" icon might not work.
 
So you're asking if the player or AI should be able to see if the "stack" he's attacking has SF capabilities and if so, how many are left? I'm on the fence about this honestly. I like the fact that you could be caught by surprise, but you also should know which combat types can have this promotion so it's not that big of a surprise in your attack. :hmm: Still on the fence.
 
I think SF should be a surprise attack. And if you played the mod one time you know which kind of units MAY have SF-shots left.

Should be taken into the Pedia under the concepts and in the unitentries in the pedia.
 
woodelf said:
So you're asking if the player or AI should be able to see if the "stack" he's attacking has SF capabilities and if so, how many are left? I'm on the fence about this honestly. I like the fact that you could be caught by surprise, but you also should know which combat types can have this promotion so it's not that big of a surprise in your attack. :hmm: Still on the fence.

Well, maybe later I can put stuff into the AI to recognize this, although I think it would be best to leave it alone. The reason is that making it realize Support Fire will only serve to make it less likely to attack, but there would have to be a whole bunch of work done to make it realize that the alternative is to spread it's forces out. I might be able to see if there's any places in there that I can make it look more to spread it forces out by default, though.

But I'm speaking from a players perspective. Basically you have to wonder if it's more fun to see an archer and know that it can do collateral but have to make decisions because you don't know if the unit has already used it up, or to be able to determine this all strategically because you already have this info.
 
Unless there's a definite need I try to K.I.S.S. everything. Doing more unnecessary work isn't a good plan.
 
Making the graphics change so that the Supporting Fire units are shown doing their little supporting fire just before the actual attack is proving to be quite a formidable challenge. It might be something I'll look at later, but right now I'm looking for creating something stable (Keep It Stable, Stupid). I'll leave the highly complex, graphical magic to something I have more stock in :P
 
Great job Gerikes.
I vote for being surprised too:)
However would there be an easy way to just limit stacks to i.e. 7 in general? This way we shouldn't have problems with the AI. Tactics like flanking are well not encouraged but forced this way but still I think not too unreasonable this way.
About the animation. Wouldn't this be just a simple python call for the attack animation? Sorry totally noob here.
Anyway I will dl this now and give the rangedunits the new tags:)

Edit:
I noticed the Cvgamecoredll.dlll is much smaller isn't that merged already with the original modcode?
 
Ok done the xml(except text). Next version we can test it. I left all units with standard settings for now. The damage was based on the unitstr. anyway right? So maybe there won't be needed many other settings.(Just gobbos and Skeletons shoot a little weaker now). And well the siegeweapons don't have it yet but that's the minority part to fix.
 
Lord Olleus said:
the size depends on how it is compiled. I use the setting 'Max speed' and I guess Gerikes uses 'Smallset DLL'. Nothing to worry about.

Actually, now that you mention it, when compiling I didn't have any optimizations on. I think the size difference is because I'm using Visual Studio? Maybe I'll actually turn on a speed opt next time :P

Edit: My bad. I had maximize speed for WH. I had no optimizations for one of my other projects. Man, I should really start renaming all those .sln files from their default CvGameCoreDLL.sln! I probably have around 6 of them spread out everywhere.

Civmansam said:
Nice job Gerikes, you should release a modcomp!

Bah, too much work!

Ploe said:
Ok done the xml(except text). Next version we can test it. I left all units with standard settings for now. The damage was based on the unitstr. anyway right? So maybe there won't be needed many other settings.(Just gobbos and Skeletons shoot a little weaker now)

I understand that the calculations was a bit long, but just know this:

Don't change any of the combat strengths for the units. Make them what they are regardless of if the unit has SF or not. If you want to alter how strongth their SF is, then alter the iSupportFireDamage tag. This will make their support fire damage do more or less. For example, if you want an archer who normally has combat strength of 4 to work as a combat strength of 2 when doing SF, don't reduce their combat strength! Instead, set their iSupportFireDamage to 50. This make sthe unit act as if it has 50% it's normal strength when calculating support fire.


As for the animation, I've always been perplexed at how it works. I've always thought that you could just use entity missions, but never was able to get them to work. I'll take another look at all that tonight.
 
Back
Top Bottom