Character tracks mouse

i have a request that when the script is activated the characters will move toward the mouse with no input from the mouse or the keyboard and while the script is activated all other inputs are disabled while the characters are moving toward the cursor
And how do you want to activate and deactivate the script?
With all other inputs deactivated half the event options will be gone...
And how do you want to activate and deactivate the script?
With all other inputs deactivated half the event options will be gone...
i was thinking that it could be activated in game with an event or it can have a condition for running the script
activating is not the problem - how do you want to deactivate it?
Because you cannot trigger events most events while such a script is running - the only way to deactivate would be either by time or by automatically touching an event that then calls a function, and the plugin writer will need to know how you plan to use this to give you the correct functions for this.
activating is not the problem - how do you want to deactivate it?
Because you cannot trigger events most events while such a script is running - the only way to deactivate would be either by time or by automatically touching an event that then calls a function, and the plugin writer will need to know how you plan to use this to give you the correct functions for this.
the goal of the script is to create an chase sequence in my game the player would control the character and move it around to dodge enemy fire and once the player reach the end the script would be deactivated
I've tinkered and think I got something to work. When game switch 20 is on, the player will follow the mouse. (edit all instance of $gameSwitches value 20 for a different switch)
followmouse1o.gif

PHP:
window.addEventListener("mousemove",function(event){
   if($gameSwitches !== null && $gameSwitches.value(20)){
       var x = Graphics.pageToCanvasX(event.pageX);
       var y = Graphics.pageToCanvasY(event.pageY);
       var x2 = $gamePlayer._x;
       var y2 = $gamePlayer._y;
       var x3 = Math.round(x / 48);
       var y3 = Math.round(y / 48);
       if(Graphics.isInsideCanvas(x, y) && x2 !== x3 && y2 !== y3){
           TouchInput._mousePressed = true;
           TouchInput._pressedTime = 0;
           TouchInput._onTrigger(x, y);
       }
   }
});
It kind of looks like a rapid-clicking bug, like when the mouse event is stuck, but that may be an effect you want?

If not...
followmouse2o.gif

Add this after it and it will just follow a plain mouse instead of that flashy space.
PHP:
Sprite_Destination.prototype.updatePosition1 = Sprite_Destination.prototype.updatePosition;
Sprite_Destination.prototype.updatePosition = function() {
    if(!$gameSwitches.value(20)){
       return this.updatePosition1.apply(this,arguments);
    }
    this.x = 999;
    this.y = 999;
};

Add this after it, if you want to turn the switch off automatically by clicking the mouse once. Don't add it if you want to handle the switch with your own thing.
PHP:
window.addEventListener("click",function(event){
   if($gameSwitches !== null && $gameSwitches.value(20)){
       $gameSwitches.setValue(20,false);
   }
});
I've tinkered and think I got something to work. When game switch 20 is on, the player will follow the mouse. (edit all instance of $gameSwitches value 20 for a different switch)
followmouse1o.gif

PHP:
window.addEventListener("mousemove",function(event){
   if($gameSwitches !== null && $gameSwitches.value(20)){
       var x = Graphics.pageToCanvasX(event.pageX);
       var y = Graphics.pageToCanvasY(event.pageY);
       var x2 = $gamePlayer._x;
       var y2 = $gamePlayer._y;
       var x3 = Math.round(x / 48);
       var y3 = Math.round(y / 48);
       if(Graphics.isInsideCanvas(x, y) && x2 !== x3 && y2 !== y3){
           TouchInput._mousePressed = true;
           TouchInput._pressedTime = 0;
           TouchInput._onTrigger(x, y);
       }
   }
});
It kind of looks like a rapid-clicking bug, like when the mouse event is stuck, but that may be an effect you want?

If not...
followmouse2o.gif

Add this after it and it will just follow a plain mouse instead of that flashy space.
PHP:
Sprite_Destination.prototype.updatePosition1 = Sprite_Destination.prototype.updatePosition;
Sprite_Destination.prototype.updatePosition = function() {
    if(!$gameSwitches.value(20)){
       return this.updatePosition1.apply(this,arguments);
    }
    this.x = 999;
    this.y = 999;
};

Add this after it, if you want to turn the switch off automatically by clicking the mouse once. Don't add it if you want to handle the switch with your own thing.
PHP:
window.addEventListener("click",function(event){
   if($gameSwitches !== null && $gameSwitches.value(20)){
       $gameSwitches.setValue(20,false);
   }
});

Thank you this is exactly what I am looking for I really appreciate it

Original thread: https://forums.rpgmakerweb.com/threads/character-tracks-mouse.75757/