• Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Resource icon

Tutorial Wild Battles that can result in Double Battles 2017-04-24

DerxwnaKapsyla

Overseer of the Abyss
Member
Joined
Apr 24, 2017
Posts
151
DerxwnaKapsyla submitted a new resource:

Wild Battles that can result in Double Battles - Replicating the effect of the Gen 5 games where you have WDB Grass

With Generation Three, we were introduced to a new concept: Double Battles, trainers that would send out two Pokemon at once. Generation Four added more to this concept in an interesting way - if you had a partner with you at the time, you would get into Wild Double Battles. Generation Five expanded on this even further and allows you to get into Wild Double Battles in certain types of Tall Grass.

This script will allow players to emulate the style of Wild Double Battles in their Pokemon...

Read more about this resource...
 

WolfPP

Discord wolfppontes
Member
Joined
Aug 24, 2018
Posts
136
Excuse, sorry to ress but i want to get 100% DWB, so i will put rand 10<9?

ty ty!
 

BlasterMillennia

Novice
Member
Joined
Jun 10, 2017
Posts
13
To encounter wild double battles all the time, you won't need the condition with the "rand" expression at all, since the chance of a wild double battle would no longer be up to chance. So your final code should simply look like the following, instead of what appears in the tutorial:
Code:
if $PokemonGlobal.partner || (pbGetTerrainTag($game_player)==PBTerrain::TallGrass) && $Trainer.ablePokemonCount>1
         encounter2=$PokemonEncounters.pbEncounteredPokemon(encounterType)
         pbDoubleWildBattle(encounter[0],encounter[1],encounter2[0],encounter2[1])
 
Last edited:

WolfPP

Discord wolfppontes
Member
Joined
Aug 24, 2018
Posts
136
To encounter wild double battles all the time, you won't need the condition with the "rand" expression at all, since the chance of a wild double battle would no longer be up to chance. So your final code should simply look like the following, instead of what appears in the tutorial:
Code:
if $PokemonGlobal.partner || (pbGetTerrainTag($game_player)==PBTerrain::TallGrass) && $Trainer.ablePokemonCount>1
         encounter2=$PokemonEncounters.pbEncounteredPokemon(encounterType)
         pbDoubleWildBattle(encounter[0],encounter[1],encounter2[0],encounter2[1])

Oh god, my fault. Sorry. I did not express myself correctly.
Unfortunately I still dont understand how "rand (x)> x" works.
If i wanted 50%, i put 10>5? and 30% to be a DWB, 10>3?
And TallGrass is Terrain Tag 2?
Ty ty!
 

DerxwnaKapsyla

Overseer of the Abyss
Member
Joined
Apr 24, 2017
Posts
151
You've got more or less the right idea! I'll try and go over the individual steps of understanding rand(x) > y.
- "rand(x)" is the total number it can roll within, 0 inclusive (this means 0 is a valid number it can roll). This can be set any number you want. If you have it set to rand(50), it can roll from 0 to 50 and no higher. If set to rand(525600), then it can only roll from 0 to 525600.

- The operator symbol after it is what determines its relationship to the number that follows. First is < and >, which respectively mean Less Than and Greater Than. For example 5<10 would read "5 is Less Than 10". After that it's <= and >=, which are Less or Equal To, and Greater or Equal to. Functionally the same as the other two, but these can also check for if the value of x is equal to the value of y. The last operator is ==, which denotes that it is specifically equal to it. Take note not to use one =, as that doesn't denote "is equal to" in code, it means "the value of x is what the value of y will mean". rand(x)=10 would mean "the randomized value of x will get stored in a variable called "10"".

- And the y is just a preset value to check your random number against. Not much can be said about that.

- When all the components of the formula are put together, "rand(x) > y" means "the random value of x is greater than the value of y". Knowing that, we can break down understanding a few more things.

The code I put has me using "if rand(10) < 3", which means that "if the random number generated up to 10 is less than 3, run a double battle". This gives you a 30% chance to get a Wild Double Battle, as there's only 3 numbers below (0, 1, and 2). The code you used would be "if rand(10) > 3", which would translate to "if the random number generated up to 10 is greater than 3, run a double wild battle." This would be a 70% chance, because there are 7 numbers above 3 (4, 5, 6, 7, 8, 9, and 10). Be sure to remember which operator to use where, and you should be set!

... I also have to tweak the code a bit because I made it when I didn't know that rand was 0 inclusive, and I need to make it more accurate to Blue Grass from Black and White.
 

WolfPP

Discord wolfppontes
Member
Joined
Aug 24, 2018
Posts
136
Hmmm, so i tried to put 10>9 and nothing happens (i have 2 pokemon in party btw).

Here is my script in 'PField_Encouters' 369:

Code:
# Used by fishing rods and Headbutt/Rock Smash/Sweet Scent
def pbEncounter(enctype)
  if $PokemonGlobal.partner || ( pbGetTerrainTag($game_player)==PBTerrain::TallGrass && rand(10)<9 ) && $Trainer.ablePokemonCount>1
    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

Im using 17.2 and EBS 4
And how looks 'TallGrass' and 'Grass' like? lol
Route 1 is only grass right? i change to this too and again, nothin happens.

Ty ty for help <3

EDIT: I GOT IT!

in PField_Field, in 'def pbBattleOnStepTaken(repel=false)'
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
    if !$PokemonTemp.forceSingleBattle && ($PokemonGlobal.partner ||
       ($Trainer.ablePokemonCount>1 && PBTerrain.isDoubleWildBattle?(pbGetTerrainTag) && rand(100)<30))
      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
[/spoiler]

Change to:
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
    if !$PokemonTemp.forceSingleBattle && ($PokemonGlobal.partner ||
#       ($Trainer.ablePokemonCount>1 && PBTerrain.isDoubleWildBattle?(pbGetTerrainTag) && rand(100)<30))
      (pbGetTerrainTag($game_player)==PBTerrain::TallGrass && rand(10)<3) && $Trainer.ablePokemonCount>1)
      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
[/spoiler]

TallGrass is Terrain Tag 10

Ty ty <3
 
Last edited:
Back
Top