• 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?".
  • Our weekly protagonist poll is now up! Vote for your favorite Kanto protagonist in the poll by clicking here.
  • 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.

[Essentials v16] Sky Battles + Inverse Battles

  • 1,224
    Posts
    10
    Years
    Place this script in its own section above the main.  This will allow you to have sky battles and/or inverse battles

    When copying and pasting scripts from pokecommunity, use Thread Tools -> Printable Version
    There is a formatting problem that breaks some scripts. If you encounter a "Syntax error", your lack of reading this warning is most likely the cause.

    Code:
    def pbWildBattle(species,level,variable=nil,canescape=true,canlose=false,skybattle=false,inverse=false)
      if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
        if $Trainer.pokemonCount>0
          Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
        end
        pbSet(variable,1)
        $PokemonGlobal.nextBattleBGM=nil
        $PokemonGlobal.nextBattleME=nil
        $PokemonGlobal.nextBattleBack=nil
        return true
      end
      # Sky battle eligibility for player
      if skybattle
        count=0
        for poke in $Trainer.party
          count+=1 if pbCanSkyBattle?(poke)
        end
        if count==0
          Kernel.pbMessage(_INTL("You don't have any eligible pokemon for a sky battle"))
          return false
        end
      end
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getID(PBSpecies,species)
      end
      handled=[nil]
      Events.onWildBattleOverride.trigger(nil,species,level,handled)
      if handled[0]!=nil
        return handled[0]
      end
      currentlevels=[]
      for i in $Trainer.party
        currentlevels.push(i.level)
      end
      genwildpoke=pbGenerateWildPokemon(species,level)
      Events.onStartBattle.trigger(nil,genwildpoke)
      if skybattle && !pbCanSkyBattle?(genwildpoke)
        Kernel.pbMessage(_INTL("This pokemon can't fight in a sky battle!"))
        return false
      end
      scene=pbNewBattleScene
      battle=PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke],$Trainer,nil,skybattle,inverse)
      battle.internalbattle=true
      battle.cantescape=!canescape
      pbPrepareBattle(battle)
      decision=0
      pbBattleAnimation(pbGetWildBattleBGM(species)) { 
         pbSceneStandby {
            decision=battle.pbStartBattle(canlose)
         }
         for i in $Trainer.party; (i.makeUnmega rescue nil); end
         if $PokemonGlobal.partner
           pbHealAll
           for i in $PokemonGlobal.partner[3]
             i.heal
             i.makeUnmega rescue nil
           end
         end
         if decision==2 || decision==5 # if loss or draw
           if canlose
             for i in $Trainer.party; i.heal; end
             for i in 0...10
               Graphics.update
             end
    #       else
    #         $game_system.bgm_unpause
    #         $game_system.bgs_unpause
    #         Kernel.pbStartOver
           end
         end
         Events.onEndBattle.trigger(nil,decision,canlose)
      }
      Input.update
      pbSet(variable,decision)
      Events.onWildBattleEnd.trigger(nil,species,level,decision)
      return (decision!=2)
    end
    
    def pbDoubleWildBattle(species1,level1,species2,level2,variable=nil,canescape=true,canlose=false,skybattle=false,inverse=false)
      if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
        if $Trainer.pokemonCount>0
          Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
        end
        pbSet(variable,1)
        $PokemonGlobal.nextBattleBGM=nil
        $PokemonGlobal.nextBattleME=nil
        $PokemonGlobal.nextBattleBack=nil
        return true
      end
      if species1.is_a?(String) || species1.is_a?(Symbol)
        species1=getID(PBSpecies,species1)
      end
      if species2.is_a?(String) || species2.is_a?(Symbol)
        species2=getID(PBSpecies,species2)
      end
      currentlevels=[]
      for i in $Trainer.party
        currentlevels.push(i.level)
      end
      genwildpoke=pbGenerateWildPokemon(species1,level1)
      genwildpoke2=pbGenerateWildPokemon(species2,level2)
      Events.onStartBattle.trigger(nil,genwildpoke)
      if skybattle && (!pbCanSkyBattle?(genwildpoke) || !pbCanSkyBattle?(genwildpoke2))
        Kernel.pbMessage(_INTL("These pokemon can't fight in a sky battle!"))
        return false
      end
      scene=pbNewBattleScene
      if $PokemonGlobal.partner
        othertrainer=PokeBattle_Trainer.new(
           $PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
        othertrainer.id=$PokemonGlobal.partner[2]
        othertrainer.party=$PokemonGlobal.partner[3]
        combinedParty=[]
        for i in 0...$Trainer.party.length
          combinedParty[i]=$Trainer.party[i]
        end
        for i in 0...othertrainer.party.length
          combinedParty[6+i]=othertrainer.party[i]
        end
        battle=PokeBattle_Battle.new(scene,combinedParty,[genwildpoke,genwildpoke2],
           [$Trainer,othertrainer],nil,skybattle,inverse)
        battle.fullparty1=true
      else
        battle=PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke,genwildpoke2],
           $Trainer,nil,skybattle,inverse)
        battle.fullparty1=false
      end
      battle.internalbattle=true
      battle.doublebattle=battle.pbDoubleBattleAllowed?()
      battle.cantescape=!canescape
      pbPrepareBattle(battle)
      decision=0
      pbBattleAnimation(pbGetWildBattleBGM(species1)) { 
         pbSceneStandby {
            decision=battle.pbStartBattle(canlose)
         }
         for i in $Trainer.party; (i.makeUnmega rescue nil); end
         if $PokemonGlobal.partner
           pbHealAll
           for i in $PokemonGlobal.partner[3]
             i.heal
             i.makeUnmega rescue nil
           end
         end
         if decision==2 || decision==5
           if canlose
             for i in $Trainer.party; i.heal; end
             for i in 0...10
               Graphics.update
             end
    #       else
    #         $game_system.bgm_unpause
    #         $game_system.bgs_unpause
    #         Kernel.pbStartOver
           end
         end
         Events.onEndBattle.trigger(nil,decision,canlose)
      }
      Input.update
      pbSet(variable,decision)
      return (decision!=2 && decision!=5)
    end
    
    
    def pbTrainerBattle(trainerid,trainername,endspeech,
                        doublebattle=false,trainerparty=0,canlose=false,variable=nil,
                        skybattle=false,inverse=false)
      if $Trainer.pokemonCount==0
        Kernel.pbMessage(_INTL("SKIPPING BATTLE...")) if $DEBUG
        return false
      end
      # Sky battle eligibility for player
      if skybattle
        count=0
        for poke in $Trainer.party
          count+=1 if pbCanSkyBattle?(poke)
        end
        if count==0
          Kernel.pbMessage(_INTL("You don't have any eligible pokemon for a sky battle"))
          return false
        end
      end
      if !$PokemonTemp.waitingTrainer && $Trainer.ablePokemonCount>1 &&
         pbMapInterpreterRunning?
        thisEvent=pbMapInterpreter.get_character(0)
        triggeredEvents=$game_player.pbTriggeredTrainerEvents([2],false)
        otherEvent=[]
        for i in triggeredEvents
          if i.id!=thisEvent.id && !$game_self_switches[[$game_map.map_id,i.id,"A"]]
            otherEvent.push(i)
          end
        end
        if otherEvent.length==1
          trainer=pbLoadTrainer(trainerid,trainername,trainerparty)
          Events.onTrainerPartyLoad.trigger(nil,trainer)
          if !trainer
            pbMissingTrainer(trainerid,trainername,trainerparty)
            return false
          end
          if trainer[2].length<=6 # 3
            $PokemonTemp.waitingTrainer=[trainer,thisEvent.id,endspeech]
            return false
          end
        end
      end
      trainer=pbLoadTrainer(trainerid,trainername,trainerparty)
      Events.onTrainerPartyLoad.trigger(nil,trainer)
      if !trainer
        pbMissingTrainer(trainerid,trainername,trainerparty)
        return false
      end
      if $PokemonGlobal.partner && ($PokemonTemp.waitingTrainer || doublebattle)
        othertrainer=PokeBattle_Trainer.new(
           $PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
        othertrainer.id=$PokemonGlobal.partner[2]
        othertrainer.party=$PokemonGlobal.partner[3]
        playerparty=[]
        for i in 0...$Trainer.party.length
          playerparty[i]=$Trainer.party[i]
        end
        for i in 0...othertrainer.party.length
          playerparty[6+i]=othertrainer.party[i]
        end
        fullparty1=true
        playertrainer=[$Trainer,othertrainer]
        doublebattle=true
      else
        playerparty=$Trainer.party
        playertrainer=$Trainer
        fullparty1=false
      end
      if $PokemonTemp.waitingTrainer
        combinedParty=[]
        fullparty2=false
        if false
          if $PokemonTemp.waitingTrainer[0][2].length>3
            raise _INTL("Opponent 1's party has more than three Pokémon, which is not allowed")
          end
          if trainer[2].length>3
            raise _INTL("Opponent 2's party has more than three Pokémon, which is not allowed")
          end
        elsif $PokemonTemp.waitingTrainer[0][2].length>3 || trainer[2].length>3
          for i in 0...$PokemonTemp.waitingTrainer[0][2].length
            combinedParty[i]=$PokemonTemp.waitingTrainer[0][2][i]
          end
          for i in 0...trainer[2].length
            combinedParty[6+i]=trainer[2][i]
          end
          fullparty2=true
        else
          for i in 0...$PokemonTemp.waitingTrainer[0][2].length
            combinedParty[i]=$PokemonTemp.waitingTrainer[0][2][i]
          end
          for i in 0...trainer[2].length
            combinedParty[3+i]=trainer[2][i]
          end
          fullparty2=false
        end
        #Sky battle eligibility for opponent
        if skybattle
          count=0
          for poke in combinedParty
            count+=1 if pbCanSkyBattle?(poke)
          end
          if count==0
            Kernel.pbMessage(_INTL("The opponents don't have any eligible pokemon for a sky battle"))
            return false
          end
        end
        scene=pbNewBattleScene
        battle=PokeBattle_Battle.new(scene,playerparty,combinedParty,playertrainer,
           [$PokemonTemp.waitingTrainer[0][0],trainer[0]],skybattle,inverse)
        trainerbgm=pbGetTrainerBattleBGM(
           [$PokemonTemp.waitingTrainer[0][0],trainer[0]])
        battle.fullparty1=fullparty1
        battle.fullparty2=fullparty2
        battle.doublebattle=battle.pbDoubleBattleAllowed?()
        battle.endspeech=$PokemonTemp.waitingTrainer[2]
        battle.endspeech2=endspeech
        battle.items=[$PokemonTemp.waitingTrainer[0][1],trainer[1]]
      else
        #Sky battle eligibility for opponent
        if skybattle
          count=0
          for poke in trainer[2]
            count+=1 if pbCanSkyBattle?(poke)
          end
          if count==0
            Kernel.pbMessage(_INTL("The opponents don't have any eligible pokemon for a sky battle"))
            return false
          end
        end
        scene=pbNewBattleScene
        battle=PokeBattle_Battle.new(scene,playerparty,trainer[2],playertrainer,trainer[0],skybattle,inverse)
        battle.fullparty1=fullparty1
        battle.doublebattle=doublebattle ? battle.pbDoubleBattleAllowed?() : false
        battle.endspeech=endspeech
        battle.items=trainer[1]
        trainerbgm=pbGetTrainerBattleBGM(trainer[0])
      end
      if Input.press?(Input::CTRL) && $DEBUG
        Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
        Kernel.pbMessage(_INTL("AFTER LOSING..."))
        Kernel.pbMessage(battle.endspeech)
        Kernel.pbMessage(battle.endspeech2) if battle.endspeech2
        if $PokemonTemp.waitingTrainer
          pbMapInterpreter.pbSetSelfSwitch($PokemonTemp.waitingTrainer[1],"A",true)
          $PokemonTemp.waitingTrainer=nil
        end
        return true
      end
      Events.onStartBattle.trigger(nil,nil)
      battle.internalbattle=true
      pbPrepareBattle(battle)
      restorebgm=true
      decision=0
      Audio.me_stop
      pbBattleAnimation(trainerbgm,trainer[0].trainertype,trainer[0].name) { 
         pbSceneStandby {
            decision=battle.pbStartBattle(canlose)
         }
         for i in $Trainer.party; (i.makeUnmega rescue nil); (i.makeUnprimal rescue nil); end
         if $PokemonGlobal.partner
           pbHealAll
           for i in $PokemonGlobal.partner[3]
             i.heal
             i.makeUnmega rescue nil
             i.makeUnprimal rescue nil
           end
         end
         if decision==2 || decision==5
           if canlose
             for i in $Trainer.party; i.heal; end
             for i in 0...10
               Graphics.update
             end
    #       else
    #         $game_system.bgm_unpause
    #         $game_system.bgs_unpause
    #         Kernel.pbStartOver
           end
         end
         Events.onEndBattle.trigger(nil,decision,canlose)
         if decision==1
           if $PokemonTemp.waitingTrainer
             pbMapInterpreter.pbSetSelfSwitch($PokemonTemp.waitingTrainer[1],"A",true)
           end
         end
      }
      Input.update
      pbSet(variable,decision)
      $PokemonTemp.waitingTrainer=nil
      return (decision==1)
    end
    
    def pbDoubleTrainerBattle(trainerid1, trainername1, trainerparty1, endspeech1,
                              trainerid2, trainername2, trainerparty2, endspeech2, 
                              canlose=false,variable=nil,skybattle=false,inverse=false)
      # Sky battle eligibility for player
      if skybattle
        count=0
        for poke in $Trainer.party
          count+=1 if pbCanSkyBattle?(poke)
        end
        if count==0
          Kernel.pbMessage(_INTL("You don't have any eligible pokemon for a sky battle"))
          return false
        end
      end
      trainer1=pbLoadTrainer(trainerid1,trainername1,trainerparty1)
      Events.onTrainerPartyLoad.trigger(nil,trainer1)
      if !trainer1
        pbMissingTrainer(trainerid1,trainername1,trainerparty1)
      end
      trainer2=pbLoadTrainer(trainerid2,trainername2,trainerparty2)
      Events.onTrainerPartyLoad.trigger(nil,trainer2)
      if !trainer2
        pbMissingTrainer(trainerid2,trainername2,trainerparty2)
      end
      if !trainer1 || !trainer2
        return false
      end
      if $PokemonGlobal.partner
        othertrainer=PokeBattle_Trainer.new($PokemonGlobal.partner[1],
                                            $PokemonGlobal.partner[0])
        othertrainer.id=$PokemonGlobal.partner[2]
        othertrainer.party=$PokemonGlobal.partner[3]
        playerparty=[]
        for i in 0...$Trainer.party.length
          playerparty[i]=$Trainer.party[i]
        end
        for i in 0...othertrainer.party.length
          playerparty[6+i]=othertrainer.party[i]
        end
        fullparty1=true
        playertrainer=[$Trainer,othertrainer]
      else
        playerparty=$Trainer.party
        playertrainer=$Trainer
        fullparty1=false
      end
      combinedParty=[]
      for i in 0...trainer1[2].length
        combinedParty[i]=trainer1[2][i]
      end
      for i in 0...trainer2[2].length
        combinedParty[6+i]=trainer2[2][i]
      end
      #Sky battle eligibility for opponent
      if skybattle
        count=0
        for poke in combinedParty
          count+=1 if pbCanSkyBattle?(poke)
        end
        if count==0
          Kernel.pbMessage(_INTL("The opponents don't have any eligible pokemon for a sky battle"))
          return false
        end
      end
      scene=pbNewBattleScene
      battle=PokeBattle_Battle.new(scene,
         playerparty,combinedParty,playertrainer,[trainer1[0],trainer2[0]],skybattle,inverse)
      trainerbgm=pbGetTrainerBattleBGM([trainer1[0],trainer2[0]])
      battle.fullparty1=fullparty1
      battle.fullparty2=true
      battle.doublebattle=battle.pbDoubleBattleAllowed?()
      battle.endspeech=endspeech1
      battle.endspeech2=endspeech2
      battle.items=[trainer1[1],trainer2[1]]
      if Input.press?(Input::CTRL) && $DEBUG
        Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
        Kernel.pbMessage(_INTL("AFTER LOSING..."))
        Kernel.pbMessage(battle.endspeech)
        Kernel.pbMessage(battle.endspeech2) if battle.endspeech2 && battle.endspeech2!=""
        return true
      end
      Events.onStartBattle.trigger(nil,nil)
      battle.internalbattle=true
      pbPrepareBattle(battle)
      restorebgm=true
      decision=0
      pbBattleAnimation(trainerbgm) { 
         pbSceneStandby {
            decision=battle.pbStartBattle(canlose)
         }
         for i in $Trainer.party; (i.makeUnmega rescue nil); (i.makeUnprimal rescue nil); end
         if $PokemonGlobal.partner
           pbHealAll
           for i in $PokemonGlobal.partner[3]
             i.heal
             i.makeUnmega rescue nil
             i.makeUnprimal rescue nil
           end
         end
         if decision==2 || decision==5
           if canlose
             for i in $Trainer.party; i.heal; end
             for i in 0...10
               Graphics.update
             end
    #       else
    #         $game_system.bgm_unpause
    #         $game_system.bgs_unpause
    #         Kernel.pbStartOver
           end
         end
         Events.onEndBattle.trigger(nil,decision,canlose)
      }
      Input.update
      pbSet(variable,decision)
      return (decision==1)
    end
    
    
    
    
    class PokeBattle_Battle
      attr_accessor :skybattle
      attr_accessor :inverse
      
      alias clauses_initialize initialize
      def initialize(scene,p1,p2,player,opponent,skybattle=false,inverse=false)
        @skybattle=skybattle
        @inverse=inverse
        if @inverse
          PBTypes.setInverse(true)
        end
        clauses_initialize(scene,p1,p2,player,opponent)
      end
      
      def pbCanSkyBattle?(pokemon)
        # list of pokemon that aren't allowed to participate, even though they are flying or have levitate
        inelligible=[getID(PBSpecies,:PIDGEY),getID(PBSpecies,:SPEAROW),getID(PBSpecies,:FARFETCHD),
                     getID(PBSpecies,:DODUO),getID(PBSpecies,:DODRIO),getID(PBSpecies,:GENGAR),
                     getID(PBSpecies,:HOOTHOOT),getID(PBSpecies,:NATU),getID(PBSpecies,:MURKROW),
                     getID(PBSpecies,:DELIBIRD),getID(PBSpecies,:TAILOW),getID(PBSpecies,:STARLY),
                     getID(PBSpecies,:CHATOT),getID(PBSpecies,:SHAYMIN),getID(PBSpecies,:PIDOVE),
                     getID(PBSpecies,:ARCHEN),getID(PBSpecies,:DUCKLETT),getID(PBSpecies,:RUFFLET),
                     getID(PBSpecies,:VULLABY),getID(PBSpecies,:FLETCHLING),getID(PBSpecies,:HAWLUCHA)]
        return (pokemon.hasType?(:FLYING) || pokemon.ability==getID(PBAbilities,:LEVITATE)) &&
                  !(inelligible.include?(pokemon.species))
      end
                
      alias clauses_pbCanChooseMove? pbCanChooseMove?
      def pbCanChooseMove?(idxPokemon,idxMove,showMessages,sleeptalk=false)
        ret=clauses_pbCanChooseMove?(idxPokemon,idxMove,showMessages,sleeptalk)
        thispkmn=@battlers[idxPokemon]
        thismove=thispkmn.moves[idxMove]
        if ret && @skybattle && thismove.unusableInSkyBattle?
          if showMessages
            pbDisplayPaused(_INTL("{1} can't be used in a sky battle!",
            thismove.name))
          end
          return false
        end
        return ret
      end
      
      def pbPokemonCount(party)
        count=0
        for i in party
          next if !i
          if !@skybattle
            count+=1 if i.hp>0 && !i.isEgg?
          else
            count+=1 if i.hp>0 && !i.isEgg? && pbCanSkyBattle?(i)
          end
        end
        return count
      end
      
      def pbFindNextUnfainted(party,start,finish=-1)
        finish=party.length if finish<0
        for i in start...finish
          next if !party[i]
          next if @skybattle && !pbCanSkyBattle?(party[i])
          return i if party[i].hp>0 && !party[i].isEgg?
        end
        return -1
      end
      
      alias clauses_pbCanSwitchLax? pbCanSwitchLax?
      def pbCanSwitchLax?(idxPokemon,pkmnidxTo,showMessages)
        ret=clauses_pbCanSwitchLax?(idxPokemon,pkmnidxTo,showMessages)
        party=pbParty(idxPokemon)
        if ret && @skybattle && !pbCanSkyBattle?(party[pkmnidxTo])
          pbDisplayPaused(_INTL("{1} can't fight in a sky battle!",party[pkmnidxTo].name)) if showMessages
          return false
        end
        return ret
      end
      
    end
    
    class PokeBattle_Move
      
      def unusableInSkyBattle?
        inelligible= [ getID(PBMoves,:BODYSLAM), getID(PBMoves,:BULLDOZE), getID(PBMoves,:DIG),
                       getID(PBMoves,:DIVE), getID(PBMoves,:EARTHPOWER), getID(PBMoves,:EARTHQUAKE),
                       getID(PBMoves,:ELECTRICTERRAIN), getID(PBMoves,:FISSURE), getID(PBMoves,:FIREPLEDGE),
                       getID(PBMoves,:FLYINGPRESS), getID(PBMoves,:FRENZYPLANT), getID(PBMoves,:GEOMANCY),
                       getID(PBMoves,:GRASSKNOT), getID(PBMoves,:GRASSPLEDGE), getID(PBMoves,:GRASSYTERRAIN),
                       getID(PBMoves,:GRAVITY), getID(PBMoves,:HEATCRASH), getID(PBMoves,:HEAVYSLAM),
                       getID(PBMoves,:INGRAIN), getID(PBMoves,:LANDSWRATH), getID(PBMoves,:MAGNITUDE),
                       getID(PBMoves,:MATBLOCK), getID(PBMoves,:MISTYTERRAIN), getID(PBMoves,:MUDSPORT),
                       getID(PBMoves,:MUDDYWATER), getID(PBMoves,:ROTOTILLER), getID(PBMoves,:SEISMICTOSS),
                       getID(PBMoves,:SLAM), getID(PBMoves,:SMACKDOWN), getID(PBMoves,:SPIKES),
                       getID(PBMoves,:STOMP), getID(PBMoves,:SUBSTITUTE), getID(PBMoves,:SURF),
                       getID(PBMoves,:TOXICSPIKES), getID(PBMoves,:WATERPLEDGE), getID(PBMoves,:WATERSPORT)
                     ]
                     
        return inelligible.include?(self.id)
      end
    end
    
    #used to determine elligibility before battle
    def pbCanSkyBattle?(pokemon)
        # list of pokemon that aren't allowed to participate, even though they are flying or have levitate
        inelligible=[getID(PBSpecies,:PIDGEY),getID(PBSpecies,:SPEAROW),getID(PBSpecies,:FARFETCHD),
                     getID(PBSpecies,:DODUO),getID(PBSpecies,:DODRIO),getID(PBSpecies,:GENGAR),
                     getID(PBSpecies,:HOOTHOOT),getID(PBSpecies,:NATU),getID(PBSpecies,:MURKROW),
                     getID(PBSpecies,:DELIBIRD),getID(PBSpecies,:TAILOW),getID(PBSpecies,:STARLY),
                     getID(PBSpecies,:CHATOT),getID(PBSpecies,:SHAYMIN),getID(PBSpecies,:PIDOVE),
                     getID(PBSpecies,:ARCHEN),getID(PBSpecies,:DUCKLETT),getID(PBSpecies,:RUFFLET),
                     getID(PBSpecies,:VULLABY),getID(PBSpecies,:FLETCHLING),getID(PBSpecies,:HAWLUCHA)]
        return (pokemon.hasType?(:FLYING) || pokemon.ability==getID(PBAbilities,:LEVITATE)) &&
                  !(inelligible.include?(pokemon.species))
    end
    
    Events.onEndBattle+=proc {|sender,e|
      PBTypes.setInverse(false)
    }
    
    class PBTypes
      @@inverse=false
      
      def PBTypes.setInverse(bool)
        @@inverse=bool
      end
      
      def PBTypes.getEffectiveness(attackType,opponentType)
        ret=PBTypes.loadTypeData()[2][attackType*(PBTypes.maxValue+1)+opponentType]
        if @@inverse
          if ret==0 || ret==1
            ret=4
          elsif ret==4
            ret=1
          end
        end
        return ret
      end
    
    end
                

    A sky or inverse battle is the same set up as a regular battle (I don't believe battles made with comments will work though, since those scripts are generated elsewhere.
    pbTrainerBattle(PBTrainers::CAMPER,"Jeff",_I("You didn't have to win so convincingly!"),false,1,false,0,false,true)

    The colored arguments there are sky battle and inverse, respectively.  

    Do note that there is a slight (non-crashing) problem if you are using EBS until it is updated, having to do with the previous version of essentials not actually picking the first eligible opponent's pokemon to lead with.
     
    Would this still work in v17.2 and does the problem still persist in the last version of EBS?
     
    It works smoothy but I wonder if I could use a specific background for sky battle? If this thread is still available please help me out
     
    It works smoothy but I wonder if I could use a specific background for sky battle? If this thread is still available please help me out

    I have a background for that but I don't have any script..
    Well I guess I might have to mess with the code...
    (I just need to know how Essentials uses battle backgrounds..)
     
    You could search a little in the Field Effects Script, or try with the event box, I do not know if it would work, but, what does it cost to try?

    If something was spelled wrong, it's Google Translator's fault.
     
    I have a background for that but I don't have any script..
    Well I guess I might have to mess with the code...
    (I just need to know how Essentials uses battle backgrounds..)
    For the battle background, just make a cloudy sky and don't insert any bases.
    Also, it still works for v18, just in case you're wondering. Just edit all scripted wild and trainer battles in the format mej71 says after his script.
    pbTrainerBattle(PBTrainers::CAMPER,"Jeff",_I("You didn't have to win so convincingly!"),false,1,false,0,false,true)
    pbWildBattle(ZYGARDE,50,true,false,false,true)
    (The last 2 on each one are sky and inverse battles, respectively)
     
    Last edited:
    You mentioned that this was still working for you in v18. I was wondering if you had any insight into a couple of errors I keep getting?
    Firstly, it's coming back saying that fullparty1=, doublebattle=, endspeech=, and internalbattle= are undefined methods on the following lines:

    Undefined Methods
    294: battle.fullparty1=fullparty1
    295: battle.doublebattle=doublebattle ? battle.pbDoubleBattleAllowed?() : false
    296: battle.endspeech=endspeech
    312: battle.internalbattle=true

    And also the following error saying that I have the "wrong number of arguments."

    ---------------------------
    Pokemon Essentials
    ---------------------------
    [Pokémon Essentials version 18]

    Exception: RuntimeError
    Message: Script error within event 10 (coords 36,36), map 161 (Boulder Bluffs):
    Exception: ArgumentError
    Message: Sky/Inverse:319:in `pbStartBattle'wrong number of arguments(1 for 0)

    ***Full script:
    pbTrainerBattle(PBTrainers::CAMPER,"Jeff",_I("You didn't have to win so convincingly!"),false,1,false,0,false,true)

    Backtrace:
    Interpreter:201:in `pbExecuteScript'
    Sky/Inverse:315:in `pbTrainerBattle'
    Sky/Inverse:314:in `pbSceneStandby'
    Sky/Inverse:316:in `pbTrainerBattle'
    Sky/Inverse:313:in `pbBattleAnimation'
    Sky/Inverse:313:in `pbTrainerBattle'
    (eval):1:in `pbExecuteScript'
    Interpreter:665:in `eval'
    Interpreter:201:in `pbExecuteScript'
    Interpreter:665:in `command_111'

    Backtrace:
    Interpreter:237:in `pbExecuteScript'
    Interpreter:665:in `command_111'
    Interpreter:279:in `execute_command'
    Interpreter:155:in `update'
    Interpreter:102:in `loop'
    Interpreter:158:in `update'
    Scene_Map:162:in `follow_update'
    Scene_Map:160:in `loop'
    Scene_Map:169:in `follow_update'
    Follow_Pokemon:1546:in `update'


    Which is in reference to the following line:
    319: decision = battle.pbStartBattle(canlose)

    Any advice you might be able to provide would be greatly appreciated!
     
    Back
    Top