整理代码
This commit is contained in:
1 parent
e362deedf7
commit
0f9602e900
9 files changed
+146
-64
No files matched your search
+38
-10
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"hk4e/common/constant"
|
||||
"hk4e/gs/model"
|
||||
"hk4e/pkg/random"
|
||||
"hk4e/protocol/cmd"
|
||||
@@ -12,11 +13,13 @@ import (
|
||||
|
||||
const (
|
||||
PUBG_PHASE_START = 0
|
||||
PUBG_PHASE_II = 2
|
||||
PUBG_PHASE_END = 16
|
||||
)
|
||||
|
||||
const (
|
||||
PUBG_PHASE_INV_TIME = 180.0
|
||||
PUBG_PHASE_INV_TIME = 180.0
|
||||
PUBG_FIRST_AREA_REDUCE_TIME = 600.0
|
||||
)
|
||||
|
||||
type Pubg struct {
|
||||
@@ -71,20 +74,20 @@ func (p *Pubg) IsInBlueArea(pos *model.Vector) bool {
|
||||
func (p *Pubg) RefreshArea() {
|
||||
info := ""
|
||||
if p.phase == PUBG_PHASE_START {
|
||||
info = "安全区已出现"
|
||||
info = fmt.Sprintf("安全区已出现,当前%v位存活玩家。", len(p.GetAlivePlayerList()))
|
||||
p.blueAreaCenterPos = &model.Vector{X: 500.0, Y: 0.0, Z: -500.0}
|
||||
p.blueAreaRadius = 2000.0
|
||||
p.safeAreaCenterPos = &model.Vector{X: 0.0, Y: 0.0, Z: 0.0}
|
||||
p.safeAreaRadius = 0.0
|
||||
TICK_MANAGER.CreateUserTimer(p.world.GetOwner().PlayerId, UserTimerActionPubgUpdateArea, PUBG_PHASE_INV_TIME)
|
||||
} else if p.phase == PUBG_PHASE_END {
|
||||
info = "安全区已消失"
|
||||
info = "安全区已消失。"
|
||||
p.blueAreaRadius = 0.0
|
||||
p.safeAreaRadius = 0.0
|
||||
} else {
|
||||
switch p.phase % 3 {
|
||||
case 1:
|
||||
info = fmt.Sprintf("新的安全区已出现,进度%.1f%%", float64(p.phase)/PUBG_PHASE_END*100.0)
|
||||
info = fmt.Sprintf("新的安全区已出现,进度%.1f%%。", float64(p.phase)/PUBG_PHASE_END*100.0)
|
||||
p.safeAreaCenterPos = &model.Vector{
|
||||
X: p.blueAreaCenterPos.X + random.GetRandomFloat64(-(p.blueAreaRadius*0.7/2.0), p.blueAreaRadius*0.7/2.0),
|
||||
Y: 0.0,
|
||||
@@ -92,15 +95,23 @@ func (p *Pubg) RefreshArea() {
|
||||
}
|
||||
p.safeAreaRadius = p.blueAreaRadius / 2.0
|
||||
p.areaReduceRadiusSpeed = 0.0
|
||||
TICK_MANAGER.CreateUserTimer(p.world.GetOwner().PlayerId, UserTimerActionPubgUpdateArea, PUBG_PHASE_INV_TIME)
|
||||
case 2:
|
||||
info = fmt.Sprintf("安全区正在缩小,进度%.1f%%", float64(p.phase)/PUBG_PHASE_END*100.0)
|
||||
p.areaReduceRadiusSpeed = (p.blueAreaRadius - p.safeAreaRadius) / PUBG_PHASE_INV_TIME
|
||||
p.areaReduceXSpeed = (p.safeAreaCenterPos.X - p.blueAreaCenterPos.X) / PUBG_PHASE_INV_TIME
|
||||
p.areaReduceZSpeed = (p.safeAreaCenterPos.Z - p.blueAreaCenterPos.Z) / PUBG_PHASE_INV_TIME
|
||||
info = fmt.Sprintf("安全区正在缩小,进度%.1f%%。", float64(p.phase)/PUBG_PHASE_END*100.0)
|
||||
invTime := 0.0
|
||||
if p.phase == PUBG_PHASE_II {
|
||||
invTime = PUBG_FIRST_AREA_REDUCE_TIME
|
||||
} else {
|
||||
invTime = PUBG_PHASE_INV_TIME
|
||||
}
|
||||
p.areaReduceRadiusSpeed = (p.blueAreaRadius - p.safeAreaRadius) / invTime
|
||||
p.areaReduceXSpeed = (p.safeAreaCenterPos.X - p.blueAreaCenterPos.X) / invTime
|
||||
p.areaReduceZSpeed = (p.safeAreaCenterPos.Z - p.blueAreaCenterPos.Z) / invTime
|
||||
TICK_MANAGER.CreateUserTimer(p.world.GetOwner().PlayerId, UserTimerActionPubgUpdateArea, uint32(invTime))
|
||||
case 0:
|
||||
info = fmt.Sprintf("安全区缩小完毕,进度%.1f%%", float64(p.phase)/PUBG_PHASE_END*100.0)
|
||||
info = fmt.Sprintf("安全区缩小完毕,进度%.1f%%。", float64(p.phase)/PUBG_PHASE_END*100.0)
|
||||
TICK_MANAGER.CreateUserTimer(p.world.GetOwner().PlayerId, UserTimerActionPubgUpdateArea, PUBG_PHASE_INV_TIME)
|
||||
}
|
||||
TICK_MANAGER.CreateUserTimer(p.world.GetOwner().PlayerId, UserTimerActionPubgUpdateArea, PUBG_PHASE_INV_TIME)
|
||||
}
|
||||
p.SyncMapMarkArea()
|
||||
GAME.PlayerChatReq(p.world.GetOwner(), &proto.PlayerChatReq{ChatInfo: &proto.ChatInfo{Content: &proto.ChatInfo_Text{Text: info}}})
|
||||
@@ -136,3 +147,20 @@ func (p *Pubg) SyncMapMarkArea() {
|
||||
GAME.SendMsg(cmd.AllMarkPointNotify, player.PlayerId, player.ClientSeq, &proto.AllMarkPointNotify{MarkList: p.areaPointList})
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Pubg) GetAlivePlayerList() []*model.Player {
|
||||
scene := p.world.GetSceneById(p.world.GetOwner().SceneId)
|
||||
alivePlayerList := make([]*model.Player, 0)
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
if scenePlayer.PlayerId == p.world.GetOwner().PlayerId {
|
||||
continue
|
||||
}
|
||||
avatarEntityId := p.world.GetPlayerWorldAvatarEntityId(scenePlayer, p.world.GetPlayerActiveAvatarId(scenePlayer))
|
||||
entity := scene.GetEntity(avatarEntityId)
|
||||
if entity.GetFightProp()[constant.FIGHT_PROP_CUR_HP] <= 0.0 {
|
||||
continue
|
||||
}
|
||||
alivePlayerList = append(alivePlayerList, scenePlayer)
|
||||
}
|
||||
return alivePlayerList
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"hk4e/common/constant"
|
||||
@@ -35,6 +36,7 @@ type TickManager struct {
|
||||
globalTick *time.Ticker
|
||||
globalTickCount uint64
|
||||
userTickMap map[uint32]*UserTick
|
||||
tm time.Time
|
||||
}
|
||||
|
||||
func NewTickManager() (r *TickManager) {
|
||||
@@ -42,6 +44,7 @@ func NewTickManager() (r *TickManager) {
|
||||
r.globalTick = time.NewTicker(time.Millisecond * ServerTickTime)
|
||||
r.globalTickCount = 0
|
||||
r.userTickMap = make(map[uint32]*UserTick)
|
||||
r.tm = time.Now()
|
||||
logger.Info("game server tick start at: %v", time.Now().UnixMilli())
|
||||
return r
|
||||
}
|
||||
@@ -159,6 +162,7 @@ func (t *TickManager) userTimerHandle(userId uint32, action int, data []any) {
|
||||
logger.Debug("UserTimerActionPubgDieExit")
|
||||
GAME.ReLoginPlayer(player.PlayerId, true)
|
||||
case UserTimerActionPubgEnd:
|
||||
logger.Debug("UserTimerActionPubgEnd")
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, userId)
|
||||
@@ -178,7 +182,8 @@ func (t *TickManager) userTimerHandle(userId uint32, action int, data []any) {
|
||||
|
||||
func (t *TickManager) OnGameServerTick() {
|
||||
t.globalTickCount++
|
||||
now := time.Now().UnixMilli()
|
||||
tm := time.Now()
|
||||
now := tm.UnixMilli()
|
||||
if t.globalTickCount%(50/ServerTickTime) == 0 {
|
||||
t.onTick50MilliSecond(now)
|
||||
}
|
||||
@@ -225,34 +230,46 @@ func (t *TickManager) OnGameServerTick() {
|
||||
t.userTimerHandle(userId, timer.action, timer.data)
|
||||
}
|
||||
}
|
||||
if tm.Hour() != t.tm.Hour() {
|
||||
t.onHourChange(now)
|
||||
}
|
||||
if tm.Day() != t.tm.Day() {
|
||||
t.onDayChange(now)
|
||||
}
|
||||
if tm.Month() != t.tm.Month() {
|
||||
t.onMonthChange(now)
|
||||
}
|
||||
t.tm = tm
|
||||
}
|
||||
|
||||
func (t *TickManager) onMonthChange(now int64) {
|
||||
logger.Info("on month change, time: %v", now)
|
||||
}
|
||||
|
||||
func (t *TickManager) onDayChange(now int64) {
|
||||
logger.Info("on day change, time: %v", now)
|
||||
}
|
||||
|
||||
func (t *TickManager) onHourChange(now int64) {
|
||||
logger.Info("on hour change, time: %v", now)
|
||||
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
if world.GetPubg() != nil {
|
||||
continue
|
||||
}
|
||||
world.NewPubg()
|
||||
pubg := world.GetPubg()
|
||||
pubg.RefreshArea()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TickManager) onTickHour(now int64) {
|
||||
logger.Info("on tick hour, time: %v", now)
|
||||
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
if world.GetPubg() != nil {
|
||||
continue
|
||||
}
|
||||
world.NewPubg()
|
||||
pubg := world.GetPubg()
|
||||
pubg.RefreshArea()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TickManager) onTickMinute(now int64) {
|
||||
gdconf.LuaStateLruRemove()
|
||||
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
if world.GetPubg() != nil {
|
||||
continue
|
||||
}
|
||||
world.NewPubg()
|
||||
pubg := world.GetPubg()
|
||||
pubg.RefreshArea()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TickManager) onTick10Second(now int64) {
|
||||
@@ -267,14 +284,19 @@ func (t *TickManager) onTick10Second(now int64) {
|
||||
func (t *TickManager) onTick5Second(now int64) {
|
||||
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
||||
if WORLD_MANAGER.IsAiWorld(world) {
|
||||
if world.GetPubg() != nil {
|
||||
if WORLD_MANAGER.IsBigWorld(world) && world.GetPubg() != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for applyUid := range world.owner.CoopApplyMap {
|
||||
GAME.PlayerDealEnterWorld(world.owner, applyUid, true)
|
||||
}
|
||||
}
|
||||
if !WORLD_MANAGER.IsBigWorld(world) && world.GetOwner().SceneLoadState == model.SceneEnterDone {
|
||||
if world.GetOwner().SceneLoadState == model.SceneEnterDone {
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
continue
|
||||
}
|
||||
|
||||
// 多人世界其他玩家的坐标位置广播
|
||||
GAME.WorldPlayerLocationNotify(world)
|
||||
GAME.ScenePlayerLocationNotify(world)
|
||||
@@ -288,6 +310,7 @@ func (t *TickManager) onTickSecond(now int64) {
|
||||
// 世界里所有玩家的网络延迟广播
|
||||
GAME.WorldPlayerRTTNotify(world)
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
pubg := world.GetPubg()
|
||||
if pubg == nil {
|
||||
@@ -315,6 +338,14 @@ func (t *TickManager) onTickSecond(now int64) {
|
||||
})
|
||||
}
|
||||
}
|
||||
alivePlayerList := pubg.GetAlivePlayerList()
|
||||
if len(alivePlayerList) <= 1 {
|
||||
if len(alivePlayerList) == 1 {
|
||||
info := fmt.Sprintf("『%v』大吉大利,今晚吃鸡。", alivePlayerList[0].NickName)
|
||||
GAME.PlayerChatReq(world.GetOwner(), &proto.PlayerChatReq{ChatInfo: &proto.ChatInfo{Content: &proto.ChatInfo_Text{Text: info}}})
|
||||
}
|
||||
TICK_MANAGER.CreateUserTimer(world.GetOwner().PlayerId, UserTimerActionPubgEnd, 30)
|
||||
}
|
||||
}
|
||||
}
|
||||
// // GCG游戏Tick
|
||||
@@ -343,6 +374,7 @@ func (t *TickManager) onTick100MilliSecond(now int64) {
|
||||
GAME.RestoreCountStaminaHandler(player)
|
||||
}
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
|
||||
hitList := bulletPhysicsEngine.Update(now)
|
||||
|
||||
@@ -68,13 +68,15 @@ func (w *WorldManager) CreateWorld(owner *model.Player) *World {
|
||||
}
|
||||
world.mpLevelEntityId = world.GetNextWorldEntityId(constant.ENTITY_TYPE_MP_LEVEL)
|
||||
w.worldMap[worldId] = world
|
||||
|
||||
if w.IsBigWorld(world) {
|
||||
aoiManager := alg.NewAoiManager()
|
||||
aoiManager.SetAoiRange(-8000, 4000, -200, 1000, -5500, 6500)
|
||||
aoiManager.Init3DRectAoiManager(1200, 12, 1200, true)
|
||||
aoiManager.Init3DRectAoiManager(120, 12, 120, true)
|
||||
world.bigWorldAoi = aoiManager
|
||||
logger.Info("big world aoi init finish")
|
||||
}
|
||||
|
||||
return world
|
||||
}
|
||||
|
||||
@@ -99,6 +101,7 @@ func (w *WorldManager) GetAiWorld() *World {
|
||||
func (w *WorldManager) InitAiWorld(owner *model.Player) {
|
||||
w.aiWorld = w.GetWorldById(owner.WorldId)
|
||||
w.aiWorld.ChangeToMultiplayer()
|
||||
|
||||
if w.IsBigWorld(w.aiWorld) {
|
||||
w.aiWorld.NewPhysicsEngine(w.sceneBlockAoiMap)
|
||||
}
|
||||
|
||||
@@ -148,6 +148,7 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
||||
logger.Error("not found def entity, DefenseId: %v", attackResult.DefenseId)
|
||||
return
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
if world.GetPubg() == nil {
|
||||
return
|
||||
@@ -157,6 +158,7 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
fightProp := defEntity.GetFightProp()
|
||||
currHp := fightProp[constant.FIGHT_PROP_CUR_HP]
|
||||
currHp -= attackResult.Damage
|
||||
@@ -178,8 +180,8 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
||||
if currHp == 0 {
|
||||
defAvatarEntity := defEntity.GetAvatarEntity()
|
||||
g.KillPlayerAvatar(player, defAvatarEntity.GetAvatarId(), proto.PlayerDieType_PLAYER_DIE_GM)
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
info := ""
|
||||
defPlayer := USER_MANAGER.GetOnlineUser(defAvatarEntity.GetUid())
|
||||
if defPlayer == nil {
|
||||
return
|
||||
@@ -191,27 +193,8 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
||||
if atkPlayer == nil {
|
||||
return
|
||||
}
|
||||
info = fmt.Sprintf("『%v』击败了『%v』,", atkPlayer.NickName, defPlayer.NickName)
|
||||
} else {
|
||||
info = fmt.Sprintf("『%v』死亡了,", defPlayer.NickName)
|
||||
}
|
||||
alivePlayerNum := 0
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
if scenePlayer.PlayerId == world.GetOwner().PlayerId {
|
||||
continue
|
||||
}
|
||||
avatarEntityId := world.GetPlayerWorldAvatarEntityId(scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer))
|
||||
entity := scene.GetEntity(avatarEntityId)
|
||||
if entity.GetFightProp()[constant.FIGHT_PROP_CUR_HP] <= 0.0 {
|
||||
continue
|
||||
}
|
||||
alivePlayerNum++
|
||||
}
|
||||
info += fmt.Sprintf("剩余%v位存活玩家。", alivePlayerNum)
|
||||
g.PlayerChatReq(world.GetOwner(), &proto.PlayerChatReq{ChatInfo: &proto.ChatInfo{Content: &proto.ChatInfo_Text{Text: info}}})
|
||||
defPlayer.PubgRank += uint32(100 - alivePlayerNum)
|
||||
if alivePlayerNum <= 1 {
|
||||
TICK_MANAGER.CreateUserTimer(world.GetOwner().PlayerId, UserTimerActionPubgEnd, 30)
|
||||
info := fmt.Sprintf("『%v』击败了『%v』。", atkPlayer.NickName, defPlayer.NickName)
|
||||
g.PlayerChatReq(world.GetOwner(), &proto.PlayerChatReq{ChatInfo: &proto.ChatInfo{Content: &proto.ChatInfo_Text{Text: info}}})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,11 +225,13 @@ func (g *Game) handleEntityMove(player *model.Player, world *World, scene *Scene
|
||||
&model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
entity.GetId(),
|
||||
)
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
g.BigWorldAoiPlayerMove(player, world, scene, player.Pos,
|
||||
&model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
)
|
||||
}
|
||||
|
||||
// 更新玩家的位置信息
|
||||
player.Pos.X, player.Pos.Y, player.Pos.Z = pos.X, pos.Y, pos.Z
|
||||
player.Rot.X, player.Rot.Y, player.Rot.Z = rot.X, rot.Y, rot.Z
|
||||
@@ -297,6 +282,7 @@ func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
return
|
||||
}
|
||||
|
||||
// 服务器处理玩家移动场景区块aoi事件频率限制
|
||||
now := uint64(time.Now().UnixMilli())
|
||||
if now-player.LastSceneBlockAoiMoveTime < 200 {
|
||||
@@ -366,11 +352,13 @@ func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene
|
||||
if exist {
|
||||
continue
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// 旧有新没有的实体即为消失的
|
||||
delEntityIdList = append(delEntityIdList, entityId)
|
||||
}
|
||||
@@ -380,11 +368,13 @@ func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene
|
||||
if exist {
|
||||
continue
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// 新有旧没有的实体即为出现的
|
||||
addEntityIdList = append(addEntityIdList, entityId)
|
||||
}
|
||||
@@ -724,6 +714,7 @@ func (g *Game) EvtBulletHitNotify(player *model.Player, payloadMsg pb.Message) {
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
g.SendToSceneA(scene, cmd.EvtBulletHitNotify, player.ClientSeq, req)
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
|
||||
if bulletPhysicsEngine.IsRigidBody(req.EntityId) {
|
||||
@@ -772,6 +763,7 @@ func (g *Game) EvtCreateGadgetNotify(player *model.Player, payloadMsg pb.Message
|
||||
Z: float64(req.InitEulerAngles.Z),
|
||||
}, req.EntityId, req.ConfigId, req.CampId, req.CampType, req.OwnerEntityId, req.TargetEntityId, req.PropOwnerEntityId)
|
||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{req.EntityId}, true, true)
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
// 甘雨冰属性蓄力箭
|
||||
if req.ConfigId == 41037009 && world.GetMultiplayer() {
|
||||
|
||||
@@ -367,7 +367,7 @@ func (g *Game) PlayerLeaveWorld(player *model.Player) bool {
|
||||
}
|
||||
|
||||
func (g *Game) WorldAddPlayer(world *World, player *model.Player) {
|
||||
if !WORLD_MANAGER.IsBigWorld(world) && world.GetWorldPlayerNum() >= 4 {
|
||||
if world.GetWorldPlayerNum() >= 4 && !WORLD_MANAGER.IsBigWorld(world) {
|
||||
return
|
||||
}
|
||||
_, exist := world.GetAllPlayer()[player.PlayerId]
|
||||
@@ -422,10 +422,12 @@ func (g *Game) WorldRemovePlayer(world *World, player *model.Player) {
|
||||
}
|
||||
|
||||
world.RemovePlayer(player)
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
bigWorldAoi := world.GetBigWorldAoi()
|
||||
bigWorldAoi.RemoveObjectFromGridByPos(int64(player.PlayerId), float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
||||
}
|
||||
|
||||
player.WorldId = 0
|
||||
if world.GetOwner().PlayerId == player.PlayerId {
|
||||
// 房主离开销毁世界
|
||||
|
||||
@@ -59,6 +59,7 @@ func (g *Game) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Message) {
|
||||
delEntityIdList = append(delEntityIdList, entityId)
|
||||
}
|
||||
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, delEntityIdList)
|
||||
|
||||
if !WORLD_MANAGER.IsBigWorld(world) {
|
||||
// 卸载旧位置附近的group
|
||||
for _, groupConfig := range g.GetNeighborGroup(ctx.OldSceneId, ctx.OldPos) {
|
||||
@@ -325,6 +326,7 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
|
||||
g.AddSceneGroup(player, scene, groupConfig)
|
||||
}
|
||||
}
|
||||
|
||||
// 同步客户端视野内的场景实体
|
||||
visionEntityMap := g.GetVisionEntity(scene, player.Pos)
|
||||
entityIdList := make([]uint32, 0)
|
||||
@@ -332,11 +334,13 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
|
||||
if entityId == activeWorldAvatar.GetAvatarEntityId() {
|
||||
continue
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
entityIdList = append(entityIdList, entityId)
|
||||
}
|
||||
g.AddSceneEntityNotify(player, visionType, entityIdList, false, false)
|
||||
@@ -345,6 +349,7 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
|
||||
vehicleEntityIdList := g.CreateSceneVehicle(scene)
|
||||
g.AddSceneEntityNotify(player, visionType, vehicleEntityIdList, false, false)
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
bigWorldAoi := world.GetBigWorldAoi()
|
||||
otherWorldAvatarMap := bigWorldAoi.GetObjectListByPos(float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
||||
@@ -633,6 +638,7 @@ func (g *Game) KillPlayerAvatar(player *model.Player, avatarId uint32, dieType p
|
||||
}
|
||||
g.SendToWorldA(world, cmd.AvatarLifeStateChangeNotify, 0, ntf)
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
TICK_MANAGER.CreateUserTimer(player.PlayerId, UserTimerActionPubgDieExit, 10)
|
||||
}
|
||||
|
||||
@@ -45,9 +45,11 @@ func (g *Game) GetPlayerSocialDetailReq(player *model.Player, payloadMsg pb.Mess
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
socialDetail.FinishAchievementNum = player.PubgRank
|
||||
socialDetail.FinishAchievementNum = targetPlayer.PubgRank
|
||||
}
|
||||
|
||||
getPlayerSocialDetailRsp := &proto.GetPlayerSocialDetailRsp{
|
||||
DetailData: socialDetail,
|
||||
}
|
||||
|
||||
+19
-6
@@ -1,6 +1,8 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"hk4e/common/constant"
|
||||
"hk4e/gdconf"
|
||||
"hk4e/gs/model"
|
||||
@@ -197,8 +199,20 @@ func (g *Game) AvatarDieAnimationEndReq(player *model.Player, payloadMsg pb.Mess
|
||||
return
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
entity := scene.GetEntity(uint32(req.DieGuid))
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
pubg := world.GetPubg()
|
||||
if pubg != nil {
|
||||
alivePlayerNum := len(pubg.GetAlivePlayerList())
|
||||
info := fmt.Sprintf("『%v』死亡了,剩余%v位存活玩家。", player.NickName, alivePlayerNum)
|
||||
g.PlayerChatReq(world.GetOwner(), &proto.PlayerChatReq{ChatInfo: &proto.ChatInfo{Content: &proto.ChatInfo_Text{Text: info}}})
|
||||
player.PubgRank += uint32(100 - alivePlayerNum)
|
||||
g.SendMsg(cmd.AvatarDieAnimationEndRsp, player.PlayerId, player.ClientSeq, &proto.AvatarDieAnimationEndRsp{SkillId: req.SkillId, DieGuid: req.DieGuid})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
entity := scene.GetEntity(uint32(req.DieGuid))
|
||||
if entity.GetLastDieType() == int32(proto.PlayerDieType_PLAYER_DIE_DRAWN) {
|
||||
maxStamina := player.PropertiesMap[constant.PLAYER_PROP_MAX_STAMINA]
|
||||
// 设置玩家耐力为一半
|
||||
@@ -240,21 +254,19 @@ func (g *Game) AvatarDieAnimationEndReq(player *model.Player, payloadMsg pb.Mess
|
||||
}
|
||||
}
|
||||
|
||||
rsp := &proto.AvatarDieAnimationEndRsp{
|
||||
SkillId: req.SkillId,
|
||||
DieGuid: req.DieGuid,
|
||||
}
|
||||
g.SendMsg(cmd.AvatarDieAnimationEndRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
g.SendMsg(cmd.AvatarDieAnimationEndRsp, player.PlayerId, player.ClientSeq, &proto.AvatarDieAnimationEndRsp{SkillId: req.SkillId, DieGuid: req.DieGuid})
|
||||
}
|
||||
|
||||
func (g *Game) WorldPlayerReviveReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.WorldPlayerReviveReq)
|
||||
_ = req
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
GAME.ReLoginPlayer(player.PlayerId, true)
|
||||
return
|
||||
}
|
||||
|
||||
g.TeleportPlayer(
|
||||
player,
|
||||
proto.EnterReason_ENTER_REASON_REVIVAL,
|
||||
@@ -330,6 +342,7 @@ func (g *Game) PacketSceneTeamUpdateNotify(world *World, player *model.Player) *
|
||||
if WORLD_MANAGER.IsBigWorld(world) && worldAvatar.uid != player.PlayerId {
|
||||
continue
|
||||
}
|
||||
|
||||
worldPlayer := USER_MANAGER.GetOnlineUser(worldAvatar.GetUid())
|
||||
if worldPlayer == nil {
|
||||
logger.Error("player is nil, uid: %v", worldAvatar.GetUid())
|
||||
|
||||
@@ -143,6 +143,7 @@ func (g *Game) MarkMapReq(player *model.Player, payloadMsg pb.Message) {
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
pubg := world.GetPubg()
|
||||
if pubg != nil {
|
||||
@@ -150,6 +151,7 @@ func (g *Game) MarkMapReq(player *model.Player, payloadMsg pb.Message) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 地图标点传送
|
||||
if req.Op == proto.MarkMapReq_ADD && req.Mark.PointType == proto.MapMarkPointType_NPC && strings.Contains(req.Mark.Name, "@@") {
|
||||
posYStr := strings.ReplaceAll(req.Mark.Name, "@@", "")
|
||||
@@ -594,10 +596,12 @@ func (g *Game) TeleportPlayer(
|
||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
|
||||
if WORLD_MANAGER.IsBigWorld(world) && sceneId != 3 {
|
||||
logger.Error("big world scene not support now, sceneId: %v, uid: %v", sceneId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
|
||||
newSceneId := sceneId
|
||||
oldSceneId := player.SceneId
|
||||
oldPos := &model.Vector{X: player.Pos.X, Y: player.Pos.Y, Z: player.Pos.Z}
|
||||
|
||||
Reference in new issue
Block a user