Need help to create passive abilities

I've learned some interesting passive skills from the forum lately, so I'd like to give my characters some passive abilities, too. However, soon I found I didn't know how to implement them in MZ. Any help is appreciated.

I'm using MZ with Visustella available.

Here are the three skills I'd like to create:

1. The character gets a MAT buff for one turn after successfully performing a physical attack or skill.

2. Recovery 10 mp after receiving physical damage during the battle. This counts only when the enemy attacks or use a physical attack skill on the character.

3. If the targeted enemy has full hp, the damage it takes will become 120%.

I think I can use conditional branch in common events and attach them to every physical skill, but it would be very inefficient.
Hmmm, I tried making these without checking, so I won't guarantee that they're correct, LOL. For the passive states:

1.
<JS Post-Damage as User>
if (this.isPhysical())
user.addBuff(4, 1);
</JS Post-Damage as User>

2.
<JS Post-Damage as Target>
if (this.isPhysical() && value > 0)
target.gainMp(10);
</JS Post-Damage as Target>

3.
<JS Pre-Damage as User>
if (target.hp === target.mhp)
value *=1.2;
</JS Pre-Damage as User>
Hmmm, I tried making these without checking, so I won't guarantee that they're correct, LOL. For the passive states:

1.
<JS Post-Damage as User>
if (this.isPhysical())
user.addBuff(4, 1);
</JS Post-Damage as User>

2.
<JS Post-Damage as Target>
if (this.isPhysical() && value > 0)
target.gainMp(10);
</JS Post-Damage as Target>

3.
<JS Pre-Damage as User>
if (target.hp === target.mhp)
value *=1.2;
</JS Pre-Damage as User>
Thank you so much. I've tried all of them and they all worked.
I have some further questions if you don't mind.

Is there any reference that I can study to customize these codes?
Are they just javascript+MV/MZ scriptcalls?

For 1:
It seems directly applying a MAT buff to my battler, but where can I find the buff in database so I can customize the value? It seems not in my STATES page.

Also, when the buff is applied, animation 53 is displayed. Is this from battlecore? Can I change or delete it?

For 2:
With the code, currently my battler gets damage(white digits) and recover mp(blue digits) at the same time. Is it possible to delay mp gaining for a while? I tried to do like below, but it worked strangely.

<JS Post-Damage as Target>
if (this.isPhysical() && value > 0)
this.wait(60);
target.gainMp(10);
</JS Post-Damage as Target>
There's a thread here called rpg maker script calls or something, where there's a link to an excel with a lot of scriptcalls. You can also open the js files in the game folder and see what's inside.

As for your other questions, you need to ask someone else LOL. I think you need a plugin to modify buffs? And does rpg maker normally play an animation on buff apply? Maybe some of your plugins is causing that...Also, I'm not sure how you can delay the popup - I thought that'd you'd have to request it in the first place with a script if you wanted to see it...
There's a thread here called rpg maker script calls or something, where there's a link to an excel with a lot of scriptcalls. You can also open the js files in the game folder and see what's inside.

As for your other questions, you need to ask someone else LOL. I think you need a plugin to modify buffs? And does rpg maker normally play an animation on buff apply? Maybe some of your plugins is causing that...Also, I'm not sure how you can delay the popup - I thought that'd you'd have to request it in the first place with a script if you wanted to see it...
Thank you for replying. I've checked the scriptcall list and done some search. Now I figured out how buff/debuff works. I'll use addstate so that the multiplier can be controlled.

I went back to check battlecore again. It turns out the damage/recover popup is hardcoded in battlecore, so I'll just leave them though.

Thank you so much, rpgLord69.
It seems directly applying a MAT buff to my battler, but where can I find the buff in database so I can customize the value? It seems not in my STATES page.
Buffs aren't states, they're buffs. If you want to customize the value, use a state with the appropriate trait instead.

The way buffs work is in MZ's instructions, in the Effects section.
1711349960360.png


Also, when the buff is applied, animation 53 is displayed. Is this from battlecore? Can I change or delete it?
Yes, check the plugin parameters. (it's always a good idea to read all the plugin parameters when you install a new plugin)

With the code, currently my battler gets damage(white digits) and recover mp(blue digits) at the same time. Is it possible to delay mp gaining for a while? I tried to do like below, but it worked strangely.
That's not correct JavaScript. There is no this.wait() for actions.

The easy way to do this would be to take the mp gain out of the skill; instead, apply a state, and give that state a notetag for the regeneration phase that gains 10 mp and removes itself.
Thank you for replying. I've checked the scriptcall list and done some search. Now I figured out how buff/debuff works. I'll use addstate so that the multiplier can be controlled.
visustella skills and states provide parameters to change how buffs and debuffs work, but modifying them without it isnt a hard process.
And does rpg maker normally play an animation on buff apply?
if the same plugin mentioned is being used, it does allow evals to be ran on buff/debuff application. it might be a default parameter option to play an animation?
Thank you all, @rpgLord69, @ATT_Turan, and @Robro33, After two days, I make my first passive ability work.

The animation 53 comes from VS's Visual State Effects plugin for buffs/debuffs. Since I change to use state instead of buff, it's fine now.

I tried every script call for "wait" I could find from the MV/MZ script call spreadsheet, but no one seems to work, as @AAT_Turan said, there's no this.wait() for actions. Therefore, I put the addState in another... phase/step/stage(not sure what's the right term), and it worked.

Here is the code for "magic buff after being attacked physically" and "ATK buff after being attacked by magic". I'm sure the code can be shortened, but don't know how. I think this code contains things from javascript, RMMZ, and Visustella, which is kinds hard for me because I'm not familiar with any of them.
Spoiler
<JS Post-Damage as User>
if (this.isPhysical()) {
$gameSwitches.setValue(1, true);
}

if (this.isMagical()) {
$gameSwitches.setValue(2, true);
}
</JS Post-Damage as User>


<JS Pre-End Action>
if ($gameSwitches.value(1)) {
user.addState(52);
$gameSwitches.setValue(1, false);
$gameVariables.setValue(42, 2);
}

if ($gameSwitches.value(2)) {
user.addState(53);
$gameSwitches.setValue(2, false);
$gameVariables.setValue(43, 2);
}
</JS Pre-End Action>


<JS Pre-End Turn>
$gameVariables.setValue(42, $gameVariables.value(42) - 1);
if ($gameVariables.value(42) == 0) {
user.removeState(52);
}

$gameVariables.setValue(43, $gameVariables.value(43) - 1);
if ($gameVariables.value(43) == 0) {
user.removeState(53);
}
</JS Pre-End Turn>

I'm working one the second ability, getting mp after being attacked physically, but this time the code from above didn't work. The battler wouldn't gain mp if the .gainMp was in Pre-End Action. I think the problem is related to enemy's turn.

Spoiler
<JS Post-Damage as Target>
if (this.isPhysical() && value > 0) {
$gameSwitches.setValue(3, true);

//store last-attacked-by-the-enemy battler's ID into variable 8.
$gameVariables.setValue(8, BattleManager._targets[BattleManager._action._targetIndex+1].actorId());
}
</JS Post-Damage as Target>

<JS Pre-End Action>
if ($gameSwitches.value(3)) {
$gameActors.actor($gameVariables.value(8)).gainMp(10);
$gameSwitches.setValue(3, false);
}
</JS Pre-End Action>
Here is the code for magic buff after being attacked physically/ATK buff after being attacked by magic.
I'm trying to read through this and it doesn't make any sense compared to your description.

- You start with a Post-Damage as User, which means it has nothing to with being attacked, but only when performing an attack. Which is it supposed to be?

- I don't at all understand the point of putting stuff in three different tags for the same ability

- I also don't understand the point of adding the state in Pre-End Action and removing it in Pre-End Turn. The battler doesn't do anything in that time period, so the state will never have any effect (unless it's supposed to be a defense improvement for the rest of the turn or something).

- If you're putting all of these notetags in one place, that's why it doesn't work - JS Pre-End Turn is not a Skill notetag. There's no way for a skill to still be doing something at the end of the turn.
1711544603292.png


I'm sure the code can be shortened, but don't know how. I think this code contains things from javascript, RMMZ, and Visustella, which is kinds hard for me because I'm not familiar with any of them.
There aren't all those distinctions - the programming language used is JavaScript. The only thing that has to do with VisuStella are the notetags you chose.

//store last-attacked-by-the-enemy battler's ID into variable 8.
$gameVariables.setValue(8, BattleManager._targets[BattleManager._action._targetIndex+1].actorId());
Where on Earth did you come up with this? It's entirely incorrect - you would simply use target.actorId()

But I also don't see any point in storing the target's actor ID in a variable to use later, MZ already does that automatically with the Last Target Actor ID. You don't need to use any notetags or code for this at all, just attach a common event to the skill.

1711544867475.png
- You start with a Post-Damage as User, which means it has nothing to with being attacked, but only when performing an attack. Which is it supposed to be?
I use "Post-Damage as User" as from post #2, rpgLord69 showed me the notetag. It seems reasonable to use Post-Damage because this.isPhysical() is used in the notetag. I think the damage type can only be determined after the damage is dealing or dealt? Is it fine to use the notetag for such passive ability, or it might cause some problem?

- I don't at all understand the point of putting stuff in three different tags for the same ability

- I also don't understand the point of adding the state in Pre-End Action and removing it in Pre-End Turn. The battler doesn't do anything in that time period, so the state will never have any effect (unless it's supposed to be a defense improvement for the rest of the turn or something).
I did it for controlling the timing when the state is applied at.

Due to Visustella, adding and removing states have popups. When my passive ability is triggered, the enemy's damage popup and the state adding popup for the attacker show up almost at the same time(Visustella Battlecore makes the attacker go to the target) and it's a little not easy to read the information. Beside, you said "There is no this.wait() for actions" and I've tried every scrip call I could find to "wait", but none of them worked. That's why I tried to find a way for the popups showing at different timing, by using different notetags.

- If you're putting all of these notetags in one place, that's why it doesn't work - JS Pre-End Turn is not a Skill notetag. There's no way for a skill to still be doing something at the end of the turn.
1711544603292.png
I put the notetag in Actor, so "Skill" can be avoided.

//store last-attacked-by-the-enemy battler's ID into variable 8.
$gameVariables.setValue(8, BattleManager._targets[BattleManager._action._targetIndex+1].actorId());
Where on Earth did you come up with this? It's entirely incorrect - you would simply use target.actorId()
Oh, I found it in another thread. haha. My knowledge of MZ is still not enough for me to read the whole line, so I just tried to use it. I'll try your code for sure.

But I also don't see any point in storing the target's actor ID in a variable to use later, MZ already does that automatically with the Last Target Actor ID. You don't need to use any notetags or code for this at all, just attach a common event to the skill.

1711544867475.png
Does it mean I have to attach to all my physical attacking skills? All my attacking skills use action sequence. That means all of them already have a common event attached. Is two common events attached to one skill fine?

Thanks for your reply, @ATT_Turan. Every time I read your post, I learn something. 😀
I use "Post-Damage as User" as from post #2, rpgLord69 showed me the notetag
yes. they used it for the passive that you wanted to trigger as the battler with the state does an attack. they also used <JS Post-Damage as Target> for the passive that's supposed to trigger after being hit. If youre trying to make a passive that does something as the battler is hit, you dont want to use the "as user" tag.. the help file has clarifications for what the tags do

//store last-attacked-by-the-enemy battler's ID into variable 8.
$gameVariables.setValue(8, BattleManager._targets[BattleManager._action._targetIndex+1].actorId());
...
$gameActors.actor($gameVariables.value(8)).gainMp(10);
...
Does it mean I have to attach to all my physical attacking skills? All my attacking skills use action sequence.
you could try changing your passive to store the "target" itself as the variable and run gainMp on that in the end instead

Original thread: https://forums.rpgmakerweb.com/threads/need-help-to-create-passive-abilities.167089/