Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Picture

Can someone please make a script so if a actor's HP is  less then 100% and more than 75% then it shows a picture? I don't think it would be very hard, I need several different scripts like this but once i see this one, i will be able to figure out how to allign it and make more.


Thanks
 
Psssst...Try common events...parallel process...

Conditional Branch [HP < 100%]
  Conditional Branch [HP > 75%]
    Display Picture [picture]
  else
    Erase Picture
else
  Erase Picture

If you want a script, give more detail (picture ID, placement, etc.).
 
no it wont work, i need it to replace the draw_actor_hp in window battlestatus the picture is in the graphics/pictures folder and it is named Green 1.png  if actor hp is 100% if actor hp is less than 100% but mroe then 75% i want it to be Green 2.png... If an actors hp is 25 to 50% i want the picture to be Yellow 1.png if 10-25% i want the picture to be Yellow 2.png and if it is less than 10% i want it to be Red 1.png and if the actor is dead, I want the picture to be Dead.png... This should take the place of or, be above the draw_actor_hp in window battle status, once i see the script on how to do this I will be abel to learn and edit it...


Thanks again
 
Do you mind posting one or two of the images? The reason I ask is, if they are simple shapes, you can do this with Rectangles right in script, and you won't need the extra images.

Hey Reg!  I assumed he was looking for some sort of HP Bar.
 
Yeah...detail always helps.  Since one can do so much with script, the scripter must know exactly what he/she is supposed to be doing or you may end up with unanticipated results.  Alternatively, most people will not work on a vague topic because the person does not know what to do.  Just some advice for future requests, be as detailed as possible.  It may take you a bit longer to type out the entire thing, but I guarantee that you will get the desired results much faster than something like this:

"Umm..hi, I want a HUD that shows hp and stuff   thanks"

"Ok, could you give some more detail?"

"Yeah...uh...make it show sp too with bars plz..."

"That really did not help.  You should read this: [link]How to make a good Request[/link]"

"ok...I want it to be blue..."

Despain: "Locked.  Try reading [some other thing about good requests]"

~starts all over again~

Now, obviously, that was an extreme example, and your post is nowhere near that bad.  Sadly, though, I've seen that happen too many times, and you can see how long this will drag out.  My point is, include all of the info you can in your first post (color, placement, shape, actors, what's displayed, etc.).  jcsnider, this isn't only directed at you, rather, I'm aiming this at anyone who happens to be reading it.  Just some helpful advice for future posting!  Good luck!  :wink:
 
Okay let me try to make this more detailed I can try to put this as a script for.

If actor_hp = 100%

Then

Show this picture at
x= 64
y= 64  (I will change these later)

This is Green 1.png

http://img225.imageshack.us/img225/2733/green1yf4.png[/img]

the zoom is 100 the blend type is normal, it is also not transparent.

Then if the actor's HP falls below 100% but above 80% then show this picture at the same spot and same attributes... Green 2.png

http://img225.imageshack.us/img225/1013/green2bi1.png[/img]



Then once it hits 65 - 80 % show this one... Yellow 1.png
http://img225.imageshack.us/img225/7885/yellow1ul8.png[/img]



Then this one if it fals between 35-65%... Yellow 2.png
http://img149.imageshack.us/img149/9885/yellow2fg3.png[/img]



Then between 10-35%... Red 1.png
http://img149.imageshack.us/img149/5456/red1yt6.png[/img]


Once the actor is almost dead from 1-10% show this one... Red 2.png

http://img225.imageshack.us/img225/1647/red2io6.png[/img]


Then once the actor is dead, so this one... Dead.png
http://img135.imageshack.us/img135/6720/deadha4.png[/img]




Hopefully this clears it up some, I have never really been good at explaining.

Thanks
 
A picture speaks a thousand words!

You can create (and update) that whole image in a bitmap in the script with .rect & .set_pixel commands. Then you won't need to create pictures.

