Casting Effectiveness for Elemental Spells for Specific Classes

I am trying to make the different magic-using classes specialise in a couple of elements per class. Elemental resistance is easy, but I would like to make classes better at casting spells using their elements than the other classes. For instance, I want Mages to be able to cast Fire and Ice spells more effectively than Wizards and Sorcerers of the same level.

I have tried playing with Himeworks' Formulae Effects plugin. I can make spells work better for one class more than others, but the damage done is purely by hit points. In my game, bats are very vulnerable to wind, but resistant to earth. Using the Himeworks plugin, Mages do similar damage to bats with “Stone” as they do with “Blast of Wind”.

Has anyone got any ideas?

EDIT: The only thing that I can think of (and it is a clumsy solution) is to give selective access to slightly more effective spells with similar MP cost.
This feels a bit vague, what does "better at casting spells" mean?
Does it refer to the damage done by the skills or the cost?
Or is there something else you want to be influenced by elemental rate?
As long as your spells have a fixed element, a nice workaround for this would be using fake attack elements. So you would have, for instance, both a "Fire" and "Fire Attack" element, and use the latter exclusively to multiply the damage in your fire spell formulas:
(original formula) * a.elementRate(5)

I'm pretty sure there are plugins for this too.

Edit: TobyYasha has a point
if all the class bonus does is increase the damage of the spell, then why not just have the spell just do more damage if the caster is the right class as a part of the formula? something like
Code:
a.isActor() && a._classId == 3 ? a.mat * 2 : a.mat
or
(a.mat*4 - a.mdf*2) * a.isActor() && a._classId == 3 ? 1.5 * 2 : 1
Thank you for your replies, everyone.
This feels a bit vague, what does "better at casting spells" mean?
Does it refer to the damage done by the skills or the cost?
Or is there something else you want to be influenced by elemental rate?
By "better at casting spells" I mean that a specific class does more damage using a specific skill than other magic users of similar level. So a Mage would do better with "Finger of Flame" than a Wizard, but the Wizard would do better than the Mage casting "Blast of Wind", assuming that the target was equally vulnerable to Fire and Wind.
As long as your spells have a fixed element, a nice workaround for this would be using fake attack elements. So you would have, for instance, both a "Fire" and "Fire Attack" element, and use the latter exclusively to multiply the damage in your fire spell formulas:
(original formula) * a.elementRate(5)

I'm pretty sure there are plugins for this too.

Edit: TobyYasha has a point
I appreciate your input, and hope that I understand it. If not, I apologise. It is a feature of my game that many of the enemies are more vulnerable to some elements than others. For instance, bats are set to have an Element Rate of 200% for Wind, but 50% for Water, which means that spells doing Wind Damage do a lot more damage to bats than spells doing Water damage. I am very keen to keep the difference in vulnerabilities to damage by different elements.
Not sure I understand your suggestion about fake elements.
The Himeworks plugin I mentioned does let you give bonuses to actors of specific class(es), but unfortunately bypasses the enemy resistance to the damage element.
if all the class bonus does is increase the damage of the spell, then why not just have the spell just do more damage if the caster is the right class as a part of the formula? something like
Code:
a.isActor() && a._classId == 3 ? a.mat * 2 : a.mat
or
(a.mat*4 - a.mdf*2) * a.isActor() && a._classId == 3 ? 1.5 * 2 : 1
Thank you very much. This looks very promising. I didn't know that you could use such code in the skill formula. I will have a play!
Thank you for your replies, everyone.

By "better at casting spells" I mean that a specific class does more damage using a specific skill than other magic users of similar level. So a Mage would do better with "Finger of Flame" than a Wizard, but the Wizard would do better than the Mage casting "Blast of Wind", assuming that the target was equally vulnerable to Fire and Wind.

I appreciate your input, and hope that I understand it. If not, I apologise. It is a feature of my game that many of the enemies are more vulnerable to some elements than others. For instance, bats are set to have an Element Rate of 200% for Wind, but 50% for Water, which means that spells doing Wind Damage do a lot more damage to bats than spells doing Water damage. I am very keen to keep the difference in vulnerabilities to damage by different elements.
Not sure I understand your suggestion about fake elements.
The Himeworks plugin I mentioned does let you give bonuses to actors of specific class(es), but unfortunately bypasses the enemy resistance to the damage element.

Thank you very much. This looks very promising. I didn't know that you could use such code in the skill formula. I will have a play!
Your damage formula is executed with an "eval", meaning it can contain absolutely any valid Javascript code you want as long as the last statement it evaluates results in the amount of damage being dealt.
@Trihan Thanks, I thought that I was a bit limited in what I could do in there. :LZYoops:

I think I have got it cracked! What I did was:

100 + a.mat * 2 - b.mdf * 2 + (a.isClass($dataClasses[8]) * 20)

[The old formula was: 100 + a.mat * 2 - b.mdf * 2]

To test it, I used 200 instead of 20, so that I couldn't mistake the 20% variance for the new bit. I went for a constant 20 because I only want about +20%, and I didn't want to end up with non-integer damage.

Thanks again to @Robro33!
@Trihan Thanks, I thought that I was a bit limited in what I could do in there. :LZYoops:

I think I have got it cracked! What I did was:

100 + a.mat * 2 - b.mdf * 2 + (a.isClass($dataClasses[8]) * 20)

[The old formula was: 100 + a.mat * 2 - b.mdf * 2]

To test it, I used 200 instead of 20, so that I couldn't mistake the 20% variance for the new bit. I went for a constant 20 because I only want about +20%, and I didn't want to end up with non-integer damage.

Thanks again to @Robro33!
I don't think that would work as intended, because isClass returns a boolean. You're trying to multiply *true* or *false* by 20, which will give you either 0 or 20.

Did you intend to just add 20 damage if the user's class is 8?
Depending on how varied you want this to be (like, Red Mages are the best at fire spells, but Black Mages are still better at fire spells than White Mages are), I would give each spellcasting class a notetag.

So I could give those three classes:
<fireprof:1.8>
<fireprof:1.2>
<fireprof:.8>

And then in the damage formula of your fire skills you can reference it:
Code:
(a.mat * 4 - b.mdf * 2) * Number(a.currentClass().meta.fireprof)

But make sure you strictly follow the examples of JavaScript syntax that you're given, otherwise things won't work as expected (or at all).

You may find this thread helpful:
I don't think that would work as intended, because isClass returns a boolean. You're trying to multiply *true* or *false* by 20, which will give you either 0 or 20.

Did you intend to just add 20 damage if the user's class is 8?
Yes, Class 8 (Mage) is the only class that has extra expertise with Fire and Ice spells. Obviously most of the other spells could do with the class being changed.
Depending on how varied you want this to be (like, Red Mages are the best at fire spells, but Black Mages are still better at fire spells than White Mages are), I would give each spellcasting class a notetag.

So I could give those three classes:
<fireprof:1.8>
<fireprof:1.2>
<fireprof:.8>

And then in the damage formula of your fire skills you can reference it:
Code:
(a.mat * 4 - b.mdf * 2) * Number(a.currentClass().meta.fireprof)

But make sure you strictly follow the examples of JavaScript syntax that you're given, otherwise things won't work as expected (or at all).

You may find this thread helpful:
That looks really interesting, but a little beyond the scope of my current game. If you don't mind, I will copy your post onto one of the documents I use for notes about Javascipt and script calls in case I want it for a future project.
Must admit that I hadn't come across the thread you link to. I will have a look at it. There is one in RPGMaker MV Support that has a lot of people noting that MV is different from ACE because it uses JavaScript rather than Ruby.
Not sure I understand your suggestion about fake elements.
For each element, you would create a complementary element for outgoing efficiency - say element 4 is your "Fire" element and element 5 would be your "Fire Attack".
So if you use this formula in your fireball skill:
a.mat * a.elementRate(5)
most battlers would do 100% of their MAT as damage. A battler whose class has a 150% element rate for element 5 would instead do 150% of their MAT.

It offers pretty much the same as the other suggestions though.

I didn't want to end up with non-integer damage.
The final damage is always rounded into an integer after variance is applied, so unless you need an exact damage range you probably won't need to worry about this.
Yes, Class 8 (Mage) is the only class that has extra expertise with Fire and Ice spells.
Then you can use the instructions in that thread for ternary statements to add a multiplier into your damage formulae.

Must admit that I hadn't come across the thread you link to. I will have a look at it. There is one in RPGMaker MV Support that has a lot of people noting that MV is different from ACE because it uses JavaScript rather than Ruby.
I'm not familiar with that specific thread, but it doesn't sound super helpful. The one I linked has a lot of information that's presented pretty clearly (even stuff that shouldn't really be put into the damage formula).
The final damage is always rounded into an integer after variance is applied, so unless you need an exact damage range you probably won't need to worry about this.
Very useful to know. Thank you. [When I was messing around with the plugin I was getting decimals.]
Then you can use the instructions in that thread for ternary statements to add a multiplier into your damage formulae.

Yes, I have now tried:

if (a.isClass($dataClasses[8])) {(110 + a.mat * 2 - b.mdf * 2)*6/5; } else { 90 + a.mat * 2 - b.mdf * 2; }

It works okay. (Obviously I varied the class number to be appropriate for the skill.)
I am very pleased because I can easily use the "*6/5" with more powerful spells. I had been limiting the ability to buy certain spells by class, but there may be less need for this if the different classes are better off learning and using the spells that use their favourite elements. I think that I am nearly ready to apply this to my actual game, rather than just the test project.

EDIT: Note for anyone looking at this thread who wants to learn how to do it. I have slightly amended the formulae, for example:

if (a.isActor() && a.isClass($dataClasses[8])) {(100 + a.mat * 2 - b.mdf * 2)*6/5; } else { 100 + a.mat * 2 - b.mdf * 2; }

The "a.isActor() &&" bit is necessary if your enemies use the same spells that your party uses. It checks that whatever is casting the spell is an actor AND they have class 8. Otherwise, it tries to resolve the class of an enemy (which doesn't have a class). As stated earlier in the thread, if RPG Maker can't resolve the formula, it causes zero damage.

Original thread: https://forums.rpgmakerweb.com/threads/casting-effectiveness-for-elemental-spells-for-specific-classes.167432/