Identifying Builders

Flying Pig

Utrinque Paratus
Retired Moderator
Joined
Jan 24, 2009
Messages
15,651
Location
Perfidious Albion
In the def onImprovementBuilt part of CvEventmanager.py, is it possible to make the game identify the unit that built the improvement?
 
This is just a guess on my part, but could you could try this...

Get the plot using iX and iY, then cycle thru the units on the plot and get the value for unit.getBuildType(). Use this value along with iImprovements to decide if this is the unit you want. There would be a problem if the game resets the unit's BuildType status before onImprovementBuilt is called, but hopfully that doesn't happen.
 
I have previously implemented this suggestion and it works, sort of. The problem is there may be several units in the plot capable of building the improvement, and some of them may or may not be actually building. In my case, in Dune Wars, I have added a "slave" unit which can build any improvement twice as fast, but it is killed at the end of the project. So my code in onImprovementBuilt finds any slaves on the plot and kills them.

There are two problems. (a) the slave may have been just passing through. (b) A player pointed out an exploit: have 2 slaves and one worker build the improvement until it is one turn away from complete; then move the slaves off the plot. When the worker finishes the improvement by himself, no slaves get killed.

Although the exploit bothers me a little, the effect is close enough for me, and I left it this way. I could imagine an sdk change which would pass along the pUnit of one unit who completed it. But it should really be a list, and it would be extremely hard to record all units who had contributed to building it in the past.
 
In the def onImprovementBuilt part of CvEventmanager.py, is it possible to make the game identify the unit that built the improvement?

You should be able to in the SDK, but I don't know any way with python.:sad:
 
I have previously implemented this suggestion and it works, sort of. The problem is there may be several units in the plot capable of building the improvement, and some of them may or may not be actually building.

If unit.getBuildType() is used to check what each unit is building, shouldn't that eliminate this problem? Or does getBuildType do something other that indicate what the unit is currently building?
 
Top Bottom