From 6d54efbbf66f3eb191ffa04910f0b95cac7e9a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Mon, 1 Dec 2025 01:45:19 +0800 Subject: [PATCH] =?UTF-8?q?```=20fix(fight):=20=E4=BF=AE=E5=A4=8DNPC?= =?UTF-8?q?=E6=88=98=E6=96=97=E9=80=BB=E8=BE=91=E5=92=8C=E7=8E=A9=E5=AE=B6?= =?UTF-8?q?=E5=AE=A0=E7=89=A9=E5=88=9D=E5=A7=8B=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了在与NPC战斗时AI玩家技能释放的逻辑错误,确保AI能够正确获取行动。 同时修正了玩家参战宠物的CatchTime生成方式,避免数据冲突。 此外,移除了大乱斗模式中不必要的延迟逻辑,并添加了战斗开始与结束的调试日志输出。 ``` --- logic/service/fight/fightc.go | 14 ++++++++------ logic/service/fight/input.go | 7 ++++--- logic/service/fight/loop.go | 8 ++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index e5a6cc6ea..a2c95dc6d 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -314,14 +314,16 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { f.closefight = true // break - } - if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC { - if _, ok := defender.Player.(*player.AI_player); ok { - defender.GetAction(f.Our) - //panic("AI自动技能") - } + } else { + if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC { + if _, ok := defender.Player.(*player.AI_player); ok { + defender.GetAction(f.Our) + //panic("AI自动技能") + } + } } + attacker.CanChange = true break } diff --git a/logic/service/fight/input.go b/logic/service/fight/input.go index 6614c2c7d..cbc2a80b1 100644 --- a/logic/service/fight/input.go +++ b/logic/service/fight/input.go @@ -162,12 +162,13 @@ func (f *FightC) initplayer(c common.PlayerI) (*input.Input, errorcode.ErrorCode initmeetpet() } for i, v := range meetpet { + v1 := v if len(in.AllPet) > 2 { break } - v.CatchTime = uint32(i) - in.AllPet = append(in.AllPet, info.CreateBattlePetEntity(v, f.rand)) + v1.CatchTime = c.GetInfo().UserID + uint32(i)*1000000 + in.AllPet = append(in.AllPet, info.CreateBattlePetEntity(v1, f.rand)) } //in.AllPet = in.AllPet[:3] @@ -276,7 +277,7 @@ func NewFight(p1, p2 common.PlayerI, fn func(*info.FightOverInfo)) (*FightC, err } f.Broadcast(func(ff *input.Input) { - //ff.InitEFFect(&f.FightStartOutboundInfo) + fmt.Println("战斗开始信息", ff.UserID) ff.Player.SendPackCmd(2503, &f.ReadyInfo) }) diff --git a/logic/service/fight/loop.go b/logic/service/fight/loop.go index d22925a8f..8dcced1d8 100644 --- a/logic/service/fight/loop.go +++ b/logic/service/fight/loop.go @@ -67,10 +67,6 @@ func (f *FightC) battleLoop() { } } - } else { - - //大乱斗,给个延迟 - <-time.After(500) } }) @@ -79,7 +75,11 @@ func (f *FightC) battleLoop() { f.callback(&f.FightOverInfo) //先执行回调,再执行返回信息,在回调内修改战斗判断 } + //大乱斗,给个延迟 + //<-time.After(1000) f.Broadcast(func(ff *input.Input) { + + fmt.Println("战斗结束信息", ff.UserID) ff.Player.SendPackCmd(2506, &f.FightOverInfo) ff.Player.QuitFight()