• 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!
  • 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] Doomsday Timer

  • 19
    Posts
    7
    Years
    • Seen Aug 14, 2021
    Hello all!

    I'm working on a short Pokemon fangame and I'm interested in adding a possibly optional feature: The game must be completed within 10 hours. After 10 in-game hours have elapsed, no matter where the player is at the time, they get a non-standard Game Over and must restart.

    I have a couple of ideas for how to implement this, but nothing seems like the perfect solution. Most time-based events trigger based on real time, and I don't want the player to have to play for ten consecutive hours. The in-game timer only goes up to 99 minutes, so that's out. The best bet seems to be to base the trigger on the in-game time played, but I'm not sure where this information is stored, how to track it, or how to make the countdown visible to the player.

    What would y'all recommend?
     
    I haven't used timers personally. But what I'd do is run a timer for 60 mins, after 60 I'll increment a variable by 1 and restart the timer. Then I'll continue this until the variable value is 10. When it reaches 10 then its game over.

    I hope I could help.
     
    At the moment I'm trying to cobble something together out of the Bug Catching Contest code, but it's slow, error-filled going. Ten one-hour timers may be the best solution.

    Edit: No, that's not going to work. I tried it, and the in-game timer pauses during battles. That's not really in the spirit of what I'm going for.
     
    Last edited:
    If you look at the trainer card, there's this bit here.
    Code:
        totalsec = Graphics.frame_count / Graphics.frame_rate
        hour = totalsec / 60 / 60
        min = totalsec / 60 % 60
    Graphics.frame_count is the number of frames the game has been running for, and it's saved and restored in the save file.

    You don't actually need to convert it to hours and minutes, you can just compare it with the number of seconds elapsed.

    That's 100% ingame time, though I don't know if it keeps counting if the game loses focus. Oh and you can't have any scripts that mess with Graphics.frame_rate
     
    Back
    Top