Script call to set parameter to a value?

vectorinox

Airport Luggage
Veteran
Joined
Jun 20, 2016
Messages
45
Reaction score
9
First Language
Singlish
Primarily Uses
I remember Archeia posted that script call list, which include: 


$gameActors.actor(id).addParam(id, n)   <---- this is the script call to add parameter


But I wanted to know the script call to set the actor parameter to specified value


$gameActors.actor(id).setParam(id, n)   <---I tried this, and apparently it doesn't work....
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
One does not simply set a param for a battler in RMMV.


Technically speaking, You may want to check this:

Game_BattlerBase.prototype.param = function(paramId) {
var value = this.paramBase(paramId) + this.paramPlus(paramId);
value *= this.paramRate(paramId) * this.paramBuffRate(paramId);
var maxValue = this.paramMax(paramId);
var minValue = this.paramMin(paramId);
return Math.round(value.clamp(minValue, maxValue));
};

Instead, you may want to do this:


var actor = $gameActors.actor(actorId);
actor.addParam(paramId, val - actor.param(paramId))


Where actor.param(paramId) returns the current value of the parameter with id paramId, meaning that val should be equal to the specified value you want, in order to use the above setup to set the param to that specified value.
 

vectorinox

Airport Luggage
Veteran
Joined
Jun 20, 2016
Messages
45
Reaction score
9
First Language
Singlish
Primarily Uses
I already tried that (using default command) as:


Harold current Luck -> 20, I want to set it 77, so I run the following event:

  • Control Variables : #0001 Difference = Luck of Harold
  • Control Variables : #0001 Difference -= 77
  • Change Parameter: Harold, Luck - {Difference}

But the problem is that the game stats can never go below 1, but it still store the negative value.


Try: Change Parameter: Harold, Luck - 300: It will set it as Luck -> 1 instead, but the game store it as -280.


Then run the above event (or your script).


It will still be Luck -> 1 and the game store it as -204. (-280 -(1-77)).


And that's why I need it to be hard set (like variables) instead of using addition/subtraction. (sorry, I just like experimenting with the engine mechanics)
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
I already tried that (using default command) as:


Harold current Luck -> 20, I want to set it 77, so I run the following event:

  • Control Variables : #0001 Difference = Luck of Harold
  • Control Variables : #0001 Difference -= 77
  • Change Parameter: Harold, Luck - {Difference}
In this case, you may want to use + 57(77 - 20) instead of -57(20 - 77).


So, basically, you can check whether a battler's param greater than, equal to, or less than your specified value:


Greater than - Use decrease by (old value - new value)


Equal to - Does nothing


Less than - Use increase by(new value - old value)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Profile Posts

Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:

Forum statistics

Threads
105,855
Messages
1,017,012
Members
137,563
Latest member
MinyakaAeon
Top