• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - 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.

[Scripting Question] How to track players steps with a script

  • 5
    Posts
    4
    Years
    So I'm trying to make a large part of my project based around how the player spends their time, and make various events trigger after a certain number of steps (e.g. after the player enters a building, x steps later security guard npcs will be alerted to their presence and the building will go into lockdown). As a understand it, the simplest way to achieve what I want would be to have 1 event on a map autorun a script counting steps, then after x steps it will return true for a conditional branch, allowing me to put any other script (such as changing switches) within that branch so that after x steps it will trigger.

    So for example a script like

    pbCountSteps(100)

    that tracks the number of steps the player takes then returns true once they've taken that number of steps.

    Does anyone know how I would go about having a script track these steps and return true after a certain number of steps? I've tried looking into the safari zone code but i really don't understand which part of it tracks the steps.
     
    Safari zone has an instance of a class SafariState, which tracks a number of safari zone related variables. The only one you really care about is steps, which is set to the number of steps allowed in the safari zone.
    pbSafariState returns said instance of the safari zone, or makes it from scratch if it doesn't exist yet

    then it's just a matter of an onStepTaken (or its variant onStepTakenTransferPossible, which allows you to warp the player away)
    If you head over to script section SafariZone you can see the onStepTakenTransferPossible which counts down the steps variable if the safari zone is active, and it's actually a step bound safari zone in the settings. when the steps are up, the condition activates and the safari zone kicks you out.

    If you're in the mood to be exploratory, you can even look at the bug contest, which has an actual timer that runs out instead of steps, though that's a bit more complicated to read through, using an onMapUpdate to check if the timer is expired.
    It's very fun to mess with actually, I used both the safari zone step counter, and a modified bug contest timer in my game.
     
    Thanks for the help, I've managed to get a working tracking script that can show a message and kick the player out of the area.
    I'm still unsure how i'd go about being able to make the script trigger an event when the player reaches 0 steps however

    Do you have any idea how I'd go about having it change a switch when the counter reaches 0? preferably a way that lets me choose which switch it changes as part of the event call?
    My current script is in this spoiler if that helps
    Spoiler:
     
    Back
    Top