Changing characters stats on the fly

So I am writing a script that can change your stats by a specific percentage. The question is:

$gameActors.actor(1).def; // => 46

But doing:

$gameActors.actor(1).def = 500;
$gameActors.actor(1).refresh();
$gameActors.actor(1).def; // => 46 ???

Why didn't it change?

Update ^ : I just noticed that .def is a get function. You get the value, you cannot set it this way, so based on below, do I set it through the class based on the level of that class?

So I did some research and it seems I can do: $gameActors.actor(1).currentClass().params[0][1] = 4500; // changes the actor 1 current classes level 1 hp to 4500.

But this seems wrong. I shouldn't have to manipulate the classes stats, I should be able to manipulate the characters stats no?

Whats the correct way to change actor 1's def to something like 999 (for example) ?
You would have to mess with the params of the class I believe, at least temporarily, because you can't touch def on the actor unless you were to alter the implementation. You can check it out in the rpg_objects file. Stats are almost entirely tied to the class parameters. The only one you can probably change without going through the params, is hp.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/changing-characters-stats-on-the-fly.78959/