How to add promotions that persist after unit upgrades?

mal_man

Chieftain
Joined
Mar 4, 2011
Messages
29
Is there a way to add a promotion or modifier to a unit and allow that modifier to carry through to the next upgrade? For example, I have a unique swordsman for Indonesia that I added, and I gave it a few modifiers that are the equivalent to Warrior Monk promotions, i.e. x2 Flanking bonus and Stealth. I want these abilities to carry forward to all upgraded units. So that means that these promotions would still apply even after I upgraded the swordsman to a musketman, or in my case, a longswordsman (since I'm using mods). Anyone know if there is a way to do this?
 
Last edited:
Hello? Can no one help me?

Edit: Well, this is encouraging. I am beginning to doubt it's even possible with the overflowing responses.
 
Last edited:
I've run into the same issue with abilities that are added from a unit being trained within a city that has Building_X. When the unit is upgraded the ability goes *poof*. I haven't found a solution as yet.
 
Is there any lua function that gets and sets unit abilities? I only know functions for promotions. If you find functions for unit abilities you could use something like this:

Code:
function OnUnitUpgraded(iPlayerID, unitID, eUpgradeUnitType)
   local pUnit = UnitManager.GetUnit(iPlayerID, unitID)
   --some code
end
Events.UnitUpgraded.Add( OnUnitUpgraded );

Of course you also have to get the promotions / abilities from the old unit, so your script knows which promotions it has to grant to the upgraded unit. I could observe that after each upgrade the old unit gets negative map coordinates and keeps its promotions. It only vanishes on the next turn.
So you could get the unit with negative coordinates and then check which promotions it has. Afterwards you kill this unit with negative coordinates in case another unit gets upgraded in the same turn, because otherwise it might cause confusions.
 
Last edited:
That is a shame. Now I have looked into Expansion1_Buildings.xml and saw the Ordu Building. I think it grants a permanent ability, because it uses the following code:
Code:
<Row>
            <ModifierId>ORDU_INCREASED_MOVEMENT_MODIFIER</ModifierId>
            <ModifierType>MODIFIER_SINGLE_CITY_GRANT_ABILITY_FOR_TRAINED_UNITS</ModifierType>
            <Permanent>true</Permanent>
        </Row>

Maybe mal_man can use this in his own mod.
 
That is a shame. Now I have looked into Expansion1_Buildings.xml and saw the Ordu Building. I think it grants a permanent ability, because it uses the following code:
Code:
<Row>
            <ModifierId>ORDU_INCREASED_MOVEMENT_MODIFIER</ModifierId>
            <ModifierType>MODIFIER_SINGLE_CITY_GRANT_ABILITY_FOR_TRAINED_UNITS</ModifierType>
            <Permanent>true</Permanent>
        </Row>

Maybe mal_man can use this in his own mod.
I used the same Collection and Effect types, and also set my modifier to grant an ability from a building as permanent and the ability still went *poof* when the unit was upgraded. When you upgrade a unit you are removing the existing unit and adding a new unit to the game -- this new unit is not trained in the city, therefore the ability is not applied to the new unit
 
Wow! I hoped that at least <Permanent>true</Permanent> would work. Now that is a big disappointment for me, because one of my mods also rely on unit abilities.

Can we declare this as a bug? I think this should be reported to Firaxis, because it makes no sense.
 
Wow! I hoped that at least <Permanent>true</Permanent> would work. Now that is a big disappointment for me, because one of my mods also rely on unit abilities.

Can we declare this as a bug? I think this should be reported to Firaxis, because it makes no sense.
Its not a bug. Its exactly as LEes said: upgrading a unit is basically removing said unit from the game and giving him the currently held promotions in the tree and updating the ABILITIES of the unit type.

To keep abilities throughout an upgrade line you need to assign the abilities to each unit in the line, like the Nubian civ.
 
Last edited:
Ok, but in my personal opinion the game should give the "new" unit the ability of the "old" unit.
The Nubia trait seems do be something different to me. It grants an ability to all units of a certain unit type. However, in this thread we are not interested in unit types. I mean mal_man certainly does not want to apply the ability to all melee units of Indonesia. He just wants to apply it to the Indonesian swordsmans and to all of its upgrades. (In my own mod I have a similar problem now.)

Now can someone explain the exact meaning of <Permanent>true</Permanent> please? If it does not have any impact on the upgraded units, then what is it good for? If it would not make any difference at all, then I would say it is a bug.
 
Ok, but in my personal opinion the game should give the "new" unit the ability of the "old" unit.
The Nubia trait seems do be something different to me. It grants an ability to all units of a certain unit type. However, in this thread we are not interested in unit types. I mean mal_man certainly does not want to apply the ability to all melee units of Indonesia. He just wants to apply it to the Indonesian swordsmans and to all of its upgrades. (In my own mod I have a similar problem now.)

Now can someone explain the exact meaning of <Permanent>true</Permanent> please? If it does not have any impact on the upgraded units, then what is it good for? If it would not make any difference at all, then I would say it is a bug.
His unique swordsman will upgrade to a musketman, then infantry, then mechanized infantry. And he wants those units to have that ability. So yes, thats exactly what he wants. Remember, at a certain point, his UU is become obsolete. So those newer units HAVE to get the ability or it dies out when the last upgraded UU dies.
 
What about warriors? They are melee units, too.
And I do not think that modern melee units should get the ability, if they have never been swordsmen.
Most likely one could exclude units by era or by UnitType.

As for the “modern melee shouldnt get it if they werent swordsman” bit? I think thats up to Mal_man lol. Also, I don’t think the game was designed that way. Maybe its possible to exclude a unit based the era it is constructed in, as opposed to the era it is “from” per se.
 
He already wrote that only swordsmen and their upgrades should have that ability. I want to achieve something similar, i.e. granting unit abilities that work like in Civ5. In Civ6 Firaxis unfortunately introduced a weird system and I suspect it is a bug.


Edit: Did anyone try to simply use promotions instead of abilities? I never changed the promotions tree, but maybe it would be possible to add in some "hidden" promotions for units. Those promotions should not be reachable by the normal promotions.
Instead they should only be granted by a Lua script.
Maybe this workaround could work.
 
Last edited:
He already wrote that only swordsmen and their upgrades should have that ability. I want to achieve something similar, i.e. granting unit abilities that work like in Civ5. In Civ6 Firaxis unfortunately introduced a weird system and I suspect it is a bug.


Edit: Did anyone try to simply use promotions instead of abilities? I never changed the promotions tree, but maybe it would be possible to add in some "hidden" promotions for units. Those promotions should not be reachable by the normal promotions.
Instead they should only be granted by a Lua script.
Maybe this workaround could work.

I've tried that and it worked I think from a gameplay point of view - the problem I had was it messed up the UI.
 
Ok, I am kind of relieved that you can confirm this workaround is actually working.
Maybe the UI problem can be solved by adjusting a Lua file. If I find a way to fix the UI for this purpose I will post it here.
 
re-writing the UI file to hide the promotion from view would not be so much the problem, altho this would instantly cause mod compatibility issues with any other mod that also uses a custom version of the UnitPanel file.

And the CivilopediaPageExcludes table may allow fairly simple hiding of the promotion from the civilopedia, but it would apply for all players, including the one able to use the promotion when playing as the correct civilization.

the problem might be locking out the promotion so it is un-selectable by the AI.
 
What if you use promotions in <UnitPromotionPrereqs> as prerequisites that can be only used for a different promotion class? Then it should be impossible to get that promotion even for the AI. :D
 
Back
Top Bottom