Injury system, non-recoverable HP gauge

Alyon93

Veteran
Veteran
Joined
May 19, 2015
Messages
62
Reaction score
2
First Language
Italian
Primarily Uses
N/A
Hi guys and girls,

I'd like to add this feature to my game that I hope it's not to difficult.

I've searched through the board and the msl and I've found anorher injury system but that's not what I wanted.

I've added this injury system in my game in which after being hit, a state might be inflicted which reduces the character's maxHP.

The default rmvxa output would be the hp gauge actually reduced of a certain percentage but the amount of damage inflicted will be overwrite.

But I'd like to keep the damage while reducing the maximum.

For example:

if a character has 100 hp and has being hit for a 15 hp of damage(85/100) and now has an injure "burn"(there are different injuries) which reduces maxHP by 25%.

The default output would be: 75/75

What I want is: 60/75 (the maxHP have been reduced but the damage inflicted hasn't disappeared.)

Also this applies to slip damage:

I like the default calculate which reduces HP every turn by a percentage of the maxHP but if a character gets injured, slip damage will:

(In the default output) reduce hp based on the new maxHP i.e. 10% of 75, 7.5 each turn.

(In what I want) reduce hp based on the actual maxHP i.e. 10% of 100, 10 damage each turn.

Also I'd like to have a graphical output too.

The green gauge of hp gets a part of it in red(which indicates the amount of HP that can't be recovered until injury is healed)

For example:

You recover 15 hp so you reach 75/75.

In the default output: Hp gauge is fully recovered(even if you still miss that 25%)

In what I want: HP gauge is recovered until reaches the red part of it which can't be recovered.

I should also state that I have yanfly enemy hp bars so the same should work for enemies too.

Also multiple injuries might be inflicted so the red bar cannot be fixed to a 25% but it could change between all of hp bar.

I hope I've explained the request correctly.

As always I accept any tip or opinion on this feature and you can add any option you think it might turn this script more usable for everyone.

Thanks in advance for anyone who'll read and answer this and sorry for my bad english(I'm native italian).

Cheers :)
 
Last edited by a moderator:

Lecode

(─‿‿─)
Veteran
Joined
Dec 18, 2013
Messages
490
Reaction score
659
First Language
French
Primarily Uses
N/A
Hello. I might help.

But i can do something more easy:

What about if there is just an instance variable that store the HP that can't be healed ?

So, there will be no problems for the HP output and the split damage as the MaxHP will not change.

I just need to ensure that the battler can't recover these "HP that can't be healed".

Example:

Eric has 100/100 HP.

He receives a state that gives...let's say "25% of injury"

Eric has now 75/100 HP. His HP can not grow more than that.
 

Alyon93

Veteran
Veteran
Joined
May 19, 2015
Messages
62
Reaction score
2
First Language
Italian
Primarily Uses
N/A
Yeah Lecode! Sure it'll work and it would be awesome! 

That's why I'm always open to tips or opinions. Someone else might have a better idea on how to have a similar or better solution.

The only thing is bugging me about your solution is if we'll be able to highlight that part of HP just for a better visual feedback. 
If not I guess I'll have to accept that anyway!  :)
 

Lecode

(─‿‿─)
Veteran
Joined
Dec 18, 2013
Messages
490
Reaction score
659
First Language
French
Primarily Uses
N/A
I can help with the visual effect as well.

But for this i need the scripts you're using that change how the HP gauge is drawed.

Also the yanfly enemy HP bar.
 

Alyon93

Veteran
Veteran
Joined
May 19, 2015
Messages
62
Reaction score
2
First Language
Italian
Primarily Uses
N/A
I'm sending you a PM since with the three scripts it says the post is too long.

Thanks for your help mate :)
 

Lecode

(─‿‿─)
Veteran
Joined
Dec 18, 2013
Messages
490
Reaction score
659
First Language
French
Primarily Uses
N/A
Hello. Let me know if it's not really what you want:

#==============================================================================# Injury System# By Lecode# For Alyon93#------------------------------------------------------------------------------# Use <injury: +x> or <injury: -x> in equipments and states notetags# to increase / decrease the % of injury##- Note: <injury: -x> is for...let's say for example an equipment/state called # "Resistance to injury" that negates 20% of injury# So if a battler is suffering from a state that give 25% injury, the# final output is 5% of injury#-# Place the script below Yea Core + Yea Battle Engine + Yea Enemy HP Bars#==============================================================================module Lecode_InjurySys #- Gauge colours Gauge_Colour1 = Color.new(128,128,128) Gauge_Colour2 = Color.new(60,60,60) endclass Game_Battler def injury_mhp self.mhp-(injury_level*self.mhp).to_i end def injury_level val = 0 self.states.each { |s| val += s.injury_level } if actor? self.equips.each { |e| val += e.injury_level unless e.nil? } end return [val*0.01,0].max end alias lecode_injurysys_refresh refresh def refresh lecode_injurysys_refresh @hp = [[@hp, injury_mhp].min, 0].max @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id) end endclass RPG::State def injury_level self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0 end endclass RPG::EquipItem def injury_level self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0 end endclass Window_Base def draw_actor_hp(actor, x, y, width = 124) actor.refresh draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) change_color(system_color) #- unless actor.injury_level <= 0 gwidth = actor.injury_level*width + 4 gx = x+actor.hp_rate*width - 1 colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 draw_gauge(gx,y,gwidth, 1, colour1, colour2) end #- draw_text(x, y, 30, line_height, Vocab::hp_a) draw_current_and_max_values(x, y, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end endclass Window_BattleStatus def draw_actor_hp(actor, dx, dy, width = 124) draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) change_color(system_color) #- unless actor.injury_level <= 0 gwidth = actor.injury_level*width + 4 gx = dx+actor.hp_rate*width - 1 colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 draw_gauge(gx,dy,gwidth, 1, colour1, colour2) end #- cy = (Font.default_size - contents.font.size) / 2 + 1 draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a) draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end endclass Sprite_Battler < Sprite_Base attr_reader :hp_gauge_viewport alias lecode_injurysys_create_enemy_gauges create_enemy_gauges def create_enemy_gauges lecode_injurysys_create_enemy_gauges @injury_hp_g = Enemy_Injury_HP_Gauge.new(@battler, @hp_gauge_viewport) end alias lecode_injurysys_dispose_enemy_gauges dispose_enemy_gauges def dispose_enemy_gauges lecode_injurysys_dispose_enemy_gauges @injury_hp_g.dispose unless @injury_hp_g.nil? end alias lecode_injurysys_update_enemy_gauges update_enemy_gauges def update_enemy_gauges lecode_injurysys_update_enemy_gauges @injury_hp_g.update unless @injury_hp_g.nil? end endclass Enemy_HP_Gauge_Viewport attr_reader :gauge_width alias lecode_injurysys_initialize initialize def initialize(battler, sprite, type) lecode_injurysys_initialize(battler, sprite, type) self.z = @type == :back ? 125 : 127 @current_inj = @battler.injury_level end #- Overwrite method def new_hp_updates return if @current_hp == @battler.hp && @current_mhp == @battler.mhp && @current_inj == @battler.injury_level @current_hp = @battler.hp @current_mhp = @battler.mhp return if @gauge_rate == target_gauge_rate && @current_inj == @battler.injury_level @current_inj = @battler.injury_level @gauge_rate = target_gauge_rate @target_gauge_width = target_gauge_width @visible_counter = 60 end #- Overwrite method def update_gauge return if @gauge_width == @target_gauge_width && @current_inj == @battler.injury_level rate = 3 @target_gauge_width = target_gauge_width if @gauge_width > @target_gauge_width @gauge_width = [@gauge_width - rate, @target_gauge_width].max elsif @gauge_width < @target_gauge_width @gauge_width = [@gauge_width + rate, @target_gauge_width].min end @visible_counter = @gauge_width == 0 ? 10 : 60 return if @type == :back self.rect.width = @gauge_width end endclass Enemy_Injury_HP_Gauge < Viewport def initialize(battler, hp_g) @battler = battler @hp_g = hp_g w = YEA::BATTLE::ENEMY_GAUGE_WIDTH h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT rect = Rect.new(0,0,w,h) super(rect) self.z = 126 self.visible = false create end def create @sprite = Plane.new(self) w = YEA::BATTLE::ENEMY_GAUGE_WIDTH*2 h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT @sprite.bitmap = Bitmap.new(w,h) colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 dx = 0 dy = 0 dw = self.rect.width dh = self.rect.height @sprite.bitmap.gradient_fill_rect(dx, dy, dw, dh, colour1, colour2) @sprite.bitmap.gradient_fill_rect(dw, dy, dw, dh, colour2, colour1) end def update super @sprite.ox += 4 return if @hp_g.nil? #return if @battler.injury_level <= 0 self.visible = @hp_g.gauge_visible? return unless self.visible self.rect.x = @hp_g.rect.x + @battler.hp_rate*@hp_g.rect.width self.rect.y = @hp_g.rect.y self.rect.width = @battler.injury_level*YEA::BATTLE::ENEMY_GAUGE_WIDTH + 1 end end  
Thanks for your help mate  :)
Np, It's an interesting system. :)
 

Alyon93

Veteran
Veteran
Joined
May 19, 2015
Messages
62
Reaction score
2
First Language
Italian
Primarily Uses
N/A
Hello. Let me know if it's not really what you want:

#==============================================================================# Injury System# By Lecode# For Alyon93#------------------------------------------------------------------------------# Use <injury: +x> or <injury: -x> in equipments and states notetags# to increase / decrease the % of injury##- Note: <injury: -x> is for...let's say for example an equipment/state called # "Resistance to injury" that negates 20% of injury# So if a battler is suffering from a state that give 25% injury, the# final output is 5% of injury#-# Place the script below Yea Core + Yea Battle Engine + Yea Enemy HP Bars#==============================================================================module Lecode_InjurySys #- Gauge colours Gauge_Colour1 = Color.new(128,128,128) Gauge_Colour2 = Color.new(60,60,60) endclass Game_Battler def injury_mhp self.mhp-(injury_level*self.mhp).to_i end def injury_level val = 0 self.states.each { |s| val += s.injury_level } if actor? self.equips.each { |e| val += e.injury_level unless e.nil? } end return [val*0.01,0].max end alias lecode_injurysys_refresh refresh def refresh lecode_injurysys_refresh @hp = [[@hp, injury_mhp].min, 0].max @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id) end endclass RPG::State def injury_level self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0 end endclass RPG::EquipItem def injury_level self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0 end endclass Window_Base def draw_actor_hp(actor, x, y, width = 124) actor.refresh draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) change_color(system_color) #- unless actor.injury_level <= 0 gwidth = actor.injury_level*width + 4 gx = x+actor.hp_rate*width - 1 colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 draw_gauge(gx,y,gwidth, 1, colour1, colour2) end #- draw_text(x, y, 30, line_height, Vocab::hp_a) draw_current_and_max_values(x, y, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end endclass Window_BattleStatus def draw_actor_hp(actor, dx, dy, width = 124) draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) change_color(system_color) #- unless actor.injury_level <= 0 gwidth = actor.injury_level*width + 4 gx = dx+actor.hp_rate*width - 1 colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 draw_gauge(gx,dy,gwidth, 1, colour1, colour2) end #- cy = (Font.default_size - contents.font.size) / 2 + 1 draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a) draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end endclass Sprite_Battler < Sprite_Base attr_reader :hp_gauge_viewport alias lecode_injurysys_create_enemy_gauges create_enemy_gauges def create_enemy_gauges lecode_injurysys_create_enemy_gauges @injury_hp_g = Enemy_Injury_HP_Gauge.new(@battler, @hp_gauge_viewport) end alias lecode_injurysys_dispose_enemy_gauges dispose_enemy_gauges def dispose_enemy_gauges lecode_injurysys_dispose_enemy_gauges @injury_hp_g.dispose unless @injury_hp_g.nil? end alias lecode_injurysys_update_enemy_gauges update_enemy_gauges def update_enemy_gauges lecode_injurysys_update_enemy_gauges @injury_hp_g.update unless @injury_hp_g.nil? end endclass Enemy_HP_Gauge_Viewport attr_reader :gauge_width alias lecode_injurysys_initialize initialize def initialize(battler, sprite, type) lecode_injurysys_initialize(battler, sprite, type) self.z = @type == :back ? 125 : 127 @current_inj = @battler.injury_level end #- Overwrite method def new_hp_updates return if @current_hp == @battler.hp && @current_mhp == @battler.mhp && @current_inj == @battler.injury_level @current_hp = @battler.hp @current_mhp = @battler.mhp return if @gauge_rate == target_gauge_rate && @current_inj == @battler.injury_level @current_inj = @battler.injury_level @gauge_rate = target_gauge_rate @target_gauge_width = target_gauge_width @visible_counter = 60 end #- Overwrite method def update_gauge return if @gauge_width == @target_gauge_width && @current_inj == @battler.injury_level rate = 3 @target_gauge_width = target_gauge_width if @gauge_width > @target_gauge_width @gauge_width = [@gauge_width - rate, @target_gauge_width].max elsif @gauge_width < @target_gauge_width @gauge_width = [@gauge_width + rate, @target_gauge_width].min end @visible_counter = @gauge_width == 0 ? 10 : 60 return if @type == :back self.rect.width = @gauge_width end endclass Enemy_Injury_HP_Gauge < Viewport def initialize(battler, hp_g) @battler = battler @hp_g = hp_g w = YEA::BATTLE::ENEMY_GAUGE_WIDTH h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT rect = Rect.new(0,0,w,h) super(rect) self.z = 126 self.visible = false create end def create @sprite = Plane.new(self) w = YEA::BATTLE::ENEMY_GAUGE_WIDTH*2 h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT @sprite.bitmap = Bitmap.new(w,h) colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 dx = 0 dy = 0 dw = self.rect.width dh = self.rect.height @sprite.bitmap.gradient_fill_rect(dx, dy, dw, dh, colour1, colour2) @sprite.bitmap.gradient_fill_rect(dw, dy, dw, dh, colour2, colour1) end def update super @sprite.ox += 4 return if @hp_g.nil? #return if @battler.injury_level <= 0 self.visible = @hp_g.gauge_visible? return unless self.visible self.rect.x = @hp_g.rect.x + @battler.hp_rate*@hp_g.rect.width self.rect.y = @hp_g.rect.y self.rect.width = @battler.injury_level*YEA::BATTLE::ENEMY_GAUGE_WIDTH + 1 end end  
Np, It's an interesting system. :)
That's exactly what I wanted mate. I've only changed the  gauge color to red which is more visible and does much contrast with the normal green.

I appreciate the blur of colors you made and I appreciate that armor add-on. I don't think I'll use it but someone out there who may try our system one day maybe would need that.

However even if it's working perfectly with actors,  it's not working as intended with enemies here I show you some pictures:

Here I take the shot after inflicting 4 injuries(a total of 50% of damage 12.5% each) I didn't hit the enemy at all just used this skill which inflicts all injuries(for debug purposes of course). 

Since I didn't hurt her the highlighted(red one) part should be the entire half bar which partly is black.

After a blow the red bar seem to enlarge:

I don't know what caused the problem but I guess that the red part should be after the black part while now it's acting contrary.

If you can make this little fix it'll be still better but I really appreciate what you've done so far and thanks for everything  :)
 

Lecode

(─‿‿─)
Veteran
Joined
Dec 18, 2013
Messages
490
Reaction score
659
First Language
French
Primarily Uses
N/A
Oh yeah, it's true.

Besides...

