SHARE
TWEET

Verus Tempus Proelium HUD

a guest May 16th, 2010 547 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # Verus Tempus Ballum - HUD
  3. #==============================================================================
  4.  
  5. Show_Switch   = 0
  6.  
  7. Text_Skills   = "Skills"
  8.  
  9. Text_Items    = "Items"
  10.  
  11. Text_Allies   = "Party"
  12.  
  13. Attack_Icon   = 1
  14.  
  15. Defend_Icon   = 52
  16.  
  17. Skill_Icon    = 119
  18.  
  19. Heal_Icon     = 128
  20.  
  21. X_Position    = 0
  22.  
  23. Y_Position    = 320
  24.  
  25. #------------------------------------------------------------------------------
  26. class Game_Party < Game_Unit
  27.  
  28.   alias verus_tempus_proelium_gparty_lose_item lose_item
  29.  
  30.   def lose_item(item, n, include_equip = false)
  31.     verus_tempus_proelium_gparty_lose_item(item, n, include_equip)
  32.     if members[0].item_hotkeys.include?(item.id)
  33.       $refresh_hud = true
  34.     end
  35.   end
  36.  
  37. end
  38.  
  39. #------------------------------------------------------------------------------
  40. class Sprite_HUD < Sprite
  41.  
  42.   def initialize(viewport)
  43.     super(viewport)
  44.     self.bitmap = Bitmap.new(132, 84)
  45.     update
  46.   end
  47.  
  48.   def update
  49.     return if $game_party.members.size <= 0
  50.     self.visible = (Show_Switch <= 0 or (Show_Switch > 0 and $game_switches[Show_Switch]))
  51.     super
  52.     if $game_player.screen_x <= self.bitmap.width+10 and
  53.       $game_player.screen_y <= self.bitmap.height+10
  54.       self.opacity -= 10 if self.opacity > 0
  55.     elsif self.opacity < 255
  56.       self.opacity += 10
  57.     end
  58.     refresh if something_changed?
  59.   end
  60.  
  61.   def refresh
  62.     @actor = $game_party.members[0]
  63.     @hp = @actor.hp
  64.     @mp = @actor.mp
  65.     self.bitmap.clear
  66.     base = Cache.system("Bar Base")
  67.     hpbar = Cache.system("HP Bar")
  68.     mpbar = Cache.system("MP Bar")
  69.     expbar = Cache.system("Exp Bar")
  70.     self.bitmap.blt(4, 4, base, base.rect)
  71.     self.bitmap.blt(4, 22, base, base.rect)
  72.     self.bitmap.blt(4, 40, base, base.rect)
  73.     hprect = Rect.new(0, 0, hpbar.width*@actor.hp/@actor.maxhp, hpbar.height)
  74.     mprect = Rect.new(0, 0, mpbar.width*@actor.mp/@actor.maxmp, mpbar.height)
  75.     exprect = Rect.new(0, 0, expbar.width*@actor.current_exp/@actor.next_exp, expbar.height)
  76.     self.bitmap.blt(4, 4, hpbar, hprect)
  77.     self.bitmap.blt(4, 22, mpbar, mprect)
  78.     self.bitmap.blt(4, 40, expbar, exprect)
  79.     self.bitmap.font.size = 16
  80.     self.bitmap.draw_outlined_text(5, 3, 26, 18, Vocab.hp_a)
  81.     self.bitmap.draw_outlined_text(5, 21, 26, 18, Vocab.mp_a)
  82.     self.bitmap.draw_outlined_text(5, 39, 26, 18, "Exp")
  83.   end
  84.  
  85.   def something_changed?
  86.     return true if @actor != $game_party.members[0]
  87.     return true if @hp != $game_party.members[0].hp
  88.     return true if @mp != $game_party.members[0].mp
  89.     return false
  90.   end
  91.  
  92. end
  93.  
  94. #------------------------------------------------------------------------------
  95. class Sprite_Hotkeys < Sprite
  96.  
  97.   def initialize(viewport)
  98.     super(viewport)
  99.     self.x = X_Position
  100.     self.y = Y_Position
  101.     self.opacity = 0
  102.     @base = Cache.system("Hotkeys Base")
  103.     self.bitmap = Bitmap.new(@base.width, @base.height)
  104.     @items = {}
  105.     @members = $game_party.members
  106.     update
  107.   end
  108.  
  109.   def update
  110.     return if $game_party.members.size <= 0
  111.     super
  112.     if $game_player.ally_action != nil
  113.       self.opacity = 64
  114.       return
  115.     end
  116.     if show?
  117.       self.visible = true unless self.visible
  118.       self.opacity += 10 if self.opacity < 255
  119.     elsif self.visible and !show?
  120.       self.opacity -= 10
  121.       if self.opacity <= 10
  122.         self.visible = false
  123.         @draw_skills = false
  124.         @draw_items = false
  125.         @draw_allies = false
  126.       end
  127.     end
  128.     if $game_player.selecting_skill and !@draw_skills
  129.       @draw_items = false
  130.       @draw_skills = true
  131.       @draw_allies = false
  132.       refresh
  133.     elsif $game_player.selecting_item and !@draw_items
  134.       @draw_skills = false
  135.       @draw_items = true
  136.       @draw_allies = false
  137.       refresh
  138.     elsif $game_player.selecting_action and !@draw_allies
  139.       @draw_allies = true
  140.       @draw_skills = false
  141.       @draw_items = false
  142.       refresh
  143.     end
  144.     if @draw_items and $refresh_hud
  145.       refresh
  146.       $refresh_hud = false
  147.     end
  148.     if @draw_allies
  149.       if @members != $game_party.members
  150.         @members = $game_party.members
  151.         refresh
  152.       end
  153.     end
  154.   end
  155.  
  156.   def refresh
  157.     self.bitmap.clear
  158.     self.bitmap.font.size = 16
  159.     self.bitmap.blt(0, 0, @base, @base.rect)
  160.     if @draw_skills
  161.       $game_player.actor.skill_hotkeys.each { |k, v|
  162.         i = (k == 2 ? 7 : k == 8 ? 1 : k == 4 ? 3 : k == 6 ? 5 : 0)
  163.         draw_icon($data_skills[v].icon_index, i%3*32+4, i/3*32+4)
  164.       }
  165.       self.bitmap.font.color = Color.new(132,170,255)
  166.       self.bitmap.draw_text(32, 40, 32, 16, Text_Skills, 1)
  167.     elsif @draw_items
  168.       $game_player.actor.item_hotkeys.each { |k, v|
  169.         i = (k == 2 ? 7 : k == 8 ? 1 : k == 4 ? 3 : k == 6 ? 5 : 0)
  170.         draw_icon($data_items[v].icon_index, i%3*32+4, i/3*32+4)
  171.         n = $game_party.item_number($data_items[v])
  172.         @items[v] = n
  173.         self.bitmap.font.color = Color.new(255,255,255)
  174.         self.bitmap.draw_outlined_text(i%3*32+4, i/3*32+16, 24, 16, n.to_s, 1)
  175.       }
  176.       self.bitmap.font.color = Color.new(132,170,255)
  177.       self.bitmap.draw_text(32, 40, 32, 16, Text_Items, 1)
  178.     elsif @draw_allies
  179.       for ally in $game_allies.compact
  180.         a = ally.actor.index
  181.         i = (a == 1 ? 1 : a == 2 ? 3 : a == 3 ? 5 : 0)
  182.         draw_face(ally.actor, i%3*32, i/3*32)
  183.       end
  184.       self.bitmap.font.color = Color.new(132,170,255)
  185.       self.bitmap.draw_text(32, 40, 32, 16, Text_Allies, 1)
  186.     end
  187.   end
  188.  
  189.   def show?
  190.     return true if $game_player.selecting_skill
  191.     return true if $game_player.selecting_item
  192.     return true if $game_player.selecting_action
  193.     return false
  194.   end
  195.  
  196. end
  197.  
  198. #------------------------------------------------------------------------------
  199. class Sprite_Actions < Sprite
  200.  
  201.   def initialize(viewport)
  202.     super(viewport)
  203.     self.x = X_Position + 9
  204.     self.y = Y_Position + 9
  205.     @base = Cache.system("Actions Base")
  206.     self.bitmap = Bitmap.new(@base.width, @base.height)
  207.     self.visible = false
  208.     self.opacity = 0
  209.     update
  210.   end
  211.  
  212.   def update
  213.     return if $game_party.members.size <= 0
  214.     super
  215.     if $game_player.ally_action != nil
  216.       unless self.visible
  217.         self.visible = true
  218.         refresh
  219.       end
  220.       self.opacity += 10 if self.opacity < 255
  221.     elsif self.visible
  222.       self.opacity -= 10
  223.       self.visible = false if self.opacity <= 0
  224.     end
  225.     if $game_player.ally_action != nil and
  226.       @action != $game_player.ally_action.action
  227.       refresh
  228.     end
  229.   end
  230.  
  231.   def refresh
  232.     @action = $game_player.ally_action.action
  233.     self.bitmap.clear
  234.     self.bitmap.blt(0, 0, @base, @base.rect)
  235.     bitmap = Cache.system("Iconset")
  236.     opacity = ($game_player.ally_action.action)
  237.     draw_icon(Attack_Icon, 28, 2, icon_opacity(0))
  238.     draw_icon(Defend_Icon, 2, 28, icon_opacity(2))
  239.     draw_icon(Skill_Icon, 54, 28, icon_opacity(1))
  240.     draw_icon(Heal_Icon, 28, 54, icon_opacity(3))
  241.     draw_face($game_player.ally_action.actor, 23, 23)
  242.   end
  243.  
  244.   def icon_opacity(i)
  245.     return ($game_player.ally_action.action == i ? 255 : 96)
  246.   end
  247.  
  248. end
  249.  
  250. #------------------------------------------------------------------------------
  251. class Spriteset_Map
  252.  
  253.   alias vtphud_spmap_initialize initialize
  254.   alias vtphud_spmap_update update
  255.   alias vtphud_spmap_dispose dispose
  256.  
  257.   def initialize
  258.     vtphud_spmap_initialize
  259.     @sprite_hud = Sprite_HUD.new(@viewport3)
  260.     @sprite_hotkeys = Sprite_Hotkeys.new(@viewport3)
  261.     @sprite_actions = Sprite_Actions.new(@viewport3)
  262.   end
  263.  
  264.   def update
  265.     vtphud_spmap_update
  266.     @sprite_hud.update if @sprite_hud != nil
  267.     @sprite_hotkeys.update if @sprite_hotkeys != nil
  268.     @sprite_actions.update if @sprite_actions != nil
  269.   end
  270.  
  271.   def dispose
  272.     vtphud_spmap_dispose
  273.     @sprite_hud.dispose if @sprite_hud != nil
  274.     @sprite_hotkeys.dispose if @sprite_hotkeys != nil
  275.     @sprite_actions.dispose if @sprite_actions != nil
  276.   end
  277.  
  278. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top