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

Just a dev who actually got a game finished
Veteran
Joined
Dec 9, 2017
Messages
1,166
Reaction score
1,426
First Language
English
Primarily Uses
RMMV
@Frankster300 Yanfly's Skill Core plugin could/should cover that I believe.
 

lokirafael

Veteran
Veteran
Joined
Jun 25, 2012
Messages
152
Reaction score
77
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.isHit() (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.isHit() (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
152
Reaction score
77
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
152
Reaction score
77
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
152
Reaction score
77
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!
 

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

Latest Threads

Latest Profile Posts

Finally the new pc is working!! But it seems a lost my license to Windows 10 because of the hardware changing :(
Tune in next time for our newest Episode: "PC issues return! Palm uses every swear in the lexicon!"
gotta update my game project thread page later
So trying out Ultra Mode 7 was a bad idea. How do I not include this in my game? XD
Stumbled upon an RPG Maker game on Steam called 'Boobs vs Zombies' while looking for a zombie themed fantasy RTS. lol

Forum statistics

Threads
93,553
Messages
913,421
Members
123,091
Latest member
ZaGorudan
Top