Possible to add statistics to units?

DocBuchanan

Combat Medic
Joined
Nov 16, 2009
Messages
137
Location
San Antonio
Is it possible to add more statistics to units that would effect combat performance? Stats like armor, size, whatever else. Just want to know if it's possible.
 
It's called "Promotions". If you want to add some extra characteristics to various units, just create custom promotions, set them to be unselectable normally (the <CannotBeChosen> flag), and then figure out how you want them awarded.

Beyond that, you'll have to be MUCH more specific as to what you want.
 
Good to know! I might add some fun stuff in my scenario.

Not sure if you've noticed this, but you're a fountain of useful information, Spatzimaus! :) Thanks for your patience in helping all of us modding noobs!
 
Right but promotions only effect parent statistics like strength and ranged strength. I want to make new statistics. Morale, armor, etc.
 
Right but promotions only effect parent statistics like strength and ranged strength. I want to make new statistics. Morale, armor, etc.

But what do those statistics DO? If a high morale means gaining a bonus to combat when friendly units are nearby, then you can do that through promotions. If "armor" means taking less damage from combat, then you can do that through promotions. If you want some units to regenerate health constantly, you can do that. It's all semantics beyond a certain point; if the goal of your "armor" system can be achieved through the existing promotion abilities, then call it whatever you want, it's still the same thing.

And that's just with XML. Once you bring Lua into the mix, you can do a lot more. In my own mod, for instance, I have added custom promotions that use Lua to:
1> Increase or decrease a unit's base strength by +/-25% based on its opponent's strength
2> Give a 10% chance of dealing 5 "first strike" damage before the fight starts
3> Give a 10% chance of spontaneously healing 5 damage after the fight ends
4> Reduce all incoming damage sources by 1 point (meaning minimum of 0 instead of 1, so that you can't whittle the unit down with weak ranged attacks)
5> Steal promotions from the opposing unit
6> Deal 1 damage to any enemy units adjacent to the unit you're attacking
and so on. So chances are, whatever you envision "morale" and "armor" to mean can already be done using the existing tools.
 
I guess the difference between a statistic and a promotion is that statistics are dynamic and promotions are static. Health can be ten points one turn and 5 the next. But a promotion that provides +25% attack power one turn can't be changed to provide only 10% the next turn... Example loosely demonstrates how a units morale can change, it's supply level can change, it's type of equipment can change, type of ammunition... But I suppose I have my answer. Being creative with promotions is the answer but it has it's limits since there are only a few stats to take in to consideration. Thanks man.
 
But a promotion that provides +25% attack power one turn can't be changed to provide only 10% the next turn

Sure it can, because Lua can adjust what promotions units have on the fly. There are two simple ways to do that:

1> Create a "Attack 10" promotion and an "Attack 25" promotion. At the start of the turn/combat/whatever, figure out which one the unit should have and which one the unit shouldn't have. Very easy.

2> Create an "Attack" promotion that gives no direct bonus in the XML, but a Lua event figures out how much to alter a unit's base strength at the time the combat begins. See #1 in my previous post for an example of a situation where I already do this sort of thing in my own mod. The only downsides to this sort of change: first, that the AI won't really understand this when making the decision of whether or not to attack, and second, that it doesn't work well for ranged attacks.

So again, promotions can do exactly what you're asking, as long as you are willing to learn basic Lua coding.
 
The only big problem with using promotions like this is that you are limited to only being able to create about 60 new ones according to the civ wiki. If this limit was removed than spatz suggestion would be very effective, as always :)
 
The only big problem with using promotions like this is that you are limited to only being able to create about 60 new ones according to the civ wiki. If this limit was removed than spatz suggestion would be very effective, as always :)

Unfortunately, last time I checked the limit's still there, and yes, it does suck. But given that the devs' own official DLCs keep inching closer to that limit, it's only a matter of time before they fix that cap. Any expansion they made would almost be guaranteed to exceed that limit, after all. So planning now towards an open-ended system should be fine, because by the time you implemented this sort of thing it'd all be ready to go.

And again, since you'd be using Lua as the trigger, it actually takes fewer promotions than you might think. After all, if I have three different mechanisms that can add +10%, then I don't actually need three distinct +10% promotions. In my mod I have Psi units that can adjust their base strengths by anywhere from 75% to 125% of the base value, but it only takes 1 slot in the promotions table. So depending on how well you want the AI's decision-making process to account for your statistics, you can do this with very few actual promotions.
 
Spatz' approach is certainly your best bet. However, if you are determined to do it with new stats, it can be done. You have to use Lua to interact with the new stats, but you would have to use Lua to interact with the new promotions anyway. The extra work is that you would have to: 1) edit unit UI XML/Lua files to show your new stats and 2) interact with SavedGameDatabase to save between gamesaves. Not trivial, probably not worth the headache over the promotion approach, but doable.
 
Back
Top Bottom