From b2718432cb59d18096dec6405ff870b8ed5c4c39 Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Wed, 31 Jul 2024 20:42:48 -0700 Subject: [PATCH] Fix some techniques not applying debuffs to monsters in battle --- src/main/java/emu/lunarcore/game/battle/Battle.java | 12 ++++++------ .../lunarcore/game/scene/entity/EntityMonster.java | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/emu/lunarcore/game/battle/Battle.java b/src/main/java/emu/lunarcore/game/battle/Battle.java index 981cf84..8eb9788 100644 --- a/src/main/java/emu/lunarcore/game/battle/Battle.java +++ b/src/main/java/emu/lunarcore/game/battle/Battle.java @@ -128,7 +128,10 @@ public class Battle { var wave = new BattleMonsterWave(stage); wave.getMonsters().addAll(stageMonsterWave); - // Handle npc monster + // Add wave to battle + this.getWaves().add(wave); + + // Add buffs from npc monsters if (npcMonster != null) { // Set wave custom level wave.setCustomLevel(npcMonster.getCustomLevel()); @@ -136,9 +139,6 @@ public class Battle { // Handle monster buffs npcMonster.applyBuffs(this, this.getWaves().size()); } - - // Finally add wave to battle - this.getWaves().add(wave); } } @@ -247,8 +247,8 @@ public class Battle { } // Buffs - for (var entry : this.getBuffs().int2ObjectEntrySet()) { - proto.addBuffList(entry.getValue().toProto()); + for (var buff : this.getBuffs().values()) { + proto.addBuffList(buff.toProto()); } // Client turn snapshots diff --git a/src/main/java/emu/lunarcore/game/scene/entity/EntityMonster.java b/src/main/java/emu/lunarcore/game/scene/entity/EntityMonster.java index 1575c76..a826aab 100644 --- a/src/main/java/emu/lunarcore/game/scene/entity/EntityMonster.java +++ b/src/main/java/emu/lunarcore/game/scene/entity/EntityMonster.java @@ -99,7 +99,7 @@ public class EntityMonster implements GameEntity, Tickable { this.tempBuffs.add(tempBuff); } - public synchronized void applyBuffs(Battle battle, int waveIndex) { + public synchronized void applyBuffs(Battle battle, int waveNum) { if (this.buffs != null) { for (var entry : this.buffs.int2ObjectEntrySet()) { // Check expiry for buff @@ -108,26 +108,26 @@ public class EntityMonster implements GameEntity, Tickable { } // Add buff to battle - this.applyBuff(battle, entry.getValue(), waveIndex); + this.applyBuff(battle, entry.getValue(), waveNum); } } if (this.getTempBuffs() != null) { for (var tempBuff : this.getTempBuffs()) { - this.applyBuff(battle, tempBuff, waveIndex); + this.applyBuff(battle, tempBuff, waveNum); } this.tempBuffs = null; } } - private boolean applyBuff(Battle battle, SceneBuff buff, int waveIndex) { + private boolean applyBuff(Battle battle, SceneBuff buff, int waveNum) { // Get index of owner in lineup int ownerIndex = battle.getLineup().indexOf(buff.getCasterAvatarId()); // Add buff to battle if owner exists if (ownerIndex != -1) { - battle.addBuff(buff.getBuffId(), ownerIndex, 1 << waveIndex); + battle.addBuff(buff.getBuffId(), ownerIndex, (1 << waveNum) - 1); return true; }