Absorb Skill

LawrenceindaSky

Veteran
Veteran
Joined
Apr 21, 2016
Messages
64
Reaction score
4
First Language
English
Primarily Uses
N/A
So I did see a post on this but I'm mainly confused on what to do with the formula I saw...
Code:
x=a.mhp - a.hp; if b.hp <= x ;x=b.hp-1;end;a.hp+=x;x
I'm trying to just have a variance of 100 or the standard attack damage, but I'm new to formulas so I don't quite understand how it all works. I do know that a.mhp is the person using said skill's Max HP and b.hp is basically the Target's HP. The rest I don't understand so if I could have a little help with this, it would be appreciated!

(I should probably mention also that my goal here is to have the user steal an ally's HP, this would be handy for Bossfights like a Giant Slime fight where the Giant Slime can absorb it's allies HP to recover itself)
 
Last edited:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
x=a.mhp - a.hp; - This sets a variable "x" to the amount of HP that the user is missing (which is a's Max HP minus a's Current HP)
if b.hp <= x ;x=b.hp-1;end; - This If - (do something) - End branch checks if the target's HP is less than "x" (the amount of HP that would be stolen), and if so, sets x to one less than the target's HP; this is done so that this move will not kill an ally
a.hp+=x; - The user gains "x" HP
x - The last value to be returned by the formula is the amount of damage (or healing) it will do before adjustments like Variance and Element Rates. Here, it's being set to x (the value calculated earlier)

Therefore, you'd want to use this damage formula on a Single Ally-targeted skill, and hopefully you have some way to prevent the user from targeting themselves. Make sure you have 0 variance and no element on the skill, if you don't want any allies to be KO'ed by it. In theory, you could also make this an All Allies skill, since the effect when used on the user himself should be nil.

However, you could probably make this easier by simply using an "HP Drain" skill on an ally, and using a simple formula - or by working some magic with Yanfly's Skill Core.
 

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
1,923
Reaction score
534
First Language
English
Primarily Uses
N/A
NVMD. delete this post
 

LawrenceindaSky

Veteran
Veteran
Joined
Apr 21, 2016
Messages
64
Reaction score
4
First Language
English
Primarily Uses
N/A
x=a.mhp - a.hp; - This sets a variable "x" to the amount of HP that the user is missing (which is a's Max HP minus a's Current HP)
if b.hp <= x ;x=b.hp-1;end; - This If - (do something) - End branch checks if the target's HP is less than "x" (the amount of HP that would be stolen), and if so, sets x to one less than the target's HP; this is done so that this move will not kill an ally
a.hp+=x; - The user gains "x" HP
x - The last value to be returned by the formula is the amount of damage (or healing) it will do before adjustments like Variance and Element Rates. Here, it's being set to x (the value calculated earlier)

Therefore, you'd want to use this damage formula on a Single Ally-targeted skill, and hopefully you have some way to prevent the user from targeting themselves. Make sure you have 0 variance and no element on the skill, if you don't want any allies to be KO'ed by it. In theory, you could also make this an All Allies skill, since the effect when used on the user himself should be nil.

However, you could probably make this easier by simply using an "HP Drain" skill on an ally, and using a simple formula - or by working some magic with Yanfly's Skill Core.
The explanation helps a lot but im still getting 0s with Drain, is there a example I can see that would use a default attack? Still trying to wrap my head around it but I am getting what stuff does.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Where did you get that formula from? It's not Javascript syntax so it probably wasn't meant for MV. Using as-is will cause a syntax error, and when there's a syntax error in the damage formula it will default to zero instead.

I'm not sure if damage formula errors are logged to the console (press F8 or F12 during playtest), but it would be smart if they were logged.

Try this version, which is written with Javascript syntax.
Code:
var x = a.mhp - a.hp; if (b.hp <= x) {x = b.hp-1;} a.hp += x; x
 

LawrenceindaSky

Veteran
Veteran
Joined
Apr 21, 2016
Messages
64
Reaction score
4
First Language
English
Primarily Uses
N/A
Where did you get that formula from? It's not Javascript syntax so it probably wasn't meant for MV. Using as-is will cause a syntax error, and when there's a syntax error in the damage formula it will default to zero instead.

I'm not sure if damage formula errors are logged to the console (press F8 or F12 during playtest), but it would be smart if they were logged.

Try this version, which is written with Javascript syntax.
Code:
var x = a.mhp - a.hp; if (b.hp <= x) {x = b.hp-1;} a.hp += x; x
Thank you! I was wondering why it wasn't working, it seemed fine the way it looked but glad you caught the mistake! Many Thanks!
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
Great catch, @Aloe Guvner!

Yeah, the syntax was correct Ruby syntax but you were using it in JavaScript-powered RPG Maker MV, which is why it was erroring out and returning 0.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Makes sense, I haven't worked with Ruby or the earlier versions of RPG Maker but makes sense it was probably from a thread about VX or VXAce.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top