Religious Beliefs Overhaul - Help Thread

LOL @ eating crow. Have never heard that expression until now. Would it be too much to ask of you to try to finish the Lua script Lee? The promotion is working btw, tested it in-game today. Only weird thing is that it gives +2 faith per death instead of +1, despite the Lua value being set to 1. Oh, and the promotion icon is the 'instant heal' icon, but I'm sure I can figure out how to change that myself.

GameEvents.UnitPrekill(iPlayer, iUnit, eUnit, iPlotX,iPlotY,bDelay,eByPlayer) is a dreadful PITA to bend to your will:
  1. It fires at least once for every unit-removal from the game for whatever cause
    • When a unit is disbanded
    • when a Settler founds a city
    • when a civiian unit is captured
    • when a Great Person does thier Great Person 'thing' (either improvement or 'action')
    • when a unit is upgraded (the original unit is removed and therefore 'killed')
    • it fires twice for any unit that is killed off as a result of actual combat. Incidentally, this is why your code is not working as anticipated.
  2. When a unit is killed off in actual combat, the event fires twice for that unit.
    • the first time it fires for the killing of a unit, bDelay will be equal to true, and eByPlayer will be equal to the Player ID# of the player who was victorious in the combat.
      • other than grabbing who did the killing to whom (iPlayer and eByPlayer) there really is not much usable information beyond what unit was killed.
    • the second time it fires for the killing of a unit, bDelay will be equal to false, and eByPlayer will be equal to -1.
      • during this second firing, additional information can be gleaned on which actual unit was the victorious unit, but in order to do so, you must get the plot info for the X,Y position of the plot, and then check all units that are seen as being on the plot.
      • when doing this check of all units seen to be on the plot, you must weed out the unit that was killed when you are interested in the victorious unit, because the defeated unit will also be shown as being a unit still occupying the plot
      • however, this only works for direct-attack units that attacked and killed off another unit. Direct-attack units as in Melee, Gunpowder, Mounted, Armor units.
      • you will get no usable information for Ranged or Siege units that attacked and killed off another unit
      • if the unit that was victorious was attacked by the unit that was killed, you will have no usable information about the unit that survived the combat.
  3. It took me weeks to work out methods to bend this event to my will when attempting to determine who killed who in terms of which units did what for the Scipio's Rome mod. And even then there are mis-firings and mis-application of results from time to time because of the reasons outlined above. I have zero desire to leap back into that fetid cesspool of Firaxis-nopes.
  4. It is pretty easy to use UnitPrekill when all you are interested in is which player killed off which unit of which other player and where this unit was killed. But as soon as you start down the path of determining which unit killed which unit, you are in for an interesting experience in lua coding for Civ5.
 
Oh I'm sorry, I should have clarified. I didn't mean for you to perfect the KillFaith feature. I was asking if you could make it so that the promotion that Troller created is tied to a Follower Belief. As it stands, any civ in the game who builds a Heroic Epic receives the promotion if a unit is built in Heroic Epic city. So the belief would be;

Blessed Crusader - Unit trained in city with Heroic Epic receive Crusader promotion, granting +1 faith per kill and +1 faith upon death.

If I'm understanding your above post, the +1 faith on kill would be tedious due to the ranged/melee issue. If so, I'm fine with faith upon death. I can rename the belief to 'Holy Martyrs' or something along those lines. Troller just mentioned that he doesn't know how to get the promotion to apply to only Heroic Epics in cities which have the religion with the belief as the major religion.
 
This gives the ID# of the major religion of a city:
Code:
local iCityMajority = pCity:GetReligiousMajority()
If the city has no majority religion, it will be "-1". If the city only has a Pantheon and has no Major religion as a majority, then it will be "0"

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

This iterator method gives the Beliefs currently in a given religion:
Code:
for i,v in ipairs(Game.GetBeliefsInReligion(eReligion)) do
	-- I believe the 'v' here will be the ID# of the Belief selected for a religion, but I've never used this method to determine which beliefs are in a religion, so am not 100% sure
	if v == GameInfoTypes.BELIEF_SOMETHING_OR_OTHER then
		--do something here
	end
end
If your belief is a Pantheon, it should still work. But if it is a Pantheon and only the desired Panrtheon is in the city, you cannot use this method since the Pantheon is not yet assigned to a Major Religion.

You would have to check for
Code:
local iCityMajority = pCity:GetReligiousMajority()
if iCityMajority == 0 then
	if pPlayer:GetBeliefInPantheon() == GameInfoTypes.BELIEF_SOMETHING_OR_OTHER then
		--do something here
	end
elseif iCityMajority > 0 then
	for i,v in ipairs(Game.GetBeliefsInReligion(iCityMajority)) do
		-- I believe the 'v' here will be the ID# of the Belief selected for a religion, but I've never used this method to determine which beliefs are in a religion, so am not 100% sure
		if v == GameInfoTypes.BELIEF_SOMETHING_OR_OTHER then
			--do something here
		end
	end
end

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

I think your code would want to look like this:
Code:
--BELIEF_SOMETHING_OR_OTHER is a Pantheon
local iHeroicEpic = GameInfoTypes.BUILDING_HEROIC_EPIC
local iCrusaderPromotion = GameInfoTypes.PROMOTION_CRUSADER
local iCrusaderBelief = GameInfoTypes.BELIEF_SOMETHING_OR_OTHER

function CrusaderPromotionFromHeroicAndBelief(iPlayer,iCity,iUnit,bGold,bFaithOrCulture)
	local pPlayer=Players[iPlayer]
	local pCity = pPlayer:GetCityByID(iCity)
	if (pCity:IsHasBuilding(iHeroicEpic)) then
		local pUnit = pPlayer:GetUnitByID(iUnit)
		local iCityMajority = pCity:GetReligiousMajority()
		if iCityMajority == 0 then
			if pPlayer:GetBeliefInPantheon() == iCrusaderBelief then
				pUnit:SetHasPromotion(iCrusaderPromotion,true)
				print("Crusader Promotion given to a unit trained/bought in "..pCity:GetName()) --this appears in the lua console; easy for debugging
			end
		elseif iCityMajority > 0 then
			for i,v in ipairs(Game.GetBeliefsInReligion(iCityMajority)) do
				-- I believe the 'v' here will be the ID# of the Belief selected for a religion, but I've never used this method to determine which beliefs are in a religion, so am not 100% sure
				if v == iCrusaderBelief then
					pUnit:SetHasPromotion(iCrusaderPromotion,true)
					print("Crusader Promotion given to a unit trained/bought in "..pCity:GetName()) --this appears in the lua console; easy for debugging
				end
			end
		end
	end
end
GameEvents.CityTrained.Add(CrusaderPromotionFromHeroicAndBelief)
Otherwise, if it is not a Pantheon, it would need to be:
Code:
--BELIEF_SOMETHING_OR_OTHER is NOT a Pantheon
local iHeroicEpic = GameInfoTypes.BUILDING_HEROIC_EPIC
local iCrusaderPromotion = GameInfoTypes.PROMOTION_CRUSADER
local iCrusaderBelief = GameInfoTypes.BELIEF_SOMETHING_OR_OTHER

function CrusaderPromotionFromHeroicAndBelief(iPlayer,iCity,iUnit,bGold,bFaithOrCulture)
	local pPlayer=Players[iPlayer]
	local pCity = pPlayer:GetCityByID(iCity)
	if (pCity:IsHasBuilding(iHeroicEpic)) then
		local pUnit = pPlayer:GetUnitByID(iUnit)
		local iCityMajority = pCity:GetReligiousMajority()
		if iCityMajority > 0 then
			for i,v in ipairs(Game.GetBeliefsInReligion(iCityMajority)) do
				-- I believe the 'v' here will be the ID# of the Belief selected for a religion, but I've never used this method to determine which beliefs are in a religion, so am not 100% sure
				if v == iCrusaderBelief then
					pUnit:SetHasPromotion(iCrusaderPromotion,true)
					print("Crusader Promotion given to a unit trained/bought in "..pCity:GetName()) --this appears in the lua console; easy for debugging
				end
			end
		end
	end
end
GameEvents.CityTrained.Add(CrusaderPromotionFromHeroicAndBelief)

This is all assuming I haven't made a goof. In any case it needs to be verified to work properly.
 
@Aheadatime, you can set the promotion icon in the UnitPromotions XML table. (See the spoiler below)
Also, regarding the +2 faith, no clue why it does that, but you can always set the faith to +0.5, so that when it fires 2x, it will grant you the desired +1 faith: If it's stupid but it works, it's not stupid

Spoiler :

An example definition of an XML promotion (used within my collab (WIP) Monaco Mod)
Code:
<UnitPromotions>
		<Row>
			<Type>PROMOTION_FOR_THE_KING</Type>
			<Description>TXT_KEY_PROMOTION_FOR_THE_KING</Description>
			<Help>TXT_KEY_PROMOTION_FOR_THE_KING_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			[COLOR="RoyalBlue"]<PortraitIndex>9</PortraitIndex>
			<IconAtlas>EXPANSION2_PROMOTION_ATLAS</IconAtlas>[/COLOR]
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_FOR_THE_KING</PediaEntry>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>false</LostWithUpgrade>
		</Row>
</UnitPromotions>


EDIT: Woops, didn't notice the additional page on the thread....
 
Ok haven't done any debugging yet, but the promotion is still being given to any unit born in a heroic epic city, regardless of religious status of city. This is what the Lua script looked like when I combined Troll's and Lee's;

Spoiler :
GameEvents.CityTrained.Add(function (iPlayer,iCity,iUnit,bGold,bFaithOrCulture)
local pPlayer=Players[iPlayer]
local pCity = pPlayer:GetCityByID(iCity)
if(pCity:IsHasBuilding(GameInfoTypes.BUILDING_HEROIC_EPIC))then
local pUnit = pPlayer:GetUnitByID(iUnit)
pUnit:SetHasPromotion(GameInfoTypes.PROMOTION_CRUSADER,true)
print("Crusader Promotion given to a unit trained/bought in "..pCity:GetName()) --this appears in the lua console; easy for debugging
end
end)

GameEvents.UnitPrekill.Add(function (iPlayer, iUnit, eUnit, iPlotX,iPlotY,bDelay,eByPlayer)
local pPlayer = Players[iPlayer]
local pUnit = pPlayer:GetUnitByID(iUnit)
if(pUnit:IsHasPromotion(GameInfoTypes.PROMOTION_CRUSADER))then
pPlayer:ChangeFaith(1) --1 is the amount of faith. This number can even be a variable! Heck, even a negative number!
print("Unit Destroyed/Disbanded: 1 Faith Added")
end
end)

--BELIEF_BLESSED_CRUSADER is NOT a Pantheon
local iHeroicEpic = GameInfoTypes.BUILDING_HEROIC_EPIC
local iCrusaderPromotion = GameInfoTypes.PROMOTION_CRUSADER
local iCrusaderBelief = GameInfoTypes.BELIEF_BLESSED_CRUSADER

function CrusaderPromotionFromHeroicAndBelief(iPlayer,iCity,iUnit,bGold,bFaithOrCulture)
local pPlayer=Players[iPlayer]
local pCity = pPlayer:GetCityByID(iCity)
if (pCity:IsHasBuilding(iHeroicEpic)) then
local pUnit = pPlayer:GetUnitByID(iUnit)
local iCityMajority = pCity:GetReligiousMajority()
if iCityMajority > 0 then
for i,v in ipairs(Game.GetBeliefsInReligion(iCityMajority)) do
-- I believe the 'v' here will be the ID# of the Belief selected for a religion, but I've never used this method to determine which beliefs are in a religion, so am not 100% sure
if v == iCrusaderBelief then
pUnit:SetHasPromotion(iCrusaderPromotion,true)
print("Crusader Promotion given to a unit trained/bought in "..pCity:GetName()) --this appears in the lua console; easy for debugging
end
end
end
end
end
GameEvents.CityTrained.Add(CrusaderPromotionFromHeroicAndBelief)


I'll try debugging it later tonight when I have some free time. I've been very busy irl with various projects.
 
Ok haven't done any debugging yet, but the promotion is still being given to any unit born in a heroic epic city, regardless of religious status of city. This is what the Lua script looked like when I combined Troll's and Lee's;

Spoiler :
Code:
[COLOR="Red"]GameEvents.CityTrained.Add(function (iPlayer,iCity,iUnit,bGold,bFaithOrCulture)
     local pPlayer=Players[iPlayer]
     local pCity = pPlayer:GetCityByID(iCity)
     if(pCity:IsHasBuilding(GameInfoTypes.BUILDING_HEROIC_EPIC))then
           local pUnit = pPlayer:GetUnitByID(iUnit)
           pUnit:SetHasPromotion(GameInfoTypes.PROMOTION_CRUSADER,true)
           print("Crusader Promotion given to a unit trained/bought in "..pCity:GetName()) --this appears in the lua console; easy for debugging
     end
end)[/COLOR]

GameEvents.UnitPrekill.Add(function (iPlayer, iUnit, eUnit, iPlotX,iPlotY,bDelay,eByPlayer)
       local pPlayer = Players[iPlayer]
       local pUnit = pPlayer:GetUnitByID(iUnit)
       if(pUnit:IsHasPromotion(GameInfoTypes.PROMOTION_CRUSADER))then
            pPlayer:ChangeFaith(1) --1 is the amount of faith. This number can even be a variable! Heck, even a negative number!
            print("Unit Destroyed/Disbanded: 1 Faith Added")
       end
end)

--BELIEF_BLESSED_CRUSADER is NOT a Pantheon
local iHeroicEpic = GameInfoTypes.BUILDING_HEROIC_EPIC
local iCrusaderPromotion = GameInfoTypes.PROMOTION_CRUSADER
local iCrusaderBelief = GameInfoTypes.BELIEF_BLESSED_CRUSADER

function CrusaderPromotionFromHeroicAndBelief(iPlayer,iCity,iUnit,bGold,bFaithOrCulture)
	local pPlayer=Players[iPlayer]
	local pCity = pPlayer:GetCityByID(iCity)
	if (pCity:IsHasBuilding(iHeroicEpic)) then
		local pUnit = pPlayer:GetUnitByID(iUnit)
		local iCityMajority = pCity:GetReligiousMajority()
		if iCityMajority > 0 then
			for i,v in ipairs(Game.GetBeliefsInReligion(iCityMajority)) do
				-- I believe the 'v' here will be the ID# of the Belief selected for a religion, but I've never used this method to determine which beliefs are in a religion, so am not 100% sure
				if v == iCrusaderBelief then
					pUnit:SetHasPromotion(iCrusaderPromotion,true)
					print("Crusader Promotion given to a unit trained/bought in "..pCity:GetName()) --this appears in the lua console; easy for debugging
				end
			end
		end
	end
end
GameEvents.CityTrained.Add(CrusaderPromotionFromHeroicAndBelief)

I'll try debugging it later tonight when I have some free time. I've been very busy irl with various projects.
  1. Use "Code" wraps around game-code to preserve the tabs and the original spacing. The tabs and spacing make it much easier to read code. # button in the advanced response view is the same as manually typing in the code wraps.
  2. This is your problem:
    Code:
    GameEvents.CityTrained.Add(function (iPlayer,iCity,iUnit,bGold,bFaithOrCulture)
         local pPlayer=Players[iPlayer]
         local pCity = pPlayer:GetCityByID(iCity)
         if(pCity:IsHasBuilding(GameInfoTypes.BUILDING_HEROIC_EPIC))then
               local pUnit = pPlayer:GetUnitByID(iUnit)
               pUnit:SetHasPromotion(GameInfoTypes.PROMOTION_CRUSADER,true)
               print("Crusader Promotion given to a unit trained/bought in "..pCity:GetName()) --this appears in the lua console; easy for debugging
         end
    end)
    You need to delete this from the code. Currently you have two "CityTrained" events, one of which is only looking at whether the city has a Heroic Epic, and the other at whether the city has a Heroic Epic and has the Correct Belief being followed by the city. The first overrides the second and makes it look like the second is not working correctly. The offending part that needs to be removed I have highlighted in red in your original code.
 
Ok took a break from the other mods I've been working on to try and wrap this mod up. I've got a few questions, but I'll start with (finally) trying to wrap up the Crusader promotion. As per Lee's instructions, this is what the code looks like;

Spoiler :
Code:
GameEvents.UnitPrekill.Add(function (iPlayer, iUnit, eUnit, iPlotX,iPlotY,bDelay,eByPlayer)
       local pPlayer = Players[iPlayer]
       local pUnit = pPlayer:GetUnitByID(iUnit)
       if(pUnit:IsHasPromotion(GameInfoTypes.PROMOTION_CRUSADE))then
            pPlayer:ChangeFaith(1) --1 is the amount of faith. This number can even be a variable! Heck, even a negative number!
            print("Unit Destroyed/Disbanded: 1 Faith Added")
       end
end)

--BELIEF_BLESSED_CRUSADE is NOT a Pantheon
local iHeroicEpic = GameInfoTypes.BUILDING_HEROIC_EPIC
local iCrusaderPromotion = GameInfoTypes.PROMOTION_CRUSADER
local iCrusaderBelief = GameInfoTypes.BELIEF_BLESSED_CRUSADE

function CrusaderPromotionFromHeroicAndBelief(iPlayer,iCity,iUnit,bGold,bFaithOrCulture)
	local pPlayer=Players[iPlayer]
	local pCity = pPlayer:GetCityByID(iCity)
	if (pCity:IsHasBuilding(iHeroicEpic)) then
		local pUnit = pPlayer:GetUnitByID(iUnit)
		local iCityMajority = pCity:GetReligiousMajority()
		if iCityMajority > 0 then
			for i,v in ipairs(Game.GetBeliefsInReligion(iCityMajority)) do
				-- I believe the 'v' here will be the ID# of the Belief selected for a religion, but I've never used this method to determine which beliefs are in a religion, so am not 100% sure
				if v == iCrusaderBelief then
					pUnit:SetHasPromotion(iCrusaderPromotion,true)
					print("Crusader Promotion given to a unit trained/bought in "..pCity:GetName()) --this appears in the lua console; easy for debugging
				end
			end
		end
	end
end
GameEvents.CityTrained.Add(CrusaderPromotionFromHeroicAndBelief)icAndBelief)

Notice where you typed BLESSED_CRUSADER, I switched it to BLESSED_CRUSADE, as this is what the belief is labeled in my xml files. I then went into Actions and made the lua file an InGameUIAddin. Loaded up the game and tested it with IGE, didn't work. Here's what I was able to find in the Lua log;


Spoiler :
[576197.570] Syntax Error: C:\Users\Leo\Documents\My Games\Sid Meier's Civilization 5\MODS\Religion Enhanced (v 1)\Martyrdom.lua:36: '=' expected near ')'
[576197.570] Runtime Error: Error loading C:\Users\Leo\Documents\My Games\Sid Meier's Civilization 5\MODS\Religion Enhanced (v 1)\Martyrdom.lua.
 
Ok took a break from the other mods I've been working on to try and wrap this mod up. I've got a few questions, but I'll start with (finally) trying to wrap up the Crusader promotion. As per Lee's instructions, this is what the code looks like;

Spoiler :
Code:
GameEvents.UnitPrekill.Add(function (iPlayer, iUnit, eUnit, iPlotX,iPlotY,bDelay,eByPlayer)
       local pPlayer = Players[iPlayer]
       local pUnit = pPlayer:GetUnitByID(iUnit)
       if(pUnit:IsHasPromotion(GameInfoTypes.PROMOTION_CRUSADE))then
            pPlayer:ChangeFaith(1) --1 is the amount of faith. This number can even be a variable! Heck, even a negative number!
            print("Unit Destroyed/Disbanded: 1 Faith Added")
       end
end)

--BELIEF_BLESSED_CRUSADE is NOT a Pantheon
local iHeroicEpic = GameInfoTypes.BUILDING_HEROIC_EPIC
local iCrusaderPromotion = GameInfoTypes.PROMOTION_CRUSADER
local iCrusaderBelief = GameInfoTypes.BELIEF_BLESSED_CRUSADE

