Skip to content

Commit

Permalink
Fix techniques that reduce enemy toughness
Browse files Browse the repository at this point in the history
  • Loading branch information
Melledy committed Jun 22, 2024
1 parent 39644fe commit 7199895
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/main/java/emu/lunarcore/data/config/SkillAbilityInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ private void parseTask(MazeSkill skill, List<MazeSkillAction> actionList, TaskIn
actionList.add(new MazeSkillModifySP(50));
} else if (task.getType().contains("CreateSummonUnit")) {
skill.setTriggerBattle(false);
} else if (task.getType().contains("AddAdventureModifier")) {
skill.addAdventureModifier(task.getModifierName());
} else if (task.getType().contains("AdventureSetAttackTargetMonsterDie")) {
actionList.add(new MazeSkillSetAttackTargetMonsterDie());
} else if (task.getSuccessTaskList() != null) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/emu/lunarcore/data/config/TaskInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class TaskInfo {
@SerializedName(value = "ID", alternate = {"SummonUnitID"})
private int ID;

private String ModifierName;
private boolean TriggerBattle = true;
private DynamicFloat LifeTime;

Expand Down
17 changes: 7 additions & 10 deletions src/main/java/emu/lunarcore/game/battle/Battle.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
import emu.lunarcore.proto.SceneBattleInfoOuterClass.SceneBattleInfo;
import emu.lunarcore.proto.SceneBattleInfoOuterClass.SceneBattleInfo.BattleTargetInfoEntry;
import emu.lunarcore.util.Utils;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.*;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -33,9 +30,9 @@ public class Battle {
private final Player player;
private final PlayerLineup lineup;
private final List<EntityMonster> npcMonsters;
private final List<MazeBuff> buffs;
private final List<BattleMonsterWave> waves;
private final List<GameItem> drops;
private final Int2ObjectMap<MazeBuff> buffs;
private final long timestamp;

private BattleStage stage; // Main battle stage
Expand All @@ -60,7 +57,7 @@ private Battle(Player player, PlayerLineup lineup) {
this.player = player;
this.lineup = lineup;
this.npcMonsters = new ArrayList<>();
this.buffs = new ArrayList<>();
this.buffs = new Int2ObjectLinkedOpenHashMap<>();
this.waves = new ArrayList<>();
this.drops = new ArrayList<>();
this.timestamp = System.currentTimeMillis();
Expand Down Expand Up @@ -190,12 +187,12 @@ public MazeBuff addBuff(int buffId, int ownerIndex, int waveFlag) {
}

public MazeBuff addBuff(MazeBuff buff) {
this.buffs.add(buff);
this.buffs.put(buff.getId(), buff);
return buff;
}

public boolean hasBuff(int buffId) {
return this.buffs.stream().filter(buff -> buff.getId() == buffId).findFirst().isPresent();
return this.buffs.containsKey(buffId);
}

public void clearBuffs() {
Expand Down Expand Up @@ -250,8 +247,8 @@ public SceneBattleInfo toProto() {
}

// Buffs
for (MazeBuff buff : this.getBuffs()) {
proto.addBuffList(buff.toProto());
for (var entry : this.getBuffs().int2ObjectEntrySet()) {
proto.addBuffList(entry.getValue().toProto());
}

// Client turn snapshots
Expand Down
21 changes: 16 additions & 5 deletions src/main/java/emu/lunarcore/game/battle/BattleService.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,22 @@ public void startBattle(Player player, int casterId, int attackedGroupId, MazeSk

// Add buffs to battle
if (castingAvatar != null) {
// Add elemental weakness debuff to enemies
MazeBuff buff = battle.addBuff(castingAvatar.getExcel().getDamageType().getEnterBattleBuff(), battle.getLineup().getLeader());
if (buff != null && castedSkill != null) {
buff.addTargetIndex(battle.getLineup().getLeader());
buff.addDynamicValue("SkillIndex", castedSkill.getIndex());
// The player is the one attacking
if (castedSkill != null) {
// Get elemental weakness debuff id
int buffId = castingAvatar.getExcel().getDamageType().getEnterBattleBuff();

// Replace with a special debuff that ignores all toughness
if (castedSkill.hasAdventureModifier("ADV_StageAbility_Maze_IgnoreWeakness_MazeSkillMark")) {
buffId = 1000119;
}

// Add buff to battle
MazeBuff buff = battle.addBuff(buffId, battle.getLineup().getLeader());
if (buff != null) {
buff.addTargetIndex(battle.getLineup().getLeader());
buff.addDynamicValue("SkillIndex", castedSkill.getIndex());
}
}
} else {
// Ambush debuff (from monsters)
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/emu/lunarcore/game/battle/skills/MazeSkill.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import emu.lunarcore.data.excel.AvatarExcel;
import emu.lunarcore.game.avatar.GameAvatar;
import emu.lunarcore.game.scene.entity.GameEntity;
import emu.lunarcore.proto.MotionInfoOuterClass.MotionInfo;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -16,6 +18,7 @@ public class MazeSkill {
private int index;
private List<MazeSkillAction> castActions;
private List<MazeSkillAction> attackActions;
private Set<String> adventureModifiers;

@Setter private boolean triggerBattle;

Expand All @@ -27,6 +30,20 @@ public MazeSkill(AvatarExcel excel, int index) {
this.attackActions = new ArrayList<>();
}

public void addAdventureModifier(String modifier) {
if (modifier == null) return;

if (this.adventureModifiers == null) {
this.adventureModifiers = new ObjectOpenHashSet<>();
}

this.adventureModifiers.add(modifier);
}

public boolean hasAdventureModifier(String modifier) {
return adventureModifiers.contains(modifier);
}

/**
* Triggered when player casts a skill
*/
Expand Down

0 comments on commit 7199895

Please sign in to comment.