Actually, as you can see in this event:
Code:
|
// when a city is captured, store old owner
HandleEvent(CaptureCity) 'LOQ_BarbCaptureCityPre' pre {
LOQ_capturedCity = city[0];
LOQ_oldCityOwner = city[0].owner;
} |
the owner is stored PRE, so before a city is captured. I used the same code to store the old owner of a captured city for the Militia code of the MedMod (and Cradle and Alex and whatever) and it works just fine there. Executing the code on my system, like I said before, also works perfectly. Perhaps you forgot to #include the file or something silly like that (happens to the best of us)? In any case, you can check if the code is actually being executed by putting in an addition messagebox somewhere with "Message(1, 'GotHere') and make a messagebox that displays a simple text message ("Got Here"

). If this doesn't work in the game, the code obviously isn't being executed at all, otherwise you have a very weird problem
I'm afraid I didn't get around to looking into the GetNearestCity function (I'll try again tonight but no promises) but I seem to vaguely remember it being bugged. If that is the case, you could try cycling to all cities of all players and store the city with the smallest distance to the location you need. Something roughly like this:
Code:
|
nearest = 9999999999; // rediculously large number
for (i = 0; i < 32; i++) {
player[0] = i;
for (j = 0; j < player[0].cities; j = j + 1) {
GetCityByIndex(i, j, tmpCity);
if (SquaredDistance(currentLoc, tmpCity.location) < nearest) {
nearest = SquaredDistance(currentLoc, tmpCity.location);
nearestCity = tmpCity;
}
}
} |
PS I use SquaredDistance instead of Distance because it's (slightly) faster (obviously, since Pythagoras is used to calculate distance).