大世界AOI广播域隔离

This commit is contained in:
flswld
2023-04-10 19:32:16 +08:00
parent 5a043a9482
commit b5faba4151
22 changed files with 677 additions and 666 deletions

View File

@@ -311,7 +311,7 @@ func UpdateFrame(rgb bool) {
for _, v := range SCREEN_ENTITY_ID_LIST {
scene.DestroyEntity(v)
}
GAME.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, SCREEN_ENTITY_ID_LIST, false, nil)
GAME.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, SCREEN_ENTITY_ID_LIST, false, 0)
SCREEN_ENTITY_ID_LIST = make([]uint32, 0)
leftTopPos := &model.Vector{
X: BASE_POS.X + float64(SCREEN_WIDTH)*SCREEN_DPI/2,

View File

@@ -375,9 +375,9 @@ func (g *Game) SendToWorldA(world *World, cmdId uint16, seq uint32, msg pb.Messa
}
// SendToWorldAEC 给世界内除某玩家(一般是自己)以外的所有玩家发消息
func (g *Game) SendToWorldAEC(world *World, cmdId uint16, seq uint32, msg pb.Message, uid uint32) {
func (g *Game) SendToWorldAEC(world *World, cmdId uint16, seq uint32, msg pb.Message, aecUid uint32) {
for _, v := range world.GetAllPlayer() {
if uid == v.PlayerID {
if aecUid == v.PlayerID {
continue
}
GAME.SendMsg(cmdId, v.PlayerID, seq, msg)
@@ -389,6 +389,44 @@ func (g *Game) SendToWorldH(world *World, cmdId uint16, seq uint32, msg pb.Messa
GAME.SendMsg(cmdId, world.GetOwner().PlayerID, seq, msg)
}
// SendToSceneA 给场景内所有玩家发消息
func (g *Game) SendToSceneA(scene *Scene, cmdId uint16, seq uint32, msg pb.Message) {
world := scene.GetWorld()
if WORLD_MANAGER.IsBigWorld(world) {
bigWorldAoi := world.GetBigWorldAoi()
otherWorldAvatarMap := bigWorldAoi.GetObjectListByPos(float32(SELF.Pos.X), float32(SELF.Pos.Y), float32(SELF.Pos.Z))
for uid := range otherWorldAvatarMap {
GAME.SendMsg(cmdId, uint32(uid), seq, msg)
}
} else {
for _, v := range scene.GetAllPlayer() {
GAME.SendMsg(cmdId, v.PlayerID, seq, msg)
}
}
}
// SendToSceneAEC 给场景内除某玩家(一般是自己)以外的所有玩家发消息
func (g *Game) SendToSceneAEC(scene *Scene, cmdId uint16, seq uint32, msg pb.Message, aecUid uint32) {
world := scene.GetWorld()
if WORLD_MANAGER.IsBigWorld(world) {
bigWorldAoi := world.GetBigWorldAoi()
otherWorldAvatarMap := bigWorldAoi.GetObjectListByPos(float32(SELF.Pos.X), float32(SELF.Pos.Y), float32(SELF.Pos.Z))
for uid := range otherWorldAvatarMap {
if aecUid == uint32(uid) {
continue
}
GAME.SendMsg(cmdId, uint32(uid), seq, msg)
}
} else {
for _, v := range scene.GetAllPlayer() {
if aecUid == v.PlayerID {
continue
}
GAME.SendMsg(cmdId, v.PlayerID, seq, msg)
}
}
}
func (g *Game) ReLoginPlayer(userId uint32, isQuitMp bool) {
reason := proto.ClientReconnectReason_CLIENT_RECONNNECT_NONE
if isQuitMp {

View File

@@ -327,6 +327,10 @@ func (w *World) GetWorldPlayerNum() int {
return len(w.playerMap)
}
func (w *World) GetBigWorldAoi() *alg.AoiManager {
return w.bigWorldAoi
}
func (w *World) AddPlayer(player *model.Player, sceneId uint32) {
w.peerList = append(w.peerList, player)
w.playerMap[player.PlayerID] = player
@@ -714,6 +718,9 @@ func (w *World) UpdateMultiplayerTeam() {
// 世界聊天
func (w *World) AddChat(chatInfo *proto.ChatInfo) {
if len(w.chatMsgList) > 100 {
w.chatMsgList = w.chatMsgList[1:]
}
w.chatMsgList = append(w.chatMsgList, chatInfo)
}

View File

@@ -276,9 +276,7 @@ func (g *Game) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.Message
AvatarGuid: req.AvatarGuid,
FlycloakId: req.FlycloakId,
}
for _, scenePlayer := range scene.GetAllPlayer() {
g.SendMsg(cmd.AvatarFlycloakChangeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarFlycloakChangeNotify)
}
g.SendToSceneA(scene, cmd.AvatarFlycloakChangeNotify, player.ClientSeq, avatarFlycloakChangeNotify)
avatarWearFlycloakRsp := &proto.AvatarWearFlycloakRsp{
AvatarGuid: req.AvatarGuid,
@@ -338,9 +336,7 @@ func (g *Game) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb.Messag
} else {
avatarChangeCostumeNotify.EntityInfo = g.PacketSceneEntityInfoAvatar(scene, player, avatar.AvatarId)
}
for _, scenePlayer := range scene.GetAllPlayer() {
g.SendMsg(cmd.AvatarChangeCostumeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarChangeCostumeNotify)
}
g.SendToSceneA(scene, cmd.AvatarChangeCostumeNotify, player.ClientSeq, avatarChangeCostumeNotify)
avatarChangeCostumeRsp := &proto.AvatarChangeCostumeRsp{
AvatarGuid: req.AvatarGuid,

View File

@@ -253,9 +253,7 @@ func (g *Game) PlayerChatReq(player *model.Player, payloadMsg pb.Message) {
ChannelId: channelId,
ChatInfo: sendChatInfo,
}
for _, worldPlayer := range world.GetAllPlayer() {
g.SendMsg(cmd.PlayerChatNotify, worldPlayer.PlayerID, player.ClientSeq, playerChatNotify)
}
g.SendToWorldA(world, cmd.PlayerChatNotify, player.ClientSeq, playerChatNotify)
g.SendMsg(cmd.PlayerChatRsp, player.PlayerID, player.ClientSeq, new(proto.PlayerChatRsp))
}

View File

@@ -219,7 +219,7 @@ func (g *Game) ScenePlayerLocationNotify(world *World) {
}
}
}
GAME.SendToWorldA(world, cmd.ScenePlayerLocationNotify, 0, scenePlayerLocationNotify)
GAME.SendToSceneA(scene, cmd.ScenePlayerLocationNotify, 0, scenePlayerLocationNotify)
}
}

View File

@@ -26,6 +26,7 @@ func DoForward[IET model.InvokeEntryType](player *model.Player, invokeHandler *m
if world == nil {
return
}
scene := world.GetSceneById(player.SceneId)
if srcNtf != nil && copyFieldList != nil {
for _, fieldName := range copyFieldList {
reflection.CopyStructField(newNtf, srcNtf, fieldName)
@@ -36,11 +37,11 @@ func DoForward[IET model.InvokeEntryType](player *model.Player, invokeHandler *m
}
if invokeHandler.AllLen() > 0 {
reflection.SetStructFieldValue(newNtf, forwardField, invokeHandler.EntryListForwardAll)
GAME.SendToWorldA(world, cmdId, player.ClientSeq, newNtf)
GAME.SendToSceneA(scene, cmdId, player.ClientSeq, newNtf)
}
if invokeHandler.AllExceptCurLen() > 0 {
reflection.SetStructFieldValue(newNtf, forwardField, invokeHandler.EntryListForwardAllExceptCur)
GAME.SendToWorldAEC(world, cmdId, player.ClientSeq, newNtf, player.PlayerID)
GAME.SendToSceneAEC(scene, cmdId, player.ClientSeq, newNtf, player.PlayerID)
}
if invokeHandler.HostLen() > 0 {
reflection.SetStructFieldValue(newNtf, forwardField, invokeHandler.EntryListForwardHost)
@@ -74,13 +75,9 @@ func (g *Game) MassiveEntityElementOpBatchNotify(player *model.Player, payloadMs
return
}
scene := world.GetSceneById(player.SceneId)
if scene == nil {
logger.Error("scene is nil, sceneId: %v", player.SceneId)
return
}
req.OpIdx = scene.GetMeeoIndex()
scene.SetMeeoIndex(scene.GetMeeoIndex() + 1)
g.SendToWorldA(world, cmd.MassiveEntityElementOpBatchNotify, player.ClientSeq, req)
g.SendToSceneA(scene, cmd.MassiveEntityElementOpBatchNotify, player.ClientSeq, req)
}
func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Message) {
@@ -120,7 +117,7 @@ func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Messa
currHp = 0
}
fightProp[constant.FIGHT_PROP_CUR_HP] = currHp
g.EntityFightPropUpdateNotifyBroadcast(world, target)
g.EntityFightPropUpdateNotifyBroadcast(scene, target)
switch target.GetEntityType() {
case constant.ENTITY_TYPE_AVATAR:
case constant.ENTITY_TYPE_MONSTER:
@@ -135,13 +132,7 @@ func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Messa
break
}
logger.Debug("[EvtBeingHit] GadgetData: %+v, EntityId: %v, uid: %v", gadgetDataConfig, target.GetId(), player.PlayerID)
// TODO 临时的解决方案
if strings.Contains(gadgetDataConfig.ServerLuaScript, "SetGadgetState") {
g.ChangeGadgetState(player, target.GetId(), constant.GADGET_STATE_GEAR_START)
}
if strings.Contains(gadgetDataConfig.ServerLuaScript, "Controller") {
g.ChangeGadgetState(player, target.GetId(), constant.GADGET_STATE_GEAR_START)
}
g.handleGadgetEntityBeHitLow(player, target, attackResult.ElementType)
}
case proto.CombatTypeArgument_ENTITY_MOVE:
entityMoveInfo := new(proto.EntityMoveInfo)
@@ -161,24 +152,21 @@ func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Messa
}
if sceneEntity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
// 玩家实体在移动
g.AoiPlayerMove(player, player.Pos, &model.Vector{
X: float64(motionInfo.Pos.X),
Y: float64(motionInfo.Pos.Y),
Z: float64(motionInfo.Pos.Z),
})
g.SceneBlockAoiPlayerMove(player, world, scene, player.Pos,
&model.Vector{X: float64(motionInfo.Pos.X), Y: float64(motionInfo.Pos.Y), Z: float64(motionInfo.Pos.Z)},
)
if WORLD_MANAGER.IsBigWorld(world) {
g.BigWorldAoiPlayerMove(player, world, scene, player.Pos,
&model.Vector{X: float64(motionInfo.Pos.X), Y: float64(motionInfo.Pos.Y), Z: float64(motionInfo.Pos.Z)},
)
}
// 场景区域触发器检测
g.SceneRegionTriggerCheck(player, player.Pos, &model.Vector{
X: float64(motionInfo.Pos.X),
Y: float64(motionInfo.Pos.Y),
Z: float64(motionInfo.Pos.Z),
}, sceneEntity.GetId())
g.SceneRegionTriggerCheck(player, player.Pos,
&model.Vector{X: float64(motionInfo.Pos.X), Y: float64(motionInfo.Pos.Y), Z: float64(motionInfo.Pos.Z)},
sceneEntity.GetId())
// 更新玩家的位置信息
player.Pos.X = float64(motionInfo.Pos.X)
player.Pos.Y = float64(motionInfo.Pos.Y)
player.Pos.Z = float64(motionInfo.Pos.Z)
player.Rot.X = float64(motionInfo.Rot.X)
player.Rot.Y = float64(motionInfo.Rot.Y)
player.Rot.Z = float64(motionInfo.Rot.Z)
player.Pos.X, player.Pos.Y, player.Pos.Z = float64(motionInfo.Pos.X), float64(motionInfo.Pos.Y), float64(motionInfo.Pos.Z)
player.Rot.X, player.Rot.Y, player.Rot.Z = float64(motionInfo.Rot.X), float64(motionInfo.Rot.Y), float64(motionInfo.Rot.Z)
// 玩家安全位置更新
switch motionInfo.State {
case proto.MotionState_MOTION_DANGER_RUN,
@@ -192,9 +180,7 @@ func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Messa
proto.MotionState_MOTION_WALK,
proto.MotionState_MOTION_DASH:
// 仅在陆地时更新玩家安全位置
player.SafePos.X = player.Pos.X
player.SafePos.Y = player.Pos.Y
player.SafePos.Z = player.Pos.Z
player.SafePos.X, player.SafePos.Y, player.SafePos.Z = player.Pos.X, player.Pos.Y, player.Pos.Z
}
// 处理耐力消耗
g.ImmediateStamina(player, motionInfo.State)
@@ -202,13 +188,9 @@ func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Messa
// 非玩家实体在移动
// 更新场景实体的位置信息
pos := sceneEntity.GetPos()
pos.X = float64(motionInfo.Pos.X)
pos.Y = float64(motionInfo.Pos.Y)
pos.Z = float64(motionInfo.Pos.Z)
pos.X, pos.Y, pos.Z = float64(motionInfo.Pos.X), float64(motionInfo.Pos.Y), float64(motionInfo.Pos.Z)
rot := sceneEntity.GetRot()
rot.X = float64(motionInfo.Rot.X)
rot.Y = float64(motionInfo.Rot.Y)
rot.Z = float64(motionInfo.Rot.Z)
rot.X, rot.Y, rot.Z = float64(motionInfo.Rot.X), float64(motionInfo.Rot.Y), float64(motionInfo.Rot.Z)
if sceneEntity.GetEntityType() == constant.ENTITY_TYPE_GADGET {
// 载具耐力消耗
gadgetEntity := sceneEntity.GetGadgetEntity()
@@ -249,13 +231,7 @@ func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Messa
}
}
func (g *Game) AoiPlayerMove(player *model.Player, oldPos *model.Vector, newPos *model.Vector) {
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil {
logger.Error("get player world is nil, uid: %v", player.PlayerID)
return
}
scene := world.GetSceneById(player.SceneId)
func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene *Scene, oldPos *model.Vector, newPos *model.Vector) {
sceneBlockAoiMap := WORLD_MANAGER.GetSceneBlockAoiMap()
aoiManager, exist := sceneBlockAoiMap[player.SceneId]
if !exist {
@@ -328,18 +304,54 @@ func (g *Game) AoiPlayerMove(player *model.Player, oldPos *model.Vector, newPos
if len(addEntityIdList) > 0 {
g.AddSceneEntityNotify(player, proto.VisionType_VISION_MEET, addEntityIdList, false, false)
}
if WORLD_MANAGER.IsBigWorld(world) {
oldGid := world.bigWorldAoi.GetGidByPos(float32(oldPos.X), float32(oldPos.Y), float32(oldPos.Z))
newGid := world.bigWorldAoi.GetGidByPos(float32(newPos.X), float32(newPos.Y), float32(newPos.Z))
if oldGid != newGid {
// 玩家跨越了格子
logger.Debug("player cross big world aoi grid, oldGid: %v, newGid: %v, uid: %v", oldGid, newGid, player.PlayerID)
// 老格子移除玩家 新格子添加玩家
activeAvatarId := world.GetPlayerActiveAvatarId(player)
activeWorldAvatar := world.GetPlayerWorldAvatar(player, activeAvatarId)
world.bigWorldAoi.RemoveObjectFromGrid(int64(player.PlayerID), oldGid)
world.bigWorldAoi.AddObjectToGrid(int64(player.PlayerID), activeWorldAvatar, newGid)
oldOtherWorldAvatarMap := world.bigWorldAoi.GetObjectListByPos(float32(oldPos.X), float32(oldPos.Y), float32(oldPos.Z))
}
func (g *Game) BigWorldAoiPlayerMove(player *model.Player, world *World, scene *Scene, oldPos *model.Vector, newPos *model.Vector) {
bigWorldAoi := world.GetBigWorldAoi()
oldGid := bigWorldAoi.GetGidByPos(float32(oldPos.X), float32(oldPos.Y), float32(oldPos.Z))
newGid := bigWorldAoi.GetGidByPos(float32(newPos.X), float32(newPos.Y), float32(newPos.Z))
if oldGid != newGid {
// 玩家跨越了格子
logger.Debug("player cross big world aoi grid, oldGid: %v, newGid: %v, uid: %v", oldGid, newGid, player.PlayerID)
// 找出本次移动所带来的消失和出现的格子
oldGridList := bigWorldAoi.GetSurrGridListByGid(oldGid)
newGridList := bigWorldAoi.GetSurrGridListByGid(newGid)
delGridIdList := make([]uint32, 0)
for _, oldGrid := range oldGridList {
exist := false
for _, newGrid := range newGridList {
if oldGrid.GetGid() == newGrid.GetGid() {
exist = true
break
}
}
if exist {
continue
}
delGridIdList = append(delGridIdList, oldGrid.GetGid())
}
addGridIdList := make([]uint32, 0)
for _, newGrid := range newGridList {
exist := false
for _, oldGrid := range oldGridList {
if newGrid.GetGid() == oldGrid.GetGid() {
exist = true
break
}
}
if exist {
continue
}
addGridIdList = append(addGridIdList, newGrid.GetGid())
}
activeAvatarId := world.GetPlayerActiveAvatarId(player)
activeWorldAvatar := world.GetPlayerWorldAvatar(player, activeAvatarId)
// 处理消失的格子
for _, delGridId := range delGridIdList {
// 老格子移除玩家
bigWorldAoi.RemoveObjectFromGrid(int64(player.PlayerID), delGridId)
// 通知自己 老格子里的其它玩家消失
oldOtherWorldAvatarMap := bigWorldAoi.GetObjectListByGid(delGridId)
delEntityIdList := make([]uint32, 0)
for _, otherWorldAvatarAny := range oldOtherWorldAvatarMap {
otherWorldAvatar := otherWorldAvatarAny.(*WorldAvatar)
@@ -348,19 +360,22 @@ func (g *Game) AoiPlayerMove(player *model.Player, oldPos *model.Vector, newPos
}
delEntityIdList = append(delEntityIdList, otherWorldAvatar.GetAvatarEntityId())
}
// 通知自己 老格子里的其它玩家消失
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, delEntityIdList)
// 通知老格子里的其它玩家 自己消失
for otherPlayerId := range oldOtherWorldAvatarMap {
if uint32(otherPlayerId) == player.PlayerID {
continue
}
otherPlayer := USER_MANAGER.GetOnlineUser(uint32(otherPlayerId))
// 通知老格子里的其它玩家 自己消失
g.RemoveSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MISS, []uint32{
activeWorldAvatar.GetAvatarEntityId(),
})
g.RemoveSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MISS, []uint32{activeWorldAvatar.GetAvatarEntityId()})
}
newOtherWorldAvatarMap := world.bigWorldAoi.GetObjectListByPos(float32(newPos.X), float32(newPos.Y), float32(newPos.Z))
}
// 处理出现的格子
for _, addGridId := range addGridIdList {
// 新格子添加玩家
bigWorldAoi.AddObjectToGrid(int64(player.PlayerID), activeWorldAvatar, addGridId)
// 通知自己 新格子里的其他玩家出现
newOtherWorldAvatarMap := bigWorldAoi.GetObjectListByGid(addGridId)
addEntityIdList := make([]uint32, 0)
for _, otherWorldAvatarAny := range newOtherWorldAvatarMap {
otherWorldAvatar := otherWorldAvatarAny.(*WorldAvatar)
@@ -369,15 +384,14 @@ func (g *Game) AoiPlayerMove(player *model.Player, oldPos *model.Vector, newPos
}
addEntityIdList = append(addEntityIdList, otherWorldAvatar.GetAvatarEntityId())
}
// 通知自己 新格子里的其他玩家出现
g.AddSceneEntityNotify(player, proto.VisionType_VISION_MEET, addEntityIdList, false, false)
// 通知新格子里的其他玩家 自己出现
for otherPlayerId := range newOtherWorldAvatarMap {
if uint32(otherPlayerId) == player.PlayerID {
continue
}
otherPlayer := USER_MANAGER.GetOnlineUser(uint32(otherPlayerId))
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, player, world.GetPlayerActiveAvatarId(player))
// 通知新格子里的其他玩家 自己出现
g.AddSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MEET, []*proto.SceneEntityInfo{sceneEntityInfoAvatar})
}
}
@@ -402,6 +416,7 @@ func (g *Game) AbilityInvocationsNotify(player *model.Player, payloadMsg pb.Mess
// logger.Debug("EntityId: %v, ModifierChange: %v", entry.EntityId, modifierChange)
// 处理耐力消耗
g.HandleAbilityStamina(player, entry)
g.handleGadgetEntityAbilityLow(player, entry.EntityId, entry.ArgumentType, modifierChange)
case proto.AbilityInvokeArgument_ABILITY_MIXIN_COST_STAMINA:
costStamina := new(proto.AbilityMixinCostStamina)
err := pb.Unmarshal(entry.AbilityData, costStamina)
@@ -526,7 +541,11 @@ func (g *Game) EvtAvatarEnterFocusNotify(player *model.Player, payloadMsg pb.Mes
}
// logger.Debug("EvtAvatarEnterFocusNotify: %v", req)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
g.SendToWorldA(world, cmd.EvtAvatarEnterFocusNotify, player.ClientSeq, req)
if world == nil {
return
}
scene := world.GetSceneById(player.SceneId)
g.SendToSceneA(scene, cmd.EvtAvatarEnterFocusNotify, player.ClientSeq, req)
}
func (g *Game) EvtAvatarUpdateFocusNotify(player *model.Player, payloadMsg pb.Message) {
@@ -536,7 +555,11 @@ func (g *Game) EvtAvatarUpdateFocusNotify(player *model.Player, payloadMsg pb.Me
}
// logger.Debug("EvtAvatarUpdateFocusNotify: %v", req)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
g.SendToWorldA(world, cmd.EvtAvatarUpdateFocusNotify, player.ClientSeq, req)
if world == nil {
return
}
scene := world.GetSceneById(player.SceneId)
g.SendToSceneA(scene, cmd.EvtAvatarUpdateFocusNotify, player.ClientSeq, req)
}
func (g *Game) EvtAvatarExitFocusNotify(player *model.Player, payloadMsg pb.Message) {
@@ -546,7 +569,11 @@ func (g *Game) EvtAvatarExitFocusNotify(player *model.Player, payloadMsg pb.Mess
}
// logger.Debug("EvtAvatarExitFocusNotify: %v", req)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
g.SendToWorldA(world, cmd.EvtAvatarExitFocusNotify, player.ClientSeq, req)
if world == nil {
return
}
scene := world.GetSceneById(player.SceneId)
g.SendToSceneA(scene, cmd.EvtAvatarExitFocusNotify, player.ClientSeq, req)
}
func (g *Game) EvtEntityRenderersChangedNotify(player *model.Player, payloadMsg pb.Message) {
@@ -556,7 +583,11 @@ func (g *Game) EvtEntityRenderersChangedNotify(player *model.Player, payloadMsg
}
// logger.Debug("EvtEntityRenderersChangedNotify: %v", req)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
g.SendToWorldA(world, cmd.EvtEntityRenderersChangedNotify, player.ClientSeq, req)
if world == nil {
return
}
scene := world.GetSceneById(player.SceneId)
g.SendToSceneA(scene, cmd.EvtEntityRenderersChangedNotify, player.ClientSeq, req)
}
func (g *Game) EvtCreateGadgetNotify(player *model.Player, payloadMsg pb.Message) {
@@ -599,7 +630,7 @@ func (g *Game) EvtDestroyGadgetNotify(player *model.Player, payloadMsg pb.Messag
}
scene := world.GetSceneById(player.SceneId)
scene.DestroyEntity(req.EntityId)
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{req.EntityId}, false, nil)
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{req.EntityId}, false, 0)
}
func (g *Game) EvtAiSyncSkillCdNotify(player *model.Player, payloadMsg pb.Message) {
@@ -609,7 +640,11 @@ func (g *Game) EvtAiSyncSkillCdNotify(player *model.Player, payloadMsg pb.Messag
}
// logger.Debug("EvtAiSyncSkillCdNotify: %v", req)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
g.SendToWorldA(world, cmd.EvtAiSyncSkillCdNotify, player.ClientSeq, req)
if world == nil {
return
}
scene := world.GetSceneById(player.SceneId)
g.SendToSceneA(scene, cmd.EvtAiSyncSkillCdNotify, player.ClientSeq, req)
}
func (g *Game) EvtAiSyncCombatThreatInfoNotify(player *model.Player, payloadMsg pb.Message) {
@@ -619,7 +654,11 @@ func (g *Game) EvtAiSyncCombatThreatInfoNotify(player *model.Player, payloadMsg
}
// logger.Debug("EvtAiSyncCombatThreatInfoNotify: %v", req)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
g.SendToWorldA(world, cmd.EvtAiSyncCombatThreatInfoNotify, player.ClientSeq, req)
if world == nil {
return
}
scene := world.GetSceneById(player.SceneId)
g.SendToSceneA(scene, cmd.EvtAiSyncCombatThreatInfoNotify, player.ClientSeq, req)
}
func (g *Game) EntityConfigHashNotify(player *model.Player, payloadMsg pb.Message) {
@@ -651,3 +690,84 @@ func (g *Game) EntityAiSyncNotify(player *model.Player, payloadMsg pb.Message) {
}
g.SendMsg(cmd.EntityAiSyncNotify, player.PlayerID, player.ClientSeq, entityAiSyncNotify)
}
// TODO 一些很low的解决方案 我本来是不想写的 有多low要多low有多low
func (g *Game) handleGadgetEntityBeHitLow(player *model.Player, entity *Entity, hitElementType uint32) {
if entity.GetEntityType() != constant.ENTITY_TYPE_GADGET {
return
}
gadgetEntity := entity.GetGadgetEntity()
gadgetId := gadgetEntity.GetGadgetId()
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetId))
if gadgetDataConfig == nil {
logger.Error("get gadget data config is nil, gadgetId: %v", gadgetEntity.GetGadgetId())
return
}
if strings.Contains(gadgetDataConfig.Name, "火把") ||
strings.Contains(gadgetDataConfig.Name, "火盆") ||
strings.Contains(gadgetDataConfig.Name, "篝火") {
// 火把点燃
if hitElementType != constant.ELEMENT_TYPE_FIRE {
return
}
g.ChangeGadgetState(player, entity.GetId(), constant.GADGET_STATE_GEAR_START)
} else if strings.Contains(gadgetDataConfig.ServerLuaScript, "Controller") {
// 元素方碑点亮
gadgetElementType := uint32(0)
if strings.Contains(gadgetDataConfig.ServerLuaScript, "Fire") {
gadgetElementType = constant.ELEMENT_TYPE_FIRE
} else if strings.Contains(gadgetDataConfig.ServerLuaScript, "Water") {
gadgetElementType = constant.ELEMENT_TYPE_WATER
} else if strings.Contains(gadgetDataConfig.ServerLuaScript, "Grass") {
gadgetElementType = constant.ELEMENT_TYPE_GRASS
} else if strings.Contains(gadgetDataConfig.ServerLuaScript, "Elec") {
gadgetElementType = constant.ELEMENT_TYPE_ELEC
} else if strings.Contains(gadgetDataConfig.ServerLuaScript, "Ice") {
gadgetElementType = constant.ELEMENT_TYPE_ICE
} else if strings.Contains(gadgetDataConfig.ServerLuaScript, "Wind") {
gadgetElementType = constant.ELEMENT_TYPE_WIND
} else if strings.Contains(gadgetDataConfig.ServerLuaScript, "Rock") {
gadgetElementType = constant.ELEMENT_TYPE_ROCK
}
if hitElementType != gadgetElementType {
return
}
g.ChangeGadgetState(player, entity.GetId(), constant.GADGET_STATE_GEAR_START)
}
}
func (g *Game) handleGadgetEntityAbilityLow(player *model.Player, entityId uint32, argument proto.AbilityInvokeArgument, entry pb.Message) {
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil {
return
}
scene := world.GetSceneById(player.SceneId)
entity := scene.GetEntity(entityId)
switch argument {
case proto.AbilityInvokeArgument_ABILITY_META_MODIFIER_CHANGE:
// 物件破碎
modifierChange := entry.(*proto.AbilityMetaModifierChange)
if modifierChange.Action != proto.ModifierAction_REMOVED {
return
}
logger.Debug("物件破碎, entityId: %v, modifierChange: %v, uid: %v", entityId, modifierChange, player.PlayerID)
if entity.GetEntityType() != constant.ENTITY_TYPE_GADGET {
return
}
gadgetEntity := entity.GetGadgetEntity()
gadgetId := gadgetEntity.GetGadgetId()
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetId))
if gadgetDataConfig == nil {
logger.Error("get gadget data config is nil, gadgetId: %v", gadgetEntity.GetGadgetId())
return
}
if strings.Contains(gadgetDataConfig.Name, "碎石堆") ||
strings.Contains(gadgetDataConfig.ServerLuaScript, "SubfieldDrop_WoodenObject_Broken") {
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_GM)
} else if strings.Contains(gadgetDataConfig.ServerLuaScript, "SubfieldDrop_Ore") {
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_GM)
g.CreateDropGadget(player, entity.GetPos(), 70900001, 233, 1)
}
}
}

