[原大逃杀]初步
This commit is contained in:
1 parent
d4bb36b02f
commit
e362deedf7
18 files changed
+534
-146
No files matched your search
+3
-1
@@ -88,7 +88,9 @@ func NewGameCore(db *dao.Dao, messageQueue *mq.MessageQueue, gsId uint32, gsAppi
|
||||
r.isStop = false
|
||||
WORLD_MANAGER.InitAiWorld(r.ai)
|
||||
COMMAND_MANAGER.SetSystem(r.ai)
|
||||
COMMAND_MANAGER.gmCmd.GMUnlockAllPoint(r.ai.PlayerId, 3)
|
||||
if !r.IsMainGs() {
|
||||
COMMAND_MANAGER.gmCmd.GMUnlockAllPoint(r.ai.PlayerId, 3)
|
||||
}
|
||||
USER_MANAGER.SetRemoteUserOnlineState(BigWorldAiUid, true, mainGsAppid)
|
||||
r.run()
|
||||
return r
|
||||
|
||||
@@ -3,7 +3,6 @@ package game
|
||||
import (
|
||||
"math"
|
||||
|
||||
"hk4e/common/constant"
|
||||
"hk4e/pkg/alg"
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
@@ -98,15 +97,10 @@ func (p *PhysicsEngine) Update(now int64) []*RigidBody {
|
||||
|
||||
func (p *PhysicsEngine) Collision(sceneId uint32, avatarEntityId uint32, oldPos *alg.Vector3, newPos *alg.Vector3) uint32 {
|
||||
scene := p.world.GetSceneById(sceneId)
|
||||
for _, entity := range scene.GetAllEntity() {
|
||||
if entity.GetEntityType() != constant.ENTITY_TYPE_AVATAR {
|
||||
continue
|
||||
}
|
||||
avatarEntity := entity.GetAvatarEntity()
|
||||
player := USER_MANAGER.GetOnlineUser(avatarEntity.GetUid())
|
||||
if avatarEntity.GetAvatarId() != p.world.GetPlayerActiveAvatarId(player) {
|
||||
continue
|
||||
}
|
||||
world := scene.GetWorld()
|
||||
for _, player := range scene.GetAllPlayer() {
|
||||
entityId := world.GetPlayerWorldAvatarEntityId(player, world.GetPlayerActiveAvatarId(player))
|
||||
entity := scene.GetEntity(entityId)
|
||||
if entity.GetId() == avatarEntityId {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"hk4e/gs/model"
|
||||
"hk4e/pkg/random"
|
||||
"hk4e/protocol/cmd"
|
||||
"hk4e/protocol/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
PUBG_PHASE_START = 0
|
||||
PUBG_PHASE_END = 16
|
||||
)
|
||||
|
||||
const (
|
||||
PUBG_PHASE_INV_TIME = 180.0
|
||||
)
|
||||
|
||||
type Pubg struct {
|
||||
world *World // 世界对象
|
||||
blueAreaCenterPos *model.Vector // 蓝区中心点
|
||||
blueAreaRadius float64 // 蓝区半径
|
||||
safeAreaCenterPos *model.Vector // 安全区中心点
|
||||
safeAreaRadius float64 // 安全区半径
|
||||
phase int // 阶段
|
||||
areaReduceRadiusSpeed float64 // 缩圈半径速度
|
||||
areaReduceXSpeed float64 // 缩圈X速度
|
||||
areaReduceZSpeed float64 // 缩圈Z速度
|
||||
areaPointList []*proto.MapMarkPoint // 客户端区域地图坐标列表
|
||||
}
|
||||
|
||||
func (w *World) NewPubg() {
|
||||
w.pubg = &Pubg{
|
||||
world: w,
|
||||
blueAreaCenterPos: &model.Vector{X: 0.0, Y: 0.0, Z: 0.0},
|
||||
blueAreaRadius: 0.0,
|
||||
safeAreaCenterPos: &model.Vector{X: 0.0, Y: 0.0, Z: 0.0},
|
||||
safeAreaRadius: 0.0,
|
||||
phase: PUBG_PHASE_START,
|
||||
areaReduceRadiusSpeed: 0.0,
|
||||
areaReduceXSpeed: 0.0,
|
||||
areaReduceZSpeed: 0.0,
|
||||
areaPointList: make([]*proto.MapMarkPoint, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Pubg) GetAreaPointList() []*proto.MapMarkPoint {
|
||||
return p.areaPointList
|
||||
}
|
||||
|
||||
func (p *Pubg) UpdateArea() {
|
||||
if p.areaReduceRadiusSpeed > 0.0 && p.blueAreaRadius > p.safeAreaRadius {
|
||||
p.blueAreaRadius -= p.areaReduceRadiusSpeed
|
||||
p.blueAreaCenterPos.X += p.areaReduceXSpeed
|
||||
p.blueAreaCenterPos.Z += p.areaReduceZSpeed
|
||||
p.SyncMapMarkArea()
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Pubg) IsInBlueArea(pos *model.Vector) bool {
|
||||
distance2D := math.Sqrt(
|
||||
(p.blueAreaCenterPos.X-pos.X)*(p.blueAreaCenterPos.X-pos.X) +
|
||||
(p.blueAreaCenterPos.Z-pos.Z)*(p.blueAreaCenterPos.Z-pos.Z),
|
||||
)
|
||||
return distance2D < p.blueAreaRadius
|
||||
}
|
||||
|
||||
func (p *Pubg) RefreshArea() {
|
||||
info := ""
|
||||
if p.phase == PUBG_PHASE_START {
|
||||
info = "安全区已出现"
|
||||
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 = "安全区已消失"
|
||||
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)
|
||||
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,
|
||||
Z: p.blueAreaCenterPos.Z + random.GetRandomFloat64(-(p.blueAreaRadius*0.7/2.0), p.blueAreaRadius*0.7/2.0),
|
||||
}
|
||||
p.safeAreaRadius = p.blueAreaRadius / 2.0
|
||||
p.areaReduceRadiusSpeed = 0.0
|
||||
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
|
||||
case 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)
|
||||
}
|
||||
p.SyncMapMarkArea()
|
||||
GAME.PlayerChatReq(p.world.GetOwner(), &proto.PlayerChatReq{ChatInfo: &proto.ChatInfo{Content: &proto.ChatInfo_Text{Text: info}}})
|
||||
}
|
||||
|
||||
func (p *Pubg) SyncMapMarkArea() {
|
||||
p.areaPointList = make([]*proto.MapMarkPoint, 0)
|
||||
if p.blueAreaRadius > 0.0 {
|
||||
for angleStep := 0; angleStep < 360; angleStep += 5 {
|
||||
x := p.blueAreaRadius*math.Cos(float64(angleStep)/360.0*2*math.Pi) + p.blueAreaCenterPos.X
|
||||
z := p.blueAreaRadius*math.Sin(float64(angleStep)/360.0*2*math.Pi) + p.blueAreaCenterPos.Z
|
||||
p.areaPointList = append(p.areaPointList, &proto.MapMarkPoint{
|
||||
SceneId: 3,
|
||||
Name: "",
|
||||
Pos: &proto.Vector{X: float32(x), Y: 0, Z: float32(z)},
|
||||
PointType: proto.MapMarkPointType_SPECIAL,
|
||||
})
|
||||
}
|
||||
}
|
||||
if p.safeAreaRadius > 0.0 {
|
||||
for angleStep := 0; angleStep < 360; angleStep += 5 {
|
||||
x := p.safeAreaRadius*math.Cos(float64(angleStep)/360.0*2*math.Pi) + p.safeAreaCenterPos.X
|
||||
z := p.safeAreaRadius*math.Sin(float64(angleStep)/360.0*2*math.Pi) + p.safeAreaCenterPos.Z
|
||||
p.areaPointList = append(p.areaPointList, &proto.MapMarkPoint{
|
||||
SceneId: 3,
|
||||
Name: "",
|
||||
Pos: &proto.Vector{X: float32(x), Y: 0, Z: float32(z)},
|
||||
PointType: proto.MapMarkPointType_COLLECTION,
|
||||
})
|
||||
}
|
||||
}
|
||||
for _, player := range p.world.GetAllPlayer() {
|
||||
GAME.SendMsg(cmd.AllMarkPointNotify, player.PlayerId, player.ClientSeq, &proto.AllMarkPointNotify{MarkList: p.areaPointList})
|
||||
}
|
||||
}
|
||||
@@ -75,8 +75,9 @@ func (t *TickManager) CreateUserTimer(userId uint32, action int, delay uint32, d
|
||||
return
|
||||
}
|
||||
userTick.timerIdCounter++
|
||||
timeout := time.Now().UnixMilli() + int64(delay)*1000
|
||||
userTick.timerMap[userTick.timerIdCounter] = &UserTimer{
|
||||
timeout: int64(delay * 1000),
|
||||
timeout: timeout,
|
||||
action: action,
|
||||
data: data,
|
||||
}
|
||||
@@ -110,6 +111,9 @@ const (
|
||||
UserTimerActionTest = iota
|
||||
UserTimerActionLuaCreateMonster
|
||||
UserTimerActionLuaGroupTimerEvent
|
||||
UserTimerActionPubgUpdateArea
|
||||
UserTimerActionPubgDieExit
|
||||
UserTimerActionPubgEnd
|
||||
)
|
||||
|
||||
func (t *TickManager) userTimerHandle(userId uint32, action int, data []any) {
|
||||
@@ -141,6 +145,32 @@ func (t *TickManager) userTimerHandle(userId uint32, action int, data []any) {
|
||||
return
|
||||
}
|
||||
GAME.TimerEventTriggerCheck(player, group, source)
|
||||
case UserTimerActionPubgUpdateArea:
|
||||
logger.Debug("UserTimerActionPubgUpdateArea")
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, userId)
|
||||
return
|
||||
}
|
||||
pubg := world.GetPubg()
|
||||
pubg.phase++
|
||||
pubg.RefreshArea()
|
||||
case UserTimerActionPubgDieExit:
|
||||
logger.Debug("UserTimerActionPubgDieExit")
|
||||
GAME.ReLoginPlayer(player.PlayerId, true)
|
||||
case UserTimerActionPubgEnd:
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, userId)
|
||||
return
|
||||
}
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
if worldPlayer.PlayerId == world.GetOwner().PlayerId {
|
||||
continue
|
||||
}
|
||||
GAME.ReLoginPlayer(worldPlayer.PlayerId, true)
|
||||
}
|
||||
world.pubg = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,10 +229,30 @@ func (t *TickManager) OnGameServerTick() {
|
||||
|
||||
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) {
|
||||
@@ -217,11 +267,14 @@ 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 {
|
||||
continue
|
||||
}
|
||||
for applyUid := range world.owner.CoopApplyMap {
|
||||
GAME.PlayerDealEnterWorld(world.owner, applyUid, true)
|
||||
}
|
||||
}
|
||||
if world.GetOwner().SceneLoadState == model.SceneEnterDone {
|
||||
if !WORLD_MANAGER.IsBigWorld(world) && world.GetOwner().SceneLoadState == model.SceneEnterDone {
|
||||
// 多人世界其他玩家的坐标位置广播
|
||||
GAME.WorldPlayerLocationNotify(world)
|
||||
GAME.ScenePlayerLocationNotify(world)
|
||||
@@ -235,6 +288,34 @@ func (t *TickManager) onTickSecond(now int64) {
|
||||
// 世界里所有玩家的网络延迟广播
|
||||
GAME.WorldPlayerRTTNotify(world)
|
||||
}
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
pubg := world.GetPubg()
|
||||
if pubg == nil {
|
||||
continue
|
||||
}
|
||||
pubg.UpdateArea()
|
||||
scene := world.GetSceneById(world.GetOwner().SceneId)
|
||||
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
|
||||
}
|
||||
if !pubg.IsInBlueArea(scenePlayer.Pos) {
|
||||
scene := world.GetSceneById(scenePlayer.SceneId)
|
||||
GAME.handleEvtBeingHit(scenePlayer, scene, &proto.EvtBeingHitInfo{
|
||||
AttackResult: &proto.AttackResult{
|
||||
AttackerId: 0,
|
||||
DefenseId: world.GetPlayerWorldAvatarEntityId(scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer)),
|
||||
Damage: 10,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// // GCG游戏Tick
|
||||
// for _, game := range GCG_MANAGER.gameMap {
|
||||
@@ -262,19 +343,21 @@ func (t *TickManager) onTick100MilliSecond(now int64) {
|
||||
GAME.RestoreCountStaminaHandler(player)
|
||||
}
|
||||
}
|
||||
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
|
||||
hitList := bulletPhysicsEngine.Update(now)
|
||||
for _, rigidBody := range hitList {
|
||||
scene := world.GetSceneById(rigidBody.sceneId)
|
||||
defAvatarEntity := scene.GetEntity(rigidBody.hitAvatarEntityId)
|
||||
defPlayer := USER_MANAGER.GetOnlineUser(defAvatarEntity.GetAvatarEntity().GetUid())
|
||||
GAME.handleEvtBeingHit(defPlayer, scene, &proto.EvtBeingHitInfo{
|
||||
AttackResult: &proto.AttackResult{
|
||||
AttackerId: rigidBody.avatarEntityId,
|
||||
DefenseId: rigidBody.hitAvatarEntityId,
|
||||
Damage: 100,
|
||||
},
|
||||
})
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
|
||||
hitList := bulletPhysicsEngine.Update(now)
|
||||
for _, rigidBody := range hitList {
|
||||
scene := world.GetSceneById(rigidBody.sceneId)
|
||||
defAvatarEntity := scene.GetEntity(rigidBody.hitAvatarEntityId)
|
||||
defPlayer := USER_MANAGER.GetOnlineUser(defAvatarEntity.GetAvatarEntity().GetUid())
|
||||
GAME.handleEvtBeingHit(defPlayer, scene, &proto.EvtBeingHitInfo{
|
||||
AttackResult: &proto.AttackResult{
|
||||
AttackerId: rigidBody.avatarEntityId,
|
||||
DefenseId: rigidBody.hitAvatarEntityId,
|
||||
Damage: 100,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ func (w *WorldManager) CreateWorld(owner *model.Player) *World {
|
||||
peerList: make([]*model.Player, 0),
|
||||
bigWorldAoi: nil,
|
||||
}
|
||||
world.NewPhysicsEngine(w.sceneBlockAoiMap)
|
||||
world.mpLevelEntityId = world.GetNextWorldEntityId(constant.ENTITY_TYPE_MP_LEVEL)
|
||||
w.worldMap[worldId] = world
|
||||
if w.IsBigWorld(world) {
|
||||
@@ -100,6 +99,9 @@ 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)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WorldManager) IsAiWorld(world *World) bool {
|
||||
@@ -223,12 +225,17 @@ type World struct {
|
||||
peerList []*model.Player // 玩家编号列表
|
||||
bigWorldAoi *alg.AoiManager // 大世界的aoi管理器
|
||||
bulletPhysicsEngine *PhysicsEngine // 蓄力箭子弹物理引擎
|
||||
pubg *Pubg
|
||||
}
|
||||
|
||||
func (w *World) GetBulletPhysicsEngine() *PhysicsEngine {
|
||||
return w.bulletPhysicsEngine
|
||||
}
|
||||
|
||||
func (w *World) GetPubg() *Pubg {
|
||||
return w.pubg
|
||||
}
|
||||
|
||||
func (w *World) GetId() uint32 {
|
||||
return w.id
|
||||
}
|
||||
|
||||
+101
-47
@@ -1,6 +1,7 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -136,17 +137,27 @@ func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Messa
|
||||
}
|
||||
|
||||
func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *proto.EvtBeingHitInfo) {
|
||||
world := scene.GetWorld()
|
||||
attackResult := hitInfo.AttackResult
|
||||
if attackResult == nil {
|
||||
logger.Error("attackResult is nil")
|
||||
return
|
||||
}
|
||||
target := scene.GetEntity(attackResult.DefenseId)
|
||||
if target == nil {
|
||||
logger.Error("could not found target, defense id: %v", attackResult.DefenseId)
|
||||
defEntity := scene.GetEntity(attackResult.DefenseId)
|
||||
if defEntity == nil {
|
||||
logger.Error("not found def entity, DefenseId: %v", attackResult.DefenseId)
|
||||
return
|
||||
}
|
||||
fightProp := target.GetFightProp()
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
if world.GetPubg() == nil {
|
||||
return
|
||||
}
|
||||
if defEntity.GetEntityType() == constant.ENTITY_TYPE_AVATAR &&
|
||||
defEntity.GetAvatarEntity().GetUid() == world.GetOwner().PlayerId {
|
||||
return
|
||||
}
|
||||
}
|
||||
fightProp := defEntity.GetFightProp()
|
||||
currHp := fightProp[constant.FIGHT_PROP_CUR_HP]
|
||||
currHp -= attackResult.Damage
|
||||
deltaHp := -attackResult.Damage
|
||||
@@ -155,32 +166,68 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
||||
currHp = 0
|
||||
}
|
||||
fightProp[constant.FIGHT_PROP_CUR_HP] = currHp
|
||||
g.EntityFightPropUpdateNotifyBroadcast(scene, target)
|
||||
switch target.GetEntityType() {
|
||||
g.EntityFightPropUpdateNotifyBroadcast(scene, defEntity)
|
||||
switch defEntity.GetEntityType() {
|
||||
case constant.ENTITY_TYPE_AVATAR:
|
||||
g.SendMsg(cmd.EntityFightPropChangeReasonNotify, player.PlayerId, player.ClientSeq, &proto.EntityFightPropChangeReasonNotify{
|
||||
PropDelta: deltaHp,
|
||||
ChangeHpReason: proto.ChangHpReason_CHANGE_HP_SUB_GM,
|
||||
EntityId: target.GetId(),
|
||||
EntityId: defEntity.GetId(),
|
||||
PropType: constant.FIGHT_PROP_CUR_HP,
|
||||
})
|
||||
if currHp == 0 {
|
||||
avatarEntity := target.GetAvatarEntity()
|
||||
g.KillPlayerAvatar(player, avatarEntity.GetAvatarId(), proto.PlayerDieType_PLAYER_DIE_GM)
|
||||
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
|
||||
}
|
||||
atkEntity := scene.GetEntity(attackResult.AttackerId)
|
||||
if atkEntity != nil && atkEntity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
||||
atkAvatarEntity := atkEntity.GetAvatarEntity()
|
||||
atkPlayer := USER_MANAGER.GetOnlineUser(atkAvatarEntity.GetUid())
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
case constant.ENTITY_TYPE_MONSTER:
|
||||
if currHp == 0 {
|
||||
g.KillEntity(player, scene, target.GetId(), proto.PlayerDieType_PLAYER_DIE_GM)
|
||||
g.KillEntity(player, scene, defEntity.GetId(), proto.PlayerDieType_PLAYER_DIE_GM)
|
||||
}
|
||||
case constant.ENTITY_TYPE_GADGET:
|
||||
gadgetEntity := target.GetGadgetEntity()
|
||||
gadgetEntity := defEntity.GetGadgetEntity()
|
||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetEntity.GetGadgetId()))
|
||||
if gadgetDataConfig == nil {
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v", gadgetEntity.GetGadgetId())
|
||||
break
|
||||
}
|
||||
logger.Debug("[EvtBeingHit] GadgetData: %+v, EntityId: %v, uid: %v", gadgetDataConfig, target.GetId(), player.PlayerId)
|
||||
g.handleGadgetEntityBeHitLow(player, target, attackResult.ElementType)
|
||||
logger.Debug("[EvtBeingHit] GadgetData: %+v, EntityId: %v, uid: %v", gadgetDataConfig, defEntity.GetId(), player.PlayerId)
|
||||
g.handleGadgetEntityBeHitLow(player, defEntity, attackResult.ElementType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,6 +294,9 @@ func (g *Game) handleEntityMove(player *model.Player, world *World, scene *Scene
|
||||
}
|
||||
|
||||
func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene *Scene, oldPos *model.Vector, newPos *model.Vector, entityId uint32) {
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
return
|
||||
}
|
||||
// 服务器处理玩家移动场景区块aoi事件频率限制
|
||||
now := uint64(time.Now().UnixMilli())
|
||||
if now-player.LastSceneBlockAoiMoveTime < 200 {
|
||||
@@ -672,14 +722,16 @@ func (g *Game) EvtBulletHitNotify(player *model.Player, payloadMsg pb.Message) {
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
|
||||
if bulletPhysicsEngine.IsRigidBody(req.EntityId) {
|
||||
logger.Debug("[FPS] EvtBulletHitNotify: %+v", req)
|
||||
bulletPhysicsEngine.DestroyRigidBody(req.EntityId)
|
||||
_ = req.HitPoint
|
||||
}
|
||||
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) {
|
||||
logger.Debug("[FPS] EvtBulletHitNotify: %+v", req)
|
||||
bulletPhysicsEngine.DestroyRigidBody(req.EntityId)
|
||||
_ = req.HitPoint
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Game) EvtBulletMoveNotify(player *model.Player, payloadMsg pb.Message) {
|
||||
@@ -706,34 +758,6 @@ func (g *Game) EvtCreateGadgetNotify(player *model.Player, payloadMsg pb.Message
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
// 甘雨冰属性蓄力箭
|
||||
if req.ConfigId == 41037009 && world.GetMultiplayer() {
|
||||
logger.Debug("[FPS] EvtCreateGadgetNotify: %+v", req)
|
||||
pitchAngleRaw := float64(req.InitEulerAngles.X)
|
||||
pitchAngle := 0.0
|
||||
if pitchAngleRaw < 90.0 {
|
||||
pitchAngle = -pitchAngleRaw
|
||||
} else if pitchAngleRaw > 270.0 {
|
||||
pitchAngle = 360.0 - pitchAngleRaw
|
||||
} else {
|
||||
logger.Error("invalid raw pitch angle: %v, uid: %v", pitchAngleRaw, player.PlayerId)
|
||||
return
|
||||
}
|
||||
vy := math.Sin(pitchAngle/360.0*2*math.Pi) * 50.0
|
||||
vxz := math.Cos(pitchAngle/360.0*2*math.Pi) * 50.0
|
||||
yawAngle := float64(req.InitEulerAngles.Y)
|
||||
vx := math.Sin(yawAngle/360.0*2*math.Pi) * vxz
|
||||
vz := math.Cos(yawAngle/360.0*2*math.Pi) * vxz
|
||||
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
|
||||
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
||||
bulletPhysicsEngine.CreateRigidBody(
|
||||
req.EntityId,
|
||||
world.GetPlayerWorldAvatarEntityId(player, activeAvatarId),
|
||||
player.SceneId,
|
||||
req.InitPos.X, req.InitPos.Y, req.InitPos.Z,
|
||||
float32(vx), float32(vy), float32(vz),
|
||||
)
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
if req.InitPos == nil {
|
||||
return
|
||||
@@ -748,6 +772,36 @@ 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() {
|
||||
logger.Debug("[FPS] EvtCreateGadgetNotify: %+v", req)
|
||||
pitchAngleRaw := float64(req.InitEulerAngles.X)
|
||||
pitchAngle := 0.0
|
||||
if pitchAngleRaw < 90.0 {
|
||||
pitchAngle = -pitchAngleRaw
|
||||
} else if pitchAngleRaw > 270.0 {
|
||||
pitchAngle = 360.0 - pitchAngleRaw
|
||||
} else {
|
||||
logger.Error("invalid raw pitch angle: %v, uid: %v", pitchAngleRaw, player.PlayerId)
|
||||
return
|
||||
}
|
||||
vy := math.Sin(pitchAngle/360.0*2*math.Pi) * 50.0
|
||||
vxz := math.Cos(pitchAngle/360.0*2*math.Pi) * 50.0
|
||||
yawAngle := float64(req.InitEulerAngles.Y)
|
||||
vx := math.Sin(yawAngle/360.0*2*math.Pi) * vxz
|
||||
vz := math.Cos(yawAngle/360.0*2*math.Pi) * vxz
|
||||
bulletPhysicsEngine := world.GetBulletPhysicsEngine()
|
||||
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
||||
bulletPhysicsEngine.CreateRigidBody(
|
||||
req.EntityId,
|
||||
world.GetPlayerWorldAvatarEntityId(player, activeAvatarId),
|
||||
player.SceneId,
|
||||
req.InitPos.X, req.InitPos.Y, req.InitPos.Z,
|
||||
float32(vx), float32(vy), float32(vz),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Game) EvtDestroyGadgetNotify(player *model.Player, payloadMsg pb.Message) {
|
||||
|
||||
+3
-10
@@ -90,14 +90,6 @@ func (g *Game) OnLogin(userId uint32, clientSeq uint32, gateAppId string, player
|
||||
|
||||
// 初始化
|
||||
player.InitOnlineData()
|
||||
dbAvatar := player.GetDbAvatar()
|
||||
dbAvatar.InitAllAvatar(player)
|
||||
dbReliquary := player.GetDbReliquary()
|
||||
dbReliquary.InitAllReliquary(player)
|
||||
dbWeapon := player.GetDbWeapon()
|
||||
dbWeapon.InitAllWeapon(player)
|
||||
dbItem := player.GetDbItem()
|
||||
dbItem.InitAllItem(player)
|
||||
|
||||
// 确保玩家位置安全
|
||||
player.Pos.X = player.SafePos.X
|
||||
@@ -166,9 +158,9 @@ func (g *Game) OnLogin(userId uint32, clientSeq uint32, gateAppId string, player
|
||||
func (g *Game) CreatePlayer(userId uint32) *model.Player {
|
||||
player := new(model.Player)
|
||||
player.PlayerId = userId
|
||||
player.NickName = ""
|
||||
player.NickName = "旅行者"
|
||||
player.Signature = ""
|
||||
player.HeadImage = 0
|
||||
player.HeadImage = 10000007
|
||||
player.Birthday = []uint8{0, 0}
|
||||
player.NameCard = 210001
|
||||
player.NameCardList = make([]uint32, 0)
|
||||
@@ -248,5 +240,6 @@ func (g *Game) LoginNotify(userId uint32, clientSeq uint32, player *model.Player
|
||||
g.SendMsg(cmd.OpenStateUpdateNotify, userId, clientSeq, g.PacketOpenStateUpdateNotify())
|
||||
g.SendMsg(cmd.QuestListNotify, userId, clientSeq, g.PacketQuestListNotify(player))
|
||||
g.SendMsg(cmd.FinishedParentQuestNotify, userId, clientSeq, g.PacketFinishedParentQuestNotify(player))
|
||||
g.SendMsg(cmd.AllMarkPointNotify, player.PlayerId, player.ClientSeq, &proto.AllMarkPointNotify{MarkList: g.PacketMapMarkPointList(player)})
|
||||
// g.GCGLogin(player) // 发送GCG登录相关的通知包
|
||||
}
|
||||
+37
-30
@@ -59,30 +59,32 @@ func (g *Game) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Message) {
|
||||
delEntityIdList = append(delEntityIdList, entityId)
|
||||
}
|
||||
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, delEntityIdList)
|
||||
// 卸载旧位置附近的group
|
||||
for _, groupConfig := range g.GetNeighborGroup(ctx.OldSceneId, ctx.OldPos) {
|
||||
if !world.GetMultiplayer() {
|
||||
// 单人世界直接卸载group
|
||||
g.RemoveSceneGroup(player, oldScene, groupConfig)
|
||||
} else {
|
||||
// 多人世界group附近没有任何玩家则卸载
|
||||
remove := true
|
||||
for _, otherPlayer := range oldScene.GetAllPlayer() {
|
||||
dx := int32(otherPlayer.Pos.X) - int32(groupConfig.Pos.X)
|
||||
if dx < 0 {
|
||||
dx *= -1
|
||||
}
|
||||
dy := int32(otherPlayer.Pos.Z) - int32(groupConfig.Pos.Z)
|
||||
if dy < 0 {
|
||||
dy *= -1
|
||||
}
|
||||
if dx <= GROUP_LOAD_DISTANCE || dy <= GROUP_LOAD_DISTANCE {
|
||||
remove = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if remove {
|
||||
if !WORLD_MANAGER.IsBigWorld(world) {
|
||||
// 卸载旧位置附近的group
|
||||
for _, groupConfig := range g.GetNeighborGroup(ctx.OldSceneId, ctx.OldPos) {
|
||||
if !world.GetMultiplayer() {
|
||||
// 单人世界直接卸载group
|
||||
g.RemoveSceneGroup(player, oldScene, groupConfig)
|
||||
} else {
|
||||
// 多人世界group附近没有任何玩家则卸载
|
||||
remove := true
|
||||
for _, otherPlayer := range oldScene.GetAllPlayer() {
|
||||
dx := int32(otherPlayer.Pos.X) - int32(groupConfig.Pos.X)
|
||||
if dx < 0 {
|
||||
dx *= -1
|
||||
}
|
||||
dy := int32(otherPlayer.Pos.Z) - int32(groupConfig.Pos.Z)
|
||||
if dy < 0 {
|
||||
dy *= -1
|
||||
}
|
||||
if dx <= GROUP_LOAD_DISTANCE || dy <= GROUP_LOAD_DISTANCE {
|
||||
remove = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if remove {
|
||||
g.RemoveSceneGroup(player, oldScene, groupConfig)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -313,13 +315,15 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
|
||||
|
||||
g.AddSceneEntityNotify(player, visionType, []uint32{activeWorldAvatar.GetAvatarEntityId()}, true, false)
|
||||
|
||||
// 加载附近的group
|
||||
for _, groupConfig := range g.GetNeighborGroup(scene.GetId(), player.Pos) {
|
||||
g.AddSceneGroup(player, scene, groupConfig)
|
||||
}
|
||||
for _, triggerDataConfig := range gdconf.GetTriggerDataMap() {
|
||||
groupConfig := gdconf.GetSceneGroup(triggerDataConfig.GroupId)
|
||||
g.AddSceneGroup(player, scene, groupConfig)
|
||||
if !WORLD_MANAGER.IsBigWorld(world) {
|
||||
// 加载附近的group
|
||||
for _, groupConfig := range g.GetNeighborGroup(scene.GetId(), player.Pos) {
|
||||
g.AddSceneGroup(player, scene, groupConfig)
|
||||
}
|
||||
for _, triggerDataConfig := range gdconf.GetTriggerDataMap() {
|
||||
groupConfig := gdconf.GetSceneGroup(triggerDataConfig.GroupId)
|
||||
g.AddSceneGroup(player, scene, groupConfig)
|
||||
}
|
||||
}
|
||||
// 同步客户端视野内的场景实体
|
||||
visionEntityMap := g.GetVisionEntity(scene, player.Pos)
|
||||
@@ -629,6 +633,9 @@ 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)
|
||||
}
|
||||
}
|
||||
|
||||
// RevivePlayerAvatar 复活玩家活跃角色实体
|
||||
|
||||
@@ -41,6 +41,13 @@ func (g *Game) GetPlayerSocialDetailReq(player *model.Player, payloadMsg pb.Mess
|
||||
FinishAchievementNum: 0,
|
||||
IsFriend: exist,
|
||||
}
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
socialDetail.FinishAchievementNum = player.PubgRank
|
||||
}
|
||||
getPlayerSocialDetailRsp := &proto.GetPlayerSocialDetailRsp{
|
||||
DetailData: socialDetail,
|
||||
}
|
||||
|
||||
@@ -250,6 +250,11 @@ func (g *Game) AvatarDieAnimationEndReq(player *model.Player, payloadMsg pb.Mess
|
||||
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,
|
||||
|
||||
+98
-20
@@ -2,6 +2,7 @@ package game
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"hk4e/common/constant"
|
||||
"hk4e/gdconf"
|
||||
@@ -138,28 +139,87 @@ func (g *Game) GetScenePointReq(player *model.Player, payloadMsg pb.Message) {
|
||||
|
||||
func (g *Game) MarkMapReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.MarkMapReq)
|
||||
if req.Op == proto.MarkMapReq_ADD {
|
||||
logger.Debug("player mark type: %v", req.Mark.PointType)
|
||||
// 地图标点传送
|
||||
if req.Mark.PointType == proto.MapMarkPointType_NPC {
|
||||
posYInt, err := strconv.ParseInt(req.Mark.Name, 10, 64)
|
||||
if err != nil {
|
||||
logger.Error("parse pos y error: %v", err)
|
||||
posYInt = 300
|
||||
}
|
||||
// 传送玩家
|
||||
g.TeleportPlayer(
|
||||
player,
|
||||
proto.EnterReason_ENTER_REASON_GM,
|
||||
req.Mark.SceneId,
|
||||
&model.Vector{X: float64(req.Mark.Pos.X), Y: float64(posYInt), Z: float64(req.Mark.Pos.Z)},
|
||||
new(model.Vector),
|
||||
0,
|
||||
0,
|
||||
)
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
if WORLD_MANAGER.IsBigWorld(world) {
|
||||
pubg := world.GetPubg()
|
||||
if pubg != nil {
|
||||
GAME.SendMsg(cmd.MarkMapRsp, player.PlayerId, player.ClientSeq, &proto.MarkMapRsp{MarkList: pubg.GetAreaPointList()})
|
||||
return
|
||||
}
|
||||
}
|
||||
g.SendMsg(cmd.MarkMapRsp, player.PlayerId, player.ClientSeq, &proto.MarkMapRsp{})
|
||||
// 地图标点传送
|
||||
if req.Op == proto.MarkMapReq_ADD && req.Mark.PointType == proto.MapMarkPointType_NPC && strings.Contains(req.Mark.Name, "@@") {
|
||||
posYStr := strings.ReplaceAll(req.Mark.Name, "@@", "")
|
||||
posY, err := strconv.Atoi(posYStr)
|
||||
if err != nil {
|
||||
logger.Error("parse pos y error: %v", err)
|
||||
posY = 300
|
||||
}
|
||||
g.TeleportPlayer(
|
||||
player,
|
||||
proto.EnterReason_ENTER_REASON_GM,
|
||||
req.Mark.SceneId,
|
||||
&model.Vector{X: float64(req.Mark.Pos.X), Y: float64(posY), Z: float64(req.Mark.Pos.Z)},
|
||||
new(model.Vector),
|
||||
0,
|
||||
0,
|
||||
)
|
||||
g.SendMsg(cmd.MarkMapRsp, player.PlayerId, player.ClientSeq, &proto.MarkMapRsp{MarkList: g.PacketMapMarkPointList(player)})
|
||||
return
|
||||
}
|
||||
dbWorld := player.GetDbWorld()
|
||||
switch req.Op {
|
||||
case proto.MarkMapReq_ADD:
|
||||
mark := &model.MapMark{
|
||||
SceneId: req.Mark.SceneId,
|
||||
Pos: &model.Vector{
|
||||
X: float64(req.Mark.Pos.X),
|
||||
Y: float64(req.Mark.Pos.Y),
|
||||
Z: float64(req.Mark.Pos.Z),
|
||||
},
|
||||
PointType: uint32(req.Mark.PointType),
|
||||
Name: req.Mark.Name,
|
||||
}
|
||||
dbWorld.MapMarkList = append(dbWorld.MapMarkList, mark)
|
||||
case proto.MarkMapReq_DEL:
|
||||
newMapMarkList := make([]*model.MapMark, 0, len(dbWorld.MapMarkList))
|
||||
for _, mapMark := range dbWorld.MapMarkList {
|
||||
if mapMark.SceneId == req.Mark.SceneId &&
|
||||
int32(mapMark.Pos.X) == int32(req.Mark.Pos.X) &&
|
||||
int32(mapMark.Pos.Y) == int32(req.Mark.Pos.Y) &&
|
||||
int32(mapMark.Pos.Z) == int32(req.Mark.Pos.Z) {
|
||||
continue
|
||||
}
|
||||
newMapMarkList = append(newMapMarkList, mapMark)
|
||||
}
|
||||
dbWorld.MapMarkList = newMapMarkList
|
||||
case proto.MarkMapReq_MOD:
|
||||
newMapMarkList := make([]*model.MapMark, 0, len(dbWorld.MapMarkList))
|
||||
for _, mapMark := range dbWorld.MapMarkList {
|
||||
if mapMark.SceneId == req.Old.SceneId &&
|
||||
int32(mapMark.Pos.X) == int32(req.Old.Pos.X) &&
|
||||
int32(mapMark.Pos.Y) == int32(req.Old.Pos.Y) &&
|
||||
int32(mapMark.Pos.Z) == int32(req.Old.Pos.Z) {
|
||||
mapMark = &model.MapMark{
|
||||
SceneId: req.Mark.SceneId,
|
||||
Pos: &model.Vector{
|
||||
X: float64(req.Mark.Pos.X),
|
||||
Y: float64(req.Mark.Pos.Y),
|
||||
Z: float64(req.Mark.Pos.Z),
|
||||
},
|
||||
PointType: uint32(req.Mark.PointType),
|
||||
Name: req.Mark.Name,
|
||||
}
|
||||
}
|
||||
newMapMarkList = append(newMapMarkList, mapMark)
|
||||
}
|
||||
dbWorld.MapMarkList = newMapMarkList
|
||||
case proto.MarkMapReq_GET:
|
||||
}
|
||||
g.SendMsg(cmd.MarkMapRsp, player.PlayerId, player.ClientSeq, &proto.MarkMapRsp{MarkList: g.PacketMapMarkPointList(player)})
|
||||
}
|
||||
|
||||
func (g *Game) GetSceneAreaReq(player *model.Player, payloadMsg pb.Message) {
|
||||
@@ -586,3 +646,21 @@ func (g *Game) TeleportPlayer(
|
||||
}
|
||||
|
||||
/************************************************** 打包封装 **************************************************/
|
||||
|
||||
func (g *Game) PacketMapMarkPointList(player *model.Player) []*proto.MapMarkPoint {
|
||||
pbMarkList := make([]*proto.MapMarkPoint, 0)
|
||||
dbWorld := player.GetDbWorld()
|
||||
for _, mapMark := range dbWorld.MapMarkList {
|
||||
pbMarkList = append(pbMarkList, &proto.MapMarkPoint{
|
||||
SceneId: mapMark.SceneId,
|
||||
Name: mapMark.Name,
|
||||
Pos: &proto.Vector{
|
||||
X: float32(mapMark.Pos.X),
|
||||
Y: float32(mapMark.Pos.Y),
|
||||
Z: float32(mapMark.Pos.Z),
|
||||
},
|
||||
PointType: proto.MapMarkPointType(mapMark.PointType),
|
||||
})
|
||||
}
|
||||
return pbMarkList
|
||||
}
|
||||
@@ -48,7 +48,7 @@ type Avatar struct {
|
||||
FightPropMap map[uint32]float32 `bson:"-" msgpack:"-"`
|
||||
}
|
||||
|
||||
func (a *DbAvatar) InitAllAvatar(player *Player) {
|
||||
func (a *DbAvatar) InitDbAvatar(player *Player) {
|
||||
for _, avatar := range a.AvatarMap {
|
||||
a.InitAvatar(player, avatar)
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ type Item struct {
|
||||
Guid uint64 `bson:"-" msgpack:"-"`
|
||||
}
|
||||
|
||||
func (i *DbItem) InitAllItem(player *Player) {
|
||||
func (i *DbItem) InitDbItem(player *Player) {
|
||||
for itemId, item := range i.ItemMap {
|
||||
item.Guid = player.GetNextGameObjectGuid()
|
||||
player.GameObjectGuidMap[item.Guid] = GameObject(item)
|
||||
|
||||
@@ -35,7 +35,7 @@ func (r *DbReliquary) GetReliquaryMapLen() int {
|
||||
return len(r.ReliquaryMap)
|
||||
}
|
||||
|
||||
func (r *DbReliquary) InitAllReliquary(player *Player) {
|
||||
func (r *DbReliquary) InitDbReliquary(player *Player) {
|
||||
for _, reliquary := range r.ReliquaryMap {
|
||||
r.InitReliquary(player, reliquary)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func (w *DbWeapon) GetWeaponMapLen() int {
|
||||
return len(w.WeaponMap)
|
||||
}
|
||||
|
||||
func (w *DbWeapon) InitAllWeapon(player *Player) {
|
||||
func (w *DbWeapon) InitDbWeapon(player *Player) {
|
||||
for _, weapon := range w.WeaponMap {
|
||||
w.InitWeapon(player, weapon)
|
||||
}
|
||||
|
||||
+11
-2
@@ -11,6 +11,13 @@ type DbSceneGroup struct {
|
||||
GadgetStateMap map[uint32]uint8
|
||||
}
|
||||
|
||||
type MapMark struct {
|
||||
SceneId uint32
|
||||
Pos *Vector
|
||||
PointType uint32
|
||||
Name string
|
||||
}
|
||||
|
||||
type DbScene struct {
|
||||
SceneId uint32
|
||||
UnlockPointMap map[uint32]bool
|
||||
@@ -19,7 +26,8 @@ type DbScene struct {
|
||||
}
|
||||
|
||||
type DbWorld struct {
|
||||
SceneMap map[uint32]*DbScene
|
||||
SceneMap map[uint32]*DbScene
|
||||
MapMarkList []*MapMark
|
||||
}
|
||||
|
||||
func (p *Player) GetDbWorld() *DbWorld {
|
||||
@@ -31,7 +39,8 @@ func (p *Player) GetDbWorld() *DbWorld {
|
||||
|
||||
func NewDbWorld() *DbWorld {
|
||||
r := &DbWorld{
|
||||
SceneMap: make(map[uint32]*DbScene),
|
||||
SceneMap: make(map[uint32]*DbScene),
|
||||
MapMarkList: make([]*MapMark, 0),
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ type Player struct {
|
||||
SafePos *Vector // 在陆地时的坐标
|
||||
Pos *Vector // 坐标
|
||||
Rot *Vector // 朝向
|
||||
PubgRank uint32 // 大逃杀模式积分
|
||||
DbItem *DbItem // 道具
|
||||
DbWeapon *DbWeapon // 武器
|
||||
DbReliquary *DbReliquary // 圣遗物
|
||||
@@ -100,6 +101,15 @@ func (p *Player) InitOnlineData() {
|
||||
p.CombatInvokeHandler = NewInvokeHandler[proto.CombatInvokeEntry]()
|
||||
p.AbilityInvokeHandler = NewInvokeHandler[proto.AbilityInvokeEntry]()
|
||||
p.GCGInfo = NewGCGInfo() // 临时测试用数据
|
||||
|
||||
dbAvatar := p.GetDbAvatar()
|
||||
dbAvatar.InitDbAvatar(p)
|
||||
dbReliquary := p.GetDbReliquary()
|
||||
dbReliquary.InitDbReliquary(p)
|
||||
dbWeapon := p.GetDbWeapon()
|
||||
dbWeapon.InitDbWeapon(p)
|
||||
dbItem := p.GetDbItem()
|
||||
dbItem.InitDbItem(p)
|
||||
}
|
||||
|
||||
// 多人世界网络同步包转发器
|
||||
|
||||
@@ -40,9 +40,9 @@ func NewCmdProtoMap() (r *CmdProtoMap) {
|
||||
|
||||
func (c *CmdProtoMap) registerMessage() {
|
||||
// 登录
|
||||
c.regMsg(DoSetPlayerBornDataNotify, func() any { return new(proto.DoSetPlayerBornDataNotify) }) // 注册账号通知 新号播放开场动画
|
||||
c.regMsg(SetPlayerBornDataReq, func() any { return new(proto.SetPlayerBornDataReq) }) // 注册账号请求
|
||||
c.regMsg(SetPlayerBornDataRsp, func() any { return new(proto.SetPlayerBornDataRsp) }) // 注册账号响应
|
||||
c.regMsg(DoSetPlayerBornDataNotify, func() any { return new(proto.DoSetPlayerBornDataNotify) }) // 出生数据设置通知 新号播放开场动画
|
||||
c.regMsg(SetPlayerBornDataReq, func() any { return new(proto.SetPlayerBornDataReq) }) // 出生数据设置请求
|
||||
c.regMsg(SetPlayerBornDataRsp, func() any { return new(proto.SetPlayerBornDataRsp) }) // 出生数据设置响应
|
||||
c.regMsg(GetPlayerTokenReq, func() any { return new(proto.GetPlayerTokenReq) }) // 获取玩家token请求 第一个登录包
|
||||
c.regMsg(GetPlayerTokenRsp, func() any { return new(proto.GetPlayerTokenRsp) }) // 获取玩家token响应
|
||||
c.regMsg(PlayerLoginReq, func() any { return new(proto.PlayerLoginReq) }) // 玩家登录请求 第二个登录包
|
||||
@@ -68,6 +68,9 @@ func (c *CmdProtoMap) registerMessage() {
|
||||
c.regMsg(ServerAnnounceRevokeNotify, func() any { return new(proto.ServerAnnounceRevokeNotify) }) // 服务器公告撤销通知
|
||||
c.regMsg(TowerAllDataReq, func() any { return new(proto.TowerAllDataReq) }) // 深渊数据请求
|
||||
c.regMsg(TowerAllDataRsp, func() any { return new(proto.TowerAllDataRsp) }) // 深渊数据响应
|
||||
c.regMsg(GmTalkReq, func() any { return new(proto.GmTalkReq) }) // GM命令执行请求
|
||||
c.regMsg(GmTalkRsp, func() any { return new(proto.GmTalkRsp) }) // GM命令执行响应
|
||||
c.regMsg(GmTalkNotify, func() any { return new(proto.GmTalkNotify) }) // GM命令执行通知
|
||||
|
||||
// 场景
|
||||
c.regMsg(PlayerSetPauseReq, func() any { return new(proto.PlayerSetPauseReq) }) // 玩家暂停请求
|
||||
@@ -89,6 +92,7 @@ func (c *CmdProtoMap) registerMessage() {
|
||||
c.regMsg(ScenePointUnlockNotify, func() any { return new(proto.ScenePointUnlockNotify) }) // 场景传送点解锁通知
|
||||
c.regMsg(MarkMapReq, func() any { return new(proto.MarkMapReq) }) // 标记地图请求
|
||||
c.regMsg(MarkMapRsp, func() any { return new(proto.MarkMapRsp) }) // 标记地图响应
|
||||
c.regMsg(AllMarkPointNotify, func() any { return new(proto.AllMarkPointNotify) }) // 全部地图标记通知
|
||||
c.regMsg(QueryPathReq, func() any { return new(proto.QueryPathReq) }) // 寻路请求
|
||||
c.regMsg(QueryPathRsp, func() any { return new(proto.QueryPathRsp) }) // 寻路响应
|
||||
c.regMsg(GetScenePointReq, func() any { return new(proto.GetScenePointReq) }) // 获取场景传送点请求
|
||||
@@ -392,9 +396,6 @@ func (c *CmdProtoMap) registerMessage() {
|
||||
c.regMsg(NavMeshStatsNotify, func() any { return new(proto.NavMeshStatsNotify) })
|
||||
c.regMsg(GMShowObstacleReq, func() any { return new(proto.GMShowObstacleReq) })
|
||||
c.regMsg(GMShowObstacleRsp, func() any { return new(proto.GMShowObstacleRsp) })
|
||||
c.regMsg(GmTalkReq, func() any { return new(proto.GmTalkReq) })
|
||||
c.regMsg(GmTalkRsp, func() any { return new(proto.GmTalkRsp) })
|
||||
c.regMsg(GmTalkNotify, func() any { return new(proto.GmTalkNotify) })
|
||||
c.regMsg(ServerLogNotify, func() any { return new(proto.ServerLogNotify) })
|
||||
c.regMsg(MarkEntityInMinMapNotify, func() any { return new(proto.MarkEntityInMinMapNotify) })
|
||||
c.regMsg(UnmarkEntityInMinMapNotify, func() any { return new(proto.UnmarkEntityInMinMapNotify) })
|
||||
|
||||
Reference in new issue
Block a user