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:
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...