Guest User

Face Frames - YEA Ace Battle Engine Addon

a guest
Oct 3rd, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.04 KB | None | 0 0
  1. #===============================================================================
  2. # // Face Frames - YEA Ace Battle Engine Addon
  3. # Author: Rikifive
  4. # Engine: RPG Maker VX Ace
  5. # Version: 1.0 (2020-10-03)
  6. #
  7. # /!\ Required Scripts (2)
  8. #   Yanfly | Yanfly Engine Ace - Ace Battle Engine v1.22
  9. #   Rikifive | Face Frames v1.1
  10. #
  11. #===============================================================================
  12. # DESCRIPTION
  13. #===============================================================================
  14. # This is an ADDON to YEA Ace Battle Engine.
  15. # Adds Face Frames to Actor Statuses in the Battle Screen.
  16. # + Allows some additional customization in Actor Statuses there.
  17. #
  18. #===============================================================================
  19. # INSTRUCTIONS
  20. #===============================================================================
  21. # ► SCRIPT DIFFICULTY: ★☆☆☆☆
  22. #   This script is basically Plug & Play, but some minor configuration might
  23. #   be required.
  24. #
  25. # -=> Place script(s) below ▼ Materials; above ▼ Main Process
  26. #
  27. # Customize offsets and display in the configuration.
  28. #
  29. # i) Due to the nature of varying status widths, only frames drawn from
  30. #    windowskin are supported. "frame" images are not supported.
  31. #
  32. #===============================================================================
  33. # TERMS OF USE
  34. #===============================================================================
  35. # > You ARE allowed to use this script in non-commercial projects.
  36. # > You ARE allowed to use this script in commercial projects.
  37. #     It's just a little script, so let's not paniK lmao
  38. #     If you'd like to support my works nevertheless, donating any amount
  39. #     would be greatly appreciated. Thank you. c:
  40. #     ( https://paypal.me/rikifive )
  41. # > You ARE allowed to edit this script to your needs.
  42. # > You ARE NOT allowed to repost or post modified versions of this script
  43. #     without my permission.
  44. # > You ARE DEFINITELY NOT allowed to claim this script as your own lmao
  45. #
  46. # How to credit me: Just include my name "Rikifive" somewhere in the credits.
  47. #
  48. # Good luck!
  49. #
  50. #===============================================================================
  51. # VERSION HISTORY
  52. #===============================================================================
  53. # YYYY-MM-DD | Ver
  54. #------------------
  55. # 03-10-2020 | 1.0 - Initial Release
  56. #
  57. #===============================================================================
  58. # COMPATIBILITY INFORMATION
  59. #===============================================================================
  60. # Overwritten Methods (2)
  61. #   Window_BattleStatus - item_rect
  62. #   Window_BattleStatus - draw_face
  63. #
  64. # Aliased Methods (5)
  65. #   Window_BattleStatus - draw_actor_name
  66. #   Window_BattleStatus - draw_actor_action
  67. #   Window_BattleStatus - draw_actor_hp
  68. #   Window_BattleStatus - draw_actor_mp
  69. #   Window_BattleStatus - draw_actor_tp
  70. #
  71. #===============================================================================
  72.  
  73. #===============================================================================
  74. # CONFIGURATION
  75. #===============================================================================
  76. module RK5_FRAMES
  77.   # PIXELS to cut out from each side of the face, so that it doesn't leak
  78.   # through the frame
  79.   # Preferably put the window frame's thickness. (default windowskin has 6 px)
  80.   YEA_BATTLE_FACE_OFFSET = 6 # pixels from each side
  81.  
  82.   # Normally actor status (hp bar etc.) are drawn across the whole face,
  83.   # but since you intend to draw a frame around the face, you may want
  84.   # to set the offset, so that the bars aren't drawn on the frame.
  85.   # Preferably use the same amount as in the setting above
  86.   YEA_BATTLE_OFFSET = 6 # pixels from each side
  87.  
  88.   # Same as above, but a separate offset for [Action Icon] and [Character Name]
  89.   YEA_BATTLE_OFFSET_TOP = 0
  90.  
  91.   # By default, [Action Icon] and [Character Name] are drawn on top of the face,
  92.   # if you'd wish to display these ABOVE the face, put "true".
  93.   # Keep in mind it will lower the height of the face.
  94.   #-------------------------------------.
  95.   # false:             true:            |
  96.   #-------------------------------------.
  97.   # .----------.       [O]Name          |
  98.   # |[O]Name   |       .----------.     |
  99.   # |          |       |          |     |
  100.   # |HP_____100|       |HP_____100|     |
  101.   # |MP__    14|       |MP__    14|     |
  102.   # '----------'       '----------'     |
  103.   #-------------------------------------'
  104.   YEA_BATTLE_TOP_OUTSIDE = false
  105.  
  106.   # By default, actor statuses' width depend on the maximum amount of battle
  107.   # members (Game_Party\max_battle_members).
  108.   # For example, if up to 4 battle members can battle, each actor's status'
  109.   # width, regardless of current party size, will equal to:
  110.   # [ BATTLE STATUS'S WIDTH / 4 ], to reserve space for the other actors.
  111.   # However, if only 1 member is allowed to battle at one time, his status
  112.   # will be drawn across the whole window, resulting in insanely long
  113.   # hp/mp/tp bars with a funny looking face in the center.
  114.   # If you'll find yourself in such situation, you may want to CAP the width
  115.   # of each actor's status, so that they don't go beyond the specified value.
  116.   # For example, to CAP the status width, so that the face always covers
  117.   # the whole face frame (status not bigger than face), follow this calculation:
  118.   # + 96 pixels for face
  119.   # + 4 pixels for cursor (the outline of the active actor)
  120.   # + window frame's thickness in pixels (like with YEA_BATTLE_FACE_OFFSET)
  121.   YEA_BATTLE_WIDTH_CAP = 106
  122.  
  123. end
  124. #===============================================================================
  125. # END OF CONFIGURATION
  126. #===============================================================================
  127.  
  128. class Window_BattleStatus < Window_Selectable
  129.   #--------------------------------------------------------------------------
  130.   # ::: OVERWRITE METHOD
  131.   #--------------------------------------------------------------------------
  132.   def item_rect(index)
  133.     rect = Rect.new
  134.     rect.width = [contents.width / $game_party.max_battle_members,RK5_FRAMES::YEA_BATTLE_WIDTH_CAP].min
  135.     rect.height = contents.height
  136.     rect.x = index * rect.width
  137.     if YEA::BATTLE::BATTLESTATUS_CENTER_FACES
  138.       rect.x += (contents.width - $game_party.members.size * rect.width) / 2
  139.     end
  140.     rect.y = 0
  141.     return rect
  142.   end
  143.  
  144.   #--------------------------------------------------------------------------
  145.   # ::: OVERWRITE METHOD
  146.   #--------------------------------------------------------------------------
  147.   def draw_face(face_name, face_index, dx, dy, enabled = true)
  148.     fo = RK5_FRAMES::YEA_BATTLE_FACE_OFFSET
  149.     to = RK5_FRAMES::YEA_BATTLE_TOP_OUTSIDE ? 20 : 0
  150.  
  151.     iw = item_rect(0).width - 4
  152.     ih = item_rect(0).height - 4
  153.     fx = (face_index % 4 * 96) + ([96-iw+fo*2,0].max / 2)
  154.     fy = (face_index / 4 * 96) + ([96-ih+fo*2,0].max / 2)
  155.     fw = 96 - [96-iw+fo*2,0].max
  156.     fh = 96 - [96-ih+fo*2,0].max
  157.  
  158.     bitmap = Cache.face(face_name)
  159.     rect = Rect.new(fx, fy+to, fw, fh-to)
  160.     contents.blt(dx+fo+[(iw/2-48-fo).floor,0].max, dy+fo+[(ih/2-48.floor),0].max+to, bitmap, rect, enabled ? 255 : translucent_alpha)
  161.     bitmap.dispose
  162.     draw_window_frame(dx, dy+to, iw, ih-to)
  163.   end
  164.  
  165.   #--------------------------------------------------------------------------
  166.   # *** ALIAS METHOD
  167.   #--------------------------------------------------------------------------
  168.   alias :draw_actor_name_w :draw_actor_name
  169.   def draw_actor_name(actor, dx, dy, dw = 112)
  170.     o = RK5_FRAMES::YEA_BATTLE_OFFSET_TOP
  171.     draw_actor_name_w(actor, dx+o, dy+o, [dw-o*2,RK5_FRAMES::YEA_BATTLE_WIDTH_CAP].min)
  172.   end
  173.  
  174.   #--------------------------------------------------------------------------
  175.   # *** ALIAS METHOD
  176.   #--------------------------------------------------------------------------
  177.   alias :draw_actor_action_w :draw_actor_action
  178.   def draw_actor_action(actor, dx, dy)
  179.     o = RK5_FRAMES::YEA_BATTLE_OFFSET_TOP
  180.     draw_actor_action_w(actor, dx+o, dy+o)
  181.   end
  182.  
  183.   #--------------------------------------------------------------------------
  184.   # *** ALIAS METHOD
  185.   #--------------------------------------------------------------------------
  186.   alias :draw_actor_hp_w :draw_actor_hp
  187.   def draw_actor_hp(actor, dx, dy, width = 124)
  188.     o = RK5_FRAMES::YEA_BATTLE_OFFSET
  189.     draw_actor_hp_w(actor, dx+o, dy-o, width-o*2)
  190.   end
  191.    
  192.   #--------------------------------------------------------------------------
  193.   # *** ALIAS METHOD
  194.   #--------------------------------------------------------------------------
  195.   alias :draw_actor_mp_w :draw_actor_mp
  196.   def draw_actor_mp(actor, dx, dy, width = 124)
  197.     o = RK5_FRAMES::YEA_BATTLE_OFFSET
  198.     draw_actor_mp_w(actor, dx+o, dy-o, width-o*2)
  199.   end
  200.    
  201.   #--------------------------------------------------------------------------
  202.   # *** ALIAS METHOD
  203.   #--------------------------------------------------------------------------
  204.   alias :draw_actor_tp_w :draw_actor_tp
  205.   def draw_actor_tp(actor, dx, dy, width = 124)
  206.     o = RK5_FRAMES::YEA_BATTLE_OFFSET
  207.     draw_actor_tp_w(actor, dx+o, dy-o, width-o*2)
  208.   end
  209.  
  210. end
Add Comment
Please, Sign In to add comment