Also I'd like to have a graphical output too. 
The green gauge of hp gets a part of it in red(which indicates the amount of HP that can't be recovered until injury is healed)
For example:
You recover 15 hp so you reach 75/75.
In the default output: Hp gauge is fully recovered(even if you still miss that 25%)
In what I want: HP gauge is recovered until reaches the red part of it which can't be recovered.
It seems that the gauge should be like that:



--

Is not it ?
 

Alyon93

Veteran
Veteran
Joined
May 19, 2015
Messages
62
Reaction score
2
First Language
Italian
Primarily Uses
N/A
That's right!
It works just fine with actors' gauge.

But with enemies' one it is like in the picture I post above!

EDIT:

It seems like I've missed something. Actually actor's too have the same problem almost, as you can see it here:

Basically red one(which indicates injuries) and black one(which indicates damage) have to be reverted. If possible of course, if not it's ok like this!
 
Last edited by a moderator:

Lecode

(─‿‿─)
Veteran
Joined
Dec 18, 2013
Messages
490
Reaction score
659
First Language
French
Primarily Uses
N/A
It should be ok now ^^

Code:
#==============================================================================# Injury System# By Lecode# For Alyon93#------------------------------------------------------------------------------# Use <injury: +x> or <injury: -x> in equipments and states notetags# to increase / decrease the % of injury##- Note: <injury: -x> is for...let's say for example an equipment/state called # "Resistance to injury" that negates 20% of injury# So if a battler is suffering from a state that give 25% injury, the# final output is 5% of injury#-# Place the script below Yea Core + Yea Battle Engine + Yea Enemy HP Bars#==============================================================================module Lecode_InjurySys    #- Gauge colours  Gauge_Colour1 = Color.new(128,128,128)  Gauge_Colour2 = Color.new(60,60,60)  endclass Game_Battler    def injury_mhp    self.mhp-(injury_level*self.mhp).to_i  end    def injury_level    val = 0    self.states.each { |s| val += s.injury_level }    if actor?      self.equips.each { |e| val += e.injury_level unless e.nil? }    end    return [val*0.01,0].max  end    alias lecode_injurysys_refresh refresh  def refresh    lecode_injurysys_refresh    @hp = [[@hp, injury_mhp].min, 0].max    @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id)  end    if $imported["YEA-EnemyHPBars"]  alias lecode_injurysys_item_apply item_apply  def item_apply(user, item)    lecode_injurysys_item_apply(user, item)    sprite.update_enemy_gauge_value unless actor?  end  end  endclass RPG::State    def injury_level    self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0  end  endclass RPG::EquipItem    def injury_level    self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0  end  endclass Window_Base    def draw_actor_hp(actor, x, y, width = 124)    actor.refresh    draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)    change_color(system_color)    #-    unless actor.injury_level <= 0      gwidth = actor.injury_level*width + 4      gx = x+width-gwidth #x+actor.hp_rate*width - 1      colour1 = Lecode_InjurySys::Gauge_Colour1      colour2 = Lecode_InjurySys::Gauge_Colour2      draw_gauge(gx,y,gwidth, 1, colour1, colour2)    end    #-    draw_text(x, y, 30, line_height, Vocab::hp_a)    draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,      hp_color(actor), normal_color)  end    endif $imported["YEA-BattleEngine"]  class Window_BattleStatus    def draw_actor_hp(actor, dx, dy, width = 124)    draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)    change_color(system_color)    #-    unless actor.injury_level <= 0      gwidth = actor.injury_level*width + 4      gx = dx+width-gwidth #dx+actor.hp_rate*width - 1      colour1 = Lecode_InjurySys::Gauge_Colour1      colour2 = Lecode_InjurySys::Gauge_Colour2      draw_gauge(gx,dy,gwidth, 1, colour1, colour2)    end    #-    cy = (Font.default_size - contents.font.size) / 2 + 1    draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a)    draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp,      hp_color(actor), normal_color)    end    endend #-$imported["YEA-BattleEngine"]if $imported["YEA-EnemyHPBars"]class Sprite_Battler < Sprite_Base  attr_reader :hp_gauge_viewport    alias lecode_injurysys_create_enemy_gauges create_enemy_gauges  def create_enemy_gauges    lecode_injurysys_create_enemy_gauges    @injury_hp_g = Enemy_Injury_HP_Gauge.new(@battler, @hp_gauge_viewport)  end    alias lecode_injurysys_dispose_enemy_gauges dispose_enemy_gauges  def dispose_enemy_gauges    lecode_injurysys_dispose_enemy_gauges    @injury_hp_g.dispose unless @injury_hp_g.nil?  end    alias lecode_injurysys_update_enemy_gauges update_enemy_gauges  def update_enemy_gauges    lecode_injurysys_update_enemy_gauges    @injury_hp_g.update unless @injury_hp_g.nil?  end  endclass Enemy_HP_Gauge_Viewport    alias lecode_injurysys_initialize initialize  def initialize(battler, sprite, type)    lecode_injurysys_initialize(battler, sprite, type)    self.z = @type == :back ? 125 : 127    @current_inj = @battler.injury_level  end    #- Overwrite method  def new_hp_updates    return if @current_hp == @battler.hp && @current_mhp == @battler.mhp &&    @current_inj == @battler.injury_level    @current_hp = @battler.hp    @current_mhp = @battler.mhp    return if @gauge_rate == target_gauge_rate && @current_inj == @battler.injury_level    @current_inj = @battler.injury_level    @gauge_rate = target_gauge_rate    @target_gauge_width = target_gauge_width    @visible_counter = 60  end    #- Overwrite method  def update_gauge    return if @gauge_width == @target_gauge_width &&    @current_inj == @battler.injury_level    rate = 3    @target_gauge_width = target_gauge_width    if @gauge_width > @target_gauge_width      @gauge_width = [@gauge_width - rate, @target_gauge_width].max    elsif @gauge_width < @target_gauge_width      @gauge_width = [@gauge_width + rate, @target_gauge_width].min    end    @visible_counter = @gauge_width == 0 ? 10 : 60    return if @type == :back    self.rect.width = @gauge_width    #puts "--Updating"    #puts "."  end    endclass Enemy_Injury_HP_Gauge < Viewport    def initialize(battler, hp_g)    @battler = battler    @hp_g = hp_g    w = YEA::BATTLE::ENEMY_GAUGE_WIDTH    h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT    rect = Rect.new(0,0,w,h)    super(rect)    self.z = 126    self.visible = false    create  end    def create    @sprite = Plane.new(self)    w = YEA::BATTLE::ENEMY_GAUGE_WIDTH*2    h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT    @sprite.bitmap = Bitmap.new(w,h)    colour1 = Lecode_InjurySys::Gauge_Colour1    colour2 = Lecode_InjurySys::Gauge_Colour2    dx = 0    dy = 0    dw = self.rect.width    dh = self.rect.height    @sprite.bitmap.gradient_fill_rect(dx, dy, dw, dh, colour1, colour2)    @sprite.bitmap.gradient_fill_rect(dw, dy, dw, dh, colour2, colour1)  end    def update    super    @sprite.ox += 4    return if @hp_g.nil?    #return if @battler.injury_level <= 0    self.visible = @hp_g.gauge_visible?    return unless self.visible    self.rect.y = @hp_g.rect.y    self.rect.width = @battler.injury_level*YEA::BATTLE::ENEMY_GAUGE_WIDTH    self.rect.x = @hp_g.rect.x + YEA::BATTLE::ENEMY_GAUGE_WIDTH - self.rect.width  end    endend #-$imported["YEA-EnemyHPBars"] 
 

Alyon93

Veteran
Veteran
Joined
May 19, 2015
Messages
62
Reaction score
2
First Language
Italian
Primarily Uses
N/A
It should be ok now ^^

#==============================================================================# Injury System# By Lecode# For Alyon93#------------------------------------------------------------------------------# Use <injury: +x> or <injury: -x> in equipments and states notetags# to increase / decrease the % of injury##- Note: <injury: -x> is for...let's say for example an equipment/state called # "Resistance to injury" that negates 20% of injury# So if a battler is suffering from a state that give 25% injury, the# final output is 5% of injury#-# Place the script below Yea Core + Yea Battle Engine + Yea Enemy HP Bars#==============================================================================module Lecode_InjurySys #- Gauge colours Gauge_Colour1 = Color.new(128,128,128) Gauge_Colour2 = Color.new(60,60,60) endclass Game_Battler def injury_mhp self.mhp-(injury_level*self.mhp).to_i end def injury_level val = 0 self.states.each { |s| val += s.injury_level } if actor? self.equips.each { |e| val += e.injury_level unless e.nil? } end return [val*0.01,0].max end alias lecode_injurysys_refresh refresh def refresh lecode_injurysys_refresh @hp = [[@hp, injury_mhp].min, 0].max @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id) end if $imported["YEA-EnemyHPBars"] alias lecode_injurysys_item_apply item_apply def item_apply(user, item) lecode_injurysys_item_apply(user, item) sprite.update_enemy_gauge_value unless actor? end end endclass RPG::State def injury_level self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0 end endclass RPG::EquipItem def injury_level self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0 end endclass Window_Base def draw_actor_hp(actor, x, y, width = 124) actor.refresh draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) change_color(system_color) #- unless actor.injury_level <= 0 gwidth = actor.injury_level*width + 4 gx = x+width-gwidth #x+actor.hp_rate*width - 1 colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 draw_gauge(gx,y,gwidth, 1, colour1, colour2) end #- draw_text(x, y, 30, line_height, Vocab::hp_a) draw_current_and_max_values(x, y, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end endif $imported["YEA-BattleEngine"] class Window_BattleStatus def draw_actor_hp(actor, dx, dy, width = 124) draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) change_color(system_color) #- unless actor.injury_level <= 0 gwidth = actor.injury_level*width + 4 gx = dx+width-gwidth #dx+actor.hp_rate*width - 1 colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 draw_gauge(gx,dy,gwidth, 1, colour1, colour2) end #- cy = (Font.default_size - contents.font.size) / 2 + 1 draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a) draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end endend #-$imported["YEA-BattleEngine"]if $imported["YEA-EnemyHPBars"]class Sprite_Battler < Sprite_Base attr_reader :hp_gauge_viewport alias lecode_injurysys_create_enemy_gauges create_enemy_gauges def create_enemy_gauges lecode_injurysys_create_enemy_gauges @injury_hp_g = Enemy_Injury_HP_Gauge.new(@battler, @hp_gauge_viewport) end alias lecode_injurysys_dispose_enemy_gauges dispose_enemy_gauges def dispose_enemy_gauges lecode_injurysys_dispose_enemy_gauges @injury_hp_g.dispose unless @injury_hp_g.nil? end alias lecode_injurysys_update_enemy_gauges update_enemy_gauges def update_enemy_gauges lecode_injurysys_update_enemy_gauges @injury_hp_g.update unless @injury_hp_g.nil? end endclass Enemy_HP_Gauge_Viewport alias lecode_injurysys_initialize initialize def initialize(battler, sprite, type) lecode_injurysys_initialize(battler, sprite, type) self.z = @type == :back ? 125 : 127 @current_inj = @battler.injury_level end #- Overwrite method def new_hp_updates return if @current_hp == @battler.hp && @current_mhp == @battler.mhp && @current_inj == @battler.injury_level @current_hp = @battler.hp @current_mhp = @battler.mhp return if @gauge_rate == target_gauge_rate && @current_inj == @battler.injury_level @current_inj = @battler.injury_level @gauge_rate = target_gauge_rate @target_gauge_width = target_gauge_width @visible_counter = 60 end #- Overwrite method def update_gauge return if @gauge_width == @target_gauge_width && @current_inj == @battler.injury_level rate = 3 @target_gauge_width = target_gauge_width if @gauge_width > @target_gauge_width @gauge_width = [@gauge_width - rate, @target_gauge_width].max elsif @gauge_width < @target_gauge_width @gauge_width = [@gauge_width + rate, @target_gauge_width].min end @visible_counter = @gauge_width == 0 ? 10 : 60 return if @type == :back self.rect.width = @gauge_width #puts "--Updating" #puts "." end endclass Enemy_Injury_HP_Gauge < Viewport def initialize(battler, hp_g) @battler = battler @hp_g = hp_g w = YEA::BATTLE::ENEMY_GAUGE_WIDTH h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT rect = Rect.new(0,0,w,h) super(rect) self.z = 126 self.visible = false create end def create @sprite = Plane.new(self) w = YEA::BATTLE::ENEMY_GAUGE_WIDTH*2 h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT @sprite.bitmap = Bitmap.new(w,h) colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 dx = 0 dy = 0 dw = self.rect.width dh = self.rect.height @sprite.bitmap.gradient_fill_rect(dx, dy, dw, dh, colour1, colour2) @sprite.bitmap.gradient_fill_rect(dw, dy, dw, dh, colour2, colour1) end def update super @sprite.ox += 4 return if @hp_g.nil? #return if @battler.injury_level <= 0 self.visible = @hp_g.gauge_visible? return unless self.visible self.rect.y = @hp_g.rect.y self.rect.width = @battler.injury_level*YEA::BATTLE::ENEMY_GAUGE_WIDTH self.rect.x = @hp_g.rect.x + YEA::BATTLE::ENEMY_GAUGE_WIDTH - self.rect.width end endend #-$imported["YEA-EnemyHPBars"] 
Sorry to still bothering you. 

it's almost done....

What is missing now is the damage inflicted before the injuries. 

If you have for instance: 90/100 if you get injured by a 25% injury you reach 75/100 with the green part until 75 and the red part from 75 to 100.

While it should instead result: 65/100 with the green bar until 65, from 65 to 75 black bar(recoverable) and from 75 to 100 red bar(unrecoverable). 

After this if you got damaged, it will remove hp starting from 75(and so having green gauge, black gauge, red gauge) which is okay. 

So it's only missing the starting point. 

I think you should somehow store the current hp_loss before injury applies and then reapply that hp_loss after the injury is set.

I would do it if I knew what to use :(  

Thanks anyway you're really approaching very fast to solving my request. :)   
 

Lecode

(─‿‿─)
Veteran
Joined
Dec 18, 2013
Messages
490
Reaction score
659
First Language
French
Primarily Uses
N/A
After this if you got damaged, it will remove hp starting from 75(and so having green gauge, black gauge, red gauge) which is okay. 
You meant from 65, no ?

If so:

Code:
#==============================================================================# Injury System# By Lecode# For Alyon93#------------------------------------------------------------------------------# Use <injury: +x> or <injury: -x> in equipments and states notetags# to increase / decrease the % of injury##- Note: <injury: -x> is for...let's say for example an equipment/state called # "Resistance to injury" that negates 20% of injury# So if a battler is suffering from a state that give 25% injury, the# final output is 5% of injury#-# Place the script below Yea Core + Yea Battle Engine + Yea Enemy HP Bars#==============================================================================module Lecode_InjurySys    #- Gauge colours  Gauge_Colour1 = Color.new(128,128,128)  Gauge_Colour2 = Color.new(60,60,60)  end$imported ||= {}class Game_Battler    def injury_mhp    self.mhp-(injury_level*self.mhp).to_i  end    def injury_level    val = 0    self.states.each { |s| val += s.injury_level }    if actor?      self.equips.each { |e| val += e.injury_level unless e.nil? }    end    return [val*0.01,0].max  end    alias lecode_injurysys_refresh refresh  def refresh    lecode_injurysys_refresh    @hp = [[@hp, injury_mhp].min, 0].max    @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id)  end    alias lecode_injurysys_add_new_state add_new_state  def add_new_state(state_id)    lost_hp = injury_mhp-self.hp    lecode_injurysys_add_new_state(state_id)    state = $data_states[state_id]    return unless state.injury?    @hp -= lost_hp    refresh  end        if $imported["YEA-EnemyHPBars"]  alias lecode_injurysys_item_apply item_apply  def item_apply(user, item)    lecode_injurysys_item_apply(user, item)    sprite.update_enemy_gauge_value unless actor?  end  end  endclass RPG::State    def injury_level    self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0  end    def injury?    injury_level > 0  end  endclass RPG::EquipItem    def injury_level    self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0  end  endclass Window_Base    def draw_actor_hp(actor, x, y, width = 124)    actor.refresh    draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)    change_color(system_color)    #-    unless actor.injury_level <= 0      gwidth = actor.injury_level*width + 4      gx = x+width-gwidth #x+actor.hp_rate*width - 1      colour1 = Lecode_InjurySys::Gauge_Colour1      colour2 = Lecode_InjurySys::Gauge_Colour2      draw_gauge(gx,y,gwidth, 1, colour1, colour2)    end    #-    draw_text(x, y, 30, line_height, Vocab::hp_a)    draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,      hp_color(actor), normal_color)  end    endif $imported["YEA-BattleEngine"]  class Window_BattleStatus    def draw_actor_hp(actor, dx, dy, width = 124)    draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)    change_color(system_color)    #-    unless actor.injury_level <= 0      gwidth = actor.injury_level*width + 4      gx = dx+width-gwidth #dx+actor.hp_rate*width - 1      colour1 = Lecode_InjurySys::Gauge_Colour1      colour2 = Lecode_InjurySys::Gauge_Colour2      draw_gauge(gx,dy,gwidth, 1, colour1, colour2)    end    #-    cy = (Font.default_size - contents.font.size) / 2 + 1    draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a)    draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp,      hp_color(actor), normal_color)    end    endend #-$imported["YEA-BattleEngine"]if $imported["YEA-EnemyHPBars"]class Sprite_Battler < Sprite_Base  attr_reader :hp_gauge_viewport    alias lecode_injurysys_create_enemy_gauges create_enemy_gauges  def create_enemy_gauges    lecode_injurysys_create_enemy_gauges    @injury_hp_g = Enemy_Injury_HP_Gauge.new(@battler, @hp_gauge_viewport)  end    alias lecode_injurysys_dispose_enemy_gauges dispose_enemy_gauges  def dispose_enemy_gauges    lecode_injurysys_dispose_enemy_gauges    @injury_hp_g.dispose unless @injury_hp_g.nil?  end    alias lecode_injurysys_update_enemy_gauges update_enemy_gauges  def update_enemy_gauges    lecode_injurysys_update_enemy_gauges    @injury_hp_g.update unless @injury_hp_g.nil?  end  endclass Enemy_HP_Gauge_Viewport    alias lecode_injurysys_initialize initialize  def initialize(battler, sprite, type)    lecode_injurysys_initialize(battler, sprite, type)    self.z = @type == :back ? 125 : 127    @current_inj = @battler.injury_level  end    #- Overwrite method  def new_hp_updates    return if @current_hp == @battler.hp && @current_mhp == @battler.mhp &&    @current_inj == @battler.injury_level    @current_hp = @battler.hp    @current_mhp = @battler.mhp    return if @gauge_rate == target_gauge_rate && @current_inj == @battler.injury_level    @current_inj = @battler.injury_level    @gauge_rate = target_gauge_rate    @target_gauge_width = target_gauge_width    @visible_counter = 60  end    #- Overwrite method  def update_gauge    return if @gauge_width == @target_gauge_width &&    @current_inj == @battler.injury_level    rate = 3    @target_gauge_width = target_gauge_width    if @gauge_width > @target_gauge_width      @gauge_width = [@gauge_width - rate, @target_gauge_width].max    elsif @gauge_width < @target_gauge_width      @gauge_width = [@gauge_width + rate, @target_gauge_width].min    end    @visible_counter = @gauge_width == 0 ? 10 : 60    return if @type == :back    self.rect.width = @gauge_width  end    endclass Enemy_Injury_HP_Gauge < Viewport    def initialize(battler, hp_g)    @battler = battler    @hp_g = hp_g    w = YEA::BATTLE::ENEMY_GAUGE_WIDTH    h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT    rect = Rect.new(0,0,w,h)    super(rect)    self.z = 126    self.visible = false    create  end    def create    @sprite = Plane.new(self)    w = YEA::BATTLE::ENEMY_GAUGE_WIDTH*2    h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT    @sprite.bitmap = Bitmap.new(w,h)    colour1 = Lecode_InjurySys::Gauge_Colour1    colour2 = Lecode_InjurySys::Gauge_Colour2    dx = 0    dy = 0    dw = self.rect.width    dh = self.rect.height    @sprite.bitmap.gradient_fill_rect(dx, dy, dw, dh, colour1, colour2)    @sprite.bitmap.gradient_fill_rect(dw, dy, dw, dh, colour2, colour1)  end    def update    super    @sprite.ox += 4    return if @hp_g.nil?    #return if @battler.injury_level <= 0    self.visible = @hp_g.gauge_visible?    return unless self.visible    self.rect.y = @hp_g.rect.y    self.rect.width = @battler.injury_level*YEA::BATTLE::ENEMY_GAUGE_WIDTH    self.rect.x = @hp_g.rect.x + YEA::BATTLE::ENEMY_GAUGE_WIDTH - self.rect.width  end    endend #-$imported["YEA-EnemyHPBars"] 
 
Last edited by a moderator:

Alyon93

Veteran
Veteran
Joined
May 19, 2015
Messages
62
Reaction score
2
First Language
Italian
Primarily Uses
N/A
You meant from 65, no ?

If so:

#==============================================================================# Injury System# By Lecode# For Alyon93#------------------------------------------------------------------------------# Use <injury: +x> or <injury: -x> in equipments and states notetags# to increase / decrease the % of injury##- Note: <injury: -x> is for...let's say for example an equipment/state called # "Resistance to injury" that negates 20% of injury# So if a battler is suffering from a state that give 25% injury, the# final output is 5% of injury#-# Place the script below Yea Core + Yea Battle Engine + Yea Enemy HP Bars#==============================================================================module Lecode_InjurySys #- Gauge colours Gauge_Colour1 = Color.new(128,128,128) Gauge_Colour2 = Color.new(60,60,60) end$imported ||= {}class Game_Battler def injury_mhp self.mhp-(injury_level*self.mhp).to_i end def injury_level val = 0 self.states.each { |s| val += s.injury_level } if actor? self.equips.each { |e| val += e.injury_level unless e.nil? } end return [val*0.01,0].max end alias lecode_injurysys_refresh refresh def refresh lecode_injurysys_refresh @hp = [[@hp, injury_mhp].min, 0].max @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id) end alias lecode_injurysys_add_new_state add_new_state def add_new_state(state_id) lost_hp = injury_mhp-self.hp lecode_injurysys_add_new_state(state_id) state = $data_states[state_id] return unless state.injury? @hp -= lost_hp refresh end if $imported["YEA-EnemyHPBars"] alias lecode_injurysys_item_apply item_apply def item_apply(user, item) lecode_injurysys_item_apply(user, item) sprite.update_enemy_gauge_value unless actor? end end endclass RPG::State def injury_level self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0 end def injury? injury_level > 0 end endclass RPG::EquipItem def injury_level self.note =~ /<injury:[ ]?(.+)>/i ? $1.to_i : 0 end endclass Window_Base def draw_actor_hp(actor, x, y, width = 124) actor.refresh draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) change_color(system_color) #- unless actor.injury_level <= 0 gwidth = actor.injury_level*width + 4 gx = x+width-gwidth #x+actor.hp_rate*width - 1 colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 draw_gauge(gx,y,gwidth, 1, colour1, colour2) end #- draw_text(x, y, 30, line_height, Vocab::hp_a) draw_current_and_max_values(x, y, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end endif $imported["YEA-BattleEngine"] class Window_BattleStatus def draw_actor_hp(actor, dx, dy, width = 124) draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) change_color(system_color) #- unless actor.injury_level <= 0 gwidth = actor.injury_level*width + 4 gx = dx+width-gwidth #dx+actor.hp_rate*width - 1 colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 draw_gauge(gx,dy,gwidth, 1, colour1, colour2) end #- cy = (Font.default_size - contents.font.size) / 2 + 1 draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a) draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end endend #-$imported["YEA-BattleEngine"]if $imported["YEA-EnemyHPBars"]class Sprite_Battler < Sprite_Base attr_reader :hp_gauge_viewport alias lecode_injurysys_create_enemy_gauges create_enemy_gauges def create_enemy_gauges lecode_injurysys_create_enemy_gauges @injury_hp_g = Enemy_Injury_HP_Gauge.new(@battler, @hp_gauge_viewport) end alias lecode_injurysys_dispose_enemy_gauges dispose_enemy_gauges def dispose_enemy_gauges lecode_injurysys_dispose_enemy_gauges @injury_hp_g.dispose unless @injury_hp_g.nil? end alias lecode_injurysys_update_enemy_gauges update_enemy_gauges def update_enemy_gauges lecode_injurysys_update_enemy_gauges @injury_hp_g.update unless @injury_hp_g.nil? end endclass Enemy_HP_Gauge_Viewport alias lecode_injurysys_initialize initialize def initialize(battler, sprite, type) lecode_injurysys_initialize(battler, sprite, type) self.z = @type == :back ? 125 : 127 @current_inj = @battler.injury_level end #- Overwrite method def new_hp_updates return if @current_hp == @battler.hp && @current_mhp == @battler.mhp && @current_inj == @battler.injury_level @current_hp = @battler.hp @current_mhp = @battler.mhp return if @gauge_rate == target_gauge_rate && @current_inj == @battler.injury_level @current_inj = @battler.injury_level @gauge_rate = target_gauge_rate @target_gauge_width = target_gauge_width @visible_counter = 60 end #- Overwrite method def update_gauge return if @gauge_width == @target_gauge_width && @current_inj == @battler.injury_level rate = 3 @target_gauge_width = target_gauge_width if @gauge_width > @target_gauge_width @gauge_width = [@gauge_width - rate, @target_gauge_width].max elsif @gauge_width < @target_gauge_width @gauge_width = [@gauge_width + rate, @target_gauge_width].min end @visible_counter = @gauge_width == 0 ? 10 : 60 return if @type == :back self.rect.width = @gauge_width end endclass Enemy_Injury_HP_Gauge < Viewport def initialize(battler, hp_g) @battler = battler @hp_g = hp_g w = YEA::BATTLE::ENEMY_GAUGE_WIDTH h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT rect = Rect.new(0,0,w,h) super(rect) self.z = 126 self.visible = false create end def create @sprite = Plane.new(self) w = YEA::BATTLE::ENEMY_GAUGE_WIDTH*2 h = YEA::BATTLE::ENEMY_GAUGE_HEIGHT @sprite.bitmap = Bitmap.new(w,h) colour1 = Lecode_InjurySys::Gauge_Colour1 colour2 = Lecode_InjurySys::Gauge_Colour2 dx = 0 dy = 0 dw = self.rect.width dh = self.rect.height @sprite.bitmap.gradient_fill_rect(dx, dy, dw, dh, colour1, colour2) @sprite.bitmap.gradient_fill_rect(dw, dy, dw, dh, colour2, colour1) end def update super @sprite.ox += 4 return if @hp_g.nil? #return if @battler.injury_level <= 0 self.visible = @hp_g.gauge_visible? return unless self.visible self.rect.y = @hp_g.rect.y self.rect.width = @battler.injury_level*YEA::BATTLE::ENEMY_GAUGE_WIDTH self.rect.x = @hp_g.rect.x + YEA::BATTLE::ENEMY_GAUGE_WIDTH - self.rect.width end endend #-$imported["YEA-EnemyHPBars"] 
That's it!

Awesome Lecode that was perfect!!!

You are a great scripter and a great person  ;)  

Thanks for all your time and patience!

I hope to return the favor one day!

Cheers friend :)   
 

Lecode

(─‿‿─)
Veteran
Joined
Dec 18, 2013
Messages
490
Reaction score
659
First Language
French
Primarily Uses
N/A
You're welcome  :D .
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Are we allowed to post about non-RPG Maker games?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:

Forum statistics

Threads
105,883
Messages
1,017,236
Members
137,608
Latest member
Arm9
Top