```
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

@@ -19,11 +19,15 @@ func Shuffle[T any](slice []T) {
}
func (our *Input) GetAction() {
actorIndex := our.TeamSlotIndex()
targetIndex := our.RandomOpponentSlotIndex()
target := our.OpponentSlotAt(targetIndex)
next := our.Exec(func(t Effect) bool {
return t.HookAction()
})
scriptCtx := buildBossHookActionContext(our, next)
scriptCtx := buildBossHookActionContext(our, target, next)
if aiPlayer, ok := our.Player.(*player.AI_player); ok && aiPlayer.BossScript != "" {
scriptBoss := &configmodel.BossConfig{Script: aiPlayer.BossScript}
nextByScript, err := scriptBoss.RunHookActionScript(scriptCtx)
@@ -37,18 +41,18 @@ func (our *Input) GetAction() {
return
}
if applyBossScriptAction(our, scriptCtx) {
if applyBossScriptAction(our, scriptCtx, actorIndex, targetIndex) {
return
}
selfPet := our.FightC.GetCurrPET(our.Player)
selfPet := our.FightC.GetCurrPETAt(our.Player, actorIndex)
if selfPet == nil {
return
}
if selfPet.Info.Hp <= 0 {
for _, v := range our.AllPet {
if v.Info.Hp > 0 {
our.FightC.ChangePet(our.Player, v.Info.CatchTime)
our.FightC.ChangePetAt(our.Player, v.Info.CatchTime, actorIndex)
return
}
}
@@ -68,9 +72,12 @@ func (our *Input) GetAction() {
if !s.CanUse() {
continue
}
s.DamageValue = our.CalculatePower(our.Opp, s)
if target == nil {
continue
}
s.DamageValue = our.CalculatePower(target, s)
oppPet := our.Opp.CurrentPet()
oppPet := target.CurrentPet()
if oppPet == nil {
continue
}
@@ -99,13 +106,13 @@ func (our *Input) GetAction() {
}
if usedskill != nil {
our.FightC.UseSkill(our.Player, uint32(usedskill.XML.ID))
our.FightC.UseSkillAt(our.Player, uint32(usedskill.XML.ID), actorIndex, targetIndex)
} else {
our.FightC.UseSkill(our.Player, 0)
our.FightC.UseSkillAt(our.Player, 0, actorIndex, targetIndex)
}
}
func buildBossHookActionContext(our *Input, hookAction bool) *configmodel.BossHookActionContext {
func buildBossHookActionContext(our, opponent *Input, hookAction bool) *configmodel.BossHookActionContext {
ctx := &configmodel.BossHookActionContext{
HookAction: hookAction,
Action: "auto",
@@ -150,8 +157,8 @@ func buildBossHookActionContext(our *Input, hookAction bool) *configmodel.BossHo
if our.AttackValue != nil {
ctx.OurAttack = convertAttackValue(our.AttackValue)
}
if our.Opp != nil {
if oppPet := our.Opp.CurrentPet(); oppPet != nil {
if opponent != nil {
if oppPet := opponent.CurrentPet(); oppPet != nil {
ctx.Opp = &configmodel.BossHookPetContext{
PetID: oppPet.Info.ID,
CatchTime: oppPet.Info.CatchTime,
@@ -159,8 +166,8 @@ func buildBossHookActionContext(our *Input, hookAction bool) *configmodel.BossHo
MaxHp: oppPet.Info.MaxHp,
}
}
if our.Opp.AttackValue != nil {
ctx.OppAttack = convertAttackValue(our.Opp.AttackValue)
if opponent.AttackValue != nil {
ctx.OppAttack = convertAttackValue(opponent.AttackValue)
}
}
@@ -195,7 +202,7 @@ func convertAttackValue(src *playermodel.AttackValue) *configmodel.BossHookAttac
}
}
func applyBossScriptAction(our *Input, ctx *configmodel.BossHookActionContext) bool {
func applyBossScriptAction(our *Input, ctx *configmodel.BossHookActionContext, actorIndex, targetIndex int) bool {
if our == nil || ctx == nil {
return false
}
@@ -204,10 +211,10 @@ func applyBossScriptAction(our *Input, ctx *configmodel.BossHookActionContext) b
case "", "auto":
return false
case "skill", "use_skill", "useskill":
our.FightC.UseSkill(our.Player, ctx.SkillID)
our.FightC.UseSkillAt(our.Player, ctx.SkillID, actorIndex, targetIndex)
return true
case "switch", "change_pet", "changepet":
our.FightC.ChangePet(our.Player, ctx.CatchTime)
our.FightC.ChangePetAt(our.Player, ctx.CatchTime, actorIndex)
return true
default:
return false