• 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?".
  • 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.

Mid Battle Dialogue/Scripted Battles

YashPokeFan123

#PokeFan
  • 283
    Posts
    3
    Years
    • Seen Apr 28, 2023
    What is this script you mentioned:

    Code:
     $PokemonGlobal.nextBattleBGM="BrockBattle"
    # Simple text change for showing that this is the 2nd time you're challening Brock
    TrainerDialogue.set("battleStart","You challenge Gym Leader Brock for the 2nd time!")
    BattleScripting.setInScript("last",:Brock_LastPlayer)
    TrainerDialogue.set("turnStart0",Proc.new{|battle|
    # At the start of the Battle, set Geodude's item to Ring Target.
    # Allows the Pikachu to hit Geodude with Electric Attacks. Plot Armor 100
    battle.battlers[1].item=getID(PBItems,:RINGTARGET)
    })
    BattleScripting.setInScript("smlDamageOpp",:Brock_MockPlayer)
    BattleScripting.setInScript("recall",:Brock_GiveUp)
    TrainerDialogue.set("fainted","Are you giving up already, \\PN?")
    BattleScripting.setInScript("halfHP,2",:Brock_Sprinklers)
    TrainerDialogue.copy("lowHP,2","halfHP,2")
    BattleScripting.setInScript("lowHPOpp,2",:Brock_Forfeit)
    party = []
    species = [:PIDGEOTTO,:PIKACHU]
    for id in species
    party.push(getConst(PBSpecies,id)) if hasConst?(PBSpecies,id)
    end
    # Species IDs of the Pokémon to be created
    for i in 0...$Trainer.party.length
    $Trainer.party[i]=nil
    end
    $Trainer.party.compact!
    for i in 0...party.length
    species = party[i]
    $Trainer.party[i] = pbNewPkmn(species,12)
    $Trainer.seen[species] = true # Set this species to seen and owned
    $Trainer.owned[species] = true
    end
    $Trainer.party[1].pbLearnMove(:AGILITY)
    $Trainer.party[1].pbLearnMove(:SLAM)
    $Trainer.party[1].pbLearnMove(:IRONTAIL)
    $Trainer.party[1].pbLearnMove(:THUNDERBOLT)
    $Trainer.party[0].pbLearnMove(:GUST)
    $Trainer.party[0].pbLearnMove(:WINGATTACK)
    $Trainer.party[0].pbLearnMove(:SANDATTACK)
    $Trainer.party[0].pbLearnMove(:TACKLE)

    There is a TrainerDialogue.copy here.

    I do Ctrl+Shift+f to search
    But not find anywhere.
     

    StCooler

    Mayst thou thy peace discover.
  • 9,304
    Posts
    4
    Years
    • Seen yesterday
    I do Ctrl+Shift+f to search
    But not find anywhere.

    Please make an effort and try to understand. You post an error with a ton of lines of script, so when I'm telling you what to change, look in the script you posted YOURSELF.
    The error is in:
    Code:
    Script error within event 21 (coords 20,8), map 2 (Lappet Town):
    The event has a ton of scripts and the error is inside.
     

    YashPokeFan123

    #PokeFan
  • 283
    Posts
    3
    Years
    • Seen Apr 28, 2023
    Please make an effort and try to understand. You post an error with a ton of lines of script, so when I'm telling you what to change, look in the script you posted YOURSELF.
    The error is in:
    Code:
    Script error within event 21 (coords 20,8), map 2 (Lappet Town):
    The event has a ton of scripts and the error is inside.

    Actually I have updated to Mid Battle Dialogue to 16v but the map event that has Mid Battle Dialogue is of v15 thats why
     
  • 658
    Posts
    7
    Years
    The script has been updated to v1.8. Make sure to check the updated instructions.

    • The script now allows you to define an "Ace" for a trainer, a Pokemon that will always be sent out last no matter what.
    • The script now allows you to define the "Order" of sending Pokemon for a trainer.
    • Minor bugfixes relating to compatibility with the newly released ZUD Plugin and the Gen 8 Project
     
  • 41
    Posts
    3
    Years
    • Seen Sep 19, 2023
    OK i need some major help apparently. I can't get this to do ANYTHING at all. I put the scripts above main as instructed. I wanted to start with something small just to get my bearings. I wanted to have the rival character simply say something when their pokemon falls below half HP for the very first battle with them.

    Code:
    BattleScripting.set(
    "halfHPOpp,","Um... I uh....oh no.")

    I have conditional branches depending on which starter you chose etc. I've placed it before any of the conditional branches, I've placed them directly before the battle of each branch. Yet every time I take their pokemon below 50%....absolutely nothing.

    How can I make this work?

    EDIT:
    I even made a separate battle instance just to test this and it doesn't do a single thing.
    Code:
    BattleScripting.set(
    "halfHPOpp,","Um... I uh....oh no.")
    pbTrainerBattle(
    :TIMIDGIRL,"Yuki",nil,nil,0)

    Those are the only 2 things in the entire event. I take her pokemon to half health. No comment from the opponent
     
    Last edited:

    StCooler

    Mayst thou thy peace discover.
  • 9,304
    Posts
    4
    Years
    • Seen yesterday
    OK i need some major help apparently. I can't get this to do ANYTHING at all. I put the scripts above main as instructed. I wanted to start with something small just to get my bearings. I wanted to have the rival character simply say something when their pokemon falls below half HP for the very first battle with them.

    Code:
    BattleScripting.set(
    "halfHPOpp,","Um... I uh....oh no.")

    I have conditional branches depending on which starter you chose etc. I've placed it before any of the conditional branches, I've placed them directly before the battle of each branch. Yet every time I take their pokemon below 50%....absolutely nothing.

    How can I make this work?

    EDIT:
    I even made a separate battle instance just to test this and it doesn't do a single thing.
    Code:
    BattleScripting.set(
    "halfHPOpp,","Um... I uh....oh no.")
    pbTrainerBattle(
    :TIMIDGIRL,"Yuki",nil,nil,0)

    Those are the only 2 things in the entire event. I take her pokemon to half health. No comment from the opponent

    The error lies in your code. You write "halfHPOpp," (with the comma) instead of "halfHPOpp".

    PS: you can use the program extendtext.exe so that your lines aren't broken by the small editor of the event scripts. You will be able to write the complete lines:
    Code:
    BattleScripting.set("halfHPOpp","Um... I uh....oh no.")
    pbTrainerBattle(:TIMIDGIRL,"Yuki",nil,nil,0)
     
    Last edited:
  • 41
    Posts
    3
    Years
    • Seen Sep 19, 2023
    The error lies in your code. You write "halfHPOpp," (with the comma) instead of "halfHPOpp".

    Well... that still didn't fix my problem at all unfortunately. I utilized the extendtext and placed the comma exactly where it should go, but the script still did nothing. Fought her only pokemon and when it got to half health there was no comment just battle as usual.

    Code:
    BattleScripting.set("halfHPOpp","Um... I uh....oh no.")
    pbTrainerBattle(:TIMIDGIRL,"Yuki",nil,nil,0)
     

    StCooler

    Mayst thou thy peace discover.
  • 9,304
    Posts
    4
    Years
    • Seen yesterday
    Well... that still didn't fix my problem at all unfortunately. I utilized the extendtext and placed the comma exactly where it should go, but the script still did nothing. Fought her only pokemon and when it got to half health there was no comment just battle as usual.

    The way it is coded, it will not trigger "halfHPOpp" dialogue if you get the Pokémon directly under 25% of their health. Try to bring them below 50% and above 25% and tell us if you get the dialogue.
    Also, make a dummy dialogue to be triggered at the end of turn 1:
    Code:
    BattleScripting.set("turnEnd1","Yes it works!!!!!")
    BattleScripting.set("halfHPOpp","Um... I uh....oh no.")
    pbTrainerBattle(:TIMIDGIRL,"Yuki",nil,nil,0)
    At this point, I just want to see if anything from this script works.
     
  • 41
    Posts
    3
    Years
    • Seen Sep 19, 2023
    Code:
    BattleScripting.set("turnEnd1","Yes it works!!!!!")
    BattleScripting.set("halfHPOpp","Um... I uh....oh no.")
    pbTrainerBattle(:TIMIDGIRL,"Yuki",nil,nil,0)

    OK so I did exactly what you stated above. The trainer did slide in and say "Yes it works!!!!!" but on turn 2 not turn 1. I changed it to "turnEnd0" and tried again and she came in at the end of the first turn. So that works.

    However still nothing for halfHPOpp. I got her Chikorita in between 25 and 50% health but no comment.

    Out of curiosity, I saw the original guy said it was updated to V1.8 but the script itself still says 1.5 from his downloads. IDK if that's just an oversight or if his link is old.

    EDIT: I'm on V18.1 of Pokemon Essentials and I have done the Generation 8 Project updates which I found on here. I also have put this script at the very bottom above Main.
     
    Last edited:

    StCooler

    Mayst thou thy peace discover.
  • 9,304
    Posts
    4
    Years
    • Seen yesterday
    OK so I did exactly what you stated above. The trainer did slide in and say "Yes it works!!!!!" but on turn 2 not turn 1. I changed it to "turnEnd0" and tried again and she came in at the end of the first turn. So that works.
    Ok, my mistake, I didn't realise the turn were numbered from 0 ^^"

    Out of curiosity, I saw the original guy said it was updated to V1.8 but the script itself still says 1.5 from his downloads. IDK if that's just an oversight or if his link is old.
    I've updated my script, it's v1.8.

    However still nothing for halfHPOpp. I got her Chikorita in between 25 and 50% health but no comment.
    This is weird. It does work for me.
    Let's enter debug mode then. Find the function
    Code:
      def pbEndureKOMessage(target)
    in the Mid Battle Dialogue script, find this part:
    Code:
        if target.hp < (target.totalhp*0.25).floor && target.hp>0
          if !target.damageState.lowHP
            target.damageState.lowHP = true
            target.damageState.halfHP = true
            if !target.opposes?
              TrainerDialogue.display("lowHP",@battle,@battle.scene)
            else
              TrainerDialogue.display("lowHPOpp",@battle,@battle.scene)
            end
          end
        elsif target.hp < (target.totalhp*0.5).floor && target.hp>0
          if !target.damageState.halfHP
            target.damageState.halfHP = true
            if !target.opposes?
              TrainerDialogue.display("halfHP",@battle,@battle.scene)
            else
              TrainerDialogue.display("halfHPOpp",@battle,@battle.scene)
            end
          end
        end
    and REPLACE it with it:
    Code:
        if target.hp < (target.totalhp*0.25).floor && target.hp>0
          pbMessage("DEBUG: This is low HP condition checked")
          if !target.damageState.lowHP
            pbMessage("DEBUG: Let's check the message for low HP")
            target.damageState.lowHP = true
            target.damageState.halfHP = true
            if !target.opposes?
              TrainerDialogue.display("lowHP",@battle,@battle.scene)
            else
              TrainerDialogue.display("lowHPOpp",@battle,@battle.scene)
            end
          else 
            pbMessage("DEBUG: Already triggered a low HP message")
          end
        elsif target.hp < (target.totalhp*0.5).floor && target.hp>0
          pbMessage("DEBUG: This is half HP condition checked")
          if !target.damageState.halfHP
            pbMessage("DEBUG: Let's check the message for half HP")
            target.damageState.halfHP = true
            if !target.opposes?
              TrainerDialogue.display("halfHP",@battle,@battle.scene)
            else
              TrainerDialogue.display("halfHPOpp",@battle,@battle.scene)
            end
          else 
            pbMessage("DEBUG: Already triggered a half HP message")
          end
        end
    It's the same code but with some debug checks. Tell me if any "DEBUG" message shows up when you get the opponent below 50% HP.
     
  • 41
    Posts
    3
    Years
    • Seen Sep 19, 2023
    Tell me if any "DEBUG" message shows up when you get the opponent below 50% HP.

    Did a few scratches
    This time, When I got down past 50% but not yet into the red zone i got
    "Debug: This is half HP Condition checked"
    "Debug: Let's check the message for half HP"
    "Um.. I uh... oh no"
    Did an additional scratch to bring it into red zone
    "Debug: This is low HP condition checked"
    "Debug: Let's check the message for low HP"
    Then her chikorita did an attack after my pokemon in the same turn as me bringing it into the red zone and once again I received.
    "Debug: This is half HP Condition checked"
    "Debug: Let's check the message for half HP"
    no quote this time


    Alternatively when I restart the battle
    When I use a fire type attack and drop it's HP into the red in a single hit i get
    "Debug: This is half HP Condition checked"
    "Debug: Already triggered a half HP message"
     

    StCooler

    Mayst thou thy peace discover.
  • 9,304
    Posts
    4
    Years
    • Seen yesterday
    Did a few scratches
    This time, When I got down past 50% but not yet into the red zone i got
    So it actually works! However this part intrigues me:
    Alternatively when I restart the battle
    When I use a fire type attack and drop it's HP into the red in a single hit i get
    WTF, it doesn't make sense!
    What do you mean you "restart the battle"? Did you quit the game and reload the save? Or did you click again on the same event?
    I don't even know what to ask, this result makes no sense to me ^^"
    Are you sure you copied/paste the right message? I suspect you copied/pasted but didn't double-check...
     
  • 41
    Posts
    3
    Years
    • Seen Sep 19, 2023
    WTF, it doesn't make sense!
    What do you mean you "restart the battle"? Did you quit the game and reload the save? Or did you click again on the same event?
    I don't even know what to ask, this result makes no sense to me ^^"

    I saved prior to the battle and closed out my game. I relaunched the game and fought the trainer again this time choosing a super effective move that immediately put the opponent in the red and got
    "Debug: This is half HP Condition checked"
    "Debug: Already triggered a half HP message"
     

    StCooler

    Mayst thou thy peace discover.
  • 9,304
    Posts
    4
    Years
    • Seen yesterday
    I saved prior to the battle and closed out my game. I relaunched the game and fought the trainer again this time choosing a super effective move that immediately put the opponent in the red and got

    I think I get it now.
    Again in the function:
    Code:
      def pbEndureKOMessage(target)
    Find this part and add the line that is marked:
    Code:
        if target.damageState.bigDamage==1
          target.damageState.bigDamage = -1
          target.damageState.smlDamage = -1
          target.damageState.halfHP = true
          pbMessage("DEBUG: this is big damage") # Mark this line.
          if !target.opposes?
            TrainerDialogue.display("bigDamage",@battle,@battle.scene)
          else
            TrainerDialogue.display("bigDamageOpp",@battle,@battle.scene)
          end
        elsif target.damageState.smlDamage==1
          if !target.opposes?
            TrainerDialogue.display("smlDamage",@battle,@battle.scene)
          else
            TrainerDialogue.display("smlDamageOpp",@battle,@battle.scene)
          end
          target.damageState.smlDamage=-1
        end
    Now tell me again the messages. (Run the three tests from your previous message)
    I think there is a conflict between "halfHP"/"halfHPOpp" and "bigDamage"/"bigDamageOpp".
     
    Last edited:
  • 41
    Posts
    3
    Years
    • Seen Sep 19, 2023
    Now tell me again the messages. (Run the three tests from your previous message)
    I think there is a conflict between "halfHP"/"halfHPOpp" and "bigDamage"/"bigDamageOpp".

    Results
    Test 1:
    2 Scratches put Chikorita in Yellow but no message. Chikorita growled on 2nd turn
    Additional Scratch stayed in Yellow. Received "DEBUG: This is half HP Condition checked" "DEBUG: Let's check the message for half HP" then trainer slid in and said "Um.. i uh... oh no"
    Restarted game

    Test 2
    2 Scratches put Chikorita in Yellow but no message. Chikorita did NOT use growl
    Additional Scratch put Chikorita into red health (not critical hit though). Received "DEBUG: This is half HP Condition checked" "DEBUG: Let's check the message for half HP" then trainer slid in and said "Um.. i uh... oh no"
    Then Chikorita used tackle that same turn as the additional scratch and put me into yellow (5PH left) it once again gave me "DEBUG: This is half HP Condition checked" "DEBUG: Let's check the message for half HP" but this time not trainer slide.
    Restarted game

    Test 3
    Used Ember on first turn which took it down to Yellow. Received message' Debug: This is big damage" then "DEBUG: This is half HP Condition checked" "DEBUG: Already Triggered a half HP message" No trainer slide in
    Restarted game

    Test 4
    Used Ember on first turn which took it down to Red this time (no crit). Received message' Debug: This is big damage" then "DEBUG: This is half HP Condition checked" "DEBUG: Already Triggered a half HP message" No trainer slide in
     
    Last edited:

    StCooler

    Mayst thou thy peace discover.
  • 9,304
    Posts
    4
    Years
    • Seen yesterday
    Results
    Test 1:
    2 Scratches put Chikorita in Yellow but no message. Chikorita growled on 2nd turn
    Additional Scratch stayed in Yellow. Received "DEBUG: This is half HP Condition checked" "DEBUG: Let's check the message for half HP" then trainer slid in and said "Um.. i uh... oh no"
    Restarted game

    Test 2
    2 Scratches put Chikorita in Yellow but no message. Chikorita did NOT use growl
    Additional Scratch put Chikorita into red health (not critical hit though). Received "DEBUG: This is half HP Condition checked" "DEBUG: Let's check the message for half HP" then trainer slid in and said "Um.. i uh... oh no"
    Then Chikorita used tackle that same turn as the additional scratch and put me into yellow (5PH left) it once again gave me "DEBUG: This is half HP Condition checked" "DEBUG: Let's check the message for half HP" but this time not trainer slide.
    Restarted game

    Test 3
    Used Ember on first turn which took it down to Yellow. Received message' Debug: This is big damage" then "DEBUG: This is half HP Condition checked" "DEBUG: Already Triggered a half HP message" No trainer slide in
    Restarted game

    Test 4
    Used Ember on first turn which took it down to Red this time (no crit). Received message' Debug: This is big damage" then "DEBUG: This is half HP Condition checked" "DEBUG: Already Triggered a half HP message" No trainer slide in

    Sorry I forgot to reply ^^"
    So there is no problem actually?
    Maybe you can comment the line:
    Code:
          target.damageState.halfHP = true
    that is above
    Code:
          pbMessage("DEBUG: this is big damage") # Mark this line.
    But be sure not to use both "halfHPOpp" and "bigDamageOpp" because both will appear if you reduce the HP of the opponent by more than 50% in just one hit.
     
  • 41
    Posts
    3
    Years
    • Seen Sep 19, 2023
    OK i'll give that a try. I guess i'm only experiencing "problems" because the HP is so small on a level 5 that it can easily fit more than one scenario with a move.
     
  • 41
    Posts
    3
    Years
    • Seen Sep 19, 2023
    Apologies for the double post, but I've run into another problem.

    Can you not designate a pokemon as an ace AND have the trainer say something when the ace is sent out?

    I have tried both of the following
    Code:
    BattleScripting.setTrainerAce(2)
    BattleScripting.set("sendout2","You can do it, Bayleef! We can still win! I believe in you!")
    Code:
    BattleScripting.setTrainerAce(2)
    BattleScripting.set("last","You can do it, Bayleef! We can still win! I believe in you!")

    Bayleef is the second one listed in trainer.txt. Since this is the starter of my rival, I wanted to not only have that as an ace, but also make a comment when sending out the starter. Both of the above code produces this error

    Code:
    Exception: RuntimeError
    Message: Script error within even 77 (coords 38,67, map 132 (Route 2)
    Exception: SyntaxError
    Message: (eval):2:in 'pbExecuteScript'compileerror
    (eval):2:syntax error
    BattleScripting.set("sendout2","You can do it, Bayleef! We can still win! I believe in you!")
    
    (eval):2:syntax error
    BattleScripting.set("sendout2","You can do it, Bayleef! We can still win! I believe in you!")
    
    **Fullscript:
    BattleScripting.setTrainerAce(2)
    BattleScripting.set("sendout2","You can do it, Bayleef! We can still win! I believe in you!")

    Same error when using last instead of sendout2
     

    StCooler

    Mayst thou thy peace discover.
  • 9,304
    Posts
    4
    Years
    • Seen yesterday
    Apologies for the double post, but I've run into another problem.

    Can you not designate a pokemon as an ace AND have the trainer say something when the ace is sent out?
    <SNIPPED>
    Same error when using last instead of sendout2

    I suspect this is due to the size of the editor; do your lines split in the middle of the string? Like maybe you want to write:
    Code:
    BattleScripting.set("sendout2","You can do it, Bayleef! We can still win! I believe in you!")
    but instead you write:
    Code:
    BattleScripting.set("sendout2","You can do it, 
    Bayleef! We can still win! I believe in you!")
    because the editor is not wide enough. If this is the error, use extendtext.exe.
     
  • 41
    Posts
    3
    Years
    • Seen Sep 19, 2023
    I suspect this is due to the size of the editor; do your lines split in the middle of the string? Like maybe you want to write:
    Code:
    BattleScripting.set("sendout2","You can do it, Bayleef! We can still win! I believe in you!")
    but instead you write:
    Code:
    BattleScripting.set("sendout2","You can do it, 
    Bayleef! We can still win! I believe in you!")
    because the editor is not wide enough. If this is the error, use extendtext.exe.

    Unfortunately no. I was using extendtext.exe so that long one is on a singular line.


    EDIT: I don't know what happened but I just sort of went through and re-wrote the code and for some reason it decided to work. I don't even know anymore, man...
     
    Last edited:
    Back
    Top