View File

@@ -81,12 +81,8 @@ func (g *Game) JoinOtherWorld(player *model.Player, hostPlayer *model.Player) {
player.SceneJump = true
player.SceneId = hostPlayer.SceneId
player.SceneLoadState = model.SceneNone
player.Pos.X = hostPlayer.Pos.X
player.Pos.Y = hostPlayer.Pos.Y
player.Pos.Z = hostPlayer.Pos.Z
player.Rot.X = hostPlayer.Rot.X
player.Rot.Y = hostPlayer.Rot.Y
player.Rot.Z = hostPlayer.Rot.Z
player.Pos.X, player.Pos.Y, player.Pos.Z = hostPlayer.Pos.X, hostPlayer.Pos.Y, hostPlayer.Pos.Z
player.Rot.X, player.Rot.Y, player.Rot.Z = hostPlayer.Rot.X, hostPlayer.Rot.Y, hostPlayer.Rot.Z
g.UserWorldAddPlayer(hostWorld, player)
playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyMp(
@@ -415,7 +411,7 @@ func (g *Game) UserWorldRemovePlayer(world *World, player *model.Player) {
g.SendMsg(cmd.PlayerQuitFromMpNotify, player.PlayerID, player.ClientSeq, playerQuitFromMpNotify)
activeAvatarId := world.GetPlayerActiveAvatarId(player)
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, []uint32{world.GetPlayerWorldAvatarEntityId(player, activeAvatarId)}, false, nil)
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, []uint32{world.GetPlayerWorldAvatarEntityId(player, activeAvatarId)}, false, 0)
}
world.RemovePlayer(player)

