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.

status change with health %

Status
Not open for further replies.
I was wondering if there was a way to change the status of a character when their health is below a certain percentage

I know it can be done with events however the status change doesn't take effect until the next turn, and by then it is too late.

So I've asked and the people said it can only be done via scripting, and being on the total hopeless side of understanding any form of script work, I was wondering if someone could help me.
 
Code:
class Game_Battler
  States_Activated_When_Health_Below_Percent = {}
  alias_method :seph_statesactivatedbyhealth_gmbtlr_states, :states
  def states
    n = seph_statesactivatedbyhealth_gmbtlr_states.dup
    percent = Integer(self.hp / self.maxhp.to_f * 100)
    States_Activated_When_Health_Below_Percent.each do |p, state_ids|
      next unless percent <= p
      state_ids.each {|s| n << s unless n.include?(s)}
    end
    return n.dup.sort
  end
end

Insert below everything else. To make it work, just add :
Code:
States_Activated_When_Health_Below_Percent = { percent => [state_id, ... ], ....}

If you need any help, just ask. If it errors, let me know, as it isn't tested.
 
Sorry to ask this but could you give me a quick example of that last line
Where the percentage number is supposed to go and is it the state name or number?

NVM I did it
Yay me ;)

Thanks Seph
 
Status
Not open for further replies.

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