Disable sprinting/dashing using scripting

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.
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. 😅

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. 😤
Thanks for this excellent suggestion! This really helps!

I will certainly try this and let you know if it works as intended.
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!

Original thread: https://forums.rpgmakerweb.com/threads/disable-sprinting-dashing-using-scripting.125136/