Upgrading high-xp units

Discussion in 'Rise of Mankind: A New Dawn' started by Noyyau, Jun 12, 2016.

  1. Noyyau

    Noyyau Privateer Captain

    Joined:
    Jun 9, 2012
    Messages:
    1,442
    Location:
    Italy
    Recently I upgraded some high-xp units and noticed an odd behavior:

    My Noble Knights, all with xp in the range 120-140, when upgraded (to Cuirassiers) had their xp bumped down to 100, as I expected would happen.

    However when I upgraded three more high-xp units (all Warlord-led), with xp from a low of 200+ up to a staggering 500+ (my starting Warrior, who was lucky to survive, got a Warlord, and became a one-unit army who eliminated a civilization on his own), none of them lost a single xp point.

    What's the reason for this different behaviour?

    Is it some subtle difference in the coding between "Starts with the promotion "Led by Warlord" (the Noble Knights) rather than attaching a Great General through the normal ingame actions (my other units), meaning that a unit starting with the Led by Warlord promo doesn't get some other flag checked/value flipped from 0 to 1, and for the upgrades counts as a normal unit?
     
  2. Vokarya

    Vokarya Deity

    Joined:
    Mar 25, 2011
    Messages:
    6,184
    I read through the source code, and only units without a leader get their XP totals reduced after upgrading. The Great General is the only leader unit we have, but other units could be defined as leaders.

    This is from CvUnit.cpp, lines 11716 - 11722.
    Code:
    if (pUpgradeUnit->getLeaderUnitType() == NO_UNIT)
    {
    	if (pUpgradeUnit->getExperience() > GC.getDefineINT("MAX_EXPERIENCE_AFTER_UPGRADE"))
    	{
    		pUpgradeUnit->setExperience(GC.getDefineINT("MAX_EXPERIENCE_AFTER_UPGRADE"));
    	}
    }
     
  3. Noyyau

    Noyyau Privateer Captain

    Joined:
    Jun 9, 2012
    Messages:
    1,442
    Location:
    Italy
    So the solution would be to set the Noble Knights to also be defined as leaders?
     
  4. Vokarya

    Vokarya Deity

    Joined:
    Mar 25, 2011
    Messages:
    6,184
    No, that would only allow the Noble Knight to join another unit as a leader. What we would have to do is somehow define the Noble Knight as having a leader already attached. This is beyond my abilities, and I don't think it it important to do for just one unit.
     
  5. 45°38'N-13°47'E

    45°38'N-13°47'E Deity

    Joined:
    Jun 7, 2008
    Messages:
    5,972
    Location:
    Just wonder...
    I think I can fix it easily enough anyway, if we want to.
     
  6. Noyyau

    Noyyau Privateer Captain

    Joined:
    Jun 9, 2012
    Messages:
    1,442
    Location:
    Italy
    I'll leave to Vokarya the decision if the Noble Knights should maintain their xp at upgrading or not.
    He's the master balancer around here!
    (I would of course vote for letting them keep the xp. Hurray for one-unit armies!)
     

Share This Page