修改游戏默认时间、游戏时间设置为离线数据、任务开始时检测已经完成的条件
This commit is contained in:
1 parent
fd937a7095
commit
213b9cb8e0
10 files changed
+75
-48
No files matched your search
@@ -258,6 +258,7 @@ const (
|
||||
EndlessLoopCheckTypeTriggerQuest
|
||||
EndlessLoopCheckTypeUseItem
|
||||
EndlessLoopCheckTypeCallLuaFunc
|
||||
EndlessLoopCheckTypeCheckFinishedCond
|
||||
)
|
||||
|
||||
func (g *Game) EndlessLoopCheck(checkType int) {
|
||||
@@ -299,6 +300,10 @@ func (g *Game) EndlessLoopCheck(checkType int) {
|
||||
if checkCount > 1000 {
|
||||
EndlessLoopHandleFunc()
|
||||
}
|
||||
case EndlessLoopCheckTypeCheckFinishedCond:
|
||||
if checkCount > 1000 {
|
||||
EndlessLoopHandleFunc()
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,9 +306,7 @@ func (t *TickManager) onTickSecond(now int64) {
|
||||
}
|
||||
// 场景时间增加
|
||||
if !world.GetOwner().Pause && world.GetOwner().PropMap[constant.PLAYER_PROP_IS_GAME_TIME_LOCKED] != 1 {
|
||||
for _, scene := range world.GetAllScene() {
|
||||
scene.ChangeGameTime(scene.gameTime + 1)
|
||||
}
|
||||
world.ChangeGameTime(world.GetGameTime() + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,6 +856,14 @@ func (w *World) RemoveWaitPlayer(uid uint32) {
|
||||
delete(w.waitEnterPlayerMap, uid)
|
||||
}
|
||||
|
||||
func (w *World) GetGameTime() uint32 {
|
||||
return w.GetOwner().GetDbWorld().GameTime
|
||||
}
|
||||
|
||||
func (w *World) ChangeGameTime(time uint32) {
|
||||
w.GetOwner().GetDbWorld().GameTime = time % 1440
|
||||
}
|
||||
|
||||
func (w *World) CreateScene(sceneId uint32) *Scene {
|
||||
scene := &Scene{
|
||||
id: sceneId,
|
||||
@@ -863,7 +871,6 @@ func (w *World) CreateScene(sceneId uint32) *Scene {
|
||||
playerMap: make(map[uint32]*model.Player),
|
||||
entityMap: make(map[uint32]*Entity),
|
||||
groupMap: make(map[uint32]*Group),
|
||||
gameTime: 0,
|
||||
createTime: time.Now().UnixMilli(),
|
||||
meeoIndex: 0,
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ type Scene struct {
|
||||
playerMap map[uint32]*model.Player
|
||||
entityMap map[uint32]*Entity // 场景中全部的实体
|
||||
groupMap map[uint32]*Group // 场景中按group->suite分类的实体
|
||||
gameTime uint32 // 游戏内提瓦特大陆的时间
|
||||
createTime int64 // 场景创建时间
|
||||
meeoIndex uint32 // 客户端风元素染色同步协议的计数器
|
||||
monsterWudi bool // 是否开启场景内怪物无敌
|
||||
@@ -49,10 +48,6 @@ func (s *Scene) GetAllGroup() map[uint32]*Group {
|
||||
return s.groupMap
|
||||
}
|
||||
|
||||
func (s *Scene) GetGameTime() uint32 {
|
||||
return s.gameTime
|
||||
}
|
||||
|
||||
func (s *Scene) GetMeeoIndex() uint32 {
|
||||
return s.meeoIndex
|
||||
}
|
||||
@@ -69,10 +64,6 @@ func (s *Scene) SetMonsterWudi(monsterWudi bool) {
|
||||
s.monsterWudi = monsterWudi
|
||||
}
|
||||
|
||||
func (s *Scene) ChangeGameTime(time uint32) {
|
||||
s.gameTime = time % 1440
|
||||
}
|
||||
|
||||
func (s *Scene) GetSceneCreateTime() int64 {
|
||||
return s.createTime
|
||||
}
|
||||
|
||||
@@ -236,14 +236,12 @@ func (g *Game) PlayerTimeNotify(world *World) {
|
||||
}
|
||||
|
||||
func (g *Game) PlayerGameTimeNotify(world *World) {
|
||||
for _, scene := range world.sceneMap {
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
playerGameTimeNotify := &proto.PlayerGameTimeNotify{
|
||||
GameTime: scene.GetGameTime(),
|
||||
Uid: scenePlayer.PlayerId,
|
||||
}
|
||||
g.SendMsg(cmd.PlayerGameTimeNotify, scenePlayer.PlayerId, 0, playerGameTimeNotify)
|
||||
for _, player := range world.GetAllPlayer() {
|
||||
playerGameTimeNotify := &proto.PlayerGameTimeNotify{
|
||||
GameTime: world.GetGameTime(),
|
||||
Uid: player.PlayerId,
|
||||
}
|
||||
g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerId, 0, playerGameTimeNotify)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+32
-1
@@ -231,6 +231,7 @@ func (g *Game) StartQuest(player *model.Player, questId uint32, notifyClient boo
|
||||
|
||||
g.ExecQuest(player, questId, QuestExecTypeStart)
|
||||
g.QuestStartTriggerCheck(player, questId)
|
||||
g.CheckQuestFinishedCond(player, questId)
|
||||
|
||||
if notifyClient {
|
||||
ntf := &proto.QuestListUpdateNotify{
|
||||
@@ -401,7 +402,7 @@ func (g *Game) ExecQuest(player *model.Player, questId uint32, questExecType int
|
||||
logger.Error("scene is nil, sceneId: %v, uid: %v", player.GetSceneId(), player.PlayerId)
|
||||
continue
|
||||
}
|
||||
g.ChangeGameTime(scene, uint32(hour*60))
|
||||
g.ChangeGameTime(world, uint32(hour*60))
|
||||
case constant.QUEST_EXEC_TYPE_ROLLBACK_QUEST:
|
||||
// 回滚任务
|
||||
if len(questExec.Param) != 1 {
|
||||
@@ -421,6 +422,36 @@ func (g *Game) ExecQuest(player *model.Player, questId uint32, questExecType int
|
||||
}
|
||||
}
|
||||
|
||||
// CheckQuestFinishedCond 检测任务已完成的条件
|
||||
func (g *Game) CheckQuestFinishedCond(player *model.Player, questId uint32) {
|
||||
g.EndlessLoopCheck(EndlessLoopCheckTypeCheckFinishedCond)
|
||||
questDataConfig := gdconf.GetQuestDataById(int32(questId))
|
||||
if questDataConfig == nil {
|
||||
return
|
||||
}
|
||||
// TODO 检测已经完成的失败条件
|
||||
// 检测已经完成的完成条件
|
||||
for _, cond := range questDataConfig.FinishCondList {
|
||||
switch cond.Type {
|
||||
case constant.QUEST_FINISH_COND_TYPE_UNLOCK_TRANS_POINT:
|
||||
sceneId := uint32(cond.Param[0])
|
||||
pointId := uint32(cond.Param[1])
|
||||
|
||||
dbWorld := player.GetDbWorld()
|
||||
dbScene := dbWorld.GetSceneById(sceneId)
|
||||
if dbScene == nil {
|
||||
logger.Error("get dbScene is nil, sceneId: %v, uid: %v", sceneId, player.PlayerId)
|
||||
continue
|
||||
}
|
||||
unlock := dbScene.CheckPointUnlock(pointId)
|
||||
if !unlock {
|
||||
continue
|
||||
}
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_UNLOCK_TRANS_POINT, "", int32(sceneId), int32(pointId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TriggerQuest 触发任务
|
||||
func (g *Game) TriggerQuest(player *model.Player, cond int32, complexParam string, param ...int32) {
|
||||
g.EndlessLoopCheck(EndlessLoopCheckTypeTriggerQuest)
|
||||
|
||||
@@ -234,7 +234,7 @@ func (g *Game) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) {
|
||||
g.SendMsg(cmd.SceneTimeNotify, player.PlayerId, player.ClientSeq, sceneTimeNotify)
|
||||
|
||||
playerGameTimeNotify := &proto.PlayerGameTimeNotify{
|
||||
GameTime: scene.GetGameTime(),
|
||||
GameTime: world.GetGameTime(),
|
||||
Uid: player.PlayerId,
|
||||
}
|
||||
g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerId, player.ClientSeq, playerGameTimeNotify)
|
||||
|
||||
+12
-12
@@ -366,25 +366,25 @@ func (g *Game) HandleDrown(player *model.Player, stamina uint32) {
|
||||
if player.StaminaInfo.State != proto.MotionState_MOTION_SWIM_MOVE && player.StaminaInfo.State != proto.MotionState_MOTION_SWIM_DASH {
|
||||
return
|
||||
}
|
||||
logger.Debug("player drown, curStamina: %v, state: %v", stamina, player.StaminaInfo.State)
|
||||
// 设置角色为死亡
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
for _, worldAvatar := range world.GetPlayerWorldAvatarList(player) {
|
||||
dbAvatar := player.GetDbAvatar()
|
||||
avatar := dbAvatar.GetAvatarById(worldAvatar.GetAvatarId())
|
||||
if avatar == nil {
|
||||
logger.Error("get avatar is nil, avatarId: %v", worldAvatar.GetAvatarId())
|
||||
continue
|
||||
}
|
||||
if avatar.LifeState != constant.LIFE_STATE_ALIVE {
|
||||
continue
|
||||
}
|
||||
g.KillPlayerAvatar(player, worldAvatar.GetAvatarId(), proto.PlayerDieType_PLAYER_DIE_DRAWN)
|
||||
// 获取现行的角色
|
||||
activeAvatarId := player.GetDbTeam().GetActiveAvatarId()
|
||||
activeAvatar := player.GetDbAvatar().GetAvatarById(activeAvatarId)
|
||||
if activeAvatar == nil {
|
||||
logger.Error("active avatar is nil, avatarId: %v", activeAvatarId)
|
||||
return
|
||||
}
|
||||
if activeAvatar.LifeState != constant.LIFE_STATE_ALIVE {
|
||||
return
|
||||
}
|
||||
g.KillPlayerAvatar(player, activeAvatarId, proto.PlayerDieType_PLAYER_DIE_DRAWN)
|
||||
|
||||
logger.Debug("player drown, curStamina: %v, state: %v", stamina, player.StaminaInfo.State)
|
||||
}
|
||||
|
||||
// SetVehicleStamina 设置载具耐力
|
||||
|
||||
+9
-14
@@ -276,19 +276,14 @@ func (g *Game) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Message) {
|
||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
scene := world.GetSceneById(player.GetSceneId())
|
||||
if scene == nil {
|
||||
logger.Error("scene is nil, sceneId: %v, uid: %v", player.GetSceneId(), player.PlayerId)
|
||||
return
|
||||
}
|
||||
logger.Debug("change game time, gameTime: %v, uid: %v", gameTime, player.PlayerId)
|
||||
g.ChangeGameTime(scene, gameTime)
|
||||
g.ChangeGameTime(world, gameTime)
|
||||
|
||||
// 天气气象随机
|
||||
g.WeatherClimateRandom(player, player.WeatherInfo.WeatherAreaId)
|
||||
|
||||
rsp := &proto.ChangeGameTimeRsp{
|
||||
CurGameTime: scene.GetGameTime(),
|
||||
CurGameTime: world.GetGameTime(),
|
||||
}
|
||||
g.SendMsg(cmd.ChangeGameTimeRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
}
|
||||
@@ -564,15 +559,15 @@ func (g *Game) UnlockPlayerSceneArea(player *model.Player, sceneId uint32, areaI
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_UNLOCK_AREA, "", int32(sceneId), int32(areaId))
|
||||
}
|
||||
|
||||
// ChangeGameTime 修改游戏场景时间
|
||||
func (g *Game) ChangeGameTime(scene *Scene, gameTime uint32) {
|
||||
scene.ChangeGameTime(gameTime)
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
// ChangeGameTime 修改游戏时间
|
||||
func (g *Game) ChangeGameTime(world *World, gameTime uint32) {
|
||||
world.ChangeGameTime(gameTime)
|
||||
for _, player := range world.GetAllPlayer() {
|
||||
playerGameTimeNotify := &proto.PlayerGameTimeNotify{
|
||||
GameTime: scene.GetGameTime(),
|
||||
Uid: scenePlayer.PlayerId,
|
||||
GameTime: world.GetGameTime(),
|
||||
Uid: player.PlayerId,
|
||||
}
|
||||
g.SendMsg(cmd.PlayerGameTimeNotify, scenePlayer.PlayerId, scenePlayer.ClientSeq, playerGameTimeNotify)
|
||||
g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerId, player.ClientSeq, playerGameTimeNotify)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
type DbWorld struct {
|
||||
SceneMap map[uint32]*DbScene
|
||||
MapMarkList []*MapMark
|
||||
GameTime uint32 // 游戏内提瓦特大陆的时间
|
||||
}
|
||||
|
||||
type DbScene struct {
|
||||
@@ -26,6 +27,7 @@ type MapMark struct {
|
||||
func (p *Player) GetDbWorld() *DbWorld {
|
||||
if p.DbWorld == nil {
|
||||
p.DbWorld = new(DbWorld)
|
||||
p.DbWorld.GameTime = 8 * 60 // 初始时间
|
||||
}
|
||||
if p.DbWorld.SceneMap == nil {
|
||||
p.DbWorld.SceneMap = make(map[uint32]*DbScene)
|
||||
|
||||
Reference in new issue
Block a user