Craig_Sutter
Deity
I use the following code to set a permanent peace between two civs, a major and a minor, which are to be permanently at peace.
The problem is, I am still able to declare war with all its repercussions. This is despite the print statement coming out and no lua.log errors.
Does the function not work??
The problem is, I am still able to declare war with all its repercussions. This is despite the print statement coming out and no lua.log errors.
Does the function not work??
Code:
--At the end of the first turn, HRE declares war on the FIC. We want TeamIDs and Teams, not PlayerIDs.
--Then set permanent war, both ways.
function HREFICPeace()
if Game.GetGameTurn() == 0 then
local HRETeam
local HRETeamID
local FICTeam
local FICTeamID
local HRE
local FIC
-- Set up HRE Player
for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do
local pHRE = Players[iPlayer]
if (GameInfo.Civilizations.CIVILIZATION_PERSIA.ID == pHRE:GetCivilizationType()) then
HRE = pHRE
HRETeamID = HRE:GetTeam();
HRETeam= Teams[ HRE:GetTeam() ]
end
end
-- Set up FIC Player
for iPlayer=GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_CIV_PLAYERS-1, 1 do
local pFIC = Players[iPlayer]
if (GameInfo.MinorCivilizations.MINOR_CIV_FREE_IMPERIAL_CITIES.ID == pFIC:GetMinorCivType()) then
FIC = pFIC
FICTeamID = FIC:GetTeam();
FICTeam= Teams[ FIC:GetTeam() ]
end
end
-- Declare war and set permanent war
if(FIC:IsAlive() and HRE:IsAlive() ) then
HRETeam:SetPermanentWarPeace(FICTeamID, true);
FICTeam:SetPermanentWarPeace(HRETeamID, true);
[COLOR="red"]print (HRE:GetName() ,"...is at peace with... ", FIC:GetName());[/COLOR]
end
end
end
Events.ActivePlayerTurnEnd.Add(HREFICPeace)