From cc01a3c846af21aee639be24273592b0f2a36a78 Mon Sep 17 00:00:00 2001 From: UnKownOwO <80520429@qq.com> Date: Sat, 4 Feb 2023 17:54:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=A7=92=E8=89=B2=E7=AD=89?= =?UTF-8?q?=E7=BA=A7=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gs/game/player_avatar.go | 14 +++++++----- gs/game/player_scene.go | 47 +++++++++++++++++++++++++++++++++++----- gs/game/world_manager.go | 2 +- 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/gs/game/player_avatar.go b/gs/game/player_avatar.go index 292483b3..96b2440f 100644 --- a/gs/game/player_avatar.go +++ b/gs/game/player_avatar.go @@ -102,14 +102,14 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa // 角色等级是否达到限制 if avatar.Level < uint8(avatarPromoteConfig.LevelLimit) { logger.Error("avatar level le level limit, level: %v", avatar.Level) - g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}) + g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_AVATAR_LEVEL_LESS_THAN) return } // 获取角色突破下一级的配置表 avatarPromoteConfig, ok = avatarPromoteDataMap[int32(avatar.Promote+1)] if !ok { logger.Error("avatar promote config error, promoteLevel: %v", avatar.Promote) - g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}) + g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_AVATAR_ON_MAX_BREAK_LEVEL) return } // 将被消耗的物品列表 @@ -130,14 +130,18 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa for _, item := range costItemList { if player.GetItemCount(item.ItemId) < item.ChangeCount { logger.Error("item count not enough, itemId: %v", item.ItemId) - g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH) + // 摩拉的错误提示与材料不同 + if item.ItemId == constant.ItemConstantConst.SCOIN { + g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH) + } + g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH) return } } // 冒险等级是否符合要求 if player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL] < uint32(avatarPromoteConfig.MinPlayerLevel) { logger.Error("player level not enough, level: %v", player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]) - g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}) + g.CommonRetError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_PLAYER_LEVEL_LESS_THAN) return } // 消耗突破材料和摩拉 @@ -219,7 +223,7 @@ func (g *GameManager) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Messa // 角色等级是否达到限制 if avatar.Level >= uint8(avatarPromoteConfig.LevelLimit) { logger.Error("avatar level ge level limit, level: %v", avatar.Level) - g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}) + g.CommonRetError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_AVATAR_BREAK_LEVEL_LESS_THAN) return } // 消耗升级材料以及摩拉 diff --git a/gs/game/player_scene.go b/gs/game/player_scene.go index 18a267a7..d5c5e996 100644 --- a/gs/game/player_scene.go +++ b/gs/game/player_scene.go @@ -654,6 +654,11 @@ func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Pl Z: float32(entity.pos.Z), } worldAvatar := scene.world.GetWorldAvatarByEntityId(entity.id) + avatar, ok := player.AvatarMap[worldAvatar.avatarId] + if !ok { + logger.Error("avatar error, avatarId: %v", worldAvatar.avatarId) + return new(proto.SceneEntityInfo) + } sceneEntityInfo := &proto.SceneEntityInfo{ EntityType: proto.ProtEntityType_PROT_ENTITY_AVATAR, EntityId: entity.id, @@ -667,11 +672,43 @@ func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Pl Speed: &proto.Vector{}, State: proto.MotionState(entity.moveState), }, - PropList: []*proto.PropPair{{Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), PropValue: &proto.PropValue{ - Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), - Value: &proto.PropValue_Ival{Ival: int64(entity.level)}, - Val: int64(entity.level), - }}}, + PropList: []*proto.PropPair{ + { + Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), + PropValue: &proto.PropValue{ + Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), + Value: &proto.PropValue_Ival{Ival: int64(avatar.Level)}, + Val: int64(avatar.Level)}, + }, + { + Type: uint32(constant.PlayerPropertyConst.PROP_EXP), + PropValue: &proto.PropValue{ + Type: uint32(constant.PlayerPropertyConst.PROP_EXP), + Value: &proto.PropValue_Ival{Ival: int64(avatar.Exp)}, + Val: int64(avatar.Exp)}, + }, + { + Type: uint32(constant.PlayerPropertyConst.PROP_BREAK_LEVEL), + PropValue: &proto.PropValue{ + Type: uint32(constant.PlayerPropertyConst.PROP_BREAK_LEVEL), + Value: &proto.PropValue_Ival{Ival: int64(avatar.Promote)}, + Val: int64(avatar.Promote)}, + }, + { + Type: uint32(constant.PlayerPropertyConst.PROP_SATIATION_VAL), + PropValue: &proto.PropValue{ + Type: uint32(constant.PlayerPropertyConst.PROP_SATIATION_VAL), + Value: &proto.PropValue_Ival{Ival: int64(avatar.Satiation)}, + Val: int64(avatar.Satiation)}, + }, + { + Type: uint32(constant.PlayerPropertyConst.PROP_SATIATION_PENALTY_TIME), + PropValue: &proto.PropValue{ + Type: uint32(constant.PlayerPropertyConst.PROP_SATIATION_PENALTY_TIME), + Value: &proto.PropValue_Ival{Ival: int64(avatar.SatiationPenalty)}, + Val: int64(avatar.SatiationPenalty)}, + }, + }, FightPropList: g.PacketFightPropMapToPbFightPropList(entity.fightProp), LifeState: uint32(entity.lifeState), AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0), diff --git a/gs/game/world_manager.go b/gs/game/world_manager.go index d55552b6..db89958e 100644 --- a/gs/game/world_manager.go +++ b/gs/game/world_manager.go @@ -862,7 +862,7 @@ func (s *Scene) CreateEntityAvatar(player *model.Player, avatarId uint32) uint32 lastMoveReliableSeq: 0, fightProp: player.AvatarMap[avatarId].FightPropMap, entityType: uint32(proto.ProtEntityType_PROT_ENTITY_AVATAR), - level: player.AvatarMap[avatarId].Level, + level: 0, // 角色等级直接读取角色对象 avatarEntity: &AvatarEntity{ uid: player.PlayerID, avatarId: avatarId,