Free promotion after tech research

wuTz

Warlord
Joined
Jan 12, 2012
Messages
160
I think, this could be an interesting element for mods...

My question:
I want the scout to have the promotion sentry after discovering tech optics. How is it possible?

Could it be similar to the allow_embarkation element?

Do I have to create a lua script or is it possible via xml/sql?

My idea (not the best)->
Sentry_promo requires optics_tech :)sad:)
Give scout free sentry_promo from gamestart
Possible? Thanks for your advice:goodjob:
 
I just took a look at the optics entry in Civ5Technologies.xml, and that doesn't use a free promotion tag, instead it uses <AllowsEmbarking>true</AllowsEmbarking> . So I'm not quite sure as to how this could be done, although I have a suspicion it would involve LUA
 
So I'm not quite sure as to how this could be done, although I have a suspicion it would involve LUA

Correct. There's no way to do this in XML, outside of the obvious kludge (make a low-cost National Wonder that gives the promotion to all units and make that NW require the tech you want). In Lua, it's fairly easy to do, though, as there's a Lua event that triggers when a tech is researched. The problem is, the Lua method's great if you want a one-shot effect (give every unit you own a free promotion when you reach tech X), and isn't so good for persistent effects (once you have that tech, every new unit will get that promotion from then on). You CAN tie this into the SerialEventUnitCreated function, to where all new units would gain the promotion as long as you have that tech, but that wouldn't help units that already exist, so you'd need two separate Lua triggers to do this right. Just be aware that SerialEventUnitCreated triggers multiple times (when a unit is created, when a unit embarks, when a unit disembarks, when an air unit rebases, and so on); since you only care about giving the promotion and never taking it away, this isn't really a problem.

Or you can combine the two approaches: in XML, make a "hidden" national wonder that gives the promotion to all units. When you research a certain tech, the Lua code triggers and an invisible copy of that wonder is placed in your capital. From then on, all units (both the ones you already had and the ones you'll build later) will have that promotion because the wonder will continue to exist. The downside to the wonder method is that if your capital is conquered, the building would be destroyed and you'd have no way to get it back unless you added ANOTHER Lua check. You could also do this with Policies, which'd have the benefit of being "intangible" and unable to be destroyed, but that has a whole slew of other issues. Projects would be ideal, as those are linked to the player (like Policies) and aren't destroyable, but Projects don't have any real effects in XML, so you'd still need Lua to place the promotions, and if you're doing that, then why bother with the Project?
 
Hm. So I will have to learn about LUA
That will take a while, because I just started modding and I am already gratified when XML/SQL works:crazyeye:

Thank you for your advice, spatzimaus.
 
Top Bottom