1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

How to prevent teams to declare war

Discussion in 'Civ4 - Creation & Customization' started by Paolo80, Jul 8, 2020.

  1. Paolo80

    Paolo80 Chieftain

    Joined:
    Dec 20, 2019
    Messages:
    41
    Gender:
    Male
    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?
     
  2. f1rpo

    f1rpo plastics

    Joined:
    May 22, 2014
    Messages:
    735
    Location:
    Germany
    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)
     
  3. Paolo80

    Paolo80 Chieftain

    Joined:
    Dec 20, 2019
    Messages:
    41
    Gender:
    Male
    Now it works, only I set iGameTurn <= 19

    Thank you
     
  4. f1rpo

    f1rpo plastics

    Joined:
    May 22, 2014
    Messages:
    735
    Location:
    Germany
    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:
     
    Paolo80 likes this.

Share This Page