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

Player Stamina - how to tell when player is walking?

119
Posts
10
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!
     
    32
    Posts
    9
    Years
    • Seen Jun 15, 2015
    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
     
    119
    Posts
    10
    Years
  • 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