Lua snippets

This gives the player's capital free walls.

Code:
function CapitalWallsTurnStart ()
	for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do
		local player=Players [iPlayer];
		if (player:IsAlive ()) then
			local pCity = player:GetCapitalCity()
			if pCity then
				pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_WALLS"], 1);
			end
		end
	end
end

Events.ActivePlayerTurnStart.Add (CapitalWallsTurnStart);
 
Subscribing - Anything further here that might help us newer modders even if you consider it too 'simple'?
 
This code spawns a minor civilization units in 1/2 their cities. Just delete /2 if you want one in every city of a minor civ. The event will happen one time, in 550. It will spawn units based upon the tech level. They spawn with promotions in this example. I recommend that they also spawn with the embarked status (isembarked I think) as they will not spawn if no space is available.

whoward provided the code for saving the data so the function only happens once. This can be adapted to many other functions as well, but I found it necessary when using the year as the event timing mechanism... it is not needed if you use gameturn = ?


Code:
local modData = Modding.OpenSaveData()
local modSussexKey = "SussexHaveSpawned"
local haveSpawnedSussex = (modData.GetValue(modSussexKey) == 1)

function SpawnSussex()

if (haveSpawnedSussex == false) then

if (Game.GetGameTurnYear() >= 550) then

    -- Set up Sussex Player

     haveSpawnedSussex = true
	 modData.SetValue(modSussexKey, 1)

	 -- find Sussex

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

	local pSussex = Players[iPlayer]

		if (GameInfo.MinorCivilizations.MINOR_CIV_SUSSEX.ID == pSussex:GetMinorCivType()) then
	
		Sussex = pSussex
		SussexTeamID = Sussex:GetTeam();
		SussexTeam= Teams[ Sussex:GetTeam() ]

			-- Enumerate cities
			local cityCount = -1
				
			for pCity in Sussex:Cities() do
   
			cityCount = cityCount + 1
										
				if cityCount < (Sussex:GetNumCities()/2) then
										
				local pPlot = pCity:GetCityIndexPlot();
				local Spawnunit;
				local iSpawnX = pPlot:GetX();
				local iSpawnY = pPlot:GetY();

					if (SussexTeam:GetTeamTechs():HasTech( GameInfoTypes["TECH_STEEL"] )) then

					Spawnunit = Sussex:InitUnit(GameInfoTypes["UNIT_LONGSWORDSMAN"], iSpawnX, iSpawnY, UNITAI_ATTACK, DIRECTION_NORTHWEST );
					Spawnunit:Promote(GameInfoTypes["PROMOTION_SIEGE"]);
					Spawnunit:Promote(GameInfoTypes["PROMOTION_SHOCK_1"]);
					print (pCity:GetName() ,"...is spawning Longswordsman... ");

					else

					Spawnunit = Sussex:InitUnit(GameInfoTypes["UNIT_SWORDSMAN"], iSpawnX, iSpawnY, UNITAI_ATTACK, DIRECTION_NORTHWEST );
					Spawnunit:Promote(GameInfoTypes["PROMOTION_SIEGE"]);
					Spawnunit:Promote(GameInfoTypes["PROMOTION_SHOCK_1"]);
					print (pCity:GetName() ,"...is spawning Swordsman... ");

					end
				end
			end
		end
	end
end
end
end

Events.ActivePlayerTurnEnd.Add(SpawnSussex)

This is a similar code for horseman:

Code:
local modData = Modding.OpenSaveData()
local modFranksEKey = "FranksEHaveSpawned"
local haveSpawnedFranksE = (modData.GetValue(modFranksEKey) == 1)

function SpawnFranksE()

if (haveSpawnedFranksE == false) then

