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

Adding a dummy belief to a religion?

Discussion in 'Civ5 - Creation & Customization' started by KyubeyD3, Oct 12, 2019 at 1:12 PM.

Tags:
  1. KyubeyD3

    KyubeyD3 Chieftain

    Joined:
    Oct 6, 2019
    Messages:
    7
    Gender:
    Male
    Is there a way to create a new founder belief and make it so that it's not possible to choose it when creating your religion, but make it so that it's added to an existing religion?

    I want to add an UB to a civ I'm making, replacing the Grand Temple (so that there's no way to legitimately obtain the new belief if you don't have a religion, since the GT can only be built on a Holy City) that allows the founder's cities that follow that religion to be able to buy military units with Faith (like the Holy Warriors and Religious Fervor beliefs, but fused together). Is it possible for a building to add a founder belief to a religion?

    How do?
     
  2. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,226
    Location:
    Illinois, USA
    Buildings cannot add a belief to a religion.

    The game is pretty much hard-coded to only allow the usual number of beliefs. Deviating from the pre-packaged system as designed and implemented by Firaxis tends pretty much to just lead to CTDs so far as attempting to stray outside the box of the religions-structure as Firaxis created it.

    I am not sure if William Howard's VMC DLL mod alters the basics of the religion system in any fundamental way, nor whether the CP DLL does so.

    --------------

    You can't really have a "dummy belief" in Civ5 -- you can add more beliefs and have one of them do what you are after, but the belief will be "up for grabs" to whomever beats everyone else to founding or enhancing a religion.

    --------------

    Work-arounds for what you are after are possible via lua methods. The usual one is to make the lua script only allow gold-purchase of the unit if the player has enough Faith for the purchase, and then to refund the needed gold and subtract the correct amount of faith. But it can be a bit kludge in my opinion. For example the lua script would want to not allow the usual gold-purchasing if the player had insufficient Faith even if they had the needed normal amount of gold.
     
  3. KyubeyD3

    KyubeyD3 Chieftain

    Joined:
    Oct 6, 2019
    Messages:
    7
    Gender:
    Male
    well that's a bummer D:

    Since my civ is based mainly on religion and military, I want to make an UB that links both in some way.
    Is there a way to make something like:

    "+1% Military Unit Production on every city for every 4 faith produced by this city (up to 75%)"
    (still as a Grand Temple replacement)

    ?
     
  4. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,226
    Location:
    Illinois, USA
  5. KyubeyD3

    KyubeyD3 Chieftain

    Joined:
    Oct 6, 2019
    Messages:
    7
    Gender:
    Male
    I think I managed to get it somewhat correct by looking at some other mods and using parts from their code, but I'm not sure:

    Code:
    function IsCivActive(civilisationID)
        for iSlot = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
            local slotStatus = PreGame.GetSlotStatus(iSlot)
            if (slotStatus == SlotStatus["SS_TAKEN"] or slotStatus == SlotStatus["SS_COMPUTER"]) then
                if PreGame.GetCivilization(iSlot) == civilisationID then
                    return true
                end
            end
        end
    
        return false
    end
    --
    function MilUnitProduction(PlayerID)
        local player = Players[playerID]
        local civilisationID = GameInfoTypes["CIVILIZATION_SERTAO"]
        local isSertaoActive = IsCivActive(civilisationID)
        if (player:IsAlive() and player:GetCivilizationType() == civilisationID) then
            for pCity in pPlayer:Cities() do
                local capellinhaMUP=0
                if (pCity:GetNumBuilding(GameInfoTypes["BUILDING_CAPELLINHA"]) > 0) then
                    capellinhaMUP=math.floor(pCity:GetFaithPerTurn()/4)
                end
                pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_SERTAO_UB_PROD"], mathMin(50, capellinhaMUP))
            end
        end
    end
    --
    local civilisationID = GameInfoTypes["CIVILIZATION_SERTAO"]
    local isSertaoActive = IsCivActive(civilisationID)
    --
    if isSertaoActive then
        GameEvents.PlayerDoTurn.Add(MilUnitProduction)
    end
    Is this correctly coded?
     
  6. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,226
    Location:
    Illinois, USA
    Not quite but pretty close.
    1. If "BUILDING_CAPELLINHA" is the Grand Temple replacement, then only the city with this National Wonder would be affected as your code was written
    2. You had a couple of typos which would be fatal to the code.
      • In one place you referred to the player variable as "player" and elsewhere you referred to it as "pPlayer"
      • In one place you referred to the player ID # variable as "PlayerID" and elsewhere you referred to it as "playerID"
      • The syntax for the "math.min" function was not spelled correctly.
    3. Assuming BUILDING_CAPELLINHA is Grand Temple National Wonder replacement, and adding a few enhancements to the code I would do as follows:
      Spoiler :
      Code:
      --
      local civilisationID = GameInfoTypes["CIVILIZATION_SERTAO"]
      local CapellinhaBuilding = GameInfoTypes["BUILDING_CAPELLINHA"]
      local MilitaryProdDummy = GameInfoTypes["BUILDING_SERTAO_UB_PROD"]
      --
      function IsCivActive(civilisationID)
          for iSlot = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
              local slotStatus = PreGame.GetSlotStatus(iSlot)
              if (slotStatus == SlotStatus["SS_TAKEN"] or slotStatus == SlotStatus["SS_COMPUTER"]) then
                  if PreGame.GetCivilization(iSlot) == civilisationID then
                      return true
                  end
              end
          end
      
          return false
      end
      --
      function MilUnitProduction(PlayerID)
          local player = Players[PlayerID]
          if (player:GetCivilizationType() == civilisationID) then
              for pCity in player:Cities() do
      		if (player:CountNumBuildings(CapellinhaBuilding) > 0) then
      			pCity:SetNumRealBuilding(MilitaryProdDummy, math.min(50, math.floor(pCity:GetFaithPerTurn()/4)))
      		else
      			if pCity:IsHasBuilding(MilitaryProdDummy) then
      				pCity:SetNumRealBuilding(MilitaryProdDummy, 0)
      			end
      		end
              end
          end
      end
      --
      if IsCivActive(civilisationID) then
          GameEvents.PlayerDoTurn.Add(MilUnitProduction)
      end
      • PlayerDoTurn does not execute for dead Civs, so if the function is only being subscribed to the PlayerDoTurn hook event there is no need to check for whether the player is alive. The following check would be sufficient:
        Code:
        if (player:GetCivilizationType() == civilisationID) then
          ----stuff----
        end
      • By making variables local at the "root" level of the file they are accessible to all functions within that same file, so we can access the GameInfoTypes once and not have to do so again within the same file. GameInfoTypes is fast but locals are generally faster than that because of the way lua handles local variables.
      • The Player:CountNumBuildings(BuildingID) method returns the integer number of buildings that the player currently owns anywhere within the empire for the designated type of Building. So if the player is the correct one but the number of "BUILDING_CAPELLINHA" they currently own is less than 1 the code will remove any of the "BUILDING_SERTAO_UB_PROD" buildings that may be in the empire.
     
  7. KyubeyD3

    KyubeyD3 Chieftain

    Joined:
    Oct 6, 2019
    Messages:
    7
    Gender:
    Male
    Thank you so much!

    I actually changed the UB to be a Temple replacement (since I couldn't figure out how to make a dummy building that increases military production on all cities, so I made it so that the bonus production on each city is relative to each city's faith output, instead of being based solely on the faith output of only one city)

    Code:
    function MilUnitProduction(PlayerID)
        local player = Players[PlayerID]
        if (player:GetCivilizationType() == civilisationID) then
            for pCity in player:Cities() do
                if (pCity:GetNumBuilding(CapellinhaBuilding) > 0) then
                    pCity:SetNumRealBuilding(MilitaryProdDummy, math.min(50, math.floor(pCity:GetFaithPerTurn()/4)))
                else
                    if pCity:IsHasBuilding(MilitaryProdDummy) then
                        pCity:SetNumRealBuilding(MilitaryProdDummy, 0)
                    end
                end
            end
        end
    end
    Would this code still be correct if I replaced player:CountNumBuildings with pCity:GetNumBuilding ?
     
    Last edited: Oct 14, 2019 at 12:47 PM
  8. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,226
    Location:
    Illinois, USA
  9. KyubeyD3

    KyubeyD3 Chieftain

    Joined:
    Oct 6, 2019
    Messages:
    7
    Gender:
    Male
    Awesome, thanks.
     

Share This Page