Disable sprinting/dashing using scripting

NeptuneTron

The Salticid Scholar of the North
Veteran
Joined
Jan 13, 2018
Messages
40
Reaction score
25
First Language
English
Primarily Uses
RMMV
So I have a certain map that's set to allow the player to dash, which I think is preferable, as it's somewhat large. However, during certain times, I need to disable dashing. Anyone know how? I looked through all the scripting references and documentation I could find, but I'm probably missing something.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,815
Reaction score
1,275
First Language
EN
Primarily Uses
RMMZ
By default the game just checks the current map setting:
JavaScript:
Game_Map.prototype.isDashDisabled = function() {
    return $dataMap.disableDashing;
};
You could alter this value mid-game with a Script command:
JavaScript:
$dataMap.disableDashing = true;
I wouldn't recommend that, though, mostly because $dataMap reloads whenever the player changes map or when they load a previous save. :kaoswt2:

Instead you could write a short plugin to alias this method, e.g. make it so that dashing is disabled when a particular game switch is turned on:
JavaScript:
(function(alias) {
'use strict';
  const SWITCH_ID = 1;  // switch ID to turn on to disable dashing
  Game_Map.prototype.isDashDisabled = function() {
    return $gameSwitches.value(SWITCH_ID) || alias.apply(this, arguments);
  };
})(Game_Map.prototype.isDashDisabled);
Just save it as a .js file (Save As > File Type: All Files, Filename: whateverYouLike.js) and import as a plugin. :kaopride:
 

NeptuneTron

The Salticid Scholar of the North
Veteran
Joined
Jan 13, 2018
Messages
40
Reaction score
25
First Language
English
Primarily Uses
RMMV
Thanks for this excellent suggestion! This really helps!

I will certainly try this and let you know if it works as intended.
 

NeptuneTron

The Salticid Scholar of the North
Veteran
Joined
Jan 13, 2018
Messages
40
Reaction score
25
First Language
English
Primarily Uses
RMMV
OK, so I don't really understand plugins at all, especially how to make/use my own, even if all the script is already given to me. Because of that, I ended up using a workaround of sorts.

Originally, since I'd been using parallel events anyhow (and the issue with the status being changed when the player loading a save or entering a new map thereby being bypassed), I was planning to just use $dataMap.disableDashing = true.

However, since I wanted to be able to switch that based on the current actor (using that parallel command I mentioned), and furthermore since I'm not certain that all of my maps in the future will have sprinting enabled, I couldn't just reenable Dashing with an actor swap.

My first thought was to have some kind of call that would refresh the map (using the potential problem as the solution), but I couldn't figure out how to make that work. If you know how to do that, I'd appreciate it, despite the fact that I have another workable solution now.

Basically, instead of disabling sprinting, I just slowed the actor down whenever they're active. So when the specific actor starts leading the party, the parallel event reduces their speed to 3 (2x slower), and when any other actor starts leading the party, the parallel event returns their speed to 4 (normal).

This means that the specific actor still feels slower (the problem dashing was causing), without having to figure out how to disable dashing. If you want more details on how I did that, I'll be happy to provide them, just let me know.

Thanks Caethyris for your suggestions, they really pointed me in the right direction even if I didn't end up using them in the end!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Part of me is really missin' the good 'ol days of RM '95... goodness just seems like such simpler times
Just got two Switch E-Shop 20$ gift cards... Is 3D All-Stars worth it? Or should I get something like Celeste? I'd love to know your opinion!
I’m looking at the MZ full body images and I think Priscilla is taller than Reid...
Ami
--- Music Selection ---

M.Archer: It's Music Station,You can Change the Music as you like.
F.Healer: i want to hear the Romantic Music.
M.Fighter: Then,i want the Hard-Rock one!
(the Troll Song has played)
M.Archer: Hey,i hear this Music.
F.Healer: It's popular from Internet Music,i wonder who change it?
Hero: I change it.
Entire Party: YOU????

Forum statistics

Threads
103,042
Messages
996,908
Members
134,516
Latest member
Pumpkinnubbin
Top