if (Game.GetGameTurnYear() >= 950) then

    -- Set up FranksE Player

     haveSpawnedFranksE = true
	 modData.SetValue(modFranksEKey, 1)

	 -- find FranksE

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

	local pFranksE = Players[iPlayer]

		if (GameInfo.MinorCivilizations.MINOR_CIV_FRANKS.ID == pFranksE:GetMinorCivType()) then
	
		FranksE = pFranksE
		FranksETeamID = FranksE:GetTeam();
		FranksETeam= Teams[ FranksE:GetTeam() ]

			-- Enumerate cities
			local cityCount = -1
				
			for pCity in FranksE:Cities() do
   
			cityCount = cityCount + 1
										
				if cityCount < (FranksE:GetNumCities()/3) then
										
				local pPlot = pCity:GetCityIndexPlot();
				local Spawnunit;
				local iSpawnX = pPlot:GetX();
				local iSpawnY = pPlot:GetY();

					if (FranksETeam:GetTeamTechs():HasTech( GameInfoTypes["TECH_CHIVALRY"] )) then

					Spawnunit = FranksE:InitUnit(GameInfoTypes["UNIT_KNIGHT"], iSpawnX, iSpawnY, UNITAI_ATTACK, DIRECTION_NORTHWEST );
					print (pCity:GetName() ,"...is spawning Knight... ");

					else

					Spawnunit = FranksE:InitUnit(GameInfoTypes["UNIT_HORSEMAN"], iSpawnX, iSpawnY, UNITAI_ATTACK, DIRECTION_NORTHWEST );
					print (pCity:GetName() ,"...is spawning Horseman... ");

					end
				end
			end
		end
	end
end
end
end

Events.ActivePlayerTurnEnd.Add(SpawnFranksE)

The above work really well with Gedemon's citystate UU code as the spawned units will be converted to the units set up by his code. For example, I modified his code to make city state swordsman into Saxon Ceorls... when the above code spawns swordsman units, they appear as Saxon Ceorls. If player is not defined as above, all minor civs will spawn units, but the neat thing is that using Gedemon's code, the swordsman unit will spawn as the unit dictated in Gedemon's code. Chevalier for the Franks, but Thegn for the Anglo-Saxons, for example.
 
Untested but will probably work. Gives embarked graphics for longship to viking type civs. Forgot who gave me the hint on how to do this.

Code:
-- this will give longboat graphics to Viking civilizations for embarkation.

function  PlayerEmbark()

	for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do 

	local pPlayer = Players[iPlayer]

		if (GameInfo.Civilizations.CIVILIZATION_SONGHAI.ID == pPlayer:GetCivilizationType()) then
		pPlayer:SetEmbarkedGraphicOverride("ART_DEF_UNIT_U_DANISH_LONGBOAT")

		elseif (GameInfo.Civilizations.CIVILIZATION_INDIA.ID == pPlayer:GetCivilizationType()) then
		pPlayer:SetEmbarkedGraphicOverride("ART_DEF_UNIT_U_DANISH_LONGBOAT")

		elseif (GameInfo.Civilizations.CIVILIZATION_SWEDEN.ID == pPlayer:GetCivilizationType()) then
		pPlayer:SetEmbarkedGraphicOverride("ART_DEF_UNIT_U_DANISH_LONGBOAT")

		end	
	end
end
 
Recreating the Carthaginian harbor trait because I could not get it to work for other civs. Adds free harbor to all of a civs cities.... could be adjusted to make any building free as a trait or otherwise.

Code:
function HladirTraitBuilding()

	for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do 

	local pHladir = Players[iPlayer]

		if (GameInfo.Civilizations.CIVILIZATION_SONGHAI.ID == pHladir:GetCivilizationType()) then

		Hladir = pHladir

			if (Hladir:IsAlive ()) then

				for pCity in Hladir:Cities() do

				local pPlot = pCity:Plot();

					if pPlot:IsCoastalLand() then
					pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_HARBOR"], 1);
					end	
				end
			end
		end
	end
end

Events.ActivePlayerTurnStart.Add (HladirTraitBuilding);
 
This code forces Declaration of Friendship until a certain year. I use this when I don't want my civs too combative at the beginning. For example, in my mod, I have Charlemagne's empire divided into 3 (HRE/France/Normandy) and the DoF agreements exist until the historical division of his empire into 3 parts.

The code does not necessarily stop wars altogether, however, when combined with the diplomacy code at the beginning of this thread, mitigates them quite a bit.

Code:
--At the end of the first turn, the HRE declare friendship with the Frisia.  We want PlayerIDs.
	
function  HREFrisiaDOF()

local HRE
local Frisia
local iFrisia
local iHRE
local HRETeam
local HRETeamID
local FrisiaTeam
local FrisiaTeamID

if Game.GetGameTurnYear() <= 650 then

--Set up HRE

	for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do 

	local pHRE = Players[iPlayer]

		if (GameInfo.Civilizations.CIVILIZATION_PERSIA.ID == pHRE:GetCivilizationType()) then
	
		HRE = pHRE
		iHRE = iPlayer
		HRETeamID = HRE:GetTeam();
		HRETeam= Teams[ HRE:GetTeam() ]
		end	
	end

--Set up Frisia

	for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do

	local pFrisia = Players[iPlayer]

   		if (GameInfo.Civilizations.CIVILIZATION_NETHERLANDS.ID == pFrisia:GetCivilizationType()) then
	
		Frisia = pFrisia
		iFrisia = iPlayer
		FrisiaTeamID = Frisia:GetTeam();
		FrisiaTeam= Teams[ Frisia:GetTeam() ]	
		end
	end

--Set DoF

	if(HRE:IsAlive() and Frisia:IsAlive() and not HRE:IsDoF(iFrisia) and not HRETeam:IsAtWar(FrisiaTeamID) ) then
	HRE:DoForceDoF( iFrisia );

	end

--Check DoF

	if (HRE:IsDoF(iFrisia)) then
	print("HRE are friends with Frisia");
	end

end
end

Events.ActivePlayerTurnEnd.Add(HREFrisiaDOF)
 
Thank you so much, this is great.

Do you perchance have a code for giving a promotion (any) to a unit just built? also how do you detect if a unit is/has just fought irrespective of the outcome so a "blooded" type promotion maybe auto-conferred?
 
Likely some game event can be used as a trigger. I've not explored those aspects... but for the latter, perhaps this trigger in events:

EndCombatSim(PlayerID attackingPlayer, UnitID attackingUnit, int attackingUnitDamage, int attackingUnitFinalDamage, int attackingUnitMaxHitPoints, PlayerID defendingPlayer, UnitID defendingUnit, int defendingUnitDamage, int defendingUnitFinalDamage, int defendingUnitMaxHitPoints)

But I really can't say for certain.
 
This will prevent, in most cases, city states from razing captured cities. I have noticed if the population is 1 and there is not enough growth, cities may raze anyhow... this may be because the function fires at turn end.

Code:
-- for minor civs, loop through the players
-- for each player loop through their cities
-- check to see if each city is being razed... if so, unraze the city.

function UnrazeCity()

for iPlayer=GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_CIV_PLAYERS-1, 1 do
	local pPlayer = Players[iPlayer];
	if pPlayer:IsEverAlive() then 
			
		-- Enumerate cities
		
		for pCity in pPlayer:Cities() do

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

Events.ActivePlayerTurnEnd.Add(UnrazeCity);
 
I am really confused and new to modding and stuff welllll I used used your religion codes and I changed the names of the religions and added city names to where I was suppose to but I don't know how to implement it to my scenario. I couldn't find any civ videos related to what I'm trying to do.
 
I am really confused and new to modding and stuff welllll I used used your religion codes and I changed the names of the religions and added city names to where I was suppose to but I don't know how to implement it to my scenario. I couldn't find any civ videos related to what I'm trying to do.

Open your mod's properties (right-click on the project name or alt-enter), then select the Content tab. In the content tab use the Add... button to add your new lua file as an InGameUIAddIn. The name and description fields dont matter, but the FileName must be exact, including the folder path (if you used one).
 
This is what i've basically done.


Spoiler :
function EstablishCatholicism()
if Game.GetGameTurn() == 0 then

function CreateCatholicismHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]

-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1

Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], iBelief4, iBelief5, pCity)
end

function FoundCatholicism()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then

for cityIndex = 0, pPlayer:GetNumCities() - 1, 1 do
local pCity = pPlayer:GetCityByID(cityIndex)

-- City exists and has the proper name?
if pCity ~= nil and pCity:GetName() == "Roma" then

CreateCatholicismHolyCity(pCity, "RELIGION_Catholicism", "BELIEF_RELIGIOUS_IDOLS",
"BELIEF_PAPAL_PRIMACY", "BELIEF_CATHEDRALS", "BELIEF_CHORAL_MUSIC", "BELIEF_HOLY_ORDER");
return pCity
end
end
end
end
end

local pChatholicPlot = FoundCatholicism():Plot()

end
end

Events.ActivePlayerTurnEnd.Add(EstablishCatholicism)

-- Enumerate Playable Civ Cities with Catholicism

function FollowCatholicism()
if Game.GetGameTurn() == 0 then

for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer];
if pPlayer:IsEverAlive() then

print (pPlayer:GetName())

-- Enumerate cities
for cityIndex = 0, pPlayer:GetNumCities() - 1, 1 do
local pCity = pPlayer:GetCityByID(cityIndex)

print (pCity:GetName());

-- City exists and has the proper name?
if pCity ~= nil and city:GetName() == "Vaticano" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Napoli" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Palermo" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Genova" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Venezia" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Marseille" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Lyon" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Bordeaux" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Orleans" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Paris" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Barcelona" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Valencia" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Madrid" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Leon" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Seville" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Lisbon" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Porto" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Faro" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Sassari" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Brussels" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Dublin" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Galaway" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Cork" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Zagreb" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Salzburg" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Wien" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Budapest" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Kosice" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Prague" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Poznan" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Wroclaw" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
elseif pCity ~= nil and pCity:GetName() == "Vilnius" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_CATHOLICISM"]);
return pCity
end
end
end
end

end
end

Events.ActivePlayerTurnEnd.Add(FollowCatholicism)




function EstablishIslam()
if Game.GetGameTurn() == 0 then

function CreateIslamHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]

-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1

Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], iBelief4, iBelief5, pCity)
end

function FoundIslam()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then

for cityIndex = 0, pPlayer:GetNumCities() - 1, 1 do
local pCity = pPlayer:GetCityByID(cityIndex)

-- City exists and has the proper name?
if pCity ~= nil and pCity:GetName() == "Mecca" then

CreateIslamHolyCity(pCity, "RELIGION_ISLAM", "BELIEF_DESERT_FORKLORE",
"BELIEF_PILGRAMAGE", "BELIEF_MOSQUE", "BELIEF_HOLY_WARRIORS", "BELIEF_JUST_WAR");
return pCity
end
end
end
end
end

local pMuslimPlot = FoundIslam():Plot()

end
end

Events.ActivePlayerTurnEnd.Add(EstablishIslam)

-- Enumerate Playable Civ Cities with Islam

function FollowIslam()
if Game.GetGameTurn() == 0 then

for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer];
if pPlayer:IsEverAlive() then

print (pPlayer:GetName())

-- Enumerate cities
for cityIndex = 0, pPlayer:GetNumCities() - 1, 1 do
local pCity = pPlayer:GetCityByID(cityIndex)

print (pCity:GetName());

-- City exists and has the proper name?
if pCity ~= nil and city:GetName() == "Tirana" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Sogut" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Konya" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Ankara" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Samsun" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Bursa" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Varna" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Susa" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Aleppo" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Pasargadae" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Persepolis" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Baghdad" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Medina" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Sidon" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Alexandria" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Nicaea" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Carthage" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Algiers" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Fes" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Tangier" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Casablanca" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Marrakech" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
elseif pCity ~= nil and pCity:GetName() == "Tirana" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_ISLAM"]);
return pCity
end
end
end
end

end
end

Events.ActivePlayerTurnEnd.Add(FollowIslam)





function EstablishProtestantism()
if Game.GetGameTurn() == 0 then

function CreateProtestantismHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]

-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1

Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], iBelief4, iBelief5, pCity)
end

function FoundProtestantism()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then

for cityIndex = 0, pPlayer:GetNumCities() - 1, 1 do
local pCity = pPlayer:GetCityByID(cityIndex)

-- City exists and has the proper name?
if pCity ~= nil and pCity:GetName() == "Hamburg" then

CreateProtestantismHolyCity(pCity, "RELIGION_PROTESTANTISM", "BELIEF_GOD_OF_CRAFTSMEN",
"BELIEF_INTERFAITH_DIALOGUE", "BELIEF_RELIGIOUS_COMMUNITY", "BELIEF_GURUSHIP", "BELIEF_RELIGIOUS_TEXT");
return pCity
end
end
end
end
end

local pProtestantPlot = FoundProtestantism():Plot()

end
end

Events.ActivePlayerTurnEnd.Add(EstablishProtestantism)


-- Enumerate Playable Civ Cities with Protestant

function FollowProtestantism()
if Game.GetGameTurn() == 0 then

for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer];
if pPlayer:IsEverAlive() then

print (pPlayer:GetName())

-- Enumerate cities
for cityIndex = 0, pPlayer:GetNumCities() - 1, 1 do
local pCity = pPlayer:GetCityByID(cityIndex)

print (pCity:GetName());

-- City exists and has the proper name?
if pCity ~= nil and city:GetName() == "Bern" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "London" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "York" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Bristol" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Liverpool" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Edinburgh" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Amsterdam" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Reykjavik" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Oslo" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Holstebro" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Copenhagen" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Berlin" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Hanover" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Frankfurt" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Munchen" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Gothenburg" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Stockholm" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Birka" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Umea" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Helsinki" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Tallinn" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
elseif pCity ~= nil and pCity:GetName() == "Riga" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_PROTESTANTISM"]);
return pCity
end
end
end
end

end
end

Events.ActivePlayerTurnEnd.Add(FollowProtestantism)




function EstablishEasternOrthodoxy()
if Game.GetGameTurn() == 0 then

function CreateEasternOrthodoxyHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]

-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1

Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], iBelief4, iBelief5, pCity)
end

function FoundEasternOrthodoxy()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then

for cityIndex = 0, pPlayer:GetNumCities() - 1, 1 do
local pCity = pPlayer:GetCityByID(cityIndex)

-- City exists and has the proper name?
if pCity ~= nil and pCity:GetName() == "Constantinople" then

CreateProtestantismHolyCity(pCity, "RELIGION_EasternOrthodoxy", "BELIEF_GOD_OF_WAR",
"BELIEF_TITHE", "BELIEF_MONASTARIES", "BELIEF_RELIGIOUS_ART", "BELIEF_DEFENDER_OF_THE_FAITH");
return pCity
end
end
end
end
end

local pEasternOrthodoxPlot = FoundEasternOrthodoxy():Plot()

end
end

Events.ActivePlayerTurnEnd.Add(EstablishEasternOrthodoxy)


-- Enumerate Playable Civ Cities with EasternOrthodox

function FollowEasternOrthodoxy()
if Game.GetGameTurn() == 0 then

for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer];
if pPlayer:IsEverAlive() then

print (pPlayer:GetName())

-- Enumerate cities
for cityIndex = 0, pPlayer:GetNumCities() - 1, 1 do
local pCity = pPlayer:GetCityByID(cityIndex)

print (pCity:GetName());

-- City exists and has the proper name?
if pCity ~= nil and city:GetName() == "Antioch" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Constantinople" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Corinth" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Athens" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Sparta" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Knossos" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Adrianople" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Odesa" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Kyiv" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "L'viv" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Kharkiv" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Belgrade" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Bucharest" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Ragusa" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Minsk" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "St. Petersburg" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Rostov" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Moscow" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Novgorod" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
elseif pCity ~= nil and pCity:GetName() == "Vologda" then
pCity:AdoptReligionFully(GameInfoTypes["RELIGION_EASTERN_ORTHODOXY"]);
return pCity
end
end
end
end

end
end

Events.ActivePlayerTurnEnd.Add(FollowEasternOrthodoxy)






btw when im in game and i go to mods and i activate my religion "mod" but no matter what i do i can't find a way for it to work in my scenario :(
 
Back
Top Bottom