View Full Version : Support Fire


Gerikes
Aug 07, 2006, 06:57 AM
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:



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...


Not the attacking unit.
At war with the SF unit's team.
Not invisible.
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.


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.

Gerikes
Aug 07, 2006, 07:05 AM
Gerikes's TODO:

Try to show supporting fire animation during combat (will try again after examining some of the things Dale has done with his stack-attack mod, once he releases the sources).

seZereth
Aug 07, 2006, 07:48 AM
sounds nice! hope it works out well ingame

woodelf
Aug 07, 2006, 08:16 AM
This sounds super. I can't wait to see it in action. :goodjob:

Duke van Frost
Aug 07, 2006, 08:25 AM
I like the way we´re going with this, stacks a re becoming more like armies the way support fire works and not just simple conglomerations of units.

Gerikes
Aug 07, 2006, 08:28 AM
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" (http://www.wapahani.com/no-sign.gif) 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.

woodelf
Aug 07, 2006, 08:39 AM
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.

Duke van Frost
Aug 07, 2006, 08:45 AM
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.

Gerikes
Aug 07, 2006, 08:52 AM
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.

woodelf
Aug 07, 2006, 09:01 AM
I'm leaning towards getting surprised. :p

Gerikes
Aug 07, 2006, 09:43 AM
I'm leaning towards getting surprised. :p

I'm pretty neutral on the whole idea (although it is less code for me if there's not interface changes :P)

woodelf
Aug 07, 2006, 09:47 AM
Unless there's a definite need I try to K.I.S.S. everything. Doing more unnecessary work isn't a good plan.

Gerikes
Aug 07, 2006, 01:56 PM
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

Psychic_Llamas
Aug 08, 2006, 03:29 AM
i vote surprise. Who ever knew where the woodelf Waywatchers were when the bretonnians tried to attack?? they got shot in the ass! (almost litterally;))

Lord Olleus
Aug 08, 2006, 07:16 AM
Wow, well done :D.

Its a good idea about it causing collateral damage as it balances stacks more. It makes stacks better for defence but not offence, which means more choices for the player, which is good. I'm leaning towards no interface change.

Ploeperpengel
Aug 08, 2006, 12:06 PM
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?

Lord Olleus
Aug 08, 2006, 12:49 PM
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.

Ploeperpengel
Aug 08, 2006, 12:57 PM
Ok good. I'm such an innocent with this:mischief:

Civmansam
Aug 08, 2006, 02:58 PM
Nice job Gerikes, you should release a modcomp!

Ploeperpengel
Aug 08, 2006, 03:01 PM
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.

Gerikes
Aug 08, 2006, 04:56 PM
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.


Nice job Gerikes, you should release a modcomp!


Bah, too much work!


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.

Ploeperpengel
Aug 08, 2006, 05:00 PM
No worries seems I understood right in the firstplace. I just altered SFdamage as you explained for gobbos and Skeletons-the rest is standard.

Gerikes
Aug 08, 2006, 05:02 PM
No worries seems I understood right in the firstplace. I just altered SFdamage as you explained for gobbos and Skeletons-the rest is standard.

Ah, ok. I must have misunderstood you then.

Ploeperpengel
Aug 08, 2006, 05:55 PM
Ok I added the tags to siegeweapons as well now. From your to do list I see you put the text into the mod, correct?

Gerikes
Aug 08, 2006, 06:18 PM
Ok I added the tags to siegeweapons as well now. From your to do list I see you put the text into the mod, correct?

Eek. No, sorry. I just assumed no one was looking at that :P

I'll post them here in a bit, gotta' recompile my latest test and I'll try them out. Then you can just copy them into any text XML file you want.

Ploeperpengel
Aug 08, 2006, 06:22 PM
hehe, ok:p

