配置表访问接口化,简化常量访问

This commit is contained in:
flswld
2023-02-09 19:20:47 +08:00
parent 867448b80d
commit ae4c505e48
74 changed files with 2313 additions and 3189 deletions

View File

@@ -10,7 +10,6 @@ import (
"time"
"hk4e/common/config"
"hk4e/common/constant"
"hk4e/common/mq"
"hk4e/common/rpc"
"hk4e/gdconf"
@@ -72,7 +71,6 @@ func Run(ctx context.Context, configFile string) error {
logger.InitLogger("gs_" + APPID)
logger.Warn("gs start, appid: %v, gsid: %v", APPID, GSID)
constant.InitConstant()
gdconf.InitGameDataConfig()
db, err := dao.NewDao()

View File

@@ -13,7 +13,7 @@ func (c *CommandManager) GMTeleportPlayer(userId, sceneId uint32, posX, posY, po
logger.Error("player is nil, uid: %v", userId)
return
}
GAME_MANAGER.TeleportPlayer(player, constant.EnterReasonConst.Gm, sceneId, &model.Vector{
GAME_MANAGER.TeleportPlayer(player, constant.EnterReasonGm, sceneId, &model.Vector{
X: posX,
Y: posY,
Z: posZ,

View File

@@ -100,7 +100,7 @@ func NewGameManager(dao *dao.Dao, messageQueue *mq.MessageQueue, gsId uint32, gs
for i := 1; i < 3; i++ {
uid := 1000000 + uint32(i)
avatarId := uint32(0)
for _, avatarData := range gdconf.CONF.AvatarDataMap {
for _, avatarData := range gdconf.GetAvatarDataMap() {
avatarId = uint32(avatarData.AvatarId)
break
}
@@ -175,7 +175,7 @@ func (g *GameManager) gameMainLoop() {
motherfuckerPlayerInfo, _ := json.Marshal(SELF)
logger.Error("the motherfucker player info: %v", string(motherfuckerPlayerInfo))
if SELF != nil {
GAME_MANAGER.DisconnectPlayer(SELF.PlayerID, kcp.EnetServerKick)
GAME_MANAGER.KickPlayer(SELF.PlayerID, kcp.EnetServerKick)
}
}
}()
@@ -260,7 +260,7 @@ func (g *GameManager) Close() {
// 单纯的告诉网关下线玩家
userList := USER_MANAGER.GetAllOnlineUserList()
for _, player := range userList {
g.DisconnectPlayer(player.PlayerID, kcp.EnetServerShutdown)
g.KickPlayer(player.PlayerID, kcp.EnetServerShutdown)
}
time.Sleep(time.Second)
}
@@ -374,11 +374,11 @@ func (g *GameManager) SendToWorldH(world *World, cmdId uint16, seq uint32, msg p
GAME_MANAGER.SendMsg(cmdId, world.GetOwner().PlayerID, seq, msg)
}
func (g *GameManager) ReconnectPlayer(userId uint32) {
func (g *GameManager) ReLoginPlayer(userId uint32) {
g.SendMsg(cmd.ClientReconnectNotify, userId, 0, new(proto.ClientReconnectNotify))
}
func (g *GameManager) DisconnectPlayer(userId uint32, reason uint32) {
func (g *GameManager) KickPlayer(userId uint32, reason uint32) {
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
return
@@ -391,7 +391,6 @@ func (g *GameManager) DisconnectPlayer(userId uint32, reason uint32) {
KickReason: reason,
},
})
// g.SendMsg(cmd.ServerDisconnectClientNotify, userId, 0, new(proto.ServerDisconnectClientNotify))
}
func (g *GameManager) GetClientProtoObjByName(protoObjName string) pb.Message {

View File

@@ -357,8 +357,8 @@ func (g *GCGGame) InitDeckCard(controller *GCGController, cardIdList ...uint32)
// GiveCharCard 给予操控者角色卡牌
func (g *GCGGame) GiveCharCard(controller *GCGController, charId uint32) {
// 读取角色卡牌配置表
gcgCharConfig, ok := gdconf.CONF.GCGCharDataMap[int32(charId)]
if !ok {
gcgCharConfig := gdconf.GetGCGCharDataById(int32(charId))
if gcgCharConfig == nil {
logger.Error("gcg char config error, charId: %v", charId)
return
}
@@ -372,10 +372,10 @@ func (g *GCGGame) GiveCharCard(controller *GCGController, charId uint32) {
faceType: 0, // 1为金卡
tagList: gcgCharConfig.TagList,
tokenMap: map[uint32]uint32{
constant.GCGTokenConst.TOKEN_CUR_HEALTH: uint32(gcgCharConfig.HPBase), // 血量
constant.GCGTokenConst.TOKEN_MAX_HEALTH: uint32(gcgCharConfig.HPBase), // 最大血量(不确定)
constant.GCGTokenConst.TOKEN_CUR_ELEM: 0, // 充能
constant.GCGTokenConst.TOKEN_MAX_ELEM: uint32(gcgCharConfig.MaxElemVal), // 充能条
constant.GCG_TOKEN_TYPE_CUR_HEALTH: uint32(gcgCharConfig.HPBase), // 血量
constant.GCG_TOKEN_TYPE_MAX_HEALTH: uint32(gcgCharConfig.HPBase), // 最大血量(不确定)
constant.GCG_TOKEN_TYPE_CUR_ELEM: 0, // 充能
constant.GCG_TOKEN_TYPE_MAX_ELEM: uint32(gcgCharConfig.MaxElemVal), // 充能条
},
skillList: make([]*GCGSkillInfo, 0, len(gcgCharConfig.SkillList)),
skillLimitList: []uint32{},
@@ -571,13 +571,13 @@ func (g *GCGGame) ControllerUseSkill(controller *GCGController, skillId uint32,
msgList = append(msgList, g.GCGMsgUseSkill(controller.selectedCharCardGuid, skillId))
msgList = append(msgList, g.GCGMsgTokenChange(targetSelectedCharCard.guid, proto.GCGReason_GCG_REASON_EFFECT, 11, 1))
msgList = append(msgList, g.GCGMsgTokenChange(targetSelectedCharCard.guid, proto.GCGReason_GCG_REASON_EFFECT_DAMAGE, constant.GCGTokenConst.TOKEN_CUR_HEALTH, 6))
msgList = append(msgList, g.GCGMsgTokenChange(targetSelectedCharCard.guid, proto.GCGReason_GCG_REASON_EFFECT_DAMAGE, constant.GCG_TOKEN_TYPE_CUR_HEALTH, 6))
msgList = append(msgList, g.GCGMsgSkillResult(targetSelectedCharCard.guid, skillId))
msgList = append(msgList, g.GCGMsgUseSkillEnd(controller.selectedCharCardGuid, skillId))
// 因为使用技能自身充能+1
msgList = append(msgList, g.GCGMsgTokenChange(controller.selectedCharCardGuid, proto.GCGReason_GCG_REASON_ATTACK, constant.GCGTokenConst.TOKEN_CUR_ELEM, 3))
msgList = append(msgList, g.GCGMsgTokenChange(controller.selectedCharCardGuid, proto.GCGReason_GCG_REASON_ATTACK, constant.GCG_TOKEN_TYPE_CUR_ELEM, 3))
g.AddAllMsgPack(controller.controllerId, proto.GCGActionType_GCG_ACTION_ATTACK, msgList...)
g.ChangePhase(proto.GCGPhaseType_GCG_PHASE_MAIN)
}
@@ -949,8 +949,8 @@ func (g *GCGGame) GCGMsgCostRevise(controller *GCGController) *proto.GCGMessage
// AttackCostList
for _, skillInfo := range selectedCharCard.skillList {
// 读取卡牌技能配置表
gcgSkillConfig, ok := gdconf.CONF.GCGSkillDataMap[int32(skillInfo.skillId)]
if !ok {
gcgSkillConfig := gdconf.GetGCGSkillDataById(int32(skillInfo.skillId))
if gcgSkillConfig == nil {
logger.Error("gcg skill config error, skillId: %v", skillInfo.skillId)
return new(proto.GCGMessage)
}
@@ -1048,8 +1048,8 @@ func (g *GCGGame) GCGMsgTokenChange(cardGuid uint32, reason proto.GCGReason, tok
// GCGMsgSkillResult GCG消息技能结果
func (g *GCGGame) GCGMsgSkillResult(selectedCharCardGuid uint32, skillId uint32) *proto.GCGMessage {
// 读取卡牌技能配置表
gcgSkillConfig, ok := gdconf.CONF.GCGSkillDataMap[int32(skillId)]
if !ok {
gcgSkillConfig := gdconf.GetGCGSkillDataById(int32(skillId))
if gcgSkillConfig == nil {
logger.Error("gcg skill config error, skillId: %v", skillId)
return new(proto.GCGMessage)
}

View File

@@ -16,7 +16,7 @@ import (
func (g *GameManager) GetAllAvatarDataConfig() map[int32]*gdconf.AvatarData {
allAvatarDataConfig := make(map[int32]*gdconf.AvatarData)
for avatarId, avatarData := range gdconf.CONF.AvatarDataMap {
for avatarId, avatarData := range gdconf.GetAvatarDataMap() {
if avatarId < 10000002 || avatarId >= 11000000 {
// 跳过无效角色
continue
@@ -49,8 +49,8 @@ func (g *GameManager) AddUserAvatar(userId uint32, avatarId uint32) {
player.AddAvatar(avatarId)
// 添加初始武器
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatarId)]
if !ok {
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatarId))
if avatarDataConfig == nil {
logger.Error("config is nil, itemId: %v", avatarId)
return
}
@@ -80,8 +80,8 @@ func (g *GameManager) AvatarPromoteGetRewardReq(player *model.Player, payloadMsg
return
}
// 获取角色配置表
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)]
if !ok {
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatar.AvatarId))
if avatarDataConfig == nil {
logger.Error("avatar config error, avatarId: %v", avatar.AvatarId)
g.SendError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{})
return
@@ -93,8 +93,8 @@ func (g *GameManager) AvatarPromoteGetRewardReq(player *model.Player, payloadMsg
return
}
// 获取奖励配置表
rewardConfig, ok := gdconf.CONF.RewardDataMap[int32(avatarDataConfig.PromoteRewardMap[req.PromoteLevel])]
if !ok {
rewardConfig := gdconf.GetRewardDataById(int32(avatarDataConfig.PromoteRewardMap[req.PromoteLevel]))
if rewardConfig == nil {
logger.Error("reward config error, rewardId: %v", avatarDataConfig.PromoteRewardMap[req.PromoteLevel])
g.SendError(cmd.AvatarPromoteGetRewardRsp, player, &proto.AvatarPromoteGetRewardRsp{})
return
@@ -131,22 +131,15 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa
return
}
// 获取角色配置表
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)]
if !ok {
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatar.AvatarId))
if avatarDataConfig == nil {
logger.Error("avatar config error, avatarId: %v", avatar.AvatarId)
g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{})
return
}
// 获取角色突破配置表
avatarPromoteDataMap, ok := gdconf.CONF.AvatarPromoteDataMap[avatarDataConfig.PromoteId]
if !ok {
logger.Error("avatar promote config error, promoteId: %v", avatarDataConfig.PromoteId)
g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{})
return
}
// 获取角色突破等级的配置表
avatarPromoteConfig, ok := avatarPromoteDataMap[int32(avatar.Promote)]
if !ok {
avatarPromoteConfig := gdconf.GetAvatarPromoteDataByIdAndLevel(avatarDataConfig.PromoteId, int32(avatar.Promote))
if avatarPromoteConfig == nil {
logger.Error("avatar promote config error, promoteLevel: %v", avatar.Promote)
g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{})
return
@@ -158,8 +151,8 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa
return
}
// 获取角色突破下一级的配置表
avatarPromoteConfig, ok = avatarPromoteDataMap[int32(avatar.Promote+1)]
if !ok {
avatarPromoteConfig = gdconf.GetAvatarPromoteDataByIdAndLevel(avatarDataConfig.PromoteId, int32(avatar.Promote+1))
if avatarPromoteConfig == nil {
logger.Error("avatar promote config error, next promoteLevel: %v", avatar.Promote+1)
g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_AVATAR_ON_MAX_BREAK_LEVEL)
return
@@ -175,7 +168,7 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa
}
// 消耗列表添加摩拉的消耗
costItemList = append(costItemList, &UserItem{
ItemId: constant.ItemConstantConst.SCOIN,
ItemId: constant.ITEM_ID_SCOIN,
ChangeCount: uint32(avatarPromoteConfig.CostCoin),
})
// 突破材料以及摩拉是否足够
@@ -183,7 +176,7 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa
if player.GetItemCount(item.ItemId) < item.ChangeCount {
logger.Error("item count not enough, itemId: %v", item.ItemId)
// 摩拉的错误提示与材料不同
if item.ItemId == constant.ItemConstantConst.SCOIN {
if item.ItemId == constant.ITEM_ID_SCOIN {
g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
}
g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH)
@@ -191,8 +184,8 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa
}
}
// 冒险等级是否符合要求
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])
if player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL] < uint32(avatarPromoteConfig.MinPlayerLevel) {
logger.Error("player level not enough, level: %v", player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL])
g.SendError(cmd.AvatarPromoteRsp, player, &proto.AvatarPromoteRsp{}, proto.Retcode_RET_PLAYER_LEVEL_LESS_THAN)
return
}
@@ -230,9 +223,9 @@ func (g *GameManager) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Messa
return
}
// 获取经验书物品配置表
itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(req.ItemId)]
if !ok {
logger.Error("item data config error, itemId: %v", constant.ItemConstantConst.SCOIN)
itemDataConfig := gdconf.GetItemDataById(int32(req.ItemId))
if itemDataConfig == nil {
logger.Error("item data config error, itemId: %v", constant.ITEM_ID_SCOIN)
g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return
}
@@ -246,28 +239,21 @@ func (g *GameManager) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Messa
// 角色获得的经验
expCount := uint32(itemParam) * req.Count
// 摩拉数量是否足够
if player.GetItemCount(constant.ItemConstantConst.SCOIN) < expCount/5 {
logger.Error("item count not enough, itemId: %v", constant.ItemConstantConst.SCOIN)
if player.GetItemCount(constant.ITEM_ID_SCOIN) < expCount/5 {
logger.Error("item count not enough, itemId: %v", constant.ITEM_ID_SCOIN)
g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
return
}
// 获取角色配置表
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)]
if !ok {
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatar.AvatarId))
if avatarDataConfig == nil {
logger.Error("avatar config error, avatarId: %v", avatar.AvatarId)
g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{})
return
}
// 获取角色突破配置表
avatarPromoteDataMap, ok := gdconf.CONF.AvatarPromoteDataMap[avatarDataConfig.PromoteId]
if !ok {
logger.Error("avatar promote config error, promoteId: %v", avatarDataConfig.PromoteId)
g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{})
return
}
// 获取角色突破等级对应的配置表
avatarPromoteConfig, ok := avatarPromoteDataMap[int32(avatar.Promote)]
if !ok {
avatarPromoteConfig := gdconf.GetAvatarPromoteDataByIdAndLevel(avatarDataConfig.PromoteId, int32(avatar.Promote))
if avatarPromoteConfig == nil {
logger.Error("avatar promote config error, promoteLevel: %v", avatar.Promote)
g.SendError(cmd.AvatarUpgradeRsp, player, &proto.AvatarUpgradeRsp{})
return
@@ -285,7 +271,7 @@ func (g *GameManager) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Messa
ChangeCount: req.Count,
},
{
ItemId: constant.ItemConstantConst.SCOIN,
ItemId: constant.ITEM_ID_SCOIN,
ChangeCount: expCount / 5,
},
})
@@ -312,20 +298,14 @@ func (g *GameManager) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Messa
// UpgradePlayerAvatar 玩家角色升级
func (g *GameManager) UpgradePlayerAvatar(player *model.Player, avatar *model.Avatar, expCount uint32) {
// 获取角色配置表
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)]
if !ok {
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatar.AvatarId))
if avatarDataConfig == nil {
logger.Error("avatar config error, avatarId: %v", avatar.AvatarId)
return
}
// 获取角色突破配置表
avatarPromoteDataMap, ok := gdconf.CONF.AvatarPromoteDataMap[avatarDataConfig.PromoteId]
if !ok {
logger.Error("avatar promote config error, promoteId: %v", avatarDataConfig.PromoteId)
return
}
// 获取角色突破等级对应的配置表
avatarPromoteConfig, ok := avatarPromoteDataMap[int32(avatar.Promote)]
if !ok {
avatarPromoteConfig := gdconf.GetAvatarPromoteDataByIdAndLevel(avatarDataConfig.PromoteId, int32(avatar.Promote))
if avatarPromoteConfig == nil {
logger.Error("avatar promote config error, promoteLevel: %v", avatar.Promote)
return
}
@@ -334,8 +314,8 @@ func (g *GameManager) UpgradePlayerAvatar(player *model.Player, avatar *model.Av
// 角色升级
for {
// 获取角色等级配置表
avatarLevelConfig, ok := gdconf.CONF.AvatarLevelDataMap[int32(avatar.Level)]
if !ok {
avatarLevelConfig := gdconf.GetAvatarLevelDataByLevel(int32(avatar.Level))
if avatarLevelConfig == nil {
// 获取不到代表已经到达最大等级
break
}
@@ -366,15 +346,15 @@ func (g *GameManager) PacketAvatarPropNotify(avatar *model.Avatar) *proto.Avatar
AvatarGuid: avatar.Guid,
}
// 角色等级
avatarPropNotify.PropMap[uint32(constant.PlayerPropertyConst.PROP_LEVEL)] = int64(avatar.Level)
avatarPropNotify.PropMap[uint32(constant.PLAYER_PROP_LEVEL)] = int64(avatar.Level)
// 角色经验
avatarPropNotify.PropMap[uint32(constant.PlayerPropertyConst.PROP_EXP)] = int64(avatar.Exp)
avatarPropNotify.PropMap[uint32(constant.PLAYER_PROP_EXP)] = int64(avatar.Exp)
// 角色突破等级
avatarPropNotify.PropMap[uint32(constant.PlayerPropertyConst.PROP_BREAK_LEVEL)] = int64(avatar.Promote)
avatarPropNotify.PropMap[uint32(constant.PLAYER_PROP_BREAK_LEVEL)] = int64(avatar.Promote)
// 角色饱食度
avatarPropNotify.PropMap[uint32(constant.PlayerPropertyConst.PROP_SATIATION_VAL)] = int64(avatar.Satiation)
avatarPropNotify.PropMap[uint32(constant.PLAYER_PROP_SATIATION_VAL)] = int64(avatar.Satiation)
// 角色饱食度溢出
avatarPropNotify.PropMap[uint32(constant.PlayerPropertyConst.PROP_SATIATION_PENALTY_TIME)] = int64(avatar.SatiationPenalty)
avatarPropNotify.PropMap[uint32(constant.PLAYER_PROP_SATIATION_PENALTY_TIME)] = int64(avatar.SatiationPenalty)
return avatarPropNotify
}
@@ -536,8 +516,8 @@ func (g *GameManager) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.
}
func (g *GameManager) PacketAvatarEquipChangeNotify(avatar *model.Avatar, weapon *model.Weapon, entityId uint32) *proto.AvatarEquipChangeNotify {
itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
if !ok {
itemDataConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
if itemDataConfig == nil {
logger.Error("item data config error, itemId: %v", weapon.ItemId)
return new(proto.AvatarEquipChangeNotify)
}
@@ -547,9 +527,9 @@ func (g *GameManager) PacketAvatarEquipChangeNotify(avatar *model.Avatar, weapon
EquipGuid: weapon.Guid,
}
switch itemDataConfig.Type {
case int32(constant.ItemTypeConst.ITEM_WEAPON):
avatarEquipChangeNotify.EquipType = uint32(constant.EquipTypeConst.EQUIP_WEAPON)
case int32(constant.ItemTypeConst.ITEM_RELIQUARY):
case int32(constant.ITEM_TYPE_WEAPON):
avatarEquipChangeNotify.EquipType = uint32(constant.EQUIP_TYPE_WEAPON)
case int32(constant.ITEM_TYPE_RELIQUARY):
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.ReliquaryType)
}
avatarEquipChangeNotify.Weapon = &proto.SceneWeaponInfo{
@@ -567,8 +547,8 @@ func (g *GameManager) PacketAvatarEquipTakeOffNotify(avatar *model.Avatar, weapo
avatarEquipChangeNotify := &proto.AvatarEquipChangeNotify{
AvatarGuid: avatar.Guid,
}
itemDataConfig, exist := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
if exist {
itemDataConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
if itemDataConfig != nil {
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.Type)
}
return avatarEquipChangeNotify
@@ -605,28 +585,28 @@ func (g *GameManager) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
AvatarId: avatar.AvatarId,
Guid: avatar.Guid,
PropMap: map[uint32]*proto.PropValue{
uint32(constant.PlayerPropertyConst.PROP_LEVEL): {
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
uint32(constant.PLAYER_PROP_LEVEL): {
Type: uint32(constant.PLAYER_PROP_LEVEL),
Val: int64(avatar.Level),
Value: &proto.PropValue_Ival{Ival: int64(avatar.Level)},
},
uint32(constant.PlayerPropertyConst.PROP_EXP): {
Type: uint32(constant.PlayerPropertyConst.PROP_EXP),
uint32(constant.PLAYER_PROP_EXP): {
Type: uint32(constant.PLAYER_PROP_EXP),
Val: int64(avatar.Exp),
Value: &proto.PropValue_Ival{Ival: int64(avatar.Exp)},
},
uint32(constant.PlayerPropertyConst.PROP_BREAK_LEVEL): {
Type: uint32(constant.PlayerPropertyConst.PROP_BREAK_LEVEL),
uint32(constant.PLAYER_PROP_BREAK_LEVEL): {
Type: uint32(constant.PLAYER_PROP_BREAK_LEVEL),
Val: int64(avatar.Promote),
Value: &proto.PropValue_Ival{Ival: int64(avatar.Promote)},
},
uint32(constant.PlayerPropertyConst.PROP_SATIATION_VAL): {
Type: uint32(constant.PlayerPropertyConst.PROP_SATIATION_VAL),
uint32(constant.PLAYER_PROP_SATIATION_VAL): {
Type: uint32(constant.PLAYER_PROP_SATIATION_VAL),
Val: int64(avatar.Satiation),
Value: &proto.PropValue_Ival{Ival: int64(avatar.Satiation)},
},
uint32(constant.PlayerPropertyConst.PROP_SATIATION_PENALTY_TIME): {
Type: uint32(constant.PlayerPropertyConst.PROP_SATIATION_PENALTY_TIME),
uint32(constant.PLAYER_PROP_SATIATION_PENALTY_TIME): {
Type: uint32(constant.PLAYER_PROP_SATIATION_PENALTY_TIME),
Val: int64(avatar.SatiationPenalty),
Value: &proto.PropValue_Ival{Ival: int64(avatar.SatiationPenalty)},
},
@@ -651,14 +631,14 @@ func (g *GameManager) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
for _, v := range avatar.FetterList {
pbAvatar.FetterInfo.FetterList = append(pbAvatar.FetterInfo.FetterList, &proto.FetterData{
FetterId: v,
FetterState: uint32(constant.FetterStateConst.FINISH),
FetterState: uint32(constant.FETTER_STATE_FINISH),
})
}
// 解锁全部资料
for _, v := range gdconf.CONF.FetterDataAvatarIdMap[int32(avatar.AvatarId)] {
for _, v := range gdconf.GetFetterIdListByAvatarId(int32(avatar.AvatarId)) {
pbAvatar.FetterInfo.FetterList = append(pbAvatar.FetterInfo.FetterList, &proto.FetterData{
FetterId: uint32(v),
FetterState: uint32(constant.FetterStateConst.FINISH),
FetterState: uint32(constant.FETTER_STATE_FINISH),
})
}
// 突破等级奖励

View File

@@ -16,40 +16,40 @@ func (g *GameManager) AddUserPlayerExp(userId uint32, expCount uint32) {
return
}
// 玩家增加冒险阅历
player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_EXP] += expCount
player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP] += expCount
// 玩家升级
for {
playerLevel := player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]
playerLevel := player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL]
// 读取玩家等级配置表
playerLevelConfig, ok := gdconf.CONF.PlayerLevelDataMap[int32(playerLevel)]
if !ok {
playerLevelConfig := gdconf.GetPlayerLevelDataById(int32(playerLevel))
if playerLevelConfig == nil {
// 获取不到代表已经到达最大等级
break
}
// 玩家冒险阅历不足则跳出循环
if player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_EXP] < uint32(playerLevelConfig.Exp) {
if player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP] < uint32(playerLevelConfig.Exp) {
break
}
// 玩家增加冒险等阶
player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]++
player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_EXP] -= uint32(playerLevelConfig.Exp)
player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL]++
player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP] -= uint32(playerLevelConfig.Exp)
// 更新玩家属性
playerPropNotify := &proto.PlayerPropNotify{
PropMap: make(map[uint32]*proto.PropValue),
}
playerPropNotify.PropMap[uint32(constant.PlayerPropertyConst.PROP_PLAYER_LEVEL)] = &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_PLAYER_LEVEL),
Val: int64(player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]),
playerPropNotify.PropMap[uint32(constant.PLAYER_PROP_PLAYER_LEVEL)] = &proto.PropValue{
Type: uint32(constant.PLAYER_PROP_PLAYER_LEVEL),
Val: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL]),
Value: &proto.PropValue_Ival{
Ival: int64(player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]),
Ival: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL]),
},
}
playerPropNotify.PropMap[uint32(constant.PlayerPropertyConst.PROP_PLAYER_EXP)] = &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_PLAYER_EXP),
Val: int64(player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_EXP]),
playerPropNotify.PropMap[uint32(constant.PLAYER_PROP_PLAYER_EXP)] = &proto.PropValue{
Type: uint32(constant.PLAYER_PROP_PLAYER_EXP),
Val: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP]),
Value: &proto.PropValue_Ival{
Ival: int64(player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_EXP]),
Ival: int64(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_EXP]),
},
}
g.SendMsg(cmd.PlayerPropNotify, userId, player.ClientSeq, playerPropNotify)

View File

@@ -139,12 +139,12 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
currHp := float32(0)
fightProp := target.GetFightProp()
if fightProp != nil {
currHp = fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)]
currHp = fightProp[uint32(constant.FIGHT_PROP_CUR_HP)]
currHp -= damage
if currHp < 0 {
currHp = 0
}
fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)] = currHp
fightProp[uint32(constant.FIGHT_PROP_CUR_HP)] = currHp
}
entityFightPropUpdateNotify := &proto.EntityFightPropUpdateNotify{
FightPropMap: fightProp,
@@ -152,7 +152,7 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
}
g.SendToWorldA(world, cmd.EntityFightPropUpdateNotify, player.ClientSeq, entityFightPropUpdateNotify)
if currHp == 0 && target.GetAvatarEntity() == nil {
scene.SetEntityLifeState(target, constant.LifeStateConst.LIFE_DEAD, proto.PlayerDieType_PLAYER_DIE_GM)
scene.SetEntityLifeState(target, constant.LIFE_STATE_DEAD, proto.PlayerDieType_PLAYER_DIE_GM)
}
combatData, err := pb.Marshal(hitInfo)
if err != nil {

View File

@@ -63,7 +63,7 @@ func (g *GameManager) GCGStartChallenge(player *model.Player) {
g.PacketGCGGameBriefDataNotify(player, proto.GCGGameBusinessType_GCG_GAME_GUIDE_GROUP, game))
// 玩家进入GCG界面
g.TeleportPlayer(player, constant.EnterReasonConst.DungeonEnter, 79999, new(model.Vector), new(model.Vector), 2162)
g.TeleportPlayer(player, constant.EnterReasonDungeonEnter, 79999, new(model.Vector), new(model.Vector), 2162)
}
// GCGAskDuelReq GCG决斗请求
@@ -392,8 +392,8 @@ func (g *GameManager) PacketGCGSkillPreviewNotify(game *GCGGame, controller *GCG
// SkillPreviewList
for _, skillInfo := range selectedCharCard.skillList {
// 读取卡牌技能配置表
gcgSkillConfig, ok := gdconf.CONF.GCGSkillDataMap[int32(skillInfo.skillId)]
if !ok {
gcgSkillConfig := gdconf.GetGCGSkillDataById(int32(skillInfo.skillId))
if gcgSkillConfig == nil {
logger.Error("gcg skill config error, skillId: %v", skillInfo.skillId)
return new(proto.GCGSkillPreviewNotify)
}
@@ -421,10 +421,10 @@ func (g *GameManager) PacketGCGSkillPreviewNotify(game *GCGGame, controller *GCG
TokenChangeList: []*proto.GCGSkillPreviewTokenInfo{
{
// Token类型
TokenType: constant.GCGTokenConst.TOKEN_CUR_ELEM,
TokenType: constant.GCG_TOKEN_TYPE_CUR_ELEM,
BeforeValue: 0,
// 更改为的值
AfterValue: selectedCharCard.tokenMap[constant.GCGTokenConst.TOKEN_CUR_ELEM] + 1,
AfterValue: selectedCharCard.tokenMap[constant.GCG_TOKEN_TYPE_CUR_ELEM] + 1,
},
},
}

View File

@@ -15,12 +15,12 @@ type UserItem struct {
func (g *GameManager) GetAllItemDataConfig() map[int32]*gdconf.ItemData {
allItemDataConfig := make(map[int32]*gdconf.ItemData)
for itemId, itemData := range gdconf.CONF.ItemDataMap {
if uint16(itemData.Type) == constant.ItemTypeConst.ITEM_WEAPON {
for itemId, itemData := range gdconf.GetItemDataMap() {
if uint16(itemData.Type) == constant.ITEM_TYPE_WEAPON {
// 排除武器
continue
}
if uint16(itemData.Type) == constant.ItemTypeConst.ITEM_RELIQUARY {
if uint16(itemData.Type) == constant.ITEM_TYPE_RELIQUARY {
// 排除圣遗物
continue
}
@@ -61,10 +61,10 @@ func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bo
for _, userItem := range itemList {
// 物品为虚拟物品则另外处理
switch userItem.ItemId {
case constant.ItemConstantConst.RESIN, constant.ItemConstantConst.LEGENDARY_KEY, constant.ItemConstantConst.HCOIN,
constant.ItemConstantConst.SCOIN, constant.ItemConstantConst.MCOIN, constant.ItemConstantConst.HOME_COIN:
case constant.ITEM_ID_RESIN, constant.ITEM_ID_LEGENDARY_KEY, constant.ITEM_ID_HCOIN, constant.ITEM_ID_SCOIN,
constant.ITEM_ID_MCOIN, constant.ITEM_ID_HOME_COIN:
// 树脂 传说任务钥匙 原石 摩拉 创世结晶 洞天宝钱
prop, ok := constant.ItemConstantConst.VIRTUAL_ITEM_PROP[userItem.ItemId]
prop, ok := constant.VIRTUAL_ITEM_PROP[userItem.ItemId]
if !ok {
continue
}
@@ -78,7 +78,7 @@ func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bo
Ival: int64(player.PropertiesMap[prop]),
},
}
case constant.ItemConstantConst.PLAYER_EXP:
case constant.ITEM_ID_PLAYER_EXP:
// 冒险阅历
g.AddUserPlayerExp(userId, userItem.ChangeCount)
default:
@@ -110,7 +110,7 @@ func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bo
if isHint {
if hintReason == 0 {
hintReason = constant.ActionReasonConst.SubfieldDrop
hintReason = constant.ActionReasonSubfieldDrop
}
itemAddHintNotify := &proto.ItemAddHintNotify{
Reason: uint32(hintReason),
@@ -139,10 +139,10 @@ func (g *GameManager) CostUserItem(userId uint32, itemList []*UserItem) {
for _, userItem := range itemList {
// 物品为虚拟物品则另外处理
switch userItem.ItemId {
case constant.ItemConstantConst.RESIN, constant.ItemConstantConst.LEGENDARY_KEY, constant.ItemConstantConst.HCOIN,
constant.ItemConstantConst.SCOIN, constant.ItemConstantConst.MCOIN, constant.ItemConstantConst.HOME_COIN:
case constant.ITEM_ID_RESIN, constant.ITEM_ID_LEGENDARY_KEY, constant.ITEM_ID_HCOIN, constant.ITEM_ID_SCOIN,
constant.ITEM_ID_MCOIN, constant.ITEM_ID_HOME_COIN:
// 树脂 传说任务钥匙 原石 摩拉 创世结晶 洞天宝钱
prop, ok := constant.ItemConstantConst.VIRTUAL_ITEM_PROP[userItem.ItemId]
prop, ok := constant.VIRTUAL_ITEM_PROP[userItem.ItemId]
if !ok {
continue
}
@@ -160,7 +160,7 @@ func (g *GameManager) CostUserItem(userId uint32, itemList []*UserItem) {
Ival: int64(player.PropertiesMap[prop]),
},
}
case constant.ItemConstantConst.PLAYER_EXP:
case constant.ITEM_ID_PLAYER_EXP:
// 冒险阅历应该也没人会去扣吧?
default:
// 普通物品直接扣除

View File

@@ -9,7 +9,6 @@ import (
"hk4e/gdconf"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/pkg/reflection"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
@@ -198,19 +197,18 @@ func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.Playe
StoreType: proto.StoreType_STORE_PACK,
WeightLimit: 30000,
}
itemDataMapConfig := gdconf.CONF.ItemDataMap
for _, weapon := range player.WeaponMap {
pbItem := &proto.Item{
ItemId: weapon.ItemId,
Guid: weapon.Guid,
Detail: nil,
}
itemData, ok := itemDataMapConfig[int32(weapon.ItemId)]
if !ok {
logger.Error("config is nil, itemId: %v", weapon.ItemId)
return nil
itemDataConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
if itemDataConfig == nil {
logger.Error("get item data config is nil, itemId: %v", weapon.ItemId)
continue
}
if uint16(itemData.Type) != constant.ItemTypeConst.ITEM_WEAPON {
if uint16(itemDataConfig.Type) != constant.ITEM_TYPE_WEAPON {
continue
}
affixMap := make(map[uint32]uint32)
@@ -238,7 +236,12 @@ func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.Playe
Guid: reliquary.Guid,
Detail: nil,
}
if uint16(itemDataMapConfig[int32(reliquary.ItemId)].Type) != constant.ItemTypeConst.ITEM_RELIQUARY {
itemDataConfig := gdconf.GetItemDataById(int32(reliquary.ItemId))
if itemDataConfig == nil {
logger.Error("get item data config is nil, itemId: %v", reliquary.ItemId)
continue
}
if uint16(itemDataConfig.Type) != constant.ITEM_TYPE_RELIQUARY {
continue
}
pbItem.Detail = &proto.Item_Equip{
@@ -263,8 +266,12 @@ func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.Playe
Guid: item.Guid,
Detail: nil,
}
itemDataConfig := itemDataMapConfig[int32(item.ItemId)]
if itemDataConfig != nil && uint16(itemDataConfig.Type) == constant.ItemTypeConst.ITEM_FURNITURE {
itemDataConfig := gdconf.GetItemDataById(int32(item.ItemId))
if itemDataConfig == nil {
logger.Error("get item data config is nil, itemId: %v", item.ItemId)
continue
}
if itemDataConfig != nil && uint16(itemDataConfig.Type) == constant.ITEM_TYPE_FURNITURE {
pbItem.Detail = &proto.Item_Furniture{
Furniture: &proto.Furniture{
Count: item.Count,
@@ -315,10 +322,9 @@ func (g *GameManager) PacketOpenStateUpdateNotify() *proto.OpenStateUpdateNotify
openStateUpdateNotify := &proto.OpenStateUpdateNotify{
OpenStateMap: make(map[uint32]uint32),
}
openStateConstMap := reflection.ConvStructToMap(constant.OpenStateConst)
// 先暂时开放全部功能模块
for _, v := range openStateConstMap {
openStateUpdateNotify.OpenStateMap[uint32(v.(uint16))] = 1
for _, v := range constant.ALL_OPEN_STATE {
openStateUpdateNotify.OpenStateMap[uint32(v)] = 1
}
return openStateUpdateNotify
}
@@ -342,31 +348,17 @@ func (g *GameManager) CreatePlayer(userId uint32, nickName string, mainCharAvata
player.SceneId = 3
player.PropertiesMap = make(map[uint16]uint32)
// 初始化所有属性
propList := reflection.ConvStructToMap(constant.PlayerPropertyConst)
for fieldName, fieldValue := range propList {
// 排除角色相关的属性
if fieldName == "PROP_EXP" ||
fieldName == "PROP_BREAK_LEVEL" ||
fieldName == "PROP_SATIATION_VAL" ||
fieldName == "PROP_SATIATION_PENALTY_TIME" ||
fieldName == "PROP_LEVEL" {
continue
}
value := fieldValue.(uint16)
player.PropertiesMap[value] = 0
}
player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL] = 1
player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL] = 0
player.PropertiesMap[constant.PlayerPropertyConst.PROP_IS_SPRING_AUTO_USE] = 1
player.PropertiesMap[constant.PlayerPropertyConst.PROP_SPRING_AUTO_USE_PERCENT] = 100
player.PropertiesMap[constant.PlayerPropertyConst.PROP_IS_FLYABLE] = 1
player.PropertiesMap[constant.PlayerPropertyConst.PROP_IS_TRANSFERABLE] = 1
player.PropertiesMap[constant.PlayerPropertyConst.PROP_MAX_STAMINA] = 24000
player.PropertiesMap[constant.PlayerPropertyConst.PROP_CUR_PERSIST_STAMINA] = 24000
player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_RESIN] = 160
player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE] = 2
player.PropertiesMap[constant.PlayerPropertyConst.PROP_IS_MP_MODE_AVAILABLE] = 1
player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL] = 1
player.PropertiesMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL] = 0
player.PropertiesMap[constant.PLAYER_PROP_IS_SPRING_AUTO_USE] = 1
player.PropertiesMap[constant.PLAYER_PROP_SPRING_AUTO_USE_PERCENT] = 100
player.PropertiesMap[constant.PLAYER_PROP_IS_FLYABLE] = 1
player.PropertiesMap[constant.PLAYER_PROP_IS_TRANSFERABLE] = 1
player.PropertiesMap[constant.PLAYER_PROP_MAX_STAMINA] = 24000
player.PropertiesMap[constant.PLAYER_PROP_CUR_PERSIST_STAMINA] = 24000
player.PropertiesMap[constant.PLAYER_PROP_PLAYER_RESIN] = 160
player.PropertiesMap[constant.PLAYER_PROP_PLAYER_MP_SETTING_TYPE] = 2
player.PropertiesMap[constant.PLAYER_PROP_IS_MP_MODE_AVAILABLE] = 1
player.FlyCloakList = make([]uint32, 0)
player.FlyCloakList = append(player.FlyCloakList, 140001)
@@ -411,8 +403,8 @@ func (g *GameManager) CreatePlayer(userId uint32, nickName string, mainCharAvata
// 添加选定的主角
player.AddAvatar(mainCharAvatarId)
// 添加初始武器
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(mainCharAvatarId)]
if !ok {
avatarDataConfig := gdconf.GetAvatarDataById(int32(mainCharAvatarId))
if avatarDataConfig == nil {
logger.Error("config is nil, mainCharAvatarId: %v", mainCharAvatarId)
return nil
}

View File

@@ -17,27 +17,22 @@ func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.M
logger.Debug("user get scene trans to point, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.SceneTransToPointReq)
scenePointConfig, exist := gdconf.CONF.ScenePointMap[int32(req.SceneId)]
if !exist {
g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{})
return
}
pointConfig, exist := scenePointConfig.PointMap[int32(req.PointId)]
if !exist {
pointDataConfig := gdconf.GetScenePointBySceneIdAndPointId(int32(req.SceneId), int32(req.PointId))
if pointDataConfig == nil {
g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{})
return
}
// 传送玩家
sceneId := req.SceneId
g.TeleportPlayer(player, constant.EnterReasonConst.TransPoint, sceneId, &model.Vector{
X: pointConfig.TranPos.X,
Y: pointConfig.TranPos.Y,
Z: pointConfig.TranPos.Z,
g.TeleportPlayer(player, constant.EnterReasonTransPoint, sceneId, &model.Vector{
X: pointDataConfig.TranPos.X,
Y: pointDataConfig.TranPos.Y,
Z: pointDataConfig.TranPos.Z,
}, &model.Vector{
X: pointConfig.TranRot.X,
Y: pointConfig.TranRot.Y,
Z: pointConfig.TranRot.Z,
X: pointDataConfig.TranRot.X,
Y: pointDataConfig.TranRot.Y,
Z: pointDataConfig.TranRot.Z,
}, 0)
sceneTransToPointRsp := &proto.SceneTransToPointRsp{
@@ -60,7 +55,7 @@ func (g *GameManager) MarkMapReq(player *model.Player, payloadMsg pb.Message) {
posYInt = 300
}
// 传送玩家
g.TeleportPlayer(player, constant.EnterReasonConst.Gm, req.Mark.SceneId, &model.Vector{
g.TeleportPlayer(player, constant.EnterReasonGm, req.Mark.SceneId, &model.Vector{
X: float64(req.Mark.Pos.X),
Y: float64(posYInt),
Z: float64(req.Mark.Pos.Z),
@@ -107,7 +102,7 @@ func (g *GameManager) TeleportPlayer(player *model.Player, enterReason uint16, s
var enterType proto.EnterType
switch enterReason {
case constant.EnterReasonConst.DungeonEnter:
case constant.EnterReasonDungeonEnter:
logger.Debug("player dungeon scene, scene: %v, pos: %v", player.SceneId, player.Pos)
enterType = proto.EnterType_ENTER_DUNGEON
default:
@@ -127,8 +122,8 @@ func (g *GameManager) GetScenePointReq(player *model.Player, payloadMsg pb.Messa
logger.Debug("user get scene point, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.GetScenePointReq)
scenePointConfig, exist := gdconf.CONF.ScenePointMap[int32(req.SceneId)]
if !exist {
scenePointMapConfig := gdconf.GetScenePointMapBySceneId(int32(req.SceneId))
if scenePointMapConfig == nil {
return
}
@@ -136,7 +131,7 @@ func (g *GameManager) GetScenePointReq(player *model.Player, payloadMsg pb.Messa
SceneId: req.SceneId,
}
areaIdMap := make(map[uint32]bool)
for _, worldAreaData := range gdconf.CONF.WorldAreaDataMap {
for _, worldAreaData := range gdconf.GetWorldAreaDataMap() {
if uint32(worldAreaData.SceneId) == req.SceneId {
areaIdMap[uint32(worldAreaData.AreaId1)] = true
}
@@ -146,7 +141,7 @@ func (g *GameManager) GetScenePointReq(player *model.Player, payloadMsg pb.Messa
areaList = append(areaList, areaId)
}
getScenePointRsp.UnlockAreaList = areaList
for _, pointData := range scenePointConfig.PointMap {
for _, pointData := range scenePointMapConfig {
if pointData.PointType == gdconf.PointTypeOther {
continue
}
@@ -163,7 +158,7 @@ func (g *GameManager) GetSceneAreaReq(player *model.Player, payloadMsg pb.Messag
SceneId: req.SceneId,
}
areaIdMap := make(map[uint32]bool)
for _, worldAreaData := range gdconf.CONF.WorldAreaDataMap {
for _, worldAreaData := range gdconf.GetWorldAreaDataMap() {
if uint32(worldAreaData.SceneId) == req.SceneId {
areaIdMap[uint32(worldAreaData.AreaId1)] = true
}

View File

@@ -212,8 +212,8 @@ func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32
ApplyPlayerOnlineInfo: &mq.UserBaseInfo{
UserId: player.PlayerID,
Nickname: player.NickName,
PlayerLevel: player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
MpSettingType: uint8(player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
PlayerLevel: player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL],
MpSettingType: uint8(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_MP_SETTING_TYPE]),
NameCardId: player.NameCard,
Signature: player.Signature,
HeadImageId: player.HeadImage,
@@ -235,7 +235,7 @@ func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_NOT_IN_PLAYER_WORLD)
return
}
mpSetting := targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]
mpSetting := targetPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_MP_SETTING_TYPE]
if mpSetting == 0 {
// 房主玩家没开权限
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_SCENE_CANNOT_ENTER)
@@ -340,7 +340,7 @@ func (g *GameManager) HostEnterMpWorld(hostPlayer *model.Player, otherUid uint32
hostPlayer,
hostPlayer,
proto.EnterType_ENTER_GOTO,
uint32(constant.EnterReasonConst.HostFromSingleToMp),
uint32(constant.EnterReasonHostFromSingleToMp),
hostPlayer.SceneId,
hostPlayer.Pos,
0,
@@ -368,7 +368,7 @@ func (g *GameManager) UserLeaveWorld(player *model.Player) bool {
return false
}
}
g.ReconnectPlayer(player.PlayerID)
g.ReLoginPlayer(player.PlayerID)
return true
}
@@ -458,8 +458,8 @@ func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *mod
onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: subWorldPlayer.PlayerID,
Nickname: subWorldPlayer.NickName,
PlayerLevel: subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
PlayerLevel: subWorldPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(subWorldPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_MP_SETTING_TYPE]),
NameCardId: subWorldPlayer.NameCard,
Signature: subWorldPlayer.Signature,
ProfilePicture: &proto.ProfilePicture{AvatarId: subWorldPlayer.HeadImage},
@@ -483,8 +483,8 @@ func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *mod
onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: worldPlayer.PlayerID,
Nickname: worldPlayer.NickName,
PlayerLevel: worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
PlayerLevel: worldPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_MP_SETTING_TYPE]),
NameCardId: worldPlayer.NameCard,
Signature: worldPlayer.Signature,
ProfilePicture: &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage},
@@ -565,7 +565,7 @@ func (g *GameManager) ServerUserMpReq(userMpInfo *mq.UserMpInfo, gsAppId string)
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_NOT_IN_PLAYER_WORLD)
return
}
mpSetting := hostPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]
mpSetting := hostPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_MP_SETTING_TYPE]
if mpSetting == 0 {
// 房主玩家没开权限
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_SCENE_CANNOT_ENTER)

View File

@@ -58,8 +58,8 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: worldPlayer.PlayerID,
Nickname: worldPlayer.NickName,
PlayerLevel: worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
PlayerLevel: worldPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_MP_SETTING_TYPE]),
NameCardId: worldPlayer.NameCard,
Signature: worldPlayer.Signature,
ProfilePicture: &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage},
@@ -99,7 +99,7 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
},
}
for _, info := range playerWorldSceneInfoListNotify.InfoList {
for _, sceneTagDataConfig := range gdconf.CONF.SceneTagDataMap {
for _, sceneTagDataConfig := range gdconf.GetSceneTagDataMap() {
if uint32(sceneTagDataConfig.SceneId) == info.SceneId {
info.SceneTagIdList = append(info.SceneTagIdList, uint32(sceneTagDataConfig.SceneTagId))
}
@@ -167,7 +167,7 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
sceneAreaWeatherNotify := &proto.SceneAreaWeatherNotify{
WeatherAreaId: 0,
ClimateType: uint32(constant.ClimateTypeConst.CLIMATE_SUNNY),
ClimateType: uint32(constant.CLIMATE_TYPE_SUNNY),
}
g.SendMsg(cmd.SceneAreaWeatherNotify, player.PlayerID, player.ClientSeq, sceneAreaWeatherNotify)
}
@@ -179,8 +179,8 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: worldPlayer.PlayerID,
Nickname: worldPlayer.NickName,
PlayerLevel: worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
PlayerLevel: worldPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_MP_SETTING_TYPE]),
NameCardId: worldPlayer.NameCard,
Signature: worldPlayer.Signature,
ProfilePicture: &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage},
@@ -284,7 +284,7 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
sceneAreaWeatherNotify := &proto.SceneAreaWeatherNotify{
WeatherAreaId: 0,
ClimateType: uint32(constant.ClimateTypeConst.CLIMATE_SUNNY),
ClimateType: uint32(constant.CLIMATE_TYPE_SUNNY),
}
g.SendMsg(cmd.SceneAreaWeatherNotify, player.PlayerID, player.ClientSeq, sceneAreaWeatherNotify)
@@ -380,8 +380,8 @@ func (g *GameManager) CreateConfigEntity(scene *Scene, objectId int64, entityCon
gadget := entityConfig.(*gdconf.Gadget)
// 70500000并不是实际的装置id 根据节点类型对应采集物配置表
if gadget.PointType != 0 && gadget.GadgetId == 70500000 {
gatherDataConfig, exist := gdconf.CONF.GatherDataPointTypeMap[gadget.PointType]
if !exist {
gatherDataConfig := gdconf.GetGatherDataByPointType(gadget.PointType)
if gatherDataConfig == nil {
return 0
}
return scene.CreateEntityGadgetGather(&model.Vector{
@@ -420,8 +420,8 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, en
Type: enterType,
TargetUid: player.PlayerID,
EnterSceneToken: player.EnterSceneToken,
WorldLevel: player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
EnterReason: uint32(constant.EnterReasonConst.Login),
WorldLevel: player.PropertiesMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL],
EnterReason: uint32(constant.EnterReasonLogin),
IsFirstLoginEnterScene: true,
WorldType: 1,
SceneTagIdList: make([]uint32, 0),
@@ -430,7 +430,7 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, en
strconv.Itoa(int(player.PlayerID)) + "-" +
strconv.Itoa(int(time.Now().Unix())) + "-" +
"296359"
for _, sceneTagDataConfig := range gdconf.CONF.SceneTagDataMap {
for _, sceneTagDataConfig := range gdconf.GetSceneTagDataMap() {
if uint32(sceneTagDataConfig.SceneId) == player.SceneId {
playerEnterSceneNotify.SceneTagIdList = append(playerEnterSceneNotify.SceneTagIdList, uint32(sceneTagDataConfig.SceneTagId))
}
@@ -470,7 +470,7 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyMp(
Type: enterType,
TargetUid: targetPlayer.PlayerID,
EnterSceneToken: player.EnterSceneToken,
WorldLevel: targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
WorldLevel: targetPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL],
EnterReason: enterReason,
WorldType: 1,
DungeonId: dungeonId,
@@ -480,7 +480,7 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyMp(
strconv.Itoa(int(targetPlayer.PlayerID)) + "-" +
strconv.Itoa(int(time.Now().Unix())) + "-" +
"296359"
for _, sceneTagDataConfig := range gdconf.CONF.SceneTagDataMap {
for _, sceneTagDataConfig := range gdconf.GetSceneTagDataMap() {
if uint32(sceneTagDataConfig.SceneId) == player.SceneId {
playerEnterSceneNotify.SceneTagIdList = append(playerEnterSceneNotify.SceneTagIdList, uint32(sceneTagDataConfig.SceneTagId))
}
@@ -591,56 +591,28 @@ func (g *GameManager) AddSceneEntityNotify(player *model.Player, visionType prot
func (g *GameManager) EntityFightPropUpdateNotifyBroadcast(scene *Scene, entity *Entity, fightPropId uint32) {
for _, player := range scene.GetAllPlayer() {
// PacketEntityFightPropUpdateNotify
g.SendMsg(cmd.EntityFightPropUpdateNotify, player.PlayerID, player.ClientSeq, &proto.EntityFightPropUpdateNotify{
FightPropMap: entity.GetFightProp(),
fightProp := entity.GetFightProp()
ntf := &proto.EntityFightPropUpdateNotify{
FightPropMap: make(map[uint32]float32),
EntityId: entity.GetId(),
})
}
ntf.FightPropMap[fightPropId] = fightProp[fightPropId]
g.SendMsg(cmd.EntityFightPropUpdateNotify, player.PlayerID, player.ClientSeq, ntf)
}
}
func (g *GameManager) PacketFightPropMapToPbFightPropList(fightPropMap map[uint32]float32) []*proto.FightPropPair {
fightPropList := []*proto.FightPropPair{
{
PropType: uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP),
PropValue: fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP)],
},
{
PropType: uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_ATTACK),
PropValue: fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_ATTACK)],
},
{
PropType: uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_DEFENSE),
PropValue: fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_DEFENSE)],
},
{
PropType: uint32(constant.FightPropertyConst.FIGHT_PROP_CRITICAL),
PropValue: fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CRITICAL)],
},
{
PropType: uint32(constant.FightPropertyConst.FIGHT_PROP_CRITICAL_HURT),
PropValue: fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CRITICAL_HURT)],
},
{
PropType: uint32(constant.FightPropertyConst.FIGHT_PROP_CHARGE_EFFICIENCY),
PropValue: fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CHARGE_EFFICIENCY)],
},
{
PropType: uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP),
PropValue: fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)],
},
{
PropType: uint32(constant.FightPropertyConst.FIGHT_PROP_MAX_HP),
PropValue: fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_MAX_HP)],
},
{
PropType: uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_ATTACK),
PropValue: fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_ATTACK)],
},
{
PropType: uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_DEFENSE),
PropValue: fightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_DEFENSE)],
},
{PropType: uint32(constant.FIGHT_PROP_BASE_HP), PropValue: fightPropMap[uint32(constant.FIGHT_PROP_BASE_HP)]},
{PropType: uint32(constant.FIGHT_PROP_BASE_ATTACK), PropValue: fightPropMap[uint32(constant.FIGHT_PROP_BASE_ATTACK)]},
{PropType: uint32(constant.FIGHT_PROP_BASE_DEFENSE), PropValue: fightPropMap[uint32(constant.FIGHT_PROP_BASE_DEFENSE)]},
{PropType: uint32(constant.FIGHT_PROP_CRITICAL), PropValue: fightPropMap[uint32(constant.FIGHT_PROP_CRITICAL)]},
{PropType: uint32(constant.FIGHT_PROP_CRITICAL_HURT), PropValue: fightPropMap[uint32(constant.FIGHT_PROP_CRITICAL_HURT)]},
{PropType: uint32(constant.FIGHT_PROP_CHARGE_EFFICIENCY), PropValue: fightPropMap[uint32(constant.FIGHT_PROP_CHARGE_EFFICIENCY)]},
{PropType: uint32(constant.FIGHT_PROP_CUR_HP), PropValue: fightPropMap[uint32(constant.FIGHT_PROP_CUR_HP)]},
{PropType: uint32(constant.FIGHT_PROP_MAX_HP), PropValue: fightPropMap[uint32(constant.FIGHT_PROP_MAX_HP)]},
{PropType: uint32(constant.FIGHT_PROP_CUR_ATTACK), PropValue: fightPropMap[uint32(constant.FIGHT_PROP_CUR_ATTACK)]},
{PropType: uint32(constant.FIGHT_PROP_CUR_DEFENSE), PropValue: fightPropMap[uint32(constant.FIGHT_PROP_CUR_DEFENSE)]},
}
return fightPropList
}
@@ -676,37 +648,37 @@ func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Pl
},
PropList: []*proto.PropPair{
{
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
Type: uint32(constant.PLAYER_PROP_LEVEL),
PropValue: &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
Type: uint32(constant.PLAYER_PROP_LEVEL),
Value: &proto.PropValue_Ival{Ival: int64(avatar.Level)},
Val: int64(avatar.Level)},
},
{
Type: uint32(constant.PlayerPropertyConst.PROP_EXP),
Type: uint32(constant.PLAYER_PROP_EXP),
PropValue: &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_EXP),
Type: uint32(constant.PLAYER_PROP_EXP),
Value: &proto.PropValue_Ival{Ival: int64(avatar.Exp)},
Val: int64(avatar.Exp)},
},
{
Type: uint32(constant.PlayerPropertyConst.PROP_BREAK_LEVEL),
Type: uint32(constant.PLAYER_PROP_BREAK_LEVEL),
PropValue: &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_BREAK_LEVEL),
Type: uint32(constant.PLAYER_PROP_BREAK_LEVEL),
Value: &proto.PropValue_Ival{Ival: int64(avatar.Promote)},
Val: int64(avatar.Promote)},
},
{
Type: uint32(constant.PlayerPropertyConst.PROP_SATIATION_VAL),
Type: uint32(constant.PLAYER_PROP_SATIATION_VAL),
PropValue: &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_SATIATION_VAL),
Type: uint32(constant.PLAYER_PROP_SATIATION_VAL),
Value: &proto.PropValue_Ival{Ival: int64(avatar.Satiation)},
Val: int64(avatar.Satiation)},
},
{
Type: uint32(constant.PlayerPropertyConst.PROP_SATIATION_PENALTY_TIME),
Type: uint32(constant.PLAYER_PROP_SATIATION_PENALTY_TIME),
PropValue: &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_SATIATION_PENALTY_TIME),
Type: uint32(constant.PLAYER_PROP_SATIATION_PENALTY_TIME),
Value: &proto.PropValue_Ival{Ival: int64(avatar.SatiationPenalty)},
Val: int64(avatar.SatiationPenalty)},
},
@@ -763,8 +735,8 @@ func (g *GameManager) PacketSceneEntityInfoMonster(scene *Scene, entityId uint32
Speed: &proto.Vector{},
State: proto.MotionState(entity.GetMoveState()),
},
PropList: []*proto.PropPair{{Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), PropValue: &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
PropList: []*proto.PropPair{{Type: uint32(constant.PLAYER_PROP_LEVEL), PropValue: &proto.PropValue{
Type: uint32(constant.PLAYER_PROP_LEVEL),
Value: &proto.PropValue_Ival{Ival: int64(entity.GetLevel())},
Val: int64(entity.GetLevel()),
}}},
@@ -811,8 +783,8 @@ func (g *GameManager) PacketSceneEntityInfoNpc(scene *Scene, entityId uint32) *p
Speed: &proto.Vector{},
State: proto.MotionState(entity.GetMoveState()),
},
PropList: []*proto.PropPair{{Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), PropValue: &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
PropList: []*proto.PropPair{{Type: uint32(constant.PLAYER_PROP_LEVEL), PropValue: &proto.PropValue{
Type: uint32(constant.PLAYER_PROP_LEVEL),
Value: &proto.PropValue_Ival{Ival: int64(entity.GetLevel())},
Val: int64(entity.GetLevel()),
}}},
@@ -859,8 +831,8 @@ func (g *GameManager) PacketSceneEntityInfoGadget(scene *Scene, entityId uint32)
Speed: &proto.Vector{},
State: proto.MotionState(entity.GetMoveState()),
},
PropList: []*proto.PropPair{{Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL), PropValue: &proto.PropValue{
Type: uint32(constant.PlayerPropertyConst.PROP_LEVEL),
PropList: []*proto.PropPair{{Type: uint32(constant.PLAYER_PROP_LEVEL), PropValue: &proto.PropValue{
Type: uint32(constant.PLAYER_PROP_LEVEL),
Value: &proto.PropValue_Ival{Ival: int64(1)},
Val: int64(1),
}}},
@@ -917,7 +889,7 @@ func (g *GameManager) PacketSceneAvatarInfo(scene *Scene, player *model.Player,
SkillDepotId: player.AvatarMap[avatarId].SkillDepotId,
Weapon: &proto.SceneWeaponInfo{
EntityId: scene.GetWorld().GetPlayerWorldAvatarWeaponEntityId(player, avatarId),
GadgetId: uint32(gdconf.CONF.ItemDataMap[int32(weapon.ItemId)].GadgetId),
GadgetId: uint32(gdconf.GetItemDataById(int32(weapon.ItemId)).GadgetId),
ItemId: weapon.ItemId,
Guid: weapon.Guid,
Level: uint32(weapon.Level),
@@ -974,8 +946,8 @@ func (g *GameManager) PacketSceneGadgetInfoNormal(entity *Entity) *proto.SceneGa
func (g *GameManager) PacketSceneGadgetInfoGather(entity *Entity) *proto.SceneGadgetInfo {
gadgetEntity := entity.GetGadgetEntity()
gatherEntity := gadgetEntity.GetGadgetGatherEntity()
gather, ok := gdconf.CONF.GatherDataMap[int32(gatherEntity.GetGatherId())]
if !ok {
gatherDataConfig := gdconf.GetGatherDataById(int32(gatherEntity.GetGatherId()))
if gatherDataConfig == nil {
logger.Error("gather data error, gatherId: %v", gatherEntity.GetGatherId())
return new(proto.SceneGadgetInfo)
}
@@ -988,7 +960,7 @@ func (g *GameManager) PacketSceneGadgetInfoGather(entity *Entity) *proto.SceneGa
AuthorityPeerId: 1,
Content: &proto.SceneGadgetInfo_GatherGadget{
GatherGadget: &proto.GatherGadgetInfo{
ItemId: uint32(gather.ItemId),
ItemId: uint32(gatherDataConfig.ItemId),
IsForbidGuest: false,
},
},
@@ -1041,21 +1013,21 @@ func (g *GameManager) PacketDelTeamEntityNotify(scene *Scene, player *model.Play
func (g *GameManager) GetTempFightPropMap() map[uint32]float32 {
fpm := map[uint32]float32{
uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP): float32(72.91699),
uint32(constant.FightPropertyConst.FIGHT_PROP_PHYSICAL_SUB_HURT): float32(0.1),
uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_DEFENSE): float32(505.0),
uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_ATTACK): float32(45.679916),
uint32(constant.FightPropertyConst.FIGHT_PROP_ICE_SUB_HURT): float32(0.1),
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_ATTACK): float32(45.679916),
uint32(constant.FightPropertyConst.FIGHT_PROP_MAX_HP): float32(72.91699),
uint32(constant.FightPropertyConst.FIGHT_PROP_FIRE_SUB_HURT): float32(0.1),
uint32(constant.FightPropertyConst.FIGHT_PROP_ELEC_SUB_HURT): float32(0.1),
uint32(constant.FightPropertyConst.FIGHT_PROP_WIND_SUB_HURT): float32(0.1),
uint32(constant.FightPropertyConst.FIGHT_PROP_ROCK_SUB_HURT): float32(0.1),
uint32(constant.FightPropertyConst.FIGHT_PROP_GRASS_SUB_HURT): float32(0.1),
uint32(constant.FightPropertyConst.FIGHT_PROP_WATER_SUB_HURT): float32(0.1),
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(72.91699),
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_DEFENSE): float32(505.0),
uint32(constant.FIGHT_PROP_CUR_HP): float32(72.91699),
uint32(constant.FIGHT_PROP_PHYSICAL_SUB_HURT): float32(0.1),
uint32(constant.FIGHT_PROP_CUR_DEFENSE): float32(505.0),
uint32(constant.FIGHT_PROP_CUR_ATTACK): float32(45.679916),
uint32(constant.FIGHT_PROP_ICE_SUB_HURT): float32(0.1),
uint32(constant.FIGHT_PROP_BASE_ATTACK): float32(45.679916),
uint32(constant.FIGHT_PROP_MAX_HP): float32(72.91699),
uint32(constant.FIGHT_PROP_FIRE_SUB_HURT): float32(0.1),
uint32(constant.FIGHT_PROP_ELEC_SUB_HURT): float32(0.1),
uint32(constant.FIGHT_PROP_WIND_SUB_HURT): float32(0.1),
uint32(constant.FIGHT_PROP_ROCK_SUB_HURT): float32(0.1),
uint32(constant.FIGHT_PROP_GRASS_SUB_HURT): float32(0.1),
uint32(constant.FIGHT_PROP_WATER_SUB_HURT): float32(0.1),
uint32(constant.FIGHT_PROP_BASE_HP): float32(72.91699),
uint32(constant.FIGHT_PROP_BASE_DEFENSE): float32(505.0),
}
return fpm
}

View File

@@ -91,7 +91,7 @@ func (g *GameManager) BuyGoodsReq(player *model.Player, payloadMsg pb.Message) {
g.AddUserItem(player.PlayerID, []*UserItem{{
ItemId: buyItemId,
ChangeCount: buyItemCount,
}}, true, constant.ActionReasonConst.Shop)
}}, true, constant.ActionReasonShop)
req.Goods.BoughtNum = player.GetItemCount(buyItemId)
buyGoodsRsp := &proto.BuyGoodsRsp{

View File

@@ -32,9 +32,9 @@ func (g *GameManager) GetPlayerSocialDetailReq(player *model.Player, payloadMsg
ProfilePicture: &proto.ProfilePicture{AvatarId: targetPlayer.HeadImage},
Nickname: targetPlayer.NickName,
Signature: targetPlayer.Signature,
Level: targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
Level: targetPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL],
Birthday: &proto.Birthday{Month: uint32(targetPlayer.Birthday[0]), Day: uint32(targetPlayer.Birthday[1])},
WorldLevel: targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
WorldLevel: targetPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL],
NameCardId: targetPlayer.NameCard,
IsShowAvatar: false,
FinishAchievementNum: 0,
@@ -174,9 +174,9 @@ func (g *GameManager) GetPlayerFriendListReq(player *model.Player, payloadMsg pb
friendBrief := &proto.FriendBrief{
Uid: friendPlayer.PlayerID,
Nickname: friendPlayer.NickName,
Level: friendPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
Level: friendPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL],
ProfilePicture: &proto.ProfilePicture{AvatarId: friendPlayer.HeadImage},
WorldLevel: friendPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
WorldLevel: friendPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL],
Signature: friendPlayer.Signature,
OnlineState: onlineState,
IsMpModeAvailable: true,
@@ -212,9 +212,9 @@ func (g *GameManager) GetPlayerAskFriendListReq(player *model.Player, payloadMsg
friendBrief := &proto.FriendBrief{
Uid: friendPlayer.PlayerID,
Nickname: friendPlayer.NickName,
Level: friendPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
Level: friendPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL],
ProfilePicture: &proto.ProfilePicture{AvatarId: friendPlayer.HeadImage},
WorldLevel: friendPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
WorldLevel: friendPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL],
Signature: friendPlayer.Signature,
OnlineState: onlineState,
IsMpModeAvailable: true,
@@ -258,11 +258,11 @@ func (g *GameManager) AskAddFriendReq(player *model.Player, payloadMsg pb.Messag
ApplyPlayerOnlineInfo: &mq.UserBaseInfo{
UserId: player.PlayerID,
Nickname: player.NickName,
PlayerLevel: player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
PlayerLevel: player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL],
NameCardId: player.NameCard,
Signature: player.Signature,
HeadImageId: player.HeadImage,
WorldLevel: player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
WorldLevel: player.PropertiesMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL],
},
},
},
@@ -301,9 +301,9 @@ func (g *GameManager) AskAddFriendReq(player *model.Player, payloadMsg pb.Messag
askAddFriendNotify.TargetFriendBrief = &proto.FriendBrief{
Uid: player.PlayerID,
Nickname: player.NickName,
Level: player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
Level: player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL],
ProfilePicture: &proto.ProfilePicture{AvatarId: player.HeadImage},
WorldLevel: player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
WorldLevel: player.PropertiesMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL],
Signature: player.Signature,
OnlineState: proto.FriendOnlineState_FRIEND_ONLINE,
IsMpModeAvailable: true,
@@ -460,8 +460,8 @@ func (g *GameManager) PacketOnlinePlayerInfo(player *model.Player) *proto.Online
onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: player.PlayerID,
Nickname: player.NickName,
PlayerLevel: player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
PlayerLevel: player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(player.PropertiesMap[constant.PLAYER_PROP_PLAYER_MP_SETTING_TYPE]),
NameCardId: player.NameCard,
Signature: player.Signature,
ProfilePicture: &proto.ProfilePicture{AvatarId: player.HeadImage},

View File

@@ -63,7 +63,7 @@ func (g *GameManager) HandleAbilityStamina(player *model.Player, entry *proto.Ab
}
// 根据ability name查找到对应的技能表里的技能配置
var avatarAbility *gdconf.AvatarSkillData = nil
for _, avatarSkillData := range gdconf.CONF.AvatarSkillDataMap {
for _, avatarSkillData := range gdconf.GetAvatarSkillDataMap() {
hashCode := endec.Hk4eAbilityHashCode(avatarSkillData.AbilityName)
if uint32(hashCode) == abilityNameHashCode {
avatarAbility = avatarSkillData
@@ -121,11 +121,11 @@ func (g *GameManager) SceneAvatarStaminaStepReq(player *model.Player, payloadMsg
// 倒三角 非常消耗体力
costRevise = -(angleRevise * 2) + 10
}
logger.Debug("stamina climbing, rotX: %v, costRevise: %v, cost: %v", req.Rot.X, costRevise, constant.StaminaCostConst.CLIMBING_BASE-costRevise)
g.UpdatePlayerStamina(player, constant.StaminaCostConst.CLIMBING_BASE-costRevise)
logger.Debug("stamina climbing, rotX: %v, costRevise: %v, cost: %v", req.Rot.X, costRevise, constant.STAMINA_COST_CLIMBING_BASE-costRevise)
g.UpdatePlayerStamina(player, constant.STAMINA_COST_CLIMBING_BASE-costRevise)
case proto.MotionState_MOTION_SWIM_MOVE:
// 缓慢游泳
g.UpdatePlayerStamina(player, constant.StaminaCostConst.SWIMMING)
g.UpdatePlayerStamina(player, constant.STAMINA_COST_SWIMMING)
}
// PacketSceneAvatarStaminaStepRsp
@@ -159,16 +159,16 @@ func (g *GameManager) ImmediateStamina(player *model.Player, motionState proto.M
switch motionState {
case proto.MotionState_MOTION_CLIMB:
// 攀爬开始
g.UpdatePlayerStamina(player, constant.StaminaCostConst.CLIMB_START)
g.UpdatePlayerStamina(player, constant.STAMINA_COST_CLIMB_START)
case proto.MotionState_MOTION_DASH_BEFORE_SHAKE:
// 冲刺
g.UpdatePlayerStamina(player, constant.StaminaCostConst.SPRINT)
g.UpdatePlayerStamina(player, constant.STAMINA_COST_SPRINT)
case proto.MotionState_MOTION_CLIMB_JUMP:
// 攀爬跳跃
g.UpdatePlayerStamina(player, constant.StaminaCostConst.CLIMB_JUMP)
g.UpdatePlayerStamina(player, constant.STAMINA_COST_CLIMB_JUMP)
case proto.MotionState_MOTION_SWIM_DASH:
// 快速游泳开始
g.UpdatePlayerStamina(player, constant.StaminaCostConst.SWIM_DASH_START)
g.UpdatePlayerStamina(player, constant.STAMINA_COST_SWIM_DASH_START)
}
}
@@ -178,8 +178,8 @@ func (g *GameManager) SkillSustainStamina(player *model.Player, isSwim bool) {
skillId := staminaInfo.LastSkillId
// 读取技能配置表
avatarSkillConfig, ok := gdconf.CONF.AvatarSkillDataMap[int32(skillId)]
if !ok {
avatarSkillConfig := gdconf.GetAvatarSkillDataById(int32(skillId))
if avatarSkillConfig == nil {
logger.Error("avatarSkillConfig error, skillId: %v", skillId)
return
}
@@ -191,8 +191,8 @@ func (g *GameManager) SkillSustainStamina(player *model.Player, isSwim bool) {
return
}
// 获取现行角色的配置表
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(worldAvatar.GetAvatarId())]
if !ok {
avatarDataConfig := gdconf.GetAvatarDataById(int32(worldAvatar.GetAvatarId()))
if avatarDataConfig == nil {
logger.Error("avatarDataConfig error, avatarId: %v", worldAvatar.GetAvatarId())
return
}
@@ -203,8 +203,8 @@ func (g *GameManager) SkillSustainStamina(player *model.Player, isSwim bool) {
// 如果为0代表使用默认值
if avatarSkillConfig.CostStamina == 0 {
// 大剑持续耐力消耗默认值
if avatarDataConfig.WeaponType == constant.WeaponTypeConst.WEAPON_CLAYMORE {
costStamina = constant.StaminaCostConst.FIGHT_CLAYMORE_PER
if avatarDataConfig.WeaponType == constant.WEAPON_TYPE_CLAYMORE {
costStamina = constant.STAMINA_COST_FIGHT_CLAYMORE_PER
}
} else {
costStamina = -(avatarSkillConfig.CostStamina * 100)
@@ -230,8 +230,8 @@ func (g *GameManager) ChargedAttackStamina(player *model.Player, worldAvatar *Wo
return
}
// 获取现行角色的配置表
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(worldAvatar.GetAvatarId())]
if !ok {
avatarDataConfig := gdconf.GetAvatarDataById(int32(worldAvatar.GetAvatarId()))
if avatarDataConfig == nil {
logger.Error("avatarDataConfig error, avatarId: %v", worldAvatar.GetAvatarId())
return
}
@@ -244,15 +244,15 @@ func (g *GameManager) ChargedAttackStamina(player *model.Player, worldAvatar *Wo
// 使用武器对应默认耐力消耗
// 双手剑为持续耐力消耗不在这里处理
switch avatarDataConfig.WeaponType {
case constant.WeaponTypeConst.WEAPON_SWORD_ONE_HAND:
case constant.WEAPON_TYPE_SWORD_ONE_HAND:
// 单手剑
costStamina = constant.StaminaCostConst.FIGHT_SWORD_ONE_HAND
case constant.WeaponTypeConst.WEAPON_POLE:
costStamina = constant.STAMINA_COST_FIGHT_SWORD_ONE_HAND
case constant.WEAPON_TYPE_POLE:
// 长枪
costStamina = constant.StaminaCostConst.FIGHT_POLE
case constant.WeaponTypeConst.WEAPON_CATALYST:
costStamina = constant.STAMINA_COST_FIGHT_POLE
case constant.WEAPON_TYPE_CATALYST:
// 法器
costStamina = constant.StaminaCostConst.FIGHT_CATALYST
costStamina = constant.STAMINA_COST_FIGHT_CATALYST
}
} else {
costStamina = -(skillData.CostStamina * 100)
@@ -268,17 +268,17 @@ func (g *GameManager) SkillStartStamina(player *model.Player, casterId uint32, s
staminaInfo := player.StaminaInfo
// 获取该技能开始时所需消耗的耐力
costStamina, ok := constant.StaminaCostConst.SKILL_START[skillId]
avatarSkillDataConfig := gdconf.GetAvatarSkillDataById(int32(skillId))
// 配置表确保存在技能开始对应的耐力消耗
if ok {
if avatarSkillDataConfig != nil {
// 距离上次处理技能开始耐力消耗过去的时间
pastTime := time.Now().UnixMilli() - staminaInfo.LastSkillStartTime
// 上次触发的技能相同则每400ms触发一次消耗
if staminaInfo.LastSkillId != skillId || pastTime > 400 {
logger.Debug("skill start stamina, skillId: %v, cost: %v", skillId, costStamina)
logger.Debug("skill start stamina, skillId: %v, cost: %v", skillId, avatarSkillDataConfig.CostStamina)
// 根据配置消耗耐力
g.UpdatePlayerStamina(player, costStamina)
g.UpdatePlayerStamina(player, avatarSkillDataConfig.CostStamina)
staminaInfo.LastSkillStartTime = time.Now().UnixMilli()
}
} else {
@@ -314,10 +314,10 @@ func (g *GameManager) VehicleRestoreStaminaHandler(player *model.Player) {
// 判断玩家处于载具中
if g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
// 角色回复耐力
g.UpdatePlayerStamina(player, constant.StaminaCostConst.IN_SKIFF)
g.UpdatePlayerStamina(player, constant.STAMINA_COST_IN_SKIFF)
} else {
// 载具回复耐力
g.UpdateVehicleStamina(player, entity, constant.StaminaCostConst.SKIFF_NOBODY)
g.UpdateVehicleStamina(player, entity, constant.STAMINA_COST_SKIFF_NOBODY)
}
}
@@ -422,9 +422,9 @@ func (g *GameManager) UpdatePlayerStamina(player *model.Player, staminaCost int3
}
// 最大耐力值
maxStamina := int32(player.PropertiesMap[constant.PlayerPropertyConst.PROP_MAX_STAMINA])
maxStamina := int32(player.PropertiesMap[constant.PLAYER_PROP_MAX_STAMINA])
// 现行耐力值
curStamina := int32(player.PropertiesMap[constant.PlayerPropertyConst.PROP_CUR_PERSIST_STAMINA])
curStamina := int32(player.PropertiesMap[constant.PLAYER_PROP_CUR_PERSIST_STAMINA])
// 将被变更的耐力
stamina := g.GetChangeStamina(curStamina, maxStamina, staminaCost)
@@ -471,12 +471,12 @@ func (g *GameManager) DrownBackHandler(player *model.Player) {
// 先传送玩家再设置角色存活否则同时设置会传送前显示角色实体
if player.StaminaInfo.DrownBackDelay > 20 && player.SceneLoadState == model.SceneEnterDone {
// 设置角色存活
scene.SetEntityLifeState(avatarEntity, constant.LifeStateConst.LIFE_REVIVE, proto.PlayerDieType_PLAYER_DIE_NONE)
scene.SetEntityLifeState(avatarEntity, constant.LIFE_STATE_REVIVE, proto.PlayerDieType_PLAYER_DIE_NONE)
// 重置溺水返回时间
player.StaminaInfo.DrownBackDelay = 0
} else if player.StaminaInfo.DrownBackDelay == 20 {
// TODO 队伍扣血
maxStamina := player.PropertiesMap[constant.PlayerPropertyConst.PROP_MAX_STAMINA]
maxStamina := player.PropertiesMap[constant.PLAYER_PROP_MAX_STAMINA]
// 设置玩家耐力为一半
g.SetPlayerStamina(player, maxStamina/2)
// 如果玩家的位置比锚点距离近则优先使用玩家位置
@@ -502,7 +502,7 @@ func (g *GameManager) DrownBackHandler(player *model.Player) {
// }
// }
// 传送玩家至安全位置
g.TeleportPlayer(player, constant.EnterReasonConst.Revival, player.SceneId, pos, new(model.Vector), 0)
g.TeleportPlayer(player, constant.EnterReasonRevival, player.SceneId, pos, new(model.Vector), 0)
}
// 防止重置后又被修改
if player.StaminaInfo.DrownBackDelay != 0 {
@@ -530,7 +530,7 @@ func (g *GameManager) HandleDrown(player *model.Player, stamina uint32) {
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)
// 设置角色为死亡
scene.SetEntityLifeState(avatarEntity, constant.LifeStateConst.LIFE_DEAD, proto.PlayerDieType_PLAYER_DIE_DRAWN)
scene.SetEntityLifeState(avatarEntity, constant.LIFE_STATE_DEAD, proto.PlayerDieType_PLAYER_DIE_DRAWN)
// 溺水返回安全点 计时开始
player.StaminaInfo.DrownBackDelay = 1
}
@@ -553,7 +553,7 @@ func (g *GameManager) SetVehicleStamina(player *model.Player, vehicleEntity *Ent
// SetPlayerStamina 设置玩家耐力
func (g *GameManager) SetPlayerStamina(player *model.Player, stamina uint32) {
// 设置玩家的耐力
prop := constant.PlayerPropertyConst.PROP_CUR_PERSIST_STAMINA
prop := constant.PLAYER_PROP_CUR_PERSIST_STAMINA
player.PropertiesMap[prop] = stamina
// logger.Debug("player stamina set, stamina: %v", stamina)

View File

@@ -244,28 +244,28 @@ func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeam
sceneTeamAvatar.SceneAvatarInfo = g.PacketSceneAvatarInfo(worldPlayerScene, worldPlayer, worldAvatar.GetAvatarId())
}
// add AbilityControlBlock
avatarDataConfig := gdconf.CONF.AvatarDataMap[int32(worldAvatar.GetAvatarId())]
acb := sceneTeamAvatar.AbilityControlBlock
embryoId := 0
// add avatar abilities
avatarDataConfig := gdconf.GetAvatarDataById(int32(worldAvatar.GetAvatarId()))
if avatarDataConfig != nil {
for _, abilityId := range avatarDataConfig.AbilityHashCodeList {
embryoId++
emb := &proto.AbilityEmbryo{
AbilityId: uint32(embryoId),
AbilityNameHash: uint32(abilityId),
AbilityOverrideNameHash: uint32(constant.GameConstantConst.DEFAULT_ABILITY_NAME),
AbilityOverrideNameHash: uint32(constant.DEFAULT_ABILITY_NAME),
}
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, emb)
}
}
// add default abilities
for _, abilityId := range constant.GameConstantConst.DEFAULT_ABILITY_HASHES {
for _, abilityId := range constant.DEFAULT_ABILITY_HASHES {
embryoId++
emb := &proto.AbilityEmbryo{
AbilityId: uint32(embryoId),
AbilityNameHash: uint32(abilityId),
AbilityOverrideNameHash: uint32(constant.GameConstantConst.DEFAULT_ABILITY_NAME),
AbilityOverrideNameHash: uint32(constant.DEFAULT_ABILITY_NAME),
}
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, emb)
}
@@ -280,14 +280,14 @@ func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeam
// acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, emb)
// }
// add skill depot abilities
skillDepot := gdconf.CONF.AvatarSkillDepotDataMap[int32(worldPlayerAvatar.SkillDepotId)]
skillDepot := gdconf.GetAvatarSkillDepotDataById(int32(worldPlayerAvatar.SkillDepotId))
if skillDepot != nil && len(skillDepot.AbilityHashCodeList) != 0 {
for _, id := range skillDepot.AbilityHashCodeList {
embryoId++
emb := &proto.AbilityEmbryo{
AbilityId: uint32(embryoId),
AbilityNameHash: uint32(id),
AbilityOverrideNameHash: uint32(constant.GameConstantConst.DEFAULT_ABILITY_NAME),
AbilityOverrideNameHash: uint32(constant.DEFAULT_ABILITY_NAME),
}
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, emb)
}
@@ -298,7 +298,7 @@ func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeam
emb := &proto.AbilityEmbryo{
AbilityId: uint32(embryoId),
AbilityNameHash: uint32(endec.Hk4eAbilityHashCode(skill)),
AbilityOverrideNameHash: uint32(constant.GameConstantConst.DEFAULT_ABILITY_NAME),
AbilityOverrideNameHash: uint32(constant.DEFAULT_ABILITY_NAME),
}
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, emb)
}

View File

@@ -16,8 +16,8 @@ import (
func (g *GameManager) GetAllWeaponDataConfig() map[int32]*gdconf.ItemData {
allWeaponDataConfig := make(map[int32]*gdconf.ItemData)
for itemId, itemData := range gdconf.CONF.ItemDataMap {
if uint16(itemData.Type) != constant.ItemTypeConst.ITEM_WEAPON {
for itemId, itemData := range gdconf.GetItemDataMap() {
if uint16(itemData.Type) != constant.ITEM_TYPE_WEAPON {
continue
}
if (itemId >= 10000 && itemId <= 10008) ||
@@ -130,15 +130,15 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
return
}
// 获取武器物品配置表
weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
if !ok {
weaponConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
if weaponConfig == nil {
logger.Error("weapon config error, itemId: %v", weapon.ItemId)
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return
}
// 摩拉数量是否足够
if player.GetItemCount(constant.ItemConstantConst.SCOIN) < weaponConfig.AwakenCoinCostList[weapon.Refinement] {
logger.Error("item count not enough, itemId: %v", constant.ItemConstantConst.SCOIN)
if player.GetItemCount(constant.ITEM_ID_SCOIN) < weaponConfig.AwakenCoinCostList[weapon.Refinement] {
logger.Error("item count not enough, itemId: %v", constant.ITEM_ID_SCOIN)
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
return
}
@@ -151,15 +151,15 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
}
// 获取精炼材料物品配置表
// 精炼的材料可能是武器也可能是物品
itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(player.GetItemIdByItemAndWeaponGuid(req.ItemGuid))]
if !ok {
itemDataConfig := gdconf.GetItemDataById(int32(player.GetItemIdByItemAndWeaponGuid(req.ItemGuid)))
if itemDataConfig == nil {
logger.Error("item data config error, itemGuid: %v", req.ItemGuid)
g.SendError(cmd.WeaponAwakenRsp, player, &proto.WeaponAwakenRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
return
}
// 根据精炼材料的类型做不同操作
switch itemDataConfig.Type {
case int32(constant.ItemTypeConst.ITEM_WEAPON):
case int32(constant.ITEM_TYPE_WEAPON):
// 精炼材料为武器
// 是否拥有将被用于精炼的武器
foodWeapon, ok := player.WeaponMap[player.GetWeaponIdByGuid(req.ItemGuid)]
@@ -176,7 +176,7 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
}
// 消耗作为精炼材料的武器
g.CostUserWeapon(player.PlayerID, []uint64{foodWeapon.WeaponId})
case int32(constant.ItemTypeConst.ITEM_MATERIAL):
case int32(constant.ITEM_TYPE_MATERIAL):
// 精炼材料为道具
// 是否拥有将被用于精炼的道具
item, ok := player.ItemMap[player.GetItemIdByGuid(req.ItemGuid)]
@@ -206,7 +206,7 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
// 消耗摩拉
g.CostUserItem(player.PlayerID, []*UserItem{
{
ItemId: constant.ItemConstantConst.SCOIN,
ItemId: constant.ITEM_ID_SCOIN,
ChangeCount: weaponConfig.AwakenCoinCostList[weapon.Refinement],
},
})
@@ -256,22 +256,15 @@ func (g *GameManager) WeaponPromoteReq(player *model.Player, payloadMsg pb.Messa
return
}
// 获取武器配置表
weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
if !ok {
weaponConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
if weaponConfig == nil {
logger.Error("weapon config error, itemId: %v", weapon.ItemId)
g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{})
return
}
// 获取武器突破配置表
weaponPromoteDataMap, ok := gdconf.CONF.WeaponPromoteDataMap[weaponConfig.PromoteId]
if !ok {
logger.Error("weapon promote config error, promoteId: %v", weaponConfig.PromoteId)
g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{})
return
}
// 获取武器突破等级的配置表
weaponPromoteConfig, ok := weaponPromoteDataMap[int32(weapon.Promote)]
if !ok {
weaponPromoteConfig := gdconf.GetWeaponPromoteDataByIdAndLevel(weaponConfig.PromoteId, int32(weapon.Promote))
if weaponPromoteConfig == nil {
logger.Error("weapon promote config error, promoteLevel: %v", weapon.Promote)
g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{})
return
@@ -283,8 +276,8 @@ func (g *GameManager) WeaponPromoteReq(player *model.Player, payloadMsg pb.Messa
return
}
// 获取武器突破下一级的配置表
weaponPromoteConfig, ok = weaponPromoteDataMap[int32(weapon.Promote+1)]
if !ok {
weaponPromoteConfig = gdconf.GetWeaponPromoteDataByIdAndLevel(weaponConfig.PromoteId, int32(weapon.Promote+1))
if weaponPromoteConfig == nil {
logger.Error("weapon promote config error, next promoteLevel: %v", weapon.Promote+1)
g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_WEAPON_PROMOTE_LEVEL_EXCEED_LIMIT)
return
@@ -300,7 +293,7 @@ func (g *GameManager) WeaponPromoteReq(player *model.Player, payloadMsg pb.Messa
}
// 消耗列表添加摩拉的消耗
costItemList = append(costItemList, &UserItem{
ItemId: constant.ItemConstantConst.SCOIN,
ItemId: constant.ITEM_ID_SCOIN,
ChangeCount: uint32(weaponPromoteConfig.CostCoin),
})
// 突破材料以及摩拉是否足够
@@ -308,7 +301,7 @@ func (g *GameManager) WeaponPromoteReq(player *model.Player, payloadMsg pb.Messa
if player.GetItemCount(item.ItemId) < item.ChangeCount {
logger.Error("item count not enough, itemId: %v", item.ItemId)
// 摩拉的错误提示与材料不同
if item.ItemId == constant.ItemConstantConst.SCOIN {
if item.ItemId == constant.ITEM_ID_SCOIN {
g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
}
g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH)
@@ -316,8 +309,8 @@ func (g *GameManager) WeaponPromoteReq(player *model.Player, payloadMsg pb.Messa
}
}
// 冒险等级是否符合要求
if player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL] < uint32(weaponPromoteConfig.MinPlayerLevel) {
logger.Error("player level not enough, level: %v", player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL])
if player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL] < uint32(weaponPromoteConfig.MinPlayerLevel) {
logger.Error("player level not enough, level: %v", player.PropertiesMap[constant.PLAYER_PROP_PLAYER_LEVEL])
g.SendError(cmd.WeaponPromoteRsp, player, &proto.WeaponPromoteRsp{}, proto.Retcode_RET_PLAYER_LEVEL_LESS_THAN)
return
}
@@ -356,12 +349,12 @@ func (g *GameManager) GetWeaponUpgradeReturnMaterial(overflowExp uint32) (return
Exp uint32
}
// 武器强化返还材料的经验列表
materialExpList := make([]*materialExpData, 0, len(constant.ItemConstantConst.WEAPON_UPGRADE_MATERIAL))
for _, itemId := range constant.ItemConstantConst.WEAPON_UPGRADE_MATERIAL {
materialExpList := make([]*materialExpData, 0, len(constant.WEAPON_UPGRADE_MATERIAL))
for _, itemId := range constant.WEAPON_UPGRADE_MATERIAL {
// 获取物品配置表
itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(itemId)]
if !ok {
logger.Error("item data config error, itemId: %v", constant.ItemConstantConst.SCOIN)
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
if itemDataConfig == nil {
logger.Error("item data config error, itemId: %v", constant.ITEM_ID_SCOIN)
return
}
// 材料将给予的经验数
@@ -411,8 +404,8 @@ func (g *GameManager) CalcWeaponUpgradeExpAndCoin(player *model.Player, itemPara
return
}
// 获取武器配置表
weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(foodWeapon.ItemId)]
if !ok {
weaponConfig := gdconf.GetItemDataById(int32(foodWeapon.ItemId))
if weaponConfig == nil {
logger.Error("weapon config error, itemId: %v", foodWeapon.ItemId)
return
}
@@ -421,8 +414,8 @@ func (g *GameManager) CalcWeaponUpgradeExpAndCoin(player *model.Player, itemPara
// 计算从1级到武器当前等级所需消耗的经验
for i := int32(1); i < int32(foodWeapon.Level); i++ {
// 获取武器等级配置表
weaponLevelConfig, ok := gdconf.CONF.WeaponLevelDataMap[i]
if !ok {
weaponLevelConfig := gdconf.GetWeaponLevelDataByLevel(i)
if weaponLevelConfig == nil {
logger.Error("weapon level config error, level: %v", i)
return
}
@@ -445,9 +438,9 @@ func (g *GameManager) CalcWeaponUpgradeExpAndCoin(player *model.Player, itemPara
// 材料经验计算
for _, param := range itemParamList {
// 获取物品配置表
itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(param.ItemId)]
if !ok {
logger.Error("item data config error, itemId: %v", constant.ItemConstantConst.SCOIN)
itemDataConfig := gdconf.GetItemDataById(int32(param.ItemId))
if itemDataConfig == nil {
logger.Error("item data config error, itemId: %v", constant.ITEM_ID_SCOIN)
return
}
// 材料将给予的经验数
@@ -471,20 +464,14 @@ func (g *GameManager) CalcWeaponUpgradeExpAndCoin(player *model.Player, itemPara
// CalcWeaponUpgrade 计算使用材料给武器强化后的等级经验以及返回的矿石
func (g *GameManager) CalcWeaponUpgrade(weapon *model.Weapon, expCount uint32) (weaponLevel uint8, weaponExp uint32, returnItemList []*proto.ItemParam, success bool) {
// 获取武器配置表
weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
if !ok {
weaponConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
if weaponConfig == nil {
logger.Error("weapon config error, itemId: %v", weapon.ItemId)
return
}
// 获取武器突破配置表
weaponPromoteDataMap, ok := gdconf.CONF.WeaponPromoteDataMap[weaponConfig.PromoteId]
if !ok {
logger.Error("weapon promote config error, promoteId: %v", weaponConfig.PromoteId)
return
}
// 获取武器突破等级对应的配置表
weaponPromoteConfig, ok := weaponPromoteDataMap[int32(weapon.Promote)]
if !ok {
weaponPromoteConfig := gdconf.GetWeaponPromoteDataByIdAndLevel(weaponConfig.PromoteId, int32(weapon.Promote))
if weaponPromoteConfig == nil {
logger.Error("weapon promote config error, promoteLevel: %v", weapon.Promote)
return
}
@@ -493,8 +480,8 @@ func (g *GameManager) CalcWeaponUpgrade(weapon *model.Weapon, expCount uint32) (
weaponExp = weapon.Exp + expCount
for {
// 获取武器等级配置表
weaponLevelConfig, ok := gdconf.CONF.WeaponLevelDataMap[int32(weaponLevel)]
if !ok {
weaponLevelConfig := gdconf.GetWeaponLevelDataByLevel(int32(weaponLevel))
if weaponLevelConfig == nil {
// 获取不到代表已经到达最大等级
break
}
@@ -537,22 +524,15 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
return
}
// 获取武器配置表
weaponConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
if !ok {
weaponConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
if weaponConfig == nil {
logger.Error("weapon config error, itemId: %v", weapon.ItemId)
g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{})
return
}
// 获取武器突破配置表
weaponPromoteDataMap, ok := gdconf.CONF.WeaponPromoteDataMap[weaponConfig.PromoteId]
if !ok {
logger.Error("weapon promote config error, promoteId: %v", weaponConfig.PromoteId)
g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{})
return
}
// 获取武器突破等级对应的配置表
weaponPromoteConfig, ok := weaponPromoteDataMap[int32(weapon.Promote)]
if !ok {
weaponPromoteConfig := gdconf.GetWeaponPromoteDataByIdAndLevel(weaponConfig.PromoteId, int32(weapon.Promote))
if weaponPromoteConfig == nil {
logger.Error("weapon promote config error, promoteLevel: %v", weapon.Promote)
g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{})
return
@@ -581,7 +561,7 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
}
// 消耗列表添加摩拉的消耗
costItemList = append(costItemList, &UserItem{
ItemId: constant.ItemConstantConst.SCOIN,
ItemId: constant.ITEM_ID_SCOIN,
ChangeCount: coinCost,
})
// 校验物品是否足够
@@ -589,7 +569,7 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
if player.GetItemCount(item.ItemId) < item.ChangeCount {
logger.Error("item count not enough, itemId: %v", item.ItemId)
// 摩拉的错误提示与材料不同
if item.ItemId == constant.ItemConstantConst.SCOIN {
if item.ItemId == constant.ITEM_ID_SCOIN {
g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_SCOIN_NOT_ENOUGH)
}
g.SendError(cmd.WeaponUpgradeRsp, player, &proto.WeaponUpgradeRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH)

View File

@@ -40,7 +40,7 @@ func (r *RouteManager) doRoute(cmdId uint16, userId uint32, clientSeq uint32, pa
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
logger.Error("player is nil, uid: %v", userId)
GAME_MANAGER.DisconnectPlayer(userId, kcp.EnetNotFoundSession)
GAME_MANAGER.KickPlayer(userId, kcp.EnetNotFoundSession)
return
}
if !player.Online {

View File

@@ -188,7 +188,7 @@ func (t *TickManager) onTickMinute(now int64) {
return
}
// TODO 3.0.0REL版本中 发送某些无效家具 可能会导致客户端背包家具界面卡死
if uint16(itemDataConfig.Type) == constant.ItemTypeConst.ITEM_FURNITURE {
if uint16(itemDataConfig.Type) == constant.ITEM_TYPE_FURNITURE {
continue
}
num := random.GetRandomInt32(1, 9)
@@ -298,7 +298,7 @@ func (t *TickManager) onTick5Second(now int64) {
Z: float32(entity.rot.Z),
},
EntityId: entity.id,
CurHp: entity.fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)],
CurHp: entity.fightProp[uint32(constant.FIGHT_PROP_CUR_HP)],
OwnerUid: entity.gadgetEntity.gadgetVehicleEntity.owner.PlayerID,
Pos: &proto.Vector{
X: float32(entity.pos.X),
@@ -307,7 +307,7 @@ func (t *TickManager) onTick5Second(now int64) {
},
UidList: make([]uint32, 0, len(entity.gadgetEntity.gadgetVehicleEntity.memberMap)),
GadgetId: entity.gadgetEntity.gadgetVehicleEntity.vehicleId,
MaxHp: entity.fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_MAX_HP)],
MaxHp: entity.fightProp[uint32(constant.FIGHT_PROP_MAX_HP)],
}
for _, p := range entity.gadgetEntity.gadgetVehicleEntity.memberMap {
vehicleLocationInfo.UidList = append(vehicleLocationInfo.UidList, p.PlayerID)

View File

@@ -1,16 +1,13 @@
package game
import (
"math"
"time"
"hk4e/common/constant"
"hk4e/common/mq"
"hk4e/gdconf"
"hk4e/gs/model"
"hk4e/pkg/alg"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
)
@@ -35,7 +32,7 @@ func NewWorldManager(snowflake *alg.SnowflakeWorker) (r *WorldManager) {
r.worldMap = make(map[uint32]*World)
r.snowflake = snowflake
r.sceneBlockAoiMap = make(map[uint32]*alg.AoiManager)
for _, sceneConfig := range gdconf.CONF.SceneMap {
for _, sceneConfig := range gdconf.GetSceneDetailMap() {
minX := int16(0)
maxX := int16(0)
minZ := int16(0)
@@ -172,7 +169,7 @@ func (w *WorldManager) CreateWorld(owner *model.Player) *World {
multiplayerTeam: CreateMultiplayerTeam(),
peerList: make([]*model.Player, 0),
}
world.mpLevelEntityId = world.GetNextWorldEntityId(constant.EntityIdTypeConst.MPLEVEL)
world.mpLevelEntityId = world.GetNextWorldEntityId(constant.ENTITY_ID_TYPE_MPLEVEL)
w.worldMap[worldId] = world
return world
}
@@ -221,8 +218,7 @@ func (w *WorldManager) GetMultiplayerWorldNum() uint32 {
return w.multiplayerWorldNum
}
// 世界数据结构
// World 世界数据结构
type World struct {
id uint32
owner *model.Player
@@ -482,7 +478,7 @@ func (w *World) GetPlayerTeamEntityId(player *model.Player) uint32 {
// InitPlayerTeamEntityId 初始化某玩家的本地队伍实体id
func (w *World) InitPlayerTeamEntityId(player *model.Player) {
w.multiplayerTeam.localTeamEntityMap[player.PlayerID] = w.GetNextWorldEntityId(constant.EntityIdTypeConst.TEAM)
w.multiplayerTeam.localTeamEntityMap[player.PlayerID] = w.GetNextWorldEntityId(constant.ENTITY_ID_TYPE_TEAM)
}
// GetPlayerWorldAvatarEntityId 获取某玩家在世界队伍中的某角色的实体id
@@ -749,670 +745,3 @@ func (w *World) GetSceneById(sceneId uint32) *Scene {
}
return scene
}
// 场景数据结构
type Scene struct {
id uint32
world *World
playerMap map[uint32]*model.Player
entityMap map[uint32]*Entity
objectIdEntityMap map[int64]*Entity // 用于标识配置档里的唯一实体是否已被创建
gameTime uint32 // 游戏内提瓦特大陆的时间
createTime int64 // 场景创建时间
meeoIndex uint32 // 客户端风元素染色同步协议的计数器
}
func (s *Scene) GetId() uint32 {
return s.id
}
func (s *Scene) GetWorld() *World {
return s.world
}
func (s *Scene) GetAllPlayer() map[uint32]*model.Player {
return s.playerMap
}
func (s *Scene) GetAllEntity() map[uint32]*Entity {
return s.entityMap
}
func (s *Scene) GetGameTime() uint32 {
return s.gameTime
}
func (s *Scene) GetMeeoIndex() uint32 {
return s.meeoIndex
}
func (s *Scene) SetMeeoIndex(meeoIndex uint32) {
s.meeoIndex = meeoIndex
}
type AvatarEntity struct {
uid uint32
avatarId uint32
}
func (a *AvatarEntity) GetUid() uint32 {
return a.uid
}
func (a *AvatarEntity) GetAvatarId() uint32 {
return a.avatarId
}
type MonsterEntity struct {
monsterId uint32
}
func (m *MonsterEntity) GetMonsterId() uint32 {
return m.monsterId
}
type NpcEntity struct {
NpcId uint32
RoomId uint32
ParentQuestId uint32
BlockId uint32
}
const (
GADGET_TYPE_NORMAL = iota
GADGET_TYPE_GATHER
GADGET_TYPE_CLIENT
GADGET_TYPE_VEHICLE // 载具
)
type GadgetClientEntity struct {
configId uint32
campId uint32
campType uint32
ownerEntityId uint32
targetEntityId uint32
propOwnerEntityId uint32
}
func (g *GadgetClientEntity) GetConfigId() uint32 {
return g.configId
}
func (g *GadgetClientEntity) GetCampId() uint32 {
return g.campId
}
func (g *GadgetClientEntity) GetCampType() uint32 {
return g.campType
}
func (g *GadgetClientEntity) GetOwnerEntityId() uint32 {
return g.ownerEntityId
}
func (g *GadgetClientEntity) GetTargetEntityId() uint32 {
return g.targetEntityId
}
func (g *GadgetClientEntity) GetPropOwnerEntityId() uint32 {
return g.propOwnerEntityId
}
type GadgetGatherEntity struct {
gatherId uint32
}
func (g *GadgetGatherEntity) GetGatherId() uint32 {
return g.gatherId
}
type GadgetVehicleEntity struct {
vehicleId uint32
owner *model.Player
maxStamina float32
curStamina float32
memberMap map[uint32]*model.Player // uint32 = pos
}
func (g *GadgetVehicleEntity) GetVehicleId() uint32 {
return g.vehicleId
}
func (g *GadgetVehicleEntity) GetOwner() *model.Player {
return g.owner
}
func (g *GadgetVehicleEntity) GetMaxStamina() float32 {
return g.maxStamina
}
func (g *GadgetVehicleEntity) GetCurStamina() float32 {
return g.curStamina
}
func (g *GadgetVehicleEntity) SetCurStamina(curStamina float32) {
g.curStamina = curStamina
}
func (g *GadgetVehicleEntity) GetMemberMap() map[uint32]*model.Player {
return g.memberMap
}
type GadgetEntity struct {
gadgetType int
gadgetId uint32
gadgetClientEntity *GadgetClientEntity
gadgetGatherEntity *GadgetGatherEntity
gadgetVehicleEntity *GadgetVehicleEntity
}
func (g *GadgetEntity) GetGadgetType() int {
return g.gadgetType
}
func (g *GadgetEntity) GetGadgetId() uint32 {
return g.gadgetId
}
func (g *GadgetEntity) GetGadgetClientEntity() *GadgetClientEntity {
return g.gadgetClientEntity
}
func (g *GadgetEntity) GetGadgetGatherEntity() *GadgetGatherEntity {
return g.gadgetGatherEntity
}
func (g *GadgetEntity) GetGadgetVehicleEntity() *GadgetVehicleEntity {
return g.gadgetVehicleEntity
}
// 场景实体数据结构
type Entity struct {
id uint32
scene *Scene
lifeState uint16
pos *model.Vector
rot *model.Vector
moveState uint16
lastMoveSceneTimeMs uint32
lastMoveReliableSeq uint32
fightProp map[uint32]float32
entityType uint32
level uint8
avatarEntity *AvatarEntity
monsterEntity *MonsterEntity
npcEntity *NpcEntity
gadgetEntity *GadgetEntity
configId uint32
objectId int64
}
func (e *Entity) GetId() uint32 {
return e.id
}
func (e *Entity) GetLifeState() uint16 {
return e.lifeState
}
func (e *Entity) GetPos() *model.Vector {
return e.pos
}
func (e *Entity) GetRot() *model.Vector {
return e.rot
}
func (e *Entity) GetMoveState() uint16 {
return e.moveState
}
func (e *Entity) SetMoveState(moveState uint16) {
e.moveState = moveState
}
func (e *Entity) GetLastMoveSceneTimeMs() uint32 {
return e.lastMoveSceneTimeMs
}
func (e *Entity) SetLastMoveSceneTimeMs(lastMoveSceneTimeMs uint32) {
e.lastMoveSceneTimeMs = lastMoveSceneTimeMs
}
func (e *Entity) GetLastMoveReliableSeq() uint32 {
return e.lastMoveReliableSeq
}
func (e *Entity) SetLastMoveReliableSeq(lastMoveReliableSeq uint32) {
e.lastMoveReliableSeq = lastMoveReliableSeq
}
func (e *Entity) GetFightProp() map[uint32]float32 {
return e.fightProp
}
func (e *Entity) GetEntityType() uint32 {
return e.entityType
}
func (e *Entity) GetLevel() uint8 {
return e.level
}
func (e *Entity) GetAvatarEntity() *AvatarEntity {
return e.avatarEntity
}
func (e *Entity) GetMonsterEntity() *MonsterEntity {
return e.monsterEntity
}
func (e *Entity) GetNpcEntity() *NpcEntity {
return e.npcEntity
}
func (e *Entity) GetGadgetEntity() *GadgetEntity {
return e.gadgetEntity
}
func (e *Entity) GetConfigId() uint32 {
return e.configId
}
type Attack struct {
combatInvokeEntry *proto.CombatInvokeEntry
uid uint32
}
func (s *Scene) ChangeGameTime(time uint32) {
s.gameTime = time % 1440
}
func (s *Scene) GetSceneCreateTime() int64 {
return s.createTime
}
func (s *Scene) GetSceneTime() int64 {
now := time.Now().UnixMilli()
return now - s.createTime
}
func (s *Scene) AddPlayer(player *model.Player) {
s.playerMap[player.PlayerID] = player
s.world.InitPlayerWorldAvatar(player)
}
func (s *Scene) RemovePlayer(player *model.Player) {
delete(s.playerMap, player.PlayerID)
worldAvatarList := s.world.GetPlayerWorldAvatarList(player)
for _, worldAvatar := range worldAvatarList {
s.DestroyEntity(worldAvatar.avatarEntityId)
s.DestroyEntity(worldAvatar.weaponEntityId)
}
}
func (s *Scene) SetEntityLifeState(entity *Entity, lifeState uint16, dieType proto.PlayerDieType) {
if entity.avatarEntity != nil {
// 获取玩家对象
player := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
if player == nil {
logger.Error("player is nil, uid: %v", entity.avatarEntity.uid)
return
}
// 获取角色
avatar, ok := player.AvatarMap[entity.avatarEntity.avatarId]
if !ok {
logger.Error("avatar is nil, avatarId: %v", avatar)
return
}
// 设置角色存活状态
if lifeState == constant.LifeStateConst.LIFE_REVIVE {
avatar.LifeState = constant.LifeStateConst.LIFE_ALIVE
// 设置血量
entity.fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)] = 110
GAME_MANAGER.EntityFightPropUpdateNotifyBroadcast(s, entity, uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP))
}
// PacketAvatarLifeStateChangeNotify
avatarLifeStateChangeNotify := &proto.AvatarLifeStateChangeNotify{
LifeState: uint32(lifeState),
AttackTag: "",
DieType: dieType,
ServerBuffList: nil,
MoveReliableSeq: entity.lastMoveReliableSeq,
SourceEntityId: 0,
AvatarGuid: avatar.Guid,
}
for _, p := range s.playerMap {
GAME_MANAGER.SendMsg(cmd.AvatarLifeStateChangeNotify, p.PlayerID, p.ClientSeq, avatarLifeStateChangeNotify)
}
} else {
// 设置存活状态
entity.lifeState = lifeState
if lifeState == constant.LifeStateConst.LIFE_DEAD {
// 设置血量
entity.fightProp[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)] = 0
GAME_MANAGER.EntityFightPropUpdateNotifyBroadcast(s, entity, uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP))
}
// PacketLifeStateChangeNotify
lifeStateChangeNotify := &proto.LifeStateChangeNotify{
EntityId: entity.id,
AttackTag: "",
MoveReliableSeq: entity.lastMoveReliableSeq,
DieType: dieType,
LifeState: uint32(lifeState),
SourceEntityId: 0,
}
for _, p := range s.playerMap {
GAME_MANAGER.SendMsg(cmd.LifeStateChangeNotify, p.PlayerID, p.ClientSeq, lifeStateChangeNotify)
}
// 删除实体
s.DestroyEntity(entity.id)
GAME_MANAGER.RemoveSceneEntityNotifyBroadcast(s, proto.VisionType_VISION_DIE, []uint32{entity.id})
}
}
func (s *Scene) CreateEntityAvatar(player *model.Player, avatarId uint32) uint32 {
entityId := s.world.GetNextWorldEntityId(constant.EntityIdTypeConst.AVATAR)
avatar, ok := player.AvatarMap[avatarId]
if !ok {
logger.Error("avatar error, avatarId: %v", avatar)
return 0
}
entity := &Entity{
id: entityId,
scene: s,
lifeState: avatar.LifeState,
pos: player.Pos,
rot: player.Rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
// fightProp: player.AvatarMap[avatarId].FightPropMap, // 使用角色结构的数据
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_AVATAR),
// level: 0, // 使用角色结构的数据
avatarEntity: &AvatarEntity{
uid: player.PlayerID,
avatarId: avatarId,
},
}
s.CreateEntity(entity, 0)
MESSAGE_QUEUE.SendToFight(s.world.owner.FightAppId, &mq.NetMsg{
MsgType: mq.MsgTypeFight,
EventId: mq.FightRoutineAddEntity,
FightMsg: &mq.FightMsg{
FightRoutineId: s.world.id,
EntityId: entity.id,
FightPropMap: entity.fightProp,
Uid: entity.avatarEntity.uid,
AvatarGuid: player.AvatarMap[avatarId].Guid,
},
})
return entity.id
}
func (s *Scene) CreateEntityWeapon() uint32 {
entityId := s.world.GetNextWorldEntityId(constant.EntityIdTypeConst.WEAPON)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LifeStateConst.LIFE_ALIVE,
pos: new(model.Vector),
rot: new(model.Vector),
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: nil,
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_WEAPON),
}
s.CreateEntity(entity, 0)
return entity.id
}
func (s *Scene) CreateEntityMonster(pos, rot *model.Vector, monsterId uint32, level uint8, fightProp map[uint32]float32, configId uint32, objectId int64) uint32 {
_, exist := s.objectIdEntityMap[objectId]
if exist {
return 0
}
entityId := s.world.GetNextWorldEntityId(constant.EntityIdTypeConst.MONSTER)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LifeStateConst.LIFE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: fightProp,
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_MONSTER),
level: level,
monsterEntity: &MonsterEntity{
monsterId: monsterId,
},
configId: configId,
objectId: objectId,
}
s.CreateEntity(entity, objectId)
MESSAGE_QUEUE.SendToFight(s.world.owner.FightAppId, &mq.NetMsg{
MsgType: mq.MsgTypeFight,
EventId: mq.FightRoutineAddEntity,
FightMsg: &mq.FightMsg{
FightRoutineId: s.world.id,
EntityId: entity.id,
FightPropMap: entity.fightProp,
},
})
return entity.id
}
func (s *Scene) CreateEntityNpc(pos, rot *model.Vector, npcId, roomId, parentQuestId, blockId, configId uint32, objectId int64) uint32 {
_, exist := s.objectIdEntityMap[objectId]
if exist {
return 0
}
entityId := s.world.GetNextWorldEntityId(constant.EntityIdTypeConst.NPC)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LifeStateConst.LIFE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: map[uint32]float32{
uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP): math.MaxFloat32,
uint32(constant.FightPropertyConst.FIGHT_PROP_MAX_HP): math.MaxFloat32,
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1),
},
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_NPC),
npcEntity: &NpcEntity{
NpcId: npcId,
RoomId: roomId,
ParentQuestId: parentQuestId,
BlockId: blockId,
},
configId: configId,
objectId: objectId,
}
s.CreateEntity(entity, objectId)
return entity.id
}
func (s *Scene) CreateEntityGadgetNormal(pos, rot *model.Vector, gadgetId uint32, configId uint32, objectId int64) uint32 {
_, exist := s.objectIdEntityMap[objectId]
if exist {
return 0
}
entityId := s.world.GetNextWorldEntityId(constant.EntityIdTypeConst.GADGET)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LifeStateConst.LIFE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: map[uint32]float32{
uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP): math.MaxFloat32,
uint32(constant.FightPropertyConst.FIGHT_PROP_MAX_HP): math.MaxFloat32,
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1),
},
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
gadgetEntity: &GadgetEntity{
gadgetId: gadgetId,
gadgetType: GADGET_TYPE_NORMAL,
},
configId: configId,
objectId: objectId,
}
s.CreateEntity(entity, objectId)
return entity.id
}
func (s *Scene) CreateEntityGadgetGather(pos, rot *model.Vector, gadgetId uint32, gatherId uint32, configId uint32, objectId int64) uint32 {
_, exist := s.objectIdEntityMap[objectId]
if exist {
return 0
}
entityId := s.world.GetNextWorldEntityId(constant.EntityIdTypeConst.GADGET)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LifeStateConst.LIFE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: map[uint32]float32{
uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP): math.MaxFloat32,
uint32(constant.FightPropertyConst.FIGHT_PROP_MAX_HP): math.MaxFloat32,
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1),
},
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
gadgetEntity: &GadgetEntity{
gadgetId: gadgetId,
gadgetType: GADGET_TYPE_GATHER,
gadgetGatherEntity: &GadgetGatherEntity{
gatherId: gatherId,
},
},
configId: configId,
objectId: objectId,
}
s.CreateEntity(entity, objectId)
return entity.id
}
func (s *Scene) CreateEntityGadgetClient(pos, rot *model.Vector, entityId uint32, configId, campId, campType, ownerEntityId, targetEntityId, propOwnerEntityId uint32) {
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LifeStateConst.LIFE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: map[uint32]float32{
uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP): math.MaxFloat32,
uint32(constant.FightPropertyConst.FIGHT_PROP_MAX_HP): math.MaxFloat32,
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1),
},
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
gadgetEntity: &GadgetEntity{
gadgetType: GADGET_TYPE_CLIENT,
gadgetClientEntity: &GadgetClientEntity{
configId: configId,
campId: campId,
campType: campType,
ownerEntityId: ownerEntityId,
targetEntityId: targetEntityId,
propOwnerEntityId: propOwnerEntityId,
},
},
}
s.CreateEntity(entity, 0)
}
func (s *Scene) CreateEntityGadgetVehicle(uid uint32, pos, rot *model.Vector, vehicleId uint32) uint32 {
player := USER_MANAGER.GetOnlineUser(uid)
if player == nil {
logger.Error("player is nil, uid: %v", uid)
return 0
}
entityId := s.world.GetNextWorldEntityId(constant.EntityIdTypeConst.GADGET)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LifeStateConst.LIFE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: map[uint32]float32{
// TODO 以后使用配置表
uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP): 114514,
uint32(constant.FightPropertyConst.FIGHT_PROP_MAX_HP): 114514,
uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP): float32(1),
},
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
gadgetEntity: &GadgetEntity{
gadgetType: GADGET_TYPE_VEHICLE,
gadgetVehicleEntity: &GadgetVehicleEntity{
vehicleId: vehicleId,
owner: player,
maxStamina: 240, // TODO 应该也能在配置表找到
curStamina: 240, // TODO 与maxStamina一致
memberMap: make(map[uint32]*model.Player),
},
},
}
s.CreateEntity(entity, 0)
return entity.id
}
func (s *Scene) CreateEntity(entity *Entity, objectId int64) {
if len(s.entityMap) >= ENTITY_MAX_SEND_NUM && !ENTITY_NUM_UNLIMIT {
logger.Error("above max scene entity num limit: %v, id: %v, pos: %v", ENTITY_MAX_SEND_NUM, entity.id, entity.pos)
return
}
if objectId != 0 {
s.objectIdEntityMap[objectId] = entity
}
s.entityMap[entity.id] = entity
}
func (s *Scene) DestroyEntity(entityId uint32) {
entity := s.GetEntity(entityId)
if entity == nil {
return
}
delete(s.entityMap, entity.id)
delete(s.objectIdEntityMap, entity.objectId)
MESSAGE_QUEUE.SendToFight(s.world.owner.FightAppId, &mq.NetMsg{
MsgType: mq.MsgTypeFight,
EventId: mq.FightRoutineDelEntity,
FightMsg: &mq.FightMsg{
FightRoutineId: s.world.id,
EntityId: entity.id,
},
})
}
func (s *Scene) GetEntity(entityId uint32) *Entity {
return s.entityMap[entityId]
}
func (s *Scene) GetEntityByObjectId(objectId int64) *Entity {
return s.objectIdEntityMap[objectId]
}

673
gs/game/world_scene.go Normal file
View File

@@ -0,0 +1,673 @@
package game
import (
"math"
"time"
"hk4e/common/constant"
"hk4e/common/mq"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
)
// Scene 场景数据结构
type Scene struct {
id uint32
world *World
playerMap map[uint32]*model.Player
entityMap map[uint32]*Entity
objectIdEntityMap map[int64]*Entity // 用于标识配置档里的唯一实体是否已被创建
gameTime uint32 // 游戏内提瓦特大陆的时间
createTime int64 // 场景创建时间
meeoIndex uint32 // 客户端风元素染色同步协议的计数器
}
func (s *Scene) GetId() uint32 {
return s.id
}
func (s *Scene) GetWorld() *World {
return s.world
}
func (s *Scene) GetAllPlayer() map[uint32]*model.Player {
return s.playerMap
}
func (s *Scene) GetAllEntity() map[uint32]*Entity {
return s.entityMap
}
func (s *Scene) GetGameTime() uint32 {
return s.gameTime
}
func (s *Scene) GetMeeoIndex() uint32 {
return s.meeoIndex
}
func (s *Scene) SetMeeoIndex(meeoIndex uint32) {
s.meeoIndex = meeoIndex
}
func (s *Scene) ChangeGameTime(time uint32) {
s.gameTime = time % 1440
}
func (s *Scene) GetSceneCreateTime() int64 {
return s.createTime
}
func (s *Scene) GetSceneTime() int64 {
now := time.Now().UnixMilli()
return now - s.createTime
}
func (s *Scene) AddPlayer(player *model.Player) {
s.playerMap[player.PlayerID] = player
s.world.InitPlayerWorldAvatar(player)
}
func (s *Scene) RemovePlayer(player *model.Player) {
delete(s.playerMap, player.PlayerID)
worldAvatarList := s.world.GetPlayerWorldAvatarList(player)
for _, worldAvatar := range worldAvatarList {
s.DestroyEntity(worldAvatar.avatarEntityId)
s.DestroyEntity(worldAvatar.weaponEntityId)
}
}
func (s *Scene) SetEntityLifeState(entity *Entity, lifeState uint16, dieType proto.PlayerDieType) {
if entity.avatarEntity != nil {
// 获取玩家对象
player := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
if player == nil {
logger.Error("player is nil, uid: %v", entity.avatarEntity.uid)
return
}
// 获取角色
avatar, ok := player.AvatarMap[entity.avatarEntity.avatarId]
if !ok {
logger.Error("avatar is nil, avatarId: %v", avatar)
return
}
// 设置角色存活状态
if lifeState == constant.LIFE_STATE_REVIVE {
avatar.LifeState = constant.LIFE_STATE_ALIVE
// 设置血量
entity.fightProp[uint32(constant.FIGHT_PROP_CUR_HP)] = 110
GAME_MANAGER.EntityFightPropUpdateNotifyBroadcast(s, entity, uint32(constant.FIGHT_PROP_CUR_HP))
}
// PacketAvatarLifeStateChangeNotify
avatarLifeStateChangeNotify := &proto.AvatarLifeStateChangeNotify{
LifeState: uint32(lifeState),
AttackTag: "",
DieType: dieType,
ServerBuffList: nil,
MoveReliableSeq: entity.lastMoveReliableSeq,
SourceEntityId: 0,
AvatarGuid: avatar.Guid,
}
for _, p := range s.playerMap {
GAME_MANAGER.SendMsg(cmd.AvatarLifeStateChangeNotify, p.PlayerID, p.ClientSeq, avatarLifeStateChangeNotify)
}
} else {
// 设置存活状态
entity.lifeState = lifeState
if lifeState == constant.LIFE_STATE_DEAD {
// 设置血量
entity.fightProp[uint32(constant.FIGHT_PROP_CUR_HP)] = 0
GAME_MANAGER.EntityFightPropUpdateNotifyBroadcast(s, entity, uint32(constant.FIGHT_PROP_CUR_HP))
}
// PacketLifeStateChangeNotify
lifeStateChangeNotify := &proto.LifeStateChangeNotify{
EntityId: entity.id,
AttackTag: "",
MoveReliableSeq: entity.lastMoveReliableSeq,
DieType: dieType,
LifeState: uint32(lifeState),
SourceEntityId: 0,
}
for _, p := range s.playerMap {
GAME_MANAGER.SendMsg(cmd.LifeStateChangeNotify, p.PlayerID, p.ClientSeq, lifeStateChangeNotify)
}
// 删除实体
s.DestroyEntity(entity.id)
GAME_MANAGER.RemoveSceneEntityNotifyBroadcast(s, proto.VisionType_VISION_DIE, []uint32{entity.id})
}
}
func (s *Scene) CreateEntityAvatar(player *model.Player, avatarId uint32) uint32 {
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_ID_TYPE_AVATAR)
avatar, ok := player.AvatarMap[avatarId]
if !ok {
logger.Error("avatar error, avatarId: %v", avatar)
return 0
}
entity := &Entity{
id: entityId,
scene: s,
lifeState: avatar.LifeState,
pos: player.Pos,
rot: player.Rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
// fightProp: player.AvatarMap[avatarId].FightPropMap, // 使用角色结构的数据
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_AVATAR),
// level: 0, // 使用角色结构的数据
avatarEntity: &AvatarEntity{
uid: player.PlayerID,
avatarId: avatarId,
},
}
s.CreateEntity(entity, 0)
MESSAGE_QUEUE.SendToFight(s.world.owner.FightAppId, &mq.NetMsg{
MsgType: mq.MsgTypeFight,
EventId: mq.FightRoutineAddEntity,
FightMsg: &mq.FightMsg{
FightRoutineId: s.world.id,
EntityId: entity.id,
FightPropMap: entity.fightProp,
Uid: entity.avatarEntity.uid,
AvatarGuid: player.AvatarMap[avatarId].Guid,
},
})
return entity.id
}
func (s *Scene) CreateEntityWeapon() uint32 {
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_ID_TYPE_WEAPON)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LIFE_STATE_ALIVE,
pos: new(model.Vector),
rot: new(model.Vector),
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: nil,
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_WEAPON),
}
s.CreateEntity(entity, 0)
return entity.id
}
func (s *Scene) CreateEntityMonster(pos, rot *model.Vector, monsterId uint32, level uint8, fightProp map[uint32]float32, configId uint32, objectId int64) uint32 {
_, exist := s.objectIdEntityMap[objectId]
if exist {
return 0
}
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_ID_TYPE_MONSTER)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LIFE_STATE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: fightProp,
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_MONSTER),
level: level,
monsterEntity: &MonsterEntity{
monsterId: monsterId,
},
configId: configId,
objectId: objectId,
}
s.CreateEntity(entity, objectId)
MESSAGE_QUEUE.SendToFight(s.world.owner.FightAppId, &mq.NetMsg{
MsgType: mq.MsgTypeFight,
EventId: mq.FightRoutineAddEntity,
FightMsg: &mq.FightMsg{
FightRoutineId: s.world.id,
EntityId: entity.id,
FightPropMap: entity.fightProp,
},
})
return entity.id
}
func (s *Scene) CreateEntityNpc(pos, rot *model.Vector, npcId, roomId, parentQuestId, blockId, configId uint32, objectId int64) uint32 {
_, exist := s.objectIdEntityMap[objectId]
if exist {
return 0
}
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_ID_TYPE_NPC)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LIFE_STATE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: map[uint32]float32{
uint32(constant.FIGHT_PROP_CUR_HP): math.MaxFloat32,
uint32(constant.FIGHT_PROP_MAX_HP): math.MaxFloat32,
uint32(constant.FIGHT_PROP_BASE_HP): float32(1),
},
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_NPC),
npcEntity: &NpcEntity{
NpcId: npcId,
RoomId: roomId,
ParentQuestId: parentQuestId,
BlockId: blockId,
},
configId: configId,
objectId: objectId,
}
s.CreateEntity(entity, objectId)
return entity.id
}
func (s *Scene) CreateEntityGadgetNormal(pos, rot *model.Vector, gadgetId uint32, configId uint32, objectId int64) uint32 {
_, exist := s.objectIdEntityMap[objectId]
if exist {
return 0
}
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_ID_TYPE_GADGET)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LIFE_STATE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: map[uint32]float32{
uint32(constant.FIGHT_PROP_CUR_HP): math.MaxFloat32,
uint32(constant.FIGHT_PROP_MAX_HP): math.MaxFloat32,
uint32(constant.FIGHT_PROP_BASE_HP): float32(1),
},
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
gadgetEntity: &GadgetEntity{
gadgetId: gadgetId,
gadgetType: GADGET_TYPE_NORMAL,
},
configId: configId,
objectId: objectId,
}
s.CreateEntity(entity, objectId)
return entity.id
}
func (s *Scene) CreateEntityGadgetGather(pos, rot *model.Vector, gadgetId uint32, gatherId uint32, configId uint32, objectId int64) uint32 {
_, exist := s.objectIdEntityMap[objectId]
if exist {
return 0
}
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_ID_TYPE_GADGET)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LIFE_STATE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: map[uint32]float32{
uint32(constant.FIGHT_PROP_CUR_HP): math.MaxFloat32,
uint32(constant.FIGHT_PROP_MAX_HP): math.MaxFloat32,
uint32(constant.FIGHT_PROP_BASE_HP): float32(1),
},
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
gadgetEntity: &GadgetEntity{
gadgetId: gadgetId,
gadgetType: GADGET_TYPE_GATHER,
gadgetGatherEntity: &GadgetGatherEntity{
gatherId: gatherId,
},
},
configId: configId,
objectId: objectId,
}
s.CreateEntity(entity, objectId)
return entity.id
}
func (s *Scene) CreateEntityGadgetClient(pos, rot *model.Vector, entityId uint32, configId, campId, campType, ownerEntityId, targetEntityId, propOwnerEntityId uint32) {
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LIFE_STATE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: map[uint32]float32{
uint32(constant.FIGHT_PROP_CUR_HP): math.MaxFloat32,
uint32(constant.FIGHT_PROP_MAX_HP): math.MaxFloat32,
uint32(constant.FIGHT_PROP_BASE_HP): float32(1),
},
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
gadgetEntity: &GadgetEntity{
gadgetType: GADGET_TYPE_CLIENT,
gadgetClientEntity: &GadgetClientEntity{
configId: configId,
campId: campId,
campType: campType,
ownerEntityId: ownerEntityId,
targetEntityId: targetEntityId,
propOwnerEntityId: propOwnerEntityId,
},
},
}
s.CreateEntity(entity, 0)
}
func (s *Scene) CreateEntityGadgetVehicle(uid uint32, pos, rot *model.Vector, vehicleId uint32) uint32 {
player := USER_MANAGER.GetOnlineUser(uid)
if player == nil {
logger.Error("player is nil, uid: %v", uid)
return 0
}
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_ID_TYPE_GADGET)
entity := &Entity{
id: entityId,
scene: s,
lifeState: constant.LIFE_STATE_ALIVE,
pos: pos,
rot: rot,
moveState: uint16(proto.MotionState_MOTION_NONE),
lastMoveSceneTimeMs: 0,
lastMoveReliableSeq: 0,
fightProp: map[uint32]float32{
// TODO 以后使用配置表
uint32(constant.FIGHT_PROP_CUR_HP): 114514,
uint32(constant.FIGHT_PROP_MAX_HP): 114514,
uint32(constant.FIGHT_PROP_BASE_HP): float32(1),
},
entityType: uint32(proto.ProtEntityType_PROT_ENTITY_GADGET),
gadgetEntity: &GadgetEntity{
gadgetType: GADGET_TYPE_VEHICLE,
gadgetVehicleEntity: &GadgetVehicleEntity{
vehicleId: vehicleId,
owner: player,
maxStamina: 240, // TODO 应该也能在配置表找到
curStamina: 240, // TODO 与maxStamina一致
memberMap: make(map[uint32]*model.Player),
},
},
}
s.CreateEntity(entity, 0)
return entity.id
}
func (s *Scene) CreateEntity(entity *Entity, objectId int64) {
if len(s.entityMap) >= ENTITY_MAX_SEND_NUM && !ENTITY_NUM_UNLIMIT {
logger.Error("above max scene entity num limit: %v, id: %v, pos: %v", ENTITY_MAX_SEND_NUM, entity.id, entity.pos)
return
}
if objectId != 0 {
s.objectIdEntityMap[objectId] = entity
}
s.entityMap[entity.id] = entity
}
func (s *Scene) DestroyEntity(entityId uint32) {
entity := s.GetEntity(entityId)
if entity == nil {
return
}
delete(s.entityMap, entity.id)
delete(s.objectIdEntityMap, entity.objectId)
MESSAGE_QUEUE.SendToFight(s.world.owner.FightAppId, &mq.NetMsg{
MsgType: mq.MsgTypeFight,
EventId: mq.FightRoutineDelEntity,
FightMsg: &mq.FightMsg{
FightRoutineId: s.world.id,
EntityId: entity.id,
},
})
}
func (s *Scene) GetEntity(entityId uint32) *Entity {
return s.entityMap[entityId]
}
func (s *Scene) GetEntityByObjectId(objectId int64) *Entity {
return s.objectIdEntityMap[objectId]
}
// Entity 场景实体数据结构
type Entity struct {
id uint32
scene *Scene
lifeState uint16
pos *model.Vector
rot *model.Vector
moveState uint16
lastMoveSceneTimeMs uint32
lastMoveReliableSeq uint32
fightProp map[uint32]float32
entityType uint32
level uint8
avatarEntity *AvatarEntity
monsterEntity *MonsterEntity
npcEntity *NpcEntity
gadgetEntity *GadgetEntity
configId uint32
objectId int64
}
func (e *Entity) GetId() uint32 {
return e.id
}
func (e *Entity) GetLifeState() uint16 {
return e.lifeState
}
func (e *Entity) GetPos() *model.Vector {
return e.pos
}
func (e *Entity) GetRot() *model.Vector {
return e.rot
}
func (e *Entity) GetMoveState() uint16 {
return e.moveState
}
func (e *Entity) SetMoveState(moveState uint16) {
e.moveState = moveState
}
func (e *Entity) GetLastMoveSceneTimeMs() uint32 {
return e.lastMoveSceneTimeMs
}
func (e *Entity) SetLastMoveSceneTimeMs(lastMoveSceneTimeMs uint32) {
e.lastMoveSceneTimeMs = lastMoveSceneTimeMs
}
func (e *Entity) GetLastMoveReliableSeq() uint32 {
return e.lastMoveReliableSeq
}
func (e *Entity) SetLastMoveReliableSeq(lastMoveReliableSeq uint32) {
e.lastMoveReliableSeq = lastMoveReliableSeq
}
func (e *Entity) GetFightProp() map[uint32]float32 {
return e.fightProp
}
func (e *Entity) GetEntityType() uint32 {
return e.entityType
}
func (e *Entity) GetLevel() uint8 {
return e.level
}
func (e *Entity) GetAvatarEntity() *AvatarEntity {
return e.avatarEntity
}
func (e *Entity) GetMonsterEntity() *MonsterEntity {
return e.monsterEntity
}
func (e *Entity) GetNpcEntity() *NpcEntity {
return e.npcEntity
}
func (e *Entity) GetGadgetEntity() *GadgetEntity {
return e.gadgetEntity
}
func (e *Entity) GetConfigId() uint32 {
return e.configId
}
type AvatarEntity struct {
uid uint32
avatarId uint32
}
func (a *AvatarEntity) GetUid() uint32 {
return a.uid
}
func (a *AvatarEntity) GetAvatarId() uint32 {
return a.avatarId
}
type MonsterEntity struct {
monsterId uint32
}
func (m *MonsterEntity) GetMonsterId() uint32 {
return m.monsterId
}
type NpcEntity struct {
NpcId uint32
RoomId uint32
ParentQuestId uint32
BlockId uint32
}
type GadgetEntity struct {
gadgetType int
gadgetId uint32
gadgetClientEntity *GadgetClientEntity
gadgetGatherEntity *GadgetGatherEntity
gadgetVehicleEntity *GadgetVehicleEntity
}
func (g *GadgetEntity) GetGadgetType() int {
return g.gadgetType
}
func (g *GadgetEntity) GetGadgetId() uint32 {
return g.gadgetId
}
func (g *GadgetEntity) GetGadgetClientEntity() *GadgetClientEntity {
return g.gadgetClientEntity
}
func (g *GadgetEntity) GetGadgetGatherEntity() *GadgetGatherEntity {
return g.gadgetGatherEntity
}
func (g *GadgetEntity) GetGadgetVehicleEntity() *GadgetVehicleEntity {
return g.gadgetVehicleEntity
}
const (
GADGET_TYPE_NORMAL = iota
GADGET_TYPE_GATHER
GADGET_TYPE_CLIENT
GADGET_TYPE_VEHICLE // 载具
)
type GadgetClientEntity struct {
configId uint32
campId uint32
campType uint32
ownerEntityId uint32
targetEntityId uint32
propOwnerEntityId uint32
}
func (g *GadgetClientEntity) GetConfigId() uint32 {
return g.configId
}
func (g *GadgetClientEntity) GetCampId() uint32 {
return g.campId
}
func (g *GadgetClientEntity) GetCampType() uint32 {
return g.campType
}
func (g *GadgetClientEntity) GetOwnerEntityId() uint32 {
return g.ownerEntityId
}
func (g *GadgetClientEntity) GetTargetEntityId() uint32 {
return g.targetEntityId
}
func (g *GadgetClientEntity) GetPropOwnerEntityId() uint32 {
return g.propOwnerEntityId
}
type GadgetGatherEntity struct {
gatherId uint32
}
func (g *GadgetGatherEntity) GetGatherId() uint32 {
return g.gatherId
}
type GadgetVehicleEntity struct {
vehicleId uint32
owner *model.Player
maxStamina float32
curStamina float32
memberMap map[uint32]*model.Player // uint32 = pos
}
func (g *GadgetVehicleEntity) GetVehicleId() uint32 {
return g.vehicleId
}
func (g *GadgetVehicleEntity) GetOwner() *model.Player {
return g.owner
}
func (g *GadgetVehicleEntity) GetMaxStamina() float32 {
return g.maxStamina
}
func (g *GadgetVehicleEntity) GetCurStamina() float32 {
return g.curStamina
}
func (g *GadgetVehicleEntity) SetCurStamina(curStamina float32) {
g.curStamina = curStamina
}
func (g *GadgetVehicleEntity) GetMemberMap() map[uint32]*model.Player {
return g.memberMap
}

View File

@@ -54,28 +54,28 @@ func (p *Player) InitAvatar(avatar *Avatar) {
// InitAvatarFightProp 初始化角色面板
func (p *Player) InitAvatarFightProp(avatar *Avatar) {
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatar.AvatarId)]
if !ok {
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatar.AvatarId))
if avatarDataConfig == nil {
logger.Error("avatarDataConfig error, avatarId: %v", avatar.AvatarId)
return
}
avatar.FightPropMap = make(map[uint32]float32)
avatar.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_NONE)] = 0.0
avatar.FightPropMap[uint32(constant.FIGHT_PROP_NONE)] = 0.0
// 白字攻防血
avatar.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_ATTACK)] = float32(avatarDataConfig.GetBaseAttackByLevel(avatar.Level))
avatar.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_DEFENSE)] = float32(avatarDataConfig.GetBaseDefenseByLevel(avatar.Level))
avatar.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_BASE_HP)] = float32(avatarDataConfig.GetBaseHpByLevel(avatar.Level))
avatar.FightPropMap[uint32(constant.FIGHT_PROP_BASE_ATTACK)] = float32(avatarDataConfig.GetBaseAttackByLevel(avatar.Level))
avatar.FightPropMap[uint32(constant.FIGHT_PROP_BASE_DEFENSE)] = float32(avatarDataConfig.GetBaseDefenseByLevel(avatar.Level))
avatar.FightPropMap[uint32(constant.FIGHT_PROP_BASE_HP)] = float32(avatarDataConfig.GetBaseHpByLevel(avatar.Level))
// 白字+绿字攻防血
avatar.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_ATTACK)] = float32(avatarDataConfig.GetBaseAttackByLevel(avatar.Level))
avatar.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_DEFENSE)] = float32(avatarDataConfig.GetBaseDefenseByLevel(avatar.Level))
avatar.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_MAX_HP)] = float32(avatarDataConfig.GetBaseHpByLevel(avatar.Level))
avatar.FightPropMap[uint32(constant.FIGHT_PROP_CUR_ATTACK)] = float32(avatarDataConfig.GetBaseAttackByLevel(avatar.Level))
avatar.FightPropMap[uint32(constant.FIGHT_PROP_CUR_DEFENSE)] = float32(avatarDataConfig.GetBaseDefenseByLevel(avatar.Level))
avatar.FightPropMap[uint32(constant.FIGHT_PROP_MAX_HP)] = float32(avatarDataConfig.GetBaseHpByLevel(avatar.Level))
// 当前血量
avatar.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CUR_HP)] = float32(avatar.CurrHP)
avatar.FightPropMap[uint32(constant.FIGHT_PROP_CUR_HP)] = float32(avatar.CurrHP)
// 双暴
avatar.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CRITICAL)] = float32(avatarDataConfig.Critical)
avatar.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CRITICAL_HURT)] = float32(avatarDataConfig.CriticalHurt)
avatar.FightPropMap[uint32(constant.FIGHT_PROP_CRITICAL)] = float32(avatarDataConfig.Critical)
avatar.FightPropMap[uint32(constant.FIGHT_PROP_CRITICAL_HURT)] = float32(avatarDataConfig.CriticalHurt)
// 元素充能
avatar.FightPropMap[uint32(constant.FightPropertyConst.FIGHT_PROP_CHARGE_EFFICIENCY)] = 1.0
avatar.FightPropMap[uint32(constant.FIGHT_PROP_CHARGE_EFFICIENCY)] = 1.0
p.SetCurrEnergy(avatar, avatar.CurrEnergy, true)
}
@@ -89,8 +89,8 @@ func (p *Player) GetAvatarIdByGuid(guid uint64) uint32 {
}
func (p *Player) AddAvatar(avatarId uint32) {
avatarDataConfig, exist := gdconf.CONF.AvatarDataMap[int32(avatarId)]
if !exist {
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatarId))
if avatarDataConfig == nil {
logger.Error("avatar data config is nil, avatarId: %v", avatarId)
return
}
@@ -103,14 +103,14 @@ func (p *Player) AddAvatar(avatarId uint32) {
} else {
skillDepotId = avatarDataConfig.SkillDepotId
}
avatarSkillDepotDataConfig, exist := gdconf.CONF.AvatarSkillDepotDataMap[skillDepotId]
if !exist {
avatarSkillDepotDataConfig := gdconf.GetAvatarSkillDepotDataById(skillDepotId)
if avatarSkillDepotDataConfig == nil {
logger.Error("avatar skill depot data config is nil, skillDepotId: %v", skillDepotId)
return
}
avatar := &Avatar{
AvatarId: avatarId,
LifeState: constant.LifeStateConst.LIFE_ALIVE,
LifeState: constant.LIFE_STATE_ALIVE,
Level: 1,
Exp: 0,
Promote: 0,
@@ -155,16 +155,16 @@ func (p *Player) AddAvatar(avatarId uint32) {
func (p *Player) SetCurrEnergy(avatar *Avatar, value float64, max bool) {
var avatarSkillDataConfig *gdconf.AvatarSkillData = nil
if avatar.AvatarId == 10000005 || avatar.AvatarId == 10000007 {
avatarSkillDepotDataConfig, exist := gdconf.CONF.AvatarSkillDepotDataMap[int32(avatar.SkillDepotId)]
if !exist {
avatarSkillDepotDataConfig := gdconf.GetAvatarSkillDepotDataById(int32(avatar.SkillDepotId))
if avatarSkillDepotDataConfig == nil {
return
}
avatarSkillDataConfig, exist = gdconf.CONF.AvatarSkillDataMap[avatarSkillDepotDataConfig.EnergySkill]
if !exist {
avatarSkillDataConfig = gdconf.GetAvatarSkillDataById(avatarSkillDepotDataConfig.EnergySkill)
if avatarSkillDataConfig == nil {
return
}
} else {
avatarSkillDataConfig = gdconf.CONF.GetAvatarEnergySkillConfig(avatar.AvatarId)
avatarSkillDataConfig = gdconf.GetAvatarEnergySkillConfig(avatar.AvatarId)
}
if avatarSkillDataConfig == nil {
logger.Error("get avatar energy skill is nil, avatarId: %v", avatar.AvatarId)

View File

@@ -46,7 +46,7 @@ func (p *Player) GetItemIdByItemAndWeaponGuid(guid uint64) uint32 {
}
func (p *Player) GetItemCount(itemId uint32) uint32 {
prop, ok := constant.ItemConstantConst.VIRTUAL_ITEM_PROP[itemId]
prop, ok := constant.VIRTUAL_ITEM_PROP[itemId]
if ok {
value := p.PropertiesMap[prop]
return value

View File

@@ -48,8 +48,8 @@ func (p *Player) AddReliquary(itemId uint32, reliquaryId uint64, mainPropId uint
AvatarId: 0,
Guid: 0,
}
itemDataConfig, exist := gdconf.CONF.ItemDataMap[int32(itemId)]
if !exist {
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
if itemDataConfig == nil {
logger.Error("reliquary config is nil, itemId: %v", itemId)
return
}

View File

@@ -26,35 +26,35 @@ func (s *StaminaInfo) SetStaminaCost(state proto.MotionState) {
// 消耗耐力
case proto.MotionState_MOTION_DASH:
// 快速跑步
s.CostStamina = constant.StaminaCostConst.DASH
s.CostStamina = constant.STAMINA_COST_DASH
case proto.MotionState_MOTION_FLY, proto.MotionState_MOTION_FLY_FAST, proto.MotionState_MOTION_FLY_SLOW:
// 滑翔
s.CostStamina = constant.StaminaCostConst.FLY
s.CostStamina = constant.STAMINA_COST_FLY
case proto.MotionState_MOTION_SWIM_DASH:
// 快速游泳
s.CostStamina = constant.StaminaCostConst.SWIM_DASH
s.CostStamina = constant.STAMINA_COST_SWIM_DASH
case proto.MotionState_MOTION_SKIFF_DASH:
// 浪船加速
s.CostStamina = constant.StaminaCostConst.SKIFF_DASH
s.CostStamina = constant.STAMINA_COST_SKIFF_DASH
// 恢复耐力
case proto.MotionState_MOTION_DANGER_RUN, proto.MotionState_MOTION_RUN:
// 正常跑步
s.CostStamina = constant.StaminaCostConst.RUN
s.CostStamina = constant.STAMINA_COST_RUN
case 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:
// 站立
s.CostStamina = constant.StaminaCostConst.STANDBY
s.CostStamina = constant.STAMINA_COST_STANDBY
case proto.MotionState_MOTION_DANGER_WALK, proto.MotionState_MOTION_WALK:
// 走路
s.CostStamina = constant.StaminaCostConst.WALK
s.CostStamina = constant.STAMINA_COST_WALK
case proto.MotionState_MOTION_SKIFF_BOARDING, proto.MotionState_MOTION_SKIFF_NORMAL:
// 浪船正常移动或停下
s.CostStamina = constant.StaminaCostConst.SKIFF_NORMAL
s.CostStamina = constant.STAMINA_COST_SKIFF_NORMAL
case proto.MotionState_MOTION_POWERED_FLY:
// 滑翔加速 (风圈等)
s.CostStamina = constant.StaminaCostConst.POWERED_FLY
s.CostStamina = constant.STAMINA_COST_POWERED_FLY
case proto.MotionState_MOTION_SKIFF_POWERED_DASH:
// 浪船加速 (风圈等)
s.CostStamina = constant.StaminaCostConst.POWERED_SKIFF
s.CostStamina = constant.STAMINA_COST_POWERED_SKIFF
// 缓慢动作将在客户端发送消息后消耗
case proto.MotionState_MOTION_CLIMB, proto.MotionState_MOTION_SWIM_MOVE:
// 缓慢攀爬 或 缓慢游泳

View File

@@ -61,7 +61,7 @@ func (t *TeamInfo) UpdateTeam() {
t.TeamResonancesConfig = make(map[int32]bool)
teamElementTypeCountMap := make(map[uint16]uint8)
for _, avatarId := range activeTeam.GetAvatarIdList() {
avatarSkillDataConfig := gdconf.CONF.GetAvatarEnergySkillConfig(avatarId)
avatarSkillDataConfig := gdconf.GetAvatarEnergySkillConfig(avatarId)
if avatarSkillDataConfig == nil {
logger.Error("get avatar energy skill is nil, avatarId: %v", avatarId)
continue

View File

@@ -68,8 +68,8 @@ func (p *Player) AddWeapon(itemId uint32, weaponId uint64) {
Refinement: 0,
Guid: 0,
}
itemDataConfig, exist := gdconf.CONF.ItemDataMap[int32(itemId)]
if !exist {
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
if itemDataConfig == nil {
logger.Error("weapon config is nil, itemId: %v", itemId)
return
}