Group: +Gold Member
Posts: 1,529
Type: Scripter
RM Skill: Undisclosed
Jens answered the question of more enemies in the #15 post, but this is a edited version that hides the enemy windows once the enemy is dead:
Code
CODE
# Breath of Fire Enemy window # By Noobitron # Slanted Bars by Sephiroth Spawn. # Edited by NR (13/Jan/10)
class Window_Base # define enemy name def draw_enemy_name(enemy, x, y) self.contents.font.color = normal_color self.contents.draw_text(x, y, 120, 32, enemy.name) end
#-------------------------------------------------------------------------- # * Draw Slant Bar(by SephirothSpawn) #-------------------------------------------------------------------------- def draw_slant_bar(x, y, min, max, width = 152, height = 6, bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255)) # Draw Border for i in 0..height self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255)) end # Draw Background for i in 1..(height - 1) r = 100 * (height - i) / height + 0 * i / height g = 100 * (height - i) / height + 0 * i / height b = 100 * (height - i) / height + 0 * i / height a = 255 * (height - i) / height + 255 * i / height self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a)) end # Draws Bar for i in 1..( (min / max.to_f) * width - 1) for j in 1..(height - 1) r = bar_color.red * (width - i) / width + end_color.red * i / width g = bar_color.green * (width - i) / width + end_color.green * i / width b = bar_color.blue * (width - i) / width + end_color.blue * i / width a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a)) end end end end
#ENEMY HP WINDOW class Window_EnemyHP < Window_Base def initialize super(0, 0, 160, 480) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = 0 refresh end
#REFRESH def refresh self.contents.clear i = 0 for enemy in $game_troop.enemies i += 1 next if enemy.hp <= 0 x = 0 y = i * 30 draw_slant_bar(x, y + 25, enemy.hp, enemy.maxhp, width = 100, height = 6, bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255)) draw_slant_bar(x, y + 30, enemy.sp, enemy.maxsp, width = 100, height = 6, bar_color = Color.new(150, 0, 150, 255), end_color = Color.new(0, 0, 255, 255)) draw_enemy_name(enemy, x, y) end end end
class Scene_Battle
alias nr_queed_main main alias queed_update update alias queed_update_phase5 update_phase5 alias queed_update_phase4_step1 update_phase4_step1 alias queed_update_phase4_step5 update_phase4_step5 alias queed_start_skill_select start_skill_select alias queed_end_skill_select end_skill_select alias queed_start_item_select start_item_select alias queed_end_item_select end_item_select
def main # Prepare troop @troop_id = $game_temp.battle_troop_id $game_troop.setup(@troop_id) # Make enemy window: @enemy_window = Window_EnemyHP.new @enemy_window.z = 250 # Call original main nr_queed_main # Dispose of windows @enemy_window.dispose end
def update @enemy_window.update queed_update end
def start_skill_select queed_start_skill_select @enemy_window.visible = false end
def end_skill_select queed_end_skill_select @enemy_window.visible = true end
def start_item_select queed_start_item_select @enemy_window.visible = false end
def end_item_select queed_end_item_select @enemy_window.visible = true end
def update_phase5 # If wait count is larger than 0 if @phase5_wait_count > 0 # Decrease wait count @phase5_wait_count -= 1 # If wait count reaches 0 if @phase5_wait_count == 0 @enemy_window.visible = false # Show result window @result_window.visible = true # Clear main phase flag $game_temp.battle_main_phase = false # Refresh status window @status_window.refresh @enemy_window.refresh end return end queed_update_phase5 end
def update_phase4_step1 queed_update_phase4_step1 @enemy_window.refresh end
def update_phase4_step5 # Hide help window @help_window.visible = false # Refresh status window @status_window.refresh @enemy_window.refresh queed_update_phase4_step5 end end
#============================================================================== # ** Window_BattleStatus #------------------------------------------------------------------------------ # Edited to display SephirothSpawn's slanted bars for the players #==============================================================================
class Window_BattleStatus < Window_Base #-------------------------------------------------------------------------- # * Alias Methods #-------------------------------------------------------------------------- alias nr_queed_refresh refresh #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- # alias nr_queed_refresh refresh def refresh(*args) # Call original refresh i = nr_queed_refresh(*args) $game_party.actors.each_with_index { |actor, i| draw_actor_hp(actor, i * 160 + 4, 32, 120) } return i end #-------------------------------------------------------------------------- # * Draw_Actor_HP #-------------------------------------------------------------------------- def draw_actor_hp(actor, x, y, width) draw_slant_bar(x, 55, actor.hp, actor.maxhp, width) super(actor, x, y, width) end #-------------------------------------------------------------------------- # * Draw_Actor_SP #-------------------------------------------------------------------------- def draw_actor_sp(actor, x, y, width) draw_slant_bar(x, 88, actor.sp, actor.maxsp, width, 6, bar_color = Color.new(150, 0, 150, 255), end_color = Color.new(0, 0, 255, 255)) super(actor, x, y, width) end end
If you want it to hide the spot where the window was as well, go to line 59:
CODE
i += 1
and put it down 1 line, so it reads;
CODE
next if enemy.hp <= 0 i += 1
To only show bars for the enemy (and not for the players), scroll down to the end of the code, and delete everything after (and including)
CODE
class Window_BattleStatus < Window_Base
on line 165.
__________________________
K.I.S.S. Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.
Group: Member
Posts: 39
Type: Event Designer
RM Skill: Advanced
When I have more then 2 enemies in battle it cuts off the third enemy hp bar. But thats fine bc i just want to get rid of the enemies HP bars all together, so how do I do that?
# Breath of Fire Enemy window # By Noobitron # Slanted Bars by Sephiroth Spawn.
class Window_Base #-------------------------------------------------------------------------- # * Draw Slant Bar(by SephirothSpawn) #-------------------------------------------------------------------------- def draw_slant_bar(x, y, min, max, width = 152, height = 6, bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255)) return if [max, width, height].include?(0) # Draw Border for i in 0..height self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255)) end # Draw Background for i in 1..(height - 1) r = 100 * (height - i) / height + 0 * i / height g = 100 * (height - i) / height + 0 * i / height b = 100 * (height - i) / height + 0 * i / height a = 255 * (height - i) / height + 255 * i / height self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a)) end # Draws Bar for i in 1..( (min / max.to_f) * width - 1) for j in 1..(height - 1) r = bar_color.red * (width - i) / width + end_color.red * i / width g = bar_color.green * (width - i) / width + end_color.green * i / width b = bar_color.blue * (width - i) / width + end_color.blue * i / width a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a)) end end end end
class Window_BattleStatus < Window_Base #-------------------------------------------------------------------------- # * Alias Methods #-------------------------------------------------------------------------- alias_method :nr_playerbar_refresh, :refresh unless $@ #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- # alias_method :nr_playerbar_refresh, :refresh unless $@ def refresh # Run the original refresh nr_playerbar_refresh # Draw in the HP & SP Bars. for i in 0...$game_party.actors.size actor = $game_party.actors[i] actor_x = i * 160 + 4 draw_slant_bar(actor_x, 55, actor.hp, actor.maxhp, 120) draw_slant_bar(actor_x, 88, actor.sp, actor.maxsp, 120, 6, Color.new(150, 0, 150, 255), Color.new(0, 0, 255, 255)) end end end
__________________________
K.I.S.S. Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.
Group: Member
Posts: 7
Type: None
RM Skill: Intermediate
hope it isnt too late but i have an error with this one and i cannot figure out why it is there. I tried it an older project i made just to test scripts and it worked perfectly in there, even with other adds ons like battle scripts. But this new project, even with no other scripts, i keep getting an error message saying ....
Script 'Enemy HP Window' Line 30: ArgumentError Occurred. bad value for range