From 98c6bbfe13879395a38ed3b0193f1063f54821d8 Mon Sep 17 00:00:00 2001 From: flswld Date: Thu, 9 Nov 2023 20:46:51 +0800 Subject: [PATCH] *** --- gs/game/game_command_controller.go | 54 ++++++++++++------------- gs/game/game_command_gm.go | 9 ++++- gs/game/game_world_manager.go | 3 -- gs/game/lua_func.go | 7 ++++ gs/game/player_fight_sync.go | 6 ++- gs/game/player_quest.go | 63 ++++++++++++++++++++++++------ gs/game/player_scene.go | 30 ++++++++++++++ gs/model/db_quest.go | 12 ++++++ 8 files changed, 139 insertions(+), 45 deletions(-) diff --git a/gs/game/game_command_controller.go b/gs/game/game_command_controller.go index 8d5c99b2..8602fe68 100644 --- a/gs/game/game_command_controller.go +++ b/gs/game/game_command_controller.go @@ -84,7 +84,7 @@ func (c *CommandManager) NewHelpCommandController() *CommandController { return &CommandController{ Name: "帮助", AliasList: []string{"help"}, - Description: "{alias} 查看简要帮助信息", + Description: "{alias} 帮助", UsageList: []string{ "{alias} 查看简要帮助信息", "{alias} <序号/命令别名> 查看详细帮助信息", @@ -128,8 +128,6 @@ func (c *CommandManager) HelpCommand(content *CommandContent) bool { } helpText += fmt.Sprintf("%v. %v - %v\n", permColor, commandCount, controller.Name, strings.ReplaceAll(controller.Description, "{alias}", controller.AliasList[0])) } - helpText += "\nhelp <命令别名> 能查看详细用法哦~\n" - helpText += "<> 代表必填参数 [] 代表可选参数 / 代表或者" content.SendMessage(content.Executor, helpText) return true } @@ -267,9 +265,9 @@ func (c *CommandManager) JumpCommand(content *CommandContent) bool { func (c *CommandManager) NewEquipCommandController() *CommandController { return &CommandController{ - Name: "管理武器", + Name: "武器", AliasList: []string{"equip", "weapon"}, - Description: "{alias} 管理你的武器", + Description: "{alias} 武器", UsageList: []string{ "{alias} add <武器ID/all> [武器等级] [突破等级] 添加武器", }, @@ -328,12 +326,12 @@ func (c *CommandManager) EquipCommand(content *CommandContent) bool { func (c *CommandManager) NewItemCommandController() *CommandController { return &CommandController{ - Name: "管理物品", + Name: "道具", AliasList: []string{"item"}, - Description: "{alias} 管理你的物品", + Description: "{alias} 道具", UsageList: []string{ - "{alias} add <物品ID/all> [数量] 添加物品", - "{alias} clear 清除全部物品", + "{alias} add <道具ID/all> [数量] 添加道具", + "{alias} clear 清除全部道具", }, Perm: CommandPermNormal, Func: c.ItemCommand, @@ -388,9 +386,9 @@ func (c *CommandManager) ItemCommand(content *CommandContent) bool { func (c *CommandManager) NewAvatarCommandController() *CommandController { return &CommandController{ - Name: "管理角色", + Name: "角色", AliasList: []string{"avatar"}, - Description: "{alias} 管理你的角色", + Description: "{alias} 角色", UsageList: []string{ "{alias} add <角色ID/all>", }, @@ -439,9 +437,9 @@ func (c *CommandManager) AvatarCommand(content *CommandContent) bool { func (c *CommandManager) NewGiveCommandController() *CommandController { return &CommandController{ - Name: "给予物品", + Name: "物品", AliasList: []string{"give"}, - Description: "{alias} 获得全部物品", + Description: "{alias} 物品", UsageList: []string{ "模式:ID / item (所有物品) / weapon (所有武器) / reliquary (所有圣遗物) / avatar (所有角色) / costume (所有时装) / flycloak (所有风之翼) / all (全部)\n不要加上括号内的中文!!", "{alias} <模式> [数量] 给予指定物品", @@ -575,7 +573,7 @@ func (c *CommandManager) NewKillCommandController() *CommandController { return &CommandController{ Name: "杀死实体", AliasList: []string{"kill"}, - Description: "{alias} 杀死讨厌的实体", + Description: "{alias} 杀死实体", UsageList: []string{ "{alias} self 杀死自己", "{alias} monster <实体ID/all> 杀死怪物", @@ -636,9 +634,9 @@ func (c *CommandManager) KillCommand(content *CommandContent) bool { func (c *CommandManager) NewMonsterCommandController() *CommandController { return &CommandController{ - Name: "生成怪物", + Name: "怪物", AliasList: []string{"monster"}, - Description: "{alias} 生成原魔", + Description: "{alias} 怪物", UsageList: []string{ "{alias} <怪物ID> [数量] [等级] [姿势 (暂时无效)] [坐标X] [坐标Y] [坐标Z] 生成怪物", }, @@ -688,9 +686,9 @@ func (c *CommandManager) MonsterCommand(content *CommandContent) bool { func (c *CommandManager) NewGadgetCommandController() *CommandController { return &CommandController{ - Name: "生成物件", + Name: "物件", AliasList: []string{"gadget"}, - Description: "{alias} 生成物件", + Description: "{alias} 物件", UsageList: []string{ "{alias} <物件ID> [数量] 附近生成物件", }, @@ -719,9 +717,9 @@ func (c *CommandManager) GadgetCommand(content *CommandContent) bool { func (c *CommandManager) NewQuestCommandController() *CommandController { return &CommandController{ - Name: "管理任务", + Name: "任务", AliasList: []string{"quest"}, - Description: "{alias} 管理你的任务", + Description: "{alias} 任务", UsageList: []string{ "{alias} <任务ID> 接受任务", "{alias} finish <任务ID/all> 完成任务", @@ -785,9 +783,9 @@ func (c *CommandManager) QuestCommand(content *CommandContent) bool { func (c *CommandManager) NewPointCommandController() *CommandController { return &CommandController{ - Name: "解锁锚点", + Name: "锚点", AliasList: []string{"point"}, - Description: "{alias} 解锁地图上的锚点", + Description: "{alias} 锚点", UsageList: []string{ "{alias} [场景ID] <锚点ID/all> 解锁锚点", }, @@ -830,9 +828,9 @@ func (c *CommandManager) PointCommand(content *CommandContent) bool { func (c *CommandManager) NewWeatherCommandController() *CommandController { return &CommandController{ - Name: "更改天气", + Name: "天气", AliasList: []string{"weather"}, - Description: "{alias} 更改天气", + Description: "{alias} 天气", UsageList: []string{ "{alias} [天气区域ID] <气象类型> 更改天气", }, @@ -961,9 +959,9 @@ func (c *CommandManager) DebugCommand(content *CommandContent) bool { func (c *CommandManager) NewWudiCommandController() *CommandController { return &CommandController{ - Name: "开关无敌", + Name: "无敌", AliasList: []string{"wudi"}, - Description: "{alias} 开关无敌", + Description: "{alias} 无敌", UsageList: []string{ "{alias} global avatar 开关玩家无敌", }, @@ -1063,9 +1061,9 @@ func (c *CommandManager) EnergyCommand(content *CommandContent) bool { func (c *CommandManager) NewStaminaCommandController() *CommandController { return &CommandController{ - Name: "无限耐力", + Name: "耐力", AliasList: []string{"stamina"}, - Description: "{alias} 无限耐力", + Description: "{alias} 耐力", UsageList: []string{ "{alias} infinite 开关无限耐力", }, diff --git a/gs/game/game_command_gm.go b/gs/game/game_command_gm.go index 0ac2aaa3..a2d63a73 100644 --- a/gs/game/game_command_gm.go +++ b/gs/game/game_command_gm.go @@ -490,7 +490,6 @@ func (g *GMCmd) GMUnlockAllOpenState(userId uint32) { // GMFreeMode 自由探索模式 func (g *GMCmd) GMFreeMode(userId uint32) { - GAME.LogoutPlayer(userId) player := USER_MANAGER.GetOnlineUser(userId) if player == nil { logger.Error("player is nil, uid: %v", userId) @@ -504,7 +503,13 @@ func (g *GMCmd) GMFreeMode(userId uint32) { player.PropMap[constant.PLAYER_PROP_PLAYER_CAN_DIVE] = 1 player.PropMap[constant.PLAYER_PROP_DIVE_MAX_STAMINA] = 10000 player.PropMap[constant.PLAYER_PROP_DIVE_CUR_STAMINA] = 10000 - g.GMUnlockAllOpenState(userId) + GAME.SendMsg(cmd.PlayerPropNotify, userId, player.ClientSeq, GAME.PacketPlayerPropNotify(player)) + for _, openStateData := range gdconf.GetOpenStateDataMap() { + player.OpenStateMap[uint32(openStateData.OpenStateId)] = 1 + } + GAME.SendMsg(cmd.OpenStateChangeNotify, player.PlayerId, player.ClientSeq, &proto.OpenStateChangeNotify{ + OpenStateMap: player.OpenStateMap, + }) for _, sceneData := range gdconf.GetSceneDataMap() { g.GMUnlockAllPoint(userId, uint32(sceneData.SceneId)) } diff --git a/gs/game/game_world_manager.go b/gs/game/game_world_manager.go index 6e7e739c..00cbbba1 100644 --- a/gs/game/game_world_manager.go +++ b/gs/game/game_world_manager.go @@ -579,9 +579,6 @@ func (w *World) GetPlayerActiveAvatarEntity(player *model.Player) *Entity { avatarEntityId := w.GetPlayerWorldAvatarEntityId(player, activeAvatarId) scene := w.GetSceneById(player.SceneId) entity := scene.GetEntity(avatarEntityId) - if entity == nil { - panic("fuck") - } return entity } diff --git a/gs/game/lua_func.go b/gs/game/lua_func.go index 93eef17b..73540aa9 100644 --- a/gs/game/lua_func.go +++ b/gs/game/lua_func.go @@ -209,6 +209,9 @@ func PrintContextLog(luaState *lua.LState) int { } func BeginCameraSceneLook(luaState *lua.LState) int { + // TODO 由于解锁风之翼任务相关原因暂时屏蔽 + luaState.Push(lua.LNumber(-1)) + return 1 ctx, ok := luaState.Get(1).(*lua.LTable) if !ok { luaState.Push(lua.LNumber(-1)) @@ -282,6 +285,10 @@ func ChangeGroupGadget(luaState *lua.LState) int { gadgetStateInfo := new(gdconf.Gadget) gdconf.ParseLuaTableToObject(gadgetInfo, gadgetStateInfo) entity := group.GetEntityByConfigId(uint32(gadgetStateInfo.ConfigId)) + if entity == nil { + luaState.Push(lua.LNumber(-1)) + return 1 + } GAME.ChangeGadgetState(player, entity.GetId(), uint32(gadgetStateInfo.State)) luaState.Push(lua.LNumber(0)) return 1 diff --git a/gs/game/player_fight_sync.go b/gs/game/player_fight_sync.go index 3c431247..3d2c37b7 100644 --- a/gs/game/player_fight_sync.go +++ b/gs/game/player_fight_sync.go @@ -323,7 +323,11 @@ func (g *Game) handleEntityMove(player *model.Player, world *World, scene *Scene rate /= 10.0 fightProp := entity.GetFightProp() maxHp := fightProp[constant.FIGHT_PROP_MAX_HP] - g.SubPlayerAvatarHp(player.PlayerId, entity.GetAvatarEntity().GetAvatarId(), maxHp*rate, false, proto.ChangHpReason_CHANGE_HP_SUB_FALL) + damage := maxHp * rate + if motionInfo.State == proto.MotionState_MOTION_FIGHT { + damage /= 2.0 + } + g.SubPlayerAvatarHp(player.PlayerId, entity.GetAvatarEntity().GetAvatarId(), damage, false, proto.ChangHpReason_CHANGE_HP_SUB_FALL) } } player.Speed = &model.Vector{X: float64(motionInfo.Speed.X), Y: float64(motionInfo.Speed.Y), Z: float64(motionInfo.Speed.Z)} diff --git a/gs/game/player_quest.go b/gs/game/player_quest.go index c63f20d9..2a45e414 100644 --- a/gs/game/player_quest.go +++ b/gs/game/player_quest.go @@ -153,6 +153,11 @@ func (g *Game) AcceptQuest(player *model.Player, notifyClient bool) { } } if canAccept { + if questData.QuestId == 35721 { + // TODO 由于第一次风龙任务进入秘境客户端会无限重连相关原因暂时屏蔽 + COMMAND_MANAGER.gmCmd.GMFreeMode(player.PlayerId) + continue + } dbQuest.AddQuest(uint32(questData.QuestId)) addQuestIdList = append(addQuestIdList, uint32(questData.QuestId)) } @@ -238,7 +243,7 @@ func (g *Game) QuestExec(player *model.Player, questId uint32, questExecType int if err != nil { continue } - g.AddSceneGroupSuite(player, uint32(groupId), uint8(suiteId)) + g.RefreshSceneGroupSuite(player, uint32(groupId), uint8(suiteId)) case constant.QUEST_EXEC_TYPE_SET_OPEN_STATE: if len(questExec.Param) != 2 { continue @@ -335,6 +340,18 @@ func (g *Game) QuestExec(player *model.Player, questId uint32, questExecType int continue } g.ChangeGameTime(scene, uint32(hour*60)) + case constant.QUEST_EXEC_TYPE_ROLLBACK_QUEST: + if len(questExec.Param) != 1 { + continue + } + rollbackQuestId, err := strconv.Atoi(questExec.Param[0]) + if err != nil { + continue + } + dbQuest := player.GetDbQuest() + rollbackQuest := dbQuest.GetQuestById(uint32(rollbackQuestId)) + rollbackQuest.State = constant.QUEST_STATE_UNSTARTED + g.StartQuest(player, rollbackQuest.QuestId, true) } } } @@ -357,13 +374,27 @@ func (g *Game) TriggerQuest(player *model.Player, cond int32, complexParam strin dbQuest := player.GetDbQuest() updateQuestIdList := make([]uint32, 0) for _, quest := range dbQuest.GetQuestMap() { - if quest.State == constant.QUEST_STATE_FINISHED { + if quest.State != constant.QUEST_STATE_UNFINISHED { continue } questDataConfig := gdconf.GetQuestDataById(int32(quest.QuestId)) if questDataConfig == nil { continue } + for _, questCond := range questDataConfig.FailCondList { + if questCond.Type != cond { + continue + } + switch cond { + case constant.QUEST_FINISH_COND_TYPE_LUA_NOTIFY: + // LUA侧通知 复杂参数 + if questCond.ComplexParam != complexParam { + continue + } + dbQuest.FailQuest(quest.QuestId) + updateQuestIdList = append(updateQuestIdList, quest.QuestId) + } + } for _, questCond := range questDataConfig.FinishCondList { if questCond.Type != cond { continue @@ -429,15 +460,6 @@ func (g *Game) TriggerQuest(player *model.Player, cond int32, complexParam strin dbQuest.ForceFinishQuest(quest.QuestId) updateQuestIdList = append(updateQuestIdList, quest.QuestId) } - if quest.State == constant.QUEST_STATE_FINISHED { - g.QuestExec(player, quest.QuestId, QuestExecTypeFinish) - if len(questDataConfig.ItemIdList) != 0 { - for index, itemId := range questDataConfig.ItemIdList { - questItem := []*ChangeItem{{ItemId: uint32(itemId), ChangeCount: uint32(questDataConfig.ItemCountList[index])}} - g.AddPlayerItem(player.PlayerId, questItem, true, 0) - } - } - } } } if len(updateQuestIdList) > 0 { @@ -499,6 +521,25 @@ func (g *Game) TriggerQuest(player *model.Player, cond int32, complexParam strin ParentQuestList: parentQuestList, }) } + for _, questId := range updateQuestIdList { + quest := dbQuest.GetQuestById(questId) + questDataConfig := gdconf.GetQuestDataById(int32(quest.QuestId)) + if questDataConfig == nil { + continue + } + if quest.State == constant.QUEST_STATE_FINISHED { + g.QuestExec(player, quest.QuestId, QuestExecTypeFinish) + if len(questDataConfig.ItemIdList) != 0 { + for index, itemId := range questDataConfig.ItemIdList { + questItem := []*ChangeItem{{ItemId: uint32(itemId), ChangeCount: uint32(questDataConfig.ItemCountList[index])}} + g.AddPlayerItem(player.PlayerId, questItem, true, 0) + } + } + } + if quest.State == constant.QUEST_STATE_FAILED { + g.QuestExec(player, quest.QuestId, QuestExecTypeFail) + } + } g.AcceptQuest(player, true) } } diff --git a/gs/game/player_scene.go b/gs/game/player_scene.go index af8b699e..ca4750e3 100644 --- a/gs/game/player_scene.go +++ b/gs/game/player_scene.go @@ -1019,6 +1019,36 @@ func (g *Game) AddSceneGroupSuiteCore(player *model.Player, scene *Scene, groupI scene.AddGroupSuite(groupId, suiteId, entityMap) } +func (g *Game) RefreshSceneGroupSuite(player *model.Player, groupId uint32, suiteId uint8) { + world := WORLD_MANAGER.GetWorldById(player.WorldId) + if world == nil { + return + } + scene := world.GetSceneById(player.SceneId) + group := scene.GetGroupById(groupId) + if group == nil { + return + } + suite := group.GetSuiteById(suiteId) + if suite == nil { + return + } + + entityIdList := make([]uint32, 0) + for _, entity := range suite.GetAllEntity() { + entityIdList = append(entityIdList, entity.GetId()) + } + g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, entityIdList, 0) + scene.RemoveGroupSuite(groupId, suiteId) + + dbWorld := player.GetDbWorld() + dbScene := dbWorld.GetSceneById(player.SceneId) + dbSceneGroup := dbScene.GetSceneGroupById(groupId) + dbSceneGroup.RemoveAllKill() + + g.AddSceneGroupSuite(player, groupId, suiteId) +} + // CreateConfigEntity 创建配置表里的实体 func (g *Game) CreateConfigEntity(scene *Scene, groupId uint32, entityConfig any) uint32 { world := scene.GetWorld() diff --git a/gs/model/db_quest.go b/gs/model/db_quest.go index 53533207..d1ed70a3 100644 --- a/gs/model/db_quest.go +++ b/gs/model/db_quest.go @@ -130,3 +130,15 @@ func (q *DbQuest) ForceFinishQuest(questId uint32) { q.AddQuestProgress(questId, index, uint32(finishCond.Count)) } } + +func (q *DbQuest) FailQuest(questId uint32) { + quest, exist := q.QuestMap[questId] + if !exist { + logger.Error("get quest is nil, questId: %v", questId) + return + } + if quest.State != constant.QUEST_STATE_UNFINISHED { + return + } + quest.State = constant.QUEST_STATE_FAILED +}