Drain Health From Enemy

Jotari

Veteran
Veteran
Joined
May 31, 2013
Messages
41
Reaction score
2
First Language
English
Primarily Uses
I want to make a skill that deals damage to an enemy and heals the user by the equivalent amount of health. Any ideas? I'm willing to edit the script but I'm hesitant to since I'm not familiar with the code, though I am familiar with coding in general.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,634
Reaction score
5,115
First Language
English
Primarily Uses
RMVXA
You'll want to make the addition in Game_Battler 3.  It needs to go (shortly) after the "Subtract Damage from HP" block (specifically, sometime shortly after this line: " effective |= self.hp != last_hp ").

Here's the coding I used for my similar skill:

      # Drain Needles Processing      if skill.id == 97        user.damage = [(0 - [last_hp, self.damage].min/2),0].min        user.hp -= user.damage        user.damage_pop = true      endChange 97 to whatever the Skill ID is.  Note that user.damage is a construct for the skill's user to keep track of how much health they're about to heal - it is self.damage that pulls in the amount of damage you did to your target.  For your skill, you can simply set the formula to: user.damage = self.damage because you want to heal an amount equal to damage dealt (my more complicated formula heals half of either the damage dealt or the amount of HP the target had remaining - whichever is smaller).  The next line does the actual change to the skill user's HP.  The final line allows the player to see how much damage the user healed by giving them their own damage popup.
 

Jotari

Veteran
Veteran
Joined
May 31, 2013
Messages
41
Reaction score
2
First Language
English
Primarily Uses
Thanks. Slotting that exact piece of code in worked just fine. Coincidentally it was even at the same skill id. I now understand the code a bit better too. One minor issue, design more than anything else, but it heals the user before it deals damage to the target. I'd prefer to heal after dealing the damage so it looks like its draining the energy. I imagine it's just a case of moving the code somewhere else but if its more complicated than that then it's no big deal.
 
Last edited by a moderator:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,634
Reaction score
5,115
First Language
English
Primarily Uses
RMVXA
No way!  It was skill #97?  XD

it heals the user before it deals damage to the target. I'd prefer to heal after dealing the damage so it looks like its draining the energy. I imagine it's just a case of moving the code somewhere else but if its more complicated than that then it's no big deal.
Yeah, I think it's because I immediately set damage_pop to true here for the user, whereas it's a bit later on in the processing that it's set for the target.  There are certainly ways to flag that it should be triggered later, and then trigger it later, but they're more complicated than what I gave you here and it's been a while since I've scripted with XP so it's not really something I can help you with.
 

Jotari

Veteran
Veteran
Joined
May 31, 2013
Messages
41
Reaction score
2
First Language
English
Primarily Uses
Ah cool then. No problem. I can officially declare this issue solved.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,018
Messages
1,018,357
Members
137,803
Latest member
andrewcole
Top