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

Making a "Challenge Button"

14
Posts
9
Years
    • Seen Sep 25, 2023
    (This should seem familiar to anyone who's played Tetra Master--or certain TCG-based video games.)

    In this scenario, when the player presses the "V" key, the following things should occur in immediate sequence:
    - pbExclaim triggers on the player's sprite, causing a "!" to appear above his/her head
    - Global Switch 100 is turned on
    - Input::C is triggered (as if the player pressed the "C" key)
    - Global Switch 100 is turned off

    If I'm right, this should mean:
    1. If you press V in front of most events, it will interact with them normally (as if you pressed C).
    2. If you press V in front of an event that specifically has a Condition set for Switch 100, you'll get a different result than if you pressed C.

    In other words, I want to make the "V" key a "challenge the person I'm facing to a battle" button. It could be used to battle trainers you wouldn't normally battle--like a Professor, or the nurse at a Pokémon Center. It could also be used to fish for rematches, in a somewhat similar way to the canonical "Vs. Seeker" item.

    I've put the following code in Scene_Map, starting at line 156:
    Code:
        if Input.trigger?(Input::V)
          unless pbMapInterpreterRunning? or $game_player.moving?
             if $game_switches[100]
             $game_switches[100]=false
             else
             $game_switches[100]=true
             pbExclaim(EV023)
           end
         end
       end
    That part is working just fine. It toggles switch 100 whenever you press the V key. But, I haven't figured out how to...
    - Get pbExclaim to trigger over the player's head, instead of over an event.
    - Have the script trigger Input::C, or an equivalent.

    Presumably, I could simply have switch 100 turn off after Input::C was triggered. (It wouldn't need to "toggle" like it currently does, I think.)


    I've tried a few different things, but feel as though I'm at a dead-end... Needless to say, I'm kind of a noob, but, any help would be much appreciated~!
     
    1,224
    Posts
    10
    Years
  • I was just wondering about how to do that the other day, unfortunately I don't have an answer for you. I do have a bit of advice though. Change
    Code:
    if $game_switches[100]
             $game_switches[100]=false
             else
             $game_switches[100]=true
    end
    to
    Code:
    $game_switches[100]=!$game_switches[100]
    This toggles it in a much faster fashion, without having to use a conditional branch.
     
    14
    Posts
    9
    Years
    • Seen Sep 25, 2023
    Cool, that does seem to work a bit better. Thanks.~

    (I still haven't made any real headway, unfortunately.)
     
    1,224
    Posts
    10
    Years
  • Oh, I think I figured it out. add the red part to this, which is in def update in Scene_Map

    Code:
    if Input.trigger?(Input::C) [COLOR="Red"]|| $game_switches[100][/COLOR]
          unless pbMapInterpreterRunning?
            [COLOR="red"]$game_switches[100]=false[/COLOR]
            $PokemonTemp.hiddenMoveEventCalling=true
          end
        end

    Edit: And I would have your V button turn a second switch on, and your actual event will use that in it's conditional and turn it off at the end. That way, you have one switch controlling the input and can be turned off so not to try and input too many times, and have the other switch be used by events.
     
    14
    Posts
    9
    Years
    • Seen Sep 25, 2023
    Oh, I think I figured it out. add the red part to this, which is in def update in Scene_Map

    Code:
    if Input.trigger?(Input::C) [COLOR="Red"]|| $game_switches[100][/COLOR]
          unless pbMapInterpreterRunning?
            [COLOR="red"]$game_switches[100]=false[/COLOR]
            $PokemonTemp.hiddenMoveEventCalling=true
          end
        end

    Edit: And I would have your V button turn a second switch on, and your actual event will use that in it's conditional and turn it off at the end. That way, you have one switch controlling the input and can be turned off so not to try and input too many times, and have the other switch be used by events.

    If I'm understanding your edit correctly (and forgive me if I'm not), that could cause a problem. If you pressed V in the middle of nowhere, it would turn the (new) switch on and leave it on... Needless to say, if that new switch is still on when you go talk to a Pkmn Center Nurse, you'll end up battling her when you wanted to heal!

    The part above that, though, was a huge help.

    Thanks to you two, I think it's working~! It hasn't been stress-tested yet, but, it's been functioning for me so far. For anyone who might want to know how this (currently) works, I've detailed it in the spoilerbox below.

    Spoiler:
     
    Last edited:

    Bowlstir

    Media Arts and Game Development
    199
    Posts
    16
    Years
  • This is really neat and I'll try and implement this in my game.

    Thanks.
     
    Back
    Top