MV How to get an Actor's Elemental Resistance converted into a number to assign to a variable?

I have a segment in my game where the player is in a lava zone. I want to run an event every 60 frames that will damage the player according to their fire element resistance, which is already augmented by their worn armors and weapons. I figure I could just get specific actors' elemental resistances, set a variable to that number/value, and then use a conditional branch to check certain spreads such as 0-10, 11-20, etc all the way to 200 (which would be 200% resistance).

I just can't for the life of me figure out what command that would even be to GET a specific actor's resistance to a specific element. I'm hoping to just use the Script command in an event for this.
Try something like one of these in Control Variables -> Script:
  • Get 100x element rate 2 for the party leader (member index 0):

    $gameParty.members()[0].elementRate(2) * 100
  • Get 100x element rate 2 for actor ID 1:

    $gameActors.actor(1).elementRate(2) * 100
Element rate is a percentage, e.g. 100% rate is a value of 1. These examples multiply by 100 partly because that's what you asked for, and partly because game variables round numerical values down to the nearest integer. (E.g. if you tried to store just the element rate, a value of 175% (1.75) would get stored as 1.)

Note that element rate measures vulnerability to an element, not resistance. I.e. 200% element rate means you take double damage from that element.
Try something like one of these in Control Variables -> Script:
  • Get 100x element rate 2 for the party leader (member index 0):

    $gameParty.members()[0].elementRate(2) * 100

  • Get 100x element rate 2 for actor ID 1:

    $gameActors.actor(1).elementRate(2) * 100

Element rate is a percentage, e.g. 100% rate is a value of 1. These examples multiply by 100 partly because that's what you asked for, and partly because game variables round numerical values down to the nearest integer. (E.g. if you tried to store just the element rate, a value of 175% (1.75) would get stored as 1.)

Note that element rate measures vulnerability to an element, not resistance. I.e. 200% element rate means you take double damage from that element.
Tried this with a variety of equipment effecting a specific element resistance and it only shows '100' when I can see with Yanfly's Status Menu Core that I'm currently at 121% - wouldn't that be '121'? Or am I reading that code wrong lol

EDIT: NEVERMIND!!! That's STATE RATE not ELEMENT RATE. Yeesh, I'm surprised I made it this far xD
DOUBLE EDIT: This works perfectly as intended, thank you so much!!!
Are you sure that you're referencing
1 - the correct actor?
2 - the correct element?

Both the actor ID (if you're using the second method) and the element type will be the numbers as they're listed in your database, with no leading zeros. If you're looking at a party member (the first method), that starts at member 0 as caethyril described.

While you're in the game, you can press F8 and go to the Console tab and directly paste or type in any of this code to see what the numbers are getting returned.

If you get stuck, post some screenshots of what you entered for the code in your event, what you see when you type their stuff into the console, and what you're seeing on the status menu.
Are you sure that you're referencing
1 - the correct actor?
2 - the correct element?

Both the actor ID (if you're using the second method) and the element type will be the numbers as they're listed in your database, with no leading zeros. If you're looking at a party member (the first method), that starts at member 0 as caethyril described.

While you're in the game, you can press F8 and go to the Console tab and directly paste or type in any of this code to see what the numbers are getting returned.

If you get stuck, post some screenshots of what you entered for the code in your event, what you see when you type their stuff into the console, and what you're seeing on the status menu.
I generally only ever have the Player's character and +1 party member at most during gameplay, so for ease of use I used the second method - but thanks!
Great! In case it helps, you can get the state rate values (as seen on the YEP Status Menu) by replacing elementRate in those script calls with stateRate.

Happy RPG Making~ 👋

Original thread: https://forums.rpgmakerweb.com/threads/how-to-get-an-actors-elemental-resistance-converted-into-a-number-to-assign-to-a-variable.153749/