Religion Change on Capture Help

Gunnaka

Chieftain
Joined
Oct 18, 2012
Messages
20
Alright, so my situation is that I created a Civilization mod nearly a year ago now, and it had a lot bigger of a reception than I had initially expected. I wanted to get more out, but I ran into issues, and lost motivation after a while.

People have been requesting that I get more out for a long time now, so I figured I'd try finish the one I almost had done at least. The problem is I need an ability script, and I'm very inexperienced with lua. Usually I wouldn't want to outright ask, but is there anybody who could try to figure out this ability for me?

The idea is that a captured city by this civilization will immediately switch completely to their religion. I played around with it a bit, but couldn't make it work out. I'd really appreciate if somebody could help here, and will give you credit where it's needed if it works out.
 
Use the following code. It is identical to the chunk posted in the link thread just with a faith bonus removed. You want to use convertPercentFollowers (which this code does) rather than adoptReligionFully because other people have said they couldn't get adoptReligionFully to work.

You'll need to change the convert percent from 25 to 100, but be aware that it only converts a percent of the majority religion in the captured city.

Code:
function Crusades(hexPos, playerID, cityID, newPlayerID)
	local player = Players[newPlayerID];
	local eReligion = player:GetReligionCreatedByPlayer();
	local plot = Map.GetPlot(ToGridFromHex(hexPos.x, hexPos.y));
	local city = plot:GetPlotCity();
	
	if([COLOR="SeaGreen"]player is not civ[/COLOR] or eReligion < 1) then
		return;
	end

	-- Only run this if the city has a religion, and the city is of a different religion
	if (plot:IsCity() and 0 < city:GetReligiousMajority() and eReligion ~= city:GetReligiousMajority()) then
		-- Convert 25% of the heathens
		[COLOR="SeaGreen"]city:ConvertPercentFollowers(eReligion, city:GetReligiousMajority(), 25);[/COLOR]
	end
end
Events.SerialEventCityCaptured.Add(Crusades);
 
Back
Top Bottom