LimeLouis

Villager
Member
Joined
Jul 13, 2017
Messages
21
Reaction score
2
First Language
English
Primarily Uses
RMMV
Hi, I'm working on a fangame in MV, and I'm wondering if there's any way to program a feature where you recover something like 5 or 10 MP whenever you kill any enemy during a battle.

Yes, this sort of feature also applies to normal attacks and even special attacks.

I know it sounds strange, but it's necessary for this situation (since it's a Cave Story fangame).
 

udime123

[C]reator of Axial
Veteran
Joined
Mar 29, 2018
Messages
110
Reaction score
23
First Language
English
Primarily Uses
RMMV
Depends on how willing you are to play around with plugins.

Using Yanfly's Action Sequence Packs, you can have skills in the Finish Action do something like check if the target isStateAffected(dead) and recover 10 MP to the user.
 

LimeLouis

Villager
Member
Joined
Jul 13, 2017
Messages
21
Reaction score
2
First Language
English
Primarily Uses
RMMV
That didn't really end well, as Victor's VE Basic Module plugin does not work together with the YEP Battle Core Engine..

Anything else?
 

udime123

[C]reator of Axial
Veteran
Joined
Mar 29, 2018
Messages
110
Reaction score
23
First Language
English
Primarily Uses
RMMV
That didn't really end well, as Victor's VE Basic Module plugin does not work together with the YEP Battle Core Engine..

Anything else?
Ah, fair enough.

Okay, in that case you're gonna want to do some crazy damage formula shenanigans. This thread is my best friend when it comes to this sort of thing, I pretty much have it open in a tab at all times for quick reference.

You're probably going to have to put this on every attack skill you have, but it would probably look something along the lines of
Code:
v[1] = a.atk-b.def; b.hp<==v[1] ? a.gainMP(10); a.atk-b.def;
Basically, this sets Variable 1 to equal however much damage the attack should do, then checks if the target's HP is less than that, and if it is, it'll regain 10 MP.

Unfortunately, I'm not sure how to accoint for variance, so if you have variance in your attacks, we'll need to figure out something else.
 

Joewoof

Veteran
Veteran
Joined
Oct 28, 2015
Messages
123
Reaction score
56
First Language
English
You can do this without relying on Yanfly.

First, have the skill apply a state to the enemy you hit. Also apply immortality (resist knockout).
Then, have the skill also activate a common event. Make sure this is ordered after the states.
Next, in the common event, check all enemies that are alive. If an enemy is alive & has the state, check if its HP is zero. If so, apply whatever effect you want.
Finally, remove the immortality state from all enemies.
 

LimeLouis

Villager
Member
Joined
Jul 13, 2017
Messages
21
Reaction score
2
First Language
English
Primarily Uses
RMMV
You can do this without relying on Yanfly.

First, have the skill apply a state to the enemy you hit. Also apply immortality (resist knockout).
Then, have the skill also activate a common event. Make sure this is ordered after the states.
Next, in the common event, check all enemies that are alive. If an enemy is alive & has the state, check if its HP is zero. If so, apply whatever effect you want.
Finally, remove the immortality state from all enemies.
How do you even check if the enemy's HP is zero, when it comes to common events?
 

udime123

[C]reator of Axial
Veteran
Joined
Mar 29, 2018
Messages
110
Reaction score
23
First Language
English
Primarily Uses
RMMV
I'm not sure if there's a way to get the common event to check a specific target, but if you had it check EVERY enemy, it would probably work?

But if you're using immortal enemies for a cutscene or something that might complicate things.

Maybe combining damage formulae with common events will do it?
 

Joewoof

Veteran
Veteran
Joined
Oct 28, 2015
Messages
123
Reaction score
56
First Language
English
How do you even check if the enemy's HP is zero, when it comes to common events?
Control Variables → Game Data → Enemy → HP

Then, use a Conditional Branch to compare the value to zero.

And yes, you have to go through every enemy, but only check the one that has a matching state.
 

LimeLouis

Villager
Member
Joined
Jul 13, 2017
Messages
21
Reaction score
2
First Language
English
Primarily Uses
RMMV
help.PNG
I know I'm definitely doing something wrong here..
 

Boonty

Veteran
Veteran
Joined
Oct 10, 2018
Messages
143
Reaction score
54
First Language
French
Primarily Uses
RMMV
With YEP_Skill Core, it is possible. You don't need YEP_Battle Engine to do so.


Here is a notetag that should work


<Post-Damage Eval>

if (target.hp <= 0){

user.gainMp(X);

}

</Post-Damage Eval>
 

Joewoof

Veteran
Veteran
Joined
Oct 28, 2015
Messages
123
Reaction score
56
First Language
English
If it's not working, try displaying a message to see if the conditions are activated or not.
 

LimeLouis

Villager
Member
Joined
Jul 13, 2017
Messages
21
Reaction score
2
First Language
English
Primarily Uses
RMMV
With YEP_Skill Core, it is possible. You don't need YEP_Battle Engine to do so.


Here is a notetag that should work


<Post-Damage Eval>

if (target.hp <= 0){

user.gainMp(X);

}

</Post-Damage Eval>
My project uses Skill Core, so that could possibly work!

EDIT: I tried it, but whenever I kill an enemy, it abruptly gives me this error:
"SyntaxError
Unexpected Token }"
 
Last edited:

Boonty

Veteran
Veteran
Joined
Oct 10, 2018
Messages
143
Reaction score
54
First Language
French
Primarily Uses
RMMV
Silly question but did you replace X by -5 for example ?

You can try with "value >=target.hp" instead of "target.hp <= 0 "

EDIT : I forgot a ";" after the last "}"
 
Last edited:

LimeLouis

Villager
Member
Joined
Jul 13, 2017
Messages
21
Reaction score
2
First Language
English
Primarily Uses
RMMV
Silly question but did you replace X by -5 for example ?

You can try with "value >=target.hp" instead of "target.hp <= 0 "

EDIT : I forgot a ";" after the last "}"
Yeah, I did replace X with that like "user.gainMp(5);" for example.

For some reason, it still gives me that strange Syntax Error, even if I do this.

1605283226713.png
 
Last edited:

Boonty

Veteran
Veteran
Joined
Oct 10, 2018
Messages
143
Reaction score
54
First Language
French
Primarily Uses
RMMV
Try in this order : target.hp >=0

If it doesn't work, try with "value >= target.hp" and <Pre-Damage Eval> !
 

LimeLouis

Villager
Member
Joined
Jul 13, 2017
Messages
21
Reaction score
2
First Language
English
Primarily Uses
RMMV
Try in this order : target.hp >=0

If it doesn't work, try with "value >= target.hp" and <Pre-Damage Eval> !
Still gives me the same error.
1605417770461.png

1605418107088.png
 

Attachments

  • 1605418104169.png
    1605418104169.png
    12.2 KB · Views: 1
Last edited:

Boonty

Veteran
Veteran
Joined
Oct 10, 2018
Messages
143
Reaction score
54
First Language
French
Primarily Uses
RMMV
Last edited:

LimeLouis

Villager
Member
Joined
Jul 13, 2017
Messages
21
Reaction score
2
First Language
English
Primarily Uses
RMMV

Latest Threads

Latest Posts

Latest Profile Posts

Remember to do even 0,01% progress on your game today! You can!
Watched a video of a kid in China leaning against a giant ceramic teletuby statue (valued at nearly $4000 apparently) in a toy store and everyone arguing whether it's the parents or the store's fault. I'm just sitting up wondering why anyone would make a giant ceramic toddler toy in the first place other than to deliberately cause exactly that from happening in the first place though.
Plans for vacation? Maybe I'll go visit
Taumatawhakatangihangakoauauotamateapokaiwhenuakitanatahu

Forum statistics

Threads
122,129
Messages
1,146,749
Members
160,419
Latest member
RealVirg
Top