Unit Experience Modifiers

zzragnar0kzz

Chieftain
Joined
May 2, 2021
Messages
22
I am working on a mod that allows a unit to continue receiving experience after it has reached the maximum amount for its current level and has a promotion pending. Experience earned while the unit has a promotion pending is calculated and stored. Upon promotion, any stored experience is applied to the unit, up to the amount required for its next promotion; as it is possible to store enough experience for multiple promotions, any stored experience exceeding this amount will remain banked for the following promotion. Ultimately, this allows units to continue earning combat experience when they otherwise wouldn't, and introduces a strategic aspect to applying promotions.

Using the information found in this excellent guide, I have written a lua function to calculate combat experience when no value is provided by the game, such as when a unit has a promotion pending. Melee/ranged combat and attacking unit bonuses are considered, as is the bonus for a kill. It should even respect any defined barbarian and max-per-combat caps, but these are not yet fully tested.

I'm stuck trying to figure out how to identify any of the other numerous experience modifiers that may be in place for a particular unit. All of the GP retirement modifiers appear to be applied as abilities, so those should be easy enough to identify and account for. Similarly, identifying and accounting for any Civilization traits that may be affecting a unit should also be relatively painless. However, these are only a small handful of possible modifiers, and many others, such as those from Encampment and Harbor district buildings, do not apply empire-wide, but instead only to units created in a city with those buildings present.

Is there an easy way to determine exactly which modifiers are affecting a particular unit, or am I going to have to write a long, ugly rat's nest of code to make this work?

As a side note, do barbarian units even earn experience? Testing so far indicates they do not.

Thank you!
 
Next time I should dig through the database a little more thoroughly. It appears that the modifiers in question are all applied as unit abilities. Please disregard.
 
Top Bottom