[Beta][P2 Bug] Fix macho brace stat calculation for HP (#4467)
This commit is contained in:
parent
b426340aee
commit
edbb09f4d6
|
@ -952,32 +952,35 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
const baseStats = this.calculateBaseStats();
|
||||
// Using base stats, calculate and store stats one by one
|
||||
for (const s of PERMANENT_STATS) {
|
||||
let value = Math.floor(((2 * baseStats[s] + this.ivs[s]) * this.level) * 0.01);
|
||||
const statHolder = new Utils.IntegerHolder(Math.floor(((2 * baseStats[s] + this.ivs[s]) * this.level) * 0.01));
|
||||
if (s === Stat.HP) {
|
||||
value = value + this.level + 10;
|
||||
statHolder.value = statHolder.value + this.level + 10;
|
||||
this.scene.applyModifier(PokemonIncrementingStatModifier, this.isPlayer(), this, s, statHolder);
|
||||
if (this.hasAbility(Abilities.WONDER_GUARD, false, true)) {
|
||||
value = 1;
|
||||
statHolder.value = 1;
|
||||
}
|
||||
if (this.hp > value || this.hp === undefined) {
|
||||
this.hp = value;
|
||||
if (this.hp > statHolder.value || this.hp === undefined) {
|
||||
this.hp = statHolder.value;
|
||||
} else if (this.hp) {
|
||||
const lastMaxHp = this.getMaxHp();
|
||||
if (lastMaxHp && value > lastMaxHp) {
|
||||
this.hp += value - lastMaxHp;
|
||||
if (lastMaxHp && statHolder.value > lastMaxHp) {
|
||||
this.hp += statHolder.value - lastMaxHp;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
value += 5;
|
||||
statHolder.value += 5;
|
||||
const natureStatMultiplier = new Utils.NumberHolder(getNatureStatMultiplier(this.getNature(), s));
|
||||
this.scene.applyModifier(PokemonNatureWeightModifier, this.isPlayer(), this, natureStatMultiplier);
|
||||
if (natureStatMultiplier.value !== 1) {
|
||||
value = Math.max(Math[natureStatMultiplier.value > 1 ? "ceil" : "floor"](value * natureStatMultiplier.value), 1);
|
||||
statHolder.value = Math.max(Math[natureStatMultiplier.value > 1 ? "ceil" : "floor"](statHolder.value * natureStatMultiplier.value), 1);
|
||||
}
|
||||
this.scene.applyModifier(PokemonIncrementingStatModifier, this.isPlayer(), this, s, statHolder);
|
||||
}
|
||||
|
||||
this.setStat(s, value);
|
||||
statHolder.value = Utils.clampInt(statHolder.value, 1, Number.MAX_SAFE_INTEGER);
|
||||
|
||||
this.setStat(s, statHolder.value);
|
||||
}
|
||||
this.scene.applyModifier(PokemonIncrementingStatModifier, this.isPlayer(), this, this.stats);
|
||||
}
|
||||
|
||||
calculateBaseStats(): number[] {
|
||||
|
|
|
@ -998,26 +998,26 @@ export class PokemonIncrementingStatModifier extends PokemonHeldItemModifier {
|
|||
}
|
||||
|
||||
shouldApply(args: any[]): boolean {
|
||||
return super.shouldApply(args) && args.length === 2 && args[1] instanceof Array;
|
||||
return super.shouldApply(args) && args.length === 3 && args[2] instanceof Utils.IntegerHolder;
|
||||
}
|
||||
|
||||
apply(args: any[]): boolean {
|
||||
// Modifies the passed in stats[] array by +1 per stack for HP, +2 per stack for other stats
|
||||
// Modifies the passed in stat integer holder by +1 per stack for HP, +2 per stack for other stats
|
||||
// If the Macho Brace is at max stacks (50), adds additional 5% to total HP and 10% to other stats
|
||||
const targetToApply = args[0] as Pokemon;
|
||||
const isHp = args[1] === Stat.HP;
|
||||
const statHolder = args[2] as Utils.IntegerHolder;
|
||||
|
||||
args[1].forEach((v, i) => {
|
||||
const isHp = i === 0;
|
||||
// Doesn't modify HP if holder has Wonder Guard
|
||||
if (!isHp || !targetToApply.hasAbility(Abilities.WONDER_GUARD)) {
|
||||
let mult = 1;
|
||||
if (this.stackCount === this.getMaxHeldItemCount()) {
|
||||
mult = isHp ? 1.05 : 1.1;
|
||||
}
|
||||
const newVal = Math.floor((v + this.stackCount * (isHp ? 1 : 2)) * mult);
|
||||
args[1][i] = Math.min(Math.max(newVal, 1), 999999);
|
||||
if (isHp) {
|
||||
statHolder.value += this.stackCount;
|
||||
if (this.stackCount === this.getMaxHeldItemCount()) {
|
||||
statHolder.value = Math.floor(statHolder.value * 1.05);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
statHolder.value += 2 * this.stackCount;
|
||||
if (this.stackCount === this.getMaxHeldItemCount()) {
|
||||
statHolder.value = Math.floor(statHolder.value * 1.1);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue