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.

XP Battler Image Change when low hp

I need the XP script that will change a battler's image when below 20%hp (for example) during
the battle.

I had searched from the forum but couldn't find it... :cry:
I've seen this script a long time ago, if anyone have it ,please let me know .
Thanks a lot! :smile:
 
Code:
class Game_Actor
  alias_method :seph_critbattlers_gmactr_cn, :character_name
  def character_name
    n = seph_critbattlers_gmactr_cn.dup
    if (hp / maxhp.to_f * 100) <= 20
      begin
        RPG::Cache.character(n + '_critical', 0)
        n += '_critical' 
      rescue
      end
    end
    return n
  end
end

class Game_Enemy
  alias_method :seph_critbattlers_gmenmy_cn, :character_name
  def character_name
    n = seph_critbattlers_gmenmy_cn.dup
    if (hp / maxhp.to_f * 100) <= 20
      begin
        RPG::Cache.character(n + '_critical', 0)
        n += '_critical' 
      rescue
      end
    end
    return n
  end
end

Let me know if that works. It adds _critical to the battler name file. If one isn't found, it won't cause an error.
 
SephirothSpawn":74c6o87o said:
Code:
class Game_Actor
  alias_method :seph_critbattlers_gmactr_cn, :character_name
  def character_name
    n = seph_critbattlers_gmactr_cn.dup
    if (hp / maxhp.to_f * 100) <= 20
      begin
        RPG::Cache.character(n + '_critical', 0)
        n += '_critical' 
      rescue
      end
    end
    return n
  end
end

class Game_Enemy
  alias_method :seph_critbattlers_gmenmy_cn, :character_name
  def character_name
    n = seph_critbattlers_gmenmy_cn.dup
    if (hp / maxhp.to_f * 100) <= 20
      begin
        RPG::Cache.character(n + '_critical', 0)
        n += '_critical' 
      rescue
      end
    end
    return n
  end
end

Let me know if that works. It adds _critical to the battler name file. If one isn't found, it won't cause an error.


It got an error at SDK line 2215

the error is
sdk_aliaslog_aliasmethod(newmethodname, oldmethodname)


and line 17 at this script

alias_method :seph_critbattlers_gmenmy_cn, :character_name
 
Ooops. lol

Code:
class Game_Actor
  alias_method :seph_critbattlers_gmactr_bn, :battler_name
  def battler_name
    n = seph_critbattlers_gmactr_bn.dup
    if (hp / maxhp.to_f * 100) <= 20
      begin
        RPG::Cache.battler(n + '_critical', 0)
        n += '_critical'
      rescue
      end
    end
    return n
  end
end

class Game_Enemy
  alias_method :seph_critbattlers_gmenmy_bn, :battler_name
  def battler_name
    n = seph_critbattlers_gmenmy_bn.dup
    if (hp / maxhp.to_f * 100) <= 20
      begin
        RPG::Cache.battler(n + '_critical', 0)
        n += '_critical'
      rescue
      end
    end
    return n
  end
end

Try that.
 
SephirothSpawn":kwufry38 said:
Ooops. lol

Code:
class Game_Actor
  alias_method :seph_critbattlers_gmactr_bn, :battler_name
  def battler_name
    n = seph_critbattlers_gmactr_bn.dup
    if (hp / maxhp.to_f * 100) <= 20
      begin
        RPG::Cache.battler(n + '_critical', 0)
        n += '_critical'
      rescue
      end
    end
    return n
  end
end

class Game_Enemy
  alias_method :seph_critbattlers_gmenmy_bn, :battler_name
  def battler_name
    n = seph_critbattlers_gmenmy_bn.dup
    if (hp / maxhp.to_f * 100) <= 20
      begin
        RPG::Cache.battler(n + '_critical', 0)
        n += '_critical'
      rescue
      end
    end
    return n
  end
end

Try that.


Amazing!!!
It works now
Thanks you for helping me! SephirothSpawn :biggrin:
I will credit this for you :thumb:
 

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