Weapons and elements

Hi!

I'm having a bit of difficulty with a particular damage formula, and my searches didn't helped a bit.

I have two kinds of weapons in my game: pure physical weapons and enchanted (elemental) weapons.

When the user attacks with a pure physical weapon (command Attack), it's the default formula that should be used (old and good a.atk * 4 - b.def * 2).

However, if the weapon has an element, I'd like to add some damage on top of that (i.e., the target is hit by the physical part of the weapon and also by the magical).

In other words, it should be something like this:

WEAPON_HAS_ELEMENT_OTHER_THAN_NORMAL ? (a.atk * 4 - b.def * 2) + (a.mat * 4 - b.mdf * 2) : a.atk * 4 - b.def * 2;

That's where I struck a roadblock. How to check if the weapon has an element associated?

Considering Normal is elementId 1, I could check if elementId > 1, but I don't know how to check that.

Follow up question: if the target is immune or resistant to that element, will this formula take that in consideration? Let's say I hit a 50% fire resistant target with a Fire Sword, he should receive full damage from the physical part (a.atk * 4 - b.def * 2) and half damage from the magical part (a.mat * 4 - b.mdf * 2).

Can this be done changing the damage formula or it's something that'll require a plug-in?

EDIT: An alternative way to do this would be having such weapon to make a second/simultaneous magical attack. If this is the alternative (and it seems easier, I think), how to chain both attacks?
I think it would be much easier to change the formulae in a way that includes the default behaviour of the elemental damage rates, as that might already do most of what you want.
And then inverse the test you think of, by asking if the weapons has no element attached instead of asking if it has one.
I can't give you the formula for that because my computer with the maker data is non-functional at the moment, but doing it this way will be easier than what you're currently planning.
(...)asking if the weapons has no element attached instead of asking if it has one.
How to do that? I can't find a way to learn the correct sintax for that.
@Fermmoylle Hi, have you already found a solution? I have a similar problem and would be interested how you dealed with yours.
@Fermmoylle Hi, have you already found a solution? I have a similar problem and would be interested how you dealed with yours.
Yes! Check this link http://yanfly.moe/2016/11/04/tips-tricks-enfire-final-fantasy-11-rpg-maker-mv/
It works like a charm.

Original thread: https://forums.rpgmakerweb.com/threads/weapons-and-elements.86678/