View File

@@ -217,10 +217,17 @@ func (g *Game) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) {
g.UpdateWorldScenePlayerInfo(player, world)
g.GCGTavernInit(player) // GCG酒馆信息通知
g.SendMsg(cmd.DungeonWayPointNotify, player.PlayerID, player.ClientSeq, &proto.DungeonWayPointNotify{})
g.SendMsg(cmd.DungeonDataNotify, player.PlayerID, player.ClientSeq, &proto.DungeonDataNotify{})
ctx := world.GetEnterSceneContextByToken(req.EnterSceneToken)
if ctx == nil {
logger.Error("get enter scene context is nil, uid: %v", player.PlayerID)
return
}
// 进入的场景是地牢副本发送相关的包
if ctx.OldDungeonPointId != 0 {
g.GCGTavernInit(player) // GCG酒馆信息通知
g.SendMsg(cmd.DungeonWayPointNotify, player.PlayerID, player.ClientSeq, &proto.DungeonWayPointNotify{})
g.SendMsg(cmd.DungeonDataNotify, player.PlayerID, player.ClientSeq, &proto.DungeonDataNotify{})
}
SceneInitFinishRsp := &proto.SceneInitFinishRsp{
EnterSceneToken: req.EnterSceneToken,
@@ -245,9 +252,7 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
activeAvatarId := world.GetPlayerActiveAvatarId(player)
activeWorldAvatar := world.GetPlayerWorldAvatar(player, activeAvatarId)
g.AddSceneEntityNotify(player, visionType, []uint32{
activeWorldAvatar.GetAvatarEntityId(),
}, true, false)
g.AddSceneEntityNotify(player, visionType, []uint32{activeWorldAvatar.GetAvatarEntityId()}, true, false)
// 加载附近的group
for _, groupConfig := range g.GetNeighborGroup(scene.GetId(), player.Pos) {
@@ -269,7 +274,8 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
}
g.AddSceneEntityNotify(player, visionType, entityIdList, false, false)
if WORLD_MANAGER.IsBigWorld(world) {
otherWorldAvatarMap := world.bigWorldAoi.GetObjectListByPos(float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
bigWorldAoi := world.GetBigWorldAoi()
otherWorldAvatarMap := bigWorldAoi.GetObjectListByPos(float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
entityIdList := make([]uint32, 0)
for _, otherWorldAvatarAny := range otherWorldAvatarMap {
otherWorldAvatar := otherWorldAvatarAny.(*WorldAvatar)
@@ -341,55 +347,53 @@ func (g *Game) SceneEntityDrownReq(player *model.Player, payloadMsg pb.Message)
// AddSceneEntityNotifyToPlayer 添加的场景实体同步给玩家
func (g *Game) AddSceneEntityNotifyToPlayer(player *model.Player, visionType proto.VisionType, entityList []*proto.SceneEntityInfo) {
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
ntf := &proto.SceneEntityAppearNotify{
AppearType: visionType,
EntityList: entityList,
}
g.SendMsg(cmd.SceneEntityAppearNotify, player.PlayerID, player.ClientSeq, sceneEntityAppearNotify)
logger.Debug("SceneEntityAppearNotify, uid: %v, type: %v, len: %v",
player.PlayerID, sceneEntityAppearNotify.AppearType, len(sceneEntityAppearNotify.EntityList))
logger.Debug("[SceneEntityAppearNotify UC], type: %v, len: %v, uid: %v", ntf.AppearType, len(ntf.EntityList), player.PlayerID)
g.SendMsg(cmd.SceneEntityAppearNotify, player.PlayerID, player.ClientSeq, ntf)
}
// AddSceneEntityNotifyBroadcast 添加的场景实体广播
func (g *Game) AddSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityList []*proto.SceneEntityInfo, aec bool, player *model.Player) {
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
func (g *Game) AddSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityList []*proto.SceneEntityInfo, aec bool, aecUid uint32) {
ntf := &proto.SceneEntityAppearNotify{
AppearType: visionType,
EntityList: entityList,
}
for _, scenePlayer := range scene.GetAllPlayer() {
if aec && scenePlayer.PlayerID == player.PlayerID {
continue
}
g.SendMsg(cmd.SceneEntityAppearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityAppearNotify)
logger.Debug("SceneEntityAppearNotify, uid: %v, type: %v, len: %v",
scenePlayer.PlayerID, sceneEntityAppearNotify.AppearType, len(sceneEntityAppearNotify.EntityList))
world := scene.GetWorld()
owner := world.GetOwner()
logger.Debug("[SceneEntityAppearNotify BC], type: %v, len: %v, uid: %v, aec: %v", ntf.AppearType, len(ntf.EntityList), owner.PlayerID, aec)
if aec {
g.SendToSceneAEC(scene, cmd.SceneEntityAppearNotify, owner.ClientSeq, ntf, aecUid)
} else {
g.SendToSceneA(scene, cmd.SceneEntityAppearNotify, owner.ClientSeq, ntf)
}
}
// RemoveSceneEntityNotifyToPlayer 移除的场景实体同步给玩家
func (g *Game) RemoveSceneEntityNotifyToPlayer(player *model.Player, visionType proto.VisionType, entityIdList []uint32) {
sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
ntf := &proto.SceneEntityDisappearNotify{
EntityList: entityIdList,
DisappearType: visionType,
}
g.SendMsg(cmd.SceneEntityDisappearNotify, player.PlayerID, player.ClientSeq, sceneEntityDisappearNotify)
logger.Debug("SceneEntityDisappearNotify, uid: %v, type: %v, len: %v",
player.PlayerID, sceneEntityDisappearNotify.DisappearType, len(sceneEntityDisappearNotify.EntityList))
logger.Debug("[SceneEntityDisappearNotify UC], type: %v, len: %v, uid: %v", ntf.DisappearType, len(ntf.EntityList), player.PlayerID)
g.SendMsg(cmd.SceneEntityDisappearNotify, player.PlayerID, player.ClientSeq, ntf)
}
// RemoveSceneEntityNotifyBroadcast 移除的场景实体广播
func (g *Game) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityIdList []uint32, aec bool, player *model.Player) {
sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
func (g *Game) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityIdList []uint32, aec bool, aecUid uint32) {
ntf := &proto.SceneEntityDisappearNotify{
EntityList: entityIdList,
DisappearType: visionType,
}
for _, scenePlayer := range scene.GetAllPlayer() {
if aec && scenePlayer.PlayerID == player.PlayerID {
continue
}
g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify)
logger.Debug("SceneEntityDisappearNotify, uid: %v, type: %v, len: %v",
scenePlayer.PlayerID, sceneEntityDisappearNotify.DisappearType, len(sceneEntityDisappearNotify.EntityList))
world := scene.GetWorld()
owner := world.GetOwner()
logger.Debug("[SceneEntityDisappearNotify BC], type: %v, len: %v, uid: %v, aec: %v", ntf.DisappearType, len(ntf.EntityList), owner.PlayerID, aec)
if aec {
g.SendToSceneAEC(scene, cmd.SceneEntityDisappearNotify, owner.ClientSeq, ntf, aecUid)
} else {
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, owner.ClientSeq, ntf)
}
}
@@ -445,7 +449,7 @@ func (g *Game) AddSceneEntityNotify(player *model.Player, visionType proto.Visio
}
}
if broadcast {
g.AddSceneEntityNotifyBroadcast(scene, visionType, entityList, aec, player)
g.AddSceneEntityNotifyBroadcast(scene, visionType, entityList, aec, player.PlayerID)
} else {
g.AddSceneEntityNotifyToPlayer(player, visionType, entityList)
}
@@ -453,12 +457,12 @@ func (g *Game) AddSceneEntityNotify(player *model.Player, visionType proto.Visio
}
// EntityFightPropUpdateNotifyBroadcast 场景实体战斗属性变更通知广播
func (g *Game) EntityFightPropUpdateNotifyBroadcast(world *World, entity *Entity) {
func (g *Game) EntityFightPropUpdateNotifyBroadcast(scene *Scene, entity *Entity) {
ntf := &proto.EntityFightPropUpdateNotify{
FightPropMap: entity.GetFightProp(),
EntityId: entity.GetId(),
}
g.SendToWorldA(world, cmd.EntityFightPropUpdateNotify, 0, ntf)
g.SendToSceneA(scene, cmd.EntityFightPropUpdateNotify, 0, ntf)
}
// KillPlayerAvatar 杀死玩家活跃角色实体
@@ -514,7 +518,7 @@ func (g *Game) RevivePlayerAvatar(player *model.Player) {
avatar.LifeState = constant.LIFE_STATE_ALIVE
// 设置血量
avatar.FightPropMap[constant.FIGHT_PROP_CUR_HP] = 110
g.EntityFightPropUpdateNotifyBroadcast(world, avatarEntity)
g.EntityFightPropUpdateNotifyBroadcast(scene, avatarEntity)
avatarEntity.lifeState = constant.LIFE_STATE_REVIVE
@@ -536,7 +540,7 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d
if entity.GetEntityType() == constant.ENTITY_TYPE_MONSTER {
// 设置血量
entity.fightProp[constant.FIGHT_PROP_CUR_HP] = 0
g.EntityFightPropUpdateNotifyBroadcast(scene.world, entity)
g.EntityFightPropUpdateNotifyBroadcast(scene, entity)
// 随机掉落
g.monsterDrop(player, entity)
}
@@ -547,8 +551,8 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d
DieType: dieType,
MoveReliableSeq: entity.GetLastMoveReliableSeq(),
}
g.SendToWorldA(scene.world, cmd.LifeStateChangeNotify, 0, ntf)
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_DIE, []uint32{entity.GetId()}, false, nil)
g.SendToSceneA(scene, cmd.LifeStateChangeNotify, 0, ntf)
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_DIE, []uint32{entity.GetId()}, false, 0)
// 删除实体
scene.DestroyEntity(entity.GetId())
group := scene.GetGroupById(entity.GetGroupId())

View File

@@ -54,9 +54,7 @@ func (g *Game) ChangeAvatarReq(player *model.Player, payloadMsg pb.Message) {
DisappearType: proto.VisionType_VISION_REPLACE,
EntityList: []uint32{oldAvatarEntity.GetId()},
}
for _, scenePlayer := range scene.GetAllPlayer() {
g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify)
}
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify)
newAvatarId := world.GetPlayerActiveAvatarId(player)
newAvatarEntity := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarId)
@@ -65,9 +63,7 @@ func (g *Game) ChangeAvatarReq(player *model.Player, payloadMsg pb.Message) {
Param: oldAvatarEntity.GetId(),
EntityList: []*proto.SceneEntityInfo{newAvatarEntity},
}
for _, scenePlayer := range scene.GetAllPlayer() {
g.SendMsg(cmd.SceneEntityAppearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityAppearNotify)
}
g.SendToSceneA(scene, cmd.SceneEntityAppearNotify, player.ClientSeq, sceneEntityAppearNotify)
changeAvatarRsp := &proto.ChangeAvatarRsp{
CurGuid: targetAvatarGuid,
@@ -214,10 +210,8 @@ func (g *Game) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.Message
newAvatarIndex := world.GetPlayerAvatarIndexByAvatarId(player, currAvatarId)
world.SetPlayerAvatarIndex(player, newAvatarIndex)
for _, worldPlayer := range world.GetAllPlayer() {
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world, player)
g.SendMsg(cmd.SceneTeamUpdateNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneTeamUpdateNotify)
}
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world, player)
g.SendToWorldA(world, cmd.SceneTeamUpdateNotify, player.ClientSeq, sceneTeamUpdateNotify)
changeMpTeamAvatarRsp := &proto.ChangeMpTeamAvatarRsp{
CurAvatarGuid: req.CurAvatarGuid,
@@ -278,65 +272,47 @@ func (g *Game) PacketSceneTeamUpdateNotify(world *World, player *model.Player) *
sceneTeamAvatar.AvatarInfo = g.PacketAvatarInfo(worldPlayerAvatar)
sceneTeamAvatar.SceneAvatarInfo = g.PacketSceneAvatarInfo(worldPlayerScene, worldPlayer, worldAvatar.GetAvatarId())
}
// add AbilityControlBlock
// 角色的ability控制块
acb := sceneTeamAvatar.AbilityControlBlock
embryoId := 0
// add avatar abilities
abilityId := 0
// 默认ability
for _, abilityHashCode := range constant.DEFAULT_ABILITY_HASH_CODE {
abilityId++
ae := &proto.AbilityEmbryo{
AbilityId: uint32(abilityId),
AbilityNameHash: uint32(abilityHashCode),
AbilityOverrideNameHash: uint32(endec.Hk4eAbilityHashCode("Default")),
}
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, ae)
}
// 角色ability
avatarDataConfig := gdconf.GetAvatarDataById(int32(worldAvatar.GetAvatarId()))
if avatarDataConfig != nil {
for _, abilityId := range avatarDataConfig.AbilityHashCodeList {
embryoId++
emb := &proto.AbilityEmbryo{
AbilityId: uint32(embryoId),
AbilityNameHash: uint32(abilityId),
AbilityOverrideNameHash: uint32(constant.DEFAULT_ABILITY_NAME),
for _, abilityHashCode := range avatarDataConfig.AbilityHashCodeList {
abilityId++
ae := &proto.AbilityEmbryo{
AbilityId: uint32(abilityId),
AbilityNameHash: uint32(abilityHashCode),
AbilityOverrideNameHash: uint32(endec.Hk4eAbilityHashCode("Default")),
}
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, emb)
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, ae)
}
}
// add default abilities
for _, abilityId := range constant.DEFAULT_ABILITY_HASHES {
embryoId++
emb := &proto.AbilityEmbryo{
AbilityId: uint32(embryoId),
AbilityNameHash: uint32(abilityId),
AbilityOverrideNameHash: uint32(constant.DEFAULT_ABILITY_NAME),
}
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, emb)
}
// // add team resonances
// for id := range worldPlayer.TeamConfig.TeamResonancesConfig {
// embryoId++
// emb := &proto.AbilityEmbryo{
// AbilityId: uint32(embryoId),
// AbilityNameHash: uint32(id),
// AbilityOverrideNameHash: uint32(constant.GameConstantConst.DEFAULT_ABILITY_NAME),
// }
// acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, emb)
// }
// add skill depot abilities
// 技能库ability
skillDepot := gdconf.GetAvatarSkillDepotDataById(int32(worldPlayerAvatar.SkillDepotId))
if skillDepot != nil && len(skillDepot.AbilityHashCodeList) != 0 {
for _, id := range skillDepot.AbilityHashCodeList {
embryoId++
emb := &proto.AbilityEmbryo{
AbilityId: uint32(embryoId),
AbilityNameHash: uint32(id),
AbilityOverrideNameHash: uint32(constant.DEFAULT_ABILITY_NAME),
for _, abilityHashCode := range skillDepot.AbilityHashCodeList {
abilityId++
ae := &proto.AbilityEmbryo{
AbilityId: uint32(abilityId),
AbilityNameHash: uint32(abilityHashCode),
AbilityOverrideNameHash: uint32(endec.Hk4eAbilityHashCode("Default")),
}
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, emb)
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, ae)
}
}
// add equip abilities
for skill := range worldPlayerAvatar.ExtraAbilityEmbryos {
embryoId++
emb := &proto.AbilityEmbryo{
AbilityId: uint32(embryoId),
AbilityNameHash: uint32(endec.Hk4eAbilityHashCode(skill)),
AbilityOverrideNameHash: uint32(constant.DEFAULT_ABILITY_NAME),
}
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, emb)
}
// TODO 队伍ability
// TODO 装备ability
sceneTeamUpdateNotify.SceneTeamAvatarList = append(sceneTeamUpdateNotify.SceneTeamAvatarList, sceneTeamAvatar)
}
return sceneTeamUpdateNotify

View File

@@ -120,7 +120,7 @@ func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleI
}
// 删除已创建的载具
scene.DestroyEntity(entity.GetId())
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{entity.GetId()}, false, nil)
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{entity.GetId()}, false, 0)
}
// EnterVehicle 进入载具

View File

@@ -501,11 +501,7 @@ func (g *Game) TeleportPlayer(
// 传送玩家
newSceneId := sceneId
oldSceneId := player.SceneId
oldPos := &model.Vector{
X: player.Pos.X,
Y: player.Pos.Y,
Z: player.Pos.Z,
}
oldPos := &model.Vector{X: player.Pos.X, Y: player.Pos.Y, Z: player.Pos.Z}
jumpScene := false
if newSceneId != oldSceneId {
jumpScene = true
@@ -518,7 +514,7 @@ func (g *Game) TeleportPlayer(
return
}
activeAvatarId := world.GetPlayerActiveAvatarId(player)
g.RemoveSceneEntityNotifyBroadcast(oldScene, proto.VisionType_VISION_REMOVE, []uint32{world.GetPlayerWorldAvatarEntityId(player, activeAvatarId)}, false, nil)
g.RemoveSceneEntityNotifyBroadcast(oldScene, proto.VisionType_VISION_REMOVE, []uint32{world.GetPlayerWorldAvatarEntityId(player, activeAvatarId)}, false, 0)
if jumpScene {
delTeamEntityNotify := g.PacketDelTeamEntityNotify(oldScene, player)
g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerID, player.ClientSeq, delTeamEntityNotify)
@@ -533,12 +529,8 @@ func (g *Game) TeleportPlayer(
newScene.AddPlayer(player)
}
player.SceneLoadState = model.SceneNone
player.Pos.X = pos.X
player.Pos.Y = pos.Y
player.Pos.Z = pos.Z
player.Rot.X = rot.X
player.Rot.Y = rot.Y
player.Rot.Z = rot.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
var enterType proto.EnterType
if jumpScene {