25% Chance to gain 25% MP after a successful "Attack"

Frankster300

Programmer/Game Designer
Member
Joined
Mar 29, 2018
Messages
24
Reaction score
12
First Language
English
Primarily Uses
RMMV
Ok, this is going to get complicated very fast...

Heres what i want:

On every "Attack" action on a specific character:
If the attack deals damage, the user who uses this action has a 25% chance to gain 25% of their own maximum mp back.

In theory, i also want this to work if a "Attack" action hits multiple targets. So each target will have its own individual 25% chance.
I dont mind if the user hits a target twice, the user gains two 25% chances... But if theres a way to make this happen once, id rather have this effect proc once on one enemy.

I dont want this effect to proc on magical/certain attacks or skills. Just on one skill, on one character, and this "Attack" skill will change over time.

and finally, i also want this effect to be placed as close to the character as possible, like in the character itself or the characters class.

I have an idea on how to do this... but i just want some input from the forums to see if theres a better way to do this.

I also have no problem downloading Yanfly's Plugins, now that im getting used to them lol.

Thank you, Frank
 

JtheDuelist

Your Friendly Nieghborhood Stygian Zinogre
Veteran
Joined
Dec 9, 2017
Messages
1,185
Reaction score
1,440
First Language
English
Primarily Uses
Other
@Frankster300 Yanfly's Skill Core plugin could/should cover that I believe.
 

lokirafael

Veteran
Veteran
Joined
Jun 25, 2012
Messages
153
Reaction score
80
First Language
Portuguese
Primarily Uses
RMMV
I'm away from my PC and the Maker, so I can't test it right now. Anyway I don't get what you mean with "Attack" that is not a skill.

You could try something like (Using Yanfly Skill core):

Code:
<Post-Damage Eval>
var ChanceRate = 0.25;
var GainMP = user.mmp * 0.25
if (this.isAttack() && Math.random() < ChanceRate) {
    user.gainMP(GainMP)
}
</Post-Damage Eval>
Just change the formula code around to get the desired effect. I don't know how multiple hits will be calculated. You can use some custom conditions like "!action.isSkill()" (Check if the its not a skill) or result.i****() (Check if the skill landed).
 

Frankster300

Programmer/Game Designer
Member
Joined
Mar 29, 2018
Messages
24
Reaction score
12
First Language
English
Primarily Uses
RMMV
Just change the formula code around to get the desired effect. I don't know how multiple hits will be calculated. You can use some custom conditions like "!action.isSkill()" (Check if the its not a skill) or result.i****() (Check if the skill landed).
Do i just post this in the notes section? Or would i have to dig till i find the location?
 

lokirafael

Veteran
Veteran
Joined
Jun 25, 2012
Messages
153
Reaction score
80
First Language
Portuguese
Primarily Uses
RMMV
Do i just post this in the notes section? Or would i have to dig till i find the location?
You need the Skill Core plugin from yanfly. Just copy the eval I gave in the skill notebox.
 

Frankster300

Programmer/Game Designer
Member
Joined
Mar 29, 2018
Messages
24
Reaction score
12
First Language
English
Primarily Uses
RMMV
You need the Skill Core plugin from yanfly. Just copy the eval I gave in the skill notebox.
Yes but WHERE do i put it? Im assuming its in the notes section... Let me play around with this

The single attack skill goes to everyone, for example. If i put it there, then everyone using this attack skill would have this buff... but if i put this in the character/class, then all skills and damage would prock this passive...

Is the this.isAttack() classifying that its dealing damage, or the fact that it is that is the default attack when using the "attack" command when in battle.

(Like when you use the default plugin "WeaponSkill", it changes the skill id of the attack command, is that "this.isAttack()"?)

Sorry im being nit-picky, its been a long day lol
 
Last edited:

lokirafael

Veteran
Veteran
Joined
Jun 25, 2012
Messages
153
Reaction score
80
First Language
Portuguese
Primarily Uses
RMMV
this.isAttack() = Basic Atack (Skill 1).

If you are using a special skill as attack then you don't need it. You can just create a Skill and use http://yanfly.moe/2015/12/26/yep-51-weapon-unleash/ to create a custom basic attack. Or you can make the eval check if actor x is using the command Attack.

I'm terrible explaining. I can work the code, but explaining is not my forte.
 

Frankster300

Programmer/Game Designer
Member
Joined
Mar 29, 2018
Messages
24
Reaction score
12
First Language
English
Primarily Uses
RMMV
Ok, this is closer to what i want... Everything is perfect but one thing... A weapon unleash replaces the skill entirely, where in this case i just want the 25% of 25 MP % to proc. Any Ideas?

Let me try something... i think i know what to do now...

Edit: Nope, didnt work... I tried to call a common event with multiple forced actions, but since one of the actions are going to change, it dosen't matter anyways -_-'.
 
Last edited:

Frankster300

Programmer/Game Designer
Member
Joined
Mar 29, 2018
Messages
24
Reaction score
12
First Language
English
Primarily Uses
RMMV
Backtracking now, I'll try to simplify what im asking:

I want a passive that has a 25% chance to gain 25% mana/mp back to the user whenever their base attack lands a hit.

This effect is only on one character, and only this character.

Using skills or attacks other then this base attack wont proc the passive, and for examples sake, by default the "base attack skill" of a character is skill 0001.

If this skill misses, but is used, then the passive does not proc. Multiple opponents trigger this passive multiple separate times, and hitting a single target with multiple attacks does not proc this passive more then once.

Example 1: Out of three targets, if one target is struck, and two other targets are misses, then the passive procs once.
Example 2: Striking one target multiple times only procs the passive once.
Example 3: Out of three targets, striking every target multiple times procs the passive only three times.

I also want to the ability to change this base attack skill by equipping a weapon. Yanfly's Weapon Unleash is a great example of what i want.

Problems: Placement of Passive
- On a specific skill or weapon: Other weapons and skills cant be swapped, and if you place the passive on every weapon, any character can use it now.

This means i need to place it on the character or class, but i need the value ID of the "Basic Attack" i switch to when im switching the attack with weapons i want...

Logically @lokirafael Your code should work as long as the if command has this:

If: "Base Attack" Skill is used, result is a hit, is on a unique enemy, and is on the first hit
- You give the mana, add some value to make "is on the first hit" false
- When the entire thing runs, before ending, it makes "is on the first hit" true

I dont know how to translate that to java script, using yanfly's variables for the code... This is becoming a project on itself!
 

lokirafael

Veteran
Veteran
Joined
Jun 25, 2012
Messages
153
Reaction score
80
First Language
Portuguese
Primarily Uses
RMMV
Then you will need:

http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/
http://yanfly.moe/2015/10/17/yep-13-auto-passive-states/

1° - Create a passive and insert the following in the notes section:
Code:
<Custom Establish Effect>
ChanceRate = 0.99;
Gain_MP = user.mmp * 0.25
if (this.isAttack() && Math.random() < ChanceRate) {
    user.gainMp(Gain_MP);
    user.startDamagePopup();
    user.clearResult();
}
</Custom Establish Effect>
2° Insert the following in the actor note section:

Code:
<Passive State: x>
Being X the passive ID you created.

For sake test i put a 99% chance of the effect happen. Just change the 0.99 (99%) to 0.25 (25%) in the code.

What it will do: If the affected actor hit a sucefull basic hit "Attack comand" he has a chance to recover 25% of his MAX MP.
 

Frankster300

Programmer/Game Designer
Member
Joined
Mar 29, 2018
Messages
24
Reaction score
12
First Language
English
Primarily Uses
RMMV
Then you will need:

1° - Create a passive and insert the following in the notes section:
Code:
<Custom Establish Effect>
ChanceRate = 0.99;
Gain_MP = user.mmp * 0.25
if (this.isAttack() && Math.random() < ChanceRate) {
    user.gainMp(Gain_MP);
    user.startDamagePopup();
    user.clearResult();
}
</Custom Establish Effect>

For sake test i put a 99% chance of the effect happen. Just change the 0.99 (99%) to 0.25 (25%) in the code.

What it will do: If the affected actor hit a sucefull basic hit "Attack comand" he has a chance to recover 25% of his MAX MP.
IT WORKS! 3 DAYS AND IT WORKS!!! I can stop now and ill be happy! BUT! Im going to play with this a bit and see if i can make it where if it the effect procs, it wont run again and will clear when its all over. If you want to add that then thats cool, but thank you for what you gave me so far!
 

starkprime

Villager
Member
Joined
Apr 25, 2020
Messages
21
Reaction score
0
First Language
english
Primarily Uses
Other
I'm trying to do a similar thing. Add a passive state to an actor that gives him a chance to apply slow state to an enemy. my slow state is state 25 and i added the passive to my actor. I also tried the $game.troops call but that didnt work either. my character does just a normal attack. i can post screens if needed. See anything wrong?

<Custom Establish Effect>
ChanceRate = 0.99;

if (this.isAttack() && Math.random() < ChanceRate) {
target.addState(25)
}
</Custom Establish Effect>
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Are we allowed to post about non-RPG Maker games? And, if so, would any of you be interested in a short, proof of concept type non-euclidian puzzle game?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:

Forum statistics

Threads
105,883
Messages
1,017,234
Members
137,608
Latest member
Arm9
Top