diff --git a/common/constant/quest_type.go b/common/constant/quest_type.go index 887c7dc0..7445893c 100644 --- a/common/constant/quest_type.go +++ b/common/constant/quest_type.go @@ -8,6 +8,18 @@ const ( QUEST_STATE_FAILED = 4 ) +const ( + QUEST_LOGIC_TYPE_NONE = 0 + QUEST_LOGIC_TYPE_AND = 1 + QUEST_LOGIC_TYPE_OR = 2 + QUEST_LOGIC_TYPE_NOT = 3 + QUEST_LOGIC_TYPE_A_AND_ETCOR = 4 + QUEST_LOGIC_TYPE_A_AND_B_AND_ETCOR = 5 + QUEST_LOGIC_TYPE_A_OR_ETCAND = 6 + QUEST_LOGIC_TYPE_A_OR_B_OR_ETCAND = 7 + QUEST_LOGIC_TYPE_A_AND_B_OR_ETCAND = 8 +) + const ( QUEST_ACCEPT_COND_TYPE_NONE = 0 QUEST_ACCEPT_COND_TYPE_STATE_EQUAL = 1 diff --git a/dispatch/controller/gate_controller.go b/dispatch/controller/gate_controller.go index 8814b0fc..2c4e8ccb 100644 --- a/dispatch/controller/gate_controller.go +++ b/dispatch/controller/gate_controller.go @@ -52,7 +52,7 @@ func (c *Controller) gateTokenVerify(context *gin.Context) { verifyFail(account.PlayerID) return } - if time.Now().UnixMilli()-int64(account.ComboTokenCreateTime) > time.Minute.Milliseconds()*5 { + if time.Now().UnixMilli()-int64(account.ComboTokenCreateTime) > time.Hour.Milliseconds()*24 { verifyFail(account.PlayerID) return } diff --git a/gs/game/player_avatar.go b/gs/game/player_avatar.go index e7ec2774..205f4c86 100644 --- a/gs/game/player_avatar.go +++ b/gs/game/player_avatar.go @@ -17,7 +17,7 @@ import ( func (g *GameManager) GetAllAvatarDataConfig() map[int32]*gdconf.AvatarData { allAvatarDataConfig := make(map[int32]*gdconf.AvatarData) for avatarId, avatarData := range gdconf.GetAvatarDataMap() { - if avatarId < 10000002 || avatarId >= 11000000 { + if avatarId <= 10000001 || avatarId >= 11000000 { // 跳过无效角色 continue } @@ -25,10 +25,6 @@ func (g *GameManager) GetAllAvatarDataConfig() map[int32]*gdconf.AvatarData { // 跳过主角 continue } - if avatarId >= 10000079 { - // 跳过后续版本的角色 - continue - } allAvatarDataConfig[avatarId] = avatarData } return allAvatarDataConfig diff --git a/gs/game/player_fight_sync.go b/gs/game/player_fight_sync.go index 29d237c0..09b8b8df 100644 --- a/gs/game/player_fight_sync.go +++ b/gs/game/player_fight_sync.go @@ -386,8 +386,6 @@ func (g *GameManager) AoiPlayerMove(player *model.Player, oldPos *model.Vector, g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, delEntityIdList) g.AddSceneEntityNotify(player, proto.VisionType_VISION_MEET, addEntityIdList, false, false) // 场景区域触发器 - dbQuest := player.GetDbQuest() - updateQuest := false for _, group := range newVisionGroupMap { for _, region := range group.RegionList { shape := alg.NewShape() @@ -443,7 +441,7 @@ func (g *GameManager) AoiPlayerMove(player *model.Player, oldPos *model.Vector, logger.Error("trigger action fail, trigger: %v, uid: %v", trigger, player.PlayerID) } } - updateQuest = g.TriggerFire(dbQuest, trigger) + g.TriggerFire(player, trigger) } } else if oldPosInRegion && !newPosInRegion { logger.Debug("player leave region: %v, uid: %v", region, player.PlayerID) @@ -473,38 +471,14 @@ func (g *GameManager) AoiPlayerMove(player *model.Player, oldPos *model.Vector, } } } - if updateQuest { - g.AcceptQuest(player, true) - } } -func (g *GameManager) TriggerFire(dbQuest *model.DbQuest, trigger *gdconf.Trigger) bool { - // TODO 这一块写得太炸裂了需要优化 - updateQuest := false +func (g *GameManager) TriggerFire(player *model.Player, trigger *gdconf.Trigger) { for _, triggerDataConfig := range gdconf.GetTriggerDataMap() { if triggerDataConfig.TriggerName == trigger.Name { - for _, quest := range dbQuest.GetQuestMap() { - questDataConfig := gdconf.GetQuestDataById(int32(quest.QuestId)) - if questDataConfig == nil { - continue - } - for _, questCond := range questDataConfig.FinishCondList { - if questCond.Type != constant.QUEST_FINISH_COND_TYPE_TRIGGER_FIRE { - continue - } - if len(questCond.Param) != 1 { - continue - } - if questCond.Param[0] != triggerDataConfig.TriggerId { - continue - } - dbQuest.ForceFinishQuest(quest.QuestId) - updateQuest = true - } - } + g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_TRIGGER_FIRE, triggerDataConfig.TriggerId) } } - return updateQuest } func (g *GameManager) AbilityInvocationsNotify(player *model.Player, payloadMsg pb.Message) { @@ -713,9 +687,12 @@ func (g *GameManager) EvtCreateGadgetNotify(player *model.Player, payloadMsg pb. } logger.Debug("EvtCreateGadgetNotify: %v", req) world := WORLD_MANAGER.GetWorldByID(player.WorldId) + if world == nil { + logger.Error("world is nil, WorldId: %v", player.WorldId) + return + } scene := world.GetSceneById(player.SceneId) - if scene == nil { - logger.Error("scene is nil, sceneId: %v", player.SceneId) + if req.InitPos == nil { return } scene.CreateEntityGadgetClient(&model.Vector{ diff --git a/gs/game/player_item.go b/gs/game/player_item.go index f8c422d6..fec7906d 100644 --- a/gs/game/player_item.go +++ b/gs/game/player_item.go @@ -24,25 +24,6 @@ func (g *GameManager) GetAllItemDataConfig() map[int32]*gdconf.ItemData { // 排除圣遗物 continue } - if itemId == 100086 || - itemId == 100087 || - (itemId >= 100100 && itemId <= 101000) || - (itemId >= 101106 && itemId <= 101110) || - itemId == 101306 || - (itemId >= 101500 && itemId <= 104000) || - itemId == 105001 || - itemId == 105004 || - (itemId >= 106000 && itemId <= 107000) || - itemId == 107011 || - itemId == 108000 || - (itemId >= 109000 && itemId <= 110000) || - (itemId >= 115000 && itemId <= 130000) || - (itemId >= 200200 && itemId <= 200899) || - itemId == 220050 || - itemId == 220054 { - // 排除无效道具 - continue - } allItemDataConfig[itemId] = itemData } return allItemDataConfig diff --git a/gs/game/player_login.go b/gs/game/player_login.go index aad757ce..3812c73d 100644 --- a/gs/game/player_login.go +++ b/gs/game/player_login.go @@ -50,6 +50,7 @@ func (g *GameManager) OnLoginOk(userId uint32, player *model.Player, clientSeq u g.SendMsgToGate(cmd.DoSetPlayerBornDataNotify, userId, clientSeq, gateAppId, new(proto.DoSetPlayerBornDataNotify)) return } + SELF = player player.OnlineTime = uint32(time.Now().UnixMilli()) player.Online = true @@ -80,6 +81,9 @@ func (g *GameManager) OnLoginOk(userId uint32, player *model.Player, clientSeq u return } + // TODO DEBUG DEL + g.AcceptQuest(player, false) + g.LoginNotify(userId, player, clientSeq) MESSAGE_QUEUE.SendToAll(&mq.NetMsg{ @@ -95,6 +99,8 @@ func (g *GameManager) OnLoginOk(userId uint32, player *model.Player, clientSeq u TICK_MANAGER.CreateUserTimer(userId, UserTimerActionTest, 100) atomic.AddInt32(&ONLINE_PLAYER_NUM, 1) + + SELF = nil } func (g *GameManager) OnReg(userId uint32, clientSeq uint32, gateAppId string, payloadMsg pb.Message) { diff --git a/gs/game/player_quest.go b/gs/game/player_quest.go index 64dec239..19840649 100644 --- a/gs/game/player_quest.go +++ b/gs/game/player_quest.go @@ -69,28 +69,60 @@ func (g *GameManager) AcceptQuest(player *model.Player, notifyClient bool) { if dbQuest.GetQuestById(uint32(questData.QuestId)) != nil { continue } - canAccept := true + acceptCondResultList := make([]bool, 0) for _, acceptCond := range questData.AcceptCondList { + result := false switch acceptCond.Type { case constant.QUEST_ACCEPT_COND_TYPE_STATE_EQUAL: // 某个任务状态等于 参数1:任务id 参数2:任务状态 if len(acceptCond.Param) != 2 { - logger.Error("quest accept cond config format error, questId: %v", questData.QuestId) - canAccept = false break } quest := dbQuest.GetQuestById(uint32(acceptCond.Param[0])) if quest == nil { - canAccept = false break } if quest.State != uint8(acceptCond.Param[1]) { + break + } + result = true + case constant.QUEST_ACCEPT_COND_TYPE_STATE_NOT_EQUAL: + // 某个任务状态不等于 参数1:任务id 参数2:任务状态 + if len(acceptCond.Param) != 2 { + break + } + quest := dbQuest.GetQuestById(uint32(acceptCond.Param[0])) + if quest == nil { + break + } + if quest.State == uint8(acceptCond.Param[1]) { + break + } + result = true + default: + break + } + acceptCondResultList = append(acceptCondResultList, result) + } + canAccept := false + switch questData.AcceptCondCompose { + case constant.QUEST_LOGIC_TYPE_NONE: + fallthrough + case constant.QUEST_LOGIC_TYPE_AND: + canAccept = true + for _, acceptCondResult := range acceptCondResultList { + if !acceptCondResult { canAccept = false break } - default: - canAccept = false - break + } + case constant.QUEST_LOGIC_TYPE_OR: + canAccept = false + for _, acceptCondResult := range acceptCondResultList { + if acceptCondResult { + canAccept = true + break + } } } if canAccept { @@ -115,6 +147,68 @@ func (g *GameManager) AcceptQuest(player *model.Player, notifyClient bool) { } } +// TriggerQuest 触发任务 +func (g *GameManager) TriggerQuest(player *model.Player, cond int32, param ...int32) { + dbQuest := player.GetDbQuest() + updateQuestIdList := make([]uint32, 0) + for _, quest := range dbQuest.GetQuestMap() { + questDataConfig := gdconf.GetQuestDataById(int32(quest.QuestId)) + if questDataConfig == nil { + continue + } + for _, questCond := range questDataConfig.FinishCondList { + if questCond.Type != cond { + continue + } + switch cond { + case constant.QUEST_FINISH_COND_TYPE_TRIGGER_FIRE: + // 场景触发器跳了 参数1:触发器id + if len(questCond.Param) != 1 { + continue + } + if len(param) != 1 { + continue + } + if questCond.Param[0] != param[0] { + continue + } + dbQuest.ForceFinishQuest(quest.QuestId) + updateQuestIdList = append(updateQuestIdList, quest.QuestId) + case constant.QUEST_FINISH_COND_TYPE_UNLOCK_TRANS_POINT: + // 解锁传送锚点 参数1:场景id 参数2:传送锚点id + if len(questCond.Param) != 2 { + continue + } + if len(param) != 2 { + continue + } + if questCond.Param[0] != param[0] { + continue + } + if questCond.Param[1] != param[1] { + continue + } + dbQuest.ForceFinishQuest(quest.QuestId) + updateQuestIdList = append(updateQuestIdList, quest.QuestId) + } + } + } + if len(updateQuestIdList) > 0 { + ntf := &proto.QuestListUpdateNotify{ + QuestList: make([]*proto.Quest, 0), + } + for _, questId := range updateQuestIdList { + pbQuest := g.PacketQuest(player, questId) + if pbQuest == nil { + continue + } + ntf.QuestList = append(ntf.QuestList, pbQuest) + } + g.SendMsg(cmd.QuestListUpdateNotify, player.PlayerID, player.ClientSeq, ntf) + g.AcceptQuest(player, true) + } +} + // PacketQuest 打包一个任务 func (g *GameManager) PacketQuest(player *model.Player, questId uint32) *proto.Quest { dbQuest := player.GetDbQuest() diff --git a/gs/game/player_reliquary.go b/gs/game/player_reliquary.go index 3a1ec419..8bbe8560 100644 --- a/gs/game/player_reliquary.go +++ b/gs/game/player_reliquary.go @@ -15,12 +15,6 @@ func (g *GameManager) GetAllReliquaryDataConfig() map[int32]*gdconf.ItemData { if itemData.Type != constant.ITEM_TYPE_RELIQUARY { continue } - if (itemId >= 20002 && itemId <= 20004) || - itemId == 23334 || - (itemId >= 23300 && itemId <= 23340) { - // 跳过无效圣遗物 - continue - } allReliquaryDataConfig[itemId] = itemData } return allReliquaryDataConfig diff --git a/gs/game/player_weapon.go b/gs/game/player_weapon.go index b9711a55..614ab315 100644 --- a/gs/game/player_weapon.go +++ b/gs/game/player_weapon.go @@ -20,24 +20,6 @@ func (g *GameManager) GetAllWeaponDataConfig() map[int32]*gdconf.ItemData { if itemData.Type != constant.ITEM_TYPE_WEAPON { continue } - if (itemId >= 10000 && itemId <= 10008) || - itemId == 11411 || - (itemId >= 11506 && itemId <= 11508) || - itemId == 12505 || - itemId == 12506 || - itemId == 12508 || - itemId == 12509 || - itemId == 13503 || - itemId == 13506 || - itemId == 14411 || - itemId == 14503 || - itemId == 14505 || - itemId == 14508 || - (itemId >= 15504 && itemId <= 15506) || - itemId == 20001 || itemId == 15306 || itemId == 14306 || itemId == 13304 || itemId == 12304 { - // 跳过无效武器 - continue - } allWeaponDataConfig[itemId] = itemData } return allWeaponDataConfig diff --git a/gs/game/player_map.go b/gs/game/player_world.go similarity index 75% rename from gs/game/player_map.go rename to gs/game/player_world.go index c10fdd59..db1e4b4b 100644 --- a/gs/game/player_map.go +++ b/gs/game/player_world.go @@ -3,6 +3,7 @@ package game import ( "strconv" + "hk4e/common/constant" "hk4e/gdconf" "hk4e/gs/model" "hk4e/pkg/logger" @@ -15,12 +16,22 @@ import ( func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.Message) { req := payloadMsg.(*proto.SceneTransToPointReq) - pointDataConfig := gdconf.GetScenePointBySceneIdAndPointId(int32(req.SceneId), int32(req.PointId)) - if pointDataConfig == nil { - g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{}) + dbWorld := player.GetDbWorld() + dbScene := dbWorld.GetSceneById(req.SceneId) + if dbScene == nil { + g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{}, proto.Retcode_RET_POINT_NOT_UNLOCKED) + return + } + unlock := dbScene.CheckPointUnlock(req.PointId) + if !unlock { + g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{}, proto.Retcode_RET_POINT_NOT_UNLOCKED) + return + } + pointDataConfig := gdconf.GetScenePointBySceneIdAndPointId(int32(req.SceneId), int32(req.PointId)) + if pointDataConfig == nil { + g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{}, proto.Retcode_RET_POINT_NOT_UNLOCKED) return } - // 传送玩家 sceneId := req.SceneId g.TeleportPlayer(player, uint16(proto.EnterReason_ENTER_REASON_TRANS_POINT), sceneId, &model.Vector{ @@ -40,6 +51,65 @@ func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.M g.SendMsg(cmd.SceneTransToPointRsp, player.PlayerID, player.ClientSeq, sceneTransToPointRsp) } +func (g *GameManager) UnlockTransPointReq(player *model.Player, payloadMsg pb.Message) { + req := payloadMsg.(*proto.UnlockTransPointReq) + + dbWorld := player.GetDbWorld() + dbScene := dbWorld.GetSceneById(req.SceneId) + if dbScene == nil { + g.SendError(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{}, proto.Retcode_RET_POINT_NOT_UNLOCKED) + return + } + unlock := dbScene.CheckPointUnlock(req.PointId) + if unlock { + g.SendError(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{}, proto.Retcode_RET_POINT_ALREAY_UNLOCKED) + return + } + dbScene.UnlockPoint(req.PointId) + + g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_UNLOCK_TRANS_POINT, int32(req.SceneId), int32(req.PointId)) + + g.SendMsg(cmd.ScenePointUnlockNotify, player.PlayerID, player.ClientSeq, &proto.ScenePointUnlockNotify{ + SceneId: req.SceneId, + PointList: []uint32{req.PointId}, + UnhidePointList: nil, + }) + g.SendSucc(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{}) +} + +func (g *GameManager) GetScenePointReq(player *model.Player, payloadMsg pb.Message) { + req := payloadMsg.(*proto.GetScenePointReq) + + dbWorld := player.GetDbWorld() + dbScene := dbWorld.GetSceneById(req.SceneId) + if dbScene == nil { + g.SendError(cmd.GetScenePointRsp, player, &proto.GetScenePointRsp{}) + return + } + getScenePointRsp := &proto.GetScenePointRsp{ + SceneId: req.SceneId, + } + areaIdMap := make(map[uint32]bool) + for _, worldAreaData := range gdconf.GetWorldAreaDataMap() { + 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 _, pointId := range dbScene.GetUnlockPointList() { + pointData := gdconf.GetScenePointBySceneIdAndPointId(int32(req.SceneId), int32(pointId)) + if pointData.IsModelHidden { + getScenePointRsp.HidePointList = append(getScenePointRsp.HidePointList, pointId) + } + getScenePointRsp.UnlockedPointList = append(getScenePointRsp.UnlockedPointList, pointId) + } + g.SendMsg(cmd.GetScenePointRsp, player.PlayerID, player.ClientSeq, getScenePointRsp) +} + func (g *GameManager) MarkMapReq(player *model.Player, payloadMsg pb.Message) { req := payloadMsg.(*proto.MarkMapReq) operation := req.Op @@ -61,6 +131,51 @@ func (g *GameManager) MarkMapReq(player *model.Player, payloadMsg pb.Message) { } } +func (g *GameManager) GetSceneAreaReq(player *model.Player, payloadMsg pb.Message) { + req := payloadMsg.(*proto.GetSceneAreaReq) + + getSceneAreaRsp := &proto.GetSceneAreaRsp{ + SceneId: req.SceneId, + } + areaIdMap := make(map[uint32]bool) + for _, worldAreaData := range gdconf.GetWorldAreaDataMap() { + 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}, + {CityId: 4, Level: 10}, + {CityId: 99, Level: 1}, + {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("player 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) +} + // TeleportPlayer 传送玩家至地图上的某个位置 func (g *GameManager) TeleportPlayer(player *model.Player, enterReason uint16, sceneId uint32, pos, rot *model.Vector, dungeonId uint32) { // 传送玩家 @@ -122,79 +237,3 @@ func (g *GameManager) TeleportPlayer(player *model.Player, enterReason uint16, s playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyTp(player, enterType, uint32(enterReason), oldSceneId, oldPos, dungeonId) g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerID, player.ClientSeq, playerEnterSceneNotify) } - -func (g *GameManager) GetScenePointReq(player *model.Player, payloadMsg pb.Message) { - req := payloadMsg.(*proto.GetScenePointReq) - - scenePointMapConfig := gdconf.GetScenePointMapBySceneId(int32(req.SceneId)) - if scenePointMapConfig == nil { - return - } - - getScenePointRsp := &proto.GetScenePointRsp{ - SceneId: req.SceneId, - } - areaIdMap := make(map[uint32]bool) - for _, worldAreaData := range gdconf.GetWorldAreaDataMap() { - 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 scenePointMapConfig { - if pointData.PointType == gdconf.PointTypeOther { - continue - } - getScenePointRsp.UnlockedPointList = append(getScenePointRsp.UnlockedPointList, uint32(pointData.Id)) - } - g.SendMsg(cmd.GetScenePointRsp, player.PlayerID, player.ClientSeq, getScenePointRsp) -} - -func (g *GameManager) GetSceneAreaReq(player *model.Player, payloadMsg pb.Message) { - req := payloadMsg.(*proto.GetSceneAreaReq) - - getSceneAreaRsp := &proto.GetSceneAreaRsp{ - SceneId: req.SceneId, - } - areaIdMap := make(map[uint32]bool) - for _, worldAreaData := range gdconf.GetWorldAreaDataMap() { - 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}, - {CityId: 4, Level: 10}, - {CityId: 99, Level: 1}, - {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("player 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) -} diff --git a/gs/game/route_manager.go b/gs/game/route_manager.go index a252fc16..b7216bb3 100644 --- a/gs/game/route_manager.go +++ b/gs/game/route_manager.go @@ -69,6 +69,7 @@ func (r *RouteManager) initRoute() { r.registerRouter(cmd.PostEnterSceneReq, GAME_MANAGER.PostEnterSceneReq) r.registerRouter(cmd.TowerAllDataReq, GAME_MANAGER.TowerAllDataReq) r.registerRouter(cmd.SceneTransToPointReq, GAME_MANAGER.SceneTransToPointReq) + r.registerRouter(cmd.UnlockTransPointReq, GAME_MANAGER.UnlockTransPointReq) r.registerRouter(cmd.MarkMapReq, GAME_MANAGER.MarkMapReq) r.registerRouter(cmd.ChangeAvatarReq, GAME_MANAGER.ChangeAvatarReq) r.registerRouter(cmd.SetUpAvatarTeamReq, GAME_MANAGER.SetUpAvatarTeamReq) diff --git a/gs/model/db_avatar.go b/gs/model/db_avatar.go index 58c95f96..66b07c93 100644 --- a/gs/model/db_avatar.go +++ b/gs/model/db_avatar.go @@ -30,8 +30,8 @@ type Avatar struct { Promote uint8 // 突破等阶 Satiation uint32 // 饱食度 SatiationPenalty uint32 // 饱食度溢出 - CurrHP float32 // 当前生命值 - CurrEnergy float32 // 当前元素能量值 + CurrHP float64 // 当前生命值 + CurrEnergy float64 // 当前元素能量值 FetterList []uint32 // 资料解锁条目 SkillLevelMap map[uint32]uint32 // 技能等级数据 SkillDepotId uint32 // 技能库id @@ -85,7 +85,7 @@ func (a *DbAvatar) InitAvatarFightProp(avatar *Avatar) { avatar.FightPropMap[constant.FIGHT_PROP_CUR_DEFENSE] = avatarDataConfig.GetBaseDefenseByLevel(avatar.Level) avatar.FightPropMap[constant.FIGHT_PROP_MAX_HP] = avatarDataConfig.GetBaseHpByLevel(avatar.Level) // 当前血量 - avatar.FightPropMap[constant.FIGHT_PROP_CUR_HP] = avatar.CurrHP + avatar.FightPropMap[constant.FIGHT_PROP_CUR_HP] = float32(avatar.CurrHP) // 双暴 avatar.FightPropMap[constant.FIGHT_PROP_CRITICAL] = avatarDataConfig.Critical avatar.FightPropMap[constant.FIGHT_PROP_CRITICAL_HURT] = avatarDataConfig.CriticalHurt @@ -147,7 +147,7 @@ func (a *DbAvatar) AddAvatar(player *Player, avatarId uint32) { // 小技能1级 avatar.SkillLevelMap[uint32(skillId)] = 1 } - avatar.CurrHP = avatarDataConfig.GetBaseHpByLevel(avatar.Level) + avatar.CurrHP = float64(avatarDataConfig.GetBaseHpByLevel(avatar.Level)) // 角色突破奖励领取状态 for promoteLevel := range avatarDataConfig.PromoteRewardMap { @@ -158,7 +158,7 @@ func (a *DbAvatar) AddAvatar(player *Player, avatarId uint32) { a.AvatarMap[avatarId] = avatar } -func (a *DbAvatar) SetCurrEnergy(avatar *Avatar, value float32, max bool) { +func (a *DbAvatar) SetCurrEnergy(avatar *Avatar, value float64, max bool) { var avatarSkillDataConfig *gdconf.AvatarSkillData = nil if avatar.AvatarId == 10000005 || avatar.AvatarId == 10000007 { avatarSkillDepotDataConfig := gdconf.GetAvatarSkillDepotDataById(int32(avatar.SkillDepotId)) @@ -185,7 +185,7 @@ func (a *DbAvatar) SetCurrEnergy(avatar *Avatar, value float32, max bool) { if max { avatar.FightPropMap[uint32(elementType.CurrEnergyProp)] = float32(avatarSkillDataConfig.CostElemVal) } else { - avatar.FightPropMap[uint32(elementType.CurrEnergyProp)] = value + avatar.FightPropMap[uint32(elementType.CurrEnergyProp)] = float32(value) } } diff --git a/gs/model/db_gacha.go b/gs/model/db_gacha.go index 3789bfc5..4d9340c8 100644 --- a/gs/model/db_gacha.go +++ b/gs/model/db_gacha.go @@ -1,5 +1,9 @@ package model +type DbGacha struct { + GachaPoolInfo map[uint32]*GachaPoolInfo +} + type GachaPoolInfo struct { GachaType uint32 // 卡池类型 OrangeTimes uint32 // 5星保底计数 @@ -8,10 +12,6 @@ type GachaPoolInfo struct { MustGetUpPurple bool // 是否4星大保底 } -type DbGacha struct { - GachaPoolInfo map[uint32]*GachaPoolInfo -} - func (p *Player) GetDbGacha() *DbGacha { if p.DbGacha == nil { p.DbGacha = NewDbGacha() diff --git a/gs/model/db_world.go b/gs/model/db_world.go new file mode 100644 index 00000000..0b11dd5a --- /dev/null +++ b/gs/model/db_world.go @@ -0,0 +1,72 @@ +package model + +import ( + "hk4e/gdconf" +) + +type DbScene struct { + SceneId uint32 + UnlockPointMap map[uint32]bool +} + +type DbWorld struct { + SceneMap map[uint32]*DbScene +} + +func (p *Player) GetDbWorld() *DbWorld { + if p.DbWorld == nil { + p.DbWorld = NewDbWorld() + } + return p.DbWorld +} + +func NewDbWorld() *DbWorld { + r := &DbWorld{ + SceneMap: make(map[uint32]*DbScene), + } + return r +} + +func NewScene(sceneId uint32) *DbScene { + r := &DbScene{ + SceneId: sceneId, + UnlockPointMap: make(map[uint32]bool), + } + return r +} + +func (w *DbWorld) GetSceneById(sceneId uint32) *DbScene { + scene, exist := w.SceneMap[sceneId] + // 不存在自动创建场景 + if !exist { + // 拒绝创建配置表中不存在的非法场景 + sceneDataConfig := gdconf.GetSceneDataById(int32(sceneId)) + if sceneDataConfig == nil { + return nil + } + scene = NewScene(sceneId) + w.SceneMap[sceneId] = scene + } + return scene +} + +func (s *DbScene) GetUnlockPointList() []uint32 { + unlockPointList := make([]uint32, 0) + for pointId := range s.UnlockPointMap { + unlockPointList = append(unlockPointList, pointId) + } + return unlockPointList +} + +func (s *DbScene) UnlockPoint(pointId uint32) { + pointDataConfig := gdconf.GetScenePointBySceneIdAndPointId(int32(s.SceneId), int32(pointId)) + if pointDataConfig == nil { + return + } + s.UnlockPointMap[pointId] = true +} + +func (s *DbScene) CheckPointUnlock(pointId uint32) bool { + _, exist := s.UnlockPointMap[pointId] + return exist +} diff --git a/gs/model/player.go b/gs/model/player.go index e9d40987..e9842af5 100644 --- a/gs/model/player.go +++ b/gs/model/player.go @@ -53,6 +53,7 @@ type Player struct { DbAvatar *DbAvatar // 角色 DbGacha *DbGacha // 卡池 DbQuest *DbQuest // 任务 + DbWorld *DbWorld // 大世界 // 在线数据 请随意 记得加忽略字段的tag LastSaveTime uint32 `bson:"-" msgpack:"-"` // 上一次保存时间 EnterSceneToken uint32 `bson:"-" msgpack:"-"` // 世界进入令牌 diff --git a/protocol/cmd/cmd_id_fix.go b/protocol/cmd/cmd_id_fix.go deleted file mode 100644 index adbb7d8b..00000000 --- a/protocol/cmd/cmd_id_fix.go +++ /dev/null @@ -1,5 +0,0 @@ -package cmd - -const ( - GCGDSBanCardNotify uint16 = 65501 -) diff --git a/protocol/cmd/cmd_id_proto_obj_map.go b/protocol/cmd/cmd_id_proto_obj_map.go index a91899ad..b258ad34 100644 --- a/protocol/cmd/cmd_id_proto_obj_map.go +++ b/protocol/cmd/cmd_id_proto_obj_map.go @@ -68,8 +68,9 @@ func (c *CmdProtoMap) registerAllMessage() { c.registerMessage(EnterWorldAreaRsp, &proto.EnterWorldAreaRsp{}) // 进入世界区域响应 c.registerMessage(SceneTransToPointReq, &proto.SceneTransToPointReq{}) // 场景传送点传送请求 c.registerMessage(SceneTransToPointRsp, &proto.SceneTransToPointRsp{}) // 场景传送点传送响应 - c.registerMessage(PathfindingEnterSceneReq, &proto.PathfindingEnterSceneReq{}) // 寻路进入场景请求 - c.registerMessage(PathfindingEnterSceneRsp, &proto.PathfindingEnterSceneRsp{}) // 寻路进入场景响应 + c.registerMessage(UnlockTransPointReq, &proto.UnlockTransPointReq{}) // 解锁场景传送点请求 + c.registerMessage(UnlockTransPointRsp, &proto.UnlockTransPointRsp{}) // 解锁场景传送点响应 + c.registerMessage(ScenePointUnlockNotify, &proto.ScenePointUnlockNotify{}) // 场景传送点解锁通知 c.registerMessage(QueryPathReq, &proto.QueryPathReq{}) // 寻路请求 c.registerMessage(QueryPathRsp, &proto.QueryPathRsp{}) // 寻路响应 c.registerMessage(GetScenePointReq, &proto.GetScenePointReq{}) // 获取场景传送点请求 @@ -95,8 +96,10 @@ func (c *CmdProtoMap) registerAllMessage() { c.registerMessage(WorldDataNotify, &proto.WorldDataNotify{}) // 世界数据通知 世界等级、是否多人世界等 c.registerMessage(WorldPlayerInfoNotify, &proto.WorldPlayerInfoNotify{}) // 世界玩家信息通知 c.registerMessage(HostPlayerNotify, &proto.HostPlayerNotify{}) // 世界房主玩家信息通知 - c.registerMessage(ToTheMoonEnterSceneReq, &proto.ToTheMoonEnterSceneReq{}) // 进入场景请求 - c.registerMessage(ToTheMoonEnterSceneRsp, &proto.ToTheMoonEnterSceneRsp{}) // 进入场景响应 + c.registerMessage(PathfindingEnterSceneReq, &proto.PathfindingEnterSceneReq{}) // 寻路服务器进入场景请求 + c.registerMessage(PathfindingEnterSceneRsp, &proto.PathfindingEnterSceneRsp{}) // 寻路服务器进入场景响应 + c.registerMessage(ToTheMoonEnterSceneReq, &proto.ToTheMoonEnterSceneReq{}) // 寻路服务器进入场景请求 + c.registerMessage(ToTheMoonEnterSceneRsp, &proto.ToTheMoonEnterSceneRsp{}) // 寻路服务器进入场景响应 c.registerMessage(SetEntityClientDataNotify, &proto.SetEntityClientDataNotify{}) // 通知 c.registerMessage(LeaveWorldNotify, &proto.LeaveWorldNotify{}) // 删除客户端世界通知 c.registerMessage(SceneAvatarStaminaStepReq, &proto.SceneAvatarStaminaStepReq{}) // 缓慢游泳或缓慢攀爬时消耗耐力请求 @@ -278,9 +281,9 @@ func (c *CmdProtoMap) registerAllMessage() { c.registerMessage(VehicleStaminaNotify, &proto.VehicleStaminaNotify{}) // 载具耐力消耗通知 // 七圣召唤 - c.registerMessage(GCGBasicDataNotify, &proto.GCGBasicDataNotify{}) // GCG基本数据通知 - c.registerMessage(GCGLevelChallengeNotify, &proto.GCGLevelChallengeNotify{}) // GCG等级挑战通知 - c.registerMessage(GCGDSBanCardNotify, &proto.GCGDSBanCardNotify{}) // GCG禁止的卡牌通知 + c.registerMessage(GCGBasicDataNotify, &proto.GCGBasicDataNotify{}) // GCG基本数据通知 + c.registerMessage(GCGLevelChallengeNotify, &proto.GCGLevelChallengeNotify{}) // GCG等级挑战通知 + // c.registerMessage(GCGDSBanCardNotify, &proto.GCGDSBanCardNotify{}) // GCG禁止的卡牌通知 c.registerMessage(GCGDSDataNotify, &proto.GCGDSDataNotify{}) // GCG数据通知 (解锁的内容) c.registerMessage(GCGTCTavernChallengeDataNotify, &proto.GCGTCTavernChallengeDataNotify{}) // GCG酒馆挑战数据通知 c.registerMessage(GCGTCTavernInfoNotify, &proto.GCGTCTavernInfoNotify{}) // GCG酒馆信息通知