Setting a variable to the player/target hit rate Ex-Parameter

Hey folks,

I need to set a variable to the hit rate for the attacking character (could be by actor ID, this actor, "subject" when attacking, etc.) as well as an enemy when it attacks (subject, ideally, as enemy ID will always be different depending on who is attacking).

I've tried setting variable to:

BattleManager._subject.xparam(0)
and
BattleManager._target.xparam(0)

But, both just return "1" for some reason. My understanding is that the xparam ID for hit rate is 0, so if I have a hit rate of 95%, shouldn't this be setting the variable to "95"?

Maybe I have the ID wrong?

Any help is much appreciated! I am basically trying to make a common event only run based on comparing a random "1-100" variable against the hit rate of the current attacking character/enemy.

Thanks!
My understanding is that the xparam ID for hit rate is 0, so if I have a hit rate of 95%, shouldn't this be setting the variable to "95"?
the id for hit is 1, but the value is a rate. 95% wouldnt be 95, itd be .95

if it is producing a 1, then whatever battler that is has a hit rate of 100%. if that isnt supposed to be the case then double check the battler and the gear/states/classes they have
It's also worth noting that depending on how you set it, you'll get the wrong value.

The Control Variables event command (same as the $gameVariables.setValue() method) will automatically round values.

So if you want to store a decimal value in a variable, you need to do it manually. e.g. a script call:
Code:
$gameVariables._data[12] = BattleManager._subject.xparams(0)
the id for hit is 1, but the value is a rate. 95% wouldnt be 95, itd be .95

if it is producing a 1, then whatever battler that is has a hit rate of 100%. if that isnt supposed to be the case then double check the battler and the gear/states/classes they have


Ah, perfect! I hadn't thought that it would be .95 for some reason. I did have +5 hit rate from my base of 95, so it was giving a 1 for that reason.
Though, the ID does seem to be 0 (1 seems to be evasion).


It's also worth noting that depending on how you set it, you'll get the wrong value.

The Control Variables event command (same as the $gameVariables.setValue() method) will automatically round values.

So if you want to store a decimal value in a variable, you need to do it manually. e.g. a script call:
Code:
$gameVariables._data[12] = BattleManager._subject.xparams(0)

Good to know! I'll do it this way.
Though, the ID does seem to be 0 (1 seems to be evasion).
oh, yeah, my bad there. i meant 0, but i ended up typing 1

Original thread: https://forums.rpgmakerweb.com/threads/setting-a-variable-to-the-player-target-hit-rate-ex-parameter.173812/