Advertisement
TheSixth

Custom Offsets by Sixth

Mar 23rd, 2016
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.60 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Custom Offsets
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.1
  6. # * Updated: 09/06/2016
  7. # * Requires: -------
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (25/02/2016)
  12. #   - Initial release.
  13. # * Version 1.1 (09/06/2016)
  14. #   - Added compatibility with my Action Notification Popups script.
  15. #-------------------------------------------------------------------------------
  16. # * < Description >
  17. #-------------------------------------------------------------------------------
  18. # * This script will enable you to fine tune the position of the character
  19. #   sprites on the map.
  20. # * Will not change the actual X and Y position of the characters on the map
  21. #   grid, only their graphic's position!
  22. #-------------------------------------------------------------------------------
  23. # * < Installation >
  24. #-------------------------------------------------------------------------------
  25. # * Place this script below Materials but above Main!
  26. #-------------------------------------------------------------------------------
  27. # * < Compatibility Info >
  28. #-------------------------------------------------------------------------------
  29. # * No known incompatibilities.
  30. #-------------------------------------------------------------------------------
  31. # * < Known Issues >
  32. #-------------------------------------------------------------------------------
  33. # * No known issues.
  34. #-------------------------------------------------------------------------------
  35. # * < Terms of Use >
  36. #-------------------------------------------------------------------------------
  37. # * Free to use for whatever purposes you want.
  38. # * Credit me (Sixth) in your game, pretty please! :P
  39. # * Posting modified versions of this script is allowed as long as you notice me
  40. #   about it with a link to it!
  41. #===============================================================================
  42. $imported = {} if $imported.nil?
  43. $imported["SixthCustomOffsets"] = true
  44. #===============================================================================
  45. # Settings:
  46. #===============================================================================
  47. module CustomOffsets
  48.   #-----------------------------------------------------------------------------
  49.   # Offset Settings:
  50.   #-----------------------------------------------------------------------------
  51.   # Because the character sprites can be changed during the game anytime, I
  52.   # found it best to make the offset settings dependent on the image used rather
  53.   # than reading it from a note-tag or event comment.
  54.   # This way, the offsets will be correct even if you change the character's
  55.   # graphic during the game, which you will most probably do more or less.
  56.   #
  57.   # Format:
  58.   #
  59.   #   "image_name" => {
  60.   #     2 => [x_offset,y_offset], # Offset when the character is facing down
  61.   #     4 => [x_offset,y_offset], # Offset when the character is facing left
  62.   #     6 => [x_offset,y_offset], # Offset when the character is facing right
  63.   #     8 => [x_offset,y_offset], # Offset when the character is facing up
  64.   #   },
  65.   #
  66.   # So, use the file name of the images for your settings' key.
  67.   # And you can set up different offsets for all directional cases.
  68.   # Sometimes you would like to move that sprite 2 pixels up, but only if the
  69.   # event is facing left, for example. Well, you can do that now.
  70.   #
  71.   # Setting the X offset to a positive number will make the image move to the
  72.   # right, while a negative setting will make it move to the left.
  73.   # Setting the Y offset to a positive number will make the image move down,
  74.   # while a negative setting will make it move up.
  75.   #
  76.   # Make sure to enter the settings for all directions!
  77.   # If you just want to set up an offset for one direction, for example, set
  78.   # that one up how you want, and set the rest to [0,0].
  79.   #
  80.   # Images without a setting here will not have any offset in the game, they
  81.   # will use the default positioning!
  82.   #-----------------------------------------------------------------------------
  83.   Offsets = {
  84.     "$48x48_enemy" => {
  85.       2 => [0,16], 4 => [0,26], 6 => [0,36], 8 => [0,46],
  86.     },
  87.     "$Larve" => {
  88.       2 => [0,18], 4 => [0,18], 6 => [0,18], 8 => [0,18],
  89.     },
  90.     # Add more offset settings here!
  91.   }
  92.  
  93. end
  94. #===============================================================================
  95. # End of settings! Editing anything below may lead to... you know it, right? o.o
  96. #===============================================================================
  97.  
  98. class Sprite_Character < Sprite_Base
  99.    
  100.   alias set_offsets7643 set_character_bitmap
  101.   def set_character_bitmap
  102.     set_offsets7643
  103.     @off_dir = 0
  104.     @notif_offset = [0,0]
  105.   end
  106.  
  107.   alias add_offsets9975 update
  108.   def update
  109.     add_offsets9975
  110.     if @off_dir != @character.direction
  111.       if CustomOffsets::Offsets.include?(@character.character_name)
  112.         off = CustomOffsets::Offsets[@character.character_name][@character.direction]
  113.         @notif_offset = off
  114.         self.ox = @cw / 2 - off[0] if @cw
  115.         self.oy = @ch - off[1] if @ch
  116.       end
  117.       @off_dir = @character.direction
  118.     end
  119.   end
  120.  
  121. end
  122. #==============================================================================
  123. # !!END OF SCRIPT - OHH, NOES!!
  124. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement