obsolete a promotion

joehbright

Chieftain
Joined
Oct 15, 2009
Messages
10
I have been investigation how to make a promotion obsolete, either by a researched tech or by selection of another promotion. There is no property in the XML schema for doing this already. In the Lua file that builds the UI for promotions, I see where it refers to a promotions list, but nowhere do I see the Lua build that table based on promotion prereqs or unit combat or anything like that.

This means, I assume, that I will need to wait until we can alter the DLLs. Anyone have a clever idea for how to do this with our existing capabilities?
 
Anyone have a clever idea for how to do this with our existing capabilities?

It's trivial.

Create a Lua event that triggers on the end of a turn. Loop over players. If that player has a certain tech, loop over his units. If that unit has the promotion in question, remove it.
The only real problem here is that it'll check this every turn, when obviously you only need to trigger the event once. If the save/load functionality was working it'd be easy to add a "have we done this yet?" check, but without that, just do it every turn.

Ta da. And yes, this sort of thing works; I used similar logic in my mod to create a "Space Elevator" Wonder that gives an "Orbital Drop" (infinite-range paradrop) promotion to any unit that starts its turn in the city the wonder is in (and then removes the promotion from any unit that DOESN'T start its turn in that city). Likewise, I created a "Hunter-Seeker Algorithm" national wonder that gives a negative promotion (lower combat vs. cities and lower visibility) to any enemy unit that starts its turn in your territory, and then removes that promotion when the unit leaves your territory. So removing promotions from a unit works just fine.
 
Although it might be good enough, and perhaps even make more sense, to make the promotion lost on upgrade
 
It's trivial.

Create a Lua event that triggers on the end of a turn. Loop over players. If that player has a certain tech, loop over his units. If that unit has the promotion in question, remove it.
The only real problem here is that it'll check this every turn, when obviously you only need to trigger the event once. If the save/load functionality was working it'd be easy to add a "have we done this yet?" check, but without that, just do it every turn.

Ta da. And yes, this sort of thing works; I used similar logic in my mod to create a "Space Elevator" Wonder that gives an "Orbital Drop" (infinite-range paradrop) promotion to any unit that starts its turn in the city the wonder is in (and then removes the promotion from any unit that DOESN'T start its turn in that city). Likewise, I created a "Hunter-Seeker Algorithm" national wonder that gives a negative promotion (lower combat vs. cities and lower visibility) to any enemy unit that starts its turn in your territory, and then removes that promotion when the unit leaves your territory. So removing promotions from a unit works just fine.

Thanks for the reply. I guess I was not specific enough with my question. When I said I want to make a promotion obsolete, I meant I wanted it to not be selectable. Lost on unit upgrade (below) is also a good suggestion, but not exactly what I had in mind.
 
Top Bottom