Advertisement
a-moonless-night

AMN - Move Route Convenience v1.02

Sep 20th, 2020 (edited)
1,847
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.44 KB | None | 0 0
  1. =begin
  2. #==============================================================================#
  3. #   AMN Move Route Convenience
  4. #   Version   1.02
  5. #   Author:   AMoonlessNight
  6. #   Date:     21 Sep 2020
  7. #   Latest:   22 Sep 2020
  8. #==============================================================================#
  9. #   UPDATE LOG
  10. #------------------------------------------------------------------------------#
  11. # 21 Sep 2020 - created the script
  12. # 22 Sep 2020 - codes can be downcase or uppercase
  13. #==============================================================================#
  14. #   TERMS OF USE
  15. #------------------------------------------------------------------------------#
  16. # - Please credit AMoonlessNight or A-Moonless-Night
  17. # - Free for non-commercial use; contact for commercial use
  18. # - If you would like to edit/adjust this script, please make edits as a new
  19. #   script (do not edit this script directly) and provide proper credit
  20. # - I'd love to see your game if you end up using one of my scripts
  21. #==============================================================================#
  22.  
  23. This script makes a few convenience methods for character move routes. If you
  24. want to make your character move up 4 times, you don't need to make 4 separate
  25. move commands---you can just use a simple script call in the move route.
  26.  
  27. Use the following script call in the character's move route:
  28.   <move X Y>
  29.  
  30.   X can be one of the following codes:
  31.     MD or M2    move down
  32.     ML or M4    move left
  33.     MR or M6    move right
  34.     MU or M8    move up
  35.     MLL or M1   move lower left
  36.     MLR or M3   move lower right
  37.     MUL or M7   move upper left
  38.     MUR or M9   move upper right
  39.     MRAN        move random
  40.     MTWP        move toward player
  41.     MAWP        move away from player
  42.     MF          move forward
  43.     MB          move backward
  44.     M90R        turn 90 degrees right
  45.     M90L        turn 90 degrees left
  46.     M90RL       turn 90 degrees right or left
  47.     M180        turn 180 degrees
  48.     MTRAN       turn random
  49.    
  50.   Y should be the number of times the character should do that action
  51.  
  52.   For example, to make the character move up 4 times, you would use the script
  53.   call in the move route:
  54.     <move MU 4>     or    <move M8 4>
  55.  
  56.  
  57. IMPORTANT: the script call must be inside the move route (e.g. Set Move Route or
  58. in the event's custom move route). It will throw an error if you try doing it
  59. in a regular script call.
  60.  
  61.  
  62. =end
  63.  
  64. #==============================================================================
  65. #  Please do not edit below this point unless you know what you are doing.
  66. #==============================================================================
  67.  
  68. class Game_Character < Game_CharacterBase
  69.   MR_REGEX = /<move\s+(.+)\s(\d+)>/i
  70.   MR_COMMANDS = {
  71.     "md" => ROUTE_MOVE_DOWN,
  72.     "m2" => ROUTE_MOVE_DOWN,
  73.     "ml" => ROUTE_MOVE_LEFT,
  74.     "m4" => ROUTE_MOVE_LEFT,
  75.     "mr" => ROUTE_MOVE_RIGHT,
  76.     "m6" => ROUTE_MOVE_RIGHT,
  77.     "mu" => ROUTE_MOVE_UP,
  78.     "m8" => ROUTE_MOVE_UP,
  79.     "mll" => ROUTE_MOVE_LOWER_L,
  80.     "m1" => ROUTE_MOVE_LOWER_L,
  81.     "mlr" => ROUTE_MOVE_LOWER_R,
  82.     "m3" => ROUTE_MOVE_LOWER_R,
  83.     "mul" => ROUTE_MOVE_UPPER_L,
  84.     "m7" => ROUTE_MOVE_UPPER_L,
  85.     "mur" => ROUTE_MOVE_UPPER_R,
  86.     "m9" => ROUTE_MOVE_UPPER_R,
  87.     "mran" => ROUTE_MOVE_RANDOM,
  88.     "mtwp" => ROUTE_MOVE_TOWARD,
  89.     "mawp" => ROUTE_MOVE_AWAY,
  90.     "mf" => ROUTE_MOVE_FORWARD,
  91.     "mb" => ROUTE_MOVE_BACKWARD,
  92.     "m90r" => ROUTE_TURN_90D_R,
  93.     "m90l" => ROUTE_TURN_90D_L,
  94.     "m180" => ROUTE_TURN_180D,
  95.     "m90rl" => ROUTE_TURN_90D_R_L,
  96.     "mtran" => ROUTE_TURN_RANDOM,
  97.   }
  98.  
  99.   alias amn_moveroute_gamechara_forcemr   force_move_route
  100.   def force_move_route(move_route)
  101.     move_route = move_route_parse(move_route)
  102.     amn_moveroute_gamechara_forcemr(move_route)
  103.   end
  104.  
  105.   def move_route_parse(move_route)
  106.     move_route.list.each_with_index do |move, i|
  107.       if move.code == ROUTE_SCRIPT && move.parameters[0] =~ MR_REGEX
  108.         code = MR_COMMANDS[$1.strip.downcase]
  109.         if code
  110.           cmd = RPG::MoveCommand.new(code, [])
  111.           $2.to_i.times { |mr| move_route.list.insert(i+1, cmd) }
  112.         end
  113.         move_route.list.delete_at(i)
  114.       end
  115.     end
  116.     return move_route
  117.   end
  118.  
  119. end
  120.  
  121. class Game_Event < Game_Character
  122.  
  123.   alias amn_moveroute_gameevent_setuppgset  setup_page_settings
  124.   def setup_page_settings
  125.     amn_moveroute_gameevent_setuppgset
  126.     @move_route = move_route_parse(@move_route)
  127.   end
  128.  
  129. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement