MZ How to add to Pharmacology outside of traits?

Hello friends! So Pharmacology is an s-param that can only be adjusted through states, weapons, and armor, it seems. Please correct me if I'm wrong because I'm going crazy trying to figure this out, lol.

I want items to increase my player's pharmacology stat - it's renamed to Alchemistry, but I'll call it pha in this post. They are "recipes" that have no other function than as a collectible with the benefit of adding to pharmacology by 1% for each. The goal is to collect them all. Super fun.

So I've been trying to figure out how to get this to work. I figure for every chest that contains a recipe item, I adjust the pharmacology in that event. Can't do it through the engine as that only changes the regular params.

My attempts:

I wrote a lot so I put them in spoilers!

VisuStella States
Spoiler
I tried making a State that gives Pharmacology 101% and then made that a "Passive" state with the "<Passive Stackable>" notetag. My thought was that every time the state was applied, it would stack. But that didn't do anything and I assume it's because "passive" states can't be "added."

I tried making it not a passive state and just adding, but the stat wouldn't go above 101%.


VisuStella Core
Spoiler
I then went into the parameter settings and tried this code:
JavaScript:
// Determine the variables used in this calculation.
let sparamId = arguments[0];
let base = this.traitsPi(Game_BattlerBase.TRAIT_SPARAM, sparamId);
let plus = this.sparamPlus(sparamId);
let paramRate = this.sparamRate(sparamId);
let flatBonus = this.sparamFlatBonus(sparamId);

if (sparamId === 3) {
  // If sparamId is 3 (PHA), apply the variable's value to paramRate
  value = (base + plus) * $gameVariables.value(25) + flatBonus;
} else {
  // For other s-params, use the default calculation
  value = (base + plus) * paramRate + flatBonus;
}

// Final value
return value;

Then I did this code to add to the variable in an event:

JavaScript:
const currentBonus = $gameVariables.value(26) + 1; // Increment the cumulative bonus by 1%
$gameVariables.setValue(26, currentBonus); // Save the new cumulative bonus

const newPharmacology = 1.0 + (currentBonus * 0.01); // Base Pharmacology (100%) plus the cumulative bonus as a decimal

$gameVariables.setValue(25, newPharmacology); // Store the new Pharmacology value in Variable ID 25 as a decimal

console.log(`New Pharmacology Value: ${newPharmacology * 100}% stored as ${newPharmacology} in Variable 25`);
Console log says this works well:
1724434291884.png


But it doesn't actually update my PHA value in the game.

It's weird. Starting the game and opening up the stats, PHA is 0%, which tells me it might be working because initially the variable is 0. When I spam this event to add to it, it stays at 0%.

When I start the game and don't open the stats, and then spam this event, the PHA becomes 100%. But it also stays at 100%.

So I don't know if there's an issue in updating...? Or what...

Hakuen Dynamic Parameters: https://hakuenstudio.itch.io/eli-dynamic-parameters-for-rpg-maker
Spoiler
Trying a different plugin now, returning VS sparam code to default.

1724434876222.png


I put the notetag <DynParams: Alchemistry> in a State, and then added the State as a Passive (VS). Pharmacology starts at 100% and then goes to 200% when I spam the event (same code as above to adjust the variable), but it stays at 200%.

So then I tried this code to set the variable:
JavaScript:
const currentBonus = $gameVariables.value(26) + 1; // Increment the cumulative bonus
$gameVariables.setValue(26, currentBonus); // Save the updated bonus

const newPharmacology = 1 + (currentBonus * 0.01); // Calculate the new Pharmacology value
$gameVariables.setValue(25, newPharmacology * 100); // Store as a percentage in Variable 25

console.log(`New Pharmacology Value: ${newPharmacology * 100}% stored in Variable 25`);

and then the parameter becomes "10,200%" - SO CLOSE!
1724435488724.png


1724435944594.png


But removing the * 100 makes it stick to 200%
1724436031948.png


Not sure what else to do here. My math is probably wrong.


Nat Dynamic Traits: https://sleepy-kitten-games.itch.io/dynamic-traits-rmmz

Spoiler
This one doesn't support variables, but that's okay cause the plugin command makes it easy enough.
1724435165030.png

Adding .01 or even .5 doesn't change it. Adding 1 changes it to 200% and then no further.

There was some attempt I was able to get it to 103% and then it got stuck at 103% but I can't replicate that so I'm not sure what I did there...

If anyone has any ideas on how I can just add 1% to PHA over the course of the game, I will give you ALL the virtual hugs.

Thank you!!
That's.... a lot...
For the sake of asking, have you tried to utilize the effect via items/skills to see if the effect itself is actually working. If it works, then it's just a matter of making it display properly. If it doesn't, then there's something else going on.
That's.... a lot...
For the sake of asking, have you tried to utilize the effect via items/skills to see if the effect itself is actually working. If it works, then it's just a matter of making it display properly. If it doesn't, then there's something else going on.
I just wanted to show that I tried some things before coming to the forums, haha. Like I'm not asking for someone to do the work for me from the getgo. I tried to do the work ;_; I promise.
Edit: put my attempts in spoilers lol

Anyway, yes! The sparam works fine normally. A weapon with 130% pha gives my actor 130% pha. Being given a 101% pha state on top of that gives my actor 131% pha. That's all working as intended.
Ok. So it's just a matter of putting it in the plugin params...

I'm not at my desk right now, but I'll look and see what I can do later tonight.

I'm willing to guess this is a matter of overthinking and taking a few steps back will make answer obvious.
:LZSwink:

Edit: BTW, you are using both variables 25 and 26. Is that intentional?

At work, so can only give this a bit of a look between mini breaks.
Ok. So it's just a matter of putting it in the plugin params...

I'm not at my desk right now, but I'll look and see what I can do later tonight.

I'm willing to guess this is a matter of overthinking and taking a few steps back will make answer obvious.
:LZSwink:

Edit: BTW, you are using both variables 25 and 26. Is that intentional?

At work, so can only give this a bit of a look between mini breaks.
Thank you, I appreciate it!! I think you're right. I stumbled and started going crazy and my math is probably wrong and it's probably just a simple fix lol.

My reasoning for 2 variables was that one variable (26) keeps track of how many times the item is looted. 1, 2, 3, 4 times, etc. And then 25 is changing 1,2,3,4,etc., to fit into whatever number format is needed for the pharmacology effect to work. Like 1 becoming 101%. Or 1.01.

It made sense at the time LOL. Writing it out now I'm not so sure.
Hello friends! So Pharmacology is an s-param that can only be adjusted through states, weapons, and armor, it seems. Please correct me if I'm wrong because I'm going crazy trying to figure this out, lol.
I don't think it's a helpful correction, but trait objects also include actors, classes, and enemies.

As far as the stuff you've tried...that Nat plugin just plumb doesn't work. I don't want to be too harsh on someone who's saying it's their first plugin, but it doesn't seem like it could've been tested. The poor formatting of the commands aside, it just ignores how traits and database values actually work.

The Hakuen Studio Dynamic Parameters...I'm not sure why it doesn't work. I used the demo project, told the short sword to have a pha equal to $gameVariables._data[29] (so you don't have to use the extra variables and multiplying), and confirmed changing that value in-game did not change the pharmacology of the actor wielding the short sword.

Perhaps @Eliaquim can shed light on that.

Galv's Dynamic Traits is an MV plugin, but I'd expect it to work fine for this:

My initial testing bears this out.
1724439802421.png


Of course, I have no idea whether it will have any conflicts with VisuStella stuff.

If anyone has any ideas on how I can just add 1% to PHA over the course of the game, I will give you ALL the virtual hugs.
Okay! 😂
ATT always taking my hugs! :LZSrasp:
ATT always taking my hugs! :LZSrasp:
Aww! Well, maybe I'll get two hugs and give you one! (you probably won't enjoy it as much)
@ATT_Turan I did say ALL the hugs! You'll have plenty to spare!
So I'm having a weird issue.

I'm not worrying about variables and have this:
JavaScript:
const actor = $gameActors.actor(1); // Replace 1 with the actor ID
const phaValue = actor.sparam(3); // sparam(3) corresponds to the Pharmacology (PHA) stat

console.log(`Actor's OG Pharmacology (PHA) value: ${phaValue}`);

Galv.DTRAITS.addTrait(1,23,3,1.01);

console.log(`Actor's New Pharmacology (PHA) value: ${phaValue}`);

And the console log shows this:
1724442636620.png


If I DON'T have the console log check the OG pha value...
JavaScript:
const actor = $gameActors.actor(1); // Replace 1 with the actor ID

const phaValue = actor.sparam(3); // sparam(3) corresponds to the Pharmacology (PHA) stat

Galv.DTRAITS.addTrait(1,23,3,1.01);

console.log(`Actor's New Pharmacology (PHA) value: ${phaValue}`);

it goes up to 101% but then stops:
1724442736699.png


This is telling me the game doesn't update the param after it's "seen" it? Using my layman's terms?

So I thought it was a VS compatibility issue maybe. I opened up a new project. It's blank. Only Galv plugin.

This code:
JavaScript:
const actor = $gameActors.actor(1); // Replace 1 with the actor ID
const phaValue = actor.sparam(3); // sparam(3) corresponds to the Pharmacology (PHA) stat

console.log(`Actor's OG Pharmacology (PHA) value: ${phaValue}`);

Galv.DTRAITS.addTrait(1,23,3,1.01);

console.log(`Actor's New Pharmacology (PHA) value: ${phaValue}`);

1724442830288.png

It sticks at 1.01. Instead of going up to 1.02, 1.03, by spamming the event script.

So! I don't know lol.

Hugs are pending.

Edit: Wait I might be dumb. Maybe it does need the variable to go up. HOLD PLEASE I'LL EDIT HERE.

Edit 2: No dice 🙁 thought I was on to something.

Normal project code:
JavaScript:
const currentBonus = $gameVariables.value(26) + 1; // Increment the cumulative bonus by 1%
$gameVariables.setValue(26, currentBonus); // Save the new cumulative bonus

const newPharmacology = 1.0 + (currentBonus * 0.01); // Base Pharmacology (100%) plus the cumulative bonus as a decimal

$gameVariables.setValue(25, newPharmacology); // Store the new Pharmacology value in Variable ID 25 as a decimal

console.log(`New Pharmacology Value: ${newPharmacology * 100}% stored as ${newPharmacology} in Variable 25`); // Corrected with backticks

Galv.DTRAITS.addTrait(1, 23, 3, $gameVariables.value(25)); // Ensure this is the correct syntax for your specific plugin

const actor = $gameActors.actor(1); // Replace 1 with the actor ID
const phaValue = actor.sparam(3); // sparam(3) corresponds to the Pharmacology (PHA) stat
console.log(`Actor's New Pharmacology (PHA) value: ${phaValue}`); // Corrected with backticks

1724443409271.png


Blank project code is the same.
1724443459614.png


note that I'm using chatgpt to make sure I don't forget any parentheses and things, which is why there are a lot of commented lines lol
It sticks at 1.01. Instead of going up to 1.02, 1.03, by spamming the event script.
Variables don't change unless you change them. When you do
Code:
const phaValue = actor.sparam(3);
that's not somehow connecting phaValue to the actor's pha. It's saying "put the current value of the actor's pha into the variable."

So it's always going to show the same number unless you change it.

If you do your script and replace the end with
Code:
console.log(`Actor's New Pharmacology (PHA) value: ${$gameActors.actor(1).pha}`);
you'll see the current value. (or sparam(3), pha is just the shortcut)

You're also not doing anything in your script call to add more to the pha. You're setting it each time to 1.01. You'd need to set it to different values at the end (that's why in the example I showed you, I used a variable there).

Try pasting these lines into your console, one at a time. Replace the 3 with the ID of whatever variable you have available:
Code:
$gameActors.actor(1).pha;
$gameVariables._data[3] = 1.01;
Galv.DTRAITS.addTrait(1,23,3,$gameVariables._data[3]);
$gameActors.actor(1).pha;
$gameVariables._data[3] += .01;
Galv.DTRAITS.addTrait(1,23,3,$gameVariables._data[3]);
$gameActors.actor(1).pha;

1724444058981.png
@ATT_Turan I realized nothing was changing because I wasn't using a variable, so I edited my post lol!

Thanks though I followed your steps.

Normal project:
1724444321175.png


Blank project:
1724444473398.png


Incompatibility then, boooo hissss.

Moved Galv to the top of the plugin list and it's still stuck at 1.

I'm guessing it's the VS Core parameter settings.
JavaScript:
// Determine the variables used in this calculation.
let sparamId = arguments[0];
let base = this.traitsPi(Game_BattlerBase.TRAIT_SPARAM, sparamId);
let plus = this.sparamPlus(sparamId);
let paramRate = this.sparamRate(sparamId);
let flatBonus = this.sparamFlatBonus(sparamId);

//if (sparamId === 3) {
  // If sparamId is 3 (PHA), apply the variable's value to paramRate
//  value = (base + plus) * $gameVariables.value(25) + flatBonus;
//} else {
  // For other s-params, use the default calculation
  value = (base + plus) * paramRate + flatBonus;
//}

// Final value
return value;
The sparam change is commented out but it is what I tried to make work before. It didn't do anything, though.
Hi there!
Thanks for taggin me @ATT_Turan !

@fallenlorelei I guess maybe your problem could be compatibility with the passive states of VS. I don't know how them work inside code. A long time ago, I did a compatibility on my plugin. But don't know what plugin you are using from them, and also, don't know if it is working on their current version:
Spoiler
1724444598364.png

Here are some thoughs:

When you use this function to set a value to a game variable: $gameVariables.setValue(30, 0.1), it will round the numbers.
So, it will return 0 anyway.
JavaScript:
Game_Variables.prototype.setValue = function(variableId, value) {
    if (variableId > 0 && variableId < $dataSystem.variables.length) {
        if (typeof value === "number") {
            value = Math.floor(value); // Here, it is rounding the value
        }
        this._data[variableId] = value;
        this.onChange();
    }
};

So the first thing you can do, is use this instead:
$gameVariables._data[ID] = 0.1

Another thing to keep in mind, is that the value for the S Params are in fact integers. So you don't need to think about % when dealing with them. The code will deal with them as % when needed.
Saying that, putting 0.1 on a variable value, should give you the result of 1.1, if the .pha is 1 by default.
I did it with a regular state, and it worked just fine:
Spoiler
1724444788481.png

1724444897267.png


Now, how your menu is dealing with it, is another thing. And I can't say anything about that.
The sparam change is commented out but it is what I tried to make work before. It didn't do anything, though.
Because $gameVariables.value() is hard-coded to return integer values.

If you change that to be $gameVariables._data[], like I've been doing in my examples, I think that may work.

Another thing to keep in mind, is that the value for the S Params are in fact integers.
...no, they're not?

1724445252717.png


1724445265900.png
...no, they're not?

1724445252717.png


1724445265900.png
What I mean is, if you set on the database like you did on the screenshot above, it will not be a value like 125, it will be like you posted 1.25 (which is not an integer, I know xD poor choice of word I used).
I tried to give an example together, like 0.1 + 1 = 1.1

Because I though maybe the OP was getting confused with the % stuff, that the database uses and also because of this code the OP used explaining the situation:
1724446097815.png

So when working with code, it does not need to think about adding a value to the .pha doing things like:
pha = 2*100
or
pha += 100/90
stuff like that ^^
@ATT_Turan @Eliaquim you both get to share ALL the hugs! You were right, changing it to $gameVariables._data[25] saved the day. I should have tried that first when Turan was using it.

So I'm using Eli's plugin with <DynParams: Alchemistry> on a VS Passive state and this code:
JavaScript:
const currentBonus = $gameVariables.value(26) + 1;
$gameVariables.setValue(26, currentBonus);

const newPharmacology =  (currentBonus * 0.01);

$gameVariables._data[25] = newPharmacology

console.log(`New Pharmacology Value: ${newPharmacology * 100}% stored as ${newPharmacology} in Variable 25`);
const actor = $gameActors.actor(1);
const phaValue = actor.sparam(3);
console.log(`Actor's New Pharmacology (PHA) value: ${phaValue}`);

1724446477198.png


It is beautiful...

COMMENCING HUG DISTRIBUTION
(っᵔ◡ᵔ)っ (っᵔ◡ᵔ)っ (っᵔ◡ᵔ)っ (っᵔ◡ᵔ)っ (っᵔ◡ᵔ)っ (っᵔ◡ᵔ)っ (っᵔ◡ᵔ)っ x infinity

thank you 🙂
Awesome! Glad you finally got it.
Cha....

Hugs......
Cha....

Hugs......
1724448218032.gif
I helped (a little). It's all gravy.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-add-to-pharmacology-outside-of-traits.171357/