MZ (SOLVED)How to script 'Elemental Resistance' and 'Elemental Bonus Damage' in JS?

Hello everyone, I'm working with the VisuStella Skill States Core and Element States Core in RPG Maker MZ.

In the Element States Core plugin, I found the note tag <Multi-Element: x>, which can change the elemental properties of character actions.

I used to think that this change included the DOTs applied by characters, but after testing, I found that visu does not provide support for DOTs to include elemental properties.

The testing process is as follows:

Details about this issue.
Spoiler
Related functionality as follows: 1. From VisuMZ_1_SkillsStatesCore, the feature of transforming a state into DOT:
* <JS type Slip Damage>
* code
* code
* damage = code;
* </JS type Slip Damage>
*
* - Used for: State Notetags
* - Code used to determine how much slip damage is dealt to the affected unit
* during each regeneration phase.
* - Replace 'type' with 'HP', 'MP', or 'TP'.
* - Replace 'code' with the calculations on what to determine slip damage.
* - The 'user' variable refers to the origin of the state.
* - The 'target' variable refers to the affected unit receiving the damage.
* - The 'state' variable refers to the current state being affected.
* - The 'damage' variable is the finalized slip damage to be dealt.
* - When these states are applied via action effects, the slip calculations
* are one time calculations made upon applying and the damage is cached to
* be used for future on regeneration calculations.
* - For that reason, do not include game mechanics here such as adding states,
* buffs, debuffs, etc. as this notetag is meant for calculations only. Use
* the VisuStella Battle Core's <JS Pre-Regenerate> and <JS Post-Regenerate>
* notetags for game mechanics instead.
* - Passive states and states with the <JS Slip Refresh> notetag are exempt
* from the one time calculation and recalculated each regeneration phase.


2. From VisuMZ_1_ElementStatusCore, the function to forcibly convert a character's action into a specified
(Note: There might be a misunderstanding here, which I have mentioned at the end.)

* <Force Action Element: Null>
*
* <Force Action Element: x>
* <Force Action Element: x,x,x>
*
* <Force Action Element: name>
* <Force Action Element: name, name, name>
*
* - Used for: Actor, Class, Weapon, Armor, Enemy, State Notetags
* - Forces any actions performed by this unit to be the specific element(s).
* - Replace 'x' with the ID of the element from Database > Types.
* - For 'name' notetag variant, replace 'name' with the element's name.
* Remove any \I[x] in the 'name' replacement.
* - If multiples of this notetag are found across various Database objects,
* priority will go in the order of states, actor, enemy, class, equips.


I attempted to replicate the operation in a new project file to eliminate any other interference.

I created a state and used the note tag provided by Visu to convert it into DOT. Utilizing the note
<JS type Slip Damage>
code
code
damage = code;
</JS type Slip Damage>
I set its damage value to 100.

As a comparison, I created a direct damage AOE skill, also setting its damage value to 100.
Instead of setting it directly to the fire element, I used the <Force Action Element: 2> found in the character's notes to transform its element from "None" to fire.
This was done to compare the differences in effects between the state and AOE under this influence.

When there are no bonuses applied, both the DOT and AOE skills deal damage equal to their base value.

After applying changes to the elemental rate, the DOT showed no change,
while the AOE demonstrated a successful transformation into fire damage by the note tag <Force Action Element: 2>,
and correctly triggered the related calculations for elemental damage.

Although this did not align with the description, I later also tried assigning the note tag directly to the state itself. As expected, it did not produce the anticipated effect.

However, it's not an error,
it seems more like Visu did not consider the possibility of DOT being involved in elemental rate calculations from the design stage.

(Perhaps, in line with visu's rigorous help text style, it would be better if they could add a clarification in the relevant descriptions to better prevent such misunderstandings. Just like: "This note tag does not affect the elemental properties of Slip Damage; Slip Damage does not include elemental properties.")



Apart from this somewhat ambiguous description,
I have not found any functionality to assign an element directly to a state itself anywhere else.

Since it's not sure if the Visu team will update the support for elemental properties of DOT in the future, for my own use, I have tried to find other solutions. First, I found the following scripts:

Spoiler
- Additive (default 0):
`user.getDealtElementPlus(x)`,
`target.elementPlus(x)`

- Multiplicative (default 1):
`user.getDealtElementRate(x)`,
`target.elementRate(x)`

- Extra Additive (default 0):
`user.getDealtElementFlat(x)`,
`target.elementFlat(x)`


I have written the damage formula as follows:
(This formula has never worked successfully in my tests, and I don't know if it's because the formula is too complex, leading to a low tolerance for errors, which makes me always fill in the format incorrectly, or if there is a problem with the design of the formula itself.)

Spoiler
a.mat * ((1 + user.getDealtElementPlus(15)) * user.getDealtElementRate(15) + user.getDealtElementFlat(15)) * ((1 + target.elementPlus(15)) * target.elementRate(15) + target.elementFlat(15))

However, this method has two problems:
1. This formula does not consider the impact of forced rates (as indicated by tags like <Force Received Element id Rate: x%>), leading to a discrepancy between direct damage and DoT in scenarios where forced rates are present;
2. I am also concerned about the complexity of the formula. I am wondering if there is a more streamlined script in MZ or Visu plugins that can represent the final results of elemental damage multipliers, as well as the final results of elemental damage taken multipliers.

Appreciate any help!




picture.png
These plugins are supposed to allow for damage over time (DoT) based on formulas and enable states with elemental attributes respectively.
Can you explain this? From a brief look over the instructions for the two plugins, I didn't see this.

Which notetags or plugin parameters are supposed to do this? Can you show screenshots of how your states are set up to begin with?

If that's correct, and it doesn't work, this should be a bug report to VisuStella (they have instructions for that on their sites).
Can you explain this? From a brief look over the instructions for the two plugins, I didn't see this.

Which notetags or plugin parameters are supposed to do this? Can you show screenshots of how your states are set up to begin with?

If that's correct, and it doesn't work, this should be a bug report to VisuStella (they have instructions for that on their sites).
I apologize for not conveying the details thoroughly, I have now edited the details into the post.
No apologies necessary. So, just to put it out there, regarding this part:
These plugins are supposed to allow for damage over time (DoT) based on formulas and enable states with elemental attributes respectively.
Nothing is wrong in the words you're saying. But you seem to be using them to come to the conclusion that these plugins claim that elemental settings on a state or skill will transfer to Slip Damage, and I don't see anything in the plugin instructions to support that.

If you really use all of those different aspects of the Element Core and need them to be taken into account in your slip damage, then yes - as far as I know, you would have to make a convoluted formula like that. It's also possible the plugin has a higher level function that already incorporates that formula.

I don't own the VisuStella plugins, @Trihan or @Arthran might be able to help you with retrieving the data from those other notetags.
No apologies necessary. So, just to put it out there, regarding this part:

Nothing is wrong in the words you're saying. But you seem to be using them to come to the conclusion that these plugins claim that elemental settings on a state or skill will transfer to Slip Damage, and I don't see anything in the plugin instructions to support that.

If you really use all of those different aspects of the Element Core and need them to be taken into account in your slip damage, then yes - as far as I know, you would have to make a convoluted formula like that. It's also possible the plugin has a higher level function that already incorporates that formula.

I don't own the VisuStella plugins, @Trihan or @Arthran might be able to help you with retrieving the data from those other notetags.
You are right, I have updated my understanding. The previous conclusion was more like a misunderstanding.

I used to think that <Multi-Element: x> included the element attributes of DOTs applied by characters on character actions, but actually, it does not.

This is not a mistake, but rather that visu does not support giving DOTs elemental properties.

I will modify some wording in the post to eliminate this misunderstanding.
The problem has been solved!

I found the script target.elementRate(x) which is used to represent the final results!

Now, the formula has been optimized to this:

Spoiler
user.mat * ((1 + user.getDealtElementPlus(15)) * user.getDealtElementRate(15) + user.getDealtElementFlat(15)) * target.elementRate(15)

I am a newbie just starting to learn about JavaScript. If you think there is any room for improvement in my method, I welcome your guidance. Thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/solved-how-to-script-elemental-resistance-and-elemental-bonus-damage-in-js.165277/