• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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.

[Scripting Question] How to force a double battle?

  • 182
    Posts
    7
    Years
    • Seen Jan 22, 2025
    Hi! I was trying to make this; always that you use a Honey or Sweet Scent in the DarkGrass tile, you will call a double battle. But i don't know how to check if the pbSweetScent method is ejecuting, or how to force a double battle once you use it. Is there a way to do this?
     
    Well, one good to way to check if a code is executing (that isn't very obvious by other means) is to add a line where it changes a switch from off to on. Then, you can check the switch's state in the debug after when it should have triggered.

    Not sure how to force double battles in wild random encounters, but that should solve one of your roadblocks
     
    Hi! I was trying to make this; always that you use a Honey or Sweet Scent in the DarkGrass tile, you will call a double battle. But i don't know how to check if the pbSweetScent method is ejecuting, or how to force a double battle once you use it. Is there a way to do this?

    Use CTRL SHIFT F and search to 'pbDoubleWildBattle'.

    Inside 'PField_Field':
    Code:
    def pbBattleOnStepTaken(repel=false)
      return if $Trainer.ablePokemonCount==0
      encounterType = $PokemonEncounters.pbEncounterType
      return if encounterType<0
      return if !$PokemonEncounters.isEncounterPossibleHere?
      encounter = $PokemonEncounters.pbGenerateEncounter(encounterType)
      encounter = EncounterModifier.trigger(encounter)
      if $PokemonEncounters.pbCanEncounter?(encounter,repel)
        $PokemonTemp.encounterType = encounterType
    [COLOR="Red"]    if !$PokemonTemp.forceSingleBattle && ($PokemonGlobal.partner ||
           ($Trainer.ablePokemonCount>1 && PBTerrain.isDoubleWildBattle?(pbGetTerrainTag) && rand(100)<30))[/COLOR]
          encounter2 = $PokemonEncounters.pbEncounteredPokemon(encounterType)
          encounter2 = EncounterModifier.trigger(encounter2)
          pbDoubleWildBattle(encounter[0],encounter[1],encounter2[0],encounter2[1])
        else
          pbWildBattle(encounter[0],encounter[1])
        end
        $PokemonTemp.encounterType = -1
      end
      $PokemonTemp.forceSingleBattle = false
      EncounterModifier.triggerEncounterEnd()
    end
     
    Last edited:
    Sweetscent/Honey use pbEncounter to generate their encounters. The catch is, it only generates a double battle if you have a partner.
    Code:
    def pbEncounter(enctype)
      if $PokemonGlobal.partner [COLOR="Red"]||
           ($Trainer.ablePokemonCount>1 && PBTerrain.isDoubleWildBattle?(pbGetTerrainTag)[/COLOR]
        encounter1 = $PokemonEncounters.pbEncounteredPokemon(enctype)
        return false if !encounter1
        encounter2 = $PokemonEncounters.pbEncounteredPokemon(enctype)
        return false if !encounter2
        $PokemonTemp.encounterType = enctype
        pbDoubleWildBattle(encounter1[0],encounter1[1],encounter2[0],encounter2[1])
        $PokemonTemp.encounterType = -1
        return true
      else
        encounter = $PokemonEncounters.pbEncounteredPokemon(enctype)
        return false if !encounter
        $PokemonTemp.encounterType = enctype
        pbWildBattle(encounter[0],encounter[1])
    	  $PokemonTemp.encounterType = -1
        return true
      end
    end
    Adding the red line in PField_Encounters will do the trick.
     
    Sweetscent/Honey use pbEncounter to generate their encounters. The catch is, it only generates a double battle if you have a partner.
    Code:
    def pbEncounter(enctype)
      if $PokemonGlobal.partner [COLOR="Red"]||
           ($Trainer.ablePokemonCount>1 && PBTerrain.isDoubleWildBattle?(pbGetTerrainTag)[/COLOR]
        encounter1 = $PokemonEncounters.pbEncounteredPokemon(enctype)
        return false if !encounter1
        encounter2 = $PokemonEncounters.pbEncounteredPokemon(enctype)
        return false if !encounter2
        $PokemonTemp.encounterType = enctype
        pbDoubleWildBattle(encounter1[0],encounter1[1],encounter2[0],encounter2[1])
        $PokemonTemp.encounterType = -1
        return true
      else
        encounter = $PokemonEncounters.pbEncounteredPokemon(enctype)
        return false if !encounter
        $PokemonTemp.encounterType = enctype
        pbWildBattle(encounter[0],encounter[1])
    	  $PokemonTemp.encounterType = -1
        return true
      end
    end
    Adding the red line in PField_Encounters will do the trick.
    You missed a ")"
    But thanks, that worked :)
     
    Back
    Top