View Full Version : Experience modifier for Combat Odds ¡CODING NEEDED!


Exel
Jan 24, 2007, 08:08 AM
I've been brainstorming possible ways to improve the Civ4 combat system. One aspect of it I want to improve is the way how experience is accumulated. I find the linear exp gain dull and unrewarding when it comes to winning battles with marginal odds. So I came up with the following.

The experience a unit gains from combat should be influenced by the odds of winning. Winning at only 40% odds should give your units more experience than casually wiping out the enemy at over 90% chances. It would be an incentive to use your units more aggressively, instead of "exping up" units against beat-up or weaker opponents. Maybe not the most original of ideas, but nevertheless something that is gravely missed and deserves implementing. I devised a simple way of achieving the desired result using experience multipliers.



Solution: The experience points a unit gains after combat are multiplied by a value that is determined by its odds for winning.

Odds / Exp Multiplier
< 10% 3X
11-40% 2X
41-59% 1.5X
60-89% 1X
> 90% 0.5X

For example, if you Knight has a 60% chance of winning an enemy Maceman, it will after successful combat receive only the default amount of experience (multiplier 1). However if the same Knight is then attacked by a Pikeman and wins despite having only 40% chances, it will receive twice the experience (multiplier 2). If it gets attacked again and by some freak chance happens to win despite the attacker now having 97% odds, the Knight's experience points from that combat are tripled (multiplier 3).



Cry for modders: I don't know if any of this is actually doable. If it is, coding it is beyond my abilities, them being limited to some basic XML editing. So I'm pleading for you who know your way around the tricks of Civ4 customization (yes, YOU!) to, if you like the idea, code this feature for the rest of us to enjoy.
Thank you! :hatsoff:

Kael
Jan 24, 2007, 08:13 AM
Here is the code from Warlords for the xp grant to a unit that has just attacked and defeated a unit (pDefender).


iExperience = pDefender->attackXPValue();
iExperience = ((iExperience * iDefenderStrength) / iAttackerStrength);
iExperience = range(iExperience, GC.getDefineINT("MIN_EXPERIENCE_PER_COMBAT"), GC.getDefineINT("MAX_EXPERIENCE_PER_COMBAT"));
changeExperience(iExperience, pDefender->maxXPValue(), !pDefender->isBarbarian(), pPlot->getOwnerINLINE() == getOwnerINLINE());


The important part here is the bolded line. That is a modifier based on the relative strength of the two units. So if the defender has 50% more strength than the attacker he gets 50% more xp, etc.

So in effect your idea is already in place.

Exel
Jan 24, 2007, 08:44 AM
The problem with that is that it only takes into account the strengths of the combatants, not the combat odds. Most of the time that formula produces only marginal variation to the exp gained, unless you are beating tanks with knights. So it's insufficient for the purpose.

Is there some "iCombatOdds" value that you could replace the strength values with in that code?

Kael
Jan 24, 2007, 10:36 AM
The problem with that is that it only takes into account the strengths of the combatants, not the combat odds. Most of the time that formula produces only marginal variation to the exp gained, unless you are beating tanks with knights. So it's insufficient for the purpose.

Is there some "iCombatOdds" value that you could replace the strength values with in that code?

Yes, iDefenderOdds could modify the result.

Exel
Jan 24, 2007, 12:06 PM
Yes, iDefenderOdds could modify the result.

Correct me if I'm wrong with the following.

If I used the formula iExperience = (iExperience * iDefenderOdds * 3); the attacker would get a 1,2X modifier for its experience having attacked with 60% odds and 2,1X modifier having attacked with 30% odds?

If that's correct, then it gets pretty close to the original scheme I had. :)