Remove candy friendship loss from fainting

This commit is contained in:
AJ Fontaine 2024-11-29 23:35:53 -05:00
parent 5992564842
commit 293b5c063c

View File

@ -4272,6 +4272,7 @@ export class PlayerPokemon extends Pokemon {
} }
addFriendship(friendship: integer): void { addFriendship(friendship: integer): void {
if (friendship > 0) {
const starterSpeciesId = this.species.getRootSpeciesId(); const starterSpeciesId = this.species.getRootSpeciesId();
const fusionStarterSpeciesId = this.isFusion() && this.fusionSpecies ? this.fusionSpecies.getRootSpeciesId() : 0; const fusionStarterSpeciesId = this.isFusion() && this.fusionSpecies ? this.fusionSpecies.getRootSpeciesId() : 0;
const starterData = [ const starterData = [
@ -4279,19 +4280,19 @@ export class PlayerPokemon extends Pokemon {
fusionStarterSpeciesId ? this.scene.gameData.starterData[fusionStarterSpeciesId] : null fusionStarterSpeciesId ? this.scene.gameData.starterData[fusionStarterSpeciesId] : null
].filter(d => !!d); ].filter(d => !!d);
const amount = new Utils.IntegerHolder(friendship); const amount = new Utils.IntegerHolder(friendship);
this.scene.applyModifier(PokemonFriendshipBoosterModifier, true, this, amount);
let candyFriendshipMultiplier = CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER; let candyFriendshipMultiplier = CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER;
if (this.scene.eventManager.isEventActive()) { if (this.scene.eventManager.isEventActive()) {
candyFriendshipMultiplier *= this.scene.eventManager.getFriendshipMultiplier(); candyFriendshipMultiplier *= this.scene.eventManager.getFriendshipMultiplier();
} }
const starterAmount = new Utils.IntegerHolder(Math.floor(friendship * (this.scene.gameMode.isClassic && friendship > 0 ? candyFriendshipMultiplier : 1) / (fusionStarterSpeciesId ? 2 : 1))); const starterAmount = new Utils.IntegerHolder(Math.floor(friendship * (this.scene.gameMode.isClassic && friendship > 0 ? candyFriendshipMultiplier : 1) / (fusionStarterSpeciesId ? 2 : 1)));
if (amount.value > 0) {
this.scene.applyModifier(PokemonFriendshipBoosterModifier, true, this, amount);
this.scene.applyModifier(PokemonFriendshipBoosterModifier, true, this, starterAmount);
//Add friendship to this PlayerPokemon
this.friendship = Math.min(this.friendship + amount.value, 255); this.friendship = Math.min(this.friendship + amount.value, 255);
if (this.friendship === 255) { if (this.friendship === 255) {
this.scene.validateAchv(achvs.MAX_FRIENDSHIP); this.scene.validateAchv(achvs.MAX_FRIENDSHIP);
} }
//Add to candy progress for this mon's starter species and its fused species (if it has one)
starterData.forEach((sd: StarterDataEntry, i: integer) => { starterData.forEach((sd: StarterDataEntry, i: integer) => {
const speciesId = !i ? starterSpeciesId : fusionStarterSpeciesId as Species; const speciesId = !i ? starterSpeciesId : fusionStarterSpeciesId as Species;
sd.friendship = (sd.friendship || 0) + starterAmount.value; sd.friendship = (sd.friendship || 0) + starterAmount.value;
@ -4301,10 +4302,8 @@ export class PlayerPokemon extends Pokemon {
} }
}); });
} else { } else {
this.friendship = Math.max(this.friendship + amount.value, 0); //Lose friendship upon fainting
for (const sd of starterData) { this.friendship = Math.max(this.friendship + friendship, 0);
sd.friendship = Math.max((sd.friendship || 0) + starterAmount.value, 0);
}
} }
} }
/** /**