Establishing who built the improvement

Mercury314

Chieftain
Joined
Sep 6, 2007
Messages
43
I was hoping someone could provide me with some insight.

I am currently using the onImprovementBuilt function from the CustomEventManager.

Here, I want to trigger an event at the moment an improvement is built.

Now triggering the event itself is not a problem, however, the onImprovementBuilt function offers no way of establishing the player (or unit and through that the player) responsible for building the improvement (which is information I need).

All it provides me with is the type of improvement and its location.

I thought about checking for a worker unit on the location, but this isn't foolproof because other players may place a worker at the same location. I also thought of checking to see who's turn it is, but because turns take place simultaneously this also doesn't allow me to determine the correct player.

Does anyone have an idea how I can establish the player who actually built the improvement? I would much appreciate the help (and I'll mention you in my mod's credits too ^_^)
 
I thought of that, yes. Unfortunately for my purposes, the improvement would not always be built inside your own cultural borders :(

I'm currently researching if it isn't possible to do this using the scripts called when the building process is started instead of when it is finished, but thats not ideal of course.
 
If you are using BtS then it is possible. Use onUnitBuildImprovement which is called when a unit begins building an improvement. In onUnitBuildImprovement you will have to mark the unit somehow to know it is building your improvement.

Then in onImprovementBuilt you run a loop through all the units on the new improvements tile and find if there are any marked workers on the tile. If there is 1 or more marked workers do your new code.

I use this method to put cultureal borders around forts when they are built and it works like a dream. :)
 
Thanks, I found this to work flawlessly. Jeckel, you won a mention in my mod credits ^_^
 
Top Bottom