mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 16:02:26 +08:00
掉落场景物件
This commit is contained in:
@@ -207,17 +207,17 @@ func (g *GMCmd) GMUnlockAllPoint(userId uint32, sceneId uint32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GMCreateGadget 在玩家附近创建物件实体
|
// GMCreateGadget 在玩家附近创建物件实体
|
||||||
func (g *GMCmd) GMCreateGadget(userId uint32, gadgetId uint32, posX, posY, posZ float64, itemId uint32) {
|
func (g *GMCmd) GMCreateGadget(userId uint32, posX, posY, posZ float64, gadgetId, itemId, count uint32) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
GAME_MANAGER.CreateGadget(player, gadgetId, &model.Vector{
|
GAME_MANAGER.CreateGadget(player, &model.Vector{
|
||||||
X: posX,
|
X: posX,
|
||||||
Y: posY,
|
Y: posY,
|
||||||
Z: posZ,
|
Z: posZ,
|
||||||
}, itemId)
|
}, gadgetId, itemId, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 系统级GM指令
|
// 系统级GM指令
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"hk4e/gs/model"
|
"hk4e/gs/model"
|
||||||
"hk4e/pkg/logger"
|
"hk4e/pkg/logger"
|
||||||
"hk4e/pkg/object"
|
"hk4e/pkg/object"
|
||||||
|
"hk4e/pkg/random"
|
||||||
"hk4e/protocol/cmd"
|
"hk4e/protocol/cmd"
|
||||||
"hk4e/protocol/proto"
|
"hk4e/protocol/proto"
|
||||||
|
|
||||||
@@ -458,7 +459,7 @@ func (g *GameManager) AddSceneEntityNotify(player *model.Player, visionType prot
|
|||||||
sceneEntityInfoNpc := g.PacketSceneEntityInfoNpc(scene, entity.GetId())
|
sceneEntityInfoNpc := g.PacketSceneEntityInfoNpc(scene, entity.GetId())
|
||||||
entityList = append(entityList, sceneEntityInfoNpc)
|
entityList = append(entityList, sceneEntityInfoNpc)
|
||||||
case constant.ENTITY_TYPE_GADGET:
|
case constant.ENTITY_TYPE_GADGET:
|
||||||
sceneEntityInfoGadget := g.PacketSceneEntityInfoGadget(scene, entity.GetId())
|
sceneEntityInfoGadget := g.PacketSceneEntityInfoGadget(player, scene, entity.GetId())
|
||||||
entityList = append(entityList, sceneEntityInfoGadget)
|
entityList = append(entityList, sceneEntityInfoGadget)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -552,7 +553,7 @@ func (g *GameManager) KillEntity(player *model.Player, scene *Scene, entityId ui
|
|||||||
entity.fightProp[constant.FIGHT_PROP_CUR_HP] = 0
|
entity.fightProp[constant.FIGHT_PROP_CUR_HP] = 0
|
||||||
g.EntityFightPropUpdateNotifyBroadcast(scene.world, entity)
|
g.EntityFightPropUpdateNotifyBroadcast(scene.world, entity)
|
||||||
// TODO
|
// TODO
|
||||||
g.CreateGadget(player, 70600055, entity.pos, 104003)
|
g.CreateGadget(player, entity.pos, 70600055, 104003, 10)
|
||||||
}
|
}
|
||||||
entity.lifeState = constant.LIFE_STATE_DEAD
|
entity.lifeState = constant.LIFE_STATE_DEAD
|
||||||
ntf := &proto.LifeStateChangeNotify{
|
ntf := &proto.LifeStateChangeNotify{
|
||||||
@@ -580,14 +581,17 @@ func (g *GameManager) KillEntity(player *model.Player, scene *Scene, entityId ui
|
|||||||
func (g *GameManager) ChangeGadgetState(player *model.Player, entityId uint32, state uint32) {
|
func (g *GameManager) ChangeGadgetState(player *model.Player, entityId uint32, state uint32) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
|
logger.Error("get world is nil, worldId: %v", player.WorldId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
entity := scene.GetEntity(entityId)
|
entity := scene.GetEntity(entityId)
|
||||||
if entity == nil {
|
if entity == nil {
|
||||||
|
logger.Error("get entity is nil, entityId: %v", entityId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_GADGET {
|
if entity.GetEntityType() != constant.ENTITY_TYPE_GADGET {
|
||||||
|
logger.Error("entity is not gadget, entityId: %v", entityId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetEntity := entity.GetGadgetEntity()
|
||||||
@@ -664,18 +668,24 @@ func (g *GameManager) RemoveSceneGroup(player *model.Player, scene *Scene, group
|
|||||||
g.SendMsg(cmd.GroupUnloadNotify, player.PlayerID, player.ClientSeq, ntf)
|
g.SendMsg(cmd.GroupUnloadNotify, player.PlayerID, player.ClientSeq, ntf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) CreateGadget(player *model.Player, gadgetId uint32, pos *model.Vector, itemId uint32) {
|
func (g *GameManager) CreateGadget(player *model.Player, pos *model.Vector, gadgetId, itemId, count uint32) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
|
logger.Error("get world is nil, worldId: %v", player.WorldId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
|
pos.X += random.GetRandomFloat64(-5.0, 5.0)
|
||||||
|
pos.Z += random.GetRandomFloat64(-5.0, 5.0)
|
||||||
|
rot := new(model.Vector)
|
||||||
|
rot.Y = random.GetRandomFloat64(0.0, 360.0)
|
||||||
entityId := scene.CreateEntityGadgetNormal(
|
entityId := scene.CreateEntityGadgetNormal(
|
||||||
pos, new(model.Vector),
|
pos, rot,
|
||||||
gadgetId,
|
gadgetId,
|
||||||
constant.GADGET_STATE_DEFAULT,
|
constant.GADGET_STATE_DEFAULT,
|
||||||
&GadgetNormalEntity{
|
&GadgetNormalEntity{
|
||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
|
count: count,
|
||||||
},
|
},
|
||||||
0, 0,
|
0, 0,
|
||||||
)
|
)
|
||||||
@@ -686,11 +696,11 @@ var SceneTransactionSeq uint32 = 0
|
|||||||
|
|
||||||
func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType proto.EnterType) *proto.PlayerEnterSceneNotify {
|
func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType proto.EnterType) *proto.PlayerEnterSceneNotify {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
if world == nil {
|
||||||
if scene == nil {
|
logger.Error("get world is nil, worldId: %v", player.WorldId)
|
||||||
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
|
||||||
return new(proto.PlayerEnterSceneNotify)
|
return new(proto.PlayerEnterSceneNotify)
|
||||||
}
|
}
|
||||||
|
scene := world.GetSceneById(player.SceneId)
|
||||||
enterSceneToken := world.AddEnterSceneContext(&EnterSceneContext{
|
enterSceneToken := world.AddEnterSceneContext(&EnterSceneContext{
|
||||||
OldSceneId: 0,
|
OldSceneId: 0,
|
||||||
Uid: player.PlayerID,
|
Uid: player.PlayerID,
|
||||||
@@ -997,7 +1007,7 @@ func (g *GameManager) PacketSceneEntityInfoNpc(scene *Scene, entityId uint32) *p
|
|||||||
return sceneEntityInfo
|
return sceneEntityInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneEntityInfoGadget(scene *Scene, entityId uint32) *proto.SceneEntityInfo {
|
func (g *GameManager) PacketSceneEntityInfoGadget(player *model.Player, scene *Scene, entityId uint32) *proto.SceneEntityInfo {
|
||||||
entity := scene.GetEntity(entityId)
|
entity := scene.GetEntity(entityId)
|
||||||
if entity == nil {
|
if entity == nil {
|
||||||
return new(proto.SceneEntityInfo)
|
return new(proto.SceneEntityInfo)
|
||||||
@@ -1043,7 +1053,7 @@ func (g *GameManager) PacketSceneEntityInfoGadget(scene *Scene, entityId uint32)
|
|||||||
switch gadgetEntity.GetGadgetType() {
|
switch gadgetEntity.GetGadgetType() {
|
||||||
case GADGET_TYPE_NORMAL:
|
case GADGET_TYPE_NORMAL:
|
||||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||||
Gadget: g.PacketSceneGadgetInfoNormal(entity),
|
Gadget: g.PacketSceneGadgetInfoNormal(player, entity),
|
||||||
}
|
}
|
||||||
case GADGET_TYPE_CLIENT:
|
case GADGET_TYPE_CLIENT:
|
||||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||||
@@ -1129,7 +1139,7 @@ func (g *GameManager) PacketSceneNpcInfo(entity *NpcEntity) *proto.SceneNpcInfo
|
|||||||
return sceneNpcInfo
|
return sceneNpcInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneGadgetInfoNormal(entity *Entity) *proto.SceneGadgetInfo {
|
func (g *GameManager) PacketSceneGadgetInfoNormal(player *model.Player, entity *Entity) *proto.SceneGadgetInfo {
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetEntity := entity.GetGadgetEntity()
|
||||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetEntity.GetGadgetId()))
|
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetEntity.GetGadgetId()))
|
||||||
if gadgetDataConfig == nil {
|
if gadgetDataConfig == nil {
|
||||||
@@ -1144,9 +1154,22 @@ func (g *GameManager) PacketSceneGadgetInfoNormal(entity *Entity) *proto.SceneGa
|
|||||||
IsEnableInteract: true,
|
IsEnableInteract: true,
|
||||||
AuthorityPeerId: 1,
|
AuthorityPeerId: 1,
|
||||||
}
|
}
|
||||||
|
gadgetNormalEntity := gadgetEntity.GetGadgetNormalEntity()
|
||||||
|
dbItem := player.GetDbItem()
|
||||||
switch gadgetDataConfig.Type {
|
switch gadgetDataConfig.Type {
|
||||||
|
case constant.GADGET_TYPE_GADGET:
|
||||||
|
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_TrifleItem{
|
||||||
|
TrifleItem: &proto.Item{
|
||||||
|
ItemId: gadgetNormalEntity.GetItemId(),
|
||||||
|
Guid: dbItem.GetItemGuid(gadgetNormalEntity.GetItemId()),
|
||||||
|
Detail: &proto.Item_Material{
|
||||||
|
Material: &proto.Material{
|
||||||
|
Count: gadgetNormalEntity.GetCount(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
case constant.GADGET_TYPE_GATHER_OBJECT:
|
case constant.GADGET_TYPE_GATHER_OBJECT:
|
||||||
gadgetNormalEntity := gadgetEntity.GetGadgetNormalEntity()
|
|
||||||
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_GatherGadget{
|
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_GatherGadget{
|
||||||
GatherGadget: &proto.GatherGadgetInfo{
|
GatherGadget: &proto.GatherGadgetInfo{
|
||||||
ItemId: gadgetNormalEntity.GetItemId(),
|
ItemId: gadgetNormalEntity.GetItemId(),
|
||||||
|
|||||||
@@ -335,14 +335,14 @@ func (g *GameManager) GadgetInteractReq(player *model.Player, payloadMsg pb.Mess
|
|||||||
interactType = proto.InteractType_INTERACT_OPEN_CHEST
|
interactType = proto.InteractType_INTERACT_OPEN_CHEST
|
||||||
if req.OpType == proto.InterOpType_INTER_OP_FINISH {
|
if req.OpType == proto.InterOpType_INTER_OP_FINISH {
|
||||||
// 宝箱交互结束 开启宝箱
|
// 宝箱交互结束 开启宝箱
|
||||||
|
// TODO
|
||||||
|
g.CreateGadget(player, entity.pos, 70600055, 104003, 1)
|
||||||
g.SendMsg(cmd.WorldChestOpenNotify, player.PlayerID, player.ClientSeq, &proto.WorldChestOpenNotify{
|
g.SendMsg(cmd.WorldChestOpenNotify, player.PlayerID, player.ClientSeq, &proto.WorldChestOpenNotify{
|
||||||
GroupId: entity.GetGroupId(),
|
GroupId: entity.GetGroupId(),
|
||||||
SceneId: scene.GetId(),
|
SceneId: scene.GetId(),
|
||||||
ConfigId: entity.GetConfigId(),
|
ConfigId: entity.GetConfigId(),
|
||||||
})
|
})
|
||||||
// TODO
|
g.ChangeGadgetState(player, entity.GetId(), constant.GADGET_STATE_CHEST_OPENED)
|
||||||
g.CreateGadget(player, 70600055, entity.pos, 104003)
|
|
||||||
g.ChangeGadgetState(player, scene.GetId(), constant.GADGET_STATE_CHEST_OPENED)
|
|
||||||
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -526,6 +526,10 @@ func (e *Entity) GetId() uint32 {
|
|||||||
return e.id
|
return e.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *Entity) GetScene() *Scene {
|
||||||
|
return e.scene
|
||||||
|
}
|
||||||
|
|
||||||
func (e *Entity) GetLifeState() uint16 {
|
func (e *Entity) GetLifeState() uint16 {
|
||||||
return e.lifeState
|
return e.lifeState
|
||||||
}
|
}
|
||||||
@@ -671,12 +675,17 @@ func (g *GadgetEntity) GetGadgetVehicleEntity() *GadgetVehicleEntity {
|
|||||||
|
|
||||||
type GadgetNormalEntity struct {
|
type GadgetNormalEntity struct {
|
||||||
itemId uint32
|
itemId uint32
|
||||||
|
count uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GadgetNormalEntity) GetItemId() uint32 {
|
func (g *GadgetNormalEntity) GetItemId() uint32 {
|
||||||
return g.itemId
|
return g.itemId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GadgetNormalEntity) GetCount() uint32 {
|
||||||
|
return g.count
|
||||||
|
}
|
||||||
|
|
||||||
type GadgetClientEntity struct {
|
type GadgetClientEntity struct {
|
||||||
configId uint32
|
configId uint32
|
||||||
campId uint32
|
campId uint32
|
||||||
|
|||||||
Reference in New Issue
Block a user