mikb89

[Ace] Advanced Direction Fix v1.1

Jan 6th, 2013
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.07 KB | None | 0 0
  1. # Advanced Direction Fix v. 1.1
  2. # VX Ace version
  3. # by mikb89
  4.  
  5. # Dettagli:
  6. #  Questo script permette di utilizzare la direzione fissa con le sole direzioni
  7. #   stabilite. Gli altri eroi del caterpillar avranno le stesse direzioni fisse.
  8. #  Via chiama script si possono inserire le istruzioni su quale direzione
  9. #   bloccare o sbloccare.
  10. #  fix_right farà in modo che la grafica di destra non si veda.
  11. #  no_fix_down sbloccherà quella in giù (se era bloccata).
  12. #  Metto giusto questi a titolo di esempio, per operare con sinistra e su
  13. #   chiaramente basta sostituire right o down con left per sinistra e up per su.
  14. #  In ogni caso attivando l'opzione sottostante si possono avere i comandi in
  15. #   italiano, molto più comodi, probabilmente ^^
  16. #
  17. #  Attenzione: questo script sovrascrive la direzione fissa standard. Vale a
  18. #              dire, attivarla equivale a chiamare fix_ per tutte le direzioni
  19. #              e disattivarla vale come un no_fix_.
  20.  
  21. # Configurazioni:
  22. module FIDIR
  23.   COMANDI_ITA = true
  24.    # Permette di avere i comandi in italiano come fix_dx, fix_giu, no_fix_giu
  25. end
  26.  
  27. #Codename: fidir
  28.  
  29. ($imported ||= {})[:mikb89_fidir] = true
  30.  
  31. # License:
  32. # - You can ask me to include support for other scripts as long as these scripts
  33. #   use the $imported[script] = true;
  34. # - You can modify and even repost my scripts, after having received a response
  35. #   by me. For reposting it, anyway, you must have done heavy edit or porting,
  36. #   you can't do a post with the script as is;
  37. # - You can use my scripts for whatever you want, from free to open to
  38. #   commercial games. I'd appreciate by the way if you let me know about what
  39. #   you're doing;
  40. # - You must credit me, if you use this script or part of it.
  41.  
  42. class Game_Player < Game_Character
  43.   attr_accessor :fidirs
  44.   alias_method(:init_b4_fidir, :initialize) unless method_defined?(:init_b4_fidir)
  45.   def initialize
  46.     init_b4_fidir
  47.     @fidirs = []
  48.   end
  49.   alias_method(:mv_strait_b4_fidir, :move_straight) unless method_defined?(:mv_strait_b4_fidir)
  50.   def move_straight(d, turn_ok = true)
  51.     @direction_fix = true if @fidirs.include?(d)
  52.     mv_strait_b4_fidir(d, turn_ok)
  53.     @direction_fix = false if @fidirs.include?(d)
  54.   end
  55.   if method_defined?(:process_move_command)
  56.     alias_method(:proc_mv_cmd_b4_fidir, :process_move_command) unless method_defined?(:proc_mv_cmd_b4_fidir)
  57.   end
  58.   def process_move_command(command)
  59.     if command.code == ROUTE_DIR_FIX_ON
  60.       @fidirs = [2, 4, 6, 8]
  61.     elsif command.code == ROUTE_DIR_FIX_OFF
  62.       @fidirs.clear
  63.     else
  64.       if respond_to?(:proc_mv_cmd_b4_fidir)
  65.         proc_mv_cmd_b4_fidir(command)
  66.       else
  67.         super
  68.       end
  69.     end
  70.   end
  71. end
  72.  
  73. class Game_Follower < Game_Character
  74.   if method_defined?(:move_straight)
  75.     alias_method(:mv_straitGF_b4_fidir, :move_straight) unless method_defined?(:mv_straitGF_b4_fidir)
  76.   end
  77.   def move_straight(d, turn_ok = true)
  78.     @direction_fix = true if $game_player.fidirs.include?(d)
  79.     if respond_to?(:mv_straitGF_b4_fidir)
  80.       mv_straitGF_b4_fidir(d, turn_ok)
  81.     else
  82.       super
  83.     end
  84.     @direction_fix = false if $game_player.fidirs.include?(d)
  85.   end
  86. end
  87.  
  88. class Game_Interpreter
  89.   def fix_dir(m)
  90.     $game_player.fidirs << m
  91.     $game_player.fidirs.uniq!
  92.   end
  93.   def no_fix_dir(m)
  94.     $game_player.fidirs.delete(m)
  95.     $game_player.fidirs.uniq!
  96.   end
  97.  
  98.   def fix_right
  99.     fix_dir(6)
  100.   end
  101.   def fix_left
  102.     fix_dir(4)
  103.   end
  104.   def fix_up
  105.     fix_dir(8)
  106.   end
  107.   def fix_down
  108.     fix_dir(2)
  109.   end
  110.   def no_fix_right
  111.     no_fix_dir(6)
  112.   end
  113.   def no_fix_left
  114.     no_fix_dir(4)
  115.   end
  116.   def no_fix_up
  117.     no_fix_dir(8)
  118.   end
  119.   def no_fix_down
  120.     no_fix_dir(2)
  121.   end
  122.   if FIDIR::COMANDI_ITA
  123.     def fix_dx
  124.       fix_dir(6)
  125.     end
  126.     def fix_sx
  127.       fix_dir(4)
  128.     end
  129.     def fix_su
  130.       fix_dir(8)
  131.     end
  132.     def fix_giu
  133.       fix_dir(2)
  134.     end
  135.     def no_fix_dx
  136.       no_fix_dir(6)
  137.     end
  138.     def no_fix_sx
  139.       no_fix_dir(4)
  140.     end
  141.     def no_fix_su
  142.       no_fix_dir(8)
  143.     end
  144.     def no_fix_giu
  145.       no_fix_dir(2)
  146.     end
  147.   end
  148. end
Advertisement
Add Comment
Please, Sign In to add comment