Not sure how to make an spell...

So basically i want a spell that when the enemy is hit they loose HP and the caster gets half of the HP... and i am not sure how to make that possible... and this would be for my game that is being made in mv


(Not sure if i put this in the right topic area... sorry if it is not...
Nope. "How do I ..." type questions belong in the Support forum for the appropriate version of the engine, so I'll move this to VX Ace Support for you now (assuming you're using Ace based on your profile). Unless it's about scripts, when it goes into the appropriate Script/Plugin Requests/Support section.
If your looking for the stereotypical "Drain" spell commonly found in most JRPG's. 


It already comes pre-made as a spell called "Life Drain"


If you're looking for a more complex DoT/HoT type of spell/state, it can be done through the database as well


Drain Over Time has the info you may need for the Dot/Hot combo
Nope. "How do I ..." type questions belong in the Support forum for the appropriate version of the engine, so I'll move this to VX Ace Support for you now (assuming you're using Ace based on your profile). Unless it's about scripts, when it goes into the appropriate Script/Plugin Requests/Support section.

This is actually for MV...


And thanks Roscalin
Then moving to MV Support. You might want to update your profile to say you're using MV rather than Ace, or to specify each time you post what engine you're using to avoid confusion.
Thanks for clearing that up..  this explains the question now, considering life drain doesn't come packaged with MV as like all the others..


Go to this post RPG Maker MV Templates and Guideline made by Archeia, in the second post below the main one is the "Full" database unlike the limited one the game tends to come installed with.


*Warning* It will overwrite any data you made in your project folder you're using if you replace the database with the ones I linked you to.


Go about making a backup project that you can easily use for references/testing/copy-pastes/Idea's for your game. and replace the .JSON files in that project to access the full database.


I do believe tomorrow, Yanfly will be releasing a life steal plug-in if you want, you can see if that would be of use to you as well 


Hopefully this helped. \(^_^)/
You need both Yanfly's Skill Core and Buffs States Core.


Create a new state, name it whatever you want.


put this in the notetag


<Custom React Effect>
origin.gainHp(Math.round(value / 2));
target.removeState(x);
</Custom React Effect>


x is the state id.


in the skill notetag, put this


<Before Eval>
target.addState(x);
</Before Eval>


x is the state id.
It can also be done by damage formula coding, then you don't need any scripts at all.

Code:
dam = (intended damage formula); a.hp+=dam/2; dam
Sorry for highjacking the thread, but @Andar does the ; start a new formula? I'm not really understanding what is happening there... if you could message me.. or I can message you? Because I am really into learning all I can about rpgmaker mv... and this looks quite interesting...
The entire field of the damage formula is processed by an eval command, which means that executed as programing code - and in most programming languages, ; separates commands. You can execute any RGSS3-script code there, and you need to understand scripting and programming if you want to create more complex damage formulae.
dam = (intended damage formula); a.hp+=dam/2; dam

idk why but this not work for me, I try changing it to


a.gainHp(dam/2)


btw, sorry to say but this code will not work correctly because:

Spoiler
if enemy have earth element which take 40% of the user's element, as example the damage is 600, the enemy will takes 40% of 600 which mean about 240.


so the enemy will take 240 damage because of the earth element. 


but the user will get (1/2 * 600) which mean 300 hp. it's not fair.

Original thread: https://forums.rpgmakerweb.com/threads/not-sure-how-to-make-an-spell.57094/