a script that where skill costs HP percentage costs

glitchy bump!
1597900886487.png

when an ally uses a physical attack when their HP is insufficient to the skill's HP cost...

1597900988823.png

this happens! is there a way to prevent this from happening?
like where:
User's Current SP: 10 < Skill's SP Cost: 20 = Can't use because Insufficient SP!
but do the same with HP:
User's Current HP: 750/6750 < Skill's HP Cost: 17% (945) = Can't use because Insufficient HP!
It would need to add some condition in skill_can_use?(skill_id) method...

EDIT
Isn't it Skill #121?
Assault Dive is Skill #136

@kyonides
i tested this with your patched script of HP Sacrifice
Ruby:
class Game_Battler
  alias :why_on_earth_skill_costs_hp_scu? :skill_can_use?
  def skill_can_use?(skill_id)
    if skill_id == 136 #Assault Dive's Skill ID
      data = LockeZ::HP_Sacrifice_Action['Skill'][skill_id]
      hp_percent = data[2] * self.hp / 100
      return self.hp >= hp_percent.round
    end
    why_on_earth_skill_costs_hp_scu?(skill_id)
  end
end
it just didn't work...
Code:
class Game_Battler
  HP_COST_SKILLS = [121, 136]
  alias :why_on_earth_skill_costs_hp_scu? :skill_can_use?
  def skill_can_use?(skill_id)
    if HP_COST_SKILLS.include?(skill_id)
      data = LockeZ::HP_Sacrifice_Action['Skill'][skill_id]
      hp_percent = data[2] * self.maxhp / 100
      return self.hp >= hp_percent.round
    end
    why_on_earth_skill_costs_hp_scu?(skill_id)
  end
end

In HP_COST_SKILLS constant add as many Skill ID's as needed.
NOW it works!
1597905367044.png

thanks!
Yeah, the old fix didn't check for any new skills and it still calculated the cost based on current HP instead of MAXHP... 🙁 That's why I've changed the code.

Original thread: https://forums.rpgmakerweb.com/threads/a-script-that-where-skill-costs-hp-percentage-costs.121800/