From 4da581224765806e4f026c88e5925392a6543a03 Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:32:45 -0400 Subject: [PATCH] Yippee Finished working in beta because I forgot main still gets updates --- src/battle.ts | 2 +- src/field/pokemon.ts | 95 +++++++++++++-------------- src/phases/attempt-capture-phase.ts | 2 + src/ui/save-slot-select-ui-handler.ts | 6 +- 4 files changed, 54 insertions(+), 51 deletions(-) diff --git a/src/battle.ts b/src/battle.ts index 7280958272f..0030b61bbd7 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -403,7 +403,7 @@ export default class Battle { scene.rngCounter = this.rngCounter++; scene.rngSeedOverride = this.battleSeed; const ret = Utils.randSeedInt(range, min); - console.log(reason, ret) + console.log("[RNG] " + reason, ret) this.battleSeedState = Phaser.Math.RND.state(); Phaser.Math.RND.state(state); //scene.setScoreText("RNG: " + tempRngCounter + " (Last sim: " + this.rngCounter + ")") diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 007023e2b31..b79e025b6f1 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2231,7 +2231,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return result; } else { const typeBoost = source.findTag(t => t instanceof TypeBoostTag && t.boostedType === moveType) as TypeBoostTag; - if (typeBoost?.oneUse) { + if (typeBoost?.oneUse && !simulated) { source.removeTag(typeBoost.tagType); } @@ -2378,19 +2378,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!isTypeImmune) { const levelMultiplier = (2 * source.level / 5 + 2); - var randRoll = simulated ? 1 : this.randSeedIntRange(85, 100, "Random damage roll") - const randomMultiplier = (randRoll / 100); - damage.value = Utils.toDmgValue((((levelMultiplier * power * sourceAtk.value / targetDef.value) / 50) + 2) - * stabMultiplier.value - * typeMultiplier - * arenaAttackTypeMultiplier.value - * screenMultiplier.value - * twoStrikeMultiplier.value - * targetMultiplier - * criticalMultiplier.value - * glaiveRushModifier.value - * randomMultiplier); - damageMin.value = Utils.toDmgValue((((levelMultiplier * powerLow * sourceAtkN.value / targetDefN.value) / 50) + 2) + if (simulated) { + damageMin.value = Utils.toDmgValue((((levelMultiplier * powerLow * sourceAtkN.value / targetDefN.value) / 50) + 2) * stabMultiplier.value * typeMultiplier * arenaAttackTypeMultiplier.value @@ -2400,7 +2389,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * criticalMultiplierN.value * glaiveRushModifier.value * 0.85); - damageMax.value = Utils.toDmgValue((((levelMultiplier * powerHigh * sourceAtkC.value / targetDefC.value) / 50) + 2) + damageMax.value = Utils.toDmgValue((((levelMultiplier * powerHigh * sourceAtkC.value / targetDefC.value) / 50) + 2) * stabMultiplier.value * typeMultiplier * arenaAttackTypeMultiplier.value @@ -2409,7 +2398,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * targetMultiplier * criticalMultiplierC.value * glaiveRushModifier.value); - + } else { + var randRoll = simulated ? 1 : this.randSeedIntRange(85, 100, "Random damage roll") + const randomMultiplier = (randRoll / 100); + damage.value = Utils.toDmgValue((((levelMultiplier * power * sourceAtk.value / targetDef.value) / 50) + 2) + * stabMultiplier.value + * typeMultiplier + * arenaAttackTypeMultiplier.value + * screenMultiplier.value + * twoStrikeMultiplier.value + * targetMultiplier + * criticalMultiplier.value + * glaiveRushModifier.value + * randomMultiplier); + } if (isPhysical && source.status && source.status.effect === StatusEffect.BURN) { if (!move.hasAttr(BypassBurnDamageReductionAttr)) { const burnDamageReductionCancelled = new Utils.BooleanHolder(false); @@ -2578,40 +2580,37 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (source.isPlayer() && !this.isPlayer()) { this.scene.applyModifiers(DamageMoneyRewardModifier, true, source, damage); } + // want to include is.Fainted() in case multi hit move ends early, still want to render message + if (source.turnData.hitsLeft === 1 || this.isFainted()) { + switch (result.hitResult) { + case HitResult.SUPER_EFFECTIVE: + this.scene.queueMessage(i18next.t("battle:hitResultSuperEffective")); + break; + case HitResult.NOT_VERY_EFFECTIVE: + this.scene.queueMessage(i18next.t("battle:hitResultNotVeryEffective")); + break; + case HitResult.ONE_HIT_KO: + this.scene.queueMessage(i18next.t("battle:hitResultOneHitKO")); + break; + case HitResult.IMMUNE: + case HitResult.NO_EFFECT: + console.error("Unhandled move immunity!"); + break; + } + } + + if (this.isFainted()) { + // set splice index here, so future scene queues happen before FaintedPhase + this.scene.setPhaseQueueSplice(); + this.scene.unshiftPhase(new FaintPhase(this.scene, this.getBattlerIndex(), isOneHitKo)); + this.resetSummonData(); + } + + if (damage) { + destinyTag?.lapse(source, BattlerTagLapseType.CUSTOM); + } } } - - // want to include is.Fainted() in case multi hit move ends early, still want to render message - if (simulated) { - // Don't show text - } else if (source.turnData.hitsLeft === 1 || this.isFainted()) { - switch (result.hitResult) { - case HitResult.SUPER_EFFECTIVE: - this.scene.queueMessage(i18next.t("battle:hitResultSuperEffective")); - break; - case HitResult.NOT_VERY_EFFECTIVE: - this.scene.queueMessage(i18next.t("battle:hitResultNotVeryEffective")); - break; - case HitResult.ONE_HIT_KO: - this.scene.queueMessage(i18next.t("battle:hitResultOneHitKO")); - break; - case HitResult.IMMUNE: - case HitResult.NO_EFFECT: - console.error("Unhandled move immunity!"); - break; - } - } - - if (this.isFainted() && !simulated) { - // set splice index here, so future scene queues happen before FaintedPhase - this.scene.setPhaseQueueSplice(); - this.scene.unshiftPhase(new FaintPhase(this.scene, this.getBattlerIndex(), isOneHitKo)); - this.resetSummonData(); - } - - if (!simulated && damage) { - destinyTag?.lapse(source, BattlerTagLapseType.CUSTOM); - } } break; case MoveCategory.STATUS: diff --git a/src/phases/attempt-capture-phase.ts b/src/phases/attempt-capture-phase.ts index 6c9e9127520..a93adb19fc0 100644 --- a/src/phases/attempt-capture-phase.ts +++ b/src/phases/attempt-capture-phase.ts @@ -63,6 +63,8 @@ export class AttemptCapturePhase extends PokemonPhase { const y = Math.round(65536 / Math.sqrt(Math.sqrt(255 / x))); const fpOffset = pokemon.getFieldPositionOffset(); + LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "Poké Ball Throw") + const pokeballAtlasKey = getPokeballAtlasKey(this.pokeballType); this.pokeball = this.scene.addFieldSprite(16, 80, "pb", pokeballAtlasKey); this.pokeball.setOrigin(0.5, 0.625); diff --git a/src/ui/save-slot-select-ui-handler.ts b/src/ui/save-slot-select-ui-handler.ts index 9295aae56eb..37c21631a82 100644 --- a/src/ui/save-slot-select-ui-handler.ts +++ b/src/ui/save-slot-select-ui-handler.ts @@ -372,6 +372,8 @@ class SessionSlot extends Phaser.GameObjects.Container { this.add(pokemonIconsContainer); + const modifiersModule = await import("../modifier/modifier"); + const modifierIconsContainer = this.scene.add.container(148, 30); modifierIconsContainer.setScale(0.5); let visibleModifierIndex = 0; @@ -379,13 +381,13 @@ class SessionSlot extends Phaser.GameObjects.Container { const itemDisplayLimit = 9 for (const m of data.modifiers) { const modifier = m.toModifier(this.scene, modifiersModule[m.className]); - if (modifier instanceof PokemonHeldItemModifier) { + if (modifier instanceof Modifier.PokemonHeldItemModifier) { continue; } numberOfModifiers++; } for (const m of data.modifiers) { - const modifier = m.toModifier(this.scene, Modifier[m.className]); + const modifier = m.toModifier(this.scene, modifiersModule[m.className]); if (modifier instanceof Modifier.PokemonHeldItemModifier) { continue; }