A few questions about how to make certain skill effects.

6. How can I make a skill which transfers MP from one actor to another actor?
6. Link the skill to a common event that checks how much MP the user has and store the value in a variable (best way is to check the user is to create a separate version for each character and swap it in combat according to method 1, if it's a skill that can be used by everyone). Then, check for the target of the skill (have the skill apply an invisible state which will act like a check) and then add MP equal to the value in the variable, and remove MP from the user. Afterwards, remove the invisible state.
Isn't there a built-in MP drain function in the engine?

8. This is more about a state than a skill itself. How can I make a state that *increases* the enemy encounter rate? The database has options to decrease or eliminate encounters, but I don't see an option to increase it.
This doesn't exist. You would need a plugin that implements the functionality.

Though.... hmmm... now as I'm sitting here typing this and thinking about it... do they REALLY have to be the same skill....? Wouldn't there be some way to make the spellbook items check which actor the item is being used on, and then teach them their version of the skill? I mean, I don't know how I would do that... but isn't that a possibility? The problem is that there can be only ONE of each spellbook, and they have to be able to teach every applicable actor that skill. So if we have a Fire Book, that item needs to be able to teach the Fire spell to Actors A, B and D, but not Actor C. I don't want to have 3 different Fire Book items for 3 different, specific actors, y'know? But yeah, this all makes me think that maybe I've been going about this the wrong way...
Thanks, though I already have a plugin from @ATT_Turan that restricts the item usage to specific actors. The problem is that, if I wanted to use multiple versions of a skill (to more easily control what each actor can do with their skills), I think I would need for the item to be able to check which Actor that it is being used on, so that it knows which version of a skill to teach them.
Maybe that's just what I'll do then! I'll rework it so that each character does indeed have unique skills, and certain characters have better versions of those skills. Then I'll just make the skill-teaching items check for which actor it's being used on, and give them the appropriate skill!
While having the book item check the actor to determine which spell to teach is one approach, there is another option. You already have a plugin to limit a skill to certain actors. Presumably spells that an actor can't use won't be listed at all. Therefore, the book item could simply teach every version of the spell. Actor A would know "Fire (A)" and "Fire (😎" but can only cast "Fire (A)", so the player never sees that they also have "Fire (😎". Similarly, Actor B would know both but can only cast "Fire (😎". I think that might be easier than the conditional teaching approach.
If you don't want to give players the chance to set encounter rates by option, I would agree that replicating the Whistle skill is a better way to go.

Guess that's what I'll do then. I think it might be better this way, actually.

I didn't mean to say that it was a problem.
In this case, if you want your skill to deal 120% of its normal damage in "situation X", then you could express that in your skills damage formula with a relatively simple pattern:
(Original Formula) * (SituationX ? 1.2 : 1)

If you want your skill to deal extra damage in the amount of 20% of the skills base damage but without the targets elemental affinity (or maybe other modifiers) then the pattern would become more intricate as you'd have to calculate these effects out (as one possible solution):
(Original Formula) * (SituationX ? (ElementRate + 0.2) / ElementRate : 1)

It wasn't entirely clear to me from your opening post if you actually needed that extra complexity.

Instead of
b.elementRate(2) > 1
you can also use
this.calcElementRate(b) > 1
to check if the target is weak to the skills element. This alternative works without you having to enter the specific element again (in case your skill has multiple elements or if you want to apply the condition to different skills).


If you look through the suggestions in the "Damage Formulas 101" thread ATT_Turan linked you'll find a lot of examples that use the damage formula for custom effects not (entirely) related to damage calculation. I was kind of tired when I wrote the footnote, but these were the kind of effects I meant.^^

Generally this works fine if you don't mind the extra code taking up space in the formula window (or if you use Ahuramazdas approach and move the code) and don't plan to make use of the Autobattle trait or plugins featuring a damage preview or elaborate enemy AI by relying on calculating the skills damage for evaluation.

The Battle Core example just provides an alternative space to put these effects in without cramping the formula window or disrupting eventual skill assessments if that is something you prefer.

I don't know if it is still relevant, but you should be able to add any of the skill effects with variable parameters using this pattern:
Code:
<JS Post-Apply>
if (b.result().isHit()) {
  let effect;
 
  effect = {};
  effect.code = Game_Action.EFFECT_GROW;
  effect.dataId = 0;
  effect.value1 = 15;
  effect.value2 = 0;
  this.applyItemEffect(b, effect);

}
</JS Post-Apply>
effect.code => You can find the possible skill effect codes in "rmmz_objects.js" in the /js folder of your project, line 1390-1402. You can use either the constants name or the assigned numerical value here:
Spoiler
Game_Action.EFFECT_RECOVER_HP = 11;
Game_Action.EFFECT_RECOVER_MP = 12;
Game_Action.EFFECT_GAIN_TP = 13;
Game_Action.EFFECT_ADD_STATE = 21;
Game_Action.EFFECT_REMOVE_STATE = 22;
Game_Action.EFFECT_ADD_BUFF = 31;
Game_Action.EFFECT_ADD_DEBUFF = 32;
Game_Action.EFFECT_REMOVE_BUFF = 33;
Game_Action.EFFECT_REMOVE_DEBUFF = 34;
Game_Action.EFFECT_SPECIAL = 41;
Game_Action.EFFECT_GROW = 42;
Game_Action.EFFECT_LEARN_SKILL = 43;
Game_Action.EFFECT_COMMON_EVENT = 44;
effect.dataId => The database ID of the operated entry, otherwise the position in the drop down menu (in these cases starting at index 0)
effect.value1 => The value of the numerical field (in case of a percentage: 1.0 equals 100%)
effect.value2 => The value of the second numerical field (only used for Recover HP/MP effects)
As this is in Javascript, you could go to any length to determine these values.

In this example, you have the skill effect for increasing MHP by 15. Value2 is not used for this particular effect and the line could be removed here.


The Battle Core also allows you to add these pre-apply, pre-damage, post-damage or post-apply effects to your actors directly with a slightly different notetag-name instead of a specific skill, in case you want an effect to apply to all skills that actor uses (as maybe an alternative to the Skills&States Core solution).

Noted!
Isn't there a built-in MP drain function in the engine?


This doesn't exist. You would need a plugin that implements the functionality.




While having the book item check the actor to determine which spell to teach is one approach, there is another option. You already have a plugin to limit a skill to certain actors. Presumably spells that an actor can't use won't be listed at all. Therefore, the book item could simply teach every version of the spell. Actor A would know "Fire (A)" and "Fire (😎" but can only cast "Fire (A)", so the player never sees that they also have "Fire (😎". Similarly, Actor B would know both but can only cast "Fire (😎". I think that might be easier than the conditional teaching approach.

Yeah but the MP drain would have to go backwards, no? If I just set a skill to MP drain and aimed it at an ally, it would eat the target's MP, when I want it to be the other way around. I want the user to gift MP to the targeted ally.

Can't have it just outright teach every version of the spell because I need all skills to go into one category. The conditional teaching thing works, by the way, I just tried it... but I've run into another little issue...

firetestbook.png



Here's the common event and item respectively. However, when I use the item on the actors... I run into a couple problems...

1. It no longer stops actors that already know the skill from learning it again (and therefore consuming the item). After taking that screenshot, I tried to make a conditional branch inside each branch which checks if the actor knows the skill, but regardless of what I put in the conditional branch, it still consumes the item.

2. Another problem is that as soon as the item is consumed and the skill is learned, it completely closes the entire menu, rather than returning to the item menu. This could be a problem if a player wants to teach multiple skills to their party one after the other.

3. On the flipside, it DOES currently recognize that some actors cannot learn the skill and plays the error buzzer when trying to use the item on them.

So uh... what should I do?
Yeah but the MP drain would have to go backwards, no? If I just set a skill to MP drain and aimed it at an ally, it would eat the target's MP, when I want it to be the other way around. I want the user to gift MP to the targeted ally.
Ahh, I understand now. Your original post didn't make that clear.

I haven't looked at the code, but it might be possible to set a negative drain or something and have that work. The engine (or the editor) might not let that happen though. Still, it could be worth a try if you don't already have something working.
Can't have it just outright teach every version of the spell because I need all skills to go into one category. The conditional teaching thing works, by the way, I just tried it... but I've run into another little issue...
Yes, that's true if category is the only way to determine which actor can use and see each spell. However, you mentioned that you have an add-on that allows hiding specific spells from specific actors. Unless I misunderstood how that works, it would allow you to put all the spells in one category and have the book teach every version of the spell.
Yeah but the MP drain would have to go backwards, no? If I just set a skill to MP drain and aimed it at an ally, it would eat the target's MP, when I want it to be the other way around. I want the user to gift MP to the targeted ally.
I actually have a skill in my game called MP Gift that does exactly this. I needed a Yanfly plugin to achieve it, but if you happen to use VisuStella's Battle Core, you already have access to the notetag you would need. You'd use a variable in your damage formula and make that variable the custom MP cost for the user.

So, say you had the following as your damage formula: v[1] = a.mp/2

Then the following notetag:

<JS Post-Damage>
a.gainMp(-v[1])
</JS Post-Damage>

If it works like I hope it does, the skill's user will give half their MP to the targeted ally, while correctly using half their MP as the cost. If you have another way that works (and if you don't use the Battle Core), then great. Just thought I'd throw this alternative out there since I use it myself.

1. It no longer stops actors that already know the skill from learning it again (and therefore consuming the item). After taking that screenshot, I tried to make a conditional branch inside each branch which checks if the actor knows the skill, but regardless of what I put in the conditional branch, it still consumes the item.
You might have did you common event wrong, because I got it to work perfectly. Pretty sure the following will be the same in MZ, so refer to the spoiler below:
Spoiler: Common Event setup
First, the conditional that checks for the actor

1659230987406.png


Next, right beneath that branch, we make another conditional branch.
1659231077749.png


Don't forget to create an else branch here too. This is how we'll make sure the skill book is refunded. The full common event looks like this:

1659231172358.png


The explanation is as follows: If the item's target is Actor 2 and they know the Firebolt spell, give the player the skill book they used. If the target is Actor 2 but they don't know the Firebolt spell, teach them the spell. Book will be used up like any other consumable.

2. Another problem is that as soon as the item is consumed and the skill is learned, it completely closes the entire menu, rather than returning to the item menu. This could be a problem if a player wants to teach multiple skills to their party one after the other.
I use a plugin to get around this, but I don't know if MZ has an equivalent one. I can throw you a link to what I use if you want to see if it'll work in MZ.
Ahh, I understand now. Your original post didn't make that clear.

I haven't looked at the code, but it might be possible to set a negative drain or something and have that work. The engine (or the editor) might not let that happen though. Still, it could be worth a try if you don't already have something working.

Yes, that's true if category is the only way to determine which actor can use and see each spell. However, you mentioned that you have an add-on that allows hiding specific spells from specific actors. Unless I misunderstood how that works, it would allow you to put all the spells in one category and have the book teach every version of the spell.

It doesn't hide the spells, it just won't let you use the item at all on an invalid actor. Like if you try and use a Fire Book on the Knight, it won't let you.

I actually have a skill in my game called MP Gift that does exactly this. I needed a Yanfly plugin to achieve it, but if you happen to use VisuStella's Battle Core, you already have access to the notetag you would need. You'd use a variable in your damage formula and make that variable the custom MP cost for the user.

So, say you had the following as your damage formula: v[1] = a.mp/2

Then the following notetag:

<JS Post-Damage>
a.gainMp(-v[1])
</JS Post-Damage>

If it works like I hope it does, the skill's user will give half their MP to the targeted ally, while correctly using half their MP as the cost. If you have another way that works (and if you don't use the Battle Core), then great. Just thought I'd throw this alternative out there since I use it myself.


You might have did you common event wrong, because I got it to work perfectly. Pretty sure the following will be the same in MZ, so refer to the spoiler below:
Spoiler: Common Event setup
First, the conditional that checks for the actor

View attachment 236193

Next, right beneath that branch, we make another conditional branch.
View attachment 236194

Don't forget to create an else branch here too. This is how we'll make sure the skill book is refunded. The full common event looks like this:

View attachment 236195

The explanation is as follows: If the item's target is Actor 2 and they know the Firebolt spell, give the player the skill book they used. If the target is Actor 2 but they don't know the Firebolt spell, teach them the spell. Book will be used up like any other consumable.


I use a plugin to get around this, but I don't know if MZ has an equivalent one. I can throw you a link to what I use if you want to see if it'll work in MZ.

Yeah, it's not working as intended, and I'm not sure why...

Maybe I should just scrap the idea of having certain Actors be better at certain spells than other actors...
Yeah, it's not working as intended, and I'm not sure why...
Do you use the Battle Core? If not, that would be why. If you do, let me see your common event.
Do you use the Battle Core? If not, that would be why. If you do, let me see your common event.

I do use the Battle Core. Here's the event I made. Though I didn't finish writing it out for every character since it didn't work right for the first one.

1659485893842.png
Please don't scrap the idea! 🙂 I think you might have misunderstood the complexity of what people are trying to tell you to do in some of the earlier posts. If all you want is for one character to deal 20% more damage than another character when using a skill, you have to do a single edit in one place for that skill.

In your skill, in the Damage field, add the following to your formula:

Code:
 * (a.actorId() == 1 ? 1.2 : 1 )

For example,
Code:
a.atk * 3 - b.def * 2

would become
Code:
(a.atk * 3 - b.def * 2) * (a.actorId() == 1 ? 1.2 : 1 )

This will make Actor 1's attack 20% stronger. An easy way to test this out is to use 100% and 0% as variables:

Code:
(a.atk * 3 - b.def * 2) * (a.actorId() == 1 ? 1 : 0 )

Using this skill will be 0 for all Actors except Actor 1. If you want to change actor, simply change the number you check with, for Actor 2 it would be:

Code:
a.actorId() = 2

There are a lot of other things you can check for if you read the Damage Formula 101 linked earlier. I really do suggest reading it, as others have. It's a great way to learn. Keep pushing!

Original thread: https://forums.rpgmakerweb.com/threads/a-few-questions-about-how-to-make-certain-skill-effects.149890/