function CrusaderPromotionFromHeroicAndBelief(iPlayer,iCity,iUnit,bGold,bFaithOrCulture)
	local pPlayer=Players[iPlayer]
	local pCity = pPlayer:GetCityByID(iCity)
	if (pCity:IsHasBuilding(iHeroicEpic)) then
		local pUnit = pPlayer:GetUnitByID(iUnit)
		local iCityMajority = pCity:GetReligiousMajority()
		if iCityMajority > 0 then
			for i,v in ipairs(Game.GetBeliefsInReligion(iCityMajority)) do
				-- I believe the 'v' here will be the ID# of the Belief selected for a religion, but I've never used this method to determine which beliefs are in a religion, so am not 100% sure
				if v == iCrusaderBelief then
					pUnit:SetHasPromotion(iCrusaderPromotion,true)
					print("Crusader Promotion given to a unit trained/bought in "..pCity:GetName()) --this appears in the lua console; easy for debugging
				end
			end
		end
	end
end
GameEvents.CityTrained.Add(CrusaderPromotionFromHeroicAndBelief)icAndBelief)

Notice where you typed BLESSED_CRUSADER, I switched it to BLESSED_CRUSADE, as this is what the belief is labeled in my xml files. I then went into Actions and made the lua file an InGameUIAddin. Loaded up the game and tested it with IGE, didn't work. Here's what I was able to find in the Lua log;


Spoiler :
[576197.570] Syntax Error: C:\Users\Leo\Documents\My Games\Sid Meier's Civilization 5\MODS\Religion Enhanced (v 1)\Martyrdom.lua:36: '=' expected near ')'
[576197.570] Runtime Error: Error loading C:\Users\Leo\Documents\My Games\Sid Meier's Civilization 5\MODS\Religion Enhanced (v 1)\Martyrdom.lua.
The whole code is needed. The error message is reporting an error that occurs on line #36 of the code, but you have only shown 32 lines of code.

However, having said, the last line of the quoted code is a mess:
Code:
GameEvents.CityTrained.Add(CrusaderPromotionFromHeroicAndBelief[COLOR="Red"])icAndBelief[/COLOR])
If the code in your actual mod-file has the highlighted gunk in red, eliminate the highlighted gunk in red.
 
Took care of that random text and it's working now. I'm starting to think this belief is sort of.. underwhelming.. not to mention exploitable. Not only does it rely upon your units dying (which feels bad in-game, and would be pretty powerful in the hands of the AI ;)), but you can spam scouts and sell them for faith.

So having the promotion award faith per kill instead seems ideal. I know there are references such as the Aztec culture-per-kill and the honor culture-per-barb-kill to study, but after re-reading this thread, you had mentioned that the scripting required for this particular instance (unit trained in heroic epic city with majority followers) is too complex, right Lee?
 
Took care of that random text and it's working now. I'm starting to think this belief is sort of.. underwhelming.. not to mention exploitable. Not only does it rely upon your units dying (which feels bad in-game, and would be pretty powerful in the hands of the AI ;)), but you can spam scouts and sell them for faith.

So having the promotion award faith per kill instead seems ideal. I know there are references such as the Aztec culture-per-kill and the honor culture-per-barb-kill to study, but after re-reading this thread, you had mentioned that the scripting required for this particular instance (unit trained in heroic epic city with majority followers) is too complex, right Lee?

Post #61 Items #3 & #4 describe my feelings on the matter. You would have to script based on using UnitPreKill because there's no way to use such a promotion except as a marker that script-processing ought to ocurr when that unit kills another, and by the time your script can more-or-less-reliably determine which unit killed off which unit, you are already deep into the territory I want no part of. And, oh, BTW, there are a couple of additional conditions under which UnitPreKill can fire which I forgot to mention in Post #61.

There's nothing in UnitPromotions that has an effect ability for when a unit with the promotion kills off another unit except for GoldenAgeValueFromKills. The word 'Kill' does not otherwise occur within the CIV5UnitPromotions.xml file.

William Howard's VMC has some event capabilities added for combat, and Gazebo's CP DLL might also but I cannot remember at the moment whether either of them alter the available commands and tables related to UnitPromotions to allow direct statements within the XML that PROMOTION_X gives YIELD_FAITH when the unit that has PROMOTION_X kills off another unit.
 
And I'm assuming it would equally difficult to have the promotion differentiate between a unit being killed and disbanded, correct?
 
And I'm assuming it would equally difficult to have the promotion differentiate between a unit being killed and disbanded, correct?
For the purposes of the discussion we are having (sort-of, because we are evidently talking past each other) the promotion itself will not do anything. It would merely act as a marker for the lua-script. So that if a unit has Promotion_X, and if an lua-script can determine if a unit with Promotion_X killed off another unit, then the lua-script creates an effect, like adding Faith to the player's score.


Event UnitKilledInCombat will tell you when a unit was killed as a result of a battle, but it provides even less info than UnitPreKill. All it tells you is the type of unit that died, which player the unit belonged to, and which player killed the unit. You actually get no information about the unit that did the killing (if any) nor do you get any data about the individual unit that was killed (like, how much XP did it have, what promotions did it have).

But the real trouble is not in creating effects for the unit that does the dying -- it is in creating effects for the unit that does the killing because of the difficulty in getting reliable information about the individual unit that did the killing. You already have code made for you that handles giving an effect when a certain type of unit is killed or otherwise removed from play -- the hard part is in creating reliable code to do the same sort of thing for when a unit kills off another unit (using a promotion to allow this effect does not make the lua-script more nor less difficult to write because the promotion merely acts as a marker-flag for the lua-script that yes indeed when this particular unit kills another we should do "Z" as included in the remainder of the code).

And in either case (looking for a unit that died or looking for a unit that did the killing) all a promotion like Promotion_X is going to do for you is to act as a marker for whether your lua-script should go ahead and add the effect you want when a unit with Promotion_X dies (or kills off another unit, if that is what you are after).
 
To say that we're talking past each other sounds rude to me. I am (for the most part) understanding your posts.

'Events' trigger in-game (although I'm not sure [in entirety] what would classify as an event.. unlocking a social policy? declaring war? everything?). Lua scripts are required to mod events. UnitPreKill and UnitKilledInCombat are two events that have been coded in an unreliable way by Firaxis, and thus make them difficult for modders to create Lua scripts for.

If I phrase a question 'simply', ie., the aforementioned 'promotion' question regarding disbanding vs. dying, it is merely to get to the point. I understood that a promotion is nothing but XML text defining and referencing the actual promotion, which is based in Lua. I also understood that, given your previous posts, the answer to the question was probably going to be "yes it's too difficult."

I asked for two reasons;

1. In post #61 you said 'when a unit is killed in actual combat, the event (UnitPreKill) fires off twice'. This made me wonder if someone was capable of utilizing the fact that the Event seems to distinguish between a combat death and a disband for the sake of improving the script to the point of being unexploitable (apparently not a word).

2. I feel burdensome requesting Lua help. I'm an autodidact for most of the skills I've picked up in life. If something interests me or acts as an obstacle for some goal I have, I learn about it, accomplish it, and move on. I've tried my hand at reading some Lua tutorials and jumping in, but it's one of those skills that is rather difficult for somebody like myself (I'm no programmer) to roll with. I've got to be a realist about the skills I can and cannot pick up in a reasonable amount of time. I simply am too busy and ignorant to grab a firm handle on Lua atm.

Thus, I appreciated the time and work you and Troller put into the Crusader script and didn't want it to go to waste. So understanding that the script isn't capable of firing when a promoted unit scores a kill, I shot for the next best thing; removing the 'spam scouts and sell them for faith' exploit (with the understanding that the Events involved aren't fun to work with). At least this way, I wouldn't feel like a douche tossing away someone else's time and effort.

I appreciate your help. You're incredibly responsive and put aside a ton of your own time to help others here in the forums. It's very admirable to me and I respect you for it. So to ask for you time and help before turning around and tossing out the work you do doesn't feel good. Paradoxically, in this case, avoiding that chain of events meant asking you for help..
 
Odd. So I was looking through some of the belief tables and saw a few that were unused, such as HolyCityYieldChanges. Decided to toy with it, but it seems incomplete. It doesn't allow science, food, or production, but does allow culture and faith. Unfortunate, because food, production, and science are sorely lacking in the Founder beliefs. Which got me thinking. If I have a Founder belief that provides culture in the Holy City, then spread my religion to another civ's Holy City via a prophet, that city would get the culture from my religion while it's still the majority religion, wouldn't it?

There's also a column called "ResourceRevealed", which seems interesting. Maybe allowing players to spot coal, aluminum, and oil before their respective techs have been reached could be quite powerful (knowing where to expand and which CS to ally with).
 
Anyone know where I can find the Maya's pyramid UB in XML? I've made the shrine available at agriculture, and want to do the same with it's unique counterparts, but can't seem to find Maya's UB.

And has anyone experimented with any of the aforementioned unused tables in the Beliefs file? I tried to create a pantheon belief that gave Horse tiles +1 faith and +50% quantity. The quantity part didn't work, and didn't show up in logs either. Looked like this;
Code:
	<Belief_ResourceQuantityModifiers>
		<Row>
			<BeliefType>BELIEF_CHARIOTS</BeliefType>
			<ResourceType>RESOURCE_HORSE</ResourceType>
			<ResourceQuantityModifier>150</ResourceQuantityModifier>
		</Row>
	</Belief_ResourceQuantityModifiers>

And here's the table I'm referencing in the XML file;

Code:
-<Table name="Belief_ResourceQuantityModifiers">
	<Column name="BeliefType" type="text" reference="Beliefs(Type)"/>
	<Column name="ResourceType" type="text" reference="Resources(Type)"/>
	<Column name="ResourceQuantityModifier" type="integer" default="0"/>
</Table>
 
[..]\Steam\SteamApps\common\Sid Meier's Civilization V\Assets\DLC\Expansion\Gameplay\XML\Buildings\CIV5Buildings_Expansion.xml

Praise Agent Ransack \o/

EDIT: Hey, you edited your post. Anyhow, I have no clue about that second part :/

EDIT2: This is the only (non-scenario-)file which defines BUILDING_MAYA_PYRAMID. I can recall that some files were never re-defined within BNW and that the game simply looks in the G&K expansion files sometimes when using BNW
 
Thanks Troller. I forgot anything outside of Expansion2 existed lol. I'll look through the Expansion XML and fix that up.

I know there's very few UI pros around here, but I'm having an issue with "[NEWLINE]" texts for some of my beliefs, and how they interact with the UI. Some examples of what the text reads;

http://imgur.com/8joYJYT
http://imgur.com/pbUv13j
http://imgur.com/LVHWNbs

And what happens within various sections of the UI because of this;

http://imgur.com/b9GHiHK
http://imgur.com/MUD0VvV

I could simply remove the spacing in between lines, but that creates an unpleasant reading experience when choosing one's beliefs.
 
Two questions.

1. How would I go about this Resource Revealed column? This is what the belief looks like in the XML file;

Code:
<Column name="ResourceRevealed" type="text" default="NULL" reference="Resources(Type)"/>

So would it look like this?

Spoiler :
Code:
<Beliefs>
     <Row>
          <Type>BELIEF_TEST</Type>
          <Description>TXT_KEY_BELIEF_TEST</Description>
          <ShortDescription>TXT_KEY_BELIEF_TEST_SHORT</ShortDescription>
          <Follower>true</Follower>
          <ResourceRevealed>true</ResourceRevealed>
          <ResourceType>RESOURCE_COAL</ResourceType>
     </Row>
</Beliefs>

2. Does anyone know the exact formula for unit faith costs? I looked through the Units file and all of the faith costs are simply production(2). In-game, however, the prices are much, much higher than that in the later eras. I'm thinking there's a multiplicative effect regarding era scaling. If that's true, is this hard-coded, or can I tweak it?
 
1) No clue, I've never modded beliefs/pantheons/religions/whateverelseregardingfaith

2) There is this column in CIV5Eras.xml ([...]\Steam\SteamApps\common\Sid Meier's Civilization V\Assets\DLC\Expansion2\Gameplay\XML\GameInfo\CIV5Eras.xml)
Code:
<FaithCostMultiplier>100</FaithCostMultiplier> (It starts to increase from the Renaissance era and onwards)
I think it does what you mean, though I've never tried changing it up :)
 
Top Bottom