[Lua] Getting Every Previous Owner of City?

Irkalla

ENTP POWWWEEEEEER
Joined
Sep 25, 2012
Messages
1,009
Location
Way down around Vicksburg
Looking for a way to get a table containing all the previous owners of any given city. Is there a method for this, or will I have to write my own?

Also looking for Player Has Ever Owned City, stuff like that. I need to go further back than Previous Owner, and Original Owner isn't going to cut it either.
 
The C++ object only stores current and original owner, so if you want all other previous owners you'll need to remember them in Lua
 
The C++ object only stores current and original owner, so if you want all other previous owners you'll need to remember them in Lua

I think it's something you and I can handle... but we're looking at a clash of balance vs. convenience here.

I'm giving out golden age progress on city captures. 5 per pop on normal cities, 10 per pop on capitals.

Do you think it would be worth the trouble to check to see if the player has ever owned the city before to prevent him from city-swapping to exploit the UA? On one hand, the fact that a city's pop is reduced by half on capture should dissuade anyone from abusing the UA. That and golden age threshold increases... But on the other hand, say we have a size 40 capital being swapped between the player and the original owner... that's 400 GAP, then 100 GAP, then 30 GAP, then 10 GAP that and every successive capture. That's 540 GAP compared to 400 GAP a player unable to abuse would get. An additional 140 GAP.

Again on the other hand, that 140 GAP comes with a price tag of 20 GAT. So we're looking at a Net of 120 GAP. Then there's the fact that the player just threw away a size 20 city.

On the other hand, yet again, the player may have planned to raze it in the first place, unable to support its population with happiness.
 
Rather than keeping track of every owner of a city, you could make the bonus only be provided the first time the civilization captures a specific city. Then you just have to keep track of a single boolean per city (if the city has provided the golden age points yet).
 
It should be simple enough to do in LUA provided you save your data to the savegame file. I do something similar with population. The caveat being that you don't have data before the mod starts running, so it's best to use it at the beginning.

Here's the events that you'll want: SerialEventCityCreated and SerialEventCityCaptured. Build a table indexed by plot with arrays of owners. You might want to also capture the event when a city is totally destroyed and remove that plot from your list.

(I didn't read the whole thread, so apologies if this was already resolved.)
 
It should be simple enough to do in LUA provided you save your data to the savegame file. I do something similar with population. The caveat being that you don't have data before the mod starts running, so it's best to use it at the beginning.

Here's the events that you'll want: SerialEventCityCreated and SerialEventCityCaptured. Build a table indexed by plot with arrays of owners. You might want to also capture the event when a city is totally destroyed and remove that plot from your list.

(I didn't read the whole thread, so apologies if this was already resolved.)

Don't Serial events only fire if the active player sees it happen?
 
Don't Serial events only fire if the active player sees it happen?
That's what I've read, but it isn't my experience. I see population changes happen all over the undiscovered "world" with SerialEventCityPopulationChanged. Here's an example from me catching and printing that event from a fresh game:
Code:
 Motiles: Karakorum (owned by Genghis Khan) population 1 (+1)
 Motiles: London (owned by Elizabeth) population 1 (+1)
 Motiles: Edinburgh (owned by Boudicca) population 1 (+1)
 Motiles: Cape Town (owned by Cape Town) population 1 (+1)
 Motiles: Venice (owned by Venice) population 1 (+1)
 Motiles: Geneva (owned by Geneva) population 1 (+1)
 Motiles: Mombasa (owned by Mombasa) population 1 (+1)
 Motiles: Brussels (owned by Brussels) population 1 (+1)
 Motiles: Lisbon (owned by Lisbon) population 1 (+1)
 Motiles: Singapore (owned by Singapore) population 1 (+1)
Maybe YMMV with each specific event?
 
Back
Top Bottom