[GS] How to use CityManager.RequestCommand

BPZ1941

Chieftain
Joined
Mar 17, 2023
Messages
1
So essentially what I'm trying to do is create a script that liberates a dead civilization from Free Cities. After some trial and error I did manage to get CityManager.TransferCity to work, but everything about it would be very bugged out.
So I figured I could rip the code from the panel for liberating a captured city and use it in the UI context, but it doesn't seem to be working.

Code:
function SpawnNewCiviliationFromCity(playerID, cityID)
    local iLocalPlayer = Game.GetLocalPlayer();
    local pLocalPlayer = Players[iLocalPlayer];
    
    local pCity = pLocalPlayer:GetCities():FindID(cityID);
    local tParameters = {};
    tParameters[UnitOperationTypes.PARAM_FLAGS] = CityDestroyDirectives.LIBERATE_PREVIOUS_OWNER;
    CityManager.RequestCommand(pCity, CityCommandTypes.DESTROY, tParameters);
end

The above code runs without error, but doesn't actually do anything. Now the way I've tried to do this (for now) is to transfer every city to myself (the human player) and run it from there, so pLocalPlayer is in fact the owner every time. What am I missing to actually liberate the cities?
 
Top Bottom