Advertisement
AngryPacman

[VXA] YEA Designed Advanced Enemy HUD

Dec 11th, 2013
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.24 KB | None | 0 0
  1. # First we'll need icons for elements.
  2.  
  3. module PacYanEdits
  4.   IconIDs = {
  5.     1 => 12, # Element ID => Icon ID
  6.     2 => 7,
  7.     5 => 26,
  8.     6 => 53,
  9.   }
  10.   IconIDs.default = 53 # Default element ID
  11.   Element_Max = 8 # Number of elements in the database.
  12.   Buff_Vocab = "Boons:"
  13.   Debuff_Vocab = "Ailments:"
  14.   Strength_Vocab = "Resistances:"
  15.   Weak_Vocab = "Weaknesses:"
  16.   Number_Size = YEA::BATTLE::BATTLESTATUS_TEXT_FONT_SIZE # <- Same as YEA BE
  17.     # Size of font HP and MP gauge text is drawn in.
  18.   Name_Size = YEA::BATTLE::BATTLESTATUS_NAME_FONT_SIZE # <- Same as YEA BE
  19.     # Size of font enemy name is drawn in.
  20.   Text_Size = YEA::BATTLE::BATTLESTATUS_NAME_FONT_SIZE
  21.     # Size of font other texts are drawn in.
  22. end
  23.  
  24. # Notetag setup for buffs, debuffs, strengths and weakness check
  25. # Put \buff in the notebox of a state to denote it as a buff, and similarly
  26. # put \debuff to denote a debuff. Duh.
  27. # Put \strong[id] in an enemy's notebox to denote a strength to the element with
  28. # that ID. Similarly, use \weak[id] to denote a wekaness.
  29.  
  30. class RPG::State
  31.   def buff?
  32.     return !self.note[/\\buff/i].nil?
  33.   end
  34.   def debuff?
  35.     return !self.note[/\\debuff/i].nil?
  36.   end
  37. end
  38.  
  39. class RPG::Enemy < RPG::BaseItem
  40.   def strength?(id)
  41.     return !self.note[/\\strong\[#{id}\]/i].nil?
  42.   end
  43.   def weakness?(id)
  44.     return !self.note[/\\weak\[#{id}\]/i].nil?
  45.   end
  46. end
  47.  
  48. # These methods will collect the buffs and debuffs a battler has, as well as
  49. # its element reactions.
  50.  
  51. class Game_BattlerBase
  52.   def pac_buffs
  53.     icons = []
  54.     @buffs.each_with_index {|lv, i|
  55.       icons.push(buff_icon_index(lv, i)) if lv > 0 }
  56.     for state in states
  57.       icons.push(state.icon_index) if state.buff?
  58.     end
  59.     icons.delete(0)
  60.     icons
  61.   end
  62.   def pac_debuffs
  63.     icons = []
  64.     @buffs.each_with_index {|lv, i|
  65.       icons.push(buff_icon_index(lv, i)) if lv < 0 }
  66.     for state in states
  67.       icons.push(state.icon_index) if state.debuff?
  68.     end
  69.     icons.delete(0)
  70.     icons
  71.   end
  72.   def pac_strengths
  73.     pac_strengths = []
  74.     for id in 1...PacYanEdits::Element_Max
  75.       pac_strengths.push(PacYanEdits::IconIDs[id]) if enemy.strength?(id)
  76.     end
  77.     pac_strengths
  78.   end
  79.   def pac_weakness
  80.     pac_weakness = []
  81.     for id in 1...PacYanEdits::Element_Max
  82.       pac_weakness.push(PacYanEdits::IconIDs[id]) if enemy.weakness?(id)
  83.     end
  84.     pac_weakness
  85.   end
  86. end
  87.  
  88. # Now to adjust what's drawn in the Enemy Window
  89.  
  90. class Window_BattleHelp < Window_Help
  91.  
  92.   alias pacyan_contents_height contents_height
  93.   def contents_height(*args)
  94.     pacyan_contents_height(*args) * 2
  95.   end
  96.  
  97.   #--------------------------------------------------------------------------
  98.   # draw_enemy_icons ~ Jesus shit look at this method
  99.   #--------------------------------------------------------------------------
  100.   def draw_enemy_icons(actor, x, y, width = 96)
  101.     # Draw Buffs
  102.     text = PacYanEdits::Buff_Vocab
  103.     w = text_size(text).width
  104.     draw_text(128, 0, contents.width, line_height, text)
  105.     buffs = (actor.pac_buffs)[0, width / 24]
  106.     buffs.each_with_index {|n, i| draw_icon(n, 128 + x + w + 24 * i, y) }
  107.     # Draw Debuffs
  108.     text = PacYanEdits::Debuff_Vocab
  109.     w = text_size(text).width
  110.     draw_text(128, line_height, contents.width, line_height, text)
  111.     debuffs = (actor.pac_debuffs)[0, width / 24]
  112.     debuffs.each_with_index {|n, i| draw_icon(n, 128 + x + w + 24 * i,
  113.       y + line_height) }
  114.     # Draw Resistances
  115.     text = PacYanEdits::Strength_Vocab
  116.     w = text_size(text).width
  117.     draw_text(128, line_height * 2, contents.width, line_height, text)
  118.     strengths = (actor.pac_strengths)
  119.     strengths.each_with_index {|n, i| draw_icon(n, 128 + x + w + 24 * i,
  120.       y + line_height * 2) }
  121.     # Draw Weaknesses
  122.     text = PacYanEdits::Weak_Vocab
  123.     w = text_size(text).width
  124.     draw_text(128, line_height * 3, contents.width, line_height, text)
  125.     weakness = (actor.pac_weakness)[0, width / 24]
  126.     weakness.each_with_index {|n, i| draw_icon(n, 128 + x + w + 24 * i,
  127.       y + line_height * 3) }
  128.   end
  129.  
  130.   #--------------------------------------------------------------------------
  131.   # refresh_battler_name
  132.   #--------------------------------------------------------------------------
  133.   def refresh_battler_name(battler)
  134.     if enemy_window.active
  135.       self.height = fitting_height(4)
  136.       contents.clear
  137.       reset_font_settings
  138.       change_color(normal_color)
  139.       @text = battler_name(battler)
  140.       contents.font.size = PacYanEdits::Name_Size
  141.       draw_text(0, 0, contents.width, line_height, @text)
  142.       contents.font.size = PacYanEdits::Number_Size
  143.       draw_actor_hp(battler, 0, line_height)
  144.       draw_actor_mp(battler, 0, line_height * 2)
  145.       contents.font.size = PacYanEdits::Text_Size
  146.       draw_enemy_icons(battler, 0, 0, contents.width)
  147.     else
  148.       contents.clear
  149.       reset_font_settings
  150.       change_color(normal_color)
  151.       @text = battler_name(battler)
  152.       icons = battler.state_icons + battler.buff_icons
  153.       dy = icons.size <= 0 ? line_height / 2 : 0
  154.       draw_text(0, dy, contents.width, line_height, @text, 1)
  155.       dx = (contents.width - (icons.size * 24)) / 2
  156.       draw_actor_icons(battler, dx, line_height, contents.width)
  157.     end
  158.   end
  159. end # Window_BattleHelp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement