• 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!
Mid Battle Dialogue/ Scripted Battles

v18 Mid Battle Dialogue/ Scripted Battles v1.8

This resource pertains to version 18 of Pokémon Essentials.
Pokémon Essentials Version
v18.1 ➖
Example_Gif_3.gif
Example_Gif_1.gif

Example_Gif_2.gif


Mid Battle Dialogue/Scripted Battles


Overview:
The main aim of this script was to recreate the feature in BW2 which allowed Trainers to say a line of dialogue when they send out their last Pokemon and when their last Pokemon is at Low HP. This feature was expanded upon in Pokemon SwSh, where an opponent made a statement even when using a move, fainting a Pokemon, before Dynamaxing their Pokemon etc. Its a feature which adds personality to trainers. This script, takes that to the next level, with many more cases to trigger dialogue and with the functionality to run whole chunks of code mid Battle, essentially allowing you to edit every aspect about the battle, the Pokemon in Battle, the battle scene and even stuff in the Overworld. It also allows for Dialogue in Wild Battles. The only limit is your imagination.

Features:
  1. Displaying dialogue Mid Battle with many options.
  2. Sword/Shield Message Display Animation
  3. Changing BGM Mid Battle
  4. Allowing Dialogue to appear in many different places throughout the battle, not just on sending out the last Pokemon
  5. Usage of code blocks allows manipulation of the battle, the battle scene and the battlers at deep levels which allows highly intricately crafted and unique battle scenarios.
  6. Works with both Trainer as well as Wild Battles

Example Battles made using this Script:
  • Rival Battle from Pokemon FRLG:
  • Simple Pokemon Catching Tutorial:
  • Gym Leader Opal from Pokemon Sword and Shield:
  • Gym Leader Brock from the Anime Episode Showdown in Pewter City:



This script is not compatible with Essentials v17, or with EBS or EBDX. I do not plan to add compatibility for any of them.

Instructions

Installation of Script:
  1. Place the contents of script1.rb in a new script section above Main called BattleScript_Main.
  2. Place the contents of script2.rbin a new script section above Main called BattleScript_Data
  3. Place the Graphics into the Battle Animations Folder
  4. Start a new save (Optional)

Note: A .rb file is like a .txt file, and can be opened with any text editor. No need to panic.

Script Commands for the Battles:
The script commands to add Dialogue to a trainer battle are
BattleScripting.set(condition,data)
  • datacan be 1 of 4 things.
    • String => Will Display a basic String Dialogue along with the Trainer Sprite sliding in Trainer Battles.
      Eg: "This is my Ace Magikarp, you're not gonna get through him!"
    • Array=> Will Display multiple Dialogues one after the other along with the Trainer Sprite sliding in Trainer Battles.
      Eg: ["This is my Ace Magikarp.","He's even more powerful than a Mega Gyarados","Even faster than a Mega Salamence","And even tougher than a Gigantamax Corviknight","Good luck beating him"]
    • Hash=> Allows you to display Dialogue, change BGM and display a different Trainer Graphic than usual and even display a Trainer when in Wild Battles. The key values are:
      • "text" : The Dialogue to be displayed. Can be a String or Array
      • "bgm" : The BGM to Switch to
      • “bar” : set this to true if you want the SwSh styled Bar Animation when displaying text.
      • "opp" : Can be a String or Number. If its a Number then it displays the Trainer of that Index (Eg in a Battle against 2 Trainers,
      • “abovePkmn” : set this to true if you want the Trainer Sprite to appear above the Pokemon during dialogue.
        if Opp is set to 2 then the Graphic of the 2nd Trainer will be shown)
        If its a string then it'll display a graphic from the Trainers folder.(Eg: trainer024 will display the Prof Oak graphic even though Prof Oak isn't part of the Battle)
        Eg: {"text" => "Time to finish this","bgm" => "SwShGymCheer", "opp" => 2,”bar”=>true}
        {"text" => "This Pikachu should be easy to catch","bgm" => "Oak Intro", "opp" => "trainer024"}
    • Proc=> Run entire chunks of code. Detailed example given in the Example Battles section.

  • conditionis the condition for the dialogue to activate. It can be one of the following:
    • "battleStart" => for changing the "X would like to battle!" text
    • "turnStartX" => triggered at the start of turn X of the battle
    • "turnEndX" => triggered at the end of turn X of the battle
    • "randX" => triggered at the end of a turn with the chance of 1 in X
    • "last" => triggered when player sends out their last battler
    • "lastOpp" => triggered when opponent sends out their last battler
    • "item" => triggered when player uses item
    • "itemOpp" => triggered when opponent uses item
    • "mega" => triggered when player Mega Evolves battler
    • "megaopp" => triggered when opponent Mega Evolves battler
    • "recall" => triggered when player recalls battler
    • "recallOpp" => triggered when opponent recalls battler
    • "lowHP" => triggered when player's battler HP reduced to below 25%
    • "lowHPOpp" => triggered when opponent's battler HP reduced to below 25%
    • "halfHP" => triggered when player's battler HP reduced to below 50%
    • "halfHPOpp" => triggered when opponent's battler HP reduced to below 50%
    • "bigDamage" => triggered when player's battler receives over 60% damage from move
    • "bigDamageOpp" => triggered when opponent's battler receives over 60% damage from move
    • "smlDamage" => triggered when player's battler receives less than 30% damage from move
    • "smlDamageOpp" => triggered when opponent's battler receives less than 30% damage from move
    • "fainted" => triggered when player's battler faints
    • "faintedOpp" => triggered when opponent's battler faints
    • "attack" => triggered when player performs their 1st attack
    • "attackOpp" => triggered when opponent performs their 1st attack attack
    • "loss" => triggered when player loses battle
    • "endspeech" => triggers when player wins Battle
    • "sendoutX" => triggers when player sends out the Xth Pokemon in their party (doesn't apply for last member)
    • "sendoutXOpp" => triggers when opponent sends out the Xth Pokemon in their party (doesn't apply for last member)

      For each of these conditions, you can add a ,Z to denote the dialogue to play on the Zth instance of the condition. So you could do
      Code:
      BattleScripting.set(“recall”,”Whoa! Nice save!”)
      BattleScripting.set(“recall.2”,”Whoa! Nice save again!”)
      
      Note: For the conditions,
      [ICODE]"lowHP","lowHPOpp","halfHP","halfHPOpp","bigDamage","bigDamageOpp","smlDamage","smlDamageOpp","attack","attackOpp","superEff","superEffOpp","notEff","notEffOpp"[/ICODE]
      the Zth instance means the Zth Pokemon sent out. So bigDamageOpp,2 will play when the 2nd Pokemon in the opponents party is hit with an attack that takes it down 60% of it's HP.
      And it’ll display a different dialogue the 2nd time the event occurs.

BattleScripting.setInScript(condition,data)
If for some reason you can't fit your data from BattleScripting.set(condition,data) then you can define a new variable in the module provided in BattleScript_Data. Eg:
In BattleScript_Data
Code:
Joey_TurnStart0 = {"text"=>"What! You don't like shorts? Time to die!","bar"=>true}
In your event
Code:
BattleScripting.setInScript("turnStart0",:Joey_TurnStart0)

BattleScripting.copy(condition 1,conditions....)
BattleScripting.copy copies all the data from condition 1 to all the conditions specified. Eg:
Code:
BattleScripting.set("recall","Huh! Are you already giving up?")
BattleScripting.copy("recall","fainted")
BattleScripting.copy("recall","fainted","sendout2Opp","lastOpp")

BattleScripting.setTrainerAce(ace1,ace2,ace3.......)
This command allows you to define an "Ace Pokemon" ie a Pokemon that is sent out last no matter what. ace1 applies to the 1st Trainer, ace2 applies to the 2nd Trainer, ace3 applies to the 3rd Trainer. ace1, ace2, ace3 are numbers corresponding to the position of the Pokemon in the Trainer's party, as defined in the trainers.txt. If you have 4 or more trainers on 1 side, then adding an ace4 will also work. The script is designed with that in mind. Eg.
Code:
BattleScripting.setTrainerAce(2)
# This will make the 2nd Pokemon in the Trainers party its ace.

BattleScripting.setTrainerOrder(order1,order2,order3.......)
This command allows you to define theorder in which a Trainer sendsout their Pokemon" ie a Pokemon. order1 applies to the 1st Trainer, order2 applies to the 2nd Trainer, order3 applies to the 3rd Trainer. order1, order2, order3 are arrays of numbers corresponding to the position of the Pokemon in the Trainer's party, as defined in the trainers.txt. If you have 4 or more trainers on 1 side, then adding an ace4 will also work. The script is designed with that in mind. This will not change the 1st Pokemon sent out by the Trainer. Eg.
Code:
BattleScripting.setTrainerOrder([1,3,4,2,6,5])
# This will make it so that after the 1st Pokemon is sent out, the next is the 3rd, then 4th, then 2nd, then 6th, then 5th.

Here are some example commands that can be used inside Procs. (Important if you want the Trainer to Animate when saying Dialogue)
Code:
# For changing/animating Trainer Sprites. Works with any sprite in the Trainers Folder
TrainerDialogue.changeTrainerSprite(["trainer024","trainer024_1","trainer024_2","trainer024_2"],battle.scene,delay=5)
# Here the trainer024,trainer024_1..... are sprites in my Graphics/Trainers folder. The delay is the amount of frames to wait before changing the sprite.

# For Opponent Sprite to Slide into Battle
battle.scene.pbShowOpponent(0,true) #0 is Index of Trainer. It can be 1 in a double battle if you want to show the 2nd Trainer. The "true" is if you want the Trainer to appear in front of their Pokemon
battle.scene.pbHideOpponent

# For showing the SwSh styled animation for Dialogue
battle.scene.appearBar
#{Dialogue Stuff}
battle.scene.disappearBar
# Note that the Black Bars are drawn above the Battle UI so you'd wanna hide the bars before proceeding with any Battle Animations and All

# For hiding and showing the HP Box in Battle
battle.scene.disappearDatabox
#{Dialogue Stuff}
battle.scene.appearDatabox

# Dialogue
pbMessage("\\f[IintroOak]\\c[2]OK \\PN, let's see if you can beat this Pikachu!")

# Yes/No
pbConfirmMessage("Are you sad?")

# Choices
pbShowCommands(nil,"Are you sad?",["Why do you care?",''Nopity Nope","Who are you?"])

# Battle Text
battle.pbDisplay("It's stats rose!")

# Raising and Lowering Stats
battle.battlers[1].pbRaiseStatStage(PBStats::ATTACK,1,battle.battlers[1])
battle.battlers[1].pbRaiseLowerStage(PBStats::ATTACK,1,battle.battlers[1])

# Displaying Common Animations
battle.pbCommonAnimation("Sky Attack charging",nil,nil)
battle.pbCommonAnimation("StatUp",nil,nil)

# Setting Weather
battle.pbStartWeather(battle.battlers[1],PBWeather::Sandstorm)

# Setting Terrain
battle.pbStartWeather(battle.battlers[1],PBBattleTerrains::Electric)

# Forcefully Ending Battle
battle.scene.pbRecall(0)
battle.scene.pbRecall(2)
battle.pbCommonAnimation("MegaEvolution",nil,nil)
battle.decision=2 # Lost Battle
battle.decision=3# Flee
battle.decision=1# Won

# Reducing HP of Pokemon on Player's side
battle.battlers[0].pbReduceHP((battle.battlers[0].totalhp/5).floor)
battle.battlers[2].pbReduceHP((battle.battlers[2].totalhp/5).floor)

# Recovering HP of Pokemon on Player's side
battle.battlers[1].pbReduceHP((battle.battlers[1].totalhp/5).floor)
battle.battlers[3].pbReduceHP((battle.battlers[3].totalhp/5).floor)

# Setting Status
battle.pbAnimation(getID(PBMoves,:DARKVOID),battle.battlers[1],battle.battlers[0])
battle.battlers[2].pbSleep if battle.battlers[2].pbCanSleep?(battle.battlers[1],false)
battle.battlers[0].pbSleep if battle.battlers[0].pbCanSleep?(battle.battlers[1],false)

# Setting up Effects on Opposing Side of Field
battle.pbAnimation(getID(PBMoves,:STEALTHROCK),battle.battlers[1],battle.battlers[0])
battle.battlers[0].pbOpposingSide.effects[PBEffects::StealthRock]=true

battle.pbAnimation(getID(PBMoves,:BARRIER),battle.battlers[1],nil)
battle.battlers[0].pbOwnSide.effects[PBEffects::LightScreen]=3

If you want more examples of how to use this script, I highly recommend checking out the BattleScript_Data from:
Pokémon Splice
Pokemon Bushido
Touhou Puppet Play ~ The Festival of Curses

If you haven't played these games already then I highly recommend checking these games out. They all make really creative use of the system, and are just damn good games in general.
Or have a look at the Example Map provided in the download, with its example battles.

Example Battles:
Test out the Battles yourself by adding the Map provided in the download to your game
To add this new map to you game:
  • Paste the MapXXX.rxdata to your projects Data Folder
  • Create a New Map in your Project
  • Go to Map Properties and note down the ID Number (Eg: 069)
  • Save and Close RPG Maker
  • Delete the Map corresponding to the ID we noted down (So Map069.rxdata will be deleted)
  • Rename the Dowloaded file such that the XXX matches the ID we noted down.
  • Open RMXP and have fun with the Trainer Battles!


Minor Issues:
  • Syntax Errors may be a big problem in setting up the events. I'd suggest actually creating the Script Command in a .txt file and pasting it into your Event once you're done. If you still get a Syntax Error, re-evaluate the parts where the error points you to. Usually it's something as simple as a missing bracket, comma or colon
Credits
Golisopod User
Luka SJ
Author
Golisopod User
Downloads
3,583
Views
17,480
First release
Last update
Rating
5.00 star(s) 6 ratings

More resources from Golisopod User

Latest updates

  1. Bugfixing and Additions

    The script now allows you to define an "Ace" for a trainer, a Pokemon that will always be sent...
  2. Bugfixes

    There have been various bugfixes to the script. Mainly compatibility issues. The format for...
  3. Mainly Bugfixes and a few cool additions.

    Fixed a few bugs Added support of larger screen sizes Added a random chance dialogue option Made...

Latest reviews

This is really cool but I don't understand how to do things like change battle music. Please help!
It's awesome and super easy to use. It's super fun and simple!!!
Back
Top