Advertisement
roninator2

Heirukichi Offset NPC position - mod

Dec 6th, 2024
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.95 KB | None | 0 0
  1. #========================================================
  2. # Author: Heirukichi
  3. # Last update: 05-26-2019 [MM-DD-YYYY]
  4. # License: CC 4.0 BY-SA
  5. #========================================================
  6. # Mod by Roninator2
  7. # use <custom_offset: x, y>
  8. # to move a specific event
  9. # Place inside a comment on the event
  10. #========================================================
  11.  
  12. module HRK_CHOFS
  13.  
  14.   #======================================================
  15.   # Set this to false if you want to use the default offset
  16.   #======================================================
  17.   USE_CUSTOM_OFFSET = true
  18.  
  19.   #======================================================
  20.   # - - - WARNING! Do not modify after this point!
  21.   #======================================================
  22.   Regex = /<custom[-_ ]offset:\s*(v\[\d+\]|\d+)\s*(\w+)?>/i
  23.  
  24. end
  25.  
  26. module RPG
  27.   class Event::Page
  28.  
  29.     def custom_position?
  30.       return @is_custom_position unless @is_custom_position.nil?
  31.       load_notetag_custom_event_positions
  32.       return @is_custom_position
  33.     end
  34.  
  35.     def load_notetag_custom_event_positions
  36.       @is_custom_position = false
  37.       @custom_position_x = 0
  38.       @custom_position_y = 0
  39.       @list.each do |cmd|
  40.         if cmd.code == 108 && cmd.parameters[0] =~ HRK_CHOFS::Regex
  41.           @custom_position_x = $1
  42.           @custom_position_y = $2
  43.           break
  44.         end
  45.       end
  46.     end
  47.  
  48.     end
  49. end
  50.  
  51. #========================================================
  52. # * Game_CharacterBase class
  53. #========================================================
  54. class Game_CharacterBase
  55.  
  56.   alias hrk_chofs_shift_y_old shift_y
  57.   def shift_y
  58.     if HRK_CHOFS::USE_CUSTOM_OFFSET
  59.       object_character? ? 0 : @custom_position_y
  60.     else
  61.       hrk_chofs_shift_y_old
  62.     end
  63.   end
  64.  
  65.   def shift_x
  66.     object_character? ? 0 : @custom_position_x
  67.   end
  68.  
  69.   alias hrk_chofs_screen_x_old screen_x
  70.   def screen_x
  71.     hrk_chofs_screen_x_old - shift_x
  72.   end
  73.  
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement