mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-02 20:26:03 +08:00
84 lines
3.2 KiB
C#
84 lines
3.2 KiB
C#
using EggLink.DanhengServer.Data;
|
|
using EggLink.DanhengServer.Data.Config;
|
|
using EggLink.DanhengServer.GameServer.Game.Battle.Skill;
|
|
using EggLink.DanhengServer.GameServer.Server.Packet.Send.Scene;
|
|
using EggLink.DanhengServer.Kcp;
|
|
using EggLink.DanhengServer.Proto;
|
|
|
|
namespace EggLink.DanhengServer.GameServer.Server.Packet.Recv.Scene;
|
|
|
|
[Opcode(CmdIds.SceneCastSkillCsReq)]
|
|
public class HandlerSceneCastSkillCsReq : Handler
|
|
{
|
|
public override async Task OnHandle(Connection connection, byte[] header, byte[] data)
|
|
{
|
|
var req = SceneCastSkillCsReq.Parser.ParseFrom(data);
|
|
|
|
var player = connection.Player!;
|
|
MazeSkill mazeSkill = new([], req);
|
|
|
|
// Get casting avatar
|
|
connection.Player!.SceneInstance!.AvatarInfo.TryGetValue((int)req.AttackedByEntityId, out var caster);
|
|
|
|
if (caster != null)
|
|
{
|
|
if (req.MazeAbilityStr != "")
|
|
{
|
|
// overwrite
|
|
caster.AvatarInfo.GetCurAvatarConfig().MazeAbility.TryGetValue(req.MazeAbilityStr, out AbilityInfo? ability);
|
|
if (ability != null)
|
|
{
|
|
mazeSkill = MazeSkillManager.GetSkill(caster.AvatarInfo.CurAvatarId, ability, req);
|
|
mazeSkill.OnCast(caster, player);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Check if normal attack or technique was used
|
|
if (req.SkillIndex > 0)
|
|
{
|
|
// Cast skill effects
|
|
var excel = caster.AvatarInfo.CurAvatarId > 0
|
|
? GameData.AvatarConfigData[caster.AvatarInfo.CurAvatarId]
|
|
: caster.AvatarInfo.GetCurAvatarConfig();
|
|
if (excel != null && excel.MazeSkill != null)
|
|
{
|
|
mazeSkill = MazeSkillManager.GetSkill(caster.AvatarInfo.CurAvatarId, (int)req.SkillIndex,
|
|
req);
|
|
mazeSkill.OnCast(caster, player);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
mazeSkill = MazeSkillManager.GetSkill(caster.AvatarInfo.CurAvatarId, 0, req);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (req.AssistEntityIdList.Count > 0)
|
|
{
|
|
if (caster != null && caster.AvatarInfo.BaseAvatarId == 1218 && req.SkillIndex == 1)
|
|
{
|
|
// Avoid Jiqoqiu's E skill
|
|
await connection.SendPacket(new PacketSceneCastSkillScRsp(req.CastEntityId, []));
|
|
}
|
|
else
|
|
{
|
|
var hitTargetEntityIdList = new List<uint>();
|
|
if (req.AssistEntityIdList.Count > 0)
|
|
foreach (var id in req.AssistEntityIdList)
|
|
hitTargetEntityIdList.Add(id);
|
|
else
|
|
foreach (var id in req.HitTargetEntityIdList)
|
|
hitTargetEntityIdList.Add(id);
|
|
// Start battle
|
|
await connection.Player!.BattleManager!.StartBattle(req, mazeSkill, [.. hitTargetEntityIdList]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// We had no targets for some reason
|
|
await connection.SendPacket(new PacketSceneCastSkillScRsp(req.CastEntityId, []));
|
|
}
|
|
}
|
|
} |