Yanfly's Leech Seed - But remade for MP?

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
1,064
Reaction score
1,326
First Language
Swedish
Primarily Uses
RMVXA
Yanfly made a lot of useful Tips n Tricks videos, including how to make the Leech Seed skill from the Pokemon games. I'd like to make a skill in the same way, but have it leech MP instead of HP.

Yanfly's setup is this. First there's a skill, this skill is very simple and all it does is applying a state to the target. The state on the other hand has some special code snippet in it's note box to make it work (it also requires some of Yanfly's plugin).

Code:
<Custom Regenerate Effect>

// Check if the original caster isn't the target and that the original target is alive.
if (origin !== target && origin.isAlive()) {
  // Determine the damage dealt.
  var damage = target.hp / 8;
  // Round up the damage.
  damage = Math.ceil(damage);
  // Cap the damage to 500.
  damage = Math.min(500, damage);
  // Play the healing animation on the original caster.
  origin.startAnimation(46);
  // Original caster gains HP.
  origin.gainHp(damage);
  // Show the HP gained.
  origin.startDamagePopup();
  // Clears the original caster's HP popup.
  origin.clearResult();
  // Play the poison animation on the target.
  target.startAnimation(59);
  // Damage the target's HP.
  target.gainHp(-damage);
  // Check if the target is dead.
  if (target.isDead()) {
  // If the target is dead, make it collapse.
    target.performCollapse();
  }
}
</Custom Regenerate Effect>

Now, I don't really know JavaScript myself so even while everything is nicely commented (which helps a lot with understanding) I can't really say I'd know how to do what I'd like to do.

But I suspect this is could be super simple for someone who knows just a wee bit of JavaScript, so hopefully someone can help me out here.

I'd be very grateful.
Thanks for taking your time and reading all the way down here. :kaohi:
 

Jenova

Because you are...a puppet!
Veteran
Joined
Nov 29, 2017
Messages
417
Reaction score
283
First Language
English
Primarily Uses
RMMV
I don't know JS either but I'm gonna try, wish me luck:
Code:
<Custom Regenerate Effect>

// Check if the original caster isn't the target and that the original target is alive.
if (origin !== target && origin.isAlive()) {
  // Determine the damage dealt.
  var mpdamage = target.mp / 8;
  // Round up the damage.
  mpdamage = Math.ceil(mpdamage);
  // Cap the damage to 500.
  mpdamage = Math.min(500, mpdamage);
  // Play the healing animation on the original caster.
  origin.startAnimation(46);
  // Original caster gains MP.
  origin.gainMp(mpdamage);
  // Show the MP gained.
  origin.startDamagePopup();
  // Clears the original caster's MP popup.
  origin.clearResult();
  // Play the poison animation on the target.
  target.startAnimation(59);
  // Damage the target's MP.
  target.gainMp(-mpdamage);
  }
}
</Custom Regenerate Effect>
All I did was change anywhere it said "damage" to "mpdamage" so it's defined. Also changed anything that referenced HP to reference MP, keeping the style of code the same. I didn't change the animations or anything like that.

Edit: and I got rid of the collapse effect as it's mp and not hp

I'm sure I messed it up.

First time. Lol.
 

JamesRyan

Game Designer
Veteran
Joined
Sep 13, 2014
Messages
696
Reaction score
215
First Language
Vietnamese
Primarily Uses
RMMV
Find all gainHp from the codes above, and replace them with gainMp.

Edit: The way Jenova did should serve your purpose. Following his codes and you will be fine.
 

Jenova

Because you are...a puppet!
Veteran
Joined
Nov 29, 2017
Messages
417
Reaction score
283
First Language
English
Primarily Uses
RMMV
Find all gainHp from the codes above, and replace them with gainMp.

Edit: The way Jenova did should serve your purpose. Following his codes and you will be fine.
I don't even know how to code and i edited it on my phone. I feel so proud but i still think I messed something up.
 

JamesRyan

Game Designer
Veteran
Joined
Sep 13, 2014
Messages
696
Reaction score
215
First Language
Vietnamese
Primarily Uses
RMMV
Basically, I have not seen any issues from your codes. In case something goes wrong, we will make it right again here, so don't worry :wink:
 

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
1,064
Reaction score
1,326
First Language
Swedish
Primarily Uses
RMVXA
Thank you for the help guys. Unfortunally I got an error msg while testing this out. I copy pasted what @Jenova wrote but changed the damage "cap" and adjusted the damage as well. I don't think that's what crashed the game though because I did the exact same changed to the normal (hp) formula and that worked fine.


And here is the code copy pasted directly out of my "MP Leech Seed" state. My own small changes to the damage values included:

Code:
<Custom Regenerate Effect>

// Check if the original caster isn't the target and that the original target is alive.
if (origin !== target && origin.isAlive()) {
  // Determine the damage dealt.
  var mpdamage = target.mp / 20;
  // Round up the damage.
  mpdamage = Math.ceil(mpdamage);
  // Cap the damage to 200.
  mpdamage = Math.min(200, mpdamage);
  // Play the healing animation on the original caster.
  origin.startAnimation(46);
  // Original caster gains MP.
  origin.gainMp(mpdamage);
  // Show the MP gained.
  origin.startDamagePopup();
  // Clears the original caster's MP popup.
  origin.clearResult();
  // Play the poison animation on the target.
  target.startAnimation(59);
  // Damage the target's MP.
  target.gainMp(-mpdamage);
  }
}
</Custom Regenerate Effect>
 

Parallax Panda

Got into VxAce ~2014 and never stopped...
Veteran
Joined
Oct 29, 2015
Messages
1,064
Reaction score
1,326
First Language
Swedish
Primarily Uses
RMVXA
@JamesRyan
Yes, that seems to work. Can't confirm that all the numbers are correct but hopefully they are. The enemy is (probably) loosing MP. That one is hard to confirm. But I am getting their MP, that I can confirm.

Most likely, it works like it should. I think.

Thank you.
 

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,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top