# Examples: Wild Battles

<mark style="background-color:red;">**Wild Battle Example # 1**</mark>

The example below demonstrates a 1v1 battle against a wild Deoxys. In this battle, the following rules are set:

* <mark style="background-color:green;">"cannotRun"</mark> is used to prevent the playing from fleeing.
* <mark style="background-color:green;">"disablePokeBalls"</mark> is used to prevent the player from manually throwing Poke Balls.
* <mark style="background-color:green;">"terrain"</mark> is used to set permanent Psychic terrain.
* <mark style="background-color:green;">"environ"</mark> is used to set the battle environment to :Space.
* <mark style="background-color:green;">"backdrop"</mark> and <mark style="background-color:green;">"base"</mark> are used to customize the battle backdrop and bases, respectively.
* <mark style="background-color:green;">"alwaysCapture"</mark> is used to ensure a 100% capture rate in this battle.
* <mark style="background-color:green;">"battleBGM"</mark> is used to set custom battle music.
* <mark style="background-color:green;">"battleIntroText"</mark> is used to set custom battle intro text.
* <mark style="background-color:green;">"editWildPokemon"</mark> is used to edit the following attributes of the wild Deoxys:
  * Name is set to "????" so that it may be "revealed" in battle.
  * Obtain location is set to "Outer Space."
  * Flagged as Super Shiny.
  * Given Pokerus.
  * HP Level set to 2, multiplying its natural HP 2x.
  * Given boss immunity to OHKO effects, effects that would force it to flee, and all forms of indirect damage.
* <mark style="background-color:green;">"midbattleScript"</mark> is used to set a script to use for this battle which does the following:
  * "Reveals" Deoxy's real name at the start of the battle.
  * Sets a damage cap for Deoxys so that it will survive with 1 HP regardless of damage taken.
  * At the end of each round, Deoxys will cycle to its next form and recover its HP/Status.
  * Whenever Deoxys takes damage from an attack, it recovers back a little HP.
  * When Deoxy's HP falls to 25% or lower, it stops regenerating HP.
  * When Deoxys reaches the set damage cap (1 HP) after its regeneration has ended, the player will automatically throw a Poke Ball to capture Deoxys. This capture is guaranteed thanks to the <mark style="background-color:green;">"alwaysCapture"</mark> rule.

```ruby
setBattleRule("cannotRun")
setBattleRule("disablePokeBalls")
setBattleRule("terrain", :Psychic)
setBattleRule("environ", :Space)
setBattleRule("backdrop", "elite4")
setBattleRule("base", "distortion")
setBattleRule("alwaysCapture")
setBattleRule("battleBGM", "Battle roaming")
setBattleRule("battleIntroText", "You encountered an alien invader!")
setBattleRule("editWildPokemon", {
  :name        => "????",
  :obtain_text => "Outer Space.",
  :super_shiny => true,
  :pokerus     => true,
  :hp_level    => 2,
  :immunities  => [:OHKO, :ESCAPE, :INDIRECT]
})
setBattleRule("midbattleScript", {
  "RoundStartCommand_1_foe" => {
    "text_A"       => "You used Prof. Pluto's Roto-Dex upgrade to identify the alien species!",
    "playSE"       => "PC access",
    "battlerName"  => "Deoxys",
    "battlerHPCap" => -1,
    "text_B"       => "The alien species was identified as Deoxys!"
  },
  "RoundEnd_foe_repeat" => {
    "playSE"        => "Anim/Sound2",
    "battlerForm"   => [:Cycle, "{1} suddenly mutated!"],
    "playCry"       => :Self,
    "battlerMoves"  => :Reset,
    "ignoreAfter"   => "TargetHPLow_foe",
    "battlerStatus" => [:NONE, true],
    "battlerHP"     => [4, "{1} regenerated some HP!"]
  },
  "TargetTookDamage_foe_repeat" => {
    "ignoreAfter" => "TargetHPLow_foe",
    "text"        => "{1} started to regenerate!",
    "battlerHP"   => [8, "{1} regenerated some HP!"]
  },
  "TargetHPLow_foe" => {
    "text" => "{1} has become too weak to regenerate any more HP!"
  },
  "BattlerReachedHPCap_foe" => {
    "speech"       => [:Opposing, "It's getting weak!\nIt's now or never!", "Go, Poké Ball!"],
    "disableBalls" => false,
    "useItem"      => :POKEBALL
  },
  "AfterCapture" => [0, "Phew...it's finally over.", "The professor would be proud."]
})
WildBattle.start(:DEOXYS, 50)
```

***

<mark style="background-color:red;">**Wild Battle Example # 2**</mark>

The example below demonstrates a double battle where the player and their partner May encounter a wild Latias and Latios. In this battle, the following rules are set:

* <mark style="background-color:green;">"cannotRun"</mark> is used to prevent the playing from fleeing.
* <mark style="background-color:green;">"weather"</mark> is used to set permanent Hail.
* <mark style="background-color:green;">"backdrop"</mark> is used to customize the battle backdrop and bases.
* <mark style="background-color:green;">"editWildPokemon"</mark> is used to edit the following attributes of the wild Latias:
  * Nature is set to Modest.
  * Given Soul Dew to hold.
  * Ability is set to Healer.
  * Given the moves Life Dew, Reflect, Helping Hand, and Psychic.
* <mark style="background-color:green;">"editWildPokemon2"</mark> is used to edit the following attributes of the wild Latios:
  * Nature is set to Adamant.
  * Given Soul Dew to hold.
  * Ability is set to Friend Guard.
  * Given the moves Dragon Dance, Breaking Swipe, Zen Headbutt, and Earthquake.
* <mark style="background-color:green;">"midbattleScript"</mark> is used to set a script to use for this battle which does the following:
  * When either Latios or Latias reach 25% HP or lower, they will call upon the other to heal them.
  * When either Latios or Latias faint, the remaining one will flee, ending the battle.

```ruby
setBattleRule("cannotRun")
setBattleRule("weather", :Hail)
setBattleRule("backdrop", "champion2")
setBattleRule("editWildPokemon", {
  :nature  => :MODEST,
  :item    => :SOULDEW,
  :ability => :HEALER,
  :moves   => [:LIFEDEW, :REFLECT, :HELPINGHAND, :PSYCHIC]
})
setBattleRule("editWildPokemon2", {
  :nature  => :ADAMANT,
  :item    => :SOULDEW,
  :ability => :FRIENDGUARD,
  :moves   => [:DRAGONDANCE, :BREAKINGSWIPE, :ZENHEADBUTT, :EARTHQUAKE]
})
setBattleRule("midbattleScript", {
  "TargetHPLow_foe_repeat" => {
    "text_A"    => "{1} calls out to its partner with a whimpering cry!",
    "playCry"   => :Self,
    "text_B"    => [:Ally, "{1} comes to its partner's aid!"],
    "battlerHP" => [4, "{1} restored a little HP!"]
  },
  "BattlerFainted_foe" => {
    "setBattler" => :Ally,
    "text"       => "{1} looks upset by its partner's defeat...\nIt lost the will to fight!",
    "wildFlee"   => true
  }
})
pbRegisterPartner(:POKEMONTRAINER_May, "May")
WildBattle.start(:LATIAS, 30, :LATIOS, 30)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lucidious89-tutorials.gitbook.io/deluxe-battle-kit-tutorial/deluxe-battle-kit-for-v21.1/example-battles/examples-wild-battles.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
