Rework scene skill handler a bit

This commit is contained in:
Melledy 2023-11-08 18:02:44 -08:00
parent e15d91bfd8
commit ac494b9d13
6 changed files with 61 additions and 28 deletions

View File

@ -23,12 +23,12 @@ public class SkillAbilityInfo {
// Skip if not a maze skill
if (ability.getName().contains("MazeSkill")) {
skill = new MazeSkill(avatarExcel);
skill = new MazeSkill(avatarExcel, 2);
avatarExcel.setMazeSkill(skill);
actionList = skill.getCastActions();
} else if (ability.getName().contains("NormalAtk")) {
skill = new MazeSkill(avatarExcel);
skill = new MazeSkill(avatarExcel, 1);
avatarExcel.setMazeAttack(skill);
actionList = skill.getAttackActions();
@ -64,13 +64,18 @@ public class SkillAbilityInfo {
for (TaskInfo t : task.getSuccessTaskList()) {
parseTask(skill, actionList, t);
}
} else if (task.getOnAttack() != null) {
if (task.getType().contains("AdventureTriggerAttack")) {
} else if (task.getType().contains("AdventureTriggerAttack")) {
if (task.getOnAttack() != null) {
for (TaskInfo t : task.getOnAttack()) {
parseTask(skill, skill.getAttackActions(), t);
}
}
if (skill.getIndex() == 2) {
skill.setTriggerBattle(task.isTriggerBattle());
}
} else if (task.getType().contains("AdventureFireProjectile")) {
for (TaskInfo t : task.getOnAttack()) {
if (task.getOnProjectileHit() != null) {
for (TaskInfo t : task.getOnProjectileHit()) {
parseTask(skill, skill.getAttackActions(), t);
}
}

View File

@ -18,10 +18,12 @@ public class TaskInfo {
@SerializedName(value = "ID", alternate = {"SummonUnitID"})
private int ID;
private boolean TriggerBattle = true;
private DynamicFloat LifeTime;
private List<TaskInfo> OnAttack;
private List<TaskInfo> SuccessTaskList;
private List<TaskInfo> OnProjectileHit;
public String getType() {
return this.$type;

View File

@ -7,7 +7,7 @@ import emu.lunarcore.data.GameDepot;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import emu.lunarcore.data.ResourceType.LoadPriority;
import emu.lunarcore.game.inventory.ItemRarity;
import lombok.Getter;
@Getter

View File

@ -8,6 +8,7 @@ import emu.lunarcore.data.GameData;
import emu.lunarcore.data.excel.CocoonExcel;
import emu.lunarcore.data.excel.StageExcel;
import emu.lunarcore.game.avatar.GameAvatar;
import emu.lunarcore.game.battle.skills.MazeSkill;
import emu.lunarcore.game.enums.StageType;
import emu.lunarcore.game.player.Player;
import emu.lunarcore.game.scene.entity.EntityMonster;
@ -29,7 +30,7 @@ public class BattleService extends BaseGameService {
super(server);
}
public void startBattle(Player player, int casterId, int attackedGroupId, boolean castedSkill, Set<Integer> targets) {
public void startBattle(Player player, int casterId, int attackedGroupId, MazeSkill castedSkill, Set<Integer> targets) {
// Setup variables
List<GameEntity> targetEntities = new ArrayList<>();
boolean isPlayerCaster = false; // Set true if the player is the one casting
@ -115,16 +116,14 @@ public class BattleService extends BaseGameService {
if (avatar != null) {
// Maze skill attack event
if (castedSkill) { // Dont need to null check maze skill since we already did it in HandlerSceneCastSkillCsReq
avatar.getExcel().getMazeSkill().onAttack(avatar, battle);
} else if (avatar.getExcel().getMazeAttack() != null) {
avatar.getExcel().getMazeAttack().onAttack(avatar, battle);
if (castedSkill != null) {
castedSkill.onAttack(avatar, battle);
}
// Add elemental weakness buff to enemies
MazeBuff buff = battle.addBuff(avatar.getExcel().getDamageType().getEnterBattleBuff(), battle.getLineup().getLeader());
if (buff != null) {
buff.addTargetIndex(battle.getLineup().getLeader());
buff.addDynamicValue("SkillIndex", castedSkill ? 2 : 1);
buff.addDynamicValue("SkillIndex", castedSkill != null ? castedSkill.getIndex() : 1);
}
}
}

View File

@ -8,15 +8,21 @@ import emu.lunarcore.game.avatar.GameAvatar;
import emu.lunarcore.game.battle.Battle;
import emu.lunarcore.proto.MotionInfoOuterClass.MotionInfo;
import lombok.Getter;
import lombok.Setter;
@Getter
public class MazeSkill {
private int id;
private int index;
private List<MazeSkillAction> castActions;
private List<MazeSkillAction> attackActions;
public MazeSkill(AvatarExcel excel) {
@Setter private boolean triggerBattle;
public MazeSkill(AvatarExcel excel, int index) {
this.id = excel.getAvatarID();
this.index = index;
this.triggerBattle = true;
this.castActions = new ArrayList<>();
this.attackActions = new ArrayList<>();
}

View File

@ -5,6 +5,7 @@ import java.util.Set;
import emu.lunarcore.game.avatar.GameAvatar;
import emu.lunarcore.game.battle.skills.MazeSkill;
import emu.lunarcore.game.player.Player;
import emu.lunarcore.proto.SceneCastSkillCsReqOuterClass.SceneCastSkillCsReq;
import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.server.packet.CmdId;
@ -20,20 +21,33 @@ public class HandlerSceneCastSkillCsReq extends PacketHandler {
public void handle(GameSession session, byte[] header, byte[] data) throws Exception {
var req = SceneCastSkillCsReq.parseFrom(data);
boolean castedSkill = false;
// Setup variables
Player player = session.getPlayer();
MazeSkill skill = null;
// Check if player casted a maze skill
if (req.getSkillIndex() > 0 && session.getPlayer().getScene().getAvatarEntityIds().contains(req.getCasterId())) {
if (player.getScene().getAvatarEntityIds().contains(req.getCasterId())) {
// Get casting avatar
GameAvatar caster = player.getCurrentLeaderAvatar();
// Sanity check, but should never happen
if (caster == null) {
session.send(new PacketSceneCastSkillScRsp(req.getAttackedGroupId()));
return;
}
// Check if normal attack or technique was used
if (req.getSkillIndex() > 0) {
// Spend one skill point
session.getPlayer().getCurrentLineup().removeMp(1);
session.send(new PacketSceneCastSkillMpUpdateScNotify(req.getAttackedGroupId(), session.getPlayer().getLineupManager().getMp()));
player.getCurrentLineup().removeMp(1);
session.send(new PacketSceneCastSkillMpUpdateScNotify(req.getAttackedGroupId(), player.getCurrentLineup().getMp()));
// Cast skill effects
GameAvatar caster = session.getPlayer().getCurrentLeaderAvatar();
if (caster != null && caster.getExcel().getMazeSkill() != null) {
MazeSkill skill = caster.getExcel().getMazeSkill();
if (caster.getExcel().getMazeSkill() != null) {
skill = caster.getExcel().getMazeSkill();
skill.onCast(caster, req.getTargetMotion());
// Set flag
castedSkill = true;
}
} else {
skill = caster.getExcel().getMazeAttack();
}
}
@ -43,9 +57,16 @@ public class HandlerSceneCastSkillCsReq extends PacketHandler {
req.getHitTargetIdList().forEach(targets::add);
req.getAssistMonsterIdList().forEach(targets::add);
// Start battle
session.getServer().getBattleService().startBattle(session.getPlayer(), req.getCasterId(), req.getAttackedGroupId(), castedSkill, targets);
// Check if we can start a battle
if (skill != null && !skill.isTriggerBattle()) {
// Skip battle if our technique does not trigger a battle
session.send(new PacketSceneCastSkillScRsp(req.getAttackedGroupId()));
} else {
// Start battle normally
session.getServer().getBattleService().startBattle(player, req.getCasterId(), req.getAttackedGroupId(), skill, targets);
}
} else {
// We had no targets for some reason
session.send(new PacketSceneCastSkillScRsp(req.getAttackedGroupId()));
}
}