Lua needed to make belef work?

isnorden

Amnesiac Modder
Joined
Jul 6, 2012
Messages
608
Location
Madison, Wisconsin, USA
I'm considering this Enhancer religious belief as part of my latest project --

Ninth-Year Festival

Lump-sum Faith bonus from the Grand Temple every 9 years; lump-sum amount of points towards the next Golden Age (both modified by game speed).

Several scripting questions come to mind:

  1. Which event would I use to check the number of "game years" that have passed since the starting date?
  2. How do I check whether a civ has adopted this belief?
  3. Which variables/values get the bonus?
  4. How do I adjust the bonuses based on game speed?
  5. And finally, is there a way to have specific religions unlock beliefs (like disallowing "Papal Primacy" to any religion EXCEPT Catholicism)? I designed "Ninth-Year Festival" based on period accounts of one culture's practice.

EDIT: Could the admins please fix my "mispelled" title? *d'oh*
 
How do I check whether a civ has adopted this belief?
You can iterate over all the beliefs with "for i,v in ipairs(Game.GetBeliefsInReligion(eReligion)) do". For example:
Code:
	local eReligion = player:GetReligionCreatedByPlayer();

	local hasBelief = false;
	for i,v in ipairs(Game.GetBeliefsInReligion(eReligion)) do
		local belief = GameInfo.Beliefs[v];

		if (belief ~= nil and belief.ID == GameInfoTypes["BELIEF_CHURCH_PROPERTY"]) then
			hasBelief = true;
		end
	end

	if(hasBelief) then
		...do special belief stuff...
	end

How do I adjust the bonuses based on game speed?
Use "GameInfo.GameSpeeds[Game:GetGameSpeedType()].scalingColumnYouNeed". For example:
Code:
		local bonusFaith = 25;
		local adjustedBonusFaith = (bonusFaith * GameInfo.GameSpeeds[Game:GetGameSpeedType()].FaithPercent) / 100;
		player:ChangeFaith(adjustedBonusFaith);

is there a way to have specific religions unlock beliefs (like disallowing "Papal Primacy" to any religion EXCEPT Catholicism)?
The short answer is not without DLL modding. There isn't a "playerCanBelief" check in the same way there is for buildings and units.

The long answer is, I can think of a pretty crazy way that might be able to awkwardly do it but would require a huge amount of effort. It involves manipulating the AI's belief evaluation logic so that they won't want to pick "illegal" off religion beliefs while modding the UI the human uses to enforce the restriction.

Lump-sum Faith bonus from the Grand Temple every 9 years; lump-sum amount of points towards the next Golden Age (both modified by game speed).
A lump sum of faith every handful of turns would be very similar in practice to a bit of faith each turn, which could be easily implemented as an entry in Belief_BuildingClassYieldChanges. Golden Age points however will require lua (use player:ChangeGoldenAgeProgress(int change)).
 
Thank you for answering my questions; I now have one more reason to buckle down and figure out DLL hacks, although messing with code on that level scares the heck out of me. :eek:

EDIT: Could someone please let me know whether there's a function for checking the current game year?
 
Back
Top Bottom