Force CS to not raze a city it takes over

hellagrant

Chieftain
Joined
Mar 28, 2010
Messages
57
I got In Game Editor mod running so I can change most things. What can I do if anything to force a CS to keep a city instead of razing it after it takes it over?

I thought changing the target city to capital would work, but it didn't. Any thing else I can do? Maybe add buildings, population, etc

I am actually not sure how the AI decides to keep a city or raze it(I am talking about a city state, not a regular civ)
 
I am actually not sure how the AI decides to keep a city or raze it(I am talking about a city state, not a regular civ)

If keeping the captured city as a puppet would take the AI (major or minor) into negative total happiness the AI will raze the city. Most of the time the City States are running close to zero happiness so that's almost always the case. If you want to change the logic, you need to mod the DLL.

However, once the CS has started to raze the city you should be able to use Lua to reverse the decision.

I don't know which Lua method to use, but this is what I would do to find out.
1) Using FireTuner, set up a test and capture a city, raze it, now find the "unraze" button and note the exact text on it
2) Search all the Civ5*.xml files for that text to identify the associated TXT_KEY_
3) Search all the UI *.xml files to find that TXT_KEY_, to give the ID of the button (control)
4) Search the associated UI Lua file for that control ID to discover what happens when the button is clicked.
5) using the button click code as a guide, write my own function to unraze cities captured by city states

HTH

W
 
Code:
city:DoTask(TaskTypes.TASK_UNRAZE, -1, -1, -1)
 
The following in lua will halt city razing by city states, no matter what the happiness state.

Code:
-- minor civs cannot raze captured cities

function UnrazeCity(oldPlayerID, bCapital, iX, iY, iPlayer, bConquest)

local oldPlayer = Players[oldPlayerID]; --not needed
local plot = Map.GetPlot(iX, iY);
local pCity = plot:GetPlotCity();
local iPlayer = plot:GetOwner()
local pPlayer = Players[iPlayer]

Player = pPlayer


	if pPlayer:IsEverAlive() and Player:IsMinorCiv() then 
			
		-- City exists and is being razed?
    	if pCity ~= nil and pCity:IsRazing() then 
		pCity:DoTask(TaskTypes.TASK_UNRAZE);
				
			return pCity							
    	end
	end
end

GameEvents.CityCaptureComplete.Add(UnrazeCity)
 
Top Bottom