优化
This commit is contained in:
1 parent
9912db38bb
commit
32da14235e
12 files changed
+275
-72
No files matched your search
@@ -36,7 +36,7 @@ type GameDataConfig struct {
|
||||
SceneLuaConfigMap map[int32]*SceneLuaConfig // 场景LUA配置
|
||||
GroupMap map[int32]*Group // 场景LUA区块group索引
|
||||
LuaStateLruMap map[int32]*LuaStateLru // 场景LUA虚拟机LRU内存淘汰
|
||||
TriggerDataMap map[int32]*TriggerData // 场景LUA触发器
|
||||
TriggerDataMap map[int32]*TriggerData // 场景区域触发器
|
||||
ScenePointMap map[int32]*ScenePoint // 场景传送点
|
||||
SceneTagDataMap map[int32]*SceneTagData // 场景标签
|
||||
GatherDataMap map[int32]*GatherData // 采集物
|
||||
@@ -150,7 +150,7 @@ func (g *GameDataConfig) loadAll(loadSceneLua bool) {
|
||||
func (g *GameDataConfig) load(loadSceneLua bool) {
|
||||
g.loadSceneData() // 场景
|
||||
g.loadSceneLuaConfig(loadSceneLua) // 场景LUA配置
|
||||
g.loadTriggerData() // 场景LUA触发器
|
||||
g.loadTriggerData() // 场景区域触发器
|
||||
g.loadScenePoint() // 场景传送点
|
||||
g.loadSceneTagData() // 场景标签
|
||||
g.loadGatherData() // 采集物
|
||||
|
||||
@@ -49,7 +49,7 @@ type ScenePoint struct {
|
||||
type PointData struct {
|
||||
Id int32 `json:"-"`
|
||||
PointType int `json:"-"`
|
||||
PointTypeStr string `json:"pointType"` // 传送点类型
|
||||
PointTypeStr string `json:"$type"` // 传送点类型
|
||||
TranPos *Position `json:"tranPos"` // 传送后位置
|
||||
TranRot *Position `json:"tranRot"` // 传送后朝向
|
||||
DungeonIds []int32 `json:"dungeonIds"` // 地牢id列表
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
|
||||
// TriggerData 场景LUA触发器配置表
|
||||
// TriggerData 场景区域触发器配置表
|
||||
type TriggerData struct {
|
||||
TriggerId int32 `csv:"ID"`
|
||||
SceneId int32 `csv:"场景ID,omitempty"`
|
||||
|
||||
+2
-2
@@ -293,7 +293,7 @@ func (g *Game) EndlessLoopCheck(checkType int) {
|
||||
EndlessLoopHandleFunc()
|
||||
}
|
||||
case EndlessLoopCheckTypeCallLuaFunc:
|
||||
if checkCount > 100 {
|
||||
if checkCount > 1000 {
|
||||
EndlessLoopHandleFunc()
|
||||
}
|
||||
default:
|
||||
@@ -304,7 +304,7 @@ var EXIT_SAVE_FIN_CHAN chan bool
|
||||
|
||||
func (g *Game) ServerStopNotify() {
|
||||
go func() {
|
||||
info := "服务器即将关闭。"
|
||||
info := "停服维护"
|
||||
GAME.ServerAnnounceNotify(1, info)
|
||||
logger.Warn("stop game server last 1 minute")
|
||||
time.Sleep(time.Minute)
|
||||
|
||||
@@ -803,6 +803,7 @@ func (c *CommandManager) NewDebugCommandController() *CommandController {
|
||||
UsageList: []string{
|
||||
"{alias} freemode 自由探索模式",
|
||||
"{alias} openstate 解锁全部功能",
|
||||
"{alias} unlockarea 解锁全部地图区域",
|
||||
"{alias} clearworld 清除大世界数据",
|
||||
"{alias} notsave 本次离线回档",
|
||||
"{alias} xluaswitch 开关xLua",
|
||||
@@ -830,6 +831,16 @@ func (c *CommandManager) DebugCommand(content *CommandContent) bool {
|
||||
c.gmCmd.GMUnlockAllOpenState(content.AssignPlayer.PlayerId)
|
||||
content.SendSuccMessage(content.Executor, "已解锁全部功能,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
return true
|
||||
case "unlockarea":
|
||||
c.gmCmd.GMUnlockAllArea(content.AssignPlayer.PlayerId, 1)
|
||||
c.gmCmd.GMUnlockAllArea(content.AssignPlayer.PlayerId, 3)
|
||||
c.gmCmd.GMUnlockAllArea(content.AssignPlayer.PlayerId, 4)
|
||||
c.gmCmd.GMUnlockAllArea(content.AssignPlayer.PlayerId, 5)
|
||||
c.gmCmd.GMUnlockAllArea(content.AssignPlayer.PlayerId, 6)
|
||||
c.gmCmd.GMUnlockAllArea(content.AssignPlayer.PlayerId, 7)
|
||||
c.gmCmd.GMUnlockAllArea(content.AssignPlayer.PlayerId, 9)
|
||||
content.SendSuccMessage(content.Executor, "已解锁全部地图区域,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
return true
|
||||
case "clearworld":
|
||||
c.gmCmd.GMClearWorld(content.AssignPlayer.PlayerId)
|
||||
content.SendSuccMessage(content.Executor, "已清除大世界数据,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
|
||||
@@ -325,14 +325,14 @@ func (g *GMCmd) GMForceFinishAllQuest(userId uint32) {
|
||||
GAME.SendMsg(cmd.QuestListUpdateNotify, player.PlayerId, player.ClientSeq, ntf)
|
||||
}
|
||||
|
||||
// GMUnlockPoint 解锁场景某个锚点
|
||||
// GMUnlockPoint 解锁场景锚点
|
||||
func (g *GMCmd) GMUnlockPoint(userId uint32, sceneId uint32, pointId uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
GAME.UnlockPlayerTransPoint(player, sceneId, pointId)
|
||||
GAME.UnlockPlayerScenePoint(player, sceneId, pointId)
|
||||
}
|
||||
|
||||
// GMUnlockAllPoint 解锁场景全部锚点
|
||||
@@ -356,10 +356,52 @@ func (g *GMCmd) GMUnlockAllPoint(userId uint32, sceneId uint32) {
|
||||
for _, pointData := range scenePointMapConfig {
|
||||
dbScene.UnlockPoint(uint32(pointData.Id))
|
||||
}
|
||||
GAME.SendMsg(cmd.ScenePointUnlockNotify, player.PlayerId, player.ClientSeq, &proto.ScenePointUnlockNotify{
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
GAME.SendToSceneA(scene, cmd.ScenePointUnlockNotify, player.ClientSeq, &proto.ScenePointUnlockNotify{
|
||||
SceneId: sceneId,
|
||||
PointList: dbScene.GetUnlockPointList(),
|
||||
})
|
||||
}, 0)
|
||||
}
|
||||
|
||||
// GMUnlockArea 解锁场景区域
|
||||
func (g *GMCmd) GMUnlockArea(userId uint32, sceneId uint32, areaId uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
GAME.UnlockPlayerSceneArea(player, sceneId, areaId)
|
||||
}
|
||||
|
||||
// GMUnlockAllArea 解锁场景全部区域
|
||||
func (g *GMCmd) GMUnlockAllArea(userId uint32, sceneId uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
dbWorld := player.GetDbWorld()
|
||||
dbScene := dbWorld.GetSceneById(sceneId)
|
||||
if dbScene == nil {
|
||||
logger.Error("db scene is nil, sceneId: %v, uid: %v", sceneId, userId)
|
||||
return
|
||||
}
|
||||
for _, worldAreaDataConfig := range gdconf.GetWorldAreaDataMap() {
|
||||
dbScene.UnlockArea(uint32(worldAreaDataConfig.AreaId1))
|
||||
}
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
GAME.SendToSceneA(scene, cmd.SceneAreaUnlockNotify, player.ClientSeq, &proto.SceneAreaUnlockNotify{
|
||||
SceneId: sceneId,
|
||||
AreaList: dbScene.GetUnlockAreaList(),
|
||||
}, 0)
|
||||
}
|
||||
|
||||
// GMSetWeather 设置天气
|
||||
|
||||
+148
-15
@@ -124,6 +124,8 @@ func RegLuaScriptLibFunc() {
|
||||
gdconf.RegScriptLibFunc("PrintContextLog", PrintContextLog)
|
||||
gdconf.RegScriptLibFunc("BeginCameraSceneLook", BeginCameraSceneLook)
|
||||
gdconf.RegScriptLibFunc("GetGroupMonsterCount", GetGroupMonsterCount)
|
||||
gdconf.RegScriptLibFunc("GetGroupMonsterCountByGroupId", GetGroupMonsterCountByGroupId)
|
||||
gdconf.RegScriptLibFunc("CheckRemainGadgetCountByGroupId", CheckRemainGadgetCountByGroupId)
|
||||
gdconf.RegScriptLibFunc("ChangeGroupGadget", ChangeGroupGadget)
|
||||
gdconf.RegScriptLibFunc("GetGadgetStateByConfigId", GetGadgetStateByConfigId)
|
||||
gdconf.RegScriptLibFunc("SetGadgetStateByConfigId", SetGadgetStateByConfigId)
|
||||
@@ -143,6 +145,18 @@ func RegLuaScriptLibFunc() {
|
||||
gdconf.RegScriptLibFunc("CreateGroupTimerEvent", CreateGroupTimerEvent)
|
||||
gdconf.RegScriptLibFunc("EnterWeatherArea", EnterWeatherArea)
|
||||
gdconf.RegScriptLibFunc("SetWeatherAreaState", SetWeatherAreaState)
|
||||
gdconf.RegScriptLibFunc("RefreshGroup", RefreshGroup)
|
||||
gdconf.RegScriptLibFunc("RemoveExtraGroupSuite", RemoveExtraGroupSuite)
|
||||
gdconf.RegScriptLibFunc("ShowReminder", ShowReminder)
|
||||
}
|
||||
|
||||
type CommonLuaTableParam struct {
|
||||
ConfigId int32 `json:"config_id"`
|
||||
DelayTime int32 `json:"delay_time"`
|
||||
RegionEid int32 `json:"region_eid"`
|
||||
EntityType int32 `json:"entity_type"`
|
||||
GroupId int32 `json:"group_id"`
|
||||
Suite int32 `json:"suite"`
|
||||
}
|
||||
|
||||
func GetEntityType(luaState *lua.LState) int {
|
||||
@@ -248,6 +262,78 @@ func GetGroupMonsterCount(luaState *lua.LState) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func GetGroupMonsterCountByGroupId(luaState *lua.LState) int {
|
||||
ctx, ok := luaState.Get(1).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
player := GetContextPlayer(ctx, luaState)
|
||||
if player == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
scene := world.GetSceneById(player.GetSceneId())
|
||||
groupId := luaState.ToInt(2)
|
||||
group := scene.GetGroupById(uint32(groupId))
|
||||
if group == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
monsterCount := 0
|
||||
for _, entity := range group.GetAllEntity() {
|
||||
if entity.GetEntityType() == constant.ENTITY_TYPE_MONSTER {
|
||||
monsterCount++
|
||||
}
|
||||
}
|
||||
luaState.Push(lua.LNumber(monsterCount))
|
||||
return 1
|
||||
}
|
||||
|
||||
func CheckRemainGadgetCountByGroupId(luaState *lua.LState) int {
|
||||
ctx, ok := luaState.Get(1).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
player := GetContextPlayer(ctx, luaState)
|
||||
if player == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
scene := world.GetSceneById(player.GetSceneId())
|
||||
luaTable, ok := luaState.Get(2).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
luaTableParam := new(CommonLuaTableParam)
|
||||
gdconf.ParseLuaTableToObject[*CommonLuaTableParam](luaTable, luaTableParam)
|
||||
group := scene.GetGroupById(uint32(luaTableParam.GroupId))
|
||||
if group == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
gadgetCount := 0
|
||||
for _, entity := range group.GetAllEntity() {
|
||||
if entity.GetEntityType() == constant.ENTITY_TYPE_GADGET {
|
||||
gadgetCount++
|
||||
}
|
||||
}
|
||||
luaState.Push(lua.LNumber(gadgetCount))
|
||||
return 1
|
||||
}
|
||||
|
||||
func ChangeGroupGadget(luaState *lua.LState) int {
|
||||
ctx, ok := luaState.Get(1).(*lua.LTable)
|
||||
if !ok {
|
||||
@@ -379,13 +465,6 @@ func AddQuestProgress(luaState *lua.LState) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
type LuaTableParam struct {
|
||||
ConfigId int32 `json:"config_id"`
|
||||
DelayTime int32 `json:"delay_time"`
|
||||
RegionEid int32 `json:"region_eid"`
|
||||
EntityType int32 `json:"entity_type"`
|
||||
}
|
||||
|
||||
func CreateMonster(luaState *lua.LState) int {
|
||||
ctx, ok := luaState.Get(1).(*lua.LTable)
|
||||
if !ok {
|
||||
@@ -407,8 +486,8 @@ func CreateMonster(luaState *lua.LState) int {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
luaTableParam := new(LuaTableParam)
|
||||
gdconf.ParseLuaTableToObject[*LuaTableParam](luaTable, luaTableParam)
|
||||
luaTableParam := new(CommonLuaTableParam)
|
||||
gdconf.ParseLuaTableToObject[*CommonLuaTableParam](luaTable, luaTableParam)
|
||||
TICK_MANAGER.CreateUserTimer(player.PlayerId, UserTimerActionLuaCreateMonster, uint32(luaTableParam.DelayTime),
|
||||
uint32(groupId), uint32(luaTableParam.ConfigId))
|
||||
luaState.Push(lua.LNumber(0))
|
||||
@@ -436,8 +515,8 @@ func CreateGadget(luaState *lua.LState) int {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
luaTableParam := new(LuaTableParam)
|
||||
gdconf.ParseLuaTableToObject[*LuaTableParam](luaTable, luaTableParam)
|
||||
luaTableParam := new(CommonLuaTableParam)
|
||||
gdconf.ParseLuaTableToObject[*CommonLuaTableParam](luaTable, luaTableParam)
|
||||
GAME.SceneGroupCreateEntity(player, uint32(groupId), uint32(luaTableParam.ConfigId), constant.ENTITY_TYPE_GADGET)
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
@@ -464,8 +543,8 @@ func KillEntityByConfigId(luaState *lua.LState) int {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
luaTableParam := new(LuaTableParam)
|
||||
gdconf.ParseLuaTableToObject[*LuaTableParam](luaTable, luaTableParam)
|
||||
luaTableParam := new(CommonLuaTableParam)
|
||||
gdconf.ParseLuaTableToObject[*CommonLuaTableParam](luaTable, luaTableParam)
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
@@ -473,7 +552,15 @@ func KillEntityByConfigId(luaState *lua.LState) int {
|
||||
}
|
||||
scene := world.GetSceneById(player.GetSceneId())
|
||||
group := scene.GetGroupById(uint32(groupId))
|
||||
if group == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
entity := group.GetEntityByConfigId(uint32(luaTableParam.ConfigId))
|
||||
if entity == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
GAME.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
@@ -674,8 +761,8 @@ func GetRegionEntityCount(luaState *lua.LState) int {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
luaTableParam := new(LuaTableParam)
|
||||
gdconf.ParseLuaTableToObject[*LuaTableParam](luaTable, luaTableParam)
|
||||
luaTableParam := new(CommonLuaTableParam)
|
||||
gdconf.ParseLuaTableToObject[*CommonLuaTableParam](luaTable, luaTableParam)
|
||||
groupConfig := gdconf.GetSceneGroup(int32(groupId))
|
||||
if groupConfig == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
@@ -782,3 +869,49 @@ func SetWeatherAreaState(luaState *lua.LState) int {
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
}
|
||||
|
||||
func RefreshGroup(luaState *lua.LState) int {
|
||||
ctx, ok := luaState.Get(1).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
player := GetContextPlayer(ctx, luaState)
|
||||
if player == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
luaTable, ok := luaState.Get(2).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
luaTableParam := new(CommonLuaTableParam)
|
||||
gdconf.ParseLuaTableToObject[*CommonLuaTableParam](luaTable, luaTableParam)
|
||||
GAME.RefreshSceneGroupSuite(player, uint32(luaTableParam.GroupId), uint8(luaTableParam.Suite))
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
}
|
||||
|
||||
func RemoveExtraGroupSuite(luaState *lua.LState) int {
|
||||
ctx, ok := luaState.Get(1).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
player := GetContextPlayer(ctx, luaState)
|
||||
if player == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
groupId := luaState.ToInt(2)
|
||||
suiteId := luaState.ToInt(3)
|
||||
GAME.RemoveSceneGroupSuite(player, uint32(groupId), uint8(suiteId))
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
}
|
||||
|
||||
func ShowReminder(luaState *lua.LState) int {
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
}
|
||||
@@ -178,6 +178,12 @@ func (g *Game) PlayerChatReq(player *model.Player, payloadMsg pb.Message) {
|
||||
g.SendMsg(cmd.PlayerChatRsp, player.PlayerId, player.ClientSeq, new(proto.PlayerChatRsp))
|
||||
}
|
||||
|
||||
func (g *Game) GetChatEmojiCollectionReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.GetChatEmojiCollectionReq)
|
||||
_ = req
|
||||
g.SendMsg(cmd.GetChatEmojiCollectionRsp, player.PlayerId, player.ClientSeq, new(proto.GetChatEmojiCollectionRsp))
|
||||
}
|
||||
|
||||
/************************************************** 游戏功能 **************************************************/
|
||||
|
||||
// SendPrivateChat 发送私聊文本消息给玩家
|
||||
|
||||
@@ -21,8 +21,10 @@ func (g *Game) PingReq(player *model.Player, payloadMsg pb.Message) {
|
||||
player.ClientTime = req.ClientTime
|
||||
now := uint32(time.Now().Unix())
|
||||
// 客户端与服务器时间相差太过严重
|
||||
if math.Abs(float64(now-player.ClientTime)) > 600.0 {
|
||||
logger.Debug("abs of client time and server time above 600s, clientTime: %v, uid: %v", player.ClientTime, player.PlayerId)
|
||||
max := math.Max(float64(now), float64(player.ClientTime))
|
||||
min := math.Min(float64(now), float64(player.ClientTime))
|
||||
if math.Abs(max-min) > 600.0 {
|
||||
logger.Error("abs of client time and server time above 600s, clientTime: %v, uid: %v", player.ClientTime, player.PlayerId)
|
||||
}
|
||||
player.LastKeepaliveTime = now
|
||||
|
||||
@@ -294,12 +296,6 @@ func (g *Game) GmTalkReq(player *model.Player, payloadMsg pb.Message) {
|
||||
g.SendMsg(cmd.GmTalkRsp, player.PlayerId, player.ClientSeq, &proto.GmTalkRsp{Retmsg: "执行成功", Msg: req.Msg})
|
||||
}
|
||||
|
||||
func (g *Game) GetChatEmojiCollectionReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.GetChatEmojiCollectionReq)
|
||||
_ = req
|
||||
g.SendMsg(cmd.GetChatEmojiCollectionRsp, player.PlayerId, player.ClientSeq, new(proto.GetChatEmojiCollectionRsp))
|
||||
}
|
||||
|
||||
func (g *Game) PacketPropValue(key uint32, value any) *proto.PropValue {
|
||||
propValue := new(proto.PropValue)
|
||||
propValue.Type = key
|
||||
|
||||
@@ -312,7 +312,7 @@ func (g *Game) ExecQuest(player *model.Player, questId uint32, questExecType int
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
g.UnlockPlayerTransPoint(player, uint32(sceneId), uint32(pointId))
|
||||
g.UnlockPlayerScenePoint(player, uint32(sceneId), uint32(pointId))
|
||||
case constant.QUEST_EXEC_TYPE_UNLOCK_AREA:
|
||||
// 解锁场景区域
|
||||
if len(questExec.Param) != 2 {
|
||||
|
||||
+35
-30
@@ -355,7 +355,9 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
|
||||
}
|
||||
for _, triggerDataConfig := range gdconf.GetTriggerDataMap() {
|
||||
groupConfig := gdconf.GetSceneGroup(triggerDataConfig.GroupId)
|
||||
g.AddSceneGroup(player, scene, groupConfig)
|
||||
if groupConfig != nil {
|
||||
g.AddSceneGroup(player, scene, groupConfig)
|
||||
}
|
||||
}
|
||||
// TODO 七天神像的group太远不加载的临时解决方案
|
||||
if player.GetSceneId() == 3 {
|
||||
@@ -939,7 +941,7 @@ func (g *Game) RemoveSceneGroup(player *model.Player, scene *Scene, groupConfig
|
||||
// g.SendMsg(cmd.GroupUnloadNotify, player.PlayerId, player.ClientSeq, ntf)
|
||||
}
|
||||
|
||||
// AddSceneGroupSuite 向场景组中添加场景小组
|
||||
// AddSceneGroupSuite 场景组中添加场景小组
|
||||
func (g *Game) AddSceneGroupSuite(player *model.Player, groupId uint32, suiteId uint8) {
|
||||
// logger.Debug("add scene group suite, groupId: %v, suiteId: %v, uid: %v", groupId, suiteId, player.PlayerId)
|
||||
groupConfig := gdconf.GetSceneGroup(int32(groupId))
|
||||
@@ -972,6 +974,37 @@ func (g *Game) AddSceneGroupSuite(player *model.Player, groupId uint32, suiteId
|
||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, entityIdList, true, false)
|
||||
}
|
||||
|
||||
// RemoveSceneGroupSuite 场景组中移除场景小组
|
||||
func (g *Game) RemoveSceneGroupSuite(player *model.Player, groupId uint32, suiteId uint8) {
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
scene := world.GetSceneById(player.GetSceneId())
|
||||
group := scene.GetGroupById(groupId)
|
||||
if group != nil {
|
||||
suite := group.GetSuiteById(suiteId)
|
||||
if suite != nil {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RefreshSceneGroupSuite 刷新场景小组
|
||||
func (g *Game) RefreshSceneGroupSuite(player *model.Player, groupId uint32, suiteId uint8) {
|
||||
dbWorld := player.GetDbWorld()
|
||||
dbScene := dbWorld.GetSceneById(player.GetSceneId())
|
||||
dbSceneGroup := dbScene.GetSceneGroupById(groupId)
|
||||
dbSceneGroup.RemoveAllKill()
|
||||
g.RemoveSceneGroupSuite(player, groupId, suiteId)
|
||||
g.AddSceneGroupSuite(player, groupId, suiteId)
|
||||
}
|
||||
|
||||
func (g *Game) AddSceneGroupSuiteCore(player *model.Player, scene *Scene, groupId uint32, suiteId uint8) {
|
||||
groupConfig := gdconf.GetSceneGroup(int32(groupId))
|
||||
if groupConfig == nil {
|
||||
@@ -1034,34 +1067,6 @@ 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.GetSceneId())
|
||||
group := scene.GetGroupById(groupId)
|
||||
if group != nil {
|
||||
suite := group.GetSuiteById(suiteId)
|
||||
if suite != nil {
|
||||
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.GetSceneId())
|
||||
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()
|
||||
|
||||
+18
-8
@@ -71,7 +71,7 @@ func (g *Game) SceneTransToPointReq(player *model.Player, payloadMsg pb.Message)
|
||||
func (g *Game) UnlockTransPointReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.UnlockTransPointReq)
|
||||
|
||||
ret := g.UnlockPlayerTransPoint(player, req.SceneId, req.PointId)
|
||||
ret := g.UnlockPlayerScenePoint(player, req.SceneId, req.PointId)
|
||||
if ret != proto.Retcode_RET_SUCC {
|
||||
g.SendError(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{}, ret)
|
||||
return
|
||||
@@ -509,13 +509,13 @@ func (g *Game) ExitTransPointRegionNotify(player *model.Player, payloadMsg pb.Me
|
||||
|
||||
/************************************************** 游戏功能 **************************************************/
|
||||
|
||||
// UnlockPlayerTransPoint 解锁锚点
|
||||
func (g *Game) UnlockPlayerTransPoint(player *model.Player, sceneId uint32, pointId uint32) proto.Retcode {
|
||||
// UnlockPlayerScenePoint 解锁场景锚点
|
||||
func (g *Game) UnlockPlayerScenePoint(player *model.Player, sceneId uint32, pointId uint32) proto.Retcode {
|
||||
dbWorld := player.GetDbWorld()
|
||||
dbScene := dbWorld.GetSceneById(sceneId)
|
||||
if dbScene == nil {
|
||||
logger.Error("get dbScene is nil, sceneId: %v, uid: %v", sceneId, player.PlayerId)
|
||||
return proto.Retcode_RET_POINT_NOT_UNLOCKED
|
||||
return proto.Retcode_RET_SVR_ERROR
|
||||
}
|
||||
unlock := dbScene.CheckPointUnlock(pointId)
|
||||
if unlock {
|
||||
@@ -523,10 +523,15 @@ func (g *Game) UnlockPlayerTransPoint(player *model.Player, sceneId uint32, poin
|
||||
return proto.Retcode_RET_POINT_ALREAY_UNLOCKED
|
||||
}
|
||||
dbScene.UnlockPoint(pointId)
|
||||
g.SendMsg(cmd.ScenePointUnlockNotify, player.PlayerId, player.ClientSeq, &proto.ScenePointUnlockNotify{
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
return proto.Retcode_RET_SVR_ERROR
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
g.SendToSceneA(scene, cmd.ScenePointUnlockNotify, player.ClientSeq, &proto.ScenePointUnlockNotify{
|
||||
SceneId: sceneId,
|
||||
PointList: []uint32{pointId},
|
||||
})
|
||||
}, 0)
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_UNLOCK_TRANS_POINT, "", int32(sceneId), int32(pointId))
|
||||
return proto.Retcode_RET_SUCC
|
||||
}
|
||||
@@ -545,10 +550,15 @@ func (g *Game) UnlockPlayerSceneArea(player *model.Player, sceneId uint32, areaI
|
||||
return
|
||||
}
|
||||
dbScene.UnlockArea(areaId)
|
||||
g.SendMsg(cmd.SceneAreaUnlockNotify, player.PlayerId, player.ClientSeq, &proto.SceneAreaUnlockNotify{
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
g.SendToSceneA(scene, cmd.SceneAreaUnlockNotify, player.ClientSeq, &proto.SceneAreaUnlockNotify{
|
||||
SceneId: sceneId,
|
||||
AreaList: []uint32{areaId},
|
||||
})
|
||||
}, 0)
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_UNLOCK_AREA, "", int32(sceneId), int32(areaId))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user