Lord, try using a 'Sprite' to hold the bitmap, initialize them at the start of battle, then update them from the Battle_Status section that updates the HP.  (just a suggestion of where I'd start looking....)

Be Well
 
Try this out. Paste in a new script above 'main'

Code:
#==============================================================================
# ** Sprite_HPbar
#------------------------------------------------------------------------------
#  This sprite is used to display the battler.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Hpbar < Sprite
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :battler                  # battler
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     viewport : viewport
  #     battler  : battler (Game_Battler)
  #--------------------------------------------------------------------------
  def initialize(viewport, battler = nil)
    super(viewport)
    @battler = battler
    # Set sprite coordinates
    self.x = @battler.screen_x - 40
    self.y = 64
    self.z = @battler.screen_z
    self.bitmap = Bitmap.new(80, 24)
    gray1 = Color.new(50, 50, 50)
    gray2 = Color.new(64, 64, 64)
    gray3 = Color.new(80, 80, 80)
    gray4 = Color.new(100, 100, 100)
    self.bitmap.fill_rect(2,0,76,24,gray1)
    self.bitmap.fill_rect(0,2,80,20,gray1)
    self.bitmap.fill_rect(2,2,76,20,gray2)
    self.bitmap.fill_rect(4,4,72,16,gray3)
    self.bitmap.fill_rect(8,8,64,8,gray4)
    self.bitmap.fill_rect(8,10,64,4,gray1)
    self.bitmap.fill_rect(10,8,60,8,gray1)
    @old_hp = @battler.hp
    refresh
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    if self.bitmap != nil
      self.bitmap.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    green1 = Color.new(128, 200, 48)
    green2 = Color.new(56, 136, 0)
    yellow1 = Color.new(248, 224, 56)
    yellow2 = Color.new(200, 168, 8)
    red1 = Color.new(248, 104, 72)
    red2 = Color.new(192, 56, 56)
    gray = Color.new(136, 136, 144)
    self.bitmap.fill_rect(10, 10, 60, 4, gray)
    # check battlers HP
    width = @battler.hp * 60 / @battler.maxhp
    # Draw the HP Bar
    if width > 40
      self.bitmap.fill_rect(10, 10, width, 2, green1)
      self.bitmap.fill_rect(10, 12, width, 2, green2)
      return
    end
    if width > 20
      self.bitmap.fill_rect(10, 10, width, 2, yellow1)
      self.bitmap.fill_rect(10, 12, width, 2, yellow2)
      return
    end
    self.bitmap.fill_rect(10, 10, width, 2, red1)
    self.bitmap.fill_rect(10, 12, width, 2, red2)
    return
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # If battler is nil
    if @battler == nil
      self.bitmap = nil
      return
    end
    if @old_hp != @battler.hp
      refresh
    end
    @old_hp = @battler_hp
  end
end

#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within
#  the Scene_Battle class.
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :viewport1                # enemy viewport
  attr_reader   :viewport2                # actor viewport
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Make viewports
    @viewport1 = Viewport.new(0, 0, 640, 320)
    @viewport2 = Viewport.new(0, 0, 640, 480)
    @viewport3 = Viewport.new(0, 0, 640, 480)
    @viewport4 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 101
    @viewport3.z = 200
    @viewport4.z = 5000
    # Make battleback sprite
    @battleback_sprite = Sprite.new(@viewport1)
    # Make enemy sprites
    @enemy_sprites = []
    for enemy in $game_troop.enemies.reverse
      @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
    end
    # Make actor sprites
    @actor_sprites = []
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    # Make HP bar sprites
    @hpbar_sprites = []
    for actor in $game_party.actors
      @hpbar_sprites.push(Sprite_Hpbar.new(@viewport1, actor))
    end
    # Make weather
    @weather = RPG::Weather.new(@viewport1)
    # Make picture sprites
    @picture_sprites = []
    for i in 51..100
      @picture_sprites.push(Sprite_Picture.new(@viewport3,
        $game_screen.pictures[i]))
    end
    # Make timer sprite
    @timer_sprite = Sprite_Timer.new
    # Frame update
    update
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    # If battleback bit map exists, dispose of it
    if @battleback_sprite.bitmap != nil
      @battleback_sprite.bitmap.dispose
    end
    # Dispose of battleback sprite
    @battleback_sprite.dispose
    # Dispose of enemy sprites and actor sprites
    for sprite in @enemy_sprites + @actor_sprites
      sprite.dispose
    end
    # Dispose of weather
    @weather.dispose
    # Dispose of picture sprites
    for sprite in @picture_sprites
      sprite.dispose
    end
    # Dispose of timer sprite
    @timer_sprite.dispose
    # Dispose of viewports
    @viewport1.dispose
    @viewport2.dispose
    @viewport3.dispose
    @viewport4.dispose
  end
  #--------------------------------------------------------------------------
  # * Determine if Effects are Displayed
  #--------------------------------------------------------------------------
  def effect?
    # Return true if even 1 effect is being displayed
    for sprite in @enemy_sprites + @actor_sprites
      return true if sprite.effect?
    end
    return false
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update actor sprite contents (corresponds with actor switching)
    @actor_sprites[0].battler = $game_party.actors[0]
    @actor_sprites[1].battler = $game_party.actors[1]
    @actor_sprites[2].battler = $game_party.actors[2]
    @actor_sprites[3].battler = $game_party.actors[3]
    # Update the hpbar sprites
    i = 0
    for actor in $game_party.actors
      @hpbar_sprites[i].battler = actor
      @hpbar_sprites[i].update
      i += 1
    end
    # If battleback file name is different from current one
    if @battleback_name != $game_temp.battleback_name
      @battleback_name = $game_temp.battleback_name
      if @battleback_sprite.bitmap != nil
        @battleback_sprite.bitmap.dispose
      end
      @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
      @battleback_sprite.src_rect.set(0, 0, 640, 320)
    end
    # Update battler sprites
    for sprite in @enemy_sprites + @actor_sprites
      sprite.update
    end
    # Update weather graphic
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.update
    # Update picture sprites
    for sprite in @picture_sprites
      sprite.update
    end
    # Update timer sprite
    @timer_sprite.update
    # Set screen color tone and shake position
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    # Set screen flash color
    @viewport4.color = $game_screen.flash_color
    # Update viewports
    @viewport1.update
    @viewport2.update
    @viewport4.update
  end
end

Be Well

Ref: Junk2
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top