How to match parameters to an exact number with script? (do not add, do not subtract)

I know how to add value to the parameters:
$gameActors.actor(actorId).addParam(paramId, n);

But I would like to match them to an exact number, instead of adding or subtracting.

I searched the forum but couldn't find anything like that. Does anyone know any code to make atk = 10? 😅
By default, actor parameters are calculated when needed:

(base + plus) * traitRate * buffRate
...where:
  • base is from the actor's class/level.
  • plus is from the Change Parameter command, i.e. the addParam method.
    • (This is only available for basic params: MHP, MMP, ATK, DEF, MAT, MDF, AGI, LUK).
  • traitRate is from parameter rate traits.
  • buffRate is from any active buffs/debuffs.
Without a plugin, there's no function to simply set a parameter to a specific value.

However, you could try something like this in a Script command:
JavaScript:
var actor = $gameActors.actor(1);
var add = 10 - actor.paramBase(2) - actor.paramPlus(2);
actor.addParam(2, add);
In theory this will make the ATK of actor 1 equal to 10 before traits/buffs are applied. Note that this does not remember the previous value!

[Edit: added actor.paramBase(2) to the suggested script call.]
By default, actor parameters are calculated when needed:

(base + plus) * traitRate * buffRate

...where:
  • base is from the actor's class/level.
  • plus is from the Change Parametercommand, i.e. the addParam method.
    • (This is only available for basic params: MHP, MMP, ATK, DEF, MAT, MDF, AGI, LUK).
  • traitRate is from parameter rate traits.
  • buffRate is from any active buffs/debuffs.
Without a plugin, there's no function to simply set a parameter to a specific value.

However, you could try something like this in a Script command:
JavaScript:
var actor = $gameActors.actor(1);
var add = 10 - actor.paramPlus(2);
actor.addParam(2, add);
In theory this will make the ATK of actor 1 equal to 10 before traits/buffs are applied. Note that this does not remember the previous value!

It did not work and I think I know why.

But I have good news, your information gave me the answer.

I found out thanks to you that the modifications I was doing were being added to "paramPlus".

So I just need to set "base" = 10 in character creator, and when I use "$ gameActors.actor (actorId) .addParam (paramId, n);" and then want to remove the added values (whether or not you know the value) it would only be enough to establish that I want to subtract "paramPlus".

In short, the code that I was looking for is:

JavaScript:
var actor = $gameActors.actor(1);
var add = actor.paramPlus(2);
actor.addParam(2, - add);

Thank you very much caethyril. 😂
Oops, yes, I forgot to include the base value. 😅

I edited my previous post with (what I think is) a fix, but good to hear you found a solution! 😂

Original thread: https://forums.rpgmakerweb.com/threads/how-to-match-parameters-to-an-exact-number-with-script-do-not-add-do-not-subtract.139565/