Original Source
- Original title: MZ How to add to Pharmacology outside of traits?
- Original author: fallenlorelei
- Original date: August 23, 2024
- Source thread: https://forums.rpgmakerweb.com/threads/how-to-add-to-pharmacology-outside-of-traits.171357/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Javascript/Plugin Support
Summary
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...
Archived First Post
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
I tried making it not a passive state and just adding, but the stat wouldn't go above 101%.
VisuStella Core
// 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:
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`);
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
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:
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!
But removing the * 100 makes it stick to 200%
Not sure what else to do here. My math is probably wrong.
Nat Dynamic Traits: https://sleepy-kitten-games.itch.io/dynamic-traits-rmmz
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!!
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadCreator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...