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
2,087
Reaction score
1,508
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

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,975
Members
137,563
Latest member
cexojow
Top