Need help with giving cities ownership to another Civ

IsaacReign

Chieftain
Joined
May 3, 2016
Messages
5
So im a complete noob when it comes to modding. I have a WB Map & Scenario I made and i read somewhere that I could use Lua scripts to modify my scenario so that certain cities and city-states belong to another civ at the start of the game. If this is truly possible how would i go about doing it.
 
Moderator Action: Welcome to Civfanatics! The Modding Tutorials and Reference sub-forum is for completed tutorials and reference guides only, so I've moved your query to the SDK/Lua sub-forum, where it should go. For the record, any queries not related to lua or the SDK go in the main Creation and Customisation forum.
 
This works for me... but note that the city in question is first founded in lua code before the part that transfers the city.

Perhaps the cities in question have not yet been founded during the initiation? Or your code is in the wrong order.

Code:
--found Wessex Cities

function  FoundWessex()

	if Game.GetElapsedGameTurns() == 0 then

	-- Set up Wessex Player

		for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do 

		local pWessex = Players[iPlayer]

			if (GameInfo.Civilizations.CIVILIZATION_ENGLAND.ID == pWessex:GetCivilizationType()) then
	
			pWessex:Found(31, 27) -- Winchester
			pWessex:Found(29, 24)
			--print (pWessex:GetName() ,"...is founding cities");

			end
		end
	end
end

Events.SequenceGameInitComplete.Add(FoundWessex)


--Transfer cities to Winchester from Wessex

function  FoundWessexWinchester()

local plotWinchester = Map.GetPlot(31, 27);
local Winchester = plotWinchester:GetPlotCity();
local pWinchester

	if Game.GetElapsedGameTurns() == 0 then

		for iPlayer=GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_CIV_PLAYERS-1, 1 do 

			local pWinchester = Players[iPlayer]

			if pWinchester:IsEverAlive() and (GameInfo.MinorCivilizations.MINOR_CIV_WINCHESTER.ID == pWinchester:GetMinorCivType()) then	
			
				-- Enumerate cities
			
				if Winchester ~= nil then
			
				print("Transferring...", Winchester:GetName(), "from Wessex to" , pWinchester:GetName() )
						
				pWinchester:AcquireCity(Winchester, false, true)

				end				
			end
		end
	end
end

Events.SequenceGameInitComplete.Add(FoundWessexWinchester)
 
So your saying i have to code in all the cities even though i placed them all in the World Builder
 
Top Bottom