Where to mod to enable razing capitals and city states ?

BloodyMaul

Chieftain
Joined
Sep 26, 2010
Messages
7
I'd like to be able to raze capitals and city states, it's for my own enjoyment of the game so it fits my playing style, I don't worry about it making it easier, I just want to be able to create cities on a perfect way so no square is lost...


Anyway, I couldn't find anything about raze in any of the xml files, the only thing I found is :

GlobalDefines.xml

<Row Name="PLAYER_ALWAYS_RAZES_CITIES">
<Value>0</Value>
</Row>

But I'm certain that this is not what I want, I also tried searching anything special about capitals but couldn't find anything, so if anyone knows where I change so I can raze those imperfectly placed cities in my map I'll be super grateful :)
 
I believe city-states can be razed once you've annexed them, but I'm not sure about capitals.

Capital possession is important for Domination victories, if I remember correctly, so it might not be wise to mod in the option to raze these critical cities if the game doesn't allow you by default.
 
I don't play for victory or anything like that, lol, I'm a pretty weird civ player I guess, anyway, I found the solution to my problem editing the lua files :

CityView.lua :

Just commented out the canraze test :
lines 1220 to 1228 :

--if (not pPlayer:CanRaze(pCity)) then
-- if (pPlayer:CanRaze(pCity, true)) then
-- Controls.RazeCityButton:SetHide(false);
-- Controls.RazeCityButton:SetDisabled(true);
-- Controls.RazeCityButton:SetToolTipString( Locale.ConvertTextKey( "TXT_KEY_CITYVIEW_RAZE_BUTTON_DISABLED_BECAUSE_CAPITAL_TT" ) );
-- else
-- Controls.RazeCityButton:SetHide(true);
-- end
--else


and line 1232 :
--end




Also on PuppetCityPopup.lua modified line 66 :
local bRaze = true;--activePlayer:CanRaze(newCity);


It did gave me the option to raze a city state, I'm gonna go back and see if it really razes it after the # of turns required, if it doesn't work I will post here again otherwise it works ;)


