Anyway to ID a captured city that was previously a City State with a Requirement?

isau

Deity
Joined
Jan 15, 2007
Messages
3,071
I've been stuck on this one a while. The ability I want modded Germany to have is this:
  • Receive x15 your current Gold per turn as an immediate payout when you conquer a City State

Problem: can't figure out how to ID a city state. Because of this the current implementation in my mod just gives the award to any city capture:

upload_2017-10-20_20-55-18.png


Fix attempts have included:
  • Checking for a Palace doesn't work--seems it's deleted prior to the check
  • Trying to add a new building with code that only City States have to use as a flag also doesn't work, because the building is removed when the city is conquered due to conqueror not having correct traits.

Here's existing code below. Ideally there would be a Requirement of some kind I could plug into a RequirementSet and apply to QUO_GERMANY_CITY_CAPTURE_PLAYER to limit which cities this triggers on, but I can't figure out a way to do it.


Code:
INSERT INTO Modifiers
    (ModifierId, ModifierType, RunOnce, Permanent, OwnerRequirementSetId, SubjectRequirementSetId)
VALUES    ('QUO_GERMANY_CITY_CAPTURE', 'MODIFIER_PLAYER_GRANT_YIELD_BASED_ON_CURRENT_YIELD_RATE', 1, 1, NULL, NULL) ,
        ('QUO_GERMANY_CITY_CAPTURE_PLAYER', 'MODIFIER_PLAYER_CAPTURED_CITY_ATTACH_MODIFIER', 0, 0, NULL, NULL) ;

        
INSERT INTO ModifierArguments
    (ModifierId,             Name,         Type,             Value,             Extra,     SecondExtra)
VALUES    ('QUO_GERMANY_CITY_CAPTURE',     'Multiplier',     'ARGTYPE_IDENTITY',     '5',            NULL,     NULL) ,
        ('QUO_GERMANY_CITY_CAPTURE',     'YieldToBaseOn',     'ARGTYPE_IDENTITY',     'YIELD_GOLD',            NULL,     NULL) ,
        ('QUO_GERMANY_CITY_CAPTURE',     'YieldToGrant',     'ARGTYPE_IDENTITY',     'YIELD_GOLD',            NULL,     NULL) ,
        ('QUO_GERMANY_CITY_CAPTURE_PLAYER',     'ModifierId',     'ARGTYPE_IDENTITY',     'QUO_GERMANY_CITY_CAPTURE',            NULL,     NULL) ;

        
INSERT INTO TraitModifiers
    (TraitType,             ModifierID)
VALUES    ('TRAIT_LEADER_HOLY_ROMAN_EMPEROR',    'QUO_GERMANY_CITY_CAPTURE_PLAYER') ;


Is it possible? I really dont want to resort to Lua for this (mainly because I hate Lua :D ).
 
City States are referenced as Minor Civs. RequirementID "REQUIRES_PLAYER_IS_MINOR_CIV". There should be a way to create a RequirementSetId with that ID that specifies the target city is a Minor Civ.
 
City States are referenced as Minor Civs. RequirementID "REQUIRES_PLAYER_IS_MINOR_CIV". There should be a way to create a RequirementSetId with that ID that specifies the target city is a Minor Civ.


Unfortunately that tag is lost the moment the city is captured, and the city is no longer owned by a minor by the time the game gets around to checking. Same issue with checking for the existence of a Palace. The building and any city states tags are gone and any Requirements seem to refer to the new owner, ignoring the old.

A workaround I had tried was giving City States an inherent Modifier that provides a free unique building in their capitals, then checking for the existence of that Building. It almost worked, the only problem with that is in order to keep players from building said building I had to give it a RequiredTrait of NULL and set the Religion field to 1. But when religion is set, the Modifier that gives the free building doesn't work. :(
 
I think your only real option here is lua

lua allows you to directly check for a city's original owner
Code:
local iOriginalOwner = pCity:GetOriginalOwner()
Variable iOriginalOwner will be holding the player ID# from the lua "Players" table. Then you can simply do as like this
Code:
local bOriginalOwnerWasCityState = (Players[iOriginalOwner]:IsMajor() == false)
If this second boolean variable bOriginalOwnerWasCityState is true you know you have a city that was originally owned by a City-State, and you can proceed from there. You can also do additional sorting within your code for whether the player the city was captured from is the same as the player that originally owned the city.
 
Last edited:
I think your only real option here is lua

lua allows you to directly check for a city's original owner
Code:
local iOriginalOwner = pCity:GetOriginalOwner()
Variable iOriginalOwner will be holding the player ID# from the lua "Players" table. Then you can simply do as like this
Code:
local bOriginalOwnerWasCityState = (Players[iOriginalOwner]:IsMajor() == false)
If this second boolean variable bOriginalOwnerWasCityState is true you know you have a city that was originally owned by a City-State, and you can proceed from there. You can also do additional sorting within your code for whether the player the city was captured from is the same as the player that originally owned the city.


Thanks I may try this method. I generally favor using SQL instead of Lua, mainly because debugging Lua is such a pain, but there are some things that SQL just can't do.
 
I tried to do a very similar thing with Germany, and the only thing I could find was a Requirement Type that checked if the city was an original capital. Unfortunately, this will also work for old capitals of major civs, and I can't find any way to stop that.

Lua will allow you to do exactly what you're looking for, though. I have an ability like that for the Aztecs.
 
Back
Top Bottom