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,808
Reaction score
1,268
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

I started really going in on my project April of last year... I'm just now making starting the actual game... making assets (and not even all of them), whoooo... TIME SINK.


Imagine being a pleb and using --------------------.js :LZSwink:
Ami
--- Survival For RPGist Part 2 ---

Survivalist: Now,I going to Test you: Fishing with Spear
M.Spear Knight: Leave it to me.
(M.Spear Knight Spearing the Fish with His Battle Spear)
M.Spear Knight: How it is?
Survivalist: I know you did it,but...Is that the Spear for Battle,not for Fishing?
M.Spear Knight: But,is that same?
Survivalist: (Sigh)...Whatever

Forum statistics

Threads
102,944
Messages
996,178
Members
134,408
Latest member
SosukeTheBro
Top