Edit: It didn't work, I have the option to raze the city but no mater how many times you click it, doesn't seem to stick with the command :( It's pretty much ignored...
 
I am interested in making the raze function available to all cities as well.

Considering in OCC (One City Challenge) it will raze capitals and City States automatically, it certainly isn't impossible...
 
Some more thinking. I checked ConfirmCityTaskPopup.lua and maybe this is the problem:

Code:
-- CONFIRM CITY TASK POPUP
-- This popup occurs when an action needs confirmation.

PopupLayouts[ButtonPopupTypes.BUTTONPOPUP_CONFIRM_CITY_TASK] = function(popupInfo)

	local iCityID	= popupInfo.Data1;
	local iTask	= popupInfo.Data2;
	
	if (iTask == TaskTypes.TASK_RAZE) then
		popupText = Locale.ConvertTextKey("TXT_KEY_POPUP_ARE_YOU_SURE_RAZE");
	else
		popupText = "NO TEXT HERE";
	end
	
	SetPopupText(popupText);
		
	-- Initialize 'yes' button.
	local OnYesClicked = function()
		
		-- Confirm action
		Network.SendDoTask(iCityID, iTask, -1, -1, false, false, false, false);
	end
	
	local buttonText = Locale.ConvertTextKey("TXT_KEY_POPUP_YES");
	AddButton(buttonText, OnYesClicked)
		
	-- Initialize 'no' button.
	local buttonText = Locale.ConvertTextKey("TXT_KEY_POPUP_NO");
	AddButton(buttonText, nil);

end

Since making the changes BloodyMaul suggested, clicking the now activated Raze City button gives this popup, but confirming it does nothing.

However, this line in this lua struck me as important:
Code:
		Network.SendDoTask(iCityID, iTask, -1, -1, false, false, false, false);

The question is, what exactly do the -1 and false refer to? The script does not tell. But I imagine setting some / one of the false to true might allow the razing to go through. Rationale being that it does not change into the Stop City Razing button but remains the Raze City button as if you had selected No instead of Yes.

So I did some digging on SendDoTask and found that is seems to have been carried over from Civ IV:
Code:
VOID sendDoTask (INT iCity, INT eTask, INT iData1, INT iData2, BOOL bOption, BOOL bAlt, BOOL bShift, BOOL bCtrl)
void (int iCity, int eTask, int iData1, int iData2, bool bOption, bool bAlt, bool bShift, bool bCtrl)

Which of course is not lua but python, but the number of ints and options seem to match up.

Any ideas?
 
I am interested in making the raze function available to all cities as well.

Considering in OCC (One City Challenge) it will raze capitals and City States automatically, it certainly isn't impossible...
i didnt know you could raze capitals and city states in OCC. i was going to say it must be hardcoded to keep the city states/capitals in, but i guess not
 
so anyone figure out what files need to be edited to in the srouce DLL and prehapes what lines ? need to be edited ?
 
Here's your mod:
Code:
GameEvents.CanRazeOverride.Add(function() return true end)
Well... Not quite. You have to do something with the Domination Victory since obviously that doesn't work anymore. I don't know if there are other pitfalls to worry about besides that.
 
Here's your mod:
Code:
GameEvents.CanRazeOverride.Add(function() return true end)
Well... Not quite. You have to do something with the Domination Victory since obviously that doesn't work anymore. I don't know if there are other pitfalls to worry about besides that.

-- oes that line of code just go into the CityView.lua file ?
 
-- oes that line of code just go into the CityView.lua file ?
That would be a strange place to put it, since that file controls UI. It would make more sense to add it in a Lua file dedicated to changing game rules. But in fact you could add it anywhere so do what you want.

Perhaps the mod referenced above does a better job though. I'm assuming it does something to make Domination victory work...
 
That would be a strange place to put it, since that file controls UI. It would make more sense to add it in a Lua file dedicated to changing game rules. But in fact you could add it anywhere so do what you want.

Perhaps the mod referenced above does a better job though. I'm assuming it does something to make Domination victory work...

so does all LUA code work in - always in any LUA even if its placed into a LUA file under

Sid Meier's Civilization V\Assets\DLC\Expansion2\Gameplay\Lua

I was under impression it code had to go into the coregameDLL files ?

and then toher question i had can someone just make a LUA file call it anything they want put it into the above folder and then put there code into it and game will just have it magically work ?
 
can someone just make a LUA file call it anything they want
Basically, yes, but you want to avoid Fireaxis file names unless you intend on replacing those files with your own.

put it into the above folder and then put there code into it and
No. You need to build a mod and activate it in-game.
Or, as said above, you could edit the file and put your code there, althought that is HIGHLY unadvisable.
How to create and build a mod? Follow this guide.

game will just have it magically work ?
"Any sufficiently advanced technology is indistinguishable from Magic." - Arthur C. Clarke. :)
But, no. It's not magic, sorry.
When you build your mod, you will tell the game what and how to load the file, so it can use the data correctly.
 
Basically, yes, but you want to avoid Fireaxis file names unless you intend on replacing those files with your own.


No. You need to build a mod and activate it in-game.
Or, as said above, you could edit the file and put your code there, althought that is HIGHLY unadvisable.
How to create and build a mod? Follow this guide.


"Any sufficiently advanced technology is indistinguishable from Magic." - Arthur C. Clarke. :)
But, no. It's not magic, sorry.
When you build your mod, you will tell the game what and how to load the file, so it can use the data correctly.


problem is mutiplayer - mods dont work in mutiplayer so u have to edit the files are in the folder directly just as if u are creating a patch.

for example if someone creats a gamecoredll file that allows u to burn all citys then if u copy it over there DLL in mutiplayer u get to burn all citys.

so for any mod to work in mutiplayer u have to edit the core game files.

not use the moding ability thats built into game.

only other way to get around this is to some how many ur game think ur mod is a DLC and show up in the DLC list.

and I am not sure how to get game to think a MOD is a DLC if it droped into the DLC folder ?
 
Well, sure, but I didn't know your intention was to make a Multiplayer mod. :p

But no, you're not correct when you say 'so for any mod to work in mutiplayer u have to edit the core game files.'
There are a few workarounds for Multiplayer mods; one of them, like you mentioned, is pretending it is some kind of expansion. There is a UI mod from bc1 [edit]right[/edit] here in the forums where he uses this method. It is good to remember, though, that he doesn't create any new rules with his mod, only graphical changes; if using his method is only useful for interface changes or not, I don't know.
 
Well, sure, but I didn't know your intention was to make a Multiplayer mod. :p

But no, you're not correct when you say 'so for any mod to work in mutiplayer u have to edit the core game files.'
There are a few workarounds for Multiplayer mods; one of them, like you mentioned, is pretending it is some kind of expansion. There is a UI mod from bc1 [edit]right[/edit] here in the forums where he uses this method. It is good to remember, though, that he doesn't create any new rules with his mod, only graphical changes; if using his method is only useful for interface changes or not, I don't know.

my head hurts lol

there mod called raze all citys on workshop its coded into a DLL file then there that mod that makes Multiplayer AI Diplomatic work like it does in single player.

what i was hopping to do was figure out how to do the raze thing my self and then use the DLL file or figure out way to merg the two mods into one. DLL
 
Replacing the DLL is one of the workarounds, but I have no knowledge of C++ to advise you on this front, sorry. :\

thanks :)

iv been playing around with the core files little.

anyways back to this thing.

GameEvents.CanRazeOverride.Add(function() return true end)

so i decide to put it into cityview i guess lua file

I added it to the top of the file, but it does not seem to do anything, I thought it could be placed anywhere in any LUA ?

-------------------------------------------------
-- Addon
-------------------------------------------------
GameEvents.CanRazeOverride.Add(function() return true end)

-------------------------------------------------
-- Game View
-------------------------------------------------
include( "IconSupport" );
include( "InstanceManager" );
include( "SupportFunctions" );
include( "TutorialPopupScreen" );
include( "InfoTooltipInclude" );
 
-------------------------------------------
-- Raze City Button (Occupied Cities only)
-------------------------------------------

if (not pCity:IsOccupied() or pCity:IsRazing()) then
g_bRazeButtonDisabled = true;
Controls.RazeCityButton:SetHide(true);
else
g_bRazeButtonDisabled = false;
Controls.RazeCityButton:SetHide(false);
Controls.RazeCityButton:SetDisabled(false);
Controls.RazeCityButton:SetToolTipString( Locale.ConvertTextKey( "TXT_KEY_CITYVIEW_RAZE_BUTTON_TT" ) );
GameEvents.CanRazeOverride.Add(function() return true end)

function OnPlayerCanRaze(iPlayer, iCity)
print(string.format("OnPlayerCanRaze(%d, %d)", iPlayer, iCity))
local pCity = Players[iPlayer]:GetCityByID(iCity)

-- Permit any city originally built by a major civ to be razed (ie anything but original CS capitals)
return (pCity:GetOriginalOwner() < GameDefines.MAX_MAJOR_CIVS)
end
GameEvents.PlayerCanRaze.Add(OnPlayerCanRaze)

end

-- Stop city razing
if (pCity:IsRazing()) then
g_bRazeButtonDisabled = false;
Controls.UnrazeCityButton:SetHide(false);
else
g_bRazeButtonDisabled = true;
Controls.UnrazeCityButton:SetHide(true);
end

-- UpdateSpecialists(pCity);


no luck so seems like city view LUA dosnt work for city raze button control ? unless there is something wrong with the code i put in it ?
 
Top Bottom