• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

Player Stamina - how to tell when player is walking?

  • 118
    Posts
    11
    Years
    HI,
    I was just wondering what script/scripts to look at to tell if the player is walking or not. I have a stamina system i want to implement where when the player is walking to decrease stamina by one and when stamina reaches 0, the player can no longer run. But the problem is, im not sure how to tell when the player is walking or not and i have tried looking through the scripts with no luck understanding where to look.
    Help would be appreciated. Thank!
     
    What you're looking to do is actually to add a little special something to a pre-existing event handler called Events.onStepTakenTransferPossible.
    This is actually already done in Pokemon, just backwards. It's a Safari Zone thing. Instead of counting steps up, you're looking to count steps down.

    I'd recommend taking a thorough look at the Safari Zone code, but I'll leave you with this snippet I copy-pasted out of there to give you an idea of how it's done. Obviously you still need to initialize all the variables and such:

    Code:
    Events.onStepTakenTransferPossible+=proc {|sender,e|
       handled=e[0]
       next if handled[0]
       if pbInSafari? && pbSafariState.decision==0 && SAFARISTEPS>0
         pbSafariState.steps-=1
         if pbSafariState.steps<=0
           Kernel.pbMessage(_INTL("PA:  Ding-dong!\1")) 
           Kernel.pbMessage(_INTL("PA:  Your safari game is over!"))
           pbSafariState.decision=1
           pbSafariState.pbGoToStart
           handled[0]=true
         end
       end
     
    What you're looking to do is actually to add a little special something to a pre-existing event handler called Events.onStepTakenTransferPossible.
    This is actually already done in Pokemon, just backwards. It's a Safari Zone thing. Instead of counting steps up, you're looking to count steps down.

    I'd recommend taking a thorough look at the Safari Zone code, but I'll leave you with this snippet I copy-pasted out of there to give you an idea of how it's done. Obviously you still need to initialize all the variables and such:

    Code:
    Events.onStepTakenTransferPossible+=proc {|sender,e|
       handled=e[0]
       next if handled[0]
       if pbInSafari? && pbSafariState.decision==0 && SAFARISTEPS>0
         pbSafariState.steps-=1
         if pbSafariState.steps<=0
           Kernel.pbMessage(_INTL("PA:  Ding-dong!\1")) 
           Kernel.pbMessage(_INTL("PA:  Your safari game is over!"))
           pbSafariState.decision=1
           pbSafariState.pbGoToStart
           handled[0]=true
         end
       end

    thanks i got it working, at least the first part :)

    so this is checking if the player is moving, is there something that checks if the player is idle? so that when the player is idle the player then regains stamina?

    Edit : nvm i figured it out. now the part is to disallow the player when stamina is 0. I've looked at "def pbCanRun?" but im not quite sure as to how it works

    Edit 2: Thanks for the above help. i was able to figure everything else out :)
     
    Last edited:
    Back
    Top