Save-Point
Draining Skills! / Compatible with ABSes and custom non-active BSes / No SDK required - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+--- Thread: Draining Skills! / Compatible with ABSes and custom non-active BSes / No SDK required (/thread-5839.html)



Draining Skills! / Compatible with ABSes and custom non-active BSes / No SDK required - DrHouse93 - 06-24-2016

Greetings, companions of RPG Maker XP!

Today, I've developed a small add-on which adds Draining Skills to RMXP, which means that some heroes (and enemies as well!) may recover HPs depending on the damage inflicted to their target. Since this is not a proper script, but an add-on, you must follow those instructions to make them work^^

Instructions

First of all, you need to create an element in the database which will be the one for our draining skills (important!). You can name it as you wish. Then, to set how much percentage of HP will be recovered, (e.g. 50%, 30%...) you must put inside the STR_F field of the skill the proper number (e.g. 50, 30...). Then, check if your BS has a configuration module (you can recognize it by the format "module [name]"). If you have one, just copy this small string inside the configuration module:
Code:
DRAINING_MOVE = 28 # In my case it's the 28th element. Be sure you put the proper number

If you DON'T have a custom a BS, here's the module:

Code:
module Doc
  DRAINING_MOVE = 28
end

Be sure to place this module above the Game_Battler scripts

Then, right-click on the list of scripts, and search for the string "def skill_effect(user, skill)" and jump on that page (keep in mind, if you have a custom BS/ABS, you must use its scripts, not the game defaults!)

Scroll some lines down until you find the string "self.hp -= self.damage"

Then, DIRECTY below it, paste this code:

Code:
      # Draining Skills
      if skill.element_set.include?([yourmodulename]::DRAINING_MOVE) && user.hp != user.maxhp
        percentage = skill.str_f.to_f / 100
        user.damage = [(0 - [last_hp, self.damage].min*percentage),0].min.to_i
        user.hp -= user.damage
      end

That's it. After you've done all the steps correctly, you can use your draining skills at your wish to recover the desired amount of HPs. Furthermore, as long as you have maximum HP, you won't recover more

Happy making^^