How to use modify chops and Golden Age yields

BIWC_EMBERS

Chieftain
Joined
Mar 25, 2021
Messages
2
I'm trying to create a civilization based on forest yields and and focusing on improved tile yields. I'm currently planning on a unique improvement and an unique unit. However, I'm very new to modding so some help would be appreciated!

For the unique improvement I've modified the lumber mill to provide culture and gold. All of the improvement implementation is in place and achievable through XML.

For the unique unit I am considering an improvement chop mechanic on a worker. Since I'm already using lumber mills I was thinking of improving chops outside of the civilization territory or possibly inside of other civs, albeit with reduced yields.

For the trait I am considering a few options. The first is to improve the Golden Age yields from improved resources or provide increased strategic resources. The other option is providing combat strength to units on resource tiles.

It seems like the unit and trait would require modifications in Lua, but I'm not exactly sure where to start. I have a fair amount of coding experience, but don't know what functions to use.

From my understanding for the chop mechanic I would need:
  • Allow worker to enter other territories
  • Allow worker to remove forest feature in other territories
  • Assign production yield to city
For the Golden Age concept, would either options be possible purely in XML or will it require Lua?

I'd appreciate any help on how to implement this, or recommendations to the concept!
 
The first is to improve the Golden Age yields from improved resources or provide increased strategic resources.
I'm... unsure what this is supposed to mean. To improve Golden Age yields is to imply Golden Ages affected resource quantity to begin with. Or were you referring to e.g. the extra +1 gold per tile that yields at least 1 gold already?

If the latter, it's not super hard to implement. The easiest way I can think of is to create a dummy building which adds +1 gold to all resources using the same table that e.g. the stable, mint, forge, etc. use - if you want to do this for all resources using SQL rather than XML will allow you to immensely compress the the size of the database instructions needed to achieve than from ~200 lines (ballpark estimate) down to 5-ish. With Lua you can detect when a Golden Age begins (I don't think that's a built-in GameEvent, but if not someone has certainly implemented a LuaEvent for it) and give a copy of the dummy building to every city, which is then removed when the Golden Age ends.

The forest chopping thing gets... iffy. First of all, "allowing the worker to enter other territories" (implied: without open borders or being at war) is prohibited by the move mechanics hardcoded in the DLL and no XML, SQL or Lua is going to be able to affect that. Short of modding the DLL itself, the only way I can think of to make this work is to implement a teleport unit mission, which would be useless because I'm 99% sure the game would just teleport the unit back out of foreign territory the very next turn when, again, the DLL realizes the unit isn't supposed to be there.

I don't actually think it's possible to make forests choppable outside your territory in purely XML/SQL - the "chopping forest" action falls under the <Builds> table, which is meant to essentially map improvements to unit missions... but for Builds, the "you can do this outside of your own territory" ability is conferred upon the improvement itself, not the build, and there isn't an improvement corresponding to the "chop forest" build. You could try re-inventing the wood-chopping wheel and implement a custom wood chopping unit action in Lua, but it's absurdly hard. Not impossible, but deep into "is it even worth it" territory. I'm in the middle of writing a utility to streamline the process of implementing new unit actions but it's not coming along very well.
 
Allowing the worker to enter other territory is possible using the same promotion as missionaries/prophets. But then you'll run into difficulties trying to use the standard "Remove Forest" action. An approach would be to create a new improvement that can be built only on forests, but doesn't remove the forest (like the lumbermill, but you may also need to use bits of the feitoria for building outside of your territory), detect the completion of the new improvement, remove the new improvement and the forest and give production to the nearest city of the owner of the unit. Then you just have to figure out how to code (in Lua) the AI's use of the improvement!
 
Thanks for the advice! This helped a lot. In regards to the workers moving into other territory it was relatively easy to do once I knew where to look. I also checked out the archaeological dig option and found that I could set IgnoreOwnership to true and it allowed it for my unique unit. Similarly, I added another improvement and build option which allows the unit to remove forest in other territories using an improvement with the Build/BuildFeature to remove the forest. Unfortunately it looks like my production from the removal isn't working correctly. I increased <Production>20</Production> within the BuildFeature, but I don't see any change in my production if I chop in my territory or another civs. I modified my text so that I know I'm using the correct chop button and I can see that it changed the production output in the text too, but I'm not sure why it isn't affecting anything. Is there a way to assign production through the improvement versus the BuildFeature?

In regards to the Golden Age yields I'm thinking something similar to a pantheon, but only in golden ages. For example, additional culture from pastures, plantations like the pantheon beliefs. Would this be possible by making a dummy policy and then finding the pantheon belief code and adding to a policy? Is there an XML file for pantheon beliefs? Or would this just be simpler with a dummy building?
 
Unfortunately it looks like my production from the removal isn't working correctly. I increased <Production>20</Production> within the BuildFeature, but I don't see any change in my production if I chop in my territory or another civs.
I have no guesses. I would need to see the code to debug it.
Is there a way to assign production through the improvement versus the BuildFeature?
No. Not via standard database tables, anyway - not unless you count what whoward suggested, making the forest chopping technically be an improvement, and then using Lua to detect when the improvement is built so you can immediately delete it and give production to the nearest city.
Would this be possible by making a dummy policy and then finding the pantheon belief code and adding to a policy?
This is guaranteed to fail. The second you try to pass a column from <Beliefs> that doesn't exist in the <Policies> schema into a <Policies> row, the database will throw a "No such column" error to database.log and discard the entirety of the file the error was found in.

You can manually add a new column with the same name of course, but it won't do jack unless you implement the logic of what it should do in Lua, because the game has no way of simply guessing what the effect of a column should be based on its name alone. Computers are not human and they do not speak English.
Is there an XML file for pantheon beliefs?
Not for pantheon beliefs specifically. All vanilla beliefs are lumped together in the same file in Sid Meier's Civilization V\Assets\DLC\Expansion\Gameplay\XML\Religions\CIV5Beliefs.xml for G&K (Expansion2 for BNW).
Or would this just be simpler with a dummy building?
It would... but the database table needed to accomplish doesn't exist natively in the game. That is, the game doesn't have a table that makes buildings grant extra yields to improvements, as opposed to resources, terrains or features. LeeS provided a utility to span the gap, but it's a whole process to set it up correctly.
 
Top Bottom