feat(fight): 添加战斗前状态检查与经验获取限制判断

- 在挑战BOSS和野外怪物战斗前,增加 CanFight 状态检查,防止非法战斗
- 修复战斗胜利后经验与物品发放逻辑,增加 CanGetExp 判断避免重复获取
- 优化战斗中精灵切换逻辑与相关伤害效果处理,确保死亡标记正确设置
- 修正战斗轮次中被动切换行为及技能执行顺序问题
- 移除无用的管理员会话控制器和宠物融合模型代码
- 调整战斗输入结构体中的 Switch 类型为 Map 以提高查找效率
- 修复战斗中精灵存活判定条件,
This commit is contained in:
2025-12-01 23:31:48 +08:00
parent 6d54efbbf6
commit aad1e2f44c
21 changed files with 335 additions and 181 deletions

View File

@@ -47,7 +47,9 @@ func processMonID(bm string) string {
// 挑战地图boss
func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if !c.CanFight() {
return nil, errorcode.ErrorCodes.ErrSystemError
}
var mo *model.PetInfo
moinfo := &model.PlayerInfo{}
@@ -144,7 +146,9 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla
// 战斗野怪
func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if !c.CanFight() {
return nil, errorcode.ErrorCodes.ErrSystemError
}
refpet := c.OgreInfo.Data[data.Number]
if refpet.Id == 0 {
@@ -167,33 +171,36 @@ func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundIn
c.Fightinfo.Mode = info.BattleMode.MULTI_MODE //多人模式
fight.NewFight(c, ai, func(foi *info.FightOverInfo) {
c.Done.Exec(model.MilestoneMode.Moster, []uint32{c.Info.MapID, moinfo.PetList[0].ID, uint32(foi.Reason)}, func(results *model.MilestoneEX) uint32 {
if foi.Reason == 0 && foi.WinnerId == c.Info.UserID {
exp := uint32(xmlres.PetMAP[int(mo.ID)].YieldingExp) * mo.Level / 7
items := &info.S2C_GET_BOSS_MONSTER{
//EV: 45,
EXP: exp * 2,
}
if refpet.Item != 0 {
c.Done.Exec(model.MilestoneMode.Moster, []uint32{c.Info.MapID, moinfo.PetList[0].ID, uint32(foi.Reason)}, nil)
if foi.Reason == 0 && foi.WinnerId == c.Info.UserID {
items.ItemList = c.ItemAdd(model.ItemInfo{
ItemId: refpet.Item,
ItemCnt: uint32(grand.Intn(2) + 1),
})
}
evs := gconv.Uint32s(strings.Split(xmlres.PetMAP[int(mo.ID)].YieldingEV, " "))
items.EV = lo.Sum(evs)
c.Info.EVPool += lo.Sum(evs) //给予累计学习力
foi.Winpet.AddEV(evs)
c.Info.ExpPool += exp * 4
c.AddPetExp(foi.Winpet, uint32(exp)*2)
c.SendPackCmd(8004, items)
if !c.CanGetExp() {
return
}
return 0
exp := uint32(xmlres.PetMAP[int(mo.ID)].YieldingExp) * mo.Level / 7
items := &info.S2C_GET_BOSS_MONSTER{
//EV: 45,
EXP: exp * 2,
}
if refpet.Item != 0 {
items.ItemList = c.ItemAdd(model.ItemInfo{
ItemId: refpet.Item,
ItemCnt: uint32(grand.Intn(2) + 1),
})
}
evs := gconv.Uint32s(strings.Split(xmlres.PetMAP[int(mo.ID)].YieldingEV, " "))
items.EV = lo.Sum(evs)
c.Info.EVPool += lo.Sum(evs) //给予累计学习力
foi.Winpet.AddEV(evs)
c.Info.ExpPool += exp * 4
c.AddPetExp(foi.Winpet, uint32(exp)*2)
c.SendPackCmd(8004, items)
}
})
})
return nil, -1

View File

@@ -23,6 +23,10 @@ func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInbou
}
if !c.CanFight() {
return nil, errorcode.ErrorCodes.ErrSystemError
}
//c.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC
resp := &info.S2C_NOTE_HANDLE_FIGHT_INVITE{