• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Implementing Triple Battles

rigbycwts

Hmm, hmm.
98
Posts
11
Years
    • Seen Feb 22, 2019
    Out of boredom, I tried to add Triple Battles to Luka's Elite Battle by reading parts of PokeBattle_Battle and PokeBattle_DynamicBattle, and doing the following:

    In PokeBattle_Battle:

    First, in line 235, I added this:
    Code:
    attr_accessor(:triplebattle) #Triple Battle Flag
    Next, in line 312, which is inside initialize, I added this:
    Code:
    @triplebattle = false
    Then, at line 454, just above def pbWeather, I added this function:
    Code:
    def pbTripleBattleAllowed?
        if !@fullparty && @party.length>MAXPARTYSIZE
          return false
        end
        _opponent=@opponent
        _player=@player
        # Wild battle
        if !_opponent
          return false # No wild triple battles happen in the official games
        #end
        # Trainer battle
        else
          if _opponent.is_a?(Array)
            if _opponent.length==1
              _opponent=_opponent[0]
            elsif _opponent.length>=2 # Triple battles do not come in tags.
              return false
            end
          end
          _player=_player
          if _player.is_a?(Array)
            if _player.length==1
              _player=_player[0]
            elsif _player.length>=2 # Triple battles do not come in tags.
              return false
            end
          end
            sendout1=pbFindNextUnfainted(@party2,0)
            sendout2=pbFindNextUnfainted(@party2,sendout1+1)
            sendout3=pbFindNextUnfainted(@party2,sendout1+2)
            return false if sendout1<0 || sendout2<0 || sendout3<0
        end
          
        sendout1=pbFindNextUnfainted(@party1,0)
        sendout2=pbFindNextUnfainted(@party1,sendout1+1)
        sendout3=pbFindNextUnfainted(@party1,sendout1+2)
        if sendout1<0 || sendout2<0 || sendout3<0
          return false
        else
          return true
        end
      end
    In PokeBattle_DynamicBattle:
    I add this at line 107:
    Code:
        elsif @triplebattle
        #=======================================
        # Initialize opponents in triple battles
        #=======================================
          if @opponent.is_a?(Array)
            if @opponent.length==1
              @opponent=@opponent[0]
            elsif @opponent.length>=2
              raise _INTL("Opponents with zero or more than one person are not allowed")
            end
          end
          if @player.is_a?(Array)
            if @player.length==1
              @player=@player[0]
            elsif @player.length>=2
              raise _INTL("Player trainers with zero or more than one person are not allowed")
            end
          end
          @scene.pbStartBattle(self)
          pbDisplayPaused(_INTL("{1}\r\nwould like to battle!",@opponent.fullname))
          sendout1=pbFindNextUnfainted(@party2,0)
          sendout2=pbFindNextUnfainted(@party2,sendout1+1)
          sendout3=pbFindNextUnfainted(@party2,sendout1+2)
          if sendout1 < 0 || sendout2 < 0 || sendout3 < 0
            raise _INTL("Opponent doesn't have three unfainted Pokémon")
          end
          pbDisplayBrief(_INTL("{1} sent\r\nout {2}, {3},\r\nand {4}!",
          @opponent.fullname,@party2[sendout1].name,@party2[sendout2].name,@party2[sendout3].name))
          @battlers[1].pbInitialize(@party2[sendout1],sendout1,false)
          @battlers[3].pbInitialize(@party2[sendout2],sendout2,false)
          @battlers[5].pbInitialize(@party2[sendout3],sendout3,false)
          pbSendOut(1,@party2[sendout1])
    And in line 184:
    Code:
        elsif @triplebattle
        #=====================================
        # Initialize players in triple battles
        #=====================================
          sendout1=pbFindNextUnfainted(@party1,0)
          sendout2=pbFindNextUnfainted(@party1,sendout1+1)
          sendout3=pbFindNextUnfainted(@party1,sendout1+2)
          if sendout1 < 0 || sendout2 < 0 || sendout3 < 0
            raise _INTL("Player doesn't have three unfainted Pokémon")
          end
          pbDisplayBrief(_INTL("Go, {1}, {2} and {3}!",@party1[sendout1].name,@party1[sendout2].name,@party1[sendout3].name))
          @battlers[0].pbInitialize(@party1[sendout1],sendout1,false)
          @battlers[2].pbInitialize(@party1[sendout2],sendout2,false)
          @battlers[4].pbInitialize(@party1[sendout3],sendout3,false)
          pbSendOut(0,@party1[sendout1])
    Currently, I'm stuck on where to modify next, but I was thinking on making Triple Battles exclusive to the new battle system only. At first, I have thought of the graphics, but I got nervous on which section to modify next: either PokeBattle_DynamicScene, PokeBattle_UI, or PokeBattle_Sprites. Any help would be appreciated.

    EDIT: Link to Scripts.rxdata in case needed: https://www.dropbox.com/s/edgya8v7cir6ui2/scripts.zip?dl=0
     
    Last edited:
    67
    Posts
    12
    Years
  • That would be a great feature to implement! Maybe also worth looking into these swarm battles they introduced in the later games, whereas you face 5 wild pokemon or so
     
    Back
    Top