MZ Visustella Core Engine: Base stat increase X param?

No idea about JS in general btw.

Used to using yanfly's base parameters to increase HP based on DEF. But unsure what the code is supposed to be in this version, or if its even setup to be able to do it?

Parameter Settings -> Basic Parameters -> JS: Formula:

Spoiler: Code
// Determine the variables used in this calculation.

let paramId = arguments[0];

let base = this.paramBase(paramId);

let plus = this.paramPlus(paramId);

let paramRate = this.paramRate(paramId);

let buffRate = this.paramBuffRate(paramId);

let flatBonus = this.paramFlatBonus(paramId);

// Formula to determine total parameter value.

let value = (base + plus) * paramRate * buffRate + flatBonus;

// Determine the limits

const maxValue = this.paramMax(paramId);

const minValue = this.paramMin(paramId);

// Final value

return Math.round(value.clamp(minValue, maxValue));

This appears to be a ''how to'' but an example would help 😛

I tried adding this but didn't work.

let mhp = (base + plus) * paramRate * buffRate + flatBonus + a.def * 2;
Try something like this (untested):
JavaScript:
// Determine the variables used in this calculation.
let paramId = arguments[0];
let base = this.paramBase(paramId);
let plus = this.paramPlus(paramId);
let paramRate = this.paramRate(paramId);
let buffRate = this.paramBuffRate(paramId);
let flatBonus = this.paramFlatBonus(paramId);

// NEW: add 2 * DEF to the flat bonus for MHP (paramId 0)
if (paramId === 0) {
  flatBonus += 2 * this.def;
}

// Formula to determine total parameter value.
let value = (base + plus) * paramRate * buffRate + flatBonus;

// Determine the limits
const maxValue = this.paramMax(paramId);
const minValue = this.paramMin(paramId);

// Final value
return Math.round(value.clamp(minValue, maxValue));
This formula is used to calculate each basic param's value, based on paramId. ID ranges from 0~7: MHP, MMP, ATK, DEF, MAT, MDF, AGI, LUK. So this should just add an extra flat bonus to MHP equal to 2 times the DEF value.
Try something like this (untested):
JavaScript:
// Determine the variables used in this calculation.
let paramId = arguments[0];
let base = this.paramBase(paramId);
let plus = this.paramPlus(paramId);
let paramRate = this.paramRate(paramId);
let buffRate = this.paramBuffRate(paramId);
let flatBonus = this.paramFlatBonus(paramId);

// NEW: add 2 * DEF to the flat bonus for MHP (paramId 0)
if (paramId === 0) {
  flatBonus += 2 * this.def;
}

// Formula to determine total parameter value.
let value = (base + plus) * paramRate * buffRate + flatBonus;

// Determine the limits
const maxValue = this.paramMax(paramId);
const minValue = this.paramMin(paramId);

// Final value
return Math.round(value.clamp(minValue, maxValue));
This formula is used to calculate each basic param's value, based on paramId. ID ranges from 0~7: MHP, MMP, ATK, DEF, MAT, MDF, AGI, LUK. So this should just add an extra flat bonus to MHP equal to 2 times the DEF value.

Works like a charm tnx! I would never have figured that out tbh xD

Just out of curiosity, is it possible to have an percentage increase? Like 1 MDF = 3% MP?

Never mind, that might be weird. If you start with 10 MDF, would that be a 30% increase of 0?😛 I can just make it so you only get 1 mp per mdf but magic gear has %mp or -mp cost 😛

This simplified another mechanic greatly, instead of having various values of -PDR on armor, I can just have DEF reduce it instead 😀
Great! In case you're interested, for a percentage increase I think you could add to the paramRate value at a similar place (i.e. between "Determine the variables" and "Formula"), e.g.
JavaScript:
if (paramId === 0) {   // MHP
  paramRate += 0.03 * this.mdf;  // +3% per 1 MDF
}
By default this value is determined by traits. If no traits are present for that parameter, its value is 1, i.e. 100%.

Note that you should be a bit careful making parameters rely on one another like this: every basic parameter's value is determined by this formula and you don't want to end up with any infinite loops.
Great! In case you're interested, for a percentage increase I think you could add to the paramRate value at a similar place (i.e. between "Determine the variables" and "Formula"), e.g.
JavaScript:
if (paramId === 0) {   // MHP
  paramRate += 0.03 * this.mdf;  // +3% per 1 MDF
}
By default this value is determined by traits. If no traits are present for that parameter, its value is 1, i.e. 100%.

Note that you should be a bit careful making parameters rely on one another like this: every basic parameter's value is determined by this formula and you don't want to end up with any infinite loops.

Sweet, I actually tried this yesterday (based on your previous help) but I got an insane number due to using 3 instead of 0.03 xD Good to know if i ever need it 😛

Original thread: https://forums.rpgmakerweb.com/threads/visustella-core-engine-base-stat-increase-x-param.146526/