Trigger function before city capture

Nefliqus

Prince
Joined
Sep 16, 2010
Messages
400
Location
Poland
Task description:
I want to create new civ with UA that will let to save cultural building in captured city.

Problem description:
I want to create list of cultural building in the city before capturing. In this why I will be able to add it later. The problem is how to trigger function just before capturing. I think that I can monitor all move or attack of this civ units but maybe there is some better solution.

Question:
1) How to trigger function before city capturing?
2) Do you know other method to save building in the city captured by given civ?
3) What is name of function that decide to destroy or not to destroy building in captured city? I think that it is core game function but I could be mistaken.
4) Do you have any example of use RunCombatSim event?

EDIT:
I just have found this info:
I would use Events.SerialEventCityCaptured, which passes: hexPos, playerID, cityID, and newPlayerID.

You can see an example of it in action in CivsAlive.lua in the Mongol Scenario.
I'm not sure if this fires when the capture isn't observed by the player tho, unfortunately some SerialEvents don't.

GameEvents.CityCaptureComplete
http://forums.civfanatics.com/archive/index.php/t-452749.html

I think that i can use it. Maybe this even is triggered before building destroying
 
Please report back what you learn. I always want to know which of these Events work when not seen by human (no way to know unless someone tests it) and timing issues.

One issue about timing: Results are not always consistent for specific Events. I think this is because they are supposed to be for animations/graphics (which could be delayed by some other running animation) and not really game rule effects (even though we modders use them this way). The GameEvent should not have this problem, although I'd guess that it is too late for your need.

SciprtData is maybe another possibility: you could store all buildings there each turn. Strangely, the wiki lists SetScriptData under city object but not GetScriptData (I have not tested to see if these exist and work). But plot:SetScriptData and plot:GetScriptData work fine and there is only one unique plot for each city.
 
Yes, please report your results.

I used RunCombatSim event in conjunction with unit:GetLastMissionPlot() to check if a city was about to be captured but it doesn't work anymore since the last patch

my guess is that with the new animation system, the result of the combat is calculated and applied before the actual animation start and RunCombatSim is called and unit:GetLastMissionPlot() does non longer return the plot the unit is going to attack, but the one it's on.
 
Yes, please report your results.

I used RunCombatSim event in conjunction with unit:GetLastMissionPlot() to check if a city was about to be captured but it doesn't work anymore since the last patch

my guess is that with the new animation system, the result of the combat is calculated and applied before the actual animation start and RunCombatSim is called and unit:GetLastMissionPlot() does non longer return the plot the unit is going to attack, but the one it's on.

But why didn't you use Events.SerialEventCityCaptured which passes: hexPos, playerID, cityID, and newPlayerID? Did you have any problem with this event?
The easiest solution for me is to add building list to city scriptdata or cityplot and check it after GameEvents.CityCaptureComplete. I can also build table with such information but it will need to run all cities loop every turn. It could add some additional turn time and I don't want to do it.
I plan to wait for GAK with all test.
 
Events.SerialEventCityCaptured is called after the city has been captured. I need an event before.
 
Top Bottom