增加时间锁定、天气锁定属性判断
This commit is contained in:
1 parent
6af98227c7
commit
fd937a7095
9 files changed
+54
-43
No files matched your search
@@ -770,7 +770,7 @@ func (c *CommandManager) NewWeatherCommandController() *CommandController {
|
||||
AliasList: []string{"weather"},
|
||||
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>天气</color>",
|
||||
UsageList: []string{
|
||||
"{alias} [天气区域ID] <气象类型> 更改天气",
|
||||
"{alias} <气象类型> 更改天气",
|
||||
},
|
||||
Perm: CommandPermNormal,
|
||||
Func: c.WeatherCommand,
|
||||
@@ -778,21 +778,16 @@ func (c *CommandManager) NewWeatherCommandController() *CommandController {
|
||||
}
|
||||
|
||||
func (c *CommandManager) WeatherCommand(content *CommandContent) bool {
|
||||
var weatherAreaId = content.AssignPlayer.WeatherInfo.WeatherAreaId // 天气区域id
|
||||
var climateType uint32 // 气象类型
|
||||
var climateType uint32 // 气象类型
|
||||
|
||||
return content.Option("uint32", func(param any) bool {
|
||||
// 天气区域id
|
||||
weatherAreaId = param.(uint32)
|
||||
return true
|
||||
}).Dynamic("uint32", func(param any) bool {
|
||||
return content.Dynamic("uint32", func(param any) bool {
|
||||
// 气象类型
|
||||
climateType = param.(uint32)
|
||||
return true
|
||||
}).Execute(func() bool {
|
||||
// 设置天气
|
||||
c.gmCmd.GMSetWeather(content.AssignPlayer.PlayerId, weatherAreaId, climateType)
|
||||
content.SendSuccMessage(content.Executor, "已更改天气,指定UID:%v,天气区域ID:%v,气象类型:%v。", content.AssignPlayer.PlayerId, weatherAreaId, climateType)
|
||||
c.gmCmd.GMSetWeather(content.AssignPlayer.PlayerId, climateType)
|
||||
content.SendSuccMessage(content.Executor, "已更改天气,指定UID:%v,气象类型:%v。", content.AssignPlayer.PlayerId, climateType)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -405,13 +405,13 @@ func (g *GMCmd) GMUnlockAllArea(userId uint32, sceneId uint32) {
|
||||
}
|
||||
|
||||
// GMSetWeather 设置天气
|
||||
func (g *GMCmd) GMSetWeather(userId uint32, weatherAreaId uint32, climateType uint32) {
|
||||
func (g *GMCmd) GMSetWeather(userId uint32, climateType uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
GAME.SetPlayerWeather(player, weatherAreaId, climateType)
|
||||
GAME.SetPlayerWeather(player, player.WeatherInfo.WeatherAreaId, climateType, true)
|
||||
}
|
||||
|
||||
// GMCreateMonster 在玩家附近创建怪物
|
||||
|
||||
@@ -249,7 +249,12 @@ func (t *TickManager) onTickMinute(now int64) {
|
||||
gdconf.LuaStateLruRemove()
|
||||
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
||||
if world.GetOwner().SceneLoadState == model.SceneEnterDone {
|
||||
GAME.PlayerGameTimeNotify(world)
|
||||
// 天气气象随机
|
||||
for _, scene := range world.GetAllScene() {
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
GAME.WeatherClimateRandom(scenePlayer, scenePlayer.WeatherInfo.WeatherAreaId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,13 +304,12 @@ func (t *TickManager) onTickSecond(now int64) {
|
||||
if world.IsMultiplayerWorld() {
|
||||
GAME.WorldPlayerRTTNotify(world)
|
||||
}
|
||||
}
|
||||
// 每个场景时间+1
|
||||
for _, scene := range world.GetAllScene() {
|
||||
if world.GetOwner().Pause {
|
||||
continue
|
||||
// 场景时间增加
|
||||
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)
|
||||
}
|
||||
}
|
||||
scene.ChangeGameTime(scene.GetGameTime() + 1)
|
||||
}
|
||||
}
|
||||
// GCG游戏Tick
|
||||
|
||||
+2
-2
@@ -847,7 +847,7 @@ func EnterWeatherArea(luaState *lua.LState) int {
|
||||
weatherAreaId := luaState.ToInt(2)
|
||||
// 设置玩家天气
|
||||
climateType := GAME.GetWeatherAreaClimate(uint32(weatherAreaId))
|
||||
GAME.SetPlayerWeather(player, uint32(weatherAreaId), climateType)
|
||||
GAME.SetPlayerWeather(player, uint32(weatherAreaId), climateType, true)
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
}
|
||||
@@ -865,7 +865,7 @@ func SetWeatherAreaState(luaState *lua.LState) int {
|
||||
}
|
||||
weatherAreaId := luaState.ToInt(2)
|
||||
climateType := luaState.ToInt(3)
|
||||
GAME.SetPlayerWeather(player, uint32(weatherAreaId), uint32(climateType))
|
||||
GAME.SetPlayerWeather(player, uint32(weatherAreaId), uint32(climateType), true)
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -19,8 +19,13 @@ import (
|
||||
|
||||
func (g *Game) PlayerSetPauseReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.PlayerSetPauseReq)
|
||||
// 处于多人游戏中禁止暂停
|
||||
if player.IsInMp {
|
||||
g.SendError(cmd.PlayerSetPauseRsp, player, &proto.PlayerSetPauseRsp{}, proto.Retcode_RET_FAIL)
|
||||
}
|
||||
player.Pause = req.IsPaused
|
||||
g.SendMsg(cmd.PlayerSetPauseRsp, player.PlayerId, player.ClientSeq, new(proto.PlayerSetPauseRsp))
|
||||
|
||||
g.SendSucc(cmd.PlayerSetPauseRsp, player, &proto.PlayerSetPauseRsp{})
|
||||
}
|
||||
|
||||
func (g *Game) SetPlayerPropReq(player *model.Player, payloadMsg pb.Message) {
|
||||
@@ -29,7 +34,7 @@ func (g *Game) SetPlayerPropReq(player *model.Player, payloadMsg pb.Message) {
|
||||
logger.Debug("player set prop, key: %v, value: %v, uid: %v", propValue.Type, propValue.Val, player.PlayerId)
|
||||
player.PropMap[propValue.Type] = uint32(propValue.Val)
|
||||
}
|
||||
g.SendMsg(cmd.SetPlayerPropRsp, player.PlayerId, player.ClientSeq, new(proto.SetPlayerPropRsp))
|
||||
g.SendSucc(cmd.SetPlayerPropRsp, player, &proto.SetPlayerPropRsp{})
|
||||
}
|
||||
|
||||
func (g *Game) SetOpenStateReq(player *model.Player, payloadMsg pb.Message) {
|
||||
|
||||
@@ -243,9 +243,6 @@ func (g *Game) PlayerGameTimeNotify(world *World) {
|
||||
Uid: scenePlayer.PlayerId,
|
||||
}
|
||||
g.SendMsg(cmd.PlayerGameTimeNotify, scenePlayer.PlayerId, 0, playerGameTimeNotify)
|
||||
|
||||
// 天气气象随机
|
||||
g.WeatherClimateRandom(scenePlayer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,8 +195,8 @@ func (g *Game) CreatePlayer(userId uint32) *model.Player {
|
||||
player.PropMap[constant.PLAYER_PROP_IS_SPRING_AUTO_USE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_SPRING_AUTO_USE_PERCENT] = 50
|
||||
player.PropMap[constant.PLAYER_PROP_IS_FLYABLE] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_IS_WEATHER_LOCKED] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_IS_GAME_TIME_LOCKED] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_IS_WEATHER_LOCKED] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_IS_GAME_TIME_LOCKED] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_IS_TRANSFERABLE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_MAX_STAMINA] = 10000
|
||||
|
||||
|
||||
+24
-14
@@ -277,13 +277,17 @@ func (g *Game) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) {
|
||||
g.SendMsg(cmd.PlayerEnterSceneInfoNotify, player.PlayerId, player.ClientSeq, playerEnterSceneInfoNotify)
|
||||
}
|
||||
|
||||
// 设置玩家天气
|
||||
weatherAreaId := g.GetPlayerInWeatherAreaId(player, player.GetPos())
|
||||
if weatherAreaId != 0 {
|
||||
// 天气未初始化 或 未锁定天气并且是场景跳跃 更新天气
|
||||
if player.WeatherInfo.WeatherAreaId == 0 || player.PropMap[constant.PLAYER_PROP_IS_WEATHER_LOCKED] == 0 {
|
||||
// 初始化天气区域id
|
||||
weatherAreaId := g.GetPlayerInWeatherAreaId(player, player.GetPos())
|
||||
if weatherAreaId == 0 {
|
||||
logger.Error("weather area id error, weatherAreaId: %v", weatherAreaId)
|
||||
return
|
||||
}
|
||||
// 获取天气气象
|
||||
climateType := g.GetWeatherAreaClimate(weatherAreaId)
|
||||
g.SetPlayerWeather(player, weatherAreaId, climateType)
|
||||
} else {
|
||||
logger.Error("weather area id error, weatherAreaId: %v", weatherAreaId)
|
||||
g.SetPlayerWeather(player, weatherAreaId, climateType, false)
|
||||
}
|
||||
|
||||
g.UpdateWorldScenePlayerInfo(player, world)
|
||||
@@ -1521,14 +1525,18 @@ func (g *Game) GetPlayerInWeatherAreaId(player *model.Player, newPos *model.Vect
|
||||
}
|
||||
|
||||
// WeatherClimateRandom 随机天气气象
|
||||
func (g *Game) WeatherClimateRandom(player *model.Player) {
|
||||
// 设置玩家天气
|
||||
climateType := g.GetWeatherAreaClimate(player.WeatherInfo.WeatherAreaId)
|
||||
func (g *Game) WeatherClimateRandom(player *model.Player, weatherAreaId uint32) {
|
||||
// 天气气象锁定则跳过
|
||||
if player.PropMap[constant.PLAYER_PROP_IS_WEATHER_LOCKED] == 1 {
|
||||
return
|
||||
}
|
||||
// 获取天气气象
|
||||
climateType := g.GetWeatherAreaClimate(weatherAreaId)
|
||||
// 跳过相同的天气
|
||||
if climateType == player.WeatherInfo.ClimateType {
|
||||
return
|
||||
}
|
||||
g.SetPlayerWeather(player, player.WeatherInfo.WeatherAreaId, climateType)
|
||||
g.SetPlayerWeather(player, player.WeatherInfo.WeatherAreaId, climateType, true)
|
||||
}
|
||||
|
||||
// SceneWeatherAreaCheck 场景天气区域变更检测
|
||||
@@ -1551,9 +1559,8 @@ func (g *Game) SceneWeatherAreaCheck(player *model.Player, oldPos *model.Vector,
|
||||
if player.WeatherInfo.WeatherAreaId == weatherAreaId {
|
||||
return
|
||||
}
|
||||
// 设置玩家天气
|
||||
climateType := g.GetWeatherAreaClimate(weatherAreaId)
|
||||
g.SetPlayerWeather(player, weatherAreaId, climateType)
|
||||
// 随机天气气象
|
||||
g.WeatherClimateRandom(player, weatherAreaId)
|
||||
}
|
||||
|
||||
// GetWeatherAreaClimate 获取天气气象
|
||||
@@ -1616,7 +1623,7 @@ func (g *Game) GetWeatherAreaClimate(weatherAreaId uint32) uint32 {
|
||||
}
|
||||
|
||||
// SetPlayerWeather 设置玩家天气
|
||||
func (g *Game) SetPlayerWeather(player *model.Player, weatherAreaId uint32, climateType uint32) {
|
||||
func (g *Game) SetPlayerWeather(player *model.Player, weatherAreaId uint32, climateType uint32, sendNotify bool) {
|
||||
// 获取天气数据配置表
|
||||
weatherData := gdconf.GetWeatherDataByWeatherAreaId(int32(weatherAreaId))
|
||||
if weatherData == nil {
|
||||
@@ -1631,6 +1638,9 @@ func (g *Game) SetPlayerWeather(player *model.Player, weatherAreaId uint32, clim
|
||||
player.WeatherInfo.JsonWeatherAreaId = uint32(weatherData.JsonWeatherAreaId)
|
||||
player.WeatherInfo.ClimateType = climateType
|
||||
|
||||
if !sendNotify {
|
||||
return
|
||||
}
|
||||
sceneAreaWeatherNotify := &proto.SceneAreaWeatherNotify{
|
||||
WeatherAreaId: weatherAreaId,
|
||||
ClimateType: climateType,
|
||||
|
||||
@@ -285,7 +285,7 @@ func (g *Game) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Message) {
|
||||
g.ChangeGameTime(scene, gameTime)
|
||||
|
||||
// 天气气象随机
|
||||
g.WeatherClimateRandom(player)
|
||||
g.WeatherClimateRandom(player, player.WeatherInfo.WeatherAreaId)
|
||||
|
||||
rsp := &proto.ChangeGameTimeRsp{
|
||||
CurGameTime: scene.GetGameTime(),
|
||||
|
||||
Reference in new issue
Block a user