1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Race for Religion!

Discussion in 'Civ5 - Modpacks' started by Machiavelli24, Sep 23, 2013.

  1. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    The most recent update of Race (the Reformation update) did add some code that executes when capitals are captured. I'll take a close look at it to see if there are mistakes in it that could be the cause of the crashing.

    EDIT:
    I think I have a solution but I haven't been able to test it yet. Replace the "...\Documents\my games\Sid Meier's Civilization 5\MODS\Race for Religion (BNW) (v 4)\Shared\Belief_FounderFreeBuildingClassCapital\Belief_FounderFreeBuildingClassCapital.lua" file with the below:
    Spoiler :

    Code:
    -- Belief_FounderFreeBuildingClassCapital
    -- Author: Machiavelli
    -- DateCreated: 3/6/2014 10:49:51 AM
    --------------------------------------------------------------
    -- NOTE: Depends on ReligionFoundedEvent.
    --------------------------------------------------------------
    function GiveBeliefBuildingCapital(founderID, iX, iY, eOldReligion, eNewReligion)
    	local founder = Players[founderID];
    
    	for row in GameInfo.Belief_FounderFreeBuildingClassCapital() do
    		if(ReligionHasBelief(eNewReligion, GameInfoTypes[row.BeliefType])) then
    			local building = GetBuildingTypeFromClass(row.BuildingClassType, founder:GetCivilizationType());
    
    			founder:GetCapitalCity():SetNumRealBuilding(GameInfoTypes[building], 1);
    		end
    	end
    end
    --LuaEvents.ReligionFoundedEvent.Add(GiveBeliefBuildingCapital);
    
    function GiveBeliefBuildingCapitalMove(oldPlayerID, bCapital, iX, iY, newPlayerID, conquest, conquest2)
    	local oldPlayer = Players[oldPlayerID];
    	local newPlayer = Players[newPlayerID];
    	local city =  Map.GetPlot(iX, iY):GetPlotCity();
    	local oldPlayerReligion = oldPlayer:GetReligionCreatedByPlayer();
    	local newPlayerReligion = newPlayer:GetReligionCreatedByPlayer();
    	
    	-- If the old player just lost their capital, they may need to have their buildings replaced
    	if(bCapital and oldPlayer:IsAlive() and oldPlayerReligion > 0) then
    		for row in GameInfo.Belief_FounderFreeBuildingClassCapital() do
    			if(ReligionHasBelief(oldPlayerReligion, GameInfoTypes[row.BeliefType])) then
    				local building = GetBuildingTypeFromClass(row.BuildingClassType, oldPlayer:GetCivilizationType());
    
    				oldPlayer:GetCapitalCity():SetNumRealBuilding(GameInfoTypes[building], 1);
    			end
    		end
    	end
    	---------------------------------
    	-- If the new player just recovered their capital, they will need to have their buildings moved
    	if(newPlayer:GetCapitalCity():GetID() == city:GetID() and newPlayerReligion > 0) then
    		for row in GameInfo.Belief_FounderFreeBuildingClassCapital() do
    			if(ReligionHasBelief(newPlayerReligion, GameInfoTypes[row.BeliefType])) then
    				local building = GetBuildingTypeFromClass(row.BuildingClassType, newPlayer:GetCivilizationType());
    
    				-- Remove capital only buildings from the new player's cities
    				for cityToRemove in newPlayer:Cities() do
    					cityToRemove:SetNumRealBuilding(GameInfoTypes[building], 0);
    				end
    				-- Add back the capital-only buildings
    				city:SetNumRealBuilding(GameInfoTypes[building], 1);
    			end
    		end
    	end
    end
    --GameEvents.CityCaptureComplete.Add(GiveBeliefBuildingCapitalMove);
    
    --------------------
    -- Private helper functions
    --------------------
    function ReligionHasBelief(eReligion, eBelief)
    	local hasBelief = false;
    
    	for i,v in ipairs(Game.GetBeliefsInReligion(eReligion)) do
    		local belief = GameInfo.Beliefs[v];
    
    		if (belief ~= nil and belief.ID == eBelief) then
    			hasBelief = true;
    			return hasBelief;
    		end
    	end
    
    	return hasBelief;
    end
    
    function GetBuildingTypeFromClass(buildingClass, civilizationTypeID)
    	-- Assume it is the default building
    	local buildingType = GameInfo.BuildingClasses[buildingClass].DefaultBuilding;
    
    	-- See if this civilization has a unique building for this building class
    	for row in GameInfo.Civilization_BuildingClassOverrides() do
    		if (GameInfoTypes[row.CivilizationType] == civilizationTypeID and row.BuildingClassType == buildingClass) then
    			-- This civilization has a unique building
    			buildingType = row.BuildingType;
    			return buildingType;
    		end
    	end
    
    	return buildingType;
    end
    
    --------------
    -- Initialization check.  Ensures this code isn't loaded twice
    --------------
    local retVal = {};
    LuaEvents.Belief_FounderFreeBuildingClassCapital_IsInitialized(retVal);
    
    -- If retVal isn't changed, no other mod has initialized this code.
    if (retVal.isInitialized == nil) then
    	LuaEvents.Belief_FounderFreeBuildingClassCapital_IsInitialized.Add(function (retVal) retVal.isInitialized = true; end);
    	-- Initialize the code
    	LuaEvents.ReligionFoundedEvent.Add(GiveBeliefBuildingCapital);
    	GameEvents.CityCaptureComplete.Add(GiveBeliefBuildingCapitalMove);
    end
    
     
  2. Enkidu Warrior

    Enkidu Warrior Ultramagnetic

    Joined:
    Nov 18, 2003
    Messages:
    3,415
    Location:
    Takoyaki Province, Sushistan
    Playing from my earlier save, this appears to do the trick. Thanks for the really quick response.
     
  3. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    Race for Religion V 5 is now available. This update contains no gameplay changes. It contains the previously mentioned fix for the crashing caused when capturing capital cities. If you have started a game with v4 you can (and should) continue the game after updating to this version.

    Also in this update, Race for Religion should now function the same no matter what order your mods happen to load in. This should make manually adding references a thing of the past. And for those who didn't bother with references, it should reduce the number of idiosyncratic issues you see when playing with lots of mods.
     
  4. Skaz881

    Skaz881 History Major

    Joined:
    Dec 15, 2013
    Messages:
    1,349
    Location:
    Crystal Lake, Illinois, USA.
    I'm not sure the fix worked correctly. If Race for Religion loads before Tomatekh's religion mods, they don't show up and this happens:
    Code:
    [189720.765] column Type is not unique
    [189720.765] While executing - 'insert into Religions('Type', 'Description', 'Civilopedia', 'IconAtlas', 'PortraitIndex', 'IconString') values (?, ?, ?, ?, ?, ?);'
    [189720.765] In XMLSerializer while inserting row into table insert into Religions('Type', 'Description', 'Civilopedia', 'IconAtlas', 'PortraitIndex', 'IconString') with  values (RELIGION_CHRISTIANITY, TXT_KEY_RELIGION_CHRISTIAN_CATHOLIC, TXT_KEY_RELIGION_CHRISTIAN_CATHOLIC_PEDIA, RELIGION_ATLAS_WHITE, 1, [ICON_RELIGION_CHRISTIANITY], ).
    [189720.765] In XMLSerializer while updating table Religions from file XML/Historical Religions Mod.xml.
    [189720.765] column Type is not unique
     
  5. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    Replace "Race for Religion (v X)/Shared/CityAdoptsReligionEvent/CityAdoptsReligionEvent.sql" with what is below:

    Spoiler :
    Code:
    -- Add the current religion building classes
    INSERT INTO BuildingClasses(Type, DefaultBuilding, Description)
    	SELECT 'BUILDINGCLASS_'||Type, 'BUILDING_'||Type, Description
    	FROM Religions;
    
    -- Add the current religion building type
    INSERT INTO Buildings(Type, BuildingClass, Description, NukeImmune, ConquestProb, Cost)
    	SELECT 'BUILDING_'||Type, 'BUILDINGCLASS_'||Type, Description, 1, 100, -1
    	FROM Religions;
    
    -- Add the has-ever-been religion building classes
    INSERT INTO BuildingClasses(Type, DefaultBuilding, Description)
    	SELECT 'BUILDINGCLASS_HAS_BEEN_'||Type, 'BUILDING_HAS_BEEN_'||Type, Description
    	FROM Religions;
    
    -- Add the has-ever-been religion building type
    INSERT INTO Buildings(Type, BuildingClass, Description, NukeImmune, ConquestProb, Cost)
    	SELECT 'BUILDING_HAS_BEEN_'||Type, 'BUILDINGCLASS_HAS_BEEN_'||Type, Description, 1, 100, -1
    	FROM Religions;
    
    -----------------------
    -- DATABASE TRIGGERS --
    -----------------------
    -- A new religion is inserted and needs to have "is" and "has been" buildings created for it
    CREATE TRIGGER ReligionInserted_CreateBuildings
    AFTER INSERT ON Religions
    BEGIN
    	INSERT INTO BuildingClasses(Type, DefaultBuilding, Description)
    	VALUES('BUILDINGCLASS_'||NEW.Type, 'BUILDING_'||NEW.Type, NEW.Description);
    
    	INSERT INTO Buildings(Type, BuildingClass, Description, NukeImmune, ConquestProb, Cost)
    	VALUES('BUILDING_'||NEW.Type, 'BUILDINGCLASS_'||NEW.Type, NEW.Description, 1, 100, -1);
    
    	INSERT INTO BuildingClasses(Type, DefaultBuilding, Description)
    	VALUES('BUILDINGCLASS_HAS_BEEN_'||NEW.Type, 'BUILDING_HAS_BEEN_'||NEW.Type, NEW.Description);
    
    	INSERT INTO Buildings(Type, BuildingClass, Description, NukeImmune, ConquestProb, Cost)
    	VALUES('BUILDING_HAS_BEEN_'||NEW.Type, 'BUILDINGCLASS_HAS_BEEN_'||NEW.Type, NEW.Description, 1, 100, -1);
    END;
    
    CREATE TRIGGER IF NOT EXISTS ReligionDeleted_DeleteBuildings
    AFTER DELETE ON Religions
    BEGIN
    	DELETE FROM BuildingClasses WHERE Type = 'BUILDINGCLASS_'||OLD.Type;
    	DELETE FROM Buildings WHERE Type = 'BUILDING_'||OLD.Type;
    
    	DELETE FROM BuildingClasses	WHERE Type = 'BUILDINGCLASS_HAS_BEEN_'||OLD.Type;
    	DELETE FROM Buildings WHERE Type = 'BUILDING_HAS_BEEN_'||OLD.Type;
    END;
     
  6. Skaz881

    Skaz881 History Major

    Joined:
    Dec 15, 2013
    Messages:
    1,349
    Location:
    Crystal Lake, Illinois, USA.
    Does the latest update affect beliefs at all?
     
  7. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    It does not change beliefs in a way that human players should notice. Fixing the AI "Goddess of Hunting"-as-Enhancer bug did require changing every enhancer belief to manipulate the AI's evaluation logic. Are you seeing anything weird?
     
  8. Jabarto

    Jabarto Emperor

    Joined:
    May 15, 2007
    Messages:
    1,025
    Location:
    Colorado, U.S.
    I love your other mods, but to be honest, I don't quite like the direction this one takes. With pantheon beliefs being mostly focused on faith and founder beliefs being focused on propagating the religion, it feels like I have all sorts of new ways to spread the faith but less incentive to do it since there are fewer beliefs that actually provide a benefit my civilization.

    That said, there are some pretty creative ideas here. Swords into Plowshares is my favorite example, and I think making cathedrals/mosques/etc . into reformation beliefs is a good way to make the Piety finisher more worthwhile.
     
  9. Skaz881

    Skaz881 History Major

    Joined:
    Dec 15, 2013
    Messages:
    1,349
    Location:
    Crystal Lake, Illinois, USA.
    :blush: No, I just copied the beliefs folder from version 5 to version 6 because I'd made changes to several pantheon beliefs to accomodate my resource pack. I guess I should at least put the new enhancer file in right?
     
  10. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    You should be ok skaz, the AI manipulation fix is done in "Race for Religion/options/enhancer spread penalty/Enhanced_Spread_Penalty.sql". The only thing you'll lose is some tweaks I made to the flavor values of mosques, cathedrals, pagodas, seminaries and haidens.

    It may be easier in the long run for you to implement your tweaks as a mod (of a mod). A mod that depends on Race and references Race (so as to load after it).
    --------------------
    Jabarto, I plan to design more follower beliefs to make up for the beliefs lost in the reformation update. Are there aspects that you would like to see more of or less of?

    As for Founder beliefs, are there only a handful of ones you default to?
     
  11. isnorden

    isnorden Amnesiac Modder

    Joined:
    Jul 6, 2012
    Messages:
    608
    Location:
    Madison, Wisconsin, USA
    Although I greatly enjoy this mod, I miss being able to give religions an appropriate building earlier in the game. The next release (IMO) should move "building buyers" down to Enhancer level -- far enough along to keep players from buying three kinds, but soon enough to allow two. (Byzantium needs both Monasteries and Cathedrals, if you're a stickler for historical accuracy!)

    P.S. I would like permission to use some of your code in a "Grand Unified Beliefs Modpack" (which will include other players' new additions, besides your own). Everyone involved, of course, will get credit for their original work. Many thanks!
     
  12. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    While I can't promise it will make the cut, there is a possibility of new follower beliefs enabling buildings. However, these buildings would be production-built rather than faith-bought.

    You can certainly re-use any of snippets I use, I want them to be useful to other mod makers. Which chunks are you planning to use?
     
  13. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
    I'm getting this error on the Baptism Enhancer:
    I can't give you more information because it was in a game I had no Religion, so it was being used by the AI. Hope it helps! :)
     
  14. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    That error is nothing to worry about bane. When a city is razed to 0 population and deleted Baptism will fail to get the city object. I ought to include a check so that Baptism does nothing in this case rather than spit out an error out but no game-play benefits are mistakenly being provided or withheld due to this error.

    I'll incorporate that fix into the next version, whenever it gets released.
     
  15. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
    Ok, good to know!

    In that same game, I got "nil Faith" from a Great General. (the one above is the usual +250 from an Honor policy)

    (Shireikan is a Great General replacement)
     
  16. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    There was a bug in v6 that caused that. It should have been fixed in v7 (the most recent version). Are you playing with v7?
     
  17. Necamijat

    Necamijat Warlord

    Joined:
    Sep 2, 2014
    Messages:
    104
    I seem to have an issue with Religious Sects (spy founder belief):
    -Spies are born when a religion is founded (which i don't know if it should happen or not), giving you a spy at classical era, allowing you to boost yourself nicely from Emperor+ AI science;
    -Spies exert A LOT more pressure than stated (not sure if cache, UI, or EUI bug): spy will exert 48 pressure on epic (which would be approx 72 on standard if the scaling is correct), allowing a single city + spy to overtake a holy city (52 combined pressure vs 20-30 from holy city). This is 6 times the stated value.

    Other than that, and the fact that Monument to the gods is in my opinion too strong with the production bonus to every wonder, I'm having a very fun time playing with this mod.
     
  18. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    It is intended for Religious Sects to give the spy right away, as the early spy is intended to be the core benefit of that belief. It is a strong, science granting, effect that has been on my watch list.

    As for the pressure scaling, that does sound wrong. On standard speed cities provide 6 pressure while on epic it is 4 pressure. The spy is intended to provide two cities worth of pressure, so 12 for standard which if scaled the same way should produce 8 pressure. I'll take another look at the DLL to see if it is being scaled properly with game speed.
     
  19. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
    Hey, I was bug hunting and found this:

    Ref line:
    local player = Players[city:GetOwner()];
     
  20. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    Baptism will produce an error like that when a city changing from 1 to 0 population (due to being razed). The population change event fires (which Baptism is hooked into) and Baptism doesn't check to see if it has been given a valid city object. Functionally, Baptism works correctly, it just errors out in certain circumstances instead of gracefully doing nothing. I expect I'll fix this in the next version of Race.
     

Share This Page