How to check relations between civs

kable

Chieftain
Joined
Jul 30, 2016
Messages
3
For my mod I need to check on every new turn whether the relations between the current player and other players have changed (specifically, if the player has been declared war on/declared war on other player/made peace).

Anyone has an idea on how to do this?
 
Code:
function TeamRelationChanged(iFromTeam,iToTeam)
       --run code here
end

GameEvents.DeclareWar.Add(TeamRelationChanged)
GameEvents.MakePeace.Add(TeamRelationChanged)
These two lua hooks fire whenever two teams make peace or declare war. This fires immediately upon such a declaration, instead of every turn. You can use a for-loop to determine which players are on the team(s).
(War and Peace Declarations, as well as Techs, are always shared across teams. Usually, each team consists of only one player however.)

--
You could also use a PlayerDoTurn as you mentioned. It would however get more complicated to check for relation changes this way. (checking for war/peace is easy, checking for changes in those is difficult (but not undoable) this way)
 
Code:
function TeamRelationChanged(iFromTeam,iToTeam)
       --run code here
end

GameEvents.DeclareWar.Add(TeamRelationChanged)
GameEvents.MakePeace.Add(TeamRelationChanged)
These two lua hooks fire whenever two teams make peace or declare war. This fires immediately upon such a declaration, instead of every turn. You can use a for-loop to determine which players are on the team(s).
(War and Peace Declarations, as well as Techs, are always shared across teams. Usually, each team consists of only one player however.)

--
You could also use a PlayerDoTurn as you mentioned. It would however get more complicated to check for relation changes this way. (checking for war/peace is easy, checking for changes in those is difficult (but not undoable) this way)

Thank you very much! I will try this
 
Back
Top Bottom