Is there a way to make an "Improvement" on a district?

General Aidz

Chieftain
Joined
Jan 19, 2018
Messages
5
I have a replacement builder unit called slave. I want to have the option of sacrificing them in various districts for immediate bonuses such as gold, science etc. This is for a warhammer Drukhari mod.

My current approach is to make an improvement which doesn't actually place anything on the map, this i'm attempting to do with a short lua script, although i've never dealt with lua before. My current problem is that I don't know how to make a district a valid location for an improvement.

I have thought of instead making the slave function as both a builder and have a great person activation for the sacrifice, but I suspect the AI might not know how to use such a unit. That said I don't actually know how the AI works.
 
I have an idea, borrowing from the idea of builder charges being expendable upon district/wonder constructions by specific civilizations:

you create a new builder ability that generates your desired bonuses, and attach that ability to your Slave unit. You make sure that it it expends a builder charge, and has a requirement of 0 distance to a district. making it expend charges should be doable through EFFECT_ADJUST_UNIT_BUILD_CHARGES. Just don't call it improvement.

Now, trickier is if you want different yields depending on the district. Then I think you'd need to create a seperate ability for each district, and specify which district you need to be 0 tiles away from (min distance 0, max distance 0).

A quick peak at the modifiers.xml suggests a possible problem, the above effect seems to be called upon to affect base charges, not expending charges. I'm not finding any other effects that seem to touch builder charges, so you might want to peak at China and the like and see how they do it.
 
I assume by ability you mean a unit operation. I originally wanted to do just as you said and define a new unit operation to have my desired effect and just kill the unit when it is used. The problem I found was that unit operations are defined in lua and from the quick research I did, it seemed people where unable to create completely new ones. I could be wrong and someone has worked it out though.

The problem with effects like China and the like is that they require the city to currently be producing the wonder, city project etc. and I don't want it to be something that can be done without using a slave.
 
Hmmm, OK, got a different idea, though it won't give you *different* bonuses based on district. At least, not from the sacrifice itself. I'm not 100% certain that this will work, but I think the pieces are all there.

Your current slave is a variant builder, what we are going to need to do is create a new great-person type that has builder charges. I know that combat units can be given builder charges, so I think this will work.

You will also need to create a *lot* of these, as great people need to have unique names. Might I suggest you use some copy and paste to create "Slave 0000" through "Slave 0100"? If you find you need more over the course of a marathon play through, you can keep building up without changing the naming convention (always try to future proof your numbering and naming!). You also need 1 great work each of a new type, I don't know your universe so I'm going to assume you call them "Soul of Slave 0000" through "Soul of Slave 0100". Give this type of great work (Might I recommend GREATWORKOBJECT_SOUL) a set of bonuses. Oh, and you need to also create a unique city project that grants one of these Slaves at the appropriate cost, *and* make sure there is no way to get them through normal great person methods. Hmm, if you are willing to have them be visible in the Great Person view, you could give them some outrageous number of Great Person Points (like 1,000,000), so that it would take even more gold/faith than that for another Civ to purchase. Then grant that many Great Person Points when completing the project I mentioned above.

And after all that painful work... you need to create some new buildings too. One for each district type that can receive this sort of bonus. The buildings will do nothing but hold these Souls, and have no yields or upkeep cost. The easy way to not create more of a burden for the player is to give the buildings a 0 production/gold cost. Alternatively, with more work, you can probably find a way to grant the building upon completion of the district, but that might be a lot more work, you might have to create unique district variants in order to do so. You also have to decide how many Soul slots each building will have. However, you can also provide a theming bonus once all slots are filled. So, your military district building could get a theming bonus of +X production when all Y slots are filled, etc. Make sure it's automatic theming, rather than checking for any combination of properties of the great work.

Keep in mind, it might take using all builder charges and using the great work in order to delete the unit, I'm not sure. Or it might go away when the Soul is sacrificed no matter how many charges are used, and not be consumed from using builder charges. I think this second one is most likely. Either way, reducing the number of builder charges might achieve your desired balance.

That's my best shot at this idea. And it'll take a lot of work to implement, if it can work.
 
Top Bottom