Parallax Panda

Veteran
Veteran
Joined
Oct 29, 2015
Messages
1,113
Reaction score
1,343
First Language
Swedish
Primarily Uses
RMMV
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
468
Reaction score
302
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
736
Reaction score
243
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
468
Reaction score
302
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
736
Reaction score
243
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

Veteran
Veteran
Joined
Oct 29, 2015
Messages
1,113
Reaction score
1,343
First Language
Swedish
Primarily Uses
RMMV
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.

GEehbhz.png

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

Veteran
Veteran
Joined
Oct 29, 2015
Messages
1,113
Reaction score
1,343
First Language
Swedish
Primarily Uses
RMMV
@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.
 

Latest Threads

Latest Posts

Latest Profile Posts

Been playing through Skies of Arcadia again, and it really makes me wanna see someone try to implement how ship battles were done in the game into RPG Maker (or really just in general).
split.png
split view of both versions of the pocket city you traverse through. there's differences like areas only being accessible in one version of Autumn Bay. or events that only happen in one or the other.
theortically if there were a developer who spied on people's game playthroughs and changed things in real time to make it harder for them, what might be said game developer's motivation?
Hi everyone! Enjoying this nice long weekend. How are you all doing? :)
I just successfully tested having events check if specific actors are in a particular party slot and then changing image to match. This will let me make scenes take into account who is in the party at the time and arrange them accordingly - this is important since I'll have extra actors beyond current party. The script used is the same from MV and is compatible with my current core plugin setup in MZ. Thank goodness.

Forum statistics

Threads
118,431
Messages
1,115,898
Members
155,386
Latest member
Yung_DemonxSlayer
Top