Danmacsch's Lua (and general modding) inquiries

Also, Player:InitUnit() causes UnitSetXY to fire, so you would have even more compounded interest on the confusion. I once got an interminable loop of unit creation trying to use a Player:InitUnit() inside a UnitSetXY function.

Also see the bottom of this post
 
I've circumvented the problem from before by simply creating copies of all mounted units in sql with the relevant changes (workrate+repair build). Just mentioning this if others with a similar problem should happen to fall upon the thread.

Now, yet another inquiry. When a unit is killed, UnitPrekill fires twice, right? First right before the unit is killed and thus still on the plot in question, and second when the unit is killed, and there potentially is a new unit (the one doing the killing) on the plot. On the first firing, bDelay returns true, and on the second it returns false. Right?
Now, I want to check if the unit preforming the kill is of a specific type. I know this is not directly possible without a custom DLL, but workarounds have been done. The unit (the killer) I want to check for is a non-ranged unit, so when bDelay returns false, the killer unit should be on the plot returned by the Event. But then why isn't the following code working. It fires until the highlighted statement and actually does the iterating of units on the plot, but doesn't continue after the unit type check:
Code:
local civilisationBurundiID								= GameInfoTypes["CIVILIZATION_DMS_BURUNDI"]
local unitGanwaID										= GameInfoTypes["UNIT_DMS_GANWA"]

function DMS_GanwaRutaganzwaRugambaHeal(iOwner, iUnit, iUnitType, iX, iY, bDelay, iKiller)
	print("DMS_GanwaRutaganzwaRugambaHeal: bDelay: " .. tostring(bDelay))
	local pPlayer = Players[iKiller]
	if pPlayer and pPlayer:IsEverAlive() and pPlayer:GetCivilizationType() == civilisationBurundiID then
		print("DMS_GanwaRutaganzwaRugambaHeal initializing for unit killed on plot (" .. iX .. "," .. iY .. ")..")
		local pPlot = Map.GetPlot(iX, iY)
		local numUnits = pPlot:GetNumUnits()
		print("DMS_GanwaRutaganzwaRugambaHeal: iterate through numUnits..")
		for i = 0, numUnits do
			[COLOR="Red"]print("DMS_GanwaRutaganzwaRugambaHeal: i = " .. i .. "..")[/COLOR]
			local pKillerUnit = pPlot:GetUnit(i)
			if pKillerUnit and pKillerUnit:GetUnitType() == unitGanwaID then
				print("DMS_GanwaRutaganzwaRugambaHeal: unitGanwaID found on plot where unit was killed..")
				for nearbyPlot in PlotAreaSweepIterator(pPlot, 2, SECTOR_NORTH, DIRECTION_CLOCKWISE, DIRECTION_OUTWARDS, CENTRE_EXCLUDE) do
					if nearbyPlot and nearbyPlot:IsUnit() then
						local pUnit = pPlot:GetUnit(i)
						if pUnit and pUnit:GetOwner(iKiller) then
							print("DMS_GanwaRutaganzwaRugambaHeal: friendly unit found at plot (" .. pPlot:GetX() .. "," .. pPlot:GetY() .. ")..")
							pUnit:ChangeDamage(10)
							print("DMS_GanwaRutaganzwaRugambaHeal: pUnit:ChangeDamage(10)..")

						end
					end
				end
			end
			title = "Rutaganzwa Rugamba"
			text = "A Ganwa has killed an enemy unit. All friendly units if any within a two tile radius has been healed for 10 HP."
			JFD_SendNotification(iKiller, "NOTIFICATION_GENERIC", text, title)
		end
	end
end

if isBurundiCivActive then
	GameEvents.UnitPrekill.Add(DMS_GanwaRutaganzwaRugambaHeal)
end
 
When 'bDelay' is false (ie, the second iteration through the event) 'iKiller' is always '-1', therefore on that run through the code
Code:
local pPlayer = Players[iKiller]
returns unusable information.

My suspicion is that anything you are seeing in the logs is from the 1st time through the event, when 'bDelay' is true and 'ikiller' is the playerID of the player who did the killing.

The following has a lot of extra print-statement code in it so I could 'learn' what was going on with the event whenever it fired. Other than the fact I took out all the confusing stuff for looking at promotions the victorius unit had and matching that to a nearby great general unit, it is the code I use to determine when a Roman Combat unit has victoriously melee attacked and killed an enemy unit.
Spoiler :
Code:
function IsCivInPlay(iCivType)
  for iSlot = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
    local iSlotStatus = PreGame.GetSlotStatus(iSlot)
    if (iSlotStatus == SlotStatus.SS_TAKEN or iSlotStatus == SlotStatus.SS_COMPUTER) then
      if (PreGame.GetCivilization(iSlot) == iCivType) then
        return true
      end
    end
  end
  
  return false
end
--------------------------------------------------------------------------------------------------------------------------------------------------
--Proconsul Combat XP system
--------------------------------------------------------------------------------------------------------------------------------------------------

local iFirstTimeThroughKillerData = "NONE"
local bPrintForDebug = true
local iRequiredCivilization = GameInfoTypes.CIVILIZATION_ROME

function NearProconsulKiller(iOwner, iUnit, iUnitType, iX, iY, bDelay, iKiller)
	if bPrintForDebug then print("prekillListener: Dumping data for bDelay = " .. tostring(bDelay)) end
	if bDelay then
		iFirstTimeThroughKillerData = iKiller
		if bPrintForDebug then 
			print("iOwner: " .. iOwner)
			print("iUnit: " .. iUnit)
			print("iUnitType: " .. iUnitType .. " (" .. GameInfo.Units[iUnitType].Type .. ")")
			print("iX: " .. iX)
			print("iY: " .. iY)
			print("bDelay: " .. tostring(bDelay))
			-- bDelay returns true before unit is killed (before UnitKilledInCombat) and only has one unit on the plot
			-- bDelay returns false after the unit is killed (after UnitKilledInCombat) and an enemy melee unit may be on the same plot at this point
			print("iKiller: " .. iKiller)
		end
		return
	end
	if iOwner == Game.GetActivePlayer() then
		if bPrintForDebug then print("Unit killed belonged to the active player, exiting the function") end
		return
	end
	if bNoBarbXP and Players[iOwner]:IsBarbarian() then
		if bPrintForDebug then print("Unit killed belonged to the Barbarians and Barbarian XP is not allowed for Proconsuls: exiting the function") end
		return
	end
	if iFirstTimeThroughKillerData == -1 then
		if bPrintForDebug then print("iFirstTimeThroughKillerData was set to -1, which means no valid iKiller data from any run-through: exiting the function") end
		iFirstTimeThroughKillerData = "NONE"
		return
	end
	if iFirstTimeThroughKillerData == "NONE" then
		if bPrintForDebug then print("iFirstTimeThroughKillerData was set to NONE, which means no valid iKiller data from any run-through: exiting the function") end
		return
	end
	local pOwnerPlayer = Players[iOwner]
	local pUnitKilled = pOwnerPlayer:GetUnitByID(iUnit)
	if not pUnitKilled:IsCombatUnit() then
		if bPrintForDebug then print("Unit killed was not a combat unit, exiting the function") end
		return
	end
	if pUnitKilled:GetDomainType() ~= iDomainLand then
		if bPrintForDebug then print("Unit killed was not a land combat unit, exiting the function") end
		return
	end

	local pKillerPlayer = Players[iFirstTimeThroughKillerData]
	if bPrintForDebug then print("iFirstTimeThroughKillerData was " .. tostring(iFirstTimeThroughKillerData) .. " before resetting") end

	iFirstTimeThroughKillerData = "NONE"
	if bPrintForDebug then 
		print("pKillerPlayer is set to " .. tostring(pKillerPlayer))
		print("iFirstTimeThroughKillerData was reset to " .. iFirstTimeThroughKillerData)


		print("iOwner: " .. iOwner)
		print("iUnit: " .. iUnit)
		print("iUnitType: " .. iUnitType .. " (" .. GameInfo.Units[iUnitType].Type .. ")")
		print("iX: " .. iX)
		print("iY: " .. iY)
		print("bDelay: " .. tostring(bDelay))
		-- bDelay returns true before unit is killed (before UnitKilledInCombat) and only has one unit on the plot
		-- bDelay returns false after the unit is killed (after UnitKilledInCombat) and an enemy melee unit may be on the same plot at this point
		print("iKiller: " .. iKiller)
	end


	if pKillerPlayer:GetCivilizationType() ~= iRequiredCivilization then
		if bPrintForDebug then print("pKillerPlayer was not the Required Civilization (Scipios Rome), exiting the function") end
		return
	end
	local pPlot = Map.GetPlot(iX, iY)
	local iNumTileUnits = pPlot:GetNumUnits()
	if bPrintForDebug then print("numUnits: " .. iNumTileUnits) end

	if iNumTileUnits > 1 then
		for i = 0, pPlot:GetNumUnits() do
			local pUnit = pPlot:GetUnit(i)
			if pUnit then
				local iPlotUnitOwner = pUnit:GetOwner()
				local iPlotUnitType = pUnit:GetUnitType()

				if pUnit ~= pUnitKilled then
					--this is the "melee" unit that did the killing
					--do stuff here		
				end
				if bPrintForDebug then
					print("Unit's Owner is: " .. iPlotUnitOwner)
					print("UnitType is: " .. iPlotUnitType .. " (" .. GameInfo.Units[iPlotUnitType].Type .. ")")
				end
			end
		end
	end
end
------------------------------------------------------------
---- Game Event Hooks if Scipio is in play
------------------------------------------------------------

if (IsCivInPlay(iRequiredCivilization)) then
	GameEvents.UnitPrekill.Add(NearProconsulKiller)
end
When the victorious unit occupies the tile where the defeated unit was positioned, there can be seen to be up to 3 units 'occupying' that tile:
  1. the defeated unit
  2. the victorious unit
  3. a civilian unit
You will never get useful information about the victorious unit until 'bDelay' is 'false' and 'iKiller' is '-1', hence the need for all the code-gymnastics and 'caching' of the 'iKiller' data.
 
Thanks so much LeeS. This is quite clever. I'll get to incorporating this method into my project.
I think I forgot to show where I was defining variables 'bNoBarbXP' and 'iDomainLand' in the previous post
Code:
local iDomainLand = GameInfoTypes.DOMAIN_LAND
local bNoBarbXP = false
I had those listed at the very top of the lua file I quoted the code from.
 
Hi,

I'm trying to check if a Civilization is embargoed, but my method isn't working, so I must be doing something wrong. I imagine the issue lies in the use of CanStopTradingWithTeam, which I might be using wrongly or something, because it gives me a "attempt to call method 'CanStopTradingWithTeam' (a nil value)" error.

Spoiler :
Code:
local civilisationAinuID						= GameInfoTypes["CIVILIZATION_LITE_AINU"]

function DMS_EmbargoedCivsBonus(iPlayer)
	local iNumCivsEmbargoed = 0
	local pPlayer = Players[iPlayer]		
	if (pPlayer and pPlayer:IsAlive() and pPlayer:GetCivilizationType() == civilisationAinuID) then
		local iNumCivsEmbargoed = 0
		for i = 0, GameDefines.MAX_MAJOR_CIVS - 1, 1 do
			local pOtherCiv = Players[i]
			if pOtherCiv and pOtherCiv:IsAlive() and pOtherCiv ~= pPlayer then
				print("Checking if civ is embargoed: " .. pOtherCiv:GetCivilizationShortDescription() .. "..")
				local iPlayerTeam = pPlayer:GetTeam()
				local pPlayerTeam = Teams[iPlayerTeam]
				local iOtherCivTeam = pOtherCiv:GetTeam()
				local pOtherCivTeam = Teams[iOtherCivTeam]
				if (not pPlayerTeam:IsAtWar(pOtherCivTeam)) then
					print("" .. pPlayer:GetCivilizationShortDescription() .. " is not at war with " .. pOtherCiv:GetCivilizationShortDescription() .. "..")
					[COLOR="DarkOrange"]if (pPlayer:CanStopTradingWithTeam(iOtherCivTeam) == false) then[/COLOR]
						print("" .. pPlayer:GetCivilizationShortDescription() .. " can not stop trading with " .. pOtherCiv:GetCivilizationShortDescription() .. " - are they embargoed?..")
						iNumCivsEmbargoed = iNumCivsEmbargoed + 1
						print("iNumCivsEmbargoed = " .. iNumCivsEmbargoed .. "..")
					end
				end
			end
		end
	end

	return iNumCivsEmbargoed
end
Any help would be great :).
 
CanStopTradingWithTeam isn't a standard method (may be a CP extension?)
 
Oh, okay, that would explain it then. I just thought it was a standard api since it's present in the modiki list of methods. Too bad.

Any other way to detect if a civ is embargoed?
 
Not sure where that entry came from, as it's not in any of the source code (Vanilla, G&K or BNW)

