Decreasing Hp or Mp overtime in battle?

Theguysayshi

Villager
Member
Joined
Jul 18, 2018
Messages
27
Reaction score
2
First Language
English
Primarily Uses
RMVXA
In my game, I’d like to have a poison state that decreases Hp or Mp my a percentage every second in battle.

So far, I’ve tried doing this by creating a parallel processing common event that decreases Hp/mp per second, but this only works outside of battle, I’d like it to work in battle. Preferably, I’d also like to players to be able to see the Hp/mood bar drain overtime when fixable during battle too.

Any ideas on how to implement this? Any help is much appreciated.
 

Benja

Lead Developer
Veteran
Joined
Mar 5, 2014
Messages
131
Reaction score
25
First Language
English
Primarily Uses
RMVXA
are you referring to MP/HP or MMP/MMP? If the former, then the best way would be to make a poison state, and have the state set HRG/MRG to a negative number. This doesn't decrease every second, but it does decrease every turn.
 

Theguysayshi

Villager
Member
Joined
Jul 18, 2018
Messages
27
Reaction score
2
First Language
English
Primarily Uses
RMVXA
are you referring to MP/HP or MMP/MMP? If the former, then the best way would be to make a poison state, and have the state set HRG/MRG to a negative number. This doesn't decrease every second, but it does decrease every turn.
Just HP/MP.
I am aware you can set a state to decrease HP or MP every turn, but I’d like it to decrease every second (maybe see the bar drain in real time?) So far I can do this outside of battles with a parallel process, not in battles. Thanks for your help though!
 
Last edited:

Benja

Lead Developer
Veteran
Joined
Mar 5, 2014
Messages
131
Reaction score
25
First Language
English
Primarily Uses
RMVXA
Himeworks global common event seems to do the trick, although I couldn't get the bars to update in real time, but the bars do update whenever a selection is made or any general interaction happens.
 

JGreene

Veteran
Veteran
Joined
Oct 24, 2015
Messages
395
Reaction score
297
First Language
English
Primarily Uses
RMMV
You'd have to use an ATB battle system and have tick effects (DoTs and HoTs) do damage or healing every second.
 

Theguysayshi

Villager
Member
Joined
Jul 18, 2018
Messages
27
Reaction score
2
First Language
English
Primarily Uses
RMVXA
You'd have to use an ATB battle system and have tick effects (DoTs and HoTs) do damage or healing every second.
Thanks! Would you be willing to point me in the right direction on how to do this?
 

JGreene

Veteran
Veteran
Joined
Oct 24, 2015
Messages
395
Reaction score
297
First Language
English
Primarily Uses
RMMV
I haven't used VX Ace in such a long time. There are a few different ATB systems out there for it, but I wouldn't know which one would be best for you.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
Let me present the problem of having this in your project. First, the code.
Code:
class Scene_Battle
 
  alias update_basicx update_basic
  def update_basic
    update_basicx
    $game_party.update
  end
 
end

class Game_Party
  def update
    members.each {|m| m.update_rt_hrg }
  end
end

class Game_Actor
  def update_rt_hrg
    if state?(2)
      self.hp -= 1 
      SceneManager.scene.refresh_status
      if $imported["YEA-BattleEngine"]
        SceneManager.scene.status_redraw_target(self)
      end
    end
  end
end
I use state 2 as an example. You can try it on your own.

First, each frame update will reduce the actor's HP by 1. So one second it will be reduced by 60. You might not want it. So you might need to think the reduction rate. On one second or 60 frames, how much the HP will be actually reduced?

Second, repeatedly redrawing HP bar is time consuming and may cause lag. This can't be fixed without reworking almost entire window actor status. So you need a custom HUD as well to make the process more efficient.

Third, during the attack animation, it will also be reduced. The longer the animation is, the more draining the state. Are you sure you want this to happen?
 

Theguysayshi

Villager
Member
Joined
Jul 18, 2018
Messages
27
Reaction score
2
First Language
English
Primarily Uses
RMVXA
Just tested and it works as intended. Thanks! This is more or less the idea I wanted. I realize the potential of the draining taking place even during animations, and that's completely fine.

Although I'd like the decrease to happen every second instead of every frame. Is is possible to alter the delay time?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
Line 19, change it to
Code:
if state?(2) && Graphics.frame_count % 60 == 0
I'm such lazier, probly some of scripters would scold me.
 

Theguysayshi

Villager
Member
Joined
Jul 18, 2018
Messages
27
Reaction score
2
First Language
English
Primarily Uses
RMVXA
Excellent, this is just what I need. Thanks a bunch you guys ^^
 

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

Latest Threads

Latest Posts

Latest Profile Posts

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
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top