Need suggestions on overriding a improvement for a civ

Joined
Mar 6, 2003
Messages
775
I want to create a unique improvement for a civilization, replacing the old one... the XML field allows me to restrict the new improvement, but theres no field to disable the old improvement.

I want to be able to do this without completely replacing either the worker unit or the old improvement's technology for that civ.

I asked in the sdk/lua forum but I thought it would be appropriate to ask here too.
 
I've never used the Upgrade logic on the Improvements table, so I have no idea if/how that works. If it works to where you can upgrade an improvement already in place, then there's no need to add a build action for your new version.

But there's a brute-force method you could do: have them build the standard improvement, trap the SerialEventImprovementCreated event, and if it's of the right type and the builder is the right civ (and you have the right tech, and whatever other limits you add), delete the old improvement and replace it with the new one. This event is the one big advantage of using Improvements in mods; there's no BuildingCreated event, for instance. So for things like terraforming, my mod uses temporary improvements that are then replaced by the REAL effect.
Of course, with this method the AI wouldn't know that it was building the new one all along, and so would base its flavor decisions on the value for the old one. So it'd think it was building a Trading Post or whatnot, and would be as likely to build those as any other civ, but once built its post would be replaced by the upgraded improvement. You can get around this through Flavor values for custom build actions, but that doesn't apply here since you want the same actions for all civs.

The other problem is that there's no BuildingClass analogue for improvements. So if someone else captured the city, they'd now have the new-and-improved version around that city as well. Conversely, if I was that civ and I captured someone else's cities, I'd have to start from scratch if I wanted to use my improved version instead of the normal one.
The better way to do it, IMO, would be to give the civilization an inherent bonus for that improvement type without creating the new type altogether. So if you wanted to make an improved Trading Post that also added +1 research, then instead just have the civ give +1 research per TP.
 
Be aware that SerialEventImprovementCreated is fired when it becomes visible to the human player, rather than when it is actually created. So if an AI on the other side of the world builds it, and you can't see it, the event won't fire.

Hopefully there's a GameEvent analogue for that event, for when an Improvement is actually built. Maybe there's even one for buildings... if only they'd publish a list of them.
 
Be aware that SerialEventImprovementCreated is fired when it becomes visible to the human player, rather than when it is actually created.

In my experience it's both, although I'm still tweaking a bit on this. My mod uses this for terraforming, and it's seemed to work so far. But I can double-check that pretty easily.

Regardless, if you're willing to pay enough overhead, you can do this without that event. At the start of each turn, scan every tile in the world; if it has improvement X on it, and the owner of the tile is the civilization Y, then replace it with improvement Z. This'd definitely get around the captured cities issue, but again, the easier way to handle it would be to build something into a trait for this (although there'd be no graphical difference). And checking the entire world every turn gets old fast.
 
Is it possible to do an update in the XML so that all Civilizations except mine are given a free tech, and make that tech a prerequisite requirement for the standard improvement ?

If not I think this could be done through Lua at the beginning of the game. Just cycle through all the civs and give them the tech. It would cover a lot more than SerialEventImprovementCreated ..
 
Hopefully there's a GameEvent analogue for that event, for when an Improvement is actually built. Maybe there's even one for buildings... if only they'd publish a list of them.

Well, there's this list on the wiki...
_____
rezaf
 
You can even just give the improvement to all civs except the one you want and give your civ a different one:


<Improvements>
<Row>
<Type>IMPROVEMENT_TERRACE_FARM</Type>
<Description>TXT_KEY_IMPROVEMENT_TERRACE_FARM</Description>
<Civilopedia>TXT_KEY_CIV5_IMPROVEMENTS_TERRACE_FARM_TEXT</Civilopedia>
<Help>TXT_KEY_CIV5_IMPROVEMENTS_TERRACE_FARM_HELP</Help>
<ArtDefineTag>ART_DEF_IMPROVEMENT_TERRACE_FARM</ArtDefineTag>
<SpecificCivRequired>true</SpecificCivRequired>
<CivilizationType>CIVILIZATION_INCA</CivilizationType>

<HillsMakesValid>true</HillsMakesValid>
<PillageGold>18</PillageGold>
<PortraitIndex>0</PortraitIndex>
<IconAtlas>DLC02_TERRAIN_ATLAS</IconAtlas>
</Row>
</Improvements>
 
You can even just give the improvement to all civs except the one you want and give your civ a different one:

But that doesn't replace an existing improvement, it just complements it. What I need is a means to take away an improvement from a civ
 
Well, there's this list on the wiki...
I can see where the page title would confuse people, but those are from the Events namespace, not the newer GameEvents one. Events are, in general, focussed on UI-related stuff (things becoming known to the player, with things not known to them excluded in many cases), while GameEvents are player-agnostic general game rules stuff. There's a list of those on the wiki, that I put there, including the ones we've been able to infer the existence of from a couple of sources.
 
As Unique Improvements aren't overrides (unlike units or buildings, which can be), there's no direct way to do this. I suspect you'd have to do it via tech, using the mechanism described on these forums for per-civ tech locking - make the techs that depend on the current tech depend on it or the clone, ditto for units etc (if that's possible), and have the original still enable the standard improvement, and the alternate enable the replacement. I'm not sure how the AI would handle it, or whether that's even quite possible. The other option would be to make the vanilla improvement be enabled by an extra tech that the one civ is blocked from, and make it a 1-beaker tech or something. That would probably confuse the hell out of the AI, you'd need to put flavours on it and everything.
 
As Unique Improvements aren't overrides (unlike units or buildings, which can be), there's no direct way to do this. I suspect you'd have to do it via tech, using the mechanism described on these forums for per-civ tech locking - make the techs that depend on the current tech depend on it or the clone, ditto for units etc (if that's possible), and have the original still enable the standard improvement, and the alternate enable the replacement. I'm not sure how the AI would handle it, or whether that's even quite possible. The other option would be to make the vanilla improvement be enabled by an extra tech that the one civ is blocked from, and make it a 1-beaker tech or something. That would probably confuse the hell out of the AI, you'd need to put flavours on it and everything.

The first solution you mention would prevent trading of the original tech, which I don't like, and would force me to mess with the tech tree.

I wanted to try out the second solution, but it seems you can't without removing the first prerequisite tech and replacing it with a new one. If I could give an improvement two prerequisites, it would work.
 
Back
Top Bottom