Key Triggered Limited Speed Boost

Joined
Jan 23, 2019
Messages
19
Reaction score
2
First Language
English
Primarily Uses
RMMV
Hello again,

I'm making a racing game and am curious to turn the shift key dash function into more of a limited availability speed boost. Basically, I want the shift key (or any key really) to function as it does now but only for x amount of time. I would like this function to be tied to an on screen meter that depletes as you hold the key. I'll complicate it further and say that once the speed meter has diminished fully, I would like it to slowly start refilling to the halfway point to be used once again for a finishing boost. At no point before being empty should the meter begin to replenish. Also, I'm not looking to turn the speed change on or off, but am looking for the speed to respond to the button being pressed.

Thanks and let me know if there's anything I should clarify. I'm curious if the solution is to create something as a common event or conditional branch that relates to my time system and trigger that through the use of a keyboard script...but I'll leave the answers up to people who know what they're talking about.
 
Joined
Jan 23, 2019
Messages
19
Reaction score
2
First Language
English
Primarily Uses
RMMV
Hmm looks like it could potentially work as a solution but I'm still not entirely sure how to implement it. Does the stamina automatically deplete over time or do I have to adjust that somehow? Thinking I should set up a common event but still feel in over my head on this one compared to other plugins.

Also, should I be concerned that this is such an old plug in? I'd hate to find a great solution and then have it not work a year down the road.
 
Joined
Jan 23, 2019
Messages
19
Reaction score
2
First Language
English
Primarily Uses
RMMV
I tried downloading the latest version and playing around a bit with it, but unless I turn it off I encounter an error message right after the title screen.
Screen Shot 2019-02-04 at 11.07.43 PM.png
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Can you please provide the full error message from the Console? (press F8 during playtest to open the Console)
 
Joined
Jan 23, 2019
Messages
19
Reaction score
2
First Language
English
Primarily Uses
RMMV
I'm working on a mac and for whatever reason can't get F8 to open the Console.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
According to the link Aloe provided, the "open console" key combination on Mac is ⌘+⌥+i. This should open a separate window next to the game playtest one; this second window is called the "console". Errors will cause a message to appear in the console window, in red text. Clicking these error messages often shows a "traceback": a detailed list of places the error passed through before the game could no longer ignore it. The traceback can help to identify the origin of the error and thus the source of the problem. :)

If that doesn't work, you may be experiencing a bug related to a partially-updated project (1.5.2 -> 1.6.1+). If you started this project in an earlier editor version (v1.6.1 stable was released on 2018 June 21) then I strongly recommend you update your project files as detailed in this announcement, under "Updating your Projects": https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-v1-6-1-stable-release.96715/
 
Joined
Jan 23, 2019
Messages
19
Reaction score
2
First Language
English
Primarily Uses
RMMV
⌘+⌥+i literally doesn't exist as a key on my keyboard. I'm using 1.61 and only downloaded it back in December so I think I'm alright there.

I did manage to get a dev window to open using F8 and turned the silver plug in back on to see what I could dig up about the error message. I clicked on the 1 error showing and it displayed this...

If it makes any difference I'm using version 1.10 of the script found deeper in the linked thread.Screen Shot 2019-02-05 at 10.11.27 AM.png
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
:kaoswt: The + in ⌘+⌥+i indicates a key combination: it's three keys to press simultaneously, not just one. I see you got it with F8 though, so all's good. :)

It seems the error is due to a faulty line of code...I should've checked the thread more thoroughly before recommending it, oops. :kaoback: Shaz posted a fix, though (requires editing a line of the plugin in a text editor):
https://forums.rpgmakerweb.com/index.php?threads/silvers-dash-stamina.51566/page-4#post-641949
Hi!
Those with the:
"Cannot assign to read only property 'parent' of 1"

Just replace line 1034 of the stamina plugin:
this.addChild(Silv.DashStamina.Window, Silv.DashStamina.Window_Z);

with this:
this.addChild(Silv.DashStamina.Window); //, Silv.DashStamina.Window_Z)

It's working for me now! Thanks Khaz!

Just mentioning it as an alternative: Yanfly's Dash Toggle gives you plugin commands to enable/disable dashing, but doesn't have anything like an automatic cut-off or stamina gauge. However, you could implement that aspect of it with some eventing if you're feeling up to it: parallel event, Control Variables to track stamina, Show Picture & Move Picture for displaying the gauge bar/background, Plugin Command & Wait to disable/enable dashing as needed.
 
Joined
Jan 23, 2019
Messages
19
Reaction score
2
First Language
English
Primarily Uses
RMMV
Thanks for the reply caethyril! For the record I was referring to the middle key in the combination...but I digress.

I appreciate the bug fix and I'm sure it's straight forward, but honestly I'd be more interested in trying to get something going with Yanfly's plugin. The other one is too old and the author is MIA so I don't want to invest any time in that unless I absolutely have to.

I think I'm up to it. I managed to set up a time system with milliseconds, seconds, and minutes as well as a display clock. I'm curious if I could relate the stamina use to time? As for the guage I imagine it would be a similar process of pictures when variable = x.

That said, I would love a little help getting started if you wouldn't mind walking me through it? I'm happy to provide any game info/screen shots you need.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
Sure! I just put something together in my test project that seems to be working OK. Here's the general approach I've used:
  • Have a variable for stamina, a switch for "out of breath", and a couple of pictures for the gauge (background and bar)
  • Set up the starting values and show the pictures via a map event (could call a common event if you need it in multiple places)
  • Every few frames (use a Wait command), have a parallel common event update a few things:
    • If out of breath but have enough stamina, regain breath (switch off, enable dashing)
    • Adjust stamina value based on current movement; I used $gamePlayer.isMoving() and $gamePlayer.isDashing() to check this
    • Cap stamina value between min & max; if at min, disable dashing and turn on breathless switch
    • Adjust gauge picture scale; I used a script call for this since the event command doesn't let you specify variable scale
And here's a complete text copy-paste of my events' commands~
  • Setup event:
    Code:
    ◆If:DashLimiter is OFF
      ◆Comment:Show gauge bar and background
      :       :(My background has a 2 px border, so the bar position is offset by that much)
      ◆Show Picture:#5, gaugeBack, Upper Left (20,20), (100%,100%), 255, Normal
      ◆Show Picture:#6, gauge, Upper Left (22,22), (100%,100%), 255, Normal
      ◆Comment:Initialise stamina variable and switches
      ◆Control Variables:#0009 Stamina = 300
      ◆Control Switches:#0005 Out of breath = OFF
      ◆Control Switches:#0003 DashLimiter = ON
      ◆Text:Actor3(0), Window, Bottom
      :    :Your dash ability has been limited.
      ◆
    :Else
      ◆Comment:Remove gauge and background pictures
      ◆Erase Picture:#5
      ◆Erase Picture:#6
      ◆Control Switches:#0003 DashLimiter = OFF
      ◆Text:Actor3(0), Window, Bottom
      :    :Your dash ability is no longer limited!
      ◆
    :End
  • Update event (parallel common event):
    Code:
    ◆Comment:Update 10 times/second (1 "stamina" variable, 1 "out of breath" switch)
    :       :  If out of breath and stamina >= 100, re-enable dashing
    :       :  Update stamina based on player's current move speed
    :       :  If stamina = 0, toggle out of breath switch and disable dash
    :       :  Update gauge picture according to current value of stamina variable
    :       :Assumes that the gauge pictures have been shown before enabling this event
    ◆Comment:----------------------------------------------------------------------
    ◆If:Out of breath is ON
      ◆Comment:Re-enable dashing after regaining some stamina
      ◆If:Stamina ≥ 150
        ◆Control Switches:#0005 Out of breath = OFF
        ◆Plugin Command:EnableDashing
        ◆Comment:Undo opacity change (see below)
        ◆Move Picture:#6, Upper Left (22,22), (50%,100%), 255, Normal, 1 frame
        ◆
      :End
      ◆
    :End
    ◆Comment:Check if player is currently moving, and if so, whether or not they're dashing
    :       :Update stamina variable accordingly
    ◆If:Script:$gamePlayer.isMoving()
      ◆If:Script:$gamePlayer.isDashing()
        ◆Control Variables:#0009 Stamina -= 10
        ◆
      :Else
        ◆Control Variables:#0009 Stamina += 2
        ◆
      :End
      ◆
    :Else
      ◆Control Variables:#0009 Stamina += 5
      ◆
    :End
    ◆Comment:Apply min/max stamina
    ◆If:Stamina ≤ 0
      ◆Control Variables:#0009 Stamina = 0
      ◆Comment:Also become out of breath at zero stamina, which disables dashing
      ◆Control Switches:#0005 Out of breath = ON
      ◆Plugin Command:DisableDashing
      ◆Comment:Let's make the gauge 50% transparent while recovering!
      ◆Move Picture:#6, Upper Left (22,22), (0%,100%), 128, Normal, 1 frame (Wait)
      ◆
    :Else
      ◆If:Stamina > 300
        ◆Control Variables:#0009 Stamina = 300
        ◆
      :End
      ◆
    :End
    ◆Comment:Rescale the stamina gauge to reflect current stamina value!
    :       :Via script call to avoid a tedious number of branches. >_>
    ◆Script:var picId = 6, duration = 6, fullScale = 100;
    :      :var staminaVarId = 9, staminaMax = 300;
    :      :// Change the above values as needed //
    :      :var scale = $gameVariables.value(staminaVarId) / staminaMax;
    :      :var pic = $gameScreen.picture(picId);
    :      :pic._duration = duration;
    :      :pic._targetScaleX = fullScale * scale;
    ◆Comment:Repeat again in 1/10 second = 6 frames.
    ◆Wait:6 frames
    Easy-copy version of the script call at the end:
    Code:
    var picId = 6, duration = 6, fullScale = 100;
    var staminaVarId = 9, staminaMax = 300;
    // Change the above values as needed //
    var scale = $gameVariables.value(staminaVarId) / staminaMax;
    var pic = $gameScreen.picture(picId);
    pic._duration = duration;
    pic._targetScaleX = fullScale * scale;
Copy/edit/adapt as much of this as you like, and if you have any questions/issues with it, feel free to ask~ :kaojoy:
 
Joined
Jan 23, 2019
Messages
19
Reaction score
2
First Language
English
Primarily Uses
RMMV
Thanks so much for posting this. I won't have time to mess with it until after the weekend but looking forward to tinkering. I'll be sure to hit you up if I run into any issues.
 
Joined
Jan 23, 2019
Messages
19
Reaction score
2
First Language
English
Primarily Uses
RMMV
Finally getting a chance to dive further into this

First question makes me feel silly but oh well...is DashLimiter just a common event with the plugin command?

Most everything else seems like it should be straight forward tinkering but I want to make sure I'm starting this off correctly.

Here's a screenshot of how I was planning on starting.

Screen Shot 2019-02-12 at 9.11.05 PM.png
 

definite_lee

Veteran
Veteran
Joined
Oct 23, 2015
Messages
151
Reaction score
189
First Language
English
Primarily Uses
Finally getting a chance to dive further into this

First question makes me feel silly but oh well...is DashLimiter just a common event with the plugin command?

Most everything else seems like it should be straight forward tinkering but I want to make sure I'm starting this off correctly.

Here's a screenshot of how I was planning on starting.

View attachment 109343
Jumping in here with a quick assist but based on the code caethyril posted, DashLimiter is a switch you need to make.
 
Joined
Jan 23, 2019
Messages
19
Reaction score
2
First Language
English
Primarily Uses
RMMV
I decided to just try a bit of a different approach just for kicks and because it was easier to wrap my head around at the moment. I'm not concerned about the images for now as that's the easy part for me, simply assigning images that correspond to the variables. I was curious to try controlling the variables via a conditional branch that registers the shift key. It seems logical assuming it doesn't just count it as 1 each time you hold it down.

Screen Shot 2019-02-12 at 10.09.26 PM.png

Tried it out and no such luck. I set up the switch as a player touch event about 10 tiles from the start line. As an autorun event it simply stopped me in my tracks. Parallel allowed me to pass but no change in the dashing. I even tried just hitting the shift button ten times to see if that would register but it did not. I also tried it with the DisableDashing plugin command but still no difference. Still curious if there's any viability in setting it up this way or if I should just go back to the suggested idea(s).
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
Like @definite_lee says, DashLimiter is my name for the switch corresponding to the parallel common event; I should've clarified that, my mistake. :kaoslp: The "out of breath" switch only gets checked within that event via Conditional Branch.

Also, as you've discovered, your common event's trigger should be Parallel. Autorun will repeat, but won't allow the player to move freely, which somewhat defeats the purpose. :p

Your "simple" example will reset Stamina to 10 every loop, which means it'll never reach 0. It will also run every frame, which is generally inadvisable. Easy mistakes to make, though! Just initialise the value in a separate event like I've suggested, and maybe add a Wait command at the end of the event. In my example, stamina starts at 300 and updates by -10 (dashing), +2 (walking), or +5 (standing) every 6 frames = 0.1 seconds. :)

The difference between "Button is pressed down" and "$gamePlayer.isDashing()" is that even if you start dashing to the next tile but release the dash key mid-move, isDashing will still recognise that you're moving fast. That's the main reason I used the script condition, less room for exploits. :kaoswt:
 
Joined
Jan 23, 2019
Messages
19
Reaction score
2
First Language
English
Primarily Uses
RMMV
I tried copying your set up line for line (minus the pictures/gauge) but still couldn't get it to function. I was able to just keep dashing even when lowering the values from 300 to 100. I'm curious if it might be because of how the scene is reached in the first place. I open on a separate map, have a quick camera scroll of the course and then transfer to the main race course where I placed the two events. The race is started by an NPC turning on the clock and making the start line passable. Should I be trying to incorporate the events into this route movement setup instead of having them as their own separate map events?

The NPC's route that starts the race... (Switch one makes the start line passable, switch two starts the time system, switch three displays the time system)
Screen Shot 2019-02-19 at 3.28.40 PM.png

Also, before getting too involved in a solution...I'm interested in setting up a "drafting" feature that might not mesh well with the $gamePlayer.isDashing function. I was going to elaborate on what I'm looking to setup, but wasn't sure if I should maybe set up a new thread? Or perhaps just message you privately, Caethyril? If you're willing to help of course. This forum is a truly incredible resource, I really appreciate y'all helping me navigate my first game.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
First, sorry: I re-read your opening post and just realised you're going for something more like a boost/fuel gauge than a stamina thing. :kaoslp: Luckily that makes things a little simpler! :kaophew:

Dashing is only applicable when the player can move freely. Normal player input is suspended while a non-parallel event is running or while the player is completing a move route assigned to them. If you're going for a kind of on-rails racer then you could try setting up your parallel event like this:
Code:
◆Comment:On-rails "fuel gauge" system
◆If:Breathless is OFF
  ◆If:Button [Shift] is pressed down
    ◆Comment:Go faster and deplete stamina
    ◆Script:$gamePlayer.setMoveSpeed(5);
    ◆Control Variables:#0001 Stamina -= 4
    ◆
  :Else
    ◆Comment:Non-boost move speed
    ◆Script:$gamePlayer.setMoveSpeed(4);
    ◆
  :End
  ◆
:Else
  ◆Comment:Slow recharge to 50
  ◆Control Variables:#0001 Stamina += 1
  ◆If:Stamina ≥ 50
    ◆Control Switches:#0002 Breathless = OFF
    ◆
  :End
  ◆
:End
◆If:Stamina ≤ 0
  ◆Comment:Disable boost, enable slow recharge
  ◆Control Variables:#0001 Stamina = 0
  ◆Control Switches:#0002 Breathless = ON
  ◆Script:$gamePlayer.setMoveSpeed(4);
  ◆
:End
◆Comment:Adjust pictures here...
◆Comment:Repeat in 1/10 second = 6 frames.
◆Wait:6 frames
As an additional bonus, this doesn't require any plugins! I've used script calls to adjust the move speed because that way the current move route is not interrupted. If you want to change a map event's move speed like this, just swap $gamePlayer for $gameMap.event(id), e.g.
Code:
$gameMap.event(1).setMoveSpeed(5);
I've put together a little demo (attached) featuring the two different systems I've mentioned, as well as a miniature 3-lap "race" to try out the boost. Probably should've done that earlier. ^_^' I uploaded it to my Google Drive, in case you're interested: link. (By the way, it says to press Q for boost, but PageUp works too.)

Otherwise it might be helpful if you could share more details about your event setup? :kaoswt:

If your "drafting" feature isn't part of the boost thing then it may be better to start a new thread. Assuming you're OK with it, I'd suggest keeping this to public threads rather than private messages...more opportunities for others to help out if I'm not around (or correct me if I am!), and it could also be helpful for anyone with a similar problem. :kaothx:
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,837
Latest member
Dabi
Top