From 6c9b27a232632709d1a83645c53bfa04000ec5d4 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 26 Oct 2023 21:42:53 -0400 Subject: [PATCH] Update enemy level formula for endless mode --- src/battle.ts | 20 ++++++++++++++++---- src/utils.ts | 7 +++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/battle.ts b/src/battle.ts index de0cbc2c2..c15b9d5cf 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -63,16 +63,28 @@ export default class Battle { private getLevelForWave(): integer { let baseLevel = 1 + this.waveIndex / 2 + Math.pow(this.waveIndex / 25, 2); + let bossMultiplier = this.waveIndex <= 250 ? 1.2 : Math.pow(1.2, this.waveIndex / 250); if (!(this.waveIndex % 10)) { - if (this.waveIndex === 200) - return 200; - return Math.floor(baseLevel * 1.2); + const ret = Math.floor(baseLevel * bossMultiplier); + if (this.waveIndex === 200 || !(this.waveIndex % 250)) + return Math.ceil(ret / 25) * 25; + return ret; } const deviation = 10 / this.waveIndex; - return Math.max(Math.round(baseLevel + Math.abs(Utils.randGauss(deviation))), 1); + const randLevel = Math.max(Math.round(baseLevel + Math.abs(Utils.randSeedGauss(deviation))), 1); + + if (this.waveIndex <= 250) + return randLevel; + + const waveRatio = Math.min(this.waveIndex - 250 / 250, 1); + + const easeInFunc = Phaser.Tweens.Builders.GetEaseFunction('Sine.easeIn'); + const easeOutFunc = Phaser.Tweens.Builders.GetEaseFunction('Sine.easeOut'); + + return Math.ceil(easeInFunc(waveRatio) * Math.floor(baseLevel * bossMultiplier) + easeOutFunc(1 - waveRatio) * randLevel); } getBattlerCount(): integer { diff --git a/src/utils.ts b/src/utils.ts index 037267555..3fbb16218 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -40,6 +40,13 @@ export function randGauss(value: number): number { return rand / value; } +export function randSeedGauss(value: number): number { + let rand = 0; + for(var i = value; i > 0; i--) + rand += Phaser.Math.RND.realInRange(0, 1); + return rand / value; +} + export function padInt(value: integer, length: integer, padWith?: string): string { if (!padWith) padWith = '0';