Block player movement

● ARCHIVED · READ-ONLY
Started by XGuarden 9 posts View original ↗
  1. I look for a way to block player movement.
    I just want to have control when he can move or not in mycinematic.
    For be able at start of cinematic to disable his movement and enable them back at the end.

    Please not, these event cannot be run in autorun for various reason.
    I really need a way to block and unblock player in a line of code.


    Thanks.
  2. Call these by event script. EDIT #2: forgot to add number pad keys too, not just arrow keys
    JavaScript:
    // disable move by 4 directions
    var pe = {37:false,38:false,39:false,40:false,98:false,100:false,102:false,104:false};
    for(i in pe) Input.keyMapper[i] = pe[i];
    and re-enable with this
    JavaScript:
    // enable move by 4 directions
    var pe = {37:"left",38:"up",39:"right",40:"down",98:'down',100:'left',102:'right',104:'up'};
    for(i in pe) Input.keyMapper[i] = pe[i];

    interestingly enough, you can get creative with this script to reverse the direction for some kind of funky magic spell, and use the same enable function to go back
    JavaScript:
    // reverse by 4 directions (this is cruelty)
    var pe = {37:"right",38:"down",39:"left",40:"up",98: 'up',100:'right',102:'left',104:'down'};
    for(i in pe) Input.keyMapper[i] = pe[i];
  3. mogwai said:
    Call these by event script. EDIT #2: forgot to add number pad keys too, not just arrow keys
    JavaScript:
    // disable move by 4 directions
    var pe = {37:false,38:false,39:false,40:false,98:false,100:false,102:false,104:false};
    for(i in pe) Input.keyMapper[i] = pe[i];
    and re-enable with this
    JavaScript:
    // enable move by 4 directions
    var pe = {37:"left",38:"up",39:"right",40:"down",98:'down',100:'left',102:'right',104:'up'};
    for(i in pe) Input.keyMapper[i] = pe[i];

    interestingly enough, you can get creative with this script to reverse the direction for some kind of funky magic spell, and use the same enable function to go back
    JavaScript:
    // reverse by 4 directions (this is cruelty)
    var pe = {37:"right",38:"down",39:"left",40:"up",98: 'up',100:'right',102:'left',104:'down'};
    for(i in pe) Input.keyMapper[i] = pe[i];
    If I understand, you actually blocking keyboard button. But what if player use mouse or hud with arrow?
  4. Doh! I didn't think of that.

    Try these to disable click move.
    // disable move by click
    if(Game_Character.prototype.findDirectionToCached === undefined)
    Game_Character.prototype.findDirectionToCached = Game_Character.prototype.findDirectionTo;
    Game_Character.prototype.findDirectionTo = function(){
    return false;
    }

    and to re-enable
    // enable move by click
    Game_Character.prototype.findDirectionTo = Game_Character.prototype.findDirectionToCached;


    EDIT: RPG Maker MV has HID support too? Hold on a second. I'm dumb.
  5. Ignore those other two ideas. This will cancel all three possible inputs' movement at once.
    PHP:
    // disable move by all input
    if($gamePlayer.moveByInputCached === undefined)
        $gamePlayer.moveByInputCached = $gamePlayer.moveByInput;
    $gamePlayer.moveByInput = function(){
        return false;
    }
    and to enable
    PHP:
    // enable move by all input
    $gamePlayer.moveByInput = $gamePlayer.moveByInputCached;
  6. mogwai said:
    Ignore those other two ideas. This will cancel all three possible inputs' movement at once.
    PHP:
    // disable move by all input
    if($gamePlayer.moveByInputCached === undefined)
        $gamePlayer.moveByInputCached = $gamePlayer.moveByInput;
    $gamePlayer.moveByInput = function(){
        return false;
    }
    and to enable
    PHP:
    // enable move by all input
    $gamePlayer.moveByInput = $gamePlayer.moveByInputCached;
    Thanks, that perfect. Any way to mark you for best answer? I did't find the button with the new forum updat.
    By the way, if I disable in some part of the game the mouse move, if I put a cute scene with these setting, that will reanable it?
  7. have you looked at YEP_stopmapmovement plugin?
  8. doranikofu said:
    have you looked at YEP_stopmapmovement plugin?
    In the past yes, but I did't remember why I did't use it. I think it's something with compatibility issue with other plugging.
  9. [closed]IgnoreMe[/closed]