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.

Extra (Shield) HP Counter

VCA

Member

I be wondering if there's a script that give you an extra HP Counter. For example say you have only one HP counter, you use an item called oh lets say "Life Barrier". What this does it give you an extra HP Counter. I don't know if this pic will help. (Note! This is an image example. I don't own the script.)

EXHP.png


If anyone can help me, I will appreciate it. Oh! one thing, if possible can this extra HP Counter have it own recovery item say for example the item is called "Shield Recovery" it recover only your extra HP Counter. Thanks.
 
Some questions... once you get that extra HP gauge on screen, you should deplete it before you actually get hurt by the enemy? Or is this HP gauge / counter a counter for, let's say, physical or magical attacks only?
 
Code:
# Life Barrier System By SephirothSpawn

module LifeBarrier

  Initial_Actor_StartValue = Hash.new(0)

  Initial_Actor_MaxValue = Hash.new(0)

  Initial_Enemy_StartValue = Hash.new(0)

  Initial_Enemy_MaxValue = Hash.new(0)

  class LifeBarrier

    attr_accessor :value

    attr_accessor :max

    def init_actor(id)

      @value = Initial_Actor_StartValue[id]

      @max = Initial_Actor_MaxValue[id]

    end

    def init_enemy(id)

      @value = Initial_Enemy_StartValue[id]

      @max = Initial_Enemy_MaxValue[id]

    end

  end

end

 

class Game_Battler

  attr_reader :lifebarrier

  alias_method :seph_lifebarrier_init, :initialize

  def initialize

    @lifebarrier = LifeBarrier::LifeBarrier.new

    seph_lifebarrier_init

  end

  alias_method :seph_lifebarrier_hp=, :hp=

  def hp=(n)

    if @lifebarrier.value > 0

      if n > @lifebarrier.value

        n -= @lifebarrier.value

        @lifebarrier.value = 0

      else

        @lifebarrier.value -= n

        n = 0

      end

    end

    self.seph_lifebarrier_hp=(n)

  end

  alias_method :seph_lifebarrier_ra, :recover_all

  def recover_all

    seph_lifebarrier_ra

    @lifebarrier.value = @lifebarrier.max

  end

end

    

class Game_Actor

  alias_method :seph_lifebarrier_setup, :setup

  def setup(actor_id)

    @lifebarrier.init_actor(actor_id)

    seph_lifebarrier_setup(actor_id)

  end

end

 

class Game_Enemy

  alias_method :seph_lifebarrier_enmy_init, :initialize

  def initialize(*args)

    seph_lifebarrier_enmy_init

    @lifebarrier.init_enemy(@enemy_id)

  end

end

I haven't tested this (just did it in fast reply), but it should work.

Setup:
* Setting up actors start life barrier
- Below this line
Initial_Actor_StartValue = Hash.new(0)
Add
Initial_Actor_StartValue[actor_id] = n

* Setting up actors max life barrier
- Below this line
Initial_Actor_MaxValue = Hash.new(0)
Add
Initial_Actor_MaxValue[actor_id] = n

* Same for enemies for setup

Syntax
* Changing current life barrier value
$game_actors[actor_id].lifebarrier.value <operator> n

* Changing max life barrier value
$game_actors[actor_id].lifebarrier.max <operator> n


As is in the script, life barrier recovers to max value when the recover_all method is called.


Let me know if it doesn't work.
 

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