diff --git a/gs/game/game.go b/gs/game/game.go index 1d1c96fe..5013198e 100644 --- a/gs/game/game.go +++ b/gs/game/game.go @@ -143,10 +143,25 @@ func (g *Game) run() { } func (g *Game) gameMainLoopD() { - for times := 1; times <= 10000; times++ { - logger.Warn("start game main loop, times: %v", times) + times := 1 + panicCounter := 0 + lastPanicTime := time.Now().UnixNano() + for { + logger.Warn("game main loop start, times: %v", times) g.gameMainLoop() - logger.Warn("game main loop stop") + logger.Warn("game main loop stop, times: %v", times) + times++ + panicCounter++ + if panicCounter > 10 { + now := time.Now().UnixNano() + if now-lastPanicTime > int64(time.Second) { + panicCounter = 0 + lastPanicTime = now + } else { + logger.Error("!!! GAME MAIN LOOP STOP !!!") + break + } + } } } diff --git a/gs/game/game_command_controller.go b/gs/game/game_command_controller.go index 1c6299b1..b99f1415 100644 --- a/gs/game/game_command_controller.go +++ b/gs/game/game_command_controller.go @@ -11,6 +11,31 @@ import ( // 玩家游戏内GM命令格式解析模块 +// 以后不妨考虑改成米哈游版本的GM命令格式 + +func (c *CommandManager) GotoCommand(cmd *CommandMessage) { + split := strings.Split(cmd.Text, " ") + if len(split) != 4 { + return + } + if split[0] != "goto" { + return + } + x, err := strconv.ParseFloat(split[1], 64) + if err != nil { + return + } + y, err := strconv.ParseFloat(split[2], 64) + if err != nil { + return + } + z, err := strconv.ParseFloat(split[3], 64) + if err != nil { + return + } + c.gmCmd.GMTeleportPlayer(cmd.Executor.PlayerId, cmd.Executor.SceneId, x, y, z) +} + // HelpCommand 帮助命令 func (c *CommandManager) HelpCommand(cmd *CommandMessage) { c.SendMessage(cmd.Executor, @@ -26,11 +51,7 @@ func (c *CommandManager) HelpCommand(cmd *CommandMessage) { // tp [--u ] [--s ] {--t --x | --y | --z } func (c *CommandManager) TeleportCommand(cmd *CommandMessage) { // 执行者如果不是玩家则必须输入UID - player, ok := cmd.Executor.(*model.Player) - if !ok && cmd.Args["u"] == "" { - c.SendMessage(cmd.Executor, "你不是玩家请指定UID。") - return - } + player := cmd.Executor // 判断是否填写必备参数 // 目前传送的必备参数是任意包含一个就行 @@ -178,12 +199,7 @@ func (c *CommandManager) TeleportCommand(cmd *CommandMessage) { // GiveCommand 给予物品命令 // give [--u ] [--c ] --i func (c *CommandManager) GiveCommand(cmd *CommandMessage) { - // 执行者如果不是玩家则必须输入UID - player, ok := cmd.Executor.(*model.Player) - if !ok && cmd.Args["u"] == "" { - c.SendMessage(cmd.Executor, "你不是玩家请指定UID。") - return - } + player := cmd.Executor // 判断是否填写必备参数 if cmd.Args["i"] == "" { @@ -330,7 +346,7 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) { // GcgCommand Gcg测试命令 func (c *CommandManager) GcgCommand(cmd *CommandMessage) { - player := cmd.Executor.(*model.Player) + player := cmd.Executor GAME.GCGStartChallenge(player) c.SendMessage(cmd.Executor, "收到命令") } @@ -338,12 +354,7 @@ func (c *CommandManager) GcgCommand(cmd *CommandMessage) { // QuestCommand 任务控制命令 // quest [--u ] [--q ] --i func (c *CommandManager) QuestCommand(cmd *CommandMessage) { - // 执行者如果不是玩家则必须输入UID - player, ok := cmd.Executor.(*model.Player) - if !ok && cmd.Args["u"] == "" { - c.SendMessage(cmd.Executor, "你不是玩家请指定UID。") - return - } + player := cmd.Executor // 判断是否填写必备参数 if cmd.Args["i"] == "" { @@ -424,14 +435,14 @@ func (c *CommandManager) QuestCommand(cmd *CommandMessage) { // UnlockAllPointCommand 解锁所有锚点命令 func (c *CommandManager) UnlockAllPointCommand(cmd *CommandMessage) { - player := cmd.Executor.(*model.Player) + player := cmd.Executor c.gmCmd.GMUnlockAllPoint(player.PlayerId, player.SceneId) c.SendMessage(cmd.Executor, "已解锁玩家 UID:%v, 场景:%v,所有锚点。", player.PlayerId, player.SceneId) } // XLuaDebugCommand 主动开启客户端XLUA调试命令 func (c *CommandManager) XLuaDebugCommand(cmd *CommandMessage) { - player := cmd.Executor.(*model.Player) + player := cmd.Executor player.XLuaDebug = true c.SendMessage(cmd.Executor, "XLua Debug Enable") } diff --git a/gs/game/game_command_gm.go b/gs/game/game_command_gm.go index c0218faa..a064b4be 100644 --- a/gs/game/game_command_gm.go +++ b/gs/game/game_command_gm.go @@ -300,8 +300,8 @@ func (g *GMCmd) XLuaDebug(userId uint32, luacBase64 string) { }) } -func (g *GMCmd) PlayAudio() { - PlayAudio() +func (g *GMCmd) PlayAudio(v bool) { + go PlayAudio() } func (g *GMCmd) UpdateFrame(rgb bool) { diff --git a/gs/game/game_command_manager.go b/gs/game/game_command_manager.go index 0ee06475..510069cc 100644 --- a/gs/game/game_command_manager.go +++ b/gs/game/game_command_manager.go @@ -24,17 +24,21 @@ const ( // CommandFunc 命令执行函数 type CommandFunc func(*CommandMessage) +const ( + PlayerChatGM = iota // 玩家聊天GM + SystemFuncGM // 系统函数GM +) + // CommandMessage 命令消息 // 给下层执行命令时提供数据 type CommandMessage struct { + GMType int // GM类型 // 玩家聊天GM - // executor 玩家为 model.Player 类型 - // GM等为 string 类型 - Executor any // 执行者 + Executor *model.Player // 执行者 Text string // 命令原始文本 Name string // 命令前缀 Args map[string]string // 命令参数 - // 系统GM + // 系统函数GM FuncName string // 函数名 ParamList []string // 函数参数列表 } @@ -75,6 +79,7 @@ func (c *CommandManager) InitRouter() { c.commandPermMap = make(map[string]CommandPerm) { // 权限等级 0: 普通玩家 + c.RegisterRouter(CommandPermNormal, c.GotoCommand, "goto") c.RegisterRouter(CommandPermNormal, c.HelpCommand, "help", "帮助") c.RegisterRouter(CommandPermNormal, c.TeleportCommand, "teleport", "tp", "传送") c.RegisterRouter(CommandPermNormal, c.GiveCommand, "give", "item", "物品", "给予") @@ -125,7 +130,7 @@ func (c *CommandManager) PlayerInputCommand(player *model.Player, targetUid uint return } // 输入的命令将在主协程中处理 - c.commandTextInput <- &CommandMessage{Executor: player, Text: text} + c.commandTextInput <- &CommandMessage{GMType: PlayerChatGM, Executor: player, Text: text} } func (c *CommandManager) CallGMCmd(funcName string, paramList []string) bool { @@ -234,54 +239,62 @@ func (c *CommandManager) CallGMCmd(funcName string, paramList []string) bool { // HandleCommand 处理命令 // 主协程接收到命令消息后执行 func (c *CommandManager) HandleCommand(cmd *CommandMessage) bool { - // 系统GM 直接执行GM函数 - if cmd.FuncName != "" { + switch cmd.GMType { + case PlayerChatGM: + // TODO 米哈游版本传送命令 + if strings.Contains(cmd.Text, "goto") { + cmd.Name = "goto" + c.ExecCommand(cmd) + return true + } + + executor := cmd.Executor + + // 分割出命令的每个参数 + // 不区分命令的大小写 统一转为小写 + cmdSplit := strings.Split(strings.ToLower(cmd.Text), " --") + + // 分割出来啥也没有可能是个空的字符串 + // 此时将会返回的命令名和命令参数都为空 + if len(cmdSplit) == 0 { + return false + } + + // 命令参数 初始化 + cmd.Args = make(map[string]string, len(cmdSplit)-1) + + // 首个参数必是命令名 + cmd.Name = cmdSplit[0] + // 命令名后当然是命令的参数喽 + argSplit := cmdSplit[1:] + + // 我们要将命令的参数转换为键值对 + // 每个参数之间会有个空格分割 + for _, s := range argSplit { + cmdArg := strings.Split(s, " ") + + // 分割出来的参数只有一个那肯定不是键值对 + if len(cmdArg) < 2 { + c.SendMessage(executor, "格式错误,用法: %v --[参数名] [参数]。", cmd.Name) + return false + } + + argKey := cmdArg[0] // 参数的键 + argValue := cmdArg[1] // 参数的值 + + // 记录命令的参数 + cmd.Args[argKey] = argValue + } + + // 执行命令 + c.ExecCommand(cmd) + return true + case SystemFuncGM: logger.Info("run gm cmd, FuncName: %v, ParamList: %v", cmd.FuncName, cmd.ParamList) // 反射调用command_gm.go中的函数并反射解析传入参数类型 return c.CallGMCmd(cmd.FuncName, cmd.ParamList) } - - executor := cmd.Executor - - // 分割出命令的每个参数 - // 不区分命令的大小写 统一转为小写 - cmdSplit := strings.Split(strings.ToLower(cmd.Text), " --") - - // 分割出来啥也没有可能是个空的字符串 - // 此时将会返回的命令名和命令参数都为空 - if len(cmdSplit) == 0 { - return false - } - - // 命令参数 初始化 - cmd.Args = make(map[string]string, len(cmdSplit)-1) - - // 首个参数必是命令名 - cmd.Name = cmdSplit[0] - // 命令名后当然是命令的参数喽 - argSplit := cmdSplit[1:] - - // 我们要将命令的参数转换为键值对 - // 每个参数之间会有个空格分割 - for _, s := range argSplit { - cmdArg := strings.Split(s, " ") - - // 分割出来的参数只有一个那肯定不是键值对 - if len(cmdArg) < 2 { - c.SendMessage(executor, "格式错误,用法: %v --[参数名] [参数]。", cmd.Name) - return false - } - - argKey := cmdArg[0] // 参数的键 - argValue := cmdArg[1] // 参数的值 - - // 记录命令的参数 - cmd.Args[argKey] = argValue - } - - // 执行命令 - c.ExecCommand(cmd) - return true + return false } // GetFriendList 获取包含系统的玩家好友列表 @@ -321,7 +334,7 @@ func (c *CommandManager) ExecCommand(cmd *CommandMessage) { } // 判断玩家的权限是否符合要求 - player, ok := executor.(*model.Player) + player := executor if ok && player.CmdPerm < uint8(cmdPerm) { logger.Debug("exec command permission denied, uid: %v, CmdPerm: %v", player.PlayerId, player.CmdPerm) c.SendMessage(player, "权限不足,该命令需要%v级权限。\n你目前的权限等级:%v", cmdPerm, player.CmdPerm) @@ -332,20 +345,8 @@ func (c *CommandManager) ExecCommand(cmd *CommandMessage) { } // SendMessage 发送消息 -func (c *CommandManager) SendMessage(executor any, msg string, param ...any) { - // 根据相应的类型发送消息 - switch executor.(type) { - case *model.Player: - // 玩家类型 - player := executor.(*model.Player) - GAME.SendPrivateChat(c.system, player.PlayerId, fmt.Sprintf(msg, param...)) - // case string: - // GM接口等 - // str := executor.(string) - default: - // 无效的类型报错 - logger.Error("command executor type error, type: %T", executor) - } +func (c *CommandManager) SendMessage(player *model.Player, msg string, param ...any) { + GAME.SendPrivateChat(c.system, player.PlayerId, fmt.Sprintf(msg, param...)) } // GetExecutorId 获取执行者Id diff --git a/gs/game/game_physics_engine.go b/gs/game/game_physics_engine.go index fe015655..50ad6182 100644 --- a/gs/game/game_physics_engine.go +++ b/gs/game/game_physics_engine.go @@ -15,13 +15,14 @@ const ( // RigidBody 刚体 type RigidBody struct { - entityId uint32 // 子弹实体id - avatarEntityId uint32 // 子弹发射者角色实体id - sceneId uint32 // 子弹所在场景id - position *alg.Vector3 // 坐标 - velocity *alg.Vector3 // 速度 - drag float32 // 阻力参数 - mass float32 // 质量 + entityId uint32 // 子弹实体id + avatarEntityId uint32 // 子弹发射者角色实体id + hitAvatarEntityId uint32 // 子弹命中的角色实体id + sceneId uint32 // 子弹所在场景id + position *alg.Vector3 // 坐标 + velocity *alg.Vector3 // 速度 + drag float32 // 阻力参数 + mass float32 // 质量 } // PhysicsEngine 物理引擎 @@ -42,8 +43,8 @@ func (w *World) NewPhysicsEngine(sceneBlockAoiMap map[uint32]*alg.AoiManager) { } } -func (p *PhysicsEngine) Update(now int64) []*Entity { - hitEntityList := make([]*Entity, 0) +func (p *PhysicsEngine) Update(now int64) []*RigidBody { + hitList := make([]*RigidBody, 0) dt := float32(now-p.lastUpdateTime) / 1000.0 for _, rigidBody := range p.rigidBodyMap { aoiManager, exist := p.sceneBlockAoiMap[rigidBody.sceneId] @@ -83,18 +84,19 @@ func (p *PhysicsEngine) Update(now int64) []*Entity { rigidBody.position.Z += rigidBody.velocity.Z * dt newPos := &alg.Vector3{X: rigidBody.position.X, Y: rigidBody.position.Y, Z: rigidBody.position.Z} // 碰撞检测 - entity := p.Collision(rigidBody.sceneId, rigidBody.avatarEntityId, oldPos, newPos) - if entity != nil { - hitEntityList = append(hitEntityList, entity) + hitAvatarEntityId := p.Collision(rigidBody.sceneId, rigidBody.avatarEntityId, oldPos, newPos) + if hitAvatarEntityId != 0 { + rigidBody.hitAvatarEntityId = hitAvatarEntityId + hitList = append(hitList, rigidBody) p.DestroyRigidBody(rigidBody.entityId) } logger.Debug("[PhysicsEngineUpdate] e: %v, s: %v, p: %v, v: %v", rigidBody.entityId, rigidBody.sceneId, rigidBody.position, rigidBody.velocity) } p.lastUpdateTime = now - return hitEntityList + return hitList } -func (p *PhysicsEngine) Collision(sceneId uint32, avatarEntityId uint32, oldPos *alg.Vector3, newPos *alg.Vector3) *Entity { +func (p *PhysicsEngine) Collision(sceneId uint32, avatarEntityId uint32, oldPos *alg.Vector3, newPos *alg.Vector3) uint32 { scene := p.world.GetSceneById(sceneId) for _, entity := range scene.GetAllEntity() { if entity.GetEntityType() != constant.ENTITY_TYPE_AVATAR { @@ -154,9 +156,9 @@ func (p *PhysicsEngine) Collision(sceneId uint32, avatarEntityId uint32, oldPos if lineMaxY < shapeMinY || lineMinY > shapeMaxY { continue } - return entity + return entity.GetId() } - return nil + return 0 } func (p *PhysicsEngine) IsRigidBody(entityId uint32) bool { diff --git a/gs/game/game_route_manager.go b/gs/game/game_route_manager.go index 1a441f57..f0fdeb28 100644 --- a/gs/game/game_route_manager.go +++ b/gs/game/game_route_manager.go @@ -114,6 +114,10 @@ func (r *RouteManager) initRoute() { r.registerRouter(cmd.PlayerQuitDungeonReq, GAME.PlayerQuitDungeonReq) r.registerRouter(cmd.GadgetInteractReq, GAME.GadgetInteractReq) r.registerRouter(cmd.GmTalkReq, GAME.GmTalkReq) + r.registerRouter(cmd.SetEntityClientDataNotify, GAME.SetEntityClientDataNotify) + r.registerRouter(cmd.EntityForceSyncReq, GAME.EntityForceSyncReq) + r.registerRouter(cmd.AvatarDieAnimationEndReq, GAME.AvatarDieAnimationEndReq) + r.registerRouter(cmd.WorldPlayerReviveReq, GAME.WorldPlayerReviveReq) } type HandlerFunc func(player *model.Player, payloadMsg pb.Message) diff --git a/gs/game/game_tick_manager.go b/gs/game/game_tick_manager.go index a906853a..af021f82 100644 --- a/gs/game/game_tick_manager.go +++ b/gs/game/game_tick_manager.go @@ -249,7 +249,6 @@ func (t *TickManager) onTick200MilliSecond(now int64) { // 耐力消耗 GAME.SustainStaminaHandler(player) GAME.VehicleRestoreStaminaHandler(player) - GAME.DrownBackHandler(player) } } } @@ -264,9 +263,18 @@ func (t *TickManager) onTick100MilliSecond(now int64) { } } bulletPhysicsEngine := world.GetBulletPhysicsEngine() - hitEntityList := bulletPhysicsEngine.Update(now) - for _, entity := range hitEntityList { - GAME.ServerEvtBeingHitInfo(world.owner, entity.GetId(), entity.GetId(), 100.0) + hitList := bulletPhysicsEngine.Update(now) + for _, rigidBody := range hitList { + scene := world.GetSceneById(rigidBody.sceneId) + defAvatarEntity := scene.GetEntity(rigidBody.hitAvatarEntityId) + defPlayer := USER_MANAGER.GetOnlineUser(defAvatarEntity.GetAvatarEntity().GetUid()) + GAME.handleEvtBeingHit(defPlayer, scene, &proto.EvtBeingHitInfo{ + AttackResult: &proto.AttackResult{ + AttackerId: rigidBody.avatarEntityId, + DefenseId: rigidBody.hitAvatarEntityId, + Damage: 100, + }, + }) } } } diff --git a/gs/game/game_world_scene.go b/gs/game/game_world_scene.go index 74dab1a7..e91a636d 100644 --- a/gs/game/game_world_scene.go +++ b/gs/game/game_world_scene.go @@ -423,9 +423,10 @@ func (s *Suite) GetAllEntity() map[uint32]*Entity { // Entity 场景实体数据结构 type Entity struct { - id uint32 // 实体id - scene *Scene // 实体归属上级场景的访问指针 - lifeState uint16 // 存活状态 + id uint32 // 实体id + scene *Scene // 实体归属上级场景的访问指针 + lifeState uint16 // 存活状态 + lastDieType int32 pos *model.Vector // 位置 rot *model.Vector // 朝向 moveState uint16 // 运动状态 @@ -454,6 +455,10 @@ func (e *Entity) GetLifeState() uint16 { return e.lifeState } +func (e *Entity) GetLastDieType() int32 { + return e.lastDieType +} + func (e *Entity) GetPos() *model.Vector { return e.pos } diff --git a/gs/game/player_common.go b/gs/game/player_common.go index 9bbf3118..e1dd5f31 100644 --- a/gs/game/player_common.go +++ b/gs/game/player_common.go @@ -44,7 +44,7 @@ func (g *Game) ClientRttNotify(userId uint32, clientRtt uint32) { logger.Error("player is nil, uid: %v", userId) return } - logger.Debug("client rtt notify, uid: %v, rtt: %v", userId, clientRtt) + // logger.Debug("client rtt notify, uid: %v, rtt: %v", userId, clientRtt) player.ClientRTT = clientRtt } @@ -57,8 +57,8 @@ func (g *Game) ClientTimeNotify(userId uint32, clientTime uint32) { player.ClientTime = clientTime now := uint32(time.Now().Unix()) // 客户端与服务器时间相差太过严重 - if math.Abs(float64(now-player.ClientTime)) > 60.0 { - logger.Error("abs of client time and server time above 60s, uid: %v", userId) + if math.Abs(float64(now-player.ClientTime)) > 600.0 { + logger.Debug("abs of client time and server time above 600s, uid: %v", userId) } player.LastKeepaliveTime = now } @@ -240,21 +240,32 @@ func (g *Game) PlayerTimeNotify(world *World) { func (g *Game) GmTalkReq(player *model.Player, payloadMsg pb.Message) { req := payloadMsg.(*proto.GmTalkReq) logger.Info("GmTalkReq: %v", req.Msg) - commandText := strings.ReplaceAll(req.Msg, " ", "") - beginIndex := strings.Index(commandText, "(") - endIndex := strings.Index(commandText, ")") - if beginIndex == 0 || beginIndex == -1 || endIndex == -1 || beginIndex >= endIndex { - g.SendMsg(cmd.GmTalkRsp, player.PlayerId, player.ClientSeq, &proto.GmTalkRsp{Retmsg: "命令解析失败", Msg: req.Msg}) - return - } - funcName := commandText[:beginIndex] - paramList := strings.Split(commandText[beginIndex+1:endIndex], ",") - ok := COMMAND_MANAGER.HandleCommand(&CommandMessage{FuncName: funcName, ParamList: paramList}) - if ok { - g.SendMsg(cmd.GmTalkRsp, player.PlayerId, player.ClientSeq, &proto.GmTalkRsp{Retmsg: "执行成功", Msg: req.Msg}) + commandTextInput := COMMAND_MANAGER.GetCommandTextInput() + if strings.Contains(req.Msg, "@@") { + commandText := req.Msg + commandText = strings.ReplaceAll(commandText, "@@", "") + commandText = strings.ReplaceAll(commandText, " ", "") + beginIndex := strings.Index(commandText, "(") + endIndex := strings.Index(commandText, ")") + if beginIndex == 0 || beginIndex == -1 || endIndex == -1 || beginIndex >= endIndex { + g.SendMsg(cmd.GmTalkRsp, player.PlayerId, player.ClientSeq, &proto.GmTalkRsp{Retmsg: "命令解析失败", Msg: req.Msg}) + return + } + funcName := commandText[:beginIndex] + paramList := strings.Split(commandText[beginIndex+1:endIndex], ",") + commandTextInput <- &CommandMessage{ + GMType: SystemFuncGM, + FuncName: funcName, + ParamList: paramList, + } } else { - g.SendMsg(cmd.GmTalkRsp, player.PlayerId, player.ClientSeq, &proto.GmTalkRsp{Retmsg: "执行失败", Msg: req.Msg}) + commandTextInput <- &CommandMessage{ + GMType: PlayerChatGM, + Executor: player, + Text: req.Msg, + } } + g.SendMsg(cmd.GmTalkRsp, player.PlayerId, player.ClientSeq, &proto.GmTalkRsp{Retmsg: "执行成功", Msg: req.Msg}) } func (g *Game) PacketOpenStateUpdateNotify() *proto.OpenStateUpdateNotify { diff --git a/gs/game/player_fight_sync.go b/gs/game/player_fight_sync.go index 311227da..caf87f09 100644 --- a/gs/game/player_fight_sync.go +++ b/gs/game/player_fight_sync.go @@ -67,21 +67,6 @@ func (g *Game) UnionCmdNotify(player *model.Player, payloadMsg pb.Message) { player.AbilityInvokeHandler.Clear() } -func (g *Game) MassiveEntityElementOpBatchNotify(player *model.Player, payloadMsg pb.Message) { - req := payloadMsg.(*proto.MassiveEntityElementOpBatchNotify) - if player.SceneLoadState != model.SceneEnterDone { - return - } - world := WORLD_MANAGER.GetWorldById(player.WorldId) - if world == nil { - return - } - scene := world.GetSceneById(player.SceneId) - req.OpIdx = scene.GetMeeoIndex() - scene.SetMeeoIndex(scene.GetMeeoIndex() + 1) - g.SendToSceneA(scene, cmd.MassiveEntityElementOpBatchNotify, player.ClientSeq, req) -} - func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Message) { req := payloadMsg.(*proto.CombatInvocationsNotify) if player.SceneLoadState != model.SceneEnterDone { @@ -101,41 +86,8 @@ func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Messa logger.Error("parse EvtBeingHitInfo error: %v", err) break } - logger.Debug("EvtBeingHitInfo: %+v, ForwardType: %v", evtBeingHitInfo, entry.ForwardType) - attackResult := evtBeingHitInfo.AttackResult - if attackResult == nil { - logger.Error("attackResult is nil") - break - } - target := scene.GetEntity(attackResult.DefenseId) - if target == nil { - logger.Error("could not found target, defense id: %v", attackResult.DefenseId) - break - } - fightProp := target.GetFightProp() - currHp := fightProp[constant.FIGHT_PROP_CUR_HP] - currHp -= attackResult.Damage - if currHp < 0 { - currHp = 0 - } - fightProp[constant.FIGHT_PROP_CUR_HP] = currHp - g.EntityFightPropUpdateNotifyBroadcast(scene, target) - switch target.GetEntityType() { - case constant.ENTITY_TYPE_AVATAR: - case constant.ENTITY_TYPE_MONSTER: - if currHp == 0 { - g.KillEntity(player, scene, target.GetId(), proto.PlayerDieType_PLAYER_DIE_GM) - } - case constant.ENTITY_TYPE_GADGET: - gadgetEntity := target.GetGadgetEntity() - gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetEntity.GetGadgetId())) - if gadgetDataConfig == nil { - logger.Error("get gadget data config is nil, gadgetId: %v", gadgetEntity.GetGadgetId()) - break - } - logger.Debug("[EvtBeingHit] GadgetData: %+v, EntityId: %v, uid: %v", gadgetDataConfig, target.GetId(), player.PlayerId) - g.handleGadgetEntityBeHitLow(player, target, attackResult.ElementType) - } + // logger.Debug("EvtBeingHitInfo: %+v, ForwardType: %v", evtBeingHitInfo, entry.ForwardType) + g.handleEvtBeingHit(player, scene, evtBeingHitInfo) case proto.CombatTypeArgument_ENTITY_MOVE: entityMoveInfo := new(proto.EntityMoveInfo) err := pb.Unmarshal(entry.CombatData, entityMoveInfo) @@ -145,65 +97,18 @@ func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Messa } // logger.Debug("EntityMoveInfo: %+v, ForwardType: %v", entityMoveInfo, entry.ForwardType) motionInfo := entityMoveInfo.MotionInfo - if motionInfo.Pos == nil || motionInfo.Rot == nil { + if motionInfo == nil || motionInfo.Pos == nil || motionInfo.Rot == nil { break } - sceneEntity := scene.GetEntity(entityMoveInfo.EntityId) - if sceneEntity == nil { - break - } - if sceneEntity.GetEntityType() == constant.ENTITY_TYPE_AVATAR { - // 玩家实体在移动 - g.SceneBlockAoiPlayerMove(player, world, scene, player.Pos, - &model.Vector{X: float64(motionInfo.Pos.X), Y: float64(motionInfo.Pos.Y), Z: float64(motionInfo.Pos.Z)}, - sceneEntity.GetId(), - ) - if WORLD_MANAGER.IsBigWorld(world) { - g.BigWorldAoiPlayerMove(player, world, scene, player.Pos, - &model.Vector{X: float64(motionInfo.Pos.X), Y: float64(motionInfo.Pos.Y), Z: float64(motionInfo.Pos.Z)}, - ) - } - // 更新玩家的位置信息 - player.Pos.X, player.Pos.Y, player.Pos.Z = float64(motionInfo.Pos.X), float64(motionInfo.Pos.Y), float64(motionInfo.Pos.Z) - player.Rot.X, player.Rot.Y, player.Rot.Z = float64(motionInfo.Rot.X), float64(motionInfo.Rot.Y), float64(motionInfo.Rot.Z) - // 玩家安全位置更新 - switch motionInfo.State { - case proto.MotionState_MOTION_DANGER_RUN, - proto.MotionState_MOTION_RUN, - proto.MotionState_MOTION_DANGER_STANDBY_MOVE, - proto.MotionState_MOTION_DANGER_STANDBY, - proto.MotionState_MOTION_LADDER_TO_STANDBY, - proto.MotionState_MOTION_STANDBY_MOVE, - proto.MotionState_MOTION_STANDBY, - proto.MotionState_MOTION_DANGER_WALK, - proto.MotionState_MOTION_WALK, - proto.MotionState_MOTION_DASH: - // 仅在陆地时更新玩家安全位置 - player.SafePos.X, player.SafePos.Y, player.SafePos.Z = player.Pos.X, player.Pos.Y, player.Pos.Z - } - // 处理耐力消耗 - g.ImmediateStamina(player, motionInfo.State) - } else { - // 其他实体在移动 - // 更新场景实体的位置信息 - pos := sceneEntity.GetPos() - pos.X, pos.Y, pos.Z = float64(motionInfo.Pos.X), float64(motionInfo.Pos.Y), float64(motionInfo.Pos.Z) - rot := sceneEntity.GetRot() - rot.X, rot.Y, rot.Z = float64(motionInfo.Rot.X), float64(motionInfo.Rot.Y), float64(motionInfo.Rot.Z) - if sceneEntity.GetEntityType() == constant.ENTITY_TYPE_GADGET { - // 载具耐力消耗 - gadgetEntity := sceneEntity.GetGadgetEntity() - if gadgetEntity.GetGadgetVehicleEntity() != nil { - // 处理耐力消耗 - g.ImmediateStamina(player, motionInfo.State) - // 处理载具销毁请求 - g.VehicleDestroyMotion(player, sceneEntity, motionInfo.State) - } - } - } - sceneEntity.SetMoveState(uint16(motionInfo.State)) - sceneEntity.SetLastMoveSceneTimeMs(entityMoveInfo.SceneTime) - sceneEntity.SetLastMoveReliableSeq(entityMoveInfo.ReliableSeq) + g.handleEntityMove(player, world, scene, entityMoveInfo.EntityId, &model.Vector{ + X: float64(motionInfo.Pos.X), + Y: float64(motionInfo.Pos.Y), + Z: float64(motionInfo.Pos.Z), + }, &model.Vector{ + X: float64(motionInfo.Rot.X), + Y: float64(motionInfo.Rot.Y), + Z: float64(motionInfo.Rot.Z), + }, false, entityMoveInfo) // 众里寻他千百度 蓦然回首 那人却在灯火阑珊处 if motionInfo.State == proto.MotionState_MOTION_NOTIFY || motionInfo.State == proto.MotionState_MOTION_FIGHT { // 只要转发了这两个包的其中之一 客户端的动画就会被打断 @@ -230,6 +135,117 @@ func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Messa } } +func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *proto.EvtBeingHitInfo) { + attackResult := hitInfo.AttackResult + if attackResult == nil { + logger.Error("attackResult is nil") + return + } + target := scene.GetEntity(attackResult.DefenseId) + if target == nil { + logger.Error("could not found target, defense id: %v", attackResult.DefenseId) + return + } + fightProp := target.GetFightProp() + currHp := fightProp[constant.FIGHT_PROP_CUR_HP] + currHp -= attackResult.Damage + deltaHp := -attackResult.Damage + if currHp < 0 { + deltaHp -= currHp + currHp = 0 + } + fightProp[constant.FIGHT_PROP_CUR_HP] = currHp + g.EntityFightPropUpdateNotifyBroadcast(scene, target) + switch target.GetEntityType() { + case constant.ENTITY_TYPE_AVATAR: + g.SendMsg(cmd.EntityFightPropChangeReasonNotify, player.PlayerId, player.ClientSeq, &proto.EntityFightPropChangeReasonNotify{ + PropDelta: deltaHp, + ChangeHpReason: proto.ChangHpReason_CHANGE_HP_SUB_GM, + EntityId: target.GetId(), + PropType: constant.FIGHT_PROP_CUR_HP, + }) + if currHp == 0 { + avatarEntity := target.GetAvatarEntity() + g.KillPlayerAvatar(player, avatarEntity.GetAvatarId(), proto.PlayerDieType_PLAYER_DIE_GM) + } + case constant.ENTITY_TYPE_MONSTER: + if currHp == 0 { + g.KillEntity(player, scene, target.GetId(), proto.PlayerDieType_PLAYER_DIE_GM) + } + case constant.ENTITY_TYPE_GADGET: + gadgetEntity := target.GetGadgetEntity() + gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetEntity.GetGadgetId())) + if gadgetDataConfig == nil { + logger.Error("get gadget data config is nil, gadgetId: %v", gadgetEntity.GetGadgetId()) + break + } + logger.Debug("[EvtBeingHit] GadgetData: %+v, EntityId: %v, uid: %v", gadgetDataConfig, target.GetId(), player.PlayerId) + g.handleGadgetEntityBeHitLow(player, target, attackResult.ElementType) + } +} + +func (g *Game) handleEntityMove(player *model.Player, world *World, scene *Scene, entityId uint32, pos, rot *model.Vector, force bool, moveInfo *proto.EntityMoveInfo) { + entity := scene.GetEntity(entityId) + if entity == nil { + return + } + if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR { + // 玩家实体在移动 + g.SceneBlockAoiPlayerMove(player, world, scene, player.Pos, + &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z}, + entity.GetId(), + ) + if WORLD_MANAGER.IsBigWorld(world) { + g.BigWorldAoiPlayerMove(player, world, scene, player.Pos, + &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z}, + ) + } + // 更新玩家的位置信息 + player.Pos.X, player.Pos.Y, player.Pos.Z = pos.X, pos.Y, pos.Z + player.Rot.X, player.Rot.Y, player.Rot.Z = rot.X, rot.Y, rot.Z + } + // 更新场景实体的位置信息 + entityPos := entity.GetPos() + entityPos.X, entityPos.Y, entityPos.Z = pos.X, pos.Y, pos.Z + entityRot := entity.GetRot() + entityRot.X, entityRot.Y, entityRot.Z = rot.X, rot.Y, rot.Z + if !force { + motionInfo := moveInfo.MotionInfo + switch entity.GetEntityType() { + case constant.ENTITY_TYPE_AVATAR: + // 玩家安全位置更新 + switch motionInfo.State { + case proto.MotionState_MOTION_DANGER_RUN, + proto.MotionState_MOTION_RUN, + proto.MotionState_MOTION_DANGER_STANDBY_MOVE, + proto.MotionState_MOTION_DANGER_STANDBY, + proto.MotionState_MOTION_LADDER_TO_STANDBY, + proto.MotionState_MOTION_STANDBY_MOVE, + proto.MotionState_MOTION_STANDBY, + proto.MotionState_MOTION_DANGER_WALK, + proto.MotionState_MOTION_WALK, + proto.MotionState_MOTION_DASH: + // 仅在陆地时更新玩家安全位置 + player.SafePos.X, player.SafePos.Y, player.SafePos.Z = player.Pos.X, player.Pos.Y, player.Pos.Z + } + // 处理耐力消耗 + g.ImmediateStamina(player, motionInfo.State) + case constant.ENTITY_TYPE_GADGET: + // 载具耐力消耗 + gadgetEntity := entity.GetGadgetEntity() + if gadgetEntity.GetGadgetVehicleEntity() != nil { + // 处理耐力消耗 + g.ImmediateStamina(player, motionInfo.State) + // 处理载具销毁请求 + g.VehicleDestroyMotion(player, entity, motionInfo.State) + } + } + entity.SetMoveState(uint16(motionInfo.State)) + entity.SetLastMoveSceneTimeMs(moveInfo.SceneTime) + entity.SetLastMoveReliableSeq(moveInfo.ReliableSeq) + } +} + func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene *Scene, oldPos *model.Vector, newPos *model.Vector, entityId uint32) { // 服务器处理玩家移动场景区块aoi事件频率限制 now := uint64(time.Now().UnixMilli()) @@ -550,6 +566,21 @@ func (g *Game) ClientAbilityChangeNotify(player *model.Player, payloadMsg pb.Mes } } +func (g *Game) MassiveEntityElementOpBatchNotify(player *model.Player, payloadMsg pb.Message) { + req := payloadMsg.(*proto.MassiveEntityElementOpBatchNotify) + if player.SceneLoadState != model.SceneEnterDone { + return + } + world := WORLD_MANAGER.GetWorldById(player.WorldId) + if world == nil { + return + } + scene := world.GetSceneById(player.SceneId) + req.OpIdx = scene.GetMeeoIndex() + scene.SetMeeoIndex(scene.GetMeeoIndex() + 1) + g.SendToSceneA(scene, cmd.MassiveEntityElementOpBatchNotify, player.ClientSeq, req) +} + func (g *Game) EvtDoSkillSuccNotify(player *model.Player, payloadMsg pb.Message) { req := payloadMsg.(*proto.EvtDoSkillSuccNotify) if player.SceneLoadState != model.SceneEnterDone { @@ -792,31 +823,6 @@ func (g *Game) EntityAiSyncNotify(player *model.Player, payloadMsg pb.Message) { g.SendMsg(cmd.EntityAiSyncNotify, player.PlayerId, player.ClientSeq, entityAiSyncNotify) } -func (g *Game) ServerEvtBeingHitInfo(player *model.Player, atkEntityId uint32, defEntityId uint32, dmg float32) { - evtBeingHitInfo := &proto.EvtBeingHitInfo{ - AttackResult: &proto.AttackResult{ - AttackerId: atkEntityId, - DefenseId: defEntityId, - Damage: dmg, - ElementType: constant.ELEMENT_TYPE_FIRE, - }, - } - combatData, err := pb.Marshal(evtBeingHitInfo) - if err != nil { - logger.Error("marshal EvtBeingHitInfo error: %v", err) - return - } - GAME.CombatInvocationsNotify(player, &proto.CombatInvocationsNotify{ - InvokeList: []*proto.CombatInvokeEntry{{ - CombatData: combatData, - ForwardType: proto.ForwardType_FORWARD_ONLY_SERVER, - ArgumentType: proto.CombatTypeArgument_COMBAT_EVT_BEING_HIT, - }}, - }) - GAME.UnionCmdNotify(player, &proto.UnionCmdNotify{}) - -} - // TODO 一些很low的解决方案 我本来是不想写的 有多low?要多low有多low! func (g *Game) handleGadgetEntityBeHitLow(player *model.Player, entity *Entity, hitElementType uint32) { diff --git a/gs/game/player_login.go b/gs/game/player_login.go index d9a22120..feb81330 100644 --- a/gs/game/player_login.go +++ b/gs/game/player_login.go @@ -69,7 +69,7 @@ func (g *Game) SetPlayerBornDataReq(player *model.Player, payloadMsg pb.Message) // 进入场景 player.SceneJump = true player.SceneLoadState = model.SceneNone - + player.SceneEnterReason = uint32(proto.EnterReason_ENTER_REASON_LOGIN) g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerId, player.ClientSeq, g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_SELF)) g.SendMsg(cmd.SetPlayerBornDataRsp, player.PlayerId, player.ClientSeq, new(proto.SetPlayerBornDataRsp)) @@ -129,6 +129,7 @@ func (g *Game) OnLogin(userId uint32, clientSeq uint32, gateAppId string, player // 进入场景 player.SceneJump = true player.SceneLoadState = model.SceneNone + player.SceneEnterReason = uint32(proto.EnterReason_ENTER_REASON_LOGIN) g.SendMsg(cmd.PlayerEnterSceneNotify, userId, clientSeq, g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_SELF)) } } else { diff --git a/gs/game/player_multiplayer.go b/gs/game/player_multiplayer.go index 36d2030d..5ece1016 100644 --- a/gs/game/player_multiplayer.go +++ b/gs/game/player_multiplayer.go @@ -154,6 +154,7 @@ func (g *Game) JoinOtherWorld(player *model.Player, hostPlayer *model.Player) { player.SceneJump = true player.SceneId = hostPlayer.SceneId player.SceneLoadState = model.SceneNone + player.SceneEnterReason = uint32(proto.EnterReason_ENTER_REASON_TEAM_JOIN) player.Pos.X, player.Pos.Y, player.Pos.Z = hostPlayer.Pos.X, hostPlayer.Pos.Y, hostPlayer.Pos.Z player.Rot.X, player.Rot.Y, player.Rot.Z = hostPlayer.Rot.X, hostPlayer.Rot.Y, hostPlayer.Rot.Z g.WorldAddPlayer(hostWorld, player) @@ -162,7 +163,6 @@ func (g *Game) JoinOtherWorld(player *model.Player, hostPlayer *model.Player) { player, hostPlayer, proto.EnterType_ENTER_OTHER, - proto.EnterReason_ENTER_REASON_TEAM_JOIN, 0, new(model.Vector), ) @@ -333,12 +333,12 @@ func (g *Game) HostEnterMpWorld(hostPlayer *model.Player) { hostPlayer.SceneJump = true hostPlayer.SceneLoadState = model.SceneNone + hostPlayer.SceneEnterReason = uint32(proto.EnterReason_ENTER_REASON_HOST_FROM_SINGLE_TO_MP) hostPlayerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyMp( hostPlayer, hostPlayer, proto.EnterType_ENTER_GOTO, - proto.EnterReason_ENTER_REASON_HOST_FROM_SINGLE_TO_MP, hostPlayer.SceneId, hostPlayer.Pos, ) diff --git a/gs/game/player_scene.go b/gs/game/player_scene.go index 447befea..3b4d8859 100644 --- a/gs/game/player_scene.go +++ b/gs/game/player_scene.go @@ -263,6 +263,21 @@ func (g *Game) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) { g.SendMsg(cmd.DungeonDataNotify, player.PlayerId, player.ClientSeq, &proto.DungeonDataNotify{}) } + if player.SceneEnterReason == uint32(proto.EnterReason_ENTER_REASON_REVIVAL) { + for _, worldAvatar := range world.GetPlayerWorldAvatarList(player) { + dbAvatar := player.GetDbAvatar() + avatar, exist := dbAvatar.AvatarMap[worldAvatar.GetAvatarId()] + if !exist { + logger.Error("get db avatar is nil, avatarId: %v", worldAvatar.GetAvatarId()) + continue + } + if avatar.LifeState != constant.LIFE_STATE_DEAD { + continue + } + g.RevivePlayerAvatar(player, worldAvatar.GetAvatarId()) + } + } + SceneInitFinishRsp := &proto.SceneInitFinishRsp{ EnterSceneToken: req.EnterSceneToken, } @@ -429,6 +444,37 @@ func (g *Game) SceneEntityDrownReq(player *model.Player, payloadMsg pb.Message) g.SendMsg(cmd.SceneEntityDrownRsp, player.PlayerId, player.ClientSeq, sceneEntityDrownRsp) } +func (g *Game) EntityForceSyncReq(player *model.Player, payloadMsg pb.Message) { + req := payloadMsg.(*proto.EntityForceSyncReq) + + world := WORLD_MANAGER.GetWorldById(player.WorldId) + if world == nil { + return + } + scene := world.GetSceneById(player.SceneId) + + motionInfo := req.MotionInfo + if motionInfo == nil { + return + } + g.handleEntityMove(player, world, scene, req.EntityId, &model.Vector{ + X: float64(motionInfo.Pos.X), + Y: float64(motionInfo.Pos.Y), + Z: float64(motionInfo.Pos.Z), + }, &model.Vector{ + X: float64(motionInfo.Rot.X), + Y: float64(motionInfo.Rot.Y), + Z: float64(motionInfo.Rot.Z), + }, true, nil) + + rsp := &proto.EntityForceSyncRsp{ + SceneTime: req.SceneTime, + EntityId: req.EntityId, + FailMotion: motionInfo, + } + g.SendMsg(cmd.EntityForceSyncRsp, player.PlayerId, player.ClientSeq, rsp) +} + /************************************************** 游戏功能 **************************************************/ // AddSceneEntityNotifyToPlayer 添加的场景实体同步给玩家 @@ -549,70 +595,79 @@ func (g *Game) EntityFightPropUpdateNotifyBroadcast(scene *Scene, entity *Entity g.SendToSceneA(scene, cmd.EntityFightPropUpdateNotify, 0, ntf) } -// KillPlayerAvatar 杀死玩家活跃角色实体 -func (g *Game) KillPlayerAvatar(player *model.Player, dieType proto.PlayerDieType) { +// KillPlayerAvatar 杀死玩家角色实体 +func (g *Game) KillPlayerAvatar(player *model.Player, avatarId uint32, dieType proto.PlayerDieType) { + dbAvatar := player.GetDbAvatar() + avatar, exist := dbAvatar.AvatarMap[avatarId] + if !exist { + logger.Error("get db avatar is nil, avatarId: %v", avatarId) + return + } + avatar.LifeState = constant.LIFE_STATE_DEAD + avatar.FightPropMap[constant.FIGHT_PROP_CUR_HP] = 0 + world := WORLD_MANAGER.GetWorldById(player.WorldId) if world == nil { return } - activeAvatarId := world.GetPlayerActiveAvatarId(player) - worldAvatar := world.GetPlayerWorldAvatar(player, activeAvatarId) - scene := world.GetSceneById(player.SceneId) - avatarEntity := scene.GetEntity(worldAvatar.GetAvatarEntityId()) - - dbAvatar := player.GetDbAvatar() - avatar, exist := dbAvatar.AvatarMap[activeAvatarId] - if !exist { - logger.Error("get active avatar is nil, avatarId: %v", activeAvatarId) + worldAvatar := world.GetPlayerWorldAvatar(player, avatarId) + if worldAvatar == nil { return } + scene := world.GetSceneById(player.SceneId) + entity := scene.GetEntity(worldAvatar.GetAvatarEntityId()) - avatarEntity.lifeState = constant.LIFE_STATE_DEAD - - ntf := &proto.AvatarLifeStateChangeNotify{ - LifeState: uint32(avatarEntity.lifeState), - AttackTag: "", - DieType: dieType, - ServerBuffList: nil, - MoveReliableSeq: avatarEntity.lastMoveReliableSeq, - SourceEntityId: 0, - AvatarGuid: avatar.Guid, + activeAvatarId := world.GetPlayerActiveAvatarId(player) + if avatarId == activeAvatarId { + g.KillEntity(player, scene, entity.GetId(), dieType) + } else { + ntf := &proto.AvatarLifeStateChangeNotify{ + AvatarGuid: avatar.Guid, + LifeState: uint32(avatar.LifeState), + DieType: dieType, + MoveReliableSeq: entity.GetLastMoveReliableSeq(), + } + g.SendToWorldA(world, cmd.AvatarLifeStateChangeNotify, 0, ntf) } - g.SendToWorldA(world, cmd.AvatarLifeStateChangeNotify, 0, ntf) } // RevivePlayerAvatar 复活玩家活跃角色实体 -func (g *Game) RevivePlayerAvatar(player *model.Player) { +func (g *Game) RevivePlayerAvatar(player *model.Player, avatarId uint32) { + dbAvatar := player.GetDbAvatar() + avatar, exist := dbAvatar.AvatarMap[avatarId] + if !exist { + logger.Error("get db avatar is nil, avatarId: %v", avatarId) + return + } + avatar.LifeState = constant.LIFE_STATE_ALIVE + avatar.FightPropMap[constant.FIGHT_PROP_CUR_HP] = 100 + + g.SendMsg(cmd.AvatarFightPropUpdateNotify, player.PlayerId, player.ClientSeq, &proto.AvatarFightPropUpdateNotify{ + AvatarGuid: avatar.Guid, + FightPropMap: avatar.FightPropMap, + }) + world := WORLD_MANAGER.GetWorldById(player.WorldId) if world == nil { return } - activeAvatarId := world.GetPlayerActiveAvatarId(player) - worldAvatar := world.GetPlayerWorldAvatar(player, activeAvatarId) - scene := world.GetSceneById(player.SceneId) - avatarEntity := scene.GetEntity(worldAvatar.GetAvatarEntityId()) - - dbAvatar := player.GetDbAvatar() - avatar, exist := dbAvatar.AvatarMap[activeAvatarId] - if !exist { - logger.Error("get active avatar is nil, avatarId: %v", activeAvatarId) + worldAvatar := world.GetPlayerWorldAvatar(player, avatarId) + if worldAvatar == nil { return } - - avatar.LifeState = constant.LIFE_STATE_ALIVE - // 设置血量 - avatar.FightPropMap[constant.FIGHT_PROP_CUR_HP] = 110 - g.EntityFightPropUpdateNotifyBroadcast(scene, avatarEntity) - - avatarEntity.lifeState = constant.LIFE_STATE_REVIVE + scene := world.GetSceneById(player.SceneId) + entity := scene.GetEntity(worldAvatar.GetAvatarEntityId()) ntf := &proto.AvatarLifeStateChangeNotify{ AvatarGuid: avatar.Guid, - LifeState: uint32(avatarEntity.lifeState), + LifeState: uint32(avatar.LifeState), DieType: proto.PlayerDieType_PLAYER_DIE_NONE, - MoveReliableSeq: avatarEntity.lastMoveReliableSeq, + MoveReliableSeq: 0, } g.SendToWorldA(world, cmd.AvatarLifeStateChangeNotify, 0, ntf) + + entity.lifeState = constant.LIFE_STATE_ALIVE + entity.fightProp[constant.FIGHT_PROP_CUR_HP] = 100 } // KillEntity 杀死实体 @@ -621,14 +676,10 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d if entity == nil { return } - if entity.GetEntityType() == constant.ENTITY_TYPE_MONSTER { - // 设置血量 - entity.fightProp[constant.FIGHT_PROP_CUR_HP] = 0 - g.EntityFightPropUpdateNotifyBroadcast(scene, entity) - // 随机掉落 - g.monsterDrop(player, entity) - } + // 设置血量 + entity.lastDieType = int32(dieType) entity.lifeState = constant.LIFE_STATE_DEAD + entity.fightProp[constant.FIGHT_PROP_CUR_HP] = 0 ntf := &proto.LifeStateChangeNotify{ EntityId: entity.GetId(), LifeState: uint32(entity.GetLifeState()), @@ -636,8 +687,14 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d MoveReliableSeq: entity.GetLastMoveReliableSeq(), } g.SendToSceneA(scene, cmd.LifeStateChangeNotify, 0, ntf) - g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_DIE, []uint32{entity.GetId()}, false, 0) + + if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR { + return + } + // 删除实体 + g.EntityFightPropUpdateNotifyBroadcast(scene, entity) + g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_DIE, []uint32{entity.GetId()}, false, 0) scene.DestroyEntity(entity.GetId()) group := scene.GetGroupById(entity.GetGroupId()) if group == nil { @@ -653,9 +710,10 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d group.DestroyEntity(entity.GetId()) - // 触发器检测 switch entity.GetEntityType() { case constant.ENTITY_TYPE_MONSTER: + // 随机掉落 + g.monsterDrop(player, entity) // 怪物死亡触发器检测 g.MonsterDieTriggerCheck(player, group) case constant.ENTITY_TYPE_GADGET: @@ -1174,7 +1232,7 @@ func (g *Game) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType TargetUid: player.PlayerId, EnterSceneToken: enterSceneToken, WorldLevel: player.PropertiesMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL], - EnterReason: uint32(proto.EnterReason_ENTER_REASON_LOGIN), + EnterReason: player.SceneEnterReason, IsFirstLoginEnterScene: true, WorldType: 1, SceneTagIdList: make([]uint32, 0), @@ -1195,31 +1253,28 @@ func (g *Game) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType func (g *Game) PacketPlayerEnterSceneNotifyTp( player *model.Player, enterType proto.EnterType, - enterReason proto.EnterReason, prevSceneId uint32, prevPos *model.Vector, dungeonId uint32, dungeonPointId uint32, ) *proto.PlayerEnterSceneNotify { - return g.PacketPlayerEnterSceneNotifyCore(player, player, enterType, enterReason, prevSceneId, prevPos, dungeonId, dungeonPointId) + return g.PacketPlayerEnterSceneNotifyCore(player, player, enterType, prevSceneId, prevPos, dungeonId, dungeonPointId) } func (g *Game) PacketPlayerEnterSceneNotifyMp( player *model.Player, targetPlayer *model.Player, enterType proto.EnterType, - enterReason proto.EnterReason, prevSceneId uint32, prevPos *model.Vector, ) *proto.PlayerEnterSceneNotify { - return g.PacketPlayerEnterSceneNotifyCore(player, targetPlayer, enterType, enterReason, prevSceneId, prevPos, 0, 0) + return g.PacketPlayerEnterSceneNotifyCore(player, targetPlayer, enterType, prevSceneId, prevPos, 0, 0) } func (g *Game) PacketPlayerEnterSceneNotifyCore( player *model.Player, targetPlayer *model.Player, enterType proto.EnterType, - enterReason proto.EnterReason, prevSceneId uint32, prevPos *model.Vector, dungeonId uint32, @@ -1251,7 +1306,7 @@ func (g *Game) PacketPlayerEnterSceneNotifyCore( TargetUid: targetPlayer.PlayerId, EnterSceneToken: enterSceneToken, WorldLevel: targetPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL], - EnterReason: uint32(enterReason), + EnterReason: player.SceneEnterReason, WorldType: 1, DungeonId: dungeonId, SceneTagIdList: make([]uint32, 0), diff --git a/gs/game/player_stamina.go b/gs/game/player_stamina.go index d1e8bc26..5325d862 100644 --- a/gs/game/player_stamina.go +++ b/gs/game/player_stamina.go @@ -359,71 +359,32 @@ func (g *Game) UpdatePlayerStamina(player *model.Player, staminaCost int32) { g.SetPlayerStamina(player, stamina) } -// DrownBackHandler 玩家溺水返回安全点 -func (g *Game) DrownBackHandler(player *model.Player) { - // 玩家暂停跳过 - if player.Pause { - return - } - // 溺水返回时间为0代表不进行返回 - if player.StaminaInfo.DrownBackDelay == 0 { - return - } - - // TODO 耐力未完成的内容: - // 一直溺水回到距离最近的位置 ? - // 溺水队伍扣血 - // 队伍都没血了显示死亡界面 - // 角色技能影响重击耐力消耗 雷神开大后修改重击耐力为20 达达利亚 一斗 - // 食物影响消耗的耐力 还有 角色天赋也会影响 - - // 先传送玩家再设置角色存活否则同时设置会传送前显示角色实体 - if player.StaminaInfo.DrownBackDelay > 20 && player.SceneLoadState == model.SceneEnterDone { - // 设置角色存活 - g.RevivePlayerAvatar(player) - // 重置溺水返回时间 - player.StaminaInfo.DrownBackDelay = 0 - } else if player.StaminaInfo.DrownBackDelay == 20 { - // TODO 队伍扣血 - maxStamina := player.PropertiesMap[constant.PLAYER_PROP_MAX_STAMINA] - // 设置玩家耐力为一半 - g.SetPlayerStamina(player, maxStamina/2) - // 如果玩家的位置比锚点距离近则优先使用玩家位置 - pos := &model.Vector{ - X: player.SafePos.X, - Y: player.SafePos.Y, - Z: player.SafePos.Z, - } - // 传送玩家至安全位置 - g.TeleportPlayer( - player, - proto.EnterReason_ENTER_REASON_REVIVAL, - player.SceneId, - pos, - new(model.Vector), - 0, - 0, - ) - } - // 防止重置后又被修改 - if player.StaminaInfo.DrownBackDelay != 0 { - player.StaminaInfo.DrownBackDelay++ - } -} - // HandleDrown 处理玩家溺水 func (g *Game) HandleDrown(player *model.Player, stamina uint32) { - // 溺水需要耐力等于0 返回延时不等于0代表已处理过溺水正在等待返回 - if stamina != 0 || player.StaminaInfo.DrownBackDelay != 0 { + // 溺水需要耐力等于0 + if stamina != 0 { return } // 确保玩家正在游泳 if player.StaminaInfo.State == proto.MotionState_MOTION_SWIM_MOVE || player.StaminaInfo.State == proto.MotionState_MOTION_SWIM_DASH { logger.Debug("player drown, curStamina: %v, state: %v", stamina, player.StaminaInfo.State) // 设置角色为死亡 - g.KillPlayerAvatar(player, proto.PlayerDieType_PLAYER_DIE_DRAWN) - // 溺水返回安全点 计时开始 - player.StaminaInfo.DrownBackDelay = 1 + world := WORLD_MANAGER.GetWorldById(player.WorldId) + if world == nil { + return + } + for _, worldAvatar := range world.GetPlayerWorldAvatarList(player) { + dbAvatar := player.GetDbAvatar() + avatar, exist := dbAvatar.AvatarMap[worldAvatar.GetAvatarId()] + if !exist { + logger.Error("get db avatar is nil, avatarId: %v", worldAvatar.GetAvatarId()) + continue + } + if avatar.LifeState != constant.LIFE_STATE_ALIVE { + continue + } + g.KillPlayerAvatar(player, worldAvatar.GetAvatarId(), proto.PlayerDieType_PLAYER_DIE_DRAWN) + } } } diff --git a/gs/game/player_team.go b/gs/game/player_team.go index f4077f2f..1d1a1f0a 100644 --- a/gs/game/player_team.go +++ b/gs/game/player_team.go @@ -17,55 +17,13 @@ import ( func (g *Game) ChangeAvatarReq(player *model.Player, payloadMsg pb.Message) { req := payloadMsg.(*proto.ChangeAvatarReq) targetAvatarGuid := req.Guid - world := WORLD_MANAGER.GetWorldById(player.WorldId) - if world == nil { - logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId) - return - } - scene := world.GetSceneById(player.SceneId) targetAvatar, ok := player.GameObjectGuidMap[targetAvatarGuid].(*model.Avatar) if !ok { logger.Error("target avatar error, avatarGuid: %v", targetAvatarGuid) return } - targetAvatarId := targetAvatar.AvatarId - oldAvatarId := world.GetPlayerActiveAvatarId(player) - if targetAvatarId == oldAvatarId { - logger.Error("can not change to the same avatar, uid: %v, oldAvatarId: %v, targetAvatarId: %v", player.PlayerId, oldAvatarId, targetAvatarId) - return - } - newAvatarIndex := world.GetPlayerAvatarIndexByAvatarId(player, targetAvatarId) - if newAvatarIndex == -1 { - logger.Error("can not find the target avatar in team, uid: %v, targetAvatarId: %v", player.PlayerId, targetAvatarId) - return - } - if !world.GetMultiplayer() { - dbTeam := player.GetDbTeam() - dbTeam.CurrAvatarIndex = uint8(newAvatarIndex) - } - world.SetPlayerAvatarIndex(player, newAvatarIndex) - oldAvatarEntityId := world.GetPlayerWorldAvatarEntityId(player, oldAvatarId) - oldAvatarEntity := scene.GetEntity(oldAvatarEntityId) - if oldAvatarEntity == nil { - logger.Error("can not find old avatar entity, entity id: %v", oldAvatarEntityId) - return - } - oldAvatarEntity.SetMoveState(uint16(proto.MotionState_MOTION_STANDBY)) - sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{ - DisappearType: proto.VisionType_VISION_REPLACE, - EntityList: []uint32{oldAvatarEntity.GetId()}, - } - g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify) - - newAvatarId := world.GetPlayerActiveAvatarId(player) - newAvatarEntity := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarId) - sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{ - AppearType: proto.VisionType_VISION_REPLACE, - Param: oldAvatarEntity.GetId(), - EntityList: []*proto.SceneEntityInfo{newAvatarEntity}, - } - g.SendToSceneA(scene, cmd.SceneEntityAppearNotify, player.ClientSeq, sceneEntityAppearNotify) + g.ChangeAvatar(player, targetAvatar.AvatarId) changeAvatarRsp := &proto.ChangeAvatarRsp{ CurGuid: targetAvatarGuid, @@ -231,8 +189,131 @@ func (g *Game) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.Message g.SendMsg(cmd.ChangeMpTeamAvatarRsp, player.PlayerId, player.ClientSeq, changeMpTeamAvatarRsp) } +func (g *Game) AvatarDieAnimationEndReq(player *model.Player, payloadMsg pb.Message) { + req := payloadMsg.(*proto.AvatarDieAnimationEndReq) + + world := WORLD_MANAGER.GetWorldById(player.WorldId) + if world == nil { + return + } + scene := world.GetSceneById(player.SceneId) + entity := scene.GetEntity(uint32(req.DieGuid)) + + if entity.GetLastDieType() == int32(proto.PlayerDieType_PLAYER_DIE_DRAWN) { + maxStamina := player.PropertiesMap[constant.PLAYER_PROP_MAX_STAMINA] + // 设置玩家耐力为一半 + g.SetPlayerStamina(player, maxStamina/2) + // 传送玩家至安全位置 + g.TeleportPlayer( + player, + proto.EnterReason_ENTER_REASON_REVIVAL, + player.SceneId, + &model.Vector{ + X: player.SafePos.X, + Y: player.SafePos.Y, + Z: player.SafePos.Z, + }, + new(model.Vector), + 0, + 0, + ) + } else { + targetAvatarId := uint32(0) + for _, worldAvatar := range world.GetPlayerWorldAvatarList(player) { + dbAvatar := player.GetDbAvatar() + avatar, exist := dbAvatar.AvatarMap[worldAvatar.GetAvatarId()] + if !exist { + logger.Error("get db avatar is nil, avatarId: %v", worldAvatar.GetAvatarId()) + continue + } + if avatar.LifeState != constant.LIFE_STATE_ALIVE { + continue + } + targetAvatarId = worldAvatar.GetAvatarId() + } + if targetAvatarId == 0 { + g.SendMsg(cmd.WorldPlayerDieNotify, player.PlayerId, player.ClientSeq, &proto.WorldPlayerDieNotify{ + DieType: proto.PlayerDieType(entity.GetLastDieType()), + }) + } else { + g.ChangeAvatar(player, targetAvatarId) + } + } + + rsp := &proto.AvatarDieAnimationEndRsp{ + SkillId: req.SkillId, + DieGuid: req.DieGuid, + } + g.SendMsg(cmd.AvatarDieAnimationEndRsp, player.PlayerId, player.ClientSeq, rsp) +} + +func (g *Game) WorldPlayerReviveReq(player *model.Player, payloadMsg pb.Message) { + req := payloadMsg.(*proto.WorldPlayerReviveReq) + _ = req + g.TeleportPlayer( + player, + proto.EnterReason_ENTER_REASON_REVIVAL, + player.SceneId, + &model.Vector{ + X: player.SafePos.X, + Y: player.SafePos.Y, + Z: player.SafePos.Z, + }, + new(model.Vector), + 0, + 0, + ) + g.SendMsg(cmd.WorldPlayerReviveRsp, player.PlayerId, player.ClientSeq, new(proto.WorldPlayerReviveRsp)) +} + /************************************************** 游戏功能 **************************************************/ +func (g *Game) ChangeAvatar(player *model.Player, targetAvatarId uint32) { + world := WORLD_MANAGER.GetWorldById(player.WorldId) + if world == nil { + logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId) + return + } + scene := world.GetSceneById(player.SceneId) + oldAvatarId := world.GetPlayerActiveAvatarId(player) + if targetAvatarId == oldAvatarId { + logger.Error("can not change to the same avatar, uid: %v, oldAvatarId: %v, targetAvatarId: %v", player.PlayerId, oldAvatarId, targetAvatarId) + return + } + newAvatarIndex := world.GetPlayerAvatarIndexByAvatarId(player, targetAvatarId) + if newAvatarIndex == -1 { + logger.Error("can not find the target avatar in team, uid: %v, targetAvatarId: %v", player.PlayerId, targetAvatarId) + return + } + if !world.GetMultiplayer() { + dbTeam := player.GetDbTeam() + dbTeam.CurrAvatarIndex = uint8(newAvatarIndex) + } + world.SetPlayerAvatarIndex(player, newAvatarIndex) + oldAvatarEntityId := world.GetPlayerWorldAvatarEntityId(player, oldAvatarId) + oldAvatarEntity := scene.GetEntity(oldAvatarEntityId) + if oldAvatarEntity == nil { + logger.Error("can not find old avatar entity, entity id: %v", oldAvatarEntityId) + return + } + oldAvatarEntity.SetMoveState(uint16(proto.MotionState_MOTION_STANDBY)) + + sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{ + DisappearType: proto.VisionType_VISION_REPLACE, + EntityList: []uint32{oldAvatarEntity.GetId()}, + } + g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify) + + newAvatarId := world.GetPlayerActiveAvatarId(player) + newAvatarEntity := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarId) + sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{ + AppearType: proto.VisionType_VISION_REPLACE, + Param: oldAvatarEntity.GetId(), + EntityList: []*proto.SceneEntityInfo{newAvatarEntity}, + } + g.SendToSceneA(scene, cmd.SceneEntityAppearNotify, player.ClientSeq, sceneEntityAppearNotify) +} + /************************************************** 打包封装 **************************************************/ func (g *Game) PacketSceneTeamUpdateNotify(world *World, player *model.Player) *proto.SceneTeamUpdateNotify { diff --git a/gs/game/player_world.go b/gs/game/player_world.go index 570ac6fe..ca999833 100644 --- a/gs/game/player_world.go +++ b/gs/game/player_world.go @@ -580,7 +580,8 @@ func (g *Game) TeleportPlayer( logger.Debug("player goto scene, scene: %v, pos: %v", player.SceneId, player.Pos) enterType = proto.EnterType_ENTER_GOTO } - playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyTp(player, enterType, enterReason, oldSceneId, oldPos, dungeonId, dungeonPointId) + player.SceneEnterReason = uint32(enterReason) + playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyTp(player, enterType, oldSceneId, oldPos, dungeonId, dungeonPointId) g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerId, player.ClientSeq, playerEnterSceneNotify) } diff --git a/gs/model/player.go b/gs/model/player.go index 8e86711c..0528a693 100644 --- a/gs/model/player.go +++ b/gs/model/player.go @@ -68,6 +68,7 @@ type Player struct { Pause bool `bson:"-" msgpack:"-"` // 暂停状态 SceneJump bool `bson:"-" msgpack:"-"` // 是否场景切换 SceneLoadState int `bson:"-" msgpack:"-"` // 场景加载状态 + SceneEnterReason uint32 `bson:"-" msgpack:"-"` // 场景进入原因 CoopApplyMap map[uint32]int64 `bson:"-" msgpack:"-"` // 敲门申请的玩家uid及时间 StaminaInfo *StaminaInfo `bson:"-" msgpack:"-"` // 耐力在线数据 VehicleInfo *VehicleInfo `bson:"-" msgpack:"-"` // 载具在线数据 diff --git a/gs/model/stamina.go b/gs/model/stamina.go index a1044acb..81b0545d 100644 --- a/gs/model/stamina.go +++ b/gs/model/stamina.go @@ -11,7 +11,6 @@ type StaminaInfo struct { RestoreDelay uint8 // 玩家耐力回复延时 LastSkillTime int64 // 最后释放技能的时间 LastCostStaminaTime int64 // 最后执行技能耐力消耗的时间 - DrownBackDelay uint8 // 溺水返回安全点延时 } func NewStaminaInfo() *StaminaInfo { diff --git a/gs/service/gm.go b/gs/service/gm.go index f6c81b6c..edd5e914 100644 --- a/gs/service/gm.go +++ b/gs/service/gm.go @@ -16,6 +16,7 @@ type GMService struct { func (s *GMService) Cmd(ctx context.Context, req *api.CmdRequest) (*api.CmdReply, error) { commandTextInput := game.COMMAND_MANAGER.GetCommandTextInput() commandTextInput <- &game.CommandMessage{ + GMType: game.SystemFuncGM, FuncName: req.FuncName, ParamList: req.ParamList, } diff --git a/protocol/cmd/cmd_id_proto_obj_map.go b/protocol/cmd/cmd_id_proto_obj_map.go index ba9ac9cc..139439ed 100644 --- a/protocol/cmd/cmd_id_proto_obj_map.go +++ b/protocol/cmd/cmd_id_proto_obj_map.go @@ -144,10 +144,14 @@ func (c *CmdProtoMap) registerMessage() { c.regMsg(GadgetInteractRsp, func() any { return new(proto.GadgetInteractRsp) }) // 物件交互响应 c.regMsg(GadgetStateNotify, func() any { return new(proto.GadgetStateNotify) }) // 物件状态更新通知 c.regMsg(WorldChestOpenNotify, func() any { return new(proto.WorldChestOpenNotify) }) // 宝箱开启通知 + c.regMsg(EntityForceSyncReq, func() any { return new(proto.EntityForceSyncReq) }) // 场景实体强制同步请求 客户端强制同步 + c.regMsg(EntityForceSyncRsp, func() any { return new(proto.EntityForceSyncRsp) }) // 场景实体强制同步响应 // 战斗与同步 c.regMsg(AvatarFightPropNotify, func() any { return new(proto.AvatarFightPropNotify) }) // 角色战斗属性通知 + c.regMsg(AvatarFightPropUpdateNotify, func() any { return new(proto.AvatarFightPropUpdateNotify) }) // 角色战斗属性更新通知 c.regMsg(EntityFightPropUpdateNotify, func() any { return new(proto.EntityFightPropUpdateNotify) }) // 实体战斗属性更新通知 + c.regMsg(EntityFightPropChangeReasonNotify, func() any { return new(proto.EntityFightPropChangeReasonNotify) }) // 实体战斗属性变更原因通知 c.regMsg(CombatInvocationsNotify, func() any { return new(proto.CombatInvocationsNotify) }) // 客户端combat通知 服务器转发 c.regMsg(AbilityInvocationsNotify, func() any { return new(proto.AbilityInvocationsNotify) }) // 客户端ability通知 服务器转发 c.regMsg(ClientAbilityInitFinishNotify, func() any { return new(proto.ClientAbilityInitFinishNotify) }) // 客户端ability初始化完成通知 服务器转发 @@ -184,6 +188,11 @@ func (c *CmdProtoMap) registerMessage() { c.regMsg(SyncTeamEntityNotify, func() any { return new(proto.SyncTeamEntityNotify) }) // 同步队伍实体通知 c.regMsg(DelTeamEntityNotify, func() any { return new(proto.DelTeamEntityNotify) }) // 删除队伍实体通知 c.regMsg(SyncScenePlayTeamEntityNotify, func() any { return new(proto.SyncScenePlayTeamEntityNotify) }) // 同步场景玩家队伍实体通知 + c.regMsg(AvatarDieAnimationEndReq, func() any { return new(proto.AvatarDieAnimationEndReq) }) // 角色死亡动画结束请求 切人或玩家死亡 + c.regMsg(AvatarDieAnimationEndRsp, func() any { return new(proto.AvatarDieAnimationEndRsp) }) // 角色死亡动画结束响应 + c.regMsg(WorldPlayerDieNotify, func() any { return new(proto.WorldPlayerDieNotify) }) // 玩家死亡通知 + c.regMsg(WorldPlayerReviveReq, func() any { return new(proto.WorldPlayerReviveReq) }) // 玩家复活请求 + c.regMsg(WorldPlayerReviveRsp, func() any { return new(proto.WorldPlayerReviveRsp) }) // 玩家复活响应 // 多人世界 c.regMsg(PlayerApplyEnterMpReq, func() any { return new(proto.PlayerApplyEnterMpReq) }) // 世界敲门请求 @@ -283,6 +292,8 @@ func (c *CmdProtoMap) registerMessage() { c.regMsg(StoreItemChangeNotify, func() any { return new(proto.StoreItemChangeNotify) }) // 背包道具变动通知 c.regMsg(ItemAddHintNotify, func() any { return new(proto.ItemAddHintNotify) }) // 道具增加提示通知 c.regMsg(StoreItemDelNotify, func() any { return new(proto.StoreItemDelNotify) }) // 背包道具删除通知 + c.regMsg(UseItemReq, func() any { return new(proto.UseItemReq) }) // 道具使用请求 + c.regMsg(UseItemRsp, func() any { return new(proto.UseItemRsp) }) // 道具使用响应 // 装备 c.regMsg(WearEquipReq, func() any { return new(proto.WearEquipReq) }) // 装备穿戴请求 @@ -385,6 +396,8 @@ func (c *CmdProtoMap) registerMessage() { c.regMsg(GmTalkRsp, func() any { return new(proto.GmTalkRsp) }) c.regMsg(GmTalkNotify, func() any { return new(proto.GmTalkNotify) }) c.regMsg(ServerLogNotify, func() any { return new(proto.ServerLogNotify) }) + c.regMsg(MarkEntityInMinMapNotify, func() any { return new(proto.MarkEntityInMinMapNotify) }) + c.regMsg(UnmarkEntityInMinMapNotify, func() any { return new(proto.UnmarkEntityInMinMapNotify) }) } func (c *CmdProtoMap) regMsg(cmdId uint16, protoObjNewFunc func() any) {