Guest User

Face Frames - YEA Ace Battle Engine Addon (v1.0.1)

a guest
Oct 4th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.22 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.1 (2020-10-04)
  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. # 04-10-2020 | 1.0.1 - Fix: Removed spacing between MP and TP.
  56. # 03-10-2020 | 1.0 - Initial Release
  57. #
  58. #===============================================================================
  59. # COMPATIBILITY INFORMATION
  60. #===============================================================================
  61. # Overwritten Methods (2)
  62. #   Window_BattleStatus - item_rect
  63. #   Window_BattleStatus - draw_face
  64. #
  65. # Aliased Methods (5)
  66. #   Window_BattleStatus - draw_actor_name
  67. #   Window_BattleStatus - draw_actor_action
  68. #   Window_BattleStatus - draw_actor_hp
  69. #   Window_BattleStatus - draw_actor_mp
  70. #   Window_BattleStatus - draw_actor_tp
  71. #
  72. #===============================================================================
  73.  
  74. #===============================================================================
  75. # CONFIGURATION
  76. #===============================================================================
  77. module RK5_FRAMES
  78.   # PIXELS to cut out from each side of the face, so that it doesn't leak
  79.   # through the frame
  80.   # Preferably put the window frame's thickness. (default windowskin has 6 px)
  81.   YEA_BATTLE_FACE_OFFSET = 6 # pixels from each side
  82.  
  83.   # Normally actor status (hp bar etc.) are drawn across the whole face,
  84.   # but since you intend to draw a frame around the face, you may want
  85.   # to set the offset, so that the bars aren't drawn on the frame.
  86.   # Preferably use the same amount as in the setting above
  87.   YEA_BATTLE_OFFSET = 6 # pixels from each side
  88.  
  89.   # Same as above, but a separate offset for [Action Icon] and [Character Name]
  90.   YEA_BATTLE_OFFSET_TOP = 0
  91.  
  92.   # By default, [Action Icon] and [Character Name] are drawn on top of the face,
  93.   # if you'd wish to display these ABOVE the face, put "true".
  94.   # Keep in mind it will lower the height of the face.
  95.   #-------------------------------------.
  96.   # false:             true:            |
  97.   #-------------------------------------.
  98.   # .----------.       [O]Name          |
  99.   # |[O]Name   |       .----------.     |
  100.   # |          |       |          |     |
  101.   # |HP_____100|       |HP_____100|     |
  102.   # |MP__    14|       |MP__    14|     |
  103.   # '----------'       '----------'     |
  104.   #-------------------------------------'
  105.   YEA_BATTLE_TOP_OUTSIDE = false
  106.  
  107.   # By default, actor statuses' width depend on the maximum amount of battle
  108.   # members (Game_Party\max_battle_members).
  109.   # For example, if up to 4 battle members can battle, each actor's status'
  110.   # width, regardless of current party size, will equal to:
  111.   # [ BATTLE STATUS'S WIDTH / 4 ], to reserve space for the other actors.
  112.   # However, if only 1 member is allowed to battle at one time, his status
  113.   # will be drawn across the whole window, resulting in insanely long
  114.   # hp/mp/tp bars with a funny looking face in the center.
  115.   # If you'll find yourself in such situation, you may want to CAP the width
  116.   # of each actor's status, so that they don't go beyond the specified value.
  117.   # For example, to CAP the status width, so that the face always covers
  118.   # the whole face frame (status not bigger than face), follow this calculation:
  119.   # + 96 pixels for face
  120.   # + 4 pixels for cursor (the outline of the active actor)
  121.   # + window frame's thickness in pixels (like with YEA_BATTLE_FACE_OFFSET)
  122.   YEA_BATTLE_WIDTH_CAP = 106
  123.  
  124. end
  125. #===============================================================================
  126. # END OF CONFIGURATION
  127. #===============================================================================
  128.  
  129. class Window_BattleStatus < Window_Selectable
  130.   #--------------------------------------------------------------------------
  131.   # ::: OVERWRITE METHOD
  132.   #--------------------------------------------------------------------------
  133.   def item_rect(index)
  134.     rect = Rect.new
  135.     rect.width = [contents.width / $game_party.max_battle_members,RK5_FRAMES::YEA_BATTLE_WIDTH_CAP].min
  136.     rect.height = contents.height
  137.     rect.x = index * rect.width
  138.     if YEA::BATTLE::BATTLESTATUS_CENTER_FACES
  139.       rect.x += (contents.width - $game_party.members.size * rect.width) / 2
  140.     end
  141.     rect.y = 0
  142.     return rect
  143.   end
  144.  
  145.   #--------------------------------------------------------------------------
  146.   # ::: OVERWRITE METHOD
  147.   #--------------------------------------------------------------------------
  148.   def draw_face(face_name, face_index, dx, dy, enabled = true)
  149.     fo = RK5_FRAMES::YEA_BATTLE_FACE_OFFSET
  150.     to = RK5_FRAMES::YEA_BATTLE_TOP_OUTSIDE ? 20 : 0
  151.  
  152.     iw = item_rect(0).width - 4
  153.     ih = item_rect(0).height - 4
  154.     fx = (face_index % 4 * 96) + ([96-iw+fo*2,0].max / 2)
  155.     fy = (face_index / 4 * 96) + ([96-ih+fo*2,0].max / 2)
  156.     fw = 96 - [96-iw+fo*2,0].max
  157.     fh = 96 - [96-ih+fo*2,0].max
  158.  
  159.     bitmap = Cache.face(face_name)
  160.     rect = Rect.new(fx, fy+to, fw, fh-to)
  161.     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)
  162.     bitmap.dispose
  163.     draw_window_frame(dx, dy+to, iw, ih-to)
  164.   end
  165.  
  166.   #--------------------------------------------------------------------------
  167.   # *** ALIAS METHOD
  168.   #--------------------------------------------------------------------------
  169.   alias :draw_actor_name_w :draw_actor_name
  170.   def draw_actor_name(actor, dx, dy, dw = 112)
  171.     o = RK5_FRAMES::YEA_BATTLE_OFFSET_TOP
  172.     draw_actor_name_w(actor, dx+o, dy+o, [dw-o*2,RK5_FRAMES::YEA_BATTLE_WIDTH_CAP].min)
  173.   end
  174.  
  175.   #--------------------------------------------------------------------------
  176.   # *** ALIAS METHOD
  177.   #--------------------------------------------------------------------------
  178.   alias :draw_actor_action_w :draw_actor_action
  179.   def draw_actor_action(actor, dx, dy)
  180.     o = RK5_FRAMES::YEA_BATTLE_OFFSET_TOP
  181.     draw_actor_action_w(actor, dx+o, dy+o)
  182.   end
  183.  
  184.   #--------------------------------------------------------------------------
  185.   # *** ALIAS METHOD
  186.   #--------------------------------------------------------------------------
  187.   alias :draw_actor_hp_w :draw_actor_hp
  188.   def draw_actor_hp(actor, dx, dy, width = 124)
  189.     o = RK5_FRAMES::YEA_BATTLE_OFFSET
  190.     draw_actor_hp_w(actor, dx+o, dy-o, width-o*2)
  191.   end
  192.    
  193.   #--------------------------------------------------------------------------
  194.   # *** ALIAS METHOD
  195.   #--------------------------------------------------------------------------
  196.   alias :draw_actor_mp_w :draw_actor_mp
  197.   def draw_actor_mp(actor, dx, dy, width = 124)
  198.     o = RK5_FRAMES::YEA_BATTLE_OFFSET
  199.     tpo = draw_tp?(actor) && draw_mp?(actor) ? o : 0
  200.     draw_actor_mp_w(actor, dx+o-tpo, dy-o, width-o*2+tpo)
  201.   end
  202.    
  203.   #--------------------------------------------------------------------------
  204.   # *** ALIAS METHOD
  205.   #--------------------------------------------------------------------------
  206.   alias :draw_actor_tp_w :draw_actor_tp
  207.   def draw_actor_tp(actor, dx, dy, width = 124)
  208.     o = RK5_FRAMES::YEA_BATTLE_OFFSET
  209.     tpo = draw_tp?(actor) && draw_mp?(actor) ? o : 0
  210.     draw_actor_tp_w(actor, dx+o, dy-o, width-o*2+tpo)
  211.   end
  212.  
  213. end
Add Comment
Please, Sign In to add comment