Look in the LeagueOverview UI code to see how that produces the list of currently active resolutions and adapt that code
 
Been looking through the LeagueOverview.lua file to find anything related to embargo of civilizations, but haven't been able to so far.

Any ideas as to what to look for?
 
Sorry for the triple post, but while using IGE I just noticed that the "Set embargo" option actually uses - or rather, attempts to use - something similar to "CanStopTradingWithTeam". When choosing the option this error occurs:
Code:
Runtime Error: E:\Libraries\Documents\My Games\Sid Meier's Civilization 5\MODS\Ingame Editor (v 39)\Panels\IGE_PlayersPanel.lua:373: attempt to call method 'StopTradingWithTeam' (a nil value)
As you suggested the "CanStopTradingWithTeam" method (and likely "StopTradingWithTeam" as well) might have been introduced in the CPP, and if that, then they probably work with that, which I haven't tested. But could it be by some off chance, that these methods existed as standard ones previously and were deleted in one of the last official patches? It seems unlikely and doesn't really matter much - I just found it curious.
 
  1. Everything in the LeagueOverview.lua seems to be manipulating "league" methods, but it is doing so by table-methods and iterating through all the valid types of proposals at any given time. Then it just seems to "NetSendMessage" which resolutions were proposed and the voting results to the rest of the game-core. That file is almost as much fun to attempt to read and parse as Curseword.lua :)
  2. There is this within William's API as XML, which might be a starting place:
    Code:
    <api object="League" method="GetActiveResolutions">
          <ret type="({ID, Type, VoterDecision, ProposerDecision, TurnEnacted})"/>
    </api>
    I'm assuming you will get a table of tables and you would have to iterate through the primary ipairs of the main table to inspect what each "v" has for detailed data. It isn't clear (but from the format William uses I would think not) if a resolution is an "Embargo Joe" type of resolution that you will get the data about who was actually embargoed.
  3. Firaxis certainly did not make it simple. I didn't find anything like I would have added if I were designing the API such as "Player:IsEmbargoed()" or "Team:IsEmbargoed()" that I could see.
  4. I wonder if the place to look is not in the lua for the "Create-A-TradeRoute" panel. Though I'm not sure exactly which file this would be.
 
which might be a starting place:
Code:
<api object="League" method="GetActiveResolutions">
      <ret type="({ID, Type, VoterDecision, ProposerDecision, TurnEnacted})"/>
</api>
I'm assuming you will get a table of tables and you would have to iterate through the primary ipairs of the main table to inspect what each "v" has for detailed data.

Correct - it's how the table of currently active resolutions is built.

The ProposerDecision item is either yes/no, or the id of the target player, so

when v.Type == GameInfoTypes.RESOLUTION_PLAYER_EMBARGO
then iEmbargoedMajor = v.ProposerDecision

Spoiler :
I wonder if the place to look is not in the lua for the "Create-A-TradeRoute" panel
From what I remember, that file gets a list of possible trade routes directly from the DLL and the logic for deciding which trade routes are available (distance, embargo, etc) is all handled within the DLL.
 
I'm having some trouble with PlayerCanTrain that I hope someone might be able to help me sort out.

