How to make element effectivness

This is the final part of my battle system I cannot figure out myself, I have no idea how I should go about it. For this I am thinking I should put it into the battle but how it will work is basically like: at the beginning of the battle, it will check to see between characters involved in the battle (at the least the player and one enemy, at most the player, two allies, and three enemies). it will check to see if the character attacking the other one has an element it is stronger, not affected by or weaker then, and applies a modifier to the damage (here is the chart: )

it will be based off these variables:
57a965c80af9871ab9f4ee0d64b59acc.png
Why not just use the elements and element rate traits in the default system?

Like make your "water" enemy have a Plant Element Rate of more than 100% so it takes more damage from plant attacks

Element Rate > 100 = takes higher damae
Element Rate < 100 = takes less damage
Element Rate = 0 = takes no damage
Why not just use the elements and element rate traits in the default system?

Like make your "water" enemy have a Plant Element Rate of more than 100% so it takes more damage from plant attacks

Element Rate > 100 = takes higher damae
Element Rate < 100 = takes less damage
Element Rate = 0 = takes no damage
i am making my own map based battle system, it's a bit complicated but basically, if you want a good idea of what i'm planning to do take a look at the outline: https://docs.google.com/drawings/d/1YycwR5fdZG_pgfEOl7nx3CcSBjmDmTfwh_O5JsPOiVo/edit?usp=sharing
I see.. Then we need an idea of how you handle each attack etc to be able to help further. We cant help you if we dont know how you're handling things.

Anyway, you can still use the data from the Traits box for easier setup, then just reference them using script calls in your on-map battle system.
I see.. Then we need an idea of how you handle each attack etc to be able to help further. We cant help you if we dont know how you're handling things.

Anyway, you can still use the data from the Traits box for easier setup, then just reference them using script calls in your on-map battle system.

I have had to re-write the battle system since the last edition, but the one im working on handles it like this: it takes the player attack stat and sends it to a variable for storage.
(for the enemy it is actually handled by a plugin that will set up the enemy stats directly to variables: )
e4a49c40eb8613ed7df6b14ce776387f.png

the attacker's attack stat is stored in a temporary variable used just for calculating the damage inflicted. then it takes into account the target's defense, it subtracts the defense from the attack, after which it applies the critical modifier if there is one. after which it would take into account the element's effect.
Hmmm it seems like you've already gotten almost everything about the damage calculation done, adding the element check is simply a matter of doing a database comparison between the attacker element and the enemy element.

Like you can just make a JS object that stores element damage factors as its properties and read from that.
Hmmm it seems like you've already gotten almost everything about the damage calculation done, adding the element check is simply a matter of doing a database comparison between the attacker element and the enemy element.

Like you can just make a JS object that stores element damage factors as its properties and read from that.
and that's the issue I've run into, I am not the most experienced of coders and i'm just learning. i can understand if someone explains it to me but when it comes to stuff like that, if i can't do it with a lot of conditional statement's I'm lost.
7cedf7ced666ff289b4b75a27a2bf778.png

just look at that mess that happened when i tried to figure it out on my own ^
No need for conditionals, we just need a JS object where you store the corresponding damage factors like PlantVsWater = 150%

That way you practically just do

Damage*FactorOfPlantVsWater

I'm not with my comp right now so I cant test things right now
No need for conditionals, we just need a JS object where you store the corresponding damage factors like PlantVsWater = 150%

That way you practically just do

Damage*FactorOfPlantVsWater

I'm not with my comp right now so I cant test things right now
so i think i understand what you are saying, but how would i make the plugin be able to compare each of the elements and have it effect the calculation? (i don't know if javascript has lists like python but is it something like that?)

also, don't worry, i'm not on a crunch for time at all
Well you can get creative with naming the JS object properties like you actually make a JS object called elementRates and you name its properties like PlantVsWater, and so on so you can just get the element of attacker, concat Vs, then concat the element of the target.

Or you can make an array for each attacker element, and save the corresponding target element rate as its members like

var elementPlant = [1.00,1.50,0.00];

So if your attacker element is Plant, you just call elementPlant[ID] where ID is the index of the target's element. This means you need to have your elements have a corresponding static index (like Plant is 0, Fire is 1, Water is 2 etc)

This approach would need a check though to get the right element array for the attacker. I dont know if JS supports multidimensional array or Tables which will make it a lot easier.
do you mean like (i don't know what the specific code would look like.)
*figure out what the attacker's element is
*compare the target's element to the three categories of Strong against, unaffected, weak against for the attacker's element
*if the target enemy's element is in the strong against category add a modifier to the damage, if weak add a modifier to the damage, if unaffected do nothing

so like
Plantstrong = [water]
Plantnothing = [plant]
Plantweak = [fire]

^ and then do that for every element? since the actual two variables of the target's element and the attacker's, there would only need to be one time that i would need to write it because the event responsible would copy the value of the attacker's element and the target's in the event that handles the attacker's turn before the plugin's function is called? that's really what i could figure out from what you suggested.
So, I found out how to use arrays like that:

Code:
var elements = ["Plant", "Fire", "Water"];
if (elements == "Plant");
    console.log("works");

works, and so I can now try to mess around with this to get something that will work for the thing i wish to get done, i'll post whether it works or not.

Edit:
I have no idea why my code isn't working i keep getting this error:
95f9ef3e5482f34830b27fe46f1204e0.png

(it's the element check function, tested as $gameVariables.Value(128) == 1 )

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-element-effectivness.102452/