Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #==============================================================================
  2. # 8 Dir Move                                                  JV Master Script
  3. #------------------------------------------------------------------------------
  4. # Make player move in 8 dir, supports diagonal pattern.
  5. #==============================================================================
  6.  
  7. module JvScripts
  8.   module Dirs8
  9.    
  10.     Switch = 0               # Switch id for toggle 4/8 dir, 0 if always 8 dir
  11.     DiagonalSuffix = "_di"   # Suffix for 8 dir charsets
  12.                              # 8 dir charsets include in the first char
  13.                              # the orthogonal and in the second the diagonal
  14.   end
  15. end
  16.  
  17. #==============================================================================
  18. # Game CharacterBase
  19. #==============================================================================
  20. class Game_CharacterBase
  21.  
  22.   def move_diagonal(horz, vert)
  23.     @move_succeed = diagonal_passable?(x, y, horz, vert)
  24.     if @move_succeed
  25.       @x = $game_map.round_x_with_direction(@x, horz)
  26.       @y = $game_map.round_y_with_direction(@y, vert)
  27.       @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
  28.       @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
  29.       increase_steps
  30.     end
  31.     if diagonal_charset?
  32.       set_direction_diagonal(horz, vert)
  33.     else
  34.       set_direction(horz) if @direction == reverse_dir(horz)
  35.       set_direction(vert) if @direction == reverse_dir(vert)
  36.     end
  37.   end
  38.  
  39.   def set_direction(d)
  40.     if !@direction_fix && d != 0
  41.       @direction = d
  42.       @character_index = 0 if diagonal_charset?
  43.     end
  44.     @stop_count = 0
  45.   end
  46.  
  47.   def set_direction_diagonal(horz, vert)
  48.     if !@direction_fix && horz != 0 && vert != 0
  49.       if horz == 4 && vert == 2
  50.         @direction = 2
  51.       elsif horz == 4 && vert == 8
  52.         @direction = 4
  53.       elsif horz == 6 && vert == 2
  54.         @direction = 6
  55.       elsif horz == 6 && vert == 8
  56.         @direction = 8
  57.       end
  58.      
  59.       @character_index = 1
  60.     end
  61.     @stop_count = 0
  62.   end
  63.  
  64.   def diagonal_charset?
  65.     true if @character_name.include?(JvScripts::Dirs8::DiagonalSuffix)
  66.   end
  67. end
  68.  
  69. #==============================================================================
  70. # Game Player
  71. #==============================================================================
  72. class Game_Player < Game_Character
  73.   def move_by_input
  74.     return if !movable? || $game_map.interpreter.running?
  75.     if JvScripts::Dirs8::Switch > 0
  76.       if $game_switches[JvScripts::Dirs8::Switch] == true
  77.         case Input.dir8
  78.         when 2, 4, 6, 8
  79.           move_straight(Input.dir4)
  80.         when 1
  81.           move_diagonal(4, 2)
  82.         when 3
  83.           move_diagonal(6, 2)
  84.         when 7
  85.           move_diagonal(4, 8)
  86.         when 9
  87.           move_diagonal(6, 8)
  88.         end
  89.       else
  90.         move_straight(Input.dir4) if Input.dir4 > 0
  91.       end
  92.     else
  93.       if Input.dir8 > 0
  94.         case Input.dir8
  95.         when 2, 4, 6, 8
  96.           move_straight(Input.dir4)
  97.         when 1
  98.           move_diagonal(4, 2)
  99.         when 3
  100.           move_diagonal(6, 2)
  101.         when 7
  102.           move_diagonal(4, 8)
  103.         when 9
  104.           move_diagonal(6, 8)
  105.         end
  106.       end
  107.     end
  108.   end
  109. end
  110. #==============================================================================