How to retrieve PDEF (and other) stat values?

I'm so sorry for clogging up this forum with questions while I figure out RGSS scripting. I'm pouring over the documentation, but I feel like I keep missing the obvious stuff.

Right now I'm just trying to implement a simple check to see if the player's PDEF is equal to a specific value. Every way I can possibly imagine to phrase this in scripting results in a crash.

(and this is, itself, a workaround to me not being able to run a check and see which elements the player's equipped weapon possesses. If I knew how to do that, it'd be even better, but it seems vastly more complicated.)
I don't know if it is the same with RMXP, but in all later makers the values were available without scripting through the control variable: game data option.

That said, the problem might be elsewhere - but you gave no info on what you tried to do and what the error messages were. Can you post which script you used where, and what error was the result?
I don't know if it is the same with RMXP, but in all later makers the values were available without scripting through the control variable: game data option.

That said, the problem might be elsewhere - but you gave no info on what you tried to do and what the error messages were. Can you post which script you used where, and what error was the result?

Unfortunately, my ultimate goal is to implement this as part of a custom battle system, so doing it without scripting is out of the question. Here are some of the scripts I've tried, each in an attempt to determine whether PDEF was set to 1:

if @pdef == 1 (no result)

if $[email hidden] == 1 (crash, syntax error)

if $game_actor(@base.pdef) == 1 (crash, syntax error)

if $game_actor(@base.pdef) == (1) (crash, syntax error)

if $game_actor[@base.pdef] == 1 (crash, NoMethodError - 'pdef' undefined)

if $game_actor[@base.pdef] == [1] (crash, NoMethodError - 'pdef' undefined)

if base.pdef == 1 (crash, NameError)

if @base.pdef == 1 (crash, NameError)

if self.pdef == 1 (crash, NoMethodError - 'pdef' undefined)

if @self.pdef == 1 (crash, NoMethodError - 'pdef' undefined)
$game_actors[ID].pdef
where ID is the Actor's Database ID, no leading zeroes necessary
e.g. $game_actors[1].pdef returns Actor 1's PDEF

$game_party.actors[ID].pdef
where ID is the actor's position in the party, zero-indexed (meaning the first party member's index is 0, the second is 1, etc.)
e.g. $game_party.actors[0].pdef returns the first party member's PDEF
$game_actors[ID].pdef
where ID is the Actor's Database ID, no leading zeroes necessary
e.g. $game_actors[1].pdef returns Actor 1's PDEF

$game_party.actors[ID].pdef
where ID is the actor's position in the party, zero-indexed (meaning the first party member's index is 0, the second is 1, etc.)
e.g. $game_party.actors[0].pdef returns the first party member's PDEF
Thank you so much! That worked perfectly!
Well, if you wanna use a shortcut because RMXP's script call box is small, you can use this scriptlet:

Ruby:
class Game_Party
  def [](pos)
    @actors[pos]
  end
end

Copy and paste it in a new section of your script editor.
Then enter this call in your event command:

Ruby:
$game_party[0]

Or pick any other position at will!

Ruby:
$game_party[204].pdef
Warning: It will throw an error if no Game_Actor could be found there, i.e.
Code:
NoMethodError (undefined method `pdef' for nil:NilClass)

Original thread: https://forums.rpgmakerweb.com/threads/how-to-retrieve-pdef-and-other-stat-values.156757/