迁移配置表

This commit is contained in:
flswld
2023-01-18 15:38:50 +08:00
parent 62ae866b1e
commit a00bee14d0
882 changed files with 1639 additions and 324485 deletions

View File

@@ -17,7 +17,7 @@ func (c *CommandManager) GMTeleportPlayer(userId, sceneId uint32, posX, posY, po
X: posX,
Y: posY,
Z: posZ,
}, 0)
}, new(model.Vector), 0)
}
// GMAddUserItem 给予玩家物品

View File

@@ -3,6 +3,7 @@ package game
import (
"encoding/json"
"reflect"
"runtime"
"time"
appConfig "hk4e/common/config"
@@ -184,6 +185,7 @@ func (g *GameManager) gameMainLoop() {
tickCost := int64(0)
localEventCost := int64(0)
commandCost := int64(0)
runtime.LockOSThread()
for {
// 消耗CPU时间性能统计
now := time.Now().UnixNano()

View File

@@ -1,9 +1,10 @@
package game
import (
"time"
"hk4e/pkg/logger"
"hk4e/protocol/proto"
"time"
)
type GCGAi struct {

View File

@@ -1,14 +1,15 @@
package game
import (
"math/rand"
"time"
"hk4e/common/constant"
"hk4e/gdconf"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"math/rand"
"time"
)
// ControllerType 操控者类型

View File

@@ -2,7 +2,7 @@ package game
import (
"hk4e/common/constant"
gdc "hk4e/gs/config"
"hk4e/gdconf"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/pkg/object"
@@ -12,9 +12,9 @@ import (
pb "google.golang.org/protobuf/proto"
)
func (g *GameManager) GetAllAvatarDataConfig() map[int32]*gdc.AvatarData {
allAvatarDataConfig := make(map[int32]*gdc.AvatarData)
for avatarId, avatarData := range gdc.CONF.AvatarDataMap {
func (g *GameManager) GetAllAvatarDataConfig() map[int32]*gdconf.AvatarData {
allAvatarDataConfig := make(map[int32]*gdconf.AvatarData)
for avatarId, avatarData := range gdconf.CONF.AvatarDataMap {
if avatarId < 10000002 || avatarId >= 11000000 {
// 跳过无效角色
continue
@@ -43,7 +43,7 @@ func (g *GameManager) AddUserAvatar(userId uint32, avatarId uint32) {
player.AddAvatar(avatarId)
// 添加初始武器
avatarDataConfig, ok := gdc.CONF.AvatarDataMap[int32(avatarId)]
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(avatarId)]
if !ok {
logger.Error("config is nil, itemId: %v", avatarId)
return
@@ -210,15 +210,15 @@ func (g *GameManager) PacketAvatarEquipChangeNotify(avatar *model.Avatar, weapon
}
avatarEquipChangeNotify.Weapon = &proto.SceneWeaponInfo{
EntityId: entityId,
GadgetId: uint32(gdc.CONF.ItemDataMap[int32(weapon.ItemId)].GadgetId),
GadgetId: uint32(gdconf.CONF.ItemDataMap[int32(weapon.ItemId)].GadgetId),
ItemId: weapon.ItemId,
Guid: weapon.Guid,
Level: uint32(weapon.Level),
AbilityInfo: new(proto.AbilitySyncStateInfo),
}
itemDataConfig, ok := gdc.CONF.ItemDataMap[int32(weapon.ItemId)]
itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
if ok {
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.EquipEnumType)
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.EquipType)
}
return avatarEquipChangeNotify
}
@@ -227,9 +227,9 @@ func (g *GameManager) PacketAvatarEquipTakeOffNotify(avatar *model.Avatar, weapo
avatarEquipChangeNotify := &proto.AvatarEquipChangeNotify{
AvatarGuid: avatar.Guid,
}
itemDataConfig, ok := gdc.CONF.ItemDataMap[int32(weapon.ItemId)]
itemDataConfig, ok := gdconf.CONF.ItemDataMap[int32(weapon.ItemId)]
if ok {
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.EquipEnumType)
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.EquipType)
}
return avatarEquipChangeNotify
}
@@ -254,9 +254,9 @@ func (g *GameManager) UpdateUserAvatarFightProp(userId uint32, avatarId uint32)
func (g *GameManager) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
isFocus := false
// if avatar.AvatarId == 10000005 || avatar.AvatarId == 10000007 {
// isFocus = true
// }
if avatar.AvatarId == 10000005 || avatar.AvatarId == 10000007 {
isFocus = true
}
pbAvatar := &proto.AvatarInfo{
IsFocus: isFocus,
AvatarId: avatar.AvatarId,
@@ -279,13 +279,13 @@ func (g *GameManager) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
},
uint32(constant.PlayerPropertyConst.PROP_SATIATION_VAL): {
Type: uint32(constant.PlayerPropertyConst.PROP_SATIATION_VAL),
Val: 0,
Value: &proto.PropValue_Ival{Ival: 0},
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),
Val: 0,
Value: &proto.PropValue_Ival{Ival: 0},
Val: int64(avatar.SatiationPenalty),
Value: &proto.PropValue_Ival{Ival: int64(avatar.SatiationPenalty)},
},
},
LifeState: uint32(avatar.LifeState),
@@ -293,9 +293,8 @@ func (g *GameManager) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
FightPropMap: nil,
SkillDepotId: avatar.SkillDepotId,
FetterInfo: &proto.AvatarFetterInfo{
ExpLevel: uint32(avatar.FetterLevel),
ExpNumber: avatar.FetterExp,
// TODO 资料解锁条目
ExpLevel: uint32(avatar.FetterLevel),
ExpNumber: avatar.FetterExp,
FetterList: nil,
RewardedFetterLevelList: []uint32{10},
},
@@ -313,7 +312,7 @@ func (g *GameManager) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
})
}
// 解锁全部资料
for _, v := range gdc.CONF.AvatarFetterDataMap[int32(avatar.AvatarId)] {
for _, v := range gdconf.CONF.FetterDataAvatarIdMap[int32(avatar.AvatarId)] {
pbAvatar.FetterInfo.FetterList = append(pbAvatar.FetterInfo.FetterList, &proto.FetterData{
FetterId: uint32(v),
FetterState: uint32(constant.FetterStateConst.FINISH),

View File

@@ -297,6 +297,9 @@ func (g *GameManager) AoiPlayerMove(player *model.Player, oldPos *model.Vector,
continue
}
entityId := g.CreateConfigEntity(scene, newObjectId, newObject)
if entityId == 0 {
continue
}
addEntityIdList = append(addEntityIdList, entityId)
}
// 发送已消失格子里的实体消失通知

View File

@@ -328,14 +328,14 @@ func (g *GameManager) doGachaKlee() (bool, uint32) {
allAvatarList := make([]uint32, 0)
allAvatarDataConfig := g.GetAllAvatarDataConfig()
for k, v := range allAvatarDataConfig {
if v.QualityType == "QUALITY_ORANGE" || v.QualityType == "QUALITY_PURPLE" {
if v.QualityType == 5 || v.QualityType == 4 {
allAvatarList = append(allAvatarList, uint32(k))
}
}
allWeaponList := make([]uint32, 0)
allWeaponDataConfig := g.GetAllWeaponDataConfig()
for k, v := range allWeaponDataConfig {
if v.RankLevel == 5 {
if v.EquipLevel == 5 {
allWeaponList = append(allWeaponList, uint32(k))
}
}
@@ -476,13 +476,13 @@ func (g *GameManager) doGachaOnce(userId uint32, gachaType uint32, mustGetUpEnab
logger.Error("avatar data config not found, avatar id: %v", avatarId)
return false, 0
}
if avatarDataConfig.QualityType == "QUALITY_ORANGE" {
if avatarDataConfig.QualityType == 5 {
itemColor = Orange
logger.Debug("[orange avatar], times: %v, gachaItemId: %v", gachaPoolInfo.OrangeTimes, gachaItemId)
if gachaPoolInfo.OrangeTimes > 90 {
logger.Error("[abnormal orange avatar], times: %v, gachaItemId: %v", gachaPoolInfo.OrangeTimes, gachaItemId)
}
} else if avatarDataConfig.QualityType == "QUALITY_PURPLE" {
} else if avatarDataConfig.QualityType == 4 {
itemColor = Purple
logger.Debug("[purple avatar], times: %v, gachaItemId: %v", gachaPoolInfo.PurpleTimes, gachaItemId)
if gachaPoolInfo.PurpleTimes > 10 {
@@ -500,13 +500,13 @@ func (g *GameManager) doGachaOnce(userId uint32, gachaType uint32, mustGetUpEnab
logger.Error("weapon item data config not found, item id: %v", gachaItemId)
return false, 0
}
if weaponDataConfig.RankLevel == 5 {
if weaponDataConfig.EquipLevel == 5 {
itemColor = Orange
logger.Debug("[orange weapon], times: %v, gachaItemId: %v", gachaPoolInfo.OrangeTimes, gachaItemId)
if gachaPoolInfo.OrangeTimes > 90 {
logger.Error("[abnormal orange weapon], times: %v, gachaItemId: %v", gachaPoolInfo.OrangeTimes, gachaItemId)
}
} else if weaponDataConfig.RankLevel == 4 {
} else if weaponDataConfig.EquipLevel == 4 {
itemColor = Purple
logger.Debug("[purple weapon], times: %v, gachaItemId: %v", gachaPoolInfo.PurpleTimes, gachaItemId)
if gachaPoolInfo.PurpleTimes > 10 {

View File

@@ -58,7 +58,7 @@ func (g *GameManager) GCGStartChallenge(player *model.Player) {
GAME_MANAGER.SendMsg(cmd.GCGGameBriefDataNotify, player.PlayerID, player.ClientSeq, g.PacketGCGGameBriefDataNotify(player, proto.GCGGameBusinessType_GCG_GAME_BUSINESS_TYPE_GUIDE_GROUP, game))
// 玩家进入GCG界面
g.TeleportPlayer(player, constant.EnterReasonConst.DungeonEnter, 79999, new(model.Vector), 2162)
g.TeleportPlayer(player, constant.EnterReasonConst.DungeonEnter, 79999, new(model.Vector), new(model.Vector), 2162)
}
// GCGAskDuelReq GCG决斗请求

View File

@@ -2,7 +2,7 @@ package game
import (
"hk4e/common/constant"
gdc "hk4e/gs/config"
"hk4e/gdconf"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
@@ -13,14 +13,14 @@ type UserItem struct {
ChangeCount uint32
}
func (g *GameManager) GetAllItemDataConfig() map[int32]*gdc.ItemData {
allItemDataConfig := make(map[int32]*gdc.ItemData)
for itemId, itemData := range gdc.CONF.ItemDataMap {
if itemData.ItemEnumType == constant.ItemTypeConst.ITEM_WEAPON {
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 {
// 排除武器
continue
}
if itemData.ItemEnumType == constant.ItemTypeConst.ITEM_RELIQUARY {
if uint16(itemData.Type) == constant.ItemTypeConst.ITEM_RELIQUARY {
// 排除圣遗物
continue
}

View File

@@ -5,7 +5,7 @@ import (
"hk4e/common/constant"
"hk4e/common/mq"
gdc "hk4e/gs/config"
"hk4e/gdconf"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/pkg/reflection"
@@ -193,7 +193,7 @@ func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.Playe
StoreType: proto.StoreType_STORE_TYPE_PACK,
WeightLimit: 30000,
}
itemDataMapConfig := gdc.CONF.ItemDataMap
itemDataMapConfig := gdconf.CONF.ItemDataMap
for _, weapon := range player.WeaponMap {
pbItem := &proto.Item{
ItemId: weapon.ItemId,
@@ -205,7 +205,7 @@ func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.Playe
logger.Error("config is nil, itemId: %v", weapon.ItemId)
return nil
}
if itemData.ItemEnumType != constant.ItemTypeConst.ITEM_WEAPON {
if uint16(itemData.Type) != constant.ItemTypeConst.ITEM_WEAPON {
continue
}
affixMap := make(map[uint32]uint32)
@@ -233,19 +233,18 @@ func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.Playe
Guid: reliquary.Guid,
Detail: nil,
}
if itemDataMapConfig[int32(reliquary.ItemId)].ItemEnumType != constant.ItemTypeConst.ITEM_RELIQUARY {
if uint16(itemDataMapConfig[int32(reliquary.ItemId)].Type) != constant.ItemTypeConst.ITEM_RELIQUARY {
continue
}
pbItem.Detail = &proto.Item_Equip{
Equip: &proto.Equip{
Detail: &proto.Equip_Reliquary{
Reliquary: &proto.Reliquary{
Level: uint32(reliquary.Level),
Exp: reliquary.Exp,
PromoteLevel: uint32(reliquary.Promote),
MainPropId: reliquary.MainPropId,
// TODO 圣遗物副词条
AppendPropIdList: nil,
Level: uint32(reliquary.Level),
Exp: reliquary.Exp,
PromoteLevel: uint32(reliquary.Promote),
MainPropId: reliquary.MainPropId,
AppendPropIdList: reliquary.AffixIdList,
},
},
IsLocked: reliquary.Lock,
@@ -260,7 +259,7 @@ func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.Playe
Detail: nil,
}
itemDataConfig := itemDataMapConfig[int32(item.ItemId)]
if itemDataConfig != nil && itemDataConfig.ItemEnumType == constant.ItemTypeConst.ITEM_FURNITURE {
if itemDataConfig != nil && uint16(itemDataConfig.Type) == constant.ItemTypeConst.ITEM_FURNITURE {
pbItem.Detail = &proto.Item_Furniture{
Furniture: &proto.Furniture{
Count: item.Count,
@@ -312,6 +311,7 @@ func (g *GameManager) PacketOpenStateUpdateNotify() *proto.OpenStateUpdateNotify
OpenStateMap: make(map[uint32]uint32),
}
openStateConstMap := reflection.ConvStructToMap(constant.OpenStateConst)
// 先暂时开放全部功能模块
for _, v := range openStateConstMap {
openStateUpdateNotify.OpenStateMap[uint32(v.(uint16))] = 1
}
@@ -340,6 +340,7 @@ func (g *GameManager) CreatePlayer(userId uint32, nickName string, mainCharAvata
// 初始化所有属性
propList := reflection.ConvStructToMap(constant.PlayerPropertyConst)
for fieldName, fieldValue := range propList {
// 排除角色相关的属性
if fieldName == "PROP_EXP" ||
fieldName == "PROP_BREAK_LEVEL" ||
fieldName == "PROP_SATIATION_VAL" ||
@@ -402,7 +403,7 @@ func (g *GameManager) CreatePlayer(userId uint32, nickName string, mainCharAvata
// 添加选定的主角
player.AddAvatar(mainCharAvatarId)
// 添加初始武器
avatarDataConfig, ok := gdc.CONF.AvatarDataMap[int32(mainCharAvatarId)]
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(mainCharAvatarId)]
if !ok {
logger.Error("config is nil, mainCharAvatarId: %v", mainCharAvatarId)
return nil
@@ -412,6 +413,8 @@ func (g *GameManager) CreatePlayer(userId uint32, nickName string, mainCharAvata
// 角色装上初始武器
player.WearWeapon(mainCharAvatarId, weaponId)
player.AddReliquary(24825, uint64(g.snowflake.GenId()), 15007)
player.TeamConfig = model.NewTeamInfo()
player.TeamConfig.GetActiveTeam().SetAvatarIdList([]uint32{mainCharAvatarId})

View File

@@ -4,7 +4,7 @@ import (
"strconv"
"hk4e/common/constant"
gdc "hk4e/gs/config"
"hk4e/gdconf"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
@@ -17,8 +17,12 @@ 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)
transPointId := strconv.Itoa(int(req.SceneId)) + "_" + strconv.Itoa(int(req.PointId))
transPointConfig, exist := gdc.CONF.ScenePointEntries[transPointId]
scenePointConfig, exist := gdconf.CONF.ScenePointMap[int32(req.SceneId)]
if !exist {
g.CommonRetError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{})
return
}
pointConfig, exist := scenePointConfig.PointMap[int32(req.PointId)]
if !exist {
g.CommonRetError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{})
return
@@ -26,13 +30,15 @@ func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.M
// 传送玩家
sceneId := req.SceneId
transPos := transPointConfig.PointData.TranPos
pos := &model.Vector{
X: transPos.X,
Y: transPos.Y,
Z: transPos.Z,
}
g.TeleportPlayer(player, constant.EnterReasonConst.TransPoint, sceneId, pos, 0)
g.TeleportPlayer(player, constant.EnterReasonConst.TransPoint, sceneId, &model.Vector{
X: pointConfig.TranPos.X,
Y: pointConfig.TranPos.Y,
Z: pointConfig.TranPos.Z,
}, &model.Vector{
X: pointConfig.TranRot.X,
Y: pointConfig.TranRot.Y,
Z: pointConfig.TranRot.Z,
}, 0)
sceneTransToPointRsp := &proto.SceneTransToPointRsp{
PointId: req.PointId,
@@ -54,18 +60,17 @@ func (g *GameManager) MarkMapReq(player *model.Player, payloadMsg pb.Message) {
posYInt = 300
}
// 传送玩家
pos := &model.Vector{
g.TeleportPlayer(player, constant.EnterReasonConst.Gm, req.Mark.SceneId, &model.Vector{
X: float64(req.Mark.Pos.X),
Y: float64(posYInt),
Z: float64(req.Mark.Pos.Z),
}
g.TeleportPlayer(player, constant.EnterReasonConst.Gm, req.Mark.SceneId, pos, 0)
}, new(model.Vector), 0)
}
}
}
// TeleportPlayer 传送玩家至地图上的某个位置
func (g *GameManager) TeleportPlayer(player *model.Player, enterReason uint16, sceneId uint32, pos *model.Vector, dungeonId uint32) {
func (g *GameManager) TeleportPlayer(player *model.Player, enterReason uint16, sceneId uint32, pos, rot *model.Vector, dungeonId uint32) {
// 传送玩家
newSceneId := sceneId
oldSceneId := player.SceneId
@@ -96,6 +101,9 @@ func (g *GameManager) TeleportPlayer(player *model.Player, enterReason uint16, s
player.Pos.X = pos.X
player.Pos.Y = pos.Y
player.Pos.Z = pos.Z
player.Rot.X = rot.X
player.Rot.Y = rot.Y
player.Rot.Z = rot.Z
var enterType proto.EnterType
switch enterReason {
@@ -119,21 +127,30 @@ func (g *GameManager) GetScenePointReq(player *model.Player, payloadMsg pb.Messa
logger.Debug("user get scene point, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.GetScenePointReq)
if req.SceneId != 3 {
getScenePointRsp := &proto.GetScenePointRsp{
SceneId: req.SceneId,
}
g.SendMsg(cmd.GetScenePointRsp, player.PlayerID, player.ClientSeq, getScenePointRsp)
scenePointConfig, exist := gdconf.CONF.ScenePointMap[int32(req.SceneId)]
if !exist {
return
}
getScenePointRsp := &proto.GetScenePointRsp{
SceneId: 3,
UnlockAreaList: []uint32{12, 11, 19, 28, 5, 1, 24, 10, 21, 2, 7, 18, 3, 26, 6, 17, 22, 20, 9, 14, 16, 8, 13, 4, 27, 23},
UnlockedPointList: []uint32{553, 155, 58, 257, 38, 135, 528, 329, 13, 212, 401, 3, 600, 545, 589, 180, 416, 7, 615, 206, 400, 599, 114, 12, 211, 104, 502, 93, 325, 540, 131, 320, 519, 121, 616, 218, 606, 197, 208, 703, 305, 499, 254, 652, 60, 458, 282, 691, 167, 366, 323, 32, 319, 222, 181, 380, 612, 234, 433, 391, 488, 79, 338, 139, 241, 42, 57, 256, 154, 353, 588, 491, 82, 209, 10, 500, 91, 301, 489, 4, 392, 536, 127, 337, 605, 8, 487, 78, 228, 626, 598, 1, 200, 137, 336, 535, 382, 310, 509, 100, 498, 14, 213, 625, 361, 471, 674, 475, 603, 6, 205, 485, 76, 77, 486, 359, 165, 364, 317, 271, 384, 72, 481, 253, 156, 350, 45, 244, 516, 107, 306, 296, 97, 162, 571, 495, 86, 44, 248, 646, 539, 221, 22, 318, 706, 308, 507, 103, 302, 258, 442, 33, 324, 393, 61, 255, 655, 246, 385, 73, 482, 551, 153, 363, 35, 444, 245, 439, 251, 445, 36, 235, 15, 424, 225, 214, 623, 327, 537, 128, 542, 133, 332, 322, 31, 20, 429, 432, 443, 34, 59, 468, 604, 405, 515, 316, 117, 321, 122, 249, 459, 50, 29, 438, 40, 330, 116, 326, 503, 304, 514, 105, 550, 351, 152, 586, 387, 250, 541, 328, 236, 435, 247, 48, 37, 446, 538, 339, 11, 210, 476, 379, 671, 477, 676, 242, 168, 577, 378, 383, 81, 490, 501, 92, 331, 543, 252, 87, 496, 463, 307, 484, 75, 505, 96, 534, 555, 146, 462, 365, 381, 182, 166, 575, 69, 478, 494, 85, 74, 483, 368, 465, 386, 95, 84, 493, 396, 587, 5, 602, 204, 99, 497, 298, 492, 702, 293},
LockedPointList: []uint32{173, 398, 627, 223, 417, 419, 231, 278, 699, 408, 276, 229, 520, 512, 415, 113, 274, 565, 344, 436, 394, 403, 262, 430, 195, 412, 315, 233, 440, 52, 409, 334, 193, 240, 566, 469, 187, 704, 413, 346, 259, 447, 286, 102, 345, 580, 411, 129, 578, 202, 682, 294, 570, 414, 511, 622, 428, 449, 426, 238, 265, 273, 564, 467, 563, 175, 269, 457, 574, 89, 388, 291, 707, 125, 559, 268, 656, 183, 280, 267, 357, 260, 354, 451, 410, 119, 216},
HidePointList: []uint32{458, 515, 459, 514},
GroupUnlimitPointList: []uint32{221, 131, 107, 350, 50, 424, 359},
SceneId: req.SceneId,
}
areaIdMap := make(map[uint32]bool)
for _, worldAreaData := range gdconf.CONF.WorldAreaDataMap {
if uint32(worldAreaData.SceneId) == req.SceneId {
areaIdMap[uint32(worldAreaData.AreaId1)] = true
}
}
areaList := make([]uint32, 0)
for areaId := range areaIdMap {
areaList = append(areaList, areaId)
}
getScenePointRsp.UnlockAreaList = areaList
for _, pointData := range scenePointConfig.PointMap {
if pointData.PointType == gdconf.PointTypeOther {
continue
}
getScenePointRsp.UnlockedPointList = append(getScenePointRsp.UnlockedPointList, uint32(pointData.Id))
}
g.SendMsg(cmd.GetScenePointRsp, player.PlayerID, player.ClientSeq, getScenePointRsp)
}
@@ -142,18 +159,22 @@ func (g *GameManager) GetSceneAreaReq(player *model.Player, payloadMsg pb.Messag
logger.Debug("user get scene area, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.GetSceneAreaReq)
if req.SceneId != 3 {
getSceneAreaRsp := &proto.GetSceneAreaRsp{
SceneId: req.SceneId,
}
g.SendMsg(cmd.GetSceneAreaRsp, player.PlayerID, player.ClientSeq, getSceneAreaRsp)
return
}
getSceneAreaRsp := &proto.GetSceneAreaRsp{
SceneId: 3,
AreaIdList: []uint32{12, 11, 19, 28, 5, 1, 24, 10, 21, 2, 7, 18, 3, 26, 6, 17, 22, 20, 9, 14, 16, 8, 13, 4, 27, 23},
CityInfoList: []*proto.CityInfo{
SceneId: req.SceneId,
}
areaIdMap := make(map[uint32]bool)
for _, worldAreaData := range gdconf.CONF.WorldAreaDataMap {
if uint32(worldAreaData.SceneId) == req.SceneId {
areaIdMap[uint32(worldAreaData.AreaId1)] = true
}
}
areaList := make([]uint32, 0)
for areaId := range areaIdMap {
areaList = append(areaList, areaId)
}
getSceneAreaRsp.AreaIdList = areaList
if req.SceneId == 3 {
getSceneAreaRsp.CityInfoList = []*proto.CityInfo{
{CityId: 1, Level: 10},
{CityId: 2, Level: 10},
{CityId: 3, Level: 10},
@@ -162,7 +183,20 @@ func (g *GameManager) GetSceneAreaReq(player *model.Player, payloadMsg pb.Messag
{CityId: 100, Level: 1},
{CityId: 101, Level: 1},
{CityId: 102, Level: 1},
},
}
}
g.SendMsg(cmd.GetSceneAreaRsp, player.PlayerID, player.ClientSeq, getSceneAreaRsp)
}
func (g *GameManager) EnterWorldAreaReq(player *model.Player, payloadMsg pb.Message) {
logger.Debug("user enter world area, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.EnterWorldAreaReq)
logger.Debug("EnterWorldAreaReq: %v", req)
enterWorldAreaRsp := &proto.EnterWorldAreaRsp{
AreaType: req.AreaType,
AreaId: req.AreaId,
}
g.SendMsg(cmd.EnterWorldAreaRsp, player.PlayerID, player.ClientSeq, enterWorldAreaRsp)
}

View File

@@ -7,7 +7,6 @@ import (
"hk4e/common/constant"
"hk4e/gdconf"
gdc "hk4e/gs/config"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/pkg/object"
@@ -86,15 +85,22 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
playerWorldSceneInfoListNotify := &proto.PlayerWorldSceneInfoListNotify{
InfoList: []*proto.PlayerWorldSceneInfo{
{SceneId: 1, IsLocked: true, SceneTagIdList: []uint32{}},
{SceneId: 3, IsLocked: false, SceneTagIdList: []uint32{102, 111, 112, 116, 118, 126, 135, 140, 142, 149, 1091, 1094, 1095, 1099, 1101, 1103, 1105, 1110, 1120, 1122, 1125, 1127, 1129, 1131, 1133, 1135, 1137, 1138, 1140, 1143, 1146, 1165, 1168}},
{SceneId: 4, IsLocked: true, SceneTagIdList: []uint32{}},
{SceneId: 5, IsLocked: false, SceneTagIdList: []uint32{121, 1031}},
{SceneId: 6, IsLocked: false, SceneTagIdList: []uint32{144, 146, 1062, 1063}},
{SceneId: 7, IsLocked: true, SceneTagIdList: []uint32{136, 137, 138, 148, 1034}},
{SceneId: 9, IsLocked: true, SceneTagIdList: []uint32{1012, 1016, 1021, 1022, 1060, 1077}},
{SceneId: 1, IsLocked: false, SceneTagIdList: []uint32{}},
{SceneId: 3, IsLocked: false, SceneTagIdList: []uint32{}},
{SceneId: 4, IsLocked: false, SceneTagIdList: []uint32{}},
{SceneId: 5, IsLocked: false, SceneTagIdList: []uint32{}},
{SceneId: 6, IsLocked: false, SceneTagIdList: []uint32{}},
{SceneId: 7, IsLocked: false, SceneTagIdList: []uint32{}},
{SceneId: 9, IsLocked: false, SceneTagIdList: []uint32{}},
},
}
for _, info := range playerWorldSceneInfoListNotify.InfoList {
for _, sceneTagDataConfig := range gdconf.CONF.SceneTagDataMap {
if uint32(sceneTagDataConfig.SceneId) == info.SceneId {
info.SceneTagIdList = append(info.SceneTagIdList, uint32(sceneTagDataConfig.SceneTagId))
}
}
}
g.SendMsg(cmd.PlayerWorldSceneInfoListNotify, player.PlayerID, player.ClientSeq, playerWorldSceneInfoListNotify)
g.SendMsg(cmd.SceneForceUnlockNotify, player.PlayerID, player.ClientSeq, new(proto.SceneForceUnlockNotify))
@@ -226,46 +232,6 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
player.SceneLoadState = model.SceneInitFinish
}
func (g *GameManager) CreateConfigEntity(scene *Scene, objectId int64, entityConfig any) uint32 {
switch entityConfig.(type) {
case *gdconf.Monster:
monster := entityConfig.(*gdconf.Monster)
return scene.CreateEntityMonster(&model.Vector{
X: monster.Pos.X,
Y: monster.Pos.Y,
Z: monster.Pos.Z,
}, &model.Vector{
X: monster.Rot.X,
Y: monster.Rot.Y,
Z: monster.Rot.Z,
}, uint32(monster.MonsterId), uint8(monster.Level), g.GetTempFightPropMap(), uint32(monster.ConfigId), objectId)
case *gdconf.Npc:
npc := entityConfig.(*gdconf.Npc)
return scene.CreateEntityNpc(&model.Vector{
X: npc.Pos.X,
Y: npc.Pos.Y,
Z: npc.Pos.Z,
}, &model.Vector{
X: npc.Rot.X,
Y: npc.Rot.Y,
Z: npc.Rot.Z,
}, uint32(npc.NpcId), 0, 0, 0, uint32(npc.ConfigId), objectId)
case *gdconf.Gadget:
gadget := entityConfig.(*gdconf.Gadget)
return scene.CreateEntityGadgetNormal(&model.Vector{
X: gadget.Pos.X,
Y: gadget.Pos.Y,
Z: gadget.Pos.Z,
}, &model.Vector{
X: gadget.Rot.X,
Y: gadget.Rot.Y,
Z: gadget.Rot.Z,
}, uint32(gadget.GadgetId), uint32(gadget.ConfigId), objectId)
default:
return 0
}
}
func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
logger.Debug("user enter scene done, uid: %v", player.PlayerID)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
@@ -302,7 +268,14 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
} else {
visionType = proto.VisionType_VISION_TYPE_TRANSPORT
}
entityIdList := scene.GetEntityIdList()
entityMap := scene.GetAllEntity()
entityIdList := make([]uint32, 0)
for _, entity := range entityMap {
if entity.id == activeAvatarEntityId {
continue
}
entityIdList = append(entityIdList, entity.id)
}
g.AddSceneEntityNotify(player, visionType, entityIdList, false, false)
sceneAreaWeatherNotify := &proto.SceneAreaWeatherNotify{
@@ -340,19 +313,6 @@ func (g *GameManager) PostEnterSceneReq(player *model.Player, payloadMsg pb.Mess
g.SendMsg(cmd.PostEnterSceneRsp, player.PlayerID, player.ClientSeq, postEnterSceneRsp)
}
func (g *GameManager) EnterWorldAreaReq(player *model.Player, payloadMsg pb.Message) {
logger.Debug("user enter world area, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.EnterWorldAreaReq)
logger.Debug("EnterWorldAreaReq: %v", req)
enterWorldAreaRsp := &proto.EnterWorldAreaRsp{
AreaType: req.AreaType,
AreaId: req.AreaId,
}
g.SendMsg(cmd.EnterWorldAreaRsp, player.PlayerID, player.ClientSeq, enterWorldAreaRsp)
}
func (g *GameManager) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Message) {
logger.Debug("user change game time, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.ChangeGameTimeReq)
@@ -375,6 +335,76 @@ func (g *GameManager) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Mess
g.SendMsg(cmd.ChangeGameTimeRsp, player.PlayerID, player.ClientSeq, changeGameTimeRsp)
}
// SceneEntityDrownReq 实体溺水请求
func (g *GameManager) SceneEntityDrownReq(player *model.Player, payloadMsg pb.Message) {
req := payloadMsg.(*proto.SceneEntityDrownReq)
logger.Error("entity drown, entityId: %v", req.EntityId)
// PacketSceneEntityDrownRsp
sceneEntityDrownRsp := new(proto.SceneEntityDrownRsp)
sceneEntityDrownRsp.EntityId = req.EntityId
g.SendMsg(cmd.SceneEntityDrownRsp, player.PlayerID, player.ClientSeq, sceneEntityDrownRsp)
}
// CreateConfigEntity 创建配置表里的实体
func (g *GameManager) CreateConfigEntity(scene *Scene, objectId int64, entityConfig any) uint32 {
switch entityConfig.(type) {
case *gdconf.Monster:
monster := entityConfig.(*gdconf.Monster)
return scene.CreateEntityMonster(&model.Vector{
X: monster.Pos.X,
Y: monster.Pos.Y,
Z: monster.Pos.Z,
}, &model.Vector{
X: monster.Rot.X,
Y: monster.Rot.Y,
Z: monster.Rot.Z,
}, uint32(monster.MonsterId), uint8(monster.Level), g.GetTempFightPropMap(), uint32(monster.ConfigId), objectId)
case *gdconf.Npc:
npc := entityConfig.(*gdconf.Npc)
return scene.CreateEntityNpc(&model.Vector{
X: npc.Pos.X,
Y: npc.Pos.Y,
Z: npc.Pos.Z,
}, &model.Vector{
X: npc.Rot.X,
Y: npc.Rot.Y,
Z: npc.Rot.Z,
}, uint32(npc.NpcId), 0, 0, 0, uint32(npc.ConfigId), objectId)
case *gdconf.Gadget:
gadget := entityConfig.(*gdconf.Gadget)
// 70500000并不是实际的装置id 根据节点类型对应采集物配置表
if gadget.PointType != 0 && gadget.GadgetId == 70500000 {
gatherDataConfig, exist := gdconf.CONF.GatherDataPointTypeMap[gadget.PointType]
if !exist {
return 0
}
return scene.CreateEntityGadgetGather(&model.Vector{
X: gadget.Pos.X,
Y: gadget.Pos.Y,
Z: gadget.Pos.Z,
}, &model.Vector{
X: gadget.Rot.X,
Y: gadget.Rot.Y,
Z: gadget.Rot.Z,
}, uint32(gatherDataConfig.GadgetId), uint32(gatherDataConfig.GatherId), uint32(gadget.ConfigId), objectId)
} else {
return scene.CreateEntityGadgetNormal(&model.Vector{
X: gadget.Pos.X,
Y: gadget.Pos.Y,
Z: gadget.Pos.Z,
}, &model.Vector{
X: gadget.Rot.X,
Y: gadget.Rot.Y,
Z: gadget.Rot.Z,
}, uint32(gadget.GadgetId), uint32(gadget.ConfigId), objectId)
}
default:
return 0
}
}
func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType proto.EnterType) *proto.PlayerEnterSceneNotify {
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId)
@@ -390,12 +420,17 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, en
EnterReason: uint32(constant.EnterReasonConst.Login),
IsFirstLoginEnterScene: true,
WorldType: 1,
SceneTagIdList: make([]uint32, 0),
}
playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(player.SceneId)) + "-" +
strconv.Itoa(int(player.PlayerID)) + "-" +
strconv.Itoa(int(time.Now().Unix())) + "-" +
"296359"
playerEnterSceneNotify.SceneTagIdList = []uint32{102, 111, 112, 116, 118, 126, 135, 140, 142, 149, 1091, 1094, 1095, 1099, 1101, 1103, 1105, 1110, 1120, 1122, 1125, 1127, 1129, 1131, 1133, 1135, 1137, 1138, 1140, 1143, 1146, 1165, 1168}
for _, sceneTagDataConfig := range gdconf.CONF.SceneTagDataMap {
if uint32(sceneTagDataConfig.SceneId) == player.SceneId {
playerEnterSceneNotify.SceneTagIdList = append(playerEnterSceneNotify.SceneTagIdList, uint32(sceneTagDataConfig.SceneTagId))
}
}
return playerEnterSceneNotify
}
@@ -435,13 +470,16 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyMp(
EnterReason: enterReason,
WorldType: 1,
DungeonId: dungeonId,
SceneTagIdList: make([]uint32, 0),
}
playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(player.SceneId)) + "-" +
strconv.Itoa(int(targetPlayer.PlayerID)) + "-" +
strconv.Itoa(int(time.Now().Unix())) + "-" +
"296359"
if player.SceneId == 3 {
playerEnterSceneNotify.SceneTagIdList = []uint32{102, 111, 112, 116, 118, 126, 135, 140, 142, 149, 1091, 1094, 1095, 1099, 1101, 1103, 1105, 1110, 1120, 1122, 1125, 1127, 1129, 1131, 1133, 1135, 1137, 1138, 1140, 1143, 1146, 1165, 1168}
for _, sceneTagDataConfig := range gdconf.CONF.SceneTagDataMap {
if uint32(sceneTagDataConfig.SceneId) == player.SceneId {
playerEnterSceneNotify.SceneTagIdList = append(playerEnterSceneNotify.SceneTagIdList, uint32(sceneTagDataConfig.SceneTagId))
}
}
return playerEnterSceneNotify
}
@@ -605,18 +643,6 @@ func (g *GameManager) PacketFightPropMapToPbFightPropList(fightPropMap map[uint3
return fightPropList
}
// SceneEntityDrownReq 实体溺水请求
func (g *GameManager) SceneEntityDrownReq(player *model.Player, payloadMsg pb.Message) {
req := payloadMsg.(*proto.SceneEntityDrownReq)
logger.Error("entity drown, entityId: %v", req.EntityId)
// PacketSceneEntityDrownRsp
sceneEntityDrownRsp := new(proto.SceneEntityDrownRsp)
sceneEntityDrownRsp.EntityId = req.EntityId
g.SendMsg(cmd.SceneEntityDrownRsp, player.PlayerID, player.ClientSeq, sceneEntityDrownRsp)
}
func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Player, avatarId uint32) *proto.SceneEntityInfo {
entity := scene.GetEntity(scene.world.GetPlayerWorldAvatarEntityId(player, avatarId))
if entity == nil {
@@ -851,7 +877,7 @@ func (g *GameManager) PacketSceneAvatarInfo(scene *Scene, player *model.Player,
SkillDepotId: player.AvatarMap[avatarId].SkillDepotId,
Weapon: &proto.SceneWeaponInfo{
EntityId: scene.world.GetPlayerWorldAvatarWeaponEntityId(player, avatarId),
GadgetId: uint32(gdc.CONF.ItemDataMap[int32(weapon.ItemId)].GadgetId),
GadgetId: uint32(gdconf.CONF.ItemDataMap[int32(weapon.ItemId)].GadgetId),
ItemId: weapon.ItemId,
Guid: weapon.Guid,
Level: uint32(weapon.Level),
@@ -905,7 +931,7 @@ func (g *GameManager) PacketSceneGadgetInfoNormal(entity *Entity) *proto.SceneGa
}
func (g *GameManager) PacketSceneGadgetInfoGather(entity *Entity) *proto.SceneGadgetInfo {
gather, ok := gdc.CONF.GatherDataMap[int32(entity.gadgetEntity.gadgetGatherEntity.gatherId)]
gather, ok := gdconf.CONF.GatherDataMap[int32(entity.gadgetEntity.gadgetGatherEntity.gatherId)]
if !ok {
logger.Error("gather data error, gatherId: %v", entity.gadgetEntity.gadgetGatherEntity.gatherId)
return new(proto.SceneGadgetInfo)

View File

@@ -491,7 +491,7 @@ func (g *GameManager) DrownBackHandler(player *model.Player) {
// }
// }
// 传送玩家至安全位置
g.TeleportPlayer(player, constant.EnterReasonConst.Revival, player.SceneId, pos, 0)
g.TeleportPlayer(player, constant.EnterReasonConst.Revival, player.SceneId, pos, new(model.Vector), 0)
}
// 防止重置后又被修改
if player.StaminaInfo.DrownBackDelay != 0 {

View File

@@ -2,7 +2,7 @@ package game
import (
"hk4e/common/constant"
gdc "hk4e/gs/config"
"hk4e/gdconf"
"hk4e/gs/model"
"hk4e/pkg/endec"
"hk4e/pkg/logger"
@@ -244,12 +244,12 @@ func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeam
sceneTeamAvatar.SceneAvatarInfo = g.PacketSceneAvatarInfo(worldPlayerScene, worldPlayer, worldAvatar.avatarId)
}
// add AbilityControlBlock
avatarDataConfig := gdc.CONF.AvatarDataMap[int32(worldAvatar.avatarId)]
avatarDataConfig := gdconf.CONF.AvatarDataMap[int32(worldAvatar.avatarId)]
acb := sceneTeamAvatar.AbilityControlBlock
embryoId := 0
// add avatar abilities
if avatarDataConfig != nil {
for _, abilityId := range avatarDataConfig.Abilities {
for _, abilityId := range avatarDataConfig.AbilityHashCodeList {
embryoId++
emb := &proto.AbilityEmbryo{
AbilityId: uint32(embryoId),
@@ -280,9 +280,9 @@ func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeam
// acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, emb)
// }
// add skill depot abilities
skillDepot := gdc.CONF.AvatarSkillDepotDataMap[int32(worldPlayerAvatar.SkillDepotId)]
if skillDepot != nil && len(skillDepot.Abilities) != 0 {
for _, id := range skillDepot.Abilities {
skillDepot := gdconf.CONF.AvatarSkillDepotDataMap[int32(worldPlayerAvatar.SkillDepotId)]
if skillDepot != nil && len(skillDepot.AbilityHashCodeList) != 0 {
for _, id := range skillDepot.AbilityHashCodeList {
embryoId++
emb := &proto.AbilityEmbryo{
AbilityId: uint32(embryoId),

View File

@@ -2,16 +2,16 @@ package game
import (
"hk4e/common/constant"
gdc "hk4e/gs/config"
"hk4e/gdconf"
"hk4e/pkg/logger"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
)
func (g *GameManager) GetAllWeaponDataConfig() map[int32]*gdc.ItemData {
allWeaponDataConfig := make(map[int32]*gdc.ItemData)
for itemId, itemData := range gdc.CONF.ItemDataMap {
if itemData.EquipEnumType != constant.EquipTypeConst.EQUIP_WEAPON {
func (g *GameManager) GetAllWeaponDataConfig() map[int32]*gdconf.ItemData {
allWeaponDataConfig := make(map[int32]*gdconf.ItemData)
for itemId, itemData := range gdconf.CONF.ItemDataMap {
if uint16(itemData.EquipType) != constant.EquipTypeConst.EQUIP_WEAPON {
continue
}
if (itemId >= 10000 && itemId <= 10008) ||

View File

@@ -190,7 +190,7 @@ func (t *TickManager) onTickMinute(now int64) {
return
}
// TODO 3.0.0REL版本中 发送某些无效家具 可能会导致客户端背包家具界面卡死
if itemDataConfig.ItemEnumType == constant.ItemTypeConst.ITEM_FURNITURE {
if uint16(itemDataConfig.Type) == constant.ItemTypeConst.ITEM_FURNITURE {
continue
}
num := random.GetRandomInt32(1, 9)

View File

@@ -1142,11 +1142,3 @@ func (s *Scene) GetEntity(entityId uint32) *Entity {
func (s *Scene) GetEntityByObjectId(objectId int64) *Entity {
return s.objectIdEntityMap[objectId]
}
func (s *Scene) GetEntityIdList() []uint32 {
entityIdList := make([]uint32, 0)
for k := range s.entityMap {
entityIdList = append(entityIdList, k)
}
return entityIdList
}