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

[Scripting Question] Mid-Battle Events

10
Posts
4
Years
    • Seen Jul 25, 2020
    So I've got this really cool idea to have your first starter Pokemon be a snagged Shadow Pokemon in your very first battle.

    During the battle, I want a dialogue box to appear telling the player to capture said Pokemon. For example, battle goes on like normal, until the Pokemon is down to a certain amount of health. That's when a message comes up saying to snag the Pokemon, or something along those lines.

    Can anyone tell me how I can make this happen, please?

    And thank you, so much!

    NOTE: I have very little coding knowledge, but I am able to put together the common sense stuff. I would appreciate instructions, examples, and where codes provided should be put.

    EDIT: The tutorial on how to battle in the original games would be a good example of what I'm trying to do. Or Krane talking to you during your first battle in Pokemon XD.

    UPDATE: So I've been messing around in the code, and this is what I've come up with. I haven't tested it and I'm sure it won't work, but can anyone confirm this or nudge me more in the right direction?

    I put this under #Initialize Battle in PokeBattle_Battle between Weather and Abilities:

    elsif @weather==PBWeather::STRONGWINDS
    pbCommonAnimation("StrongWinds",nil,nil)
    pbDisplay(_INTL("The wind is strong."))
    end
    if $game_switches[63] = true
    pbDisplay(_INTL("The Poké Ball you found before is glowing in your hand!"))
    pbDisplay(_INTL("Krane: What's this? You're glowing."))
    pbDisplay(_INTL("I wonder...? Hey, try catching that Shadow Pokémon!"))
    pbDisplay(_INTL("I know it belongs to someone else, but just trust me."))
    end
    pbOnActiveAll # Abilities

    That should call those messages up while that switch is active. It will be turned on just before the battle starts.

    And I put this under attacking, hoping to disable attacks when that same switch is still on, for the same battle:

    # Attacking.
    ################################################################################
    def pbCanShowFightMenu?(idxPokemon)
    thispkmn=@battlers[idxPokemon]
    if !pbCanShowCommands?(idxPokemon)
    return false
    end
    #Starter Pokemon
    if $game_switches[63] = true && foe.totalhp>2
    pbDisplayPaused(_INTL("Krane: Try and catch that Pokémon!"))
    return false
    end
    # No moves that can be chosen

    I didn't get any errors, so I'm assuming I did the code language right at least.

    FINAL UPDATE:

    I figured it out on my own! Just had to go into PokeBattle_Battle and add a conditional branch in two places, one in the battle initialization and one to disable the player from being able to use any moves.
     
    Last edited:
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Hopefully someone can chime in with a better/less hacky way, but I'm pretty confident you could wrangle something by using pbDisplay (I think that's what it's called—check what the moves/abilities use to say things) to talk to the player. You'd introduce a global switch that's on during the tutorial battle, and put pbDisplay calls in the battle system when you detect situations that warrant a message (you'll probably also want to prevent those messages from being displayed again); you can look at how berries and items trigger to have an idea about how to write checks for those situations.

    Or maybe you'll want to detect those situations after all the other end-of-turn effects happen.

    In any case I guess you'd end up with something a little like:

    Code:
    if SWITCH && !@said_snag && foe.hp < (foe.totalhp/2)
      pbDisplay("Now, snag it!")
      @said_snag = true
    end

    (Except that this code almost certainly doesn't work since I haven't bothered to actually look at Essentials)
     
    10
    Posts
    4
    Years
    • Seen Jul 25, 2020
    Hopefully someone can chime in with a better/less hacky way, but I'm pretty confident you could wrangle something by using pbDisplay (I think that's what it's called—check what the moves/abilities use to say things) to talk to the player. You'd introduce a global switch that's on during the tutorial battle, and put pbDisplay calls in the battle system when you detect situations that warrant a message (you'll probably also want to prevent those messages from being displayed again); you can look at how berries and items trigger to have an idea about how to write checks for those situations.

    Or maybe you'll want to detect those situations after all the other end-of-turn effects happen.

    In any case I guess you'd end up with something a little like:

    Code:
    if SWITCH && !@said_snag && foe.hp < (foe.totalhp/2)
      pbDisplay("Now, snag it!")
      @said_snag = true
    end

    (Except that this code almost certainly doesn't work since I haven't bothered to actually look at Essentials)

    Thanks for pointing me in the right direction! I'll see what I can do with what you've told me. I was thinking I might be able to look at moves or abilities and see how they make messages appear in battle, and if nothing else, I would just make an ability for what I'm wanting to happen. But I would have to change the ability back to the pokemon's original ability, and that might be a pain. I'll see what I can do. Hopefully, someone else will come through as well.
     
    Back
    Top