• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

How to prevent teams to declare war

Paolo80

Chieftain
Joined
Dec 20, 2019
Messages
85
Hi guys,

I did a scenario and I would want to prevent teams to declare war until a certain turn.

e.g. Until the 19th turn no team can declare war to each other. After the 19th turn every team can declare war to each other.

I wrote this code, but it only force a team to make peace with other but it doesn't prevent a team to declare war. So every team can declare war to other teams for one turn.

Code:
def onBeginPlayerTurn(self, argsList):
        'Called at the beginning of a players turn'
        iGameTurn, iPlayer = argsList
        
        if iGameTurn < 19:
            for i in range(4):
                for j in range(4):
                    eTeam = gc.getTeam(i)
                    if i == j:
                        j = j + 1
                    else:
                        eTeam.makePeace(j)

How could I do?
 
I saw your post in your "Four Emperors" thread, but forgot about it again. Looks like you've made some progress already. setPermanentWarPeace might be the function you're looking for (not tested, no proper indentation):
Code:
if iGameTurn == 0 or iGameTurn == 19:
   for i in range(4):
       for j in range(4):
           if i == j:
               continue
           bPeace = (iGameTurn == 0)
           gc.getTeam(i).setPermanentWarPeace(j, bPeace)
 
setPermanentWarPeace should be remembered by the DLL until it is called again (for the same pair of teams). Even gets stored in savegames. Doesn't hurt of course to set it on each turn. Anyway, so long as it works ... :thumbsup:
 
Back
Top Bottom