Gerikes
Aug 08, 2006, 06:42 PM
<TEXT>
<Tag>TXT_KEY_MISC_YOU_SUFFER_SUPPORT_FIRE_DMG</Tag>
<English>You have suffered support fire damage! (%d1_Num [NUM1:Unit:Units])</English>
<French>You have suffered support fire damage! (%d1_Num [NUM1:Unit:Units])</French>
<German>You have suffered support fire damage! (%d1_Num [NUM1:Unit:Units])</German>
<Italian>You have suffered support fire damage! (%d1_Num [NUM1:Unit:Units])</Italian>
<Spanish>You have suffered support fire damage! (%d1_Num [NUM1:Unit:Units])</Spanish>
</TEXT>
<TEXT>
<Tag>TXT_KEY_MISC_YOU_INFLICT_SUPPORT_FIRE_DMG</Tag>
<English>Your %s1_UnitName has caused support fire damage! (%d2_Num [NUM2:Unit:Units])</English>
<French>Your %s1_UnitName has caused support fire damage! (%d2_Num [NUM2:Unit:Units])</French>
<German>Your %s1_UnitName has caused support fire damage! (%d2_Num [NUM2:Unit:Units])</German>
<Italian>Your %s1_UnitName has caused support fire damage! (%d2_Num [NUM2:Unit:Units])</Italian>
<Spanish>Your %s1_UnitName has caused support fire damage! (%d2_Num [NUM2:Unit:Units])</Spanish>
</TEXT>


Those are the txt_keys for the code that show up when dealing/receiving. I still have to work on the code for displaying that a unit has the support fire ability. I'll provide the key's when I provide the code :P

Ploeperpengel
Aug 08, 2006, 06:56 PM
wonderful is also added to the mod.:)

woodelf
Aug 08, 2006, 07:09 PM
This is a super addition. Fear my Woodelven army now! :evil:

Duke van Frost
Aug 09, 2006, 08:37 AM
Yeah, a really nice and brand new feature for the mod. Can´t wait to play with this.

Ploeperpengel
Aug 09, 2006, 08:39 AM
25mins to go;)

woodelf
Aug 09, 2006, 09:05 AM
Oooh, a new version coming today then?

Ploeperpengel
Aug 09, 2006, 09:17 AM
It's uploaded don't you remember what we talked about 5 hours ago?:p

Gerikes
Aug 09, 2006, 11:38 AM
I like how Support Fire turned out. Just need the XML text tag added in for help, but that's no problem.

I think I'm also gonna' try to fix how when you inflict support fire damage there's no little pointer. I never tried it out, just assumed it worked, but apparently not. It's nice how I feel that I should support my axemen with a few archers, and when I'm about to attack a city I spread my troops out.

Gerikes
Aug 09, 2006, 11:46 AM
Oh, BTW, there's a bug in the Support Fire shots. Stupid little thing. The total number of support fire shots will increase every turn, so rather than regenerating the shots, they willl get another shot every turn. So, after a few turns they will have developed a few shots :P

I'll put out a patch soon.

Ploeperpengel
Aug 09, 2006, 01:18 PM
Oh, BTW, there's a bug in the Support Fire shots. Stupid little thing. The total number of support fire shots will increase every turn, so rather than regenerating the shots, they willl get another shot every turn. So, after a few turns they will have developed a few shots :P

I'll put out a patch soon.
Ah ok better wait for that unitl I start my testgame.

Gerikes
Aug 09, 2006, 01:32 PM
Ah ok better wait for that unitl I start my testgame.

Patch here:

http://forums.civfanatics.com/showpost.php?p=4384250&postcount=3

Lord Olleus
Aug 09, 2006, 02:48 PM
whats new in it?

Gerikes
Aug 09, 2006, 03:33 PM
whats new in it?

I put the differences in the post that the link goes to. It basically fixes the fact that units were gathering additional support fire shots every turn rather than just regenerating, so after five turns a unit would have 5 support fire shots. Now, they are correctly capped at one.

I also changed it so that when you inflict support fire there shows an icon on the plot that you inflicted, which wasn't there before.

woodelf
Aug 09, 2006, 05:58 PM
Since I'm a noob about coding, where do I put your patch Gerikes?

Gerikes
Aug 09, 2006, 06:06 PM
Since I'm a noob about coding, where do I put your patch Gerikes?

All you have to do is replace the dll file that's in the assets folder with the one with the patch. Don't worry about any of the other files.

woodelf
Aug 09, 2006, 06:10 PM
Ah, thanks. The other files had me confused. :)

Gerikes
Aug 09, 2006, 06:25 PM
Ah, thanks. The other files had me confused. :)

Yeah. What happens is the programmers take those files, and compile them together. That compilization process spits out that dll file, which then works all by itself. So, the sources are just there so that the programmers can work on them, and the dll is used for everyone else. It's not even necessary for the sources to go out with every release, but it's good to have them there for reference of what is in the dll.

Ploeperpengel
Apr 11, 2007, 07:22 PM
Player feedback about this subject is essential to balance the mod.

Ronin 42
Apr 17, 2007, 11:24 AM
Just some quick feedback - support fire seems quite well balanced already, not too much or too little and really makes you think about stack attacks which is good (you actually need some tactics to successfully attack a city) and gives defenders good support. I think it takes off the right amount of damage already and im glad that there is a stack limit on units - makes it much better. :)

seZereth
Apr 18, 2007, 12:55 PM
yea support fire is one of the coolest additions to WHFB, we need a programmer :( for more such creative little features.

Ronin 42
Apr 18, 2007, 06:06 PM
The only wierd thing about support fire is that it works on units inside cities aswell - when you attack from out of a city surely the other units you have inside the city are well fortified and if you attack it's only your one unit that vunerable but still it seems that all your units suffer damage.

I just think that units inside cities, not fighting but defending/fortified cant get hit by support fire because they will be too well covered and shielded.

Ploeperpengel
Apr 18, 2007, 07:29 PM
The only wierd thing about support fire is that it works on units inside cities aswell - when you attack from out of a city surely the other units you have inside the city are well fortified and if you attack it's only your one unit that vunerable but still it seems that all your units suffer damage.

I just think that units inside cities, not fighting but defending/fortified cant get hit by support fire because they will be too well covered and shielded.

That makes sense.

Ronin 42
Apr 19, 2007, 11:59 AM
Is there any way it can be changed without a programmer?

Ploeperpengel
Apr 19, 2007, 06:17 PM
Unfortunatly not. But I will lern it myself in time I hope I think this is a minor tweak to the code so maybe after BTS conversion I'll find a way to do it.

Psychic_Llamas
Apr 20, 2007, 07:16 PM
Well, ive started learning about programming, but have hit a dead end :( i followed one of the tutorials on how to get all the necessary programs etc, but i must have done something wrong and they dont work as described. im waiting for a response to my last post. once i get that little thing fixed ill check out the suppor fire stuff as my first assignment (just to ease myself in :p) but it may be a while till im competent.

Arexack_heretic
Apr 23, 2007, 03:16 AM
soon we'll have a whole corps of programmers! :D

Gerikes
Apr 23, 2007, 03:58 PM
Well isn't this thread a blast from the past :P

The only wierd thing about support fire is that it works on units inside cities aswell - when you attack from out of a city surely the other units you have inside the city are well fortified and if you attack it's only your one unit that vunerable but still it seems that all your units suffer damage.

I just think that units inside cities, not fighting but defending/fortified cant get hit by support fire because they will be too well covered and shielded.

If you guys can compile it, I think this change would work. It's in the CvUnit.cpp file under the updateCombat function. Add the emboldened lines.


// Gerikes / Warhammer Mod / 8th August 2006
// Support Fire

// If the plot is not a city, SF is ok. Prevents SF against a city.
if (!plot()->isCity())
{

// Check for a unit that can be a support fire unit.
CvUnit* pSupportFireUnit = pDefender->plot()->getBestSupportFireDefender(pDefender);

// If we've found one, start supporting fire.
if (pSupportFireUnit != NULL)
{
// Have that defending unit do collateral damage on this unit's attack-from plot
pSupportFireUnit->supportFireCollateralCombat(plot(), this);
}

}
// Gerikes / End

Ploeperpengel
Apr 23, 2007, 04:29 PM
Great thx Gerikes. Yes I can compile now:)

It may be an old thread but support fire rocks imo:goodjob: