Lort Krassbeter
Chieftain
Hi,
so am trying to prevent a player from declaring war between turns and remember the declarer/declaree to declare war automatically at the start of the next turn.
This is what I tried:
However, the event GameEvents.CanDeclareWar does not work the way I thought.
Instead of fireing when someone tries to declare war it fires multiple times on the beginning of the turn with all possible combinations of players that have already met.
So is there any other event I could use to do this? If not I also had another idea: Since I only care about human players in a game I could replace the popup lua file for the war declaration popup with my own version that remembers the user but declares war on the beginning of the next turn. But so far I have only been updating XML files by adding an action to the mod. How can I achieve an update/replacement of a lua game file?
Thanks in advance
so am trying to prevent a player from declaring war between turns and remember the declarer/declaree to declare war automatically at the start of the next turn.
This is what I tried:
Code:
local declareWarNextTurn = {}
function OnCanDeclareWar(t1, t2)
declareWarNextTurn[t1] = t2
return false
end
GameEvents.CanDeclareWar.Add(OnCanDeclareWar)
function OnActivePlayerTurnStart()
for t1, t2 in pairs(declareWarNextTurn) do
if t1==Players[Game.GetActivePlayer()]:GetTeam() then
Network.SendChangeWar(t2, true)
end
end
end
Events.ActivePlayerTurnStart.Add(OnActivePlayerTurnStart)
Instead of fireing when someone tries to declare war it fires multiple times on the beginning of the turn with all possible combinations of players that have already met.
So is there any other event I could use to do this? If not I also had another idea: Since I only care about human players in a game I could replace the popup lua file for the war declaration popup with my own version that remembers the user but declares war on the beginning of the next turn. But so far I have only been updating XML files by adding an action to the mod. How can I achieve an update/replacement of a lua game file?
Thanks in advance