Michael Super Simple Diagonal Movement Patch

● ARCHIVED · READ-ONLY
Started by Mike 14 posts View original ↗
  1. Michael Super Simple Diagonal Movement Patch

    Introduction
    This is a simple script to enable diagonal movement by default. It's so simple that it's less than 50 lines, I could bleed to metaphorical dead.


    How to Use

    Put it under material, above main.

    if you're using another movement script, put this above that script.

    Script

    Spoiler
    Code:
    #==============================================================================
    # Michael Basic 8D
    #==============================================================================
    class Game_Map
      def x_with_direction(x, d)
       x + ((d == 9 || d == 6 || d == 3) ? 1 : ((d == 7 || d == 4 || d == 1) ? -1 : 0))
      end
      def y_with_direction(y, d)
       y + ((d == 1 || d == 2 || d == 3) ? 1 : ((d == 7 || d == 8 || d == 9) ? -1 : 0))
      end
      def round_x_with_direction(x, d)
       round_x(x + ((d == 9 || d == 6 || d == 3) ? 1 : ((d == 7 || d == 4 || d == 1) ? -1 : 0)))
      end
      def round_y_with_direction(y, d)
       round_y(y + ((d == 1 || d == 2 || d == 3) ? 1 : ((d == 7 || d == 8 || d == 9) ? -1 : 0)))
      end
    end
    class Game_Character < Game_CharacterBase
      def turn_right_90
       case @direction
         when 1; set_direction(7); when 2; set_direction(4)
         when 3; set_direction(1); when 4; set_direction(8)
         when 6; set_direction(2); when 7; set_direction(9)
         when 8; set_direction(6); when 9; set_direction(3)
       end
      end
      def turn_left_90
       case @direction
         when 1; set_direction(3); when 2; set_direction(6)
         when 3; set_direction(9); when 4; set_direction(2)
         when 6; set_direction(8); when 7; set_direction(1)
         when 8; set_direction(4); when 9; set_direction(7)
       end
      end
    end
    class Game_Player < Game_Character
      def move_by_input
       return if !movable? || $game_map.interpreter.running?
       case Input.dir8
         when 2,4,6,8; move_straight(Input.dir8)
         when 1; move_diagonal(4, 2); when 3; move_diagonal(6, 2)
         when 7; move_diagonal(4, 8); when 9; move_diagonal(6, 8)
       else; end
      end
    end
    Terms

    Feel free to change, edit, use like as a slave, burn maybe.

    Credit is also optional

    [10/1/2019] edit: text format is updated to display the script
  2. You, sir, are a scholar and a gentleman!

    Thank you for this.  It's going to make moving around so much better.
  3. Haha, thanks. There are multiple diagonal script out, the aim of this script is too reduce the amount of process calling and variable checks by making the script static, therefore performance wise is better than most. : p
  4. It might be worth putting in your OP that this script disables the mouse (or at least it does if you are using Shaz's Mouse script).  Sadly this means that I shan't be able to use your script after all.
  5. Tested, put it above Shaz script and it should work with the keypad.

    Shaz mouse doesn't seem to support diagonal movement.
  6. It does indeed work with the keypad, thanks.  Yet another reason for me to stick with arrows for my own personal game playing.  
  7. diagonal movement method was provided in the default engine, but never used (not sure why, such a great feature), but mouse input method isn't provided, so scripter needs to define them, and defining them requires patient. : x

    Anyway, thanks for reporting, I'll update my first post on how to use the script.

    Code:
    if you're using another movement script, put this above that script.
  8. Although you say credit is optional, I would like to give it, so is it Mike, Michael or something else?
  9. Mike is my nick since it's easier for my pals to address me, but please go with Michael. Credit page that uses nickname  instead of the real/screen name is kinda funny. : p
  10. well, Mike is your screen name... XD
  11. I was quite lucky that "Mike" hadn't been taken yet. lol
  12. Script is broken, the forum update messed it up...
  13. this should be good.
    diagonal movement
    Code:
    #==============================================================================
    # Michael Basic 8D
    #==============================================================================
    class Game_Map
      def x_with_direction(x, d)
        x + ((d == 9 || d == 6 || d == 3) ? 1 : ((d == 7 || d == 4 || d == 1) ? -1 : 0))
      end
      def y_with_direction(y, d)
        y + ((d == 1 || d == 2 || d == 3) ? 1 : ((d == 7 || d == 8 || d == 9) ? -1 : 0))
      end
      def round_x_with_direction(x, d)
        round_x(x + ((d == 9 || d == 6 || d == 3) ? 1 : ((d == 7 || d == 4 || d == 1) ? -1 : 0)))
      end
      def round_y_with_direction(y, d)
        round_y(y + ((d == 1 || d == 2 || d == 3) ? 1 : ((d == 7 || d == 8 || d == 9) ? -1 : 0)))
      end
    end
    class Game_Character < Game_CharacterBase
      def turn_right_90
        case @direction
          when 1; set_direction(7);
          when 2; set_direction(4)
          when 3; set_direction(1);
          when 4; set_direction(8)
          when 6; set_direction(2);
          when 7; set_direction(9)
          when 8; set_direction(6);
          when 9; set_direction(3)
        end
      end
      def turn_left_90
        case @direction
          when 1; set_direction(3);
          when 2; set_direction(6)
          when 3; set_direction(9);
          when 4; set_direction(2)
          when 6; set_direction(8);
          when 7; set_direction(1)
          when 8; set_direction(4);
          when 9; set_direction(7)
        end
      end
    end
    class Game_Player < Game_Character
      def move_by_input
        return if !movable? || $game_map.interpreter.running?
        case Input.dir8
          when 2,4,6,8;move_straight(Input.dir8)
          when 1;move_diagonal(4, 2);
          when 3;move_diagonal(6, 2)
          when 7;move_diagonal(4, 8);
          when 9;move_diagonal(6, 8)
        else;
        end
      end
    end