Upgrading a unit which is the avatar of you leader still causes you to loose your traits.
I just noticed that this code in
void CvUnit::convert(CvUnit* pUnit) sets the new unit to be an Avatar, but does not set the old unit not to be an avatar before killing it. Shouldn't it be more like this?
Code:
// Avatars
if (pUnit->isAvatarOfCivLeader())
{[COLOR="Red"]
pUnit->setAvatarOfCivLeader(false);[/COLOR]
setAvatarOfCivLeader(true);
}
I believe your
if (!bConvert) lines in
void CvUnit::kill(bool bDelay, PlayerTypes ePlayer, bool bConvert) were added to prevent this, as well as to stop the unit passing through
def onUnitLost(self, argsList):, but they don't seem to be working. The suggestion above won't deal with
def onUnitLost(self, argsList): but seems like a better way of dealing with avatars.
---
In my modmod units of the Cult of the Dragon religion may gain the Rebellious promotion (as can Calabim units of the Empyrean religion), which has <iBetrayalChance>20 and so can make the unit turn barbarian.
I just now noticed that when a unit that starts with a religion in its xml defines but had converted to a different religion, it reverts back to its original religion once it turns barbarian. This isn't exactly a bug, but it does seems odd to me and has caused quite a bit of confusion for at least one player of my modmod.
I see that
void CvUnit::betray(PlayerTypes ePlayer) and
void CvUnit::upgrade(UnitTypes eUnit) both call
void CvUnit::convert(CvUnit* pUnit). I understand why you would want the religion set in XML to override the units actual religion for upgrades (otherwise you might get priests with the wrong religion or no religion), but I don't think this should happen for betrayals.
Would you mind editing
void CvUnit::betray(PlayerTypes ePlayer) so that the unit's religion wont get reset?
Changing the religion when trading or gifting a unit (which also use
void CvUnit::convert(CvUnit* pUnit)) seems odd too. Maybe it would be better for
void CvUnit::convert(CvUnit* pUnit) to pass on the units religion but
void CvUnit::upgrade(UnitTypes eUnit) to override this with the any religion the unit is given in the XML?
(Since I have spells to let Great Prophets upgrade to High Priests in my modmod, treating
void CvUnit::castConvertUnit(int spell) like
void CvUnit::upgrade(UnitTypes eUnit) as far as religions are concerned would be preferred.)