Shaking when hit and/or a health bar that shows above the battlers

SWAMPFOOT9000

Veteran
Veteran
Joined
Jun 1, 2014
Messages
52
Reaction score
8
First Language
English
Primarily Uses
N/A
This request is pretty much exactly was it sounds like from the title. It seems that all of the health bar scripts that I have found, have the battlers on top of the health bar. Which, is annoying, because if the enemy battler happens to be big, it will just cover the whole health bar. I'm sure there's some way to change the Z of the health, however it probably involves messing with the main part of the scripts. Also, I've been wondering if there was a script that would make the battlers "shake" a bit, upon being hit. These both seem relatively simple, and I've seen both of these things done on rpgmaker vxace, so I asume that they must be in some way possible to pull of in xp. (However, I may be wrong, since I don't know THAT much about scripting...) Any help will be greatly appreciated!
 

Sky Usanin

deleted
Veteran
Joined
Jun 5, 2015
Messages
115
Reaction score
14
First Language
Unknown
Primarily Uses
N/A
Well, you can try using (EDIT: It's not YEA) V.M. of D.T.'s Enemy Health Bar Script and adjust it to the bottom of the enemy (I also recommend deactivating the percentage or any numbers that appear above/below the health bar). I don't remember where do you adjust it, but I'm going to look for it and Edit this post.

EDIT 2: Well, here it is:

#--# Basic Enemy HP Bars v 2.8## Adds customizable hp bars to enemies in battle. See configuration# below for more detail. Also allows for the option of using a nice# graphical hp bar from a image file.## Usage: Plug and play, customize as needed.##------##-- Script by: V.M of D.T##- Questions or comments can be:# posted on the thread for the script# given by email: sumptuaryspade@live.ca# provided on facebook: http://www.facebook.com/DaimoniousTailsGames# posed on site: daimonioustails.wordpress.com##--- Free to use in any project, commercial or non-commercial, with credit given# - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's) #Customization starts here:module DTP_HP #Whether to place the hp bar above or below the enemy ABOVE_MONSTER = false #Whether to use a custome image or not: #Image would be placed in Graphics/System and named Custom_HP.png CUSTOM_BAR = false #Whether to include the hp bar or not USE_HP_BAR = true #Whether to include an mp bar or not USE_MP_BAR = false #The width of the hp bar BAR_WIDTH = 66 #The height of the hp bar BAR_HEIGHT = 5 #The width of the border around the hp bar BORDER_WIDTH = 1 #The height of the border around the hp bar BORDER_HEIGHT = 1 #Offset the hp bar along the x-axis(left,right) BAR_OFFSET_X = 0 #Offset the hp bar along the y-axis(up,down) BAR_OFFSET_Y = 5 #Color for the back of the hp bar COLOR_BAR_BACK = Color.new(0,0,0,200) #First color for the hp bar gradient COLOR_BAR_1 = Color.new(255,0,0) #Second color for the hp bar gradient COLOR_BAR_2 = Color.new(200,100,100) #Outside border color COLOR_BORDER_1 = Color.new(0,0,0,185) #Inside border color COLOR_BORDER_2 = Color.new(255,255,255,185) #First color for the mp bar gradient MP_COLOR_BAR_1 = Color.new(0,175,255) #Second color fot he mp bar gradient MP_COLOR_BAR_2 = Color.new(0,0,255) #Whether to display text or not USE_TEXT = false #Text to be displayed, chp = current hp, mhp = max hp, php = percentage hp #Examples: "php%" or "chp/mhp" or "chp - php%" TEXT_DISPLAY = "chp" #Offset for the text along the x-axis(left,right) TEXT_OFFSET_X = 5 #Offset for the text along the y-axis(up,down) TEXT_OFFSET_Y = -24 #Size of the displayed text TEXT_SIZE = Font.default_size #Font of the displayed text TEXT_FONT = Font.default_name #Show bars only when specific actor in party. Array format. Example: [8,7] #Set to [] to not use actor only SPECIFIC_ACTOR = [] #Show enemy hp bar only if certain state is applied (like a scan state) #Set to 0 to not use state only SCAN_STATE = 0 #Enemies will show hp bar as long as they have been affected but scan state #at least once before SCAN_ONCE = false #Hp bars will only show when you are targetting a monster ONLY_ON_TARGET = false #Text to display if it's a boss monster, accepts same arguments BOSS_TEXT = "???" #The width of the boss hp bar BOSS_BAR_WIDTH = 66 #The height of the boss hp bar BOSS_BAR_HEIGHT = 5 #The width of the border around the boss hp bar BOSS_BORDER_WIDTH = 1 #The height of the border around the boss hp bar BOSS_BORDER_HEIGHT = 1 #ID's of boss monsters in array format. BOSS_MONSTERS = []end#Customization ends here class Sprite_Battler alias hpbar_update update alias hpbar_dispose dispose def update hpbar_update return unless @battler.is_a?(Game_Enemy) if @battler update_hp_bar end end def update_hp_bar boss = DTP_HP::BOSS_MONSTERS.include?(@battler.enemy_id) if @hp_bar.nil? @hp_bar = Sprite_Base.new(self.viewport) if !boss width = DTP_HP::BAR_WIDTH + DTP_HP::BORDER_WIDTH * 4 height = DTP_HP::BAR_HEIGHT + DTP_HP::BORDER_HEIGHT * 4 else width = DTP_HP::BOSS_BAR_WIDTH + DTP_HP::BOSS_BORDER_WIDTH * 4 height = DTP_HP::BOSS_BAR_HEIGHT + DTP_HP::BOSS_BORDER_HEIGHT * 4 end @hp_bar.bitmap = Bitmap.new(width,height) @hp_bar.x = self.x - @hp_bar.width / 2 + DTP_HP::BAR_OFFSET_X @hp_bar.y = self.y + DTP_HP::BAR_OFFSET_Y - self.bitmap.height - @hp_bar.height @hp_bar.y = self.y + DTP_HP::BAR_OFFSET_Y unless DTP_HP::ABOVE_MONSTER @hp_bar.x = 0 if @hp_bar.x < 0 @hp_bar.y = 0 if @hp_bar.y < 0 @hp_bar.z = 98 if DTP_HP::USE_MP_BAR @mp_bar = Sprite_Base.new(self.viewport) @mp_bar.bitmap = Bitmap.new(@hp_bar.width,@hp_bar.height) @mp_bar.x = @hp_bar.x + 6 @mp_bar.y = @hp_bar.y + @mp_bar.height - 3 @mp_bar.z = 97 end end if @text_display.nil? @text_display = Sprite_Base.new(self.viewport) @text_display.bitmap = Bitmap.new(100,DTP_HP::TEXT_SIZE) @text_display.bitmap.font.size = DTP_HP::TEXT_SIZE @text_display.bitmap.font.name = DTP_HP::TEXT_FONT @text_display.x = @hp_bar.x + DTP_HP::TEXT_OFFSET_X @text_display.y = @hp_bar.y + DTP_HP::TEXT_OFFSET_Y @text_display.z = 99 end determine_visible return unless @hp_bar.visible if @hp_bar.opacity != self.opacity @hp_bar.opacity = self.opacity @mp_bar.opacity = @hp_bar.opacity if DTP_HP::USE_MP_BAR end @hp_bar.bitmap.clear if !boss width = DTP_HP::BAR_WIDTH height = DTP_HP::BAR_HEIGHT bwidth = DTP_HP::BORDER_WIDTH bheight = DTP_HP::BORDER_HEIGHT else width = DTP_HP::BOSS_BAR_WIDTH height = DTP_HP::BOSS_BAR_HEIGHT bwidth = DTP_HP::BOSS_BORDER_WIDTH bheight = DTP_HP::BOSS_BORDER_HEIGHT end btotal = (bwidth + bheight) * 2 rwidth = @hp_bar.bitmap.width rheight = @hp_bar.bitmap.height if !DTP_HP::CUSTOM_BAR && DTP_HP::USE_HP_BAR @hp_bar.bitmap.fill_rect(0,0,rwidth,rheight,DTP_HP::COLOR_BAR_BACK) @hp_bar.bitmap.fill_rect(bwidth,bheight,rwidth-bwidth*2,rheight-bheight*2,DTP_HP::COLOR_BORDER_2) @hp_bar.bitmap.fill_rect(bwidth*2,bheight*2,width,height,DTP_HP::COLOR_BORDER_1) end hp_width = @battler.hp_rate * width if DTP_HP::USE_HP_BAR @hp_bar.bitmap.gradient_fill_rect(bwidth*2,bheight*2,hp_width,height,DTP_HP::COLOR_BAR_1,DTP_HP::COLOR_BAR_2) end if DTP_HP::CUSTOM_BAR && DTP_HP::USE_HP_BAR border_bitmap = Bitmap.new("Graphics/System/Custom_HP.png") rect = Rect.new(0,0,border_bitmap.width,border_bitmap.height) @hp_bar.bitmap.blt(0,0,border_bitmap,rect) end if DTP_HP::USE_MP_BAR @mp_bar.bitmap.clear if !DTP_HP::CUSTOM_BAR @mp_bar.bitmap.fill_rect(0,0,rwidth,rheight,DTP_HP::COLOR_BAR_BACK) @mp_bar.bitmap.fill_rect(bwidth,bheight,rwidth-bwidth*2,rheight-bheight*2,DTP_HP::COLOR_BORDER_2) @mp_bar.bitmap.fill_rect(bwidth*2,bheight*2,width,height,DTP_HP::COLOR_BORDER_1) end mp_width = @battler.mp_rate * width @mp_bar.bitmap.gradient_fill_rect(bwidth*2,bheight*2,mp_width,height,DTP_HP::MP_COLOR_BAR_1,DTP_HP::MP_COLOR_BAR_2) if DTP_HP::CUSTOM_BAR border_bitmap = Bitmap.new("Graphics/System/Custom_HP.png") rect = Rect.new(0,0,border_bitmap.width,border_bitmap.height) @mp_bar.bitmap.blt(0,0,border_bitmap,rect) end end return unless DTP_HP::USE_TEXT @text_display.opacity = @hp_bar.opacity if @text_display.opacity != @hp_bar.opacity @text_display.bitmap.clear text = DTP_HP::TEXT_DISPLAY.clone text = DTP_HP::BOSS_TEXT.clone if DTP_HP::BOSS_MONSTERS.include?(@battler.enemy_id) text.gsub!(/chp/) {@battler.hp} text.gsub!(/mhp/) {@battler.mhp} text.gsub!(/php/) {(@battler.hp_rate * 100).to_i} @text_display.bitmap.draw_text(0,0,100,@text_display.height,text) end def determine_visible if !@battler.alive? @hp_bar.visible = false @mp_bar.visible = false if @mp_bar @text_display.visible = false return if !@battler.alive? end @hp_bar.visible = true if DTP_HP::SCAN_STATE != 0 @hp_bar.visible = false @hp_bar.visible = true if @battler.state?(DTP_HP::SCAN_STATE) if DTP_HP::SCAN_ONCE @hp_bar.visible = true if $game_party.monster_scans[@battler.enemy_id] == true $game_party.monster_scans[@battler.enemy_id] = true if @hp_bar.visible end end if !DTP_HP::SPECIFIC_ACTOR.empty? @hp_bar.visible = false unless DTP_HP::SCAN_STATE != 0 DTP_HP::SPECIFIC_ACTOR.each do |i| next unless $game_party.battle_members.include?($game_actors) @hp_bar.visible = true end end if DTP_HP::oNLY_ON_TARGET return unless SceneManager.scene.is_a?(Scene_Battle) return unless SceneManager.scene.enemy_window @hp_bar.visible = SceneManager.scene.target_window_index == @battler.index @hp_bar.visible = false if !SceneManager.scene.enemy_window.active end @text_display.visible = false if !@hp_bar.visible @text_display.visible = true if @hp_bar.visible @mp_bar.visible = @hp_bar.visible if DTP_HP::USE_MP_BAR end def dispose @hp_bar.dispose if @hp_bar @mp_bar.dispose if @mp_bar @text_display.dispose if @text_display hpbar_dispose endend class Scene_Battle attr_reader :enemy_window def target_window_index begin @enemy_window.enemy.index rescue return -1 end endend class Game_Party alias hp_bar_init initialize attr_accessor :monster_scans def initialize hp_bar_init @monster_scans = [] endend
You may have noticed that, but the Adjustments for all this are on the very beginning of the Script.
 
Last edited by a moderator:

SWAMPFOOT9000

Veteran
Veteran
Joined
Jun 1, 2014
Messages
52
Reaction score
8
First Language
English
Primarily Uses
N/A
Well, you can try using (EDIT: It's not YEA) V.M. of D.T.'s Enemy Health Bar Script and adjust it to the bottom of the enemy (I also recommend deactivating the percentage or any numbers that appear above/below the health bar). I don't remember where do you adjust it, but I'm going to look for it and Edit this post.

EDIT 2: Well, here it is:

#--# Basic Enemy HP Bars v 2.8## Adds customizable hp bars to enemies in battle. See configuration# below for more detail. Also allows for the option of using a nice# graphical hp bar from a image file.## Usage: Plug and play, customize as needed.##------##-- Script by: V.M of D.T##- Questions or comments can be:# posted on the thread for the script# given by email: sumptuaryspade@live.ca# provided on facebook: http://www.facebook.com/DaimoniousTailsGames# posed on site: daimonioustails.wordpress.com##--- Free to use in any project, commercial or non-commercial, with credit given# - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's) #Customization starts here:module DTP_HP #Whether to place the hp bar above or below the enemy ABOVE_MONSTER = false #Whether to use a custome image or not: #Image would be placed in Graphics/System and named Custom_HP.png CUSTOM_BAR = false #Whether to include the hp bar or not USE_HP_BAR = true #Whether to include an mp bar or not USE_MP_BAR = false #The width of the hp bar BAR_WIDTH = 66 #The height of the hp bar BAR_HEIGHT = 5 #The width of the border around the hp bar BORDER_WIDTH = 1 #The height of the border around the hp bar BORDER_HEIGHT = 1 #Offset the hp bar along the x-axis(left,right) BAR_OFFSET_X = 0 #Offset the hp bar along the y-axis(up,down) BAR_OFFSET_Y = 5 #Color for the back of the hp bar COLOR_BAR_BACK = Color.new(0,0,0,200) #First color for the hp bar gradient COLOR_BAR_1 = Color.new(255,0,0) #Second color for the hp bar gradient COLOR_BAR_2 = Color.new(200,100,100) #Outside border color COLOR_BORDER_1 = Color.new(0,0,0,185) #Inside border color COLOR_BORDER_2 = Color.new(255,255,255,185) #First color for the mp bar gradient MP_COLOR_BAR_1 = Color.new(0,175,255) #Second color fot he mp bar gradient MP_COLOR_BAR_2 = Color.new(0,0,255) #Whether to display text or not USE_TEXT = false #Text to be displayed, chp = current hp, mhp = max hp, php = percentage hp #Examples: "php%" or "chp/mhp" or "chp - php%" TEXT_DISPLAY = "chp" #Offset for the text along the x-axis(left,right) TEXT_OFFSET_X = 5 #Offset for the text along the y-axis(up,down) TEXT_OFFSET_Y = -24 #Size of the displayed text TEXT_SIZE = Font.default_size #Font of the displayed text TEXT_FONT = Font.default_name #Show bars only when specific actor in party. Array format. Example: [8,7] #Set to [] to not use actor only SPECIFIC_ACTOR = [] #Show enemy hp bar only if certain state is applied (like a scan state) #Set to 0 to not use state only SCAN_STATE = 0 #Enemies will show hp bar as long as they have been affected but scan state #at least once before SCAN_ONCE = false #Hp bars will only show when you are targetting a monster ONLY_ON_TARGET = false #Text to display if it's a boss monster, accepts same arguments BOSS_TEXT = "???" #The width of the boss hp bar BOSS_BAR_WIDTH = 66 #The height of the boss hp bar BOSS_BAR_HEIGHT = 5 #The width of the border around the boss hp bar BOSS_BORDER_WIDTH = 1 #The height of the border around the boss hp bar BOSS_BORDER_HEIGHT = 1 #ID's of boss monsters in array format. BOSS_MONSTERS = []end#Customization ends here class Sprite_Battler alias hpbar_update update alias hpbar_dispose dispose def update hpbar_update return unless @battler.is_a?(Game_Enemy) if @battler update_hp_bar end end def update_hp_bar boss = DTP_HP::BOSS_MONSTERS.include?(@battler.enemy_id) if @hp_bar.nil? @hp_bar = Sprite_Base.new(self.viewport) if !boss width = DTP_HP::BAR_WIDTH + DTP_HP::BORDER_WIDTH * 4 height = DTP_HP::BAR_HEIGHT + DTP_HP::BORDER_HEIGHT * 4 else width = DTP_HP::BOSS_BAR_WIDTH + DTP_HP::BOSS_BORDER_WIDTH * 4 height = DTP_HP::BOSS_BAR_HEIGHT + DTP_HP::BOSS_BORDER_HEIGHT * 4 end @hp_bar.bitmap = Bitmap.new(width,height) @hp_bar.x = self.x - @hp_bar.width / 2 + DTP_HP::BAR_OFFSET_X @hp_bar.y = self.y + DTP_HP::BAR_OFFSET_Y - self.bitmap.height - @hp_bar.height @hp_bar.y = self.y + DTP_HP::BAR_OFFSET_Y unless DTP_HP::ABOVE_MONSTER @hp_bar.x = 0 if @hp_bar.x < 0 @hp_bar.y = 0 if @hp_bar.y < 0 @hp_bar.z = 98 if DTP_HP::USE_MP_BAR @mp_bar = Sprite_Base.new(self.viewport) @mp_bar.bitmap = Bitmap.new(@hp_bar.width,@hp_bar.height) @mp_bar.x = @hp_bar.x + 6 @mp_bar.y = @hp_bar.y + @mp_bar.height - 3 @mp_bar.z = 97 end end if @text_display.nil? @text_display = Sprite_Base.new(self.viewport) @text_display.bitmap = Bitmap.new(100,DTP_HP::TEXT_SIZE) @text_display.bitmap.font.size = DTP_HP::TEXT_SIZE @text_display.bitmap.font.name = DTP_HP::TEXT_FONT @text_display.x = @hp_bar.x + DTP_HP::TEXT_OFFSET_X @text_display.y = @hp_bar.y + DTP_HP::TEXT_OFFSET_Y @text_display.z = 99 end determine_visible return unless @hp_bar.visible if @hp_bar.opacity != self.opacity @hp_bar.opacity = self.opacity @mp_bar.opacity = @hp_bar.opacity if DTP_HP::USE_MP_BAR end @hp_bar.bitmap.clear if !boss width = DTP_HP::BAR_WIDTH height = DTP_HP::BAR_HEIGHT bwidth = DTP_HP::BORDER_WIDTH bheight = DTP_HP::BORDER_HEIGHT else width = DTP_HP::BOSS_BAR_WIDTH height = DTP_HP::BOSS_BAR_HEIGHT bwidth = DTP_HP::BOSS_BORDER_WIDTH bheight = DTP_HP::BOSS_BORDER_HEIGHT end btotal = (bwidth + bheight) * 2 rwidth = @hp_bar.bitmap.width rheight = @hp_bar.bitmap.height if !DTP_HP::CUSTOM_BAR && DTP_HP::USE_HP_BAR @hp_bar.bitmap.fill_rect(0,0,rwidth,rheight,DTP_HP::COLOR_BAR_BACK) @hp_bar.bitmap.fill_rect(bwidth,bheight,rwidth-bwidth*2,rheight-bheight*2,DTP_HP::COLOR_BORDER_2) @hp_bar.bitmap.fill_rect(bwidth*2,bheight*2,width,height,DTP_HP::COLOR_BORDER_1) end hp_width = @battler.hp_rate * width if DTP_HP::USE_HP_BAR @hp_bar.bitmap.gradient_fill_rect(bwidth*2,bheight*2,hp_width,height,DTP_HP::COLOR_BAR_1,DTP_HP::COLOR_BAR_2) end if DTP_HP::CUSTOM_BAR && DTP_HP::USE_HP_BAR border_bitmap = Bitmap.new("Graphics/System/Custom_HP.png") rect = Rect.new(0,0,border_bitmap.width,border_bitmap.height) @hp_bar.bitmap.blt(0,0,border_bitmap,rect) end if DTP_HP::USE_MP_BAR @mp_bar.bitmap.clear if !DTP_HP::CUSTOM_BAR @mp_bar.bitmap.fill_rect(0,0,rwidth,rheight,DTP_HP::COLOR_BAR_BACK) @mp_bar.bitmap.fill_rect(bwidth,bheight,rwidth-bwidth*2,rheight-bheight*2,DTP_HP::COLOR_BORDER_2) @mp_bar.bitmap.fill_rect(bwidth*2,bheight*2,width,height,DTP_HP::COLOR_BORDER_1) end mp_width = @battler.mp_rate * width @mp_bar.bitmap.gradient_fill_rect(bwidth*2,bheight*2,mp_width,height,DTP_HP::MP_COLOR_BAR_1,DTP_HP::MP_COLOR_BAR_2) if DTP_HP::CUSTOM_BAR border_bitmap = Bitmap.new("Graphics/System/Custom_HP.png") rect = Rect.new(0,0,border_bitmap.width,border_bitmap.height) @mp_bar.bitmap.blt(0,0,border_bitmap,rect) end end return unless DTP_HP::USE_TEXT @text_display.opacity = @hp_bar.opacity if @text_display.opacity != @hp_bar.opacity @text_display.bitmap.clear text = DTP_HP::TEXT_DISPLAY.clone text = DTP_HP::BOSS_TEXT.clone if DTP_HP::BOSS_MONSTERS.include?(@battler.enemy_id) text.gsub!(/chp/) {@battler.hp} text.gsub!(/mhp/) {@battler.mhp} text.gsub!(/php/) {(@battler.hp_rate * 100).to_i} @text_display.bitmap.draw_text(0,0,100,@text_display.height,text) end def determine_visible if !@battler.alive? @hp_bar.visible = false @mp_bar.visible = false if @mp_bar @text_display.visible = false return if !@battler.alive? end @hp_bar.visible = true if DTP_HP::SCAN_STATE != 0 @hp_bar.visible = false @hp_bar.visible = true if @battler.state?(DTP_HP::SCAN_STATE) if DTP_HP::SCAN_ONCE @hp_bar.visible = true if $game_party.monster_scans[@battler.enemy_id] == true $game_party.monster_scans[@battler.enemy_id] = true if @hp_bar.visible end end if !DTP_HP::SPECIFIC_ACTOR.empty? @hp_bar.visible = false unless DTP_HP::SCAN_STATE != 0 DTP_HP::SPECIFIC_ACTOR.each do |i| next unless $game_party.battle_members.include?($game_actors) @hp_bar.visible = true end end if DTP_HP::oNLY_ON_TARGET return unless SceneManager.scene.is_a?(Scene_Battle) return unless SceneManager.scene.enemy_window @hp_bar.visible = SceneManager.scene.target_window_index == @battler.index @hp_bar.visible = false if !SceneManager.scene.enemy_window.active end @text_display.visible = false if !@hp_bar.visible @text_display.visible = true if @hp_bar.visible @mp_bar.visible = @hp_bar.visible if DTP_HP::USE_MP_BAR end def dispose @hp_bar.dispose if @hp_bar @mp_bar.dispose if @mp_bar @text_display.dispose if @text_display hpbar_dispose endend class Scene_Battle attr_reader :enemy_window def target_window_index begin @enemy_window.enemy.index rescue return -1 end endend class Game_Party alias hp_bar_init initialize attr_accessor :monster_scans def initialize hp_bar_init @monster_scans = [] endend


You may have noticed that, but the Adjustments for all this are on the very beginning of the Script.

I plugged the script in, and it gave me an error. Are you sure that this an rpgmaker XP script?
 

MobiusXVI

Game Maker
Veteran
Joined
Mar 20, 2013
Messages
383
Reaction score
91
First Language
English
Primarily Uses
Post a link to the HP Bar script you're using (or want to use) and I can try changing the z-display for you. 
 

SWAMPFOOT9000

Veteran
Veteran
Joined
Jun 1, 2014
Messages
52
Reaction score
8
First Language
English
Primarily Uses
N/A
Post a link to the HP Bar script you're using (or want to use) and I can try changing the z-display for you. 
OK, here it is ^_^! (Sorry for the long wait time BTW...)

#==============================================================================#

# ** Enemy HP and SP bars Addon v1.0 **                                             #

#==============================================================================#

# Author: Diagostimo                                                           #

#------------------------------------------------------------------------------#

# Description:                                                                 #

#                                                                              #

#   this script adds HP and SP bars below enemies while in battle, this        #

#   enables you to see the current state of the enemy.                         #

#   this script will most likely be compatible with most custom battle         #

#   systems that use Sprite_battler to display the battler, note that the      #

#   size of the bars have been designed with the default system in mind.       #

#                                                                              #

#==============================================================================#

#==============================================================================

# ** Sprite_Battler

#==============================================================================

class Sprite_Battler < RPG::Sprite

  #----------------------------------------------------------------------------

  # * Object Initialization

  #----------------------------------------------------------------------------

  alias init_battle_bars initialize

  def initialize(viewport, battler = nil)

    init_battle_bars(viewport, battler)

    if @battler.is_a?(Game_Enemy)

      @bars_sprite = RPG::Sprite.new

      @bars_sprite.x = @battler.screen_x - 26

      @bars_sprite.y = @battler.screen_y + 7

      @bars_sprite.z = 50

      @bars_sprite.bitmap = Bitmap.new(54, 15)

      @bars_sprite.opacity = 0

    end

  end

  #----------------------------------------------------------------------------

  # Frame Update

  #----------------------------------------------------------------------------

  alias update_battle_bars update

  def update

    update_battle_bars

    if @battler.is_a?(Game_Enemy)

      update_bars

    end

  end

  #----------------------------------------------------------------------------

  # * Frame update of bars

  #----------------------------------------------------------------------------

  def update_bars

    @bars_sprite.opacity = self.opacity

    if @bars_sprite.opacity > 0

      @bars_sprite.bitmap.clear

      #shell

      rect = Rect.new(0, 0, 54, 15)

      @bars_sprite.bitmap.fill_rect(rect, Color.new(0, 0, 0))

      rect = Rect.new(1, 1, 52, 6)

      @bars_sprite.bitmap.fill_rect(rect, Color.new(255, 255, 255))

      rect = Rect.new(1, 8, 52, 6)

      @bars_sprite.bitmap.fill_rect(rect, Color.new(255, 255, 255))

      #draw hp

      width = 50 * @battler.hp / @battler.maxhp

      rect = Rect.new(2, 2, width, 4)

      @bars_sprite.bitmap.fill_rect(rect, Color.new(255, 0, 0))

      #draw sp

      width = 50 * @battler.sp / @battler.maxsp

      rect = Rect.new(2, 9, width, 4)

      @bars_sprite.bitmap.fill_rect(rect, Color.new(0, 0, 255))

    end

  end

  #----------------------------------------------------------------------------

  # * Collapse

  #----------------------------------------------------------------------------

  def collapse

    super

    if @battler.is_a?(Game_Enemy)

      @bars_sprite.collapse

    end

  end

  #----------------------------------------------------------------------------

  # * Dispose

  #----------------------------------------------------------------------------

  def dispose

    super

    if @battler.is_a?(Game_Enemy)

      @bars_sprite.dispose

    end

  end

end
 
Last edited by a moderator:

SWAMPFOOT9000

Veteran
Veteran
Joined
Jun 1, 2014
Messages
52
Reaction score
8
First Language
English
Primarily Uses
N/A
Actually, nevermind.... -_- it turns out it wasn't even the z doing it at all, sorry! :D Still, now does anyone know how to make the battlers shake?
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,070
Members
137,577
Latest member
SadaSoda
Top