Stop PC/NPC Movement

Stop Movement v1
RPG Maker MV Plugin
Jackkel Dragon
​
Introduction
A simple plugin to allow the developer to stop PC/NPC movement based on switches. (PC movement by events can still be run while player movement is restricted.)

How to Use
- Copy the plugin code into a .js file and add it to your project's "js/plugins/" folder. (Be sure to use the name given in the code's header!)
- Load the plugin in RPG Maker MV's plugin manager for your project.
- Set the switches used to stop PC/NPC movement. Set to -1 for unused.

Updates
- v1: First release. November 9th, 2015.

Plugin Code
v1
Spoiler
Code:
//=============================================================================// StopMovement.js//=============================================================================/*: * @plugindesc Stops player/NPC movement based on switches. * @author Jackkel Dragon * * @param PC Switch ID * @desc The ID of the switch that stops player movement. * @default -1 * * @param NPC Switch ID * @desc The ID of the switch that stops NPC movement. * @default -1 * * @help This plugin does not provide plugin commands. */(function() {    var parameters = PluginManager.parameters('StopMovement');    var PCswitchId = Number(parameters['PC Switch ID'] || -1);    var NPCswitchId = Number(parameters['NPC Switch ID'] || -1);        var _Game_Player_moveByInput = Game_Player.prototype.moveByInput;    Game_Player.prototype.moveByInput = function() {        if ($gameSwitches.value(PCswitchId))            return;        _Game_Player_moveByInput.call(this);    }        var _Game_Event_updateSelfMovement = Game_Event.prototype.updateSelfMovement;    Game_Event.prototype.updateSelfMovement = function() {        if ($gameSwitches.value(NPCswitchId))            return;        _Game_Event_updateSelfMovement.call(this);    }})();
Credits
This plugin is essentially a remake of Yanfly's VXAce script "Stop All Movement". Credit for the original script/idea goes to Yanfly.

Terms
Free to use, even for commercial projects. Credit Yanfly in your game's credits.
Shouldn't credit go to Yanfly, for the original script that you ported? And therefore, terms should match Yanfly's terms & conditions.
Edited the opening post a bit to make it more clear that Yanfly created the VXAce script I based this on.


@Shaz: Do you know if Yanfly's terms have changed? According to the old blog that I linked to, the only real change would be crediting Yanfly in the game's credits.
I believe that's the requirement, yes. But your OP says "no credit required". It should say to credit Yanfly as per Yanfly's terms, even if you don't want credit for the port.
Went ahead and linked to Yanfly's terms page, just to be safe. Hopefully that works.
Not working 4 me
Save the code below as StopMovement.js
PluginManager parameters is case-sensitive

Stopping player character with a switch works however not for stopping npc/ game event movement. (version 1.6.2)
Probably works with previous versions of MV at the time.

Credit: Jackkel Dragon and Yanfly

Code:
//=============================================================================
// StopMovement.js
//=============================================================================

/*:
 * @plugindesc Stops player/NPC movement based on switches.
 * @author Jackkel Dragon
 *
 * @param PC Switch ID
 * @desc The ID of the switch that stops player movement.
 * @default -1
 *
 * @param NPC Switch ID
 * @desc The ID of the switch that stops NPC movement.
 * @default -1
 *
 * @help This plugin does not provide plugin commands.
 */
 (function() {
     var parameters = PluginManager.parameters('StopMovement');
     var PCswitchId = Number(parameters['PC Switch ID'] || -1);
     var NPCswitchId = Number(parameters['NPC Switch ID'] || -1);
     var _Game_Player_moveByInput = Game_Player.prototype.moveByInput;
     Game_Player.prototype.moveByInput = function() {
         if ($gameSwitches.value(PCswitchId))
             return;
         _Game_Player_moveByInput.call(this);
     }
     var _Game_Event_updateSelfMovement = Game_Event.prototype.updateSelfMovement;
     Game_Event.prototype.updateSelfMovement = function() {
         if ($gameSwitches.value(NPCswitchId))
             return;
         _Game_Event_updateSelfMovement.call(this);
     }
 })();

Original thread: https://forums.rpgmakerweb.com/threads/stop-pc-npc-movement.50032/