```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

feat(fight): 添加旧组队协议支持并优化战斗系统

- 实现了旧组队协议相关功能,包括GroupReadyFightFinish、GroupUseSkill、
  GroupUseItem、GroupChangePet和GroupEscape方法
- 新增组队战斗相关的入站信息结构体定义
- 实现了组队BOSS战斗逻辑,添加groupBossSlotLimit常量
- 重构宠物技能设置逻辑,调整金币消耗时机
- 优化战斗循环逻辑,添加对无行动槽位的处理
- 改进AI行动逻辑,增加多位置目标选择
This commit is contained in:
昔念
2026-04-08 01:28:55 +08:00
parent 918cdeac0e
commit 0051ac0be8
21 changed files with 993 additions and 67 deletions

View File

@@ -147,6 +147,9 @@ func (f *FightC) Over(c common.PlayerI, res model.EnumBattleOverReason) {
if f.GetInputByPlayer(c, true) != nil {
f.WinnerId = f.GetInputByPlayer(c, true).UserID
}
f.FightOverInfo.Reason = f.Reason
f.FightOverInfo.WinnerId = f.WinnerId
f.closefight = true
close(f.quit)
@@ -281,6 +284,17 @@ func (f *FightC) UseItemAt(c common.PlayerI, cacthid, itemid uint32, actorIndex,
// ReadyFight 处理玩家战斗准备逻辑,当满足条件时启动战斗循环
func (f *FightC) ReadyFight(c common.PlayerI) {
if f.LegacyGroupProtocol {
input := f.GetInputByPlayer(c, false)
if input == nil {
return
}
input.Finished = true
if f.checkBothPlayersReady(c) {
f.startLegacyGroupBattle()
}
return
}
f.Broadcast(func(ff *input.Input) {
ff.Player.SendPackCmd(2404, &info.S2C_2404{UserID: c.GetInfo().UserID})
@@ -355,8 +369,23 @@ func (f *FightC) startBattle(startInfo info.FightStartOutboundInfo) {
go f.battleLoop()
// 向双方广播战斗开始信息
if f.LegacyGroupProtocol {
f.Broadcast(func(ff *input.Input) {
f.sendLegacyGroupStart(ff.Player)
})
} else {
f.Broadcast(func(ff *input.Input) {
ff.Player.SendPackCmd(2504, &startInfo)
})
}
})
}
func (f *FightC) startLegacyGroupBattle() {
f.startl.Do(func() {
go f.battleLoop()
f.Broadcast(func(ff *input.Input) {
ff.Player.SendPackCmd(2504, &startInfo)
f.sendLegacyGroupStart(ff.Player)
})
})
}