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
local pPlayer = Players[iKiller]
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
I think I forgot to show where I was defining variables 'bNoBarbXP' and 'iDomainLand' in the previous postThanks so much LeeS. This is quite clever. I'll get to incorporating this method into my project.
local iDomainLand = GameInfoTypes.DOMAIN_LAND
local bNoBarbXP = false
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
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)
<api object="League" method="GetActiveResolutions">
<ret type="({ID, Type, VoterDecision, ProposerDecision, TurnEnacted})"/>
</api>
which might be a starting place: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.Code:<api object="League" method="GetActiveResolutions"> <ret type="({ID, Type, VoterDecision, ProposerDecision, TurnEnacted})"/> </api>
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 wonder if the place to look is not in the lua for the "Create-A-TradeRoute" panel
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)
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)
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)