mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 16:02:26 +08:00
fix panic
This commit is contained in:
@@ -322,19 +322,25 @@ func UpdateFrame(rgb bool) {
|
|||||||
for h := 0; h < SCREEN_HEIGHT; h++ {
|
for h := 0; h < SCREEN_HEIGHT; h++ {
|
||||||
// 创建像素点
|
// 创建像素点
|
||||||
if rgb {
|
if rgb {
|
||||||
entityId := scene.CreateEntityGadgetNormal(&model.Vector{
|
entityId := scene.CreateEntityGadgetNormal(
|
||||||
X: leftTopPos.X - float64(w)*SCREEN_DPI,
|
&model.Vector{
|
||||||
Y: leftTopPos.Y - float64(h)*SCREEN_DPI,
|
|
||||||
Z: leftTopPos.Z,
|
|
||||||
}, new(model.Vector), uint32(FRAME_COLOR[w][h]), uint32(constant.GADGET_STATE_DEFAULT), nil, 0, 0)
|
|
||||||
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, entityId)
|
|
||||||
} else {
|
|
||||||
if !FRAME[w][h] {
|
|
||||||
entityId := scene.CreateEntityGadgetNormal(&model.Vector{
|
|
||||||
X: leftTopPos.X - float64(w)*SCREEN_DPI,
|
X: leftTopPos.X - float64(w)*SCREEN_DPI,
|
||||||
Y: leftTopPos.Y - float64(h)*SCREEN_DPI,
|
Y: leftTopPos.Y - float64(h)*SCREEN_DPI,
|
||||||
Z: leftTopPos.Z,
|
Z: leftTopPos.Z,
|
||||||
}, new(model.Vector), uint32(GADGET_ID), uint32(constant.GADGET_STATE_DEFAULT), nil, 0, 0)
|
}, new(model.Vector),
|
||||||
|
uint32(FRAME_COLOR[w][h]), uint32(constant.GADGET_STATE_DEFAULT),
|
||||||
|
new(GadgetNormalEntity), 0, 0)
|
||||||
|
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, entityId)
|
||||||
|
} else {
|
||||||
|
if !FRAME[w][h] {
|
||||||
|
entityId := scene.CreateEntityGadgetNormal(
|
||||||
|
&model.Vector{
|
||||||
|
X: leftTopPos.X - float64(w)*SCREEN_DPI,
|
||||||
|
Y: leftTopPos.Y - float64(h)*SCREEN_DPI,
|
||||||
|
Z: leftTopPos.Z,
|
||||||
|
}, new(model.Vector),
|
||||||
|
uint32(GADGET_ID), uint32(constant.GADGET_STATE_DEFAULT),
|
||||||
|
new(GadgetNormalEntity), 0, 0)
|
||||||
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, entityId)
|
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, entityId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ func (g *GMCmd) GMCreateGadget(userId uint32, posX, posY, posZ float64, gadgetId
|
|||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
GAME_MANAGER.CreateGadget(player, &model.Vector{
|
GAME_MANAGER.CreateDropGadget(player, &model.Vector{
|
||||||
X: posX,
|
X: posX,
|
||||||
Y: posY,
|
Y: posY,
|
||||||
Z: posZ,
|
Z: posZ,
|
||||||
@@ -264,3 +264,11 @@ func (g *GMCmd) XLuaDebug(userId uint32, luacBase64 string) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GMCmd) PlayAudio() {
|
||||||
|
PlayAudio()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *GMCmd) UpdateFrame(rgb bool) {
|
||||||
|
UpdateFrame(rgb)
|
||||||
|
}
|
||||||
|
|||||||
@@ -553,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, entity.pos, 70600055, 104003, 10)
|
g.CreateDropGadget(player, entity.pos, 70600055, 104003, 10)
|
||||||
}
|
}
|
||||||
entity.lifeState = constant.LIFE_STATE_DEAD
|
entity.lifeState = constant.LIFE_STATE_DEAD
|
||||||
ntf := &proto.LifeStateChangeNotify{
|
ntf := &proto.LifeStateChangeNotify{
|
||||||
@@ -668,7 +668,7 @@ 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, pos *model.Vector, gadgetId, itemId, count uint32) {
|
func (g *GameManager) CreateDropGadget(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)
|
logger.Error("get world is nil, worldId: %v", player.WorldId)
|
||||||
@@ -684,6 +684,7 @@ func (g *GameManager) CreateGadget(player *model.Player, pos *model.Vector, gadg
|
|||||||
gadgetId,
|
gadgetId,
|
||||||
constant.GADGET_STATE_DEFAULT,
|
constant.GADGET_STATE_DEFAULT,
|
||||||
&GadgetNormalEntity{
|
&GadgetNormalEntity{
|
||||||
|
isDrop: true,
|
||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
count: count,
|
count: count,
|
||||||
},
|
},
|
||||||
@@ -1155,9 +1156,8 @@ func (g *GameManager) PacketSceneGadgetInfoNormal(player *model.Player, entity *
|
|||||||
AuthorityPeerId: 1,
|
AuthorityPeerId: 1,
|
||||||
}
|
}
|
||||||
gadgetNormalEntity := gadgetEntity.GetGadgetNormalEntity()
|
gadgetNormalEntity := gadgetEntity.GetGadgetNormalEntity()
|
||||||
dbItem := player.GetDbItem()
|
if gadgetNormalEntity.GetIsDrop() {
|
||||||
switch gadgetDataConfig.Type {
|
dbItem := player.GetDbItem()
|
||||||
case constant.GADGET_TYPE_GADGET:
|
|
||||||
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_TrifleItem{
|
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_TrifleItem{
|
||||||
TrifleItem: &proto.Item{
|
TrifleItem: &proto.Item{
|
||||||
ItemId: gadgetNormalEntity.GetItemId(),
|
ItemId: gadgetNormalEntity.GetItemId(),
|
||||||
@@ -1169,7 +1169,7 @@ func (g *GameManager) PacketSceneGadgetInfoNormal(player *model.Player, entity *
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
case constant.GADGET_TYPE_GATHER_OBJECT:
|
} else if gadgetDataConfig.Type == constant.GADGET_TYPE_GATHER_OBJECT {
|
||||||
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_GatherGadget{
|
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_GatherGadget{
|
||||||
GatherGadget: &proto.GatherGadgetInfo{
|
GatherGadget: &proto.GatherGadgetInfo{
|
||||||
ItemId: gadgetNormalEntity.GetItemId(),
|
ItemId: gadgetNormalEntity.GetItemId(),
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ func (g *GameManager) GadgetInteractReq(player *model.Player, payloadMsg pb.Mess
|
|||||||
if req.OpType == proto.InterOpType_INTER_OP_FINISH {
|
if req.OpType == proto.InterOpType_INTER_OP_FINISH {
|
||||||
// 宝箱交互结束 开启宝箱
|
// 宝箱交互结束 开启宝箱
|
||||||
// TODO
|
// TODO
|
||||||
g.CreateGadget(player, entity.pos, 70600055, 104003, 1)
|
g.CreateDropGadget(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(),
|
||||||
|
|||||||
@@ -402,7 +402,9 @@ func (s *Scene) createConfigEntity(groupId uint32, entityConfig any) uint32 {
|
|||||||
uint32(gatherDataConfig.GadgetId),
|
uint32(gatherDataConfig.GadgetId),
|
||||||
uint32(constant.GADGET_STATE_DEFAULT),
|
uint32(constant.GADGET_STATE_DEFAULT),
|
||||||
&GadgetNormalEntity{
|
&GadgetNormalEntity{
|
||||||
|
isDrop: false,
|
||||||
itemId: uint32(gatherDataConfig.ItemId),
|
itemId: uint32(gatherDataConfig.ItemId),
|
||||||
|
count: 1,
|
||||||
},
|
},
|
||||||
uint32(gadget.ConfigId),
|
uint32(gadget.ConfigId),
|
||||||
groupId,
|
groupId,
|
||||||
@@ -413,7 +415,7 @@ func (s *Scene) createConfigEntity(groupId uint32, entityConfig any) uint32 {
|
|||||||
&model.Vector{X: float64(gadget.Rot.X), Y: float64(gadget.Rot.Y), Z: float64(gadget.Rot.Z)},
|
&model.Vector{X: float64(gadget.Rot.X), Y: float64(gadget.Rot.Y), Z: float64(gadget.Rot.Z)},
|
||||||
uint32(gadget.GadgetId),
|
uint32(gadget.GadgetId),
|
||||||
uint32(gadget.State),
|
uint32(gadget.State),
|
||||||
nil,
|
new(GadgetNormalEntity),
|
||||||
uint32(gadget.ConfigId),
|
uint32(gadget.ConfigId),
|
||||||
groupId,
|
groupId,
|
||||||
)
|
)
|
||||||
@@ -426,21 +428,21 @@ func (s *Scene) createConfigEntity(groupId uint32, entityConfig any) uint32 {
|
|||||||
// TODO 临时写死
|
// TODO 临时写死
|
||||||
func getTempFightPropMap() map[uint32]float32 {
|
func getTempFightPropMap() map[uint32]float32 {
|
||||||
fpm := map[uint32]float32{
|
fpm := map[uint32]float32{
|
||||||
constant.FIGHT_PROP_CUR_HP: float32(72.91699),
|
constant.FIGHT_PROP_BASE_ATTACK: float32(50.0),
|
||||||
|
constant.FIGHT_PROP_CUR_ATTACK: float32(50.0),
|
||||||
|
constant.FIGHT_PROP_BASE_DEFENSE: float32(500.0),
|
||||||
|
constant.FIGHT_PROP_CUR_DEFENSE: float32(500.0),
|
||||||
|
constant.FIGHT_PROP_BASE_HP: float32(100000.0),
|
||||||
|
constant.FIGHT_PROP_CUR_HP: float32(100000.0),
|
||||||
|
constant.FIGHT_PROP_MAX_HP: float32(100000.0),
|
||||||
constant.FIGHT_PROP_PHYSICAL_SUB_HURT: float32(0.1),
|
constant.FIGHT_PROP_PHYSICAL_SUB_HURT: float32(0.1),
|
||||||
constant.FIGHT_PROP_CUR_DEFENSE: float32(505.0),
|
|
||||||
constant.FIGHT_PROP_CUR_ATTACK: float32(45.679916),
|
|
||||||
constant.FIGHT_PROP_ICE_SUB_HURT: float32(0.1),
|
constant.FIGHT_PROP_ICE_SUB_HURT: float32(0.1),
|
||||||
constant.FIGHT_PROP_BASE_ATTACK: float32(45.679916),
|
|
||||||
constant.FIGHT_PROP_MAX_HP: float32(72.91699),
|
|
||||||
constant.FIGHT_PROP_FIRE_SUB_HURT: float32(0.1),
|
constant.FIGHT_PROP_FIRE_SUB_HURT: float32(0.1),
|
||||||
constant.FIGHT_PROP_ELEC_SUB_HURT: float32(0.1),
|
constant.FIGHT_PROP_ELEC_SUB_HURT: float32(0.1),
|
||||||
constant.FIGHT_PROP_WIND_SUB_HURT: float32(0.1),
|
constant.FIGHT_PROP_WIND_SUB_HURT: float32(0.1),
|
||||||
constant.FIGHT_PROP_ROCK_SUB_HURT: float32(0.1),
|
constant.FIGHT_PROP_ROCK_SUB_HURT: float32(0.1),
|
||||||
constant.FIGHT_PROP_GRASS_SUB_HURT: float32(0.1),
|
constant.FIGHT_PROP_GRASS_SUB_HURT: float32(0.1),
|
||||||
constant.FIGHT_PROP_WATER_SUB_HURT: float32(0.1),
|
constant.FIGHT_PROP_WATER_SUB_HURT: float32(0.1),
|
||||||
constant.FIGHT_PROP_BASE_HP: float32(72.91699),
|
|
||||||
constant.FIGHT_PROP_BASE_DEFENSE: float32(505.0),
|
|
||||||
}
|
}
|
||||||
return fpm
|
return fpm
|
||||||
}
|
}
|
||||||
@@ -674,10 +676,15 @@ func (g *GadgetEntity) GetGadgetVehicleEntity() *GadgetVehicleEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GadgetNormalEntity struct {
|
type GadgetNormalEntity struct {
|
||||||
|
isDrop bool
|
||||||
itemId uint32
|
itemId uint32
|
||||||
count uint32
|
count uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GadgetNormalEntity) GetIsDrop() bool {
|
||||||
|
return g.isDrop
|
||||||
|
}
|
||||||
|
|
||||||
func (g *GadgetNormalEntity) GetItemId() uint32 {
|
func (g *GadgetNormalEntity) GetItemId() uint32 {
|
||||||
return g.itemId
|
return g.itemId
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user