Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- Script: RMX-OS Party HUD Version 0.83
- Author: Chaucer
- thanks to Blizzard for helping get player stats.
- free to use in commercial & non-commercial games just give credits.
- Instructions:
- Place Below RMX-OS, Blizz ABS,
- HUD_X & Y self explanitory
- HP_X & Y As above
- SP_X & Y As above
- HP_OX & OY used to center Health bar inside of the health background
- (if background is larger than the hp bar)
- SP_OX & OY As above
- Name_x & y name & level x & y values
- Background:
- nil = black border(used to match blizz abs hud border)
- 0 = no border
- 'Image_name' = use an image background instead.
- HP_Full:
- Health bar image
- HP_Empty:
- Background for health
- SP_Full:
- same as HP_Full(Except for SP)
- SP_Empty:
- same as HP_Empty(Except for SP)
- Percent_HP:
- true will show HP in % value I.E. full HP = 100%
- false will show HP in Current_HP / Max HP
- Percent SP:
- same as above except for SP
- =end
- module NewHUD
- #============================================================================
- #Configuration
- #============================================================================
- #The X & Y of the new Hud
- HUD_X = 44
- HUD_Y = 86
- #X & Y of HP Bars
- HP_X = 10
- HP_Y = 11
- #X & Y of SP Bars
- SP_X = 10
- SP_Y = 21
- #Offset X & Offset Y of HP Bars
- HP_OX = 1
- HP_OY = 1
- #Offset X & Offset Y of HP Bars
- SP_OX = 1
- SP_OY = 1
- #use icons to define party member's class
- ICONS = false
- #use colors to define party member's place in party
- ICON_COLOR = false
- #Class Icons x & y if ICONS = TRUE
- ICON_X = 1
- ICON_Y = 1
- #draws name & level X & Y positions
- NAME_X = 0
- NAME_Y = -1
- #Background Image of HUD
- BACKGROUND = nil
- #Hud HP Full
- HP_FULL = "Health_bar"
- #Hud HP Empty
- HP_EMPTY = "Health_bar_Empty"
- #Hud HP Full
- SP_FULL = "Mana_bar"
- #Hud HP Empty
- SP_EMPTY = "Mana_bar_Empty"
- #Party Leader Name Color
- #please use one of the following anything else will result in 1
- #1 = Red
- #2 = Blue
- #3 = Green
- #4 = Yellow
- #5 = Orange
- #6 = Purple
- COLOR = 4
- #Health Number in % or [hp/maxhp]
- PERCENT_HP = false #true = hp in % false = hp / maxhp
- #Health Number in % or [hp/maxhp]
- PERCENT_SP = false #same as above
- end
- #=============================================================================
- #Hud Draw
- #=============================================================================
- class New_Hud
- def initialize
- @old_leader = []
- @old_leader.push($network.partyleader)
- @old_party = []
- @old_class = []
- @old_party.push($network.party)
- @old_combine = @old_leader + @old_party.flatten
- @old_combine - [$network.username]
- @old_combine.uniq
- @party_each = $network.party.size
- @background_image = []
- @old_level = []
- @name_level = []
- @class_icon = []
- @health_0_image = []
- @health_1_image = []
- @old_maxhp = []
- @old_hp = []
- @health_2_image = []
- @hnumber = []
- @mana_0_image = []
- @mana_1_image = []
- @old_maxsp = []
- @old_sp = []
- @mana_2_image = []
- @mnumber = []
- #=============================================================================
- #Hud Update
- #=============================================================================
- def update
- @new_leader = []
- @new_leader.push($network.partyleader)
- @new_party = []
- @new_party.push($network.party)
- @new_combine = @new_leader + @new_party.flatten
- @new_combine = @new_combine - [$network.username]
- @new_combine = @new_combine - [""]
- @new_combine = @new_combine.uniq
- @party_each = @new_combine.size - 1
- @new_level = []
- @new_combine.each do |username|
- $network.players.each do |id, player|
- if username == player.username
- @new_level.push(player.battler.level)
- end
- end
- end
- @new_class = []
- @new_combine.each do |username|
- $network.players.each do |id, player|
- if username == player.username
- @new_class.push(player.battler.class_name)
- end
- end
- end
- @new_maxhp = []
- @new_combine.each do |username|
- $network.players.each do |id, player|
- if username == player.username
- @new_maxhp.push(player.battler.maxhp)
- end
- end
- end
- @new_hp = []
- @new_combine.each do |username|
- $network.players.each do |id, player|
- if username == player.username
- @new_hp.push(player.battler.hp)
- end
- end
- end
- @new_maxsp = []
- @new_combine.each do |username|
- $network.players.each do |id, player|
- if username == player.username
- @new_maxsp.push(player.battler.maxsp)
- end
- end
- end
- @new_sp = []
- @new_combine.each do |username|
- $network.players.each do |id, player|
- if username == player.username
- @new_sp.push(player.battler.sp)
- end
- end
- end
- dispose if @new_party != @old_party
- update_background if @new_combine != @old_combine
- update_name if @new_party != @old_party || @new_level != @old_level
- update_icon if @new_party != @old_party || @new_class != @old_class
- update_hp if @new_hp != @old_hp || @new_maxhp != @old_maxhp
- update_sp if @new_sp != @old_sp || @new_maxsp != @old_maxsp
- end
- def update_background
- #draws background
- @old_combine = @new_combine
- @background_image.each {|sprite| sprite.dispose } if @background_image != nil
- if NewHUD::BACKGROUND == nil
- #draws background
- @background_image = []
- for i in (0..@party_each)
- @background_image[i] = Sprite.new
- @background_image[i].bitmap = Bitmap.new(78,30)
- @background_image[i].bitmap.fill_rect(0, 0, 78, 30, Color.new(0, 0, 0,128))
- @background_image[i].x = NewHUD::HUD_X
- @background_image[i].y = NewHUD::HUD_Y + (30 + 1) * i
- @background_image[i].z = 1000
- end
- elsif NewHUD::BACKGROUND == 0
- @background_image = []
- for i in (0..@party_each)
- @background_image[i] = Sprite.new
- @background_image[i].bitmap = Bitmap.new(78,30)
- @background_image[i].bitmap.fill_rect(0, 0, 78, 30, Color.new(0, 0, 0,0))
- @background_image[i].x = NewHUD::HUD_X
- @background_image[i].y = NewHUD::HUD_Y + (30 + 1) * i
- @background_image[i].z = 1000
- end
- else
- @background_image = []
- for i in (0..@party_each)
- @background_image[i] = Sprite.new
- @background_image[i].bitmap = RPG::Cache.picture(NewHUD::BACKGROUND)
- @background_image[i].x = NewHUD::HUD_X
- @background_image[i].y = NewHUD::HUD_Y + (@background_image[i].bitmap.height + 1) * i
- @background_image[i].z = 1000
- end
- end
- end
- def update_name
- @old_party = @new_party
- @old_level = @new_level
- @name_level.each {|sprite| sprite.dispose } if @name_level != []
- #draws name & level
- if NewHUD::BACKGROUND == nil || NewHUD::BACKGROUND == 0
- nmlvw = 78
- nmlvh = 30
- else
- nmlvw = RPG::Cache.picture(NewHUD::BACKGROUND).width
- nmlvh = RPG::Cache.picture(NewHUD::BACKGROUND).height
- end
- nmlvx = NewHUD::HUD_X + NewHUD::NAME_X
- nmlvy = NewHUD::HUD_Y + NewHUD::NAME_Y
- @name_level = []
- for i in (0..@party_each)
- @nm2 = @new_combine - [$network.username]
- @name = '' if @nm2.at(i) == nil
- @name = @nm2.at(i) + ' Lv:' + @new_level.at(i).to_s
- @name_level[i] = Sprite.new
- @name_level[i].bitmap = Bitmap.new(nmlvw,15)
- @name_level[i].bitmap.font.name = "Arial"
- @name_level[i].bitmap.font.size = 12
- @name_level[i].bitmap.font.bold = false
- @leader_color = Color.new(255,50,50,255) if NewHUD::COLOR == 1 || NewHUD::COLOR > 6 or NewHUD::COLOR < 1
- @leader_color = Color.new(87,87,255,255) if NewHUD::COLOR == 2
- @leader_color = Color.new(87,255,87,255) if NewHUD::COLOR == 1
- @leader_color = Color.new(255,255,87,255) if NewHUD::COLOR == 4
- @leader_color = Color.new(255,187,0,255) if NewHUD::COLOR == 5
- @leader_color = Color.new(255,87,255,255) if NewHUD::COLOR == 6
- @name_level[i].bitmap.font.color = Color.new(255, 255, 255,255) if @nm2.at(i) != $network.partyleader
- @name_level[i].bitmap.font.color = @leader_color if @nm2.at(i) == $network.partyleader
- @name_level[i].bitmap.draw_text_full(0, 0, nmlvw, 14, @name, 1)
- @name_level[i].x = nmlvx
- @name_level[i].y = nmlvy - 1 + (nmlvh + 1) * i
- @name_level[i].z = 1004
- end
- end
- def update_icon
- @class_icon.each {|sprite| sprite.dispose } if @class_icon != [] || @class_icon == nil
- @old_class = @new_class
- if NewHUD::ICONS == true
- nmlvx = NewHUD::HUD_X + NewHUD::NAME_X
- nmlvy = NewHUD::HUD_Y + NewHUD::NAME_Y
- if NewHUD::BACKGROUND == nil || NewHUD::BACKGROUND == 0
- nmlvh = 30
- else
- nmlvh = RPG::Cache.picture(NewHUD::BACKGROUND).height
- end
- #p @new_class.to_s
- for i in (0..@party_each)
- @nm2 = @new_combine - [$network.username]
- @class_nm = @new_class.at(i)
- # p @class_nm
- @class_icon[i] = Sprite.new
- @class_icon[i].bitmap = RPG::Cache.icon("#{@class_nm}")
- @class_icon[i].x = nmlvx - 24 + NewHUD::ICON_X
- @class_icon[i].y = (nmlvy + 3 - 1 + (nmlvh + 1) * i) + NewHUD::ICON_Y
- @class_icon[i].z = 1004
- if i == 0 && @nm2.at(i) == $network.partyleader && NewHUD::ICON_COLOR == true
- @class_icon[i].tone = Tone.new(255, 0, 0, 255)
- elsif i == 0 && @nm2.at(i) != $network.partyleader && NewHUD::ICON_COLOR == true
- @class_icon[i].tone = Tone.new(0, 0, 255, 255)
- elsif i == 1 && @nm2.at(i) != $network.partyleader && NewHUD::ICON_COLOR == true
- @class_icon[i].tone = Tone.new(0, 255, 0, 255)
- elif i > 1 && @nm2.at(i) != $network.partyleader && NewHUD::ICON_COLOR == true
- @class_icon[i].tone = Tone.new(255, 255, 0, 255)
- end
- end
- end
- end
- def update_hp
- @old_hp = @new_hp
- @old_maxhp = @new_maxhp
- if NewHUD::BACKGROUND == nil || NewHUD::BACKGROUND == 0
- nmlvh = 30
- else
- nmlvh = RPG::Cache.picture(NewHUD::BACKGROUND).height
- end
- #draws HP Background
- @health_1_image.each {|sprite| sprite.dispose } if @health_1_image != nil
- hpx = NewHUD::HUD_X + NewHUD::HP_X
- hpy = NewHUD::HUD_Y + NewHUD::HP_Y
- if NewHUD::BACKGROUND == nil
- hpx = NewHUD::HUD_X + NewHUD::HP_X
- hpy = NewHUD::HUD_Y + NewHUD::HP_Y
- @health_0_image = []
- for i in (0..@party_each)
- @health_0_image[i] = Sprite.new
- @health_0_image[i].bitmap = Bitmap.new(58, 8)
- @health_0_image[i].bitmap.fill_rect(0, 0, 58, 8, Color.new(255, 255, 255, 192))
- @health_0_image[i].x = hpx + 1
- @health_0_image[i].y = hpy + (nmlvh + 1) * i
- @health_0_image[i].z = 1001
- end
- @health_1_image = []
- for i in (0..@party_each)
- @health_1_image[i] = Sprite.new
- @health_1_image[i].bitmap = Bitmap.new(57, 6)
- @health_1_image[i].bitmap.gradient_bar_hud(0, -4, 57, 0, 'hud_green_bar', 0)
- @health_1_image[i].x = hpx + NewHUD::HP_OX
- @health_1_image[i].y = hpy + NewHUD::HP_OY + (nmlvh + 1) * i
- @health_1_image[i].z = 1002
- end
- else
- @health_1_image = []
- for i in (0..@party_each)
- @health_1_image[i] = Sprite.new
- @health_1_image[i].bitmap = RPG::Cache.picture(NewHUD::HP_EMPTY)
- @health_1_image[i].x = hpx
- @health_1_image[i].y = hpy + (nmlvh + 1) * i
- @health_1_image[i].z = 1001
- end
- end
- #draws HP bars
- @health_2_image.each {|sprite| sprite.dispose } if @health_2_image != nil
- hpi = RPG::Cache.picture(NewHUD::HP_FULL)
- w = hpi.width
- h = hpi.height
- if NewHUD::BACKGROUND == nil
- @health_2_image = []
- for i in (0..@party_each)
- rate = (@new_maxhp.at(i) > 0 ? @new_hp.at(i).to_f / @new_maxhp.at(i) : 0) if @new_maxhp.at(i) != nil
- rate = 0 if @new_maxhp.at(i) == nil
- w2 = w * @new_hp.at(i) / @new_maxhp.at(i) if @new_hp.at(i) != nil && @new_maxhp.at(i) != nil
- w2 = 0 if @new_hp.at(i) == nil && @new_maxhp.at(i) == nil
- @health_2_image[i] = Sprite.new
- @health_2_image[i].bitmap = Bitmap.new(57,6)
- @health_2_image[i].bitmap.gradient_bar_hud(0, -4, 57, rate, 'hud_green_bar', 1)
- @health_2_image[i].x = hpx + NewHUD::HP_OX
- @health_2_image[i].y = hpy + NewHUD::HP_OY + (nmlvh + 1) * i
- @health_2_image[i].z = 1003
- end
- else
- @health_2_image = []
- for i in (0..@party_each)
- w2 = w * @new_hp.at(i) / @new_maxhp.at(i) if @new_hp.at(i) != nil && @new_maxhp.at(i) != nil
- w2 = 0 if @new_hp.at(i) == nil && @new_maxhp.at(i) == nil
- @health_2_image[i] = Sprite.new
- @health_2_image[i].bitmap = Bitmap.new(w,h)
- @health_2_image[i].bitmap.fill_rect(0, 0, w, h, Color.new(250, 0, 0,0))
- @health_2_image[i].x = hpx + NewHUD::HP_OX
- @health_2_image[i].y = hpy + NewHUD::HP_OY + (nmlvh + 1) * i
- @health_2_image[i].z = 1002
- @health_2_image[i].bitmap.blt(0, 0, hpi, Rect.new(0, 0, w2, h))
- end
- end
- #draw HP number
- @hnumber.each {|sprite| sprite.dispose } if @hnumber != nil
- hpi = RPG::Cache.picture(NewHUD::HP_FULL)
- w = hpi.width
- h = hpi.height
- @hnumber = []
- for i in (0..@party_each)
- hp_number = 'Offline' if @new_hp.at(i) == nil && @new_maxhp.at(i) == nil
- hp_number = @new_hp.at(i).to_s + ' / ' + @new_maxhp.at(i).to_s if NewHUD::PERCENT_HP == false
- hp_number = @new_hp.at(i) * 100 / @new_maxhp.at(i) if NewHUD::PERCENT_HP == true
- @hnumber[i] = Sprite.new
- @hnumber[i].bitmap = Bitmap.new(300,15)
- @hnumber[i].bitmap.font.name = "Arial"
- @hnumber[i].bitmap.font.size = 12
- @hnumber[i].bitmap.font.bold = false
- @hnumber[i].bitmap.draw_text_full(0,0,w,h+5,' ' + hp_number,1) if NewHUD::PERCENT_HP == false
- @hnumber[i].bitmap.draw_text_full(0,0,w,h+5,' ' + hp_number.to_s + '%',1) if NewHUD::PERCENT_HP == true
- @hnumber[i].x = hpx
- @hnumber[i].y = hpy - 2 + (nmlvh + 1) * i
- @hnumber[i].z = 1004
- end
- end
- def update_sp
- @old_sp = @new_sp
- @old_maxsp = @new_maxsp
- if NewHUD::BACKGROUND == nil || NewHUD::BACKGROUND == 0
- nmlvh = 30
- else
- nmlvh = RPG::Cache.picture(NewHUD::BACKGROUND).height
- end
- @mana_1_image.each {|sprite| sprite.dispose } if @mana_1_image != nil
- spx = NewHUD::HUD_X + NewHUD::SP_X
- spy = NewHUD::HUD_Y + NewHUD::SP_Y
- if NewHUD::BACKGROUND == nil
- hpx = NewHUD::HUD_X + NewHUD::HP_X
- hpy = NewHUD::HUD_Y + NewHUD::HP_Y
- @mana_0_image = []
- for i in (0..@party_each)
- @mana_0_image[i] = Sprite.new
- @mana_0_image[i].bitmap = Bitmap.new(58, 8)
- @mana_0_image[i].bitmap.fill_rect(0, 0, 58, 8, Color.new(255, 255, 255, 192))
- @mana_0_image[i].x = spx + 1
- @mana_0_image[i].y = spy + (nmlvh + 1) * i
- @mana_0_image[i].z = 1001
- end
- @mana_1_image = []
- for i in (0..@party_each)
- @mana_1_image[i] = Sprite.new
- @mana_1_image[i].bitmap = Bitmap.new(57, 6)
- @mana_1_image[i].bitmap.gradient_bar_hud(0, -4, 57, 0, 'hud_blue_bar', 0)
- @mana_1_image[i].x = hpx + NewHUD::HP_OX
- @mana_1_image[i].y = hpy + NewHUD::HP_OY + (nmlvh + 1) * i
- @mana_1_image[i].z = 1002
- end
- else
- @mana_1_image = []
- for i in (0..@party_each)
- @mana_1_image[i] = Sprite.new
- @mana_1_image[i].bitmap = RPG::Cache.picture(NewHUD::SP_EMPTY)
- @mana_1_image[i].x = spx
- @mana_1_image[i].y = spy + (nmlvh + 1) * i
- @mana_1_image[i].z = 1001
- end
- end
- #draws SP bars
- spi = RPG::Cache.picture(NewHUD::SP_FULL)
- sw = spi.width
- sh = spi.height
- @mana_2_image.each {|sprite| sprite.dispose } if @mana_2_image != []
- if NewHUD::BACKGROUND == nil
- @mana_2_image = []
- for i in (0..@party_each)
- rate = (@new_maxsp.at(i) > 0 ? @new_sp.at(i).to_f / @new_maxsp.at(i) : 0) if @new_maxhp.at(i) != nil
- rate = 0 if @new_maxsp.at(i) == nil
- sw2 = sw * @new_sp.at(i) / @new_maxsp.at(i) if @new_sp.at(i) != nil && @new_maxsp.at(i) != nil
- sw2 = 0 if @new_sp.at(i) == nil && @new_maxsp.at(i) == nil
- @mana_2_image[i] = Sprite.new
- @mana_2_image[i].bitmap = Bitmap.new(57,6)
- @mana_2_image[i].bitmap.gradient_bar_hud(0, -4, 57, rate, 'hud_blue_bar', 0)
- @mana_2_image[i].x = spx + NewHUD::SP_OX
- @mana_2_image[i].y = spy + NewHUD::SP_OY + (nmlvh + 1) * i
- @mana_2_image[i].z = 1003
- end
- else
- @mana_2_image = []
- for i in (0..@party_each)
- sw2 = sw * @new_sp.at(i) / @new_maxsp.at(i) if @new_sp.at(i) != nil && @new_maxsp.at(i) != nil
- sw2 = 0 if @new_sp.at(i) == nil && @new_maxsp.at(i) == nil
- @mana_2_image[i] = Sprite.new
- @mana_2_image[i].bitmap = Bitmap.new(sw,sh)
- @mana_2_image[i].bitmap.fill_rect(0, 0, sw, sh, Color.new(0, 0, 0, 0))
- @mana_2_image[i].x = spx + NewHUD::SP_OX
- @mana_2_image[i].y = spy + NewHUD::SP_OY + (nmlvh + 1) * i
- @mana_2_image[i].z = 1002
- @mana_2_image[i].bitmap.blt(0, 0, spi, Rect.new(0, 0, sw2, sh))
- end
- end
- #draw SP number
- @mnumber.each {|sprite| sprite.dispose } if @mnumber != nil
- @mnumber = []
- for i in (0..@party_each)
- sp_number = 'Offline' if @new_sp.at(i) == nil && @new_maxsp.at(i) == nil
- sp_number = @new_sp.at(i).to_s+' / '+ @new_maxsp.at(i).to_s if NewHUD::PERCENT_SP == false
- sp_number = @new_sp.at(i) * 100 / @new_maxsp.at(i) if NewHUD::PERCENT_SP == true
- @mnumber[i] = Sprite.new
- @mnumber[i].bitmap = Bitmap.new(sw,sh+4)
- @mnumber[i].bitmap.font.name = "Arial"
- @mnumber[i].bitmap.font.size = 12
- @mnumber[i].bitmap.font.bold = false
- @mnumber[i].bitmap.draw_text_full(0,0,sw,sh+5,' ' + sp_number,1) if NewHUD::PERCENT_SP == false
- @mnumber[i].bitmap.draw_text_full(0,0,sw,sh+5,' ' + sp_number.to_s + '%',1) if NewHUD::PERCENT_SP == true
- @mnumber[i].x = spx
- @mnumber[i].y = spy - 2 + (nmlvh + 1) * i
- @mnumber[i].z = 1004
- end
- end
- #=============================================================================
- #Hud Dispose
- #=============================================================================
- def dispose
- @old_party = []
- @old_combine = []
- @old_hp = []
- @old_maxhp = []
- @old_sp = []
- @old_maxsp = []
- @old_level = []
- @old_class = []
- @background_image.each {|sprite| sprite.dispose } if @background_image != nil
- @name_level.each {|sprite| sprite.dispose } if @name_level != []
- @class_icon.each {|sprite| sprite.dispose } if @class_icon != []
- if @health_0_image != nil || @health_0_image != []
- @health_0_image.each {|sprite| sprite.dispose }
- end
- @health_1_image.each {|sprite| sprite.dispose } if @health_1_image != []
- @health_2_image.each {|sprite| sprite.dispose } if @health_2_image != []
- @hnumber.each {|sprite| sprite.dispose } if @hnumber != []
- if @mana_0_image != nil || @mana_0_image != []
- @mana_0_image.each {|sprite| sprite.dispose }
- end
- @mana_1_image.each {|sprite| sprite.dispose } if @mana_1_image != []
- @mana_2_image.each {|sprite| sprite.dispose } if @mana_2_image != []
- @mnumber.each {|sprite| sprite.dispose } if @mnumber != []
- end
- end
- end
- class Scene_Map
- alias hud_main main
- def main
- @newhud = New_Hud.new
- @newhud.dispose
- hud_main
- @newhud = nil
- end
- alias phud_update update
- def update
- phud_update
- if $scene != Scene_Map
- @newhud.dispose
- end
- if $game_system.hud == true
- @newhud.update
- elsif $game_system.hud != true
- @newhud.dispose
- end
- end
- end
- class Hud
- alias draw_name_online draw_name
- def draw_name
- if @name != $network.username || @old_leader != $network.partyleader
- #set username
- @name = $network.username
- #setup bitmap
- self.bitmap.fill_rect(@name_x, @name_y, 104, 19, Color.new(0, 0, 0, 128))
- # set font color
- if $network.partyleader != $network.username || $network.partyleader == ''
- self.bitmap.font.color = Color.new(255, 255, 255)
- else
- @leader_color = Color.new(0,0,0,255) if NewHUD::COLOR > 6 or NewHUD::COLOR < 1
- @leader_color = Color.new(255,50,50,255) if NewHUD::COLOR == 1
- @leader_color = Color.new(87,87,255,255) if NewHUD::COLOR == 2
- @leader_color = Color.new(87,255,87,255) if NewHUD::COLOR == 1
- @leader_color = Color.new(255,255,87,255) if NewHUD::COLOR == 4
- @leader_color = Color.new(255,187,0,255) if NewHUD::COLOR == 5
- @leader_color = Color.new(255,87,255,255) if NewHUD::COLOR == 6
- self.bitmap.font.color = @leader_color
- end
- # draw actor's name
- self.bitmap.draw_text_full(@name_x, @name_y, 104, 20, @name)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement