mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-02 20:26:03 +08:00
Fix: Skill cast for Firefly and avoid view stuck
This commit is contained in:
@@ -15,7 +15,7 @@ namespace EggLink.DanhengServer.Game.Battle
|
||||
{
|
||||
public class BattleManager(PlayerInstance player) : BasePlayerManager(player)
|
||||
{
|
||||
public void StartBattle(SceneCastSkillCsReq req, MazeSkill skill)
|
||||
public void StartBattle(SceneCastSkillCsReq req, MazeSkill skill, List<uint> hitTargetEntityIdList)
|
||||
{
|
||||
if (Player.BattleInstance != null) return;
|
||||
var targetList = new List<EntityMonster>();
|
||||
@@ -25,7 +25,7 @@ namespace EggLink.DanhengServer.Game.Battle
|
||||
|
||||
if (Player.SceneInstance!.AvatarInfo.ContainsKey((int)req.AttackedByEntityId))
|
||||
{
|
||||
foreach (var entity in req.HitTargetEntityIdList)
|
||||
foreach (var entity in hitTargetEntityIdList)
|
||||
{
|
||||
Player.SceneInstance!.Entities.TryGetValue((int)entity, out var entityInstance);
|
||||
if (entityInstance is EntityMonster monster)
|
||||
@@ -52,7 +52,7 @@ namespace EggLink.DanhengServer.Game.Battle
|
||||
} else
|
||||
{
|
||||
bool isAmbushed = false;
|
||||
foreach (var entity in req.HitTargetEntityIdList)
|
||||
foreach (var entity in hitTargetEntityIdList)
|
||||
{
|
||||
if (Player.SceneInstance!.AvatarInfo.ContainsKey((int)entity))
|
||||
{
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using EggLink.DanhengServer.Data;
|
||||
using EggLink.DanhengServer.Game.Battle.Skill;
|
||||
using EggLink.DanhengServer.Game.Battle.Skill.Action;
|
||||
using EggLink.DanhengServer.Game.Scene;
|
||||
using EggLink.DanhengServer.Game.Scene.Entity;
|
||||
using EggLink.DanhengServer.Game.Battle.Skill;
|
||||
using EggLink.DanhengServer.Game.Player;
|
||||
using EggLink.DanhengServer.Proto;
|
||||
using EggLink.DanhengServer.Server.Packet.Send.Battle;
|
||||
using System;
|
||||
@@ -19,51 +16,56 @@ namespace EggLink.DanhengServer.Server.Packet.Recv.Battle
|
||||
public override void OnHandle(Connection connection, byte[] header, byte[] data)
|
||||
{
|
||||
var req = SceneCastSkillCsReq.Parser.ParseFrom(data);
|
||||
if (req != null)
|
||||
|
||||
PlayerInstance player = connection.Player!;
|
||||
MazeSkill mazeSkill = new([]);
|
||||
|
||||
// Get casting avatar
|
||||
connection.Player!.SceneInstance!.AvatarInfo.TryGetValue((int)req.AttackedByEntityId, out var caster);
|
||||
|
||||
if (caster != null)
|
||||
{
|
||||
var scene = connection.Player!.SceneInstance!;
|
||||
scene.AvatarInfo.TryGetValue((int)req.AttackedByEntityId, out var info);
|
||||
MazeSkill mazeSkill = new([]);
|
||||
|
||||
bool triggerBattle = true;
|
||||
if (info != null) // cast by player
|
||||
// Check if normal attack or technique was used
|
||||
if (req.SkillIndex > 0)
|
||||
{
|
||||
mazeSkill = MazeSkillManager.GetSkill(info.AvatarInfo.GetAvatarId(), (int)req.SkillIndex);
|
||||
} else
|
||||
{
|
||||
// monster
|
||||
foreach (var id in req.AssistMonsterEntityIdList)
|
||||
// Cast skill effects
|
||||
if (caster.AvatarInfo.Excel!.MazeSkill != null)
|
||||
{
|
||||
if (scene.Entities.TryGetValue((int)id, out var entity))
|
||||
{
|
||||
if (entity is EntityMonster || entity is EntityProp) // avoid monster hit monster
|
||||
{
|
||||
triggerBattle = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
mazeSkill = MazeSkillManager.GetSkill(caster.AvatarInfo.GetAvatarId(), (int)req.SkillIndex);
|
||||
mazeSkill.OnCast(caster);
|
||||
}
|
||||
}
|
||||
|
||||
if (req.AssistMonsterEntityIdList.Count == 0)
|
||||
{
|
||||
triggerBattle = false;
|
||||
}
|
||||
|
||||
if (!triggerBattle)
|
||||
{
|
||||
// didnt hit any target
|
||||
if (info != null && req.SkillIndex > 0)
|
||||
{
|
||||
mazeSkill.OnCast(info);
|
||||
}
|
||||
connection.SendPacket(new PacketSceneCastSkillScRsp(req.CastEntityId));
|
||||
}
|
||||
else
|
||||
{
|
||||
connection.Player!.BattleManager!.StartBattle(req, mazeSkill);
|
||||
mazeSkill = MazeSkillManager.GetSkill(caster.AvatarInfo.GetAvatarId(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (req.AssistMonsterEntityIdList.Count > 0)
|
||||
{
|
||||
List<uint> hitTargetEntityIdList = new List<uint>();
|
||||
if (req.HitTargetEntityIdList.Count > 0)
|
||||
{
|
||||
foreach (uint id in req.HitTargetEntityIdList)
|
||||
{
|
||||
hitTargetEntityIdList.Add(id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (uint id in req.AssistMonsterEntityIdList)
|
||||
{
|
||||
hitTargetEntityIdList.Add(id);
|
||||
}
|
||||
}
|
||||
// Start battle
|
||||
connection.Player!.BattleManager!.StartBattle(req, mazeSkill!, [.. hitTargetEntityIdList]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We had no targets for some reason
|
||||
connection.SendPacket(new PacketSceneCastSkillScRsp(req.CastEntityId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user