As so often is the case when people mess around with said GameEvent, I'm trying to manipulate the cost of units, such that under some circumstances unit A is trainable while unit B is not, and under other circumstances unit B is trainable while unit A is not. The situation is further complicated by the fact that it's not one unit I'm trying to manipulate the cost of, it's all Mounted Units in the game, which includes both of a certain civilizations unique units (plus a couple of units introduced by the Enlightenment Era mod, but I'll let that be for now). The certain circumstances under which the different units should be trainable are different levels of a global faith output.

Okay, so I was thinking that I could use the PlayerCanTrain method like this (unique units are coloured for reference, and the DMS_Print function is essentially just Print. The Civilization type is localized elsewhere in the file, as are all the different mounted units and their respective copies):
Spoiler :
Code:
function DMS_MountedUnitsCheaperBasedOnFaith(iPlayer, iUnit)
	local pPlayer = Players[iPlayer]
	if (iUnit == unitCavalryCheaper1ID or iUnit == unitLancerCheaper1ID or iUnit == unitKnightCheaper1ID or iUnit == [COLOR="YellowGreen"]unitTaratineCavalryCheaper1ID[/COLOR] or iUnit == [COLOR="YellowGreen"]unitPtolemaicElephantCheaper1ID[/COLOR] or iUnit == unitCavalryCheaper2ID or iUnit == unitLancerCheaper2ID or iUnit == unitKnightCheaper2ID or iUnit == [COLOR="yellowgreen"]unitTaratineCavalryCheaper2ID[/COLOR] or iUnit == [COLOR="yellowgreen"]unitPtolemaicElephantCheaper2ID[/COLOR] or iUnit == unitCavalryCheaper3ID or iUnit == unitLancerCheaper3ID or iUnit == unitKnightCheaper3ID or iUnit == [COLOR="yellowgreen"]unitTaratineCavalryCheaper3ID[/COLOR] or iUnit == [COLOR="yellowgreen"]unitPtolemaicElephantCheaper3ID[/COLOR]) then
		DMS_Print("DMS_MountedUnitsCheaperBasedOnFaith initializing..")
		if pPlayer:GetCivilizationType() == civilisationID then
			DMS_Print("DMS_MountedUnitsCheaperBasedOnFaith: processing for " .. pPlayer:GetCivilizationShortDescription() .. "..")
			local iFaithLevel = pPlayer:GetTotalFaithPerTurn()
			DMS_Print("DMS_MountedUnitsCheaperBasedOnFaith: iFaithLevel = " .. iFaithLevel .. "..")
			if iUnit == unitCavalryCheaper1ID or iUnit == unitLancerCheaper1ID or iUnit == unitKnightCheaper1ID or iUnit == unitTaratineCavalryCheaper1ID or iUnit == unitPtolemaicElephantCheaper1ID then
				DMS_Print("DMS_MountedUnitsCheaperBasedOnFaith: process for discount level 1 cost units..")
				if iFaithLevel > 5 and iFaithLevel <= 15 then
					DMS_Print("DMS_MountedUnitsCheaperBasedOnFaith: iFaithLevel between 6 and 15 means discount 1 mounted unit costs..")
					return true
				end
			elseif iUnit == unitCavalryCheaper2ID or iUnit == unitLancerCheaper2ID or iUnit == unitKnightCheaper2ID or iUnit == unitTaratineCavalryCheaper2ID or iUnit == unitPtolemaicElephantCheaper2ID then
				DMS_Print("DMS_MountedUnitsCheaperBasedOnFaith: process for discount level 2 cost units..")
				if iFaithLevel > 15 and iFaithLevel <= 25 then
					DMS_Print("DMS_MountedUnitsCheaperBasedOnFaith: iFaithLevel between 16 and 25 means discount 2 mounted unit costs..")
					return true
				end
			elseif iUnit == unitCavalryCheaper3ID or iUnit == unitLancerCheaper3ID or iUnit == unitKnightCheaper3ID or iUnit == unitTaratineCavalryCheaper3ID or iUnit == unitPtolemaicElephantCheaper3ID then
				DMS_Print("DMS_MountedUnitsCheaperBasedOnFaith: process for discount level 3 cost units..")
				if iFaithLevel > 25 then
					DMS_Print("DMS_MountedUnitsCheaperBasedOnFaith: iFaithLevel over 26 means discount 3 mounted unit costs..")
					return true
				end
			end
			return false
		end
		return false -- units above not trainable by other civilizations
	end
	return true -- units not of the above types are trainable
end

GameEvents.PlayerCanTrain.Add(DMS_MountedUnitsCheaperBasedOnFaith)
But it doesn't work as intended. Whenever the total faith output is in the interval [0,5] the mounted units are trainable at the regular cost, but when the faith output surpasses 5, the function returns false and no mounted units are trainable.

Any idea where I'm doing something wrong?

Thanks in advance.
 
I don't have time to test anything, so this can be completely wrong, but it might because you return false outside and after the if statements (so it might always return it regardless of if it meets the conditions); moving the return false to before the return true if statements might fix this. Otherwise, something might be getting confused in the elseif statements.

I would try separating all the if statements and specifically returning false/true for each case. Something like this:

Spoiler :
Code:
function DMS_MountedUnitsCheaperBasedOnFaith(iPlayer, iUnit)
	local pPlayer = Players[iPlayer]

	if (iUnit == unitCavalryCheaper1ID or iUnit == unitLancerCheaper1ID or iUnit == unitKnightCheaper1ID or iUnit == unitTaratineCavalryCheaper1ID or iUnit == unitPtolemaicElephantCheaper1ID or iUnit == unitCavalryCheaper2ID or iUnit == unitLancerCheaper2ID or iUnit == unitKnightCheaper2ID or iUnit == unitTaratineCavalryCheaper2ID or iUnit == unitPtolemaicElephantCheaper2ID or iUnit == unitCavalryCheaper3ID or iUnit == unitLancerCheaper3ID or iUnit == unitKnightCheaper3ID or iUnit == unitTaratineCavalryCheaper3ID or iUnit == unitPtolemaicElephantCheaper3ID) then

		if pPlayer:GetCivilizationType() == civilisationID then

			local iFaithLevel = pPlayer:GetTotalFaithPerTurn()

			if iUnit == unitCavalryCheaper1ID or iUnit == unitLancerCheaper1ID or iUnit == unitKnightCheaper1ID or iUnit == unitTaratineCavalryCheaper1ID or iUnit == unitPtolemaicElephantCheaper1ID then
				if iFaithLevel > 5 and iFaithLevel <= 15 then
					return true
				else
					return false
				end
			end

			if iUnit == unitCavalryCheaper2ID or iUnit == unitLancerCheaper2ID or iUnit == unitKnightCheaper2ID or iUnit == unitTaratineCavalryCheaper2ID or iUnit == unitPtolemaicElephantCheaper2ID then
				if iFaithLevel > 15 and iFaithLevel <= 25 then
					return true
				else
					return false
				end
			end

			if iUnit == unitCavalryCheaper3ID or iUnit == unitLancerCheaper3ID or iUnit == unitKnightCheaper3ID or iUnit == unitTaratineCavalryCheaper3ID or iUnit == unitPtolemaicElephantCheaper3ID then
				if iFaithLevel > 25 then
					return true
				else
					return false
				end
			end

		else
			return false 
		end

	end

	return true 

end

GameEvents.PlayerCanTrain.Add(DMS_MountedUnitsCheaperBasedOnFaith)
 
Alternatively, also try it only returning false:

Spoiler :
Code:
function DMS_MountedUnitsCheaperBasedOnFaith(iPlayer, iUnit)
	local pPlayer = Players[iPlayer]

	if (iUnit == unitCavalryCheaper1ID or iUnit == unitLancerCheaper1ID or iUnit == unitKnightCheaper1ID or iUnit == unitTaratineCavalryCheaper1ID or iUnit == unitPtolemaicElephantCheaper1ID or iUnit == unitCavalryCheaper2ID or iUnit == unitLancerCheaper2ID or iUnit == unitKnightCheaper2ID or iUnit == unitTaratineCavalryCheaper2ID or iUnit == unitPtolemaicElephantCheaper2ID or iUnit == unitCavalryCheaper3ID or iUnit == unitLancerCheaper3ID or iUnit == unitKnightCheaper3ID or iUnit == unitTaratineCavalryCheaper3ID or iUnit == unitPtolemaicElephantCheaper3ID) then

		if pPlayer:GetCivilizationType() == civilisationID then

			local iFaithLevel = pPlayer:GetTotalFaithPerTurn()

			if iUnit == unitCavalryCheaper1ID or iUnit == unitLancerCheaper1ID or iUnit == unitKnightCheaper1ID or iUnit == unitTaratineCavalryCheaper1ID or iUnit == unitPtolemaicElephantCheaper1ID then
				if iFaithLevel < 5 or iFaithLevel >= 15 then
					return false
				end
			end

			if iUnit == unitCavalryCheaper2ID or iUnit == unitLancerCheaper2ID or iUnit == unitKnightCheaper2ID or iUnit == unitTaratineCavalryCheaper2ID or iUnit == unitPtolemaicElephantCheaper2ID then
				if iFaithLevel < 15 or iFaithLevel >= 25 then
					return false
				end
			end

			if iUnit == unitCavalryCheaper3ID or iUnit == unitLancerCheaper3ID or iUnit == unitKnightCheaper3ID or iUnit == unitTaratineCavalryCheaper3ID or iUnit == unitPtolemaicElephantCheaper3ID then
				if iFaithLevel < 25 then
					return false
				end
			end

		else
			return false 
		end

	end

	return true 

end

GameEvents.PlayerCanTrain.Add(DMS_MountedUnitsCheaperBasedOnFaith)
 
Moving the return false to before the return true if statements didn't work, and neither did splitting the if then elseif then [etc] end statements.

I'll attempt not using the return true statements and see if that fixes it. Thanks :).
 
Back
Top Bottom