Advertisement
Kyriaki

Yanfly Engine RD - Display Party Data 2.0

Apr 27th, 2011
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 16.72 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine RD - Display Party Data 2.0
  4. # Last Date Updated: 2009.05.30
  5. # Level: Easy
  6. #
  7. # This pretty much changes the party information window in battles to show the
  8. # party member names horizontally than vertically. When structured as such,
  9. # you'll be able to see the party members' faces and/or sprites. With the new
  10. # arrangement, the player can also see up to four status effects on each actor
  11. # as opposed to the original two. A big difference.
  12. #
  13. # Version 2.0 gives options to change font size, show extra gauges (for rage and
  14. # morale) and no longer hides the actor sprite behind the states.
  15. #
  16. #===============================================================================
  17. # Instructions
  18. #===============================================================================
  19. #
  20. # Just put this script under Materials and that's it. If you'd like to change
  21. # other settings such as showing the face graphic or changing its opacity, just
  22. # scroll down a bit and make adjustments as necessary.
  23. #
  24. #===============================================================================
  25. # Updates:
  26. # ----------------------------------------------------------------------------
  27. # o 2009.05.30 - Fixed max states shown bug.
  28. #              - Greatly improved drawing efficiency.
  29. # o 2009.05.16 - Started and finished version 2.0.
  30. # o 2009.02.23 - Started script and finished.
  31. #===============================================================================
  32. #
  33. # Compatibility
  34. # - Alias: Window_BattleStatus, initialize
  35. # - Overwrites: Window_BattleStatus, draw_item
  36. #
  37. #===============================================================================
  38.  
  39. $imported = {} if $imported == nil
  40. $imported["DisplayPartyData"] = true
  41.  
  42. module YE
  43.   module BATTLE
  44.     module DISPLAY
  45.      
  46.       # This changes what will and will not be shown. If you choose to shown
  47.       # the actor's face graphic, you can choose its opacity. 255 means it's
  48.       # fully visible while 0 means it's completely transparent. For the
  49.       # number of states shown, do not exceed 4 unless you want the states to
  50.       # overlap into the next actor's data window.
  51.       SHOW_ALLY_FACE    = true
  52.       ALLY_FACE_OPACITY = 255
  53.       SHOW_ALLY_SPRITE  = false
  54.       MAX_STATES_SHOWN  = 2
  55.      
  56.       # This governs the sizes used for each of the items in the display.
  57.       NAME_FONT_SIZE  = 16
  58.       STAT_FONT_SIZE  = 16
  59.      
  60.       # This governs how HP and MP are shown. Here is a type listing for each
  61.       # individual one.
  62.       # Type 1 = Current           Type 4 = Current & Percentage
  63.       # Type 2 = Current/Maximum   Type 5 = Current/Max & Percent
  64.       # Type 3 = Percentage
  65.       SHOWN_HP_TYPE = 1
  66.       SHOWN_MP_TYPE = 1
  67.      
  68.       # For those using Custom Skill Effects and would like to show Rage for
  69.       # your bar, input the ID's of the classes you would Rage to appear for.
  70.       # The reason this is dependent on class rather than character is because
  71.       # if the character switches classes to one that no longer uses rage, the
  72.       # rage meter will be useless there.
  73.       RAGE_CLASSES = [1, 2]
  74.      
  75.       # This governs the type of display used for Rage. Here's a list of the
  76.       # various types of way you can choose to display Rage. If you don't want
  77.       # rage to be displayed at all, set it to 0.
  78.       # Type 1 - Rage icon and number value appears in lower left corner. MP
  79.       #          bar is moved over to give room for Rage bar.
  80.       # Type 2 - Rage icon and number value appears in lower right corner. MP
  81.       #          bar is on the left side instead.
  82.       RAGE_DISPLAY = 1
  83.      
  84.       # This governs the text shown for rage and the gauge colours used.
  85.       RAGE_TEXT   = "RG"
  86.       RAGE_GAUGE1 = 2
  87.       RAGE_GAUGE2 = 10
  88.      
  89.       # For those who are using Battler Stat Morale, this script can place a
  90.       # morale gauge under your MP bar (after pushing it upward).
  91.       GAUGE_MORALE   = true
  92.       MORALE_TEXT    = "Morale"
  93.       MORALE_GAUGE1  = 28        # This is for positive morale.
  94.       MORALE_GAUGE2  = 29        # This is for positive morale.
  95.       MORALE_GAUGE3  = 30        # This is for positive morale.
  96.       MORALE_GAUGE4  = 31        # This is for positive morale.
  97.      
  98.       # For those who don't want an extra gauge but would still like to show
  99.       # morale, there's an icon you can display for it instead. Morale icon
  100.       # will not appear if morale is equal to zero.
  101.       ICON_MORALE = true
  102.       ICON_MORALE_HIGH = 242     # Appears when morale is positive.
  103.       ICON_MORALE_LOW  = 241     # Appears when morale is negative.
  104.       MORALE_DIVISOR   = 100     # How much morale shown is divided by.
  105.       MORALE_FONT_SIZE = 16      # This is the font size used for morale icon.
  106.       MORALE_COL_HIGH  = 0       # This is the text colour used for high morale.
  107.       MORALE_COL_LOW   = 8       # This is the text colour used for low morale.
  108.      
  109.     end # end module DISPLAY
  110.   end # end module BATTLE
  111. end # end module YE
  112.  
  113. #===============================================================================
  114. # Don't touch anything past here or else your computer will explode and you will
  115. # be a very sad person.
  116. #===============================================================================
  117.  
  118. #==============================================================================
  119. # Window_BattleStatus
  120. #==============================================================================
  121.  
  122. class Window_BattleStatus < Window_Selectable
  123.  
  124.   #--------------------------------------------------------------------------
  125.   # Alias Object Initialization
  126.   #--------------------------------------------------------------------------
  127.   alias displaypartydata_initialize initialize unless $@
  128.   def initialize
  129.     displaypartydata_initialize
  130.     @column_max = $game_party.members.size
  131.     @spacing = 0
  132.   end
  133.  
  134.   #--------------------------------------------------------------------------
  135.   # Draw Item
  136.   #--------------------------------------------------------------------------
  137.   def draw_item(index)
  138.     rect = Rect.new(0, 0, 0, 0)
  139.     rect.width = 96
  140.     rect.height = 96
  141.     rect.x = index * 96
  142.     rect.y = 0
  143.     self.contents.clear_rect(rect)
  144.     self.contents.font.color = normal_color
  145.     @actor = $game_party.members[index]
  146.     draw_party_face(index)
  147.     draw_party_state(index)
  148.     draw_party_name(index)
  149.     draw_party_graphic(index)
  150.     draw_party_hp(index)
  151.     draw_party_mp(index)
  152.     draw_party_morale(index)
  153.   end
  154.  
  155.   #--------------------------------------------------------------------------
  156.   # Update Cursor
  157.   #--------------------------------------------------------------------------
  158.   def update_cursor
  159.     if @index < 0
  160.       self.cursor_rect.empty
  161.     else
  162.       self.cursor_rect.set(@index * 96, 0, 96, 96)
  163.     end
  164.   end
  165.  
  166.   #--------------------------------------------------------------------------
  167.   # Draw Party Face
  168.   #--------------------------------------------------------------------------
  169.   def draw_party_face(index)
  170.     return unless YE::BATTLE::DISPLAY::SHOW_ALLY_FACE
  171.     opacity = YE::BATTLE::DISPLAY::ALLY_FACE_OPACITY
  172.     @actor = $game_party.members[index]
  173.     face_name = @actor.face_name
  174.     face_index = @actor.face_index
  175.     bitmap = Cache.face(face_name)
  176.     rect = Rect.new(0, 0, 0, 0)
  177.     rect.x = face_index % 4 * 96 + 4 / 2
  178.     rect.y = face_index / 4 * 96 + 4 / 2
  179.     rect.width = 92
  180.     rect.height = 92
  181.     self.contents.blt(index * 96 + 2, 2, bitmap, rect, opacity)
  182.     bitmap.dispose
  183.   end
  184.  
  185.   #--------------------------------------------------------------------------
  186.   # Draw Party State
  187.   #--------------------------------------------------------------------------
  188.   def draw_party_state(index)
  189.     return unless YE::BATTLE::DISPLAY::MAX_STATES_SHOWN > 0
  190.     dx = index * 96
  191.     dy = WLH * 1
  192.     dw = YE::BATTLE::DISPLAY::MAX_STATES_SHOWN * 24
  193.     draw_actor_state(@actor, dx, dy, dw)
  194.   end
  195.  
  196.   #--------------------------------------------------------------------------
  197.   # Draw Party Graphic
  198.   #--------------------------------------------------------------------------
  199.   def draw_party_graphic(index)
  200.     return unless YE::BATTLE::DISPLAY::SHOW_ALLY_SPRITE
  201.     @actor = $game_party.members[index]
  202.     dx = index * 96 + 48
  203.     dy = WLH * 3 - YE::BATTLE::DISPLAY::STAT_FONT_SIZE + 16 + 2
  204.     if $imported["BattlerStatMorale"] and YE::BATTLE::DISPLAY::GAUGE_MORALE
  205.       dy -= YE::BATTLE::DISPLAY::STAT_FONT_SIZE
  206.     end
  207.     draw_character(@actor.character_name, @actor.character_index, dx, dy)
  208.   end
  209.  
  210.   #--------------------------------------------------------------------------
  211.   # Draw Party Name
  212.   #--------------------------------------------------------------------------
  213.   def draw_party_name(index)
  214.     self.contents.font.color = hp_color(@actor)
  215.     self.contents.font.size = YE::BATTLE::DISPLAY::NAME_FONT_SIZE
  216.     dx = 96 * index + 4
  217.     dy = 0
  218.     dw = 94
  219.     if $imported["BattlerStatMorale"] and YE::BATTLE::DISPLAY::ICON_MORALE
  220.       dw -= 24
  221.     end
  222.     self.contents.draw_text(dx, dy, dw, WLH, @actor.name)
  223.   end
  224.  
  225.   #--------------------------------------------------------------------------
  226.   # Draw Party HP
  227.   #--------------------------------------------------------------------------
  228.   def draw_party_hp(index)
  229.     dx = index * 96 + 2
  230.     dy = WLH * 3 - YE::BATTLE::DISPLAY::STAT_FONT_SIZE + 2
  231.     if $imported["BattlerStatMorale"] and YE::BATTLE::DISPLAY::GAUGE_MORALE
  232.       dy -= YE::BATTLE::DISPLAY::STAT_FONT_SIZE
  233.     end
  234.     dw = 92
  235.     draw_actor_hp_gauge(@actor, dx, dy, dw)
  236.     self.contents.font.size = YE::BATTLE::DISPLAY::STAT_FONT_SIZE
  237.     self.contents.font.color = system_color
  238.     self.contents.draw_text(dx + 2, dy + 4, 28, WLH, Vocab::hp_a, 0)
  239.     self.contents.font.color = hp_color(@actor)
  240.     text = sprintf("%d/%d", @actor.hp, @actor.maxhp)
  241.     percent = @actor.hp * 100.0 / @actor.maxhp
  242.     case YE::BATTLE::DISPLAY::SHOWN_HP_TYPE
  243.     when 1; text = @actor.hp
  244.     when 2; text = sprintf("%d/%d", @actor.hp, @actor.maxhp)
  245.     when 3; text = sprintf("%d%%", percent)
  246.     when 4; text = sprintf("%d %d%%", @actor.hp, percent)
  247.     when 5; text = sprintf("%d/%d %d%%", @actor.hp, @actor.maxhp, percent)
  248.     end
  249.     self.contents.draw_text(dx + 30, dy + 4, dw - 32, WLH, text, 2)
  250.   end
  251.  
  252.   #--------------------------------------------------------------------------
  253.   # Draw Party HP
  254.   #--------------------------------------------------------------------------
  255.   def draw_party_mp(index)
  256.     dx = index * 96 + 2
  257.     dy = WLH * 3
  258.     if $imported["BattlerStatMorale"] and YE::BATTLE::DISPLAY::GAUGE_MORALE
  259.       dy -= YE::BATTLE::DISPLAY::STAT_FONT_SIZE
  260.     end
  261.     dw = 92
  262.     #---
  263.     move_mp_bar = false
  264.     if $imported["CustomSkillEffects"]
  265.       if YE::BATTLE::DISPLAY::RAGE_CLASSES.include?(@actor.class.id)
  266.         move_mp_bar = true
  267.       end
  268.       if $imported["SubclassSelectionSystem"] and @actor.subclass != nil
  269.         if YE::BATTLE::DISPLAY::RAGE_CLASSES.include?(@actor.subclass.id)
  270.           move_mp_bar = true
  271.         end
  272.       end
  273.     end
  274.     if move_mp_bar and YE::BATTLE::DISPLAY::RAGE_DISPLAY == 1
  275.       dw /= 2
  276.       dx += dw
  277.       draw_party_rage(index)
  278.     elsif move_mp_bar and YE::BATTLE::DISPLAY::RAGE_DISPLAY == 1
  279.       dw /= 2
  280.       draw_party_rage(index)
  281.     end
  282.     #---
  283.     draw_actor_mp_gauge(@actor, dx, dy, dw)
  284.     self.contents.font.size = YE::BATTLE::DISPLAY::STAT_FONT_SIZE
  285.     self.contents.font.color = system_color
  286.     self.contents.draw_text(dx + 2, dy + 4, 28, WLH, Vocab::mp_a, 0)
  287.     self.contents.font.color = mp_color(@actor)
  288.     text = sprintf("%d/%d", @actor.mp, @actor.maxmp)
  289.     unless @actor.maxmp == 0
  290.       percent = @actor.mp * 100.0 / @actor.maxmp
  291.     else
  292.       percent = 0
  293.     end
  294.     case YE::BATTLE::DISPLAY::SHOWN_MP_TYPE
  295.     when 1; text = @actor.mp
  296.     when 2; text = sprintf("%d/%d", @actor.mp, @actor.maxmp)
  297.     when 3; text = sprintf("%d%%", percent)
  298.     when 4; text = sprintf("%d %d%%", @actor.mp, percent)
  299.     when 5; text = sprintf("%d/%d %d%%", @actor.mp, @actor.maxmp, percent)
  300.     end
  301.     self.contents.draw_text(dx + 30, dy + 4, dw - 32, WLH, text, 2)
  302.   end
  303.  
  304.   #--------------------------------------------------------------------------
  305.   # Draw Party Rage
  306.   #--------------------------------------------------------------------------
  307.   def draw_party_rage(index)
  308.     return unless $imported["CustomSkillEffects"]
  309.     dx = 0
  310.     dy = WLH * 3
  311.     if $imported["BattlerStatMorale"] and YE::BATTLE::DISPLAY::GAUGE_MORALE
  312.       dy -= YE::BATTLE::DISPLAY::STAT_FONT_SIZE
  313.     end
  314.     dw = 92 / 2
  315.     if YE::BATTLE::DISPLAY::RAGE_DISPLAY == 1
  316.       dx = index * 96 + 2
  317.     elsif YE::BATTLE::DISPLAY::RAGE_DISPLAY == 2
  318.       dx = index * 96 + 2 + dw
  319.     end
  320.     draw_rage_gauge(@actor, dx, dy, dw)
  321.     self.contents.font.size = YE::BATTLE::DISPLAY::STAT_FONT_SIZE
  322.     self.contents.font.color = system_color
  323.     text = YE::BATTLE::DISPLAY::RAGE_TEXT
  324.     self.contents.draw_text(dx + 2, dy + 4, 28, WLH, text, 0)
  325.     self.contents.font.color = mp_color(@actor)
  326.     text = @actor.rage
  327.     self.contents.draw_text(dx + 30, dy + 4, dw - 32, WLH, text, 2)
  328.   end
  329.  
  330.   #--------------------------------------------------------------------------
  331.   # Draw Rage Gauge
  332.   #--------------------------------------------------------------------------
  333.   def draw_rage_gauge(actor, x, y, width = 120)
  334.     return unless $imported["CustomSkillEffects"]
  335.     gc0 = gauge_back_color
  336.     gc1 = text_color(YE::BATTLE::DISPLAY::RAGE_GAUGE1)
  337.     gc2 = text_color(YE::BATTLE::DISPLAY::RAGE_GAUGE2)
  338.     gh = 6
  339.     gy = y + WLH - 8 - (gh - 6)
  340.     gb = width
  341.     self.contents.fill_rect(x, gy, gb, gh, gc0)
  342.     if actor.rage <= 0
  343.       gw = 0
  344.     else
  345.       gw = gb * actor.rage / YE::BATTLE::MAX_RAGE
  346.     end
  347.     self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
  348.   end
  349.  
  350.   #--------------------------------------------------------------------------
  351.   # Draw Party Morale
  352.   #--------------------------------------------------------------------------
  353.   def draw_party_morale(index)
  354.     return unless $imported["BattlerStatMorale"]
  355.     draw_morale_icon(index)
  356.     return unless YE::BATTLE::DISPLAY::GAUGE_MORALE
  357.     dx = index * 96 + 2
  358.     dy = WLH * 3
  359.     dw = 92
  360.     draw_morale_gauge(@actor, dx, dy, dw)
  361.     self.contents.font.size = YE::BATTLE::DISPLAY::STAT_FONT_SIZE
  362.     self.contents.font.color = system_color
  363.     text = YE::BATTLE::DISPLAY::MORALE_TEXT
  364.     self.contents.draw_text(dx + 2, dy + 4, 44, WLH, text, 0)
  365.     self.contents.font.color = normal_color
  366.     text = sprintf("%+d", @actor.morale)
  367.     self.contents.draw_text(dx + 46, dy + 4, 44, WLH, text, 2)
  368.   end
  369.  
  370.   #--------------------------------------------------------------------------
  371.   # Draw Morale Gauge
  372.   #--------------------------------------------------------------------------
  373.   def draw_morale_gauge(actor, x, y, width = 120)
  374.     return unless $imported["BattlerStatMorale"]
  375.     gc0 = gauge_back_color
  376.     gc1 = text_color(YE::BATTLE::DISPLAY::MORALE_GAUGE1)
  377.     gc2 = text_color(YE::BATTLE::DISPLAY::MORALE_GAUGE2)
  378.     gc3 = text_color(YE::BATTLE::DISPLAY::MORALE_GAUGE3)
  379.     gc4 = text_color(YE::BATTLE::DISPLAY::MORALE_GAUGE4)
  380.     gh = 6
  381.     gy = y + WLH - 8 - (gh - 6)
  382.     gb = width
  383.     self.contents.fill_rect(x, gy, gb, gh, gc0)
  384.     if actor.morale == 0
  385.       gw = 0
  386.     elsif actor.morale > 0
  387.       gw = gb * actor.morale / actor.max_morale
  388.       self.contents.gradient_fill_rect(x, gy, gw, gh, gc1, gc2)
  389.     else
  390.       gw = gb * actor.morale / actor.min_morale
  391.       x += gb - gw
  392.       self.contents.gradient_fill_rect(x, gy, gw, gh, gc3, gc4)
  393.     end
  394.   end
  395.  
  396.   #--------------------------------------------------------------------------
  397.   # Draw Morale Icon
  398.   #--------------------------------------------------------------------------
  399.   def draw_morale_icon(index)
  400.     return unless YE::BATTLE::DISPLAY::ICON_MORALE
  401.     morale = @actor.morale / YE::BATTLE::DISPLAY::MORALE_DIVISOR
  402.     return if morale == 0
  403.     dx = index * 96 + 72
  404.     dy = 0
  405.     if morale > 0
  406.       icon = YE::BATTLE::DISPLAY::ICON_MORALE_HIGH
  407.       colour = YE::BATTLE::DISPLAY::MORALE_COL_HIGH
  408.     else
  409.       icon = YE::BATTLE::DISPLAY::ICON_MORALE_LOW
  410.       colour = YE::BATTLE::DISPLAY::MORALE_COL_LOW
  411.     end
  412.     draw_icon(icon, dx, dy)
  413.     self.contents.font.size = YE::BATTLE::DISPLAY::MORALE_FONT_SIZE
  414.     self.contents.font.color = text_color(colour)
  415.     text = sprintf("%+d%%", morale)
  416.     self.contents.draw_text(dx + 2, dy + 2, 20, 20, text, 1)
  417.   end
  418.  
  419. end # end Window_BattleStatus
  420.  
  421. #===============================================================================
  422. #
  423. # END OF FILE
  424. #
  425. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement