mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 15:52:27 +08:00
优化
This commit is contained in:
@@ -432,9 +432,9 @@ func getTempFightPropMap() map[uint32]float32 {
|
||||
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_BASE_HP: float32(10000.0),
|
||||
constant.FIGHT_PROP_CUR_HP: float32(10000.0),
|
||||
constant.FIGHT_PROP_MAX_HP: float32(10000.0),
|
||||
constant.FIGHT_PROP_PHYSICAL_SUB_HURT: float32(0.1),
|
||||
constant.FIGHT_PROP_ICE_SUB_HURT: float32(0.1),
|
||||
constant.FIGHT_PROP_FIRE_SUB_HURT: float32(0.1),
|
||||
|
||||
@@ -553,27 +553,7 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d
|
||||
entity.fightProp[constant.FIGHT_PROP_CUR_HP] = 0
|
||||
g.EntityFightPropUpdateNotifyBroadcast(scene.world, entity)
|
||||
// 随机掉落
|
||||
sceneGroupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
||||
monsterConfig := sceneGroupConfig.MonsterMap[int32(entity.GetConfigId())]
|
||||
monsterDropDataConfig := gdconf.GetMonsterDropDataByDropTagAndLevel(monsterConfig.DropTag, monsterConfig.Level)
|
||||
if monsterDropDataConfig == nil {
|
||||
logger.Error("get monster drop data config is nil, monsterConfig: %v, uid: %v", monsterConfig, player.PlayerID)
|
||||
return
|
||||
}
|
||||
dropDataConfig := gdconf.GetDropDataById(monsterDropDataConfig.DropId)
|
||||
if dropDataConfig == nil {
|
||||
logger.Error("get drop data config is nil, dropId: %v, uid: %v", monsterDropDataConfig.DropId, player.PlayerID)
|
||||
return
|
||||
}
|
||||
totalItemMap := g.doRandDropFullTimes(dropDataConfig, int(monsterDropDataConfig.DropCount))
|
||||
for itemId, count := range totalItemMap {
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("get item data config is nil, itemId: %v, uid: %v", itemId, player.PlayerID)
|
||||
continue
|
||||
}
|
||||
g.CreateDropGadget(player, entity.pos, uint32(itemDataConfig.GadgetId), itemId, count)
|
||||
}
|
||||
g.monsterDrop(player, entity)
|
||||
}
|
||||
entity.lifeState = constant.LIFE_STATE_DEAD
|
||||
ntf := &proto.LifeStateChangeNotify{
|
||||
@@ -588,7 +568,6 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d
|
||||
scene.DestroyEntity(entity.GetId())
|
||||
group := scene.GetGroupById(entity.groupId)
|
||||
if group == nil {
|
||||
logger.Error("get scene group is nil, groupId: %v, uid: %v", entity.groupId, player.PlayerID)
|
||||
return
|
||||
}
|
||||
group.DestroyEntity(entity.GetId())
|
||||
|
||||
@@ -337,27 +337,7 @@ func (g *Game) GadgetInteractReq(player *model.Player, payloadMsg pb.Message) {
|
||||
// 宝箱交互结束 开启宝箱
|
||||
if req.OpType == proto.InterOpType_INTER_OP_FINISH {
|
||||
// 随机掉落
|
||||
sceneGroupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
||||
gadgetConfig := sceneGroupConfig.GadgetMap[int32(entity.GetConfigId())]
|
||||
chestDropDataConfig := gdconf.GetChestDropDataByDropTagAndLevel(gadgetConfig.DropTag, gadgetConfig.Level)
|
||||
if chestDropDataConfig == nil {
|
||||
logger.Error("get chest drop data config is nil, gadgetConfig: %v, uid: %v", gadgetConfig, player.PlayerID)
|
||||
return
|
||||
}
|
||||
dropDataConfig := gdconf.GetDropDataById(chestDropDataConfig.DropId)
|
||||
if dropDataConfig == nil {
|
||||
logger.Error("get drop data config is nil, dropId: %v, uid: %v", chestDropDataConfig.DropId, player.PlayerID)
|
||||
return
|
||||
}
|
||||
totalItemMap := g.doRandDropFullTimes(dropDataConfig, int(chestDropDataConfig.DropCount))
|
||||
for itemId, count := range totalItemMap {
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("get item data config is nil, itemId: %v, uid: %v", itemId, player.PlayerID)
|
||||
continue
|
||||
}
|
||||
g.CreateDropGadget(player, entity.pos, uint32(itemDataConfig.GadgetId), itemId, count)
|
||||
}
|
||||
g.chestDrop(player, entity)
|
||||
// 更新宝箱状态
|
||||
g.SendMsg(cmd.WorldChestOpenNotify, player.PlayerID, player.ClientSeq, &proto.WorldChestOpenNotify{
|
||||
GroupId: entity.GetGroupId(),
|
||||
@@ -378,6 +358,54 @@ func (g *Game) GadgetInteractReq(player *model.Player, payloadMsg pb.Message) {
|
||||
g.SendMsg(cmd.GadgetInteractRsp, player.PlayerID, player.ClientSeq, rsp)
|
||||
}
|
||||
|
||||
func (g *Game) monsterDrop(player *model.Player, entity *Entity) {
|
||||
sceneGroupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
||||
monsterConfig := sceneGroupConfig.MonsterMap[int32(entity.GetConfigId())]
|
||||
monsterDropDataConfig := gdconf.GetMonsterDropDataByDropTagAndLevel(monsterConfig.DropTag, monsterConfig.Level)
|
||||
if monsterDropDataConfig == nil {
|
||||
logger.Error("get monster drop data config is nil, monsterConfig: %v, uid: %v", monsterConfig, player.PlayerID)
|
||||
return
|
||||
}
|
||||
dropDataConfig := gdconf.GetDropDataById(monsterDropDataConfig.DropId)
|
||||
if dropDataConfig == nil {
|
||||
logger.Error("get drop data config is nil, dropId: %v, uid: %v", monsterDropDataConfig.DropId, player.PlayerID)
|
||||
return
|
||||
}
|
||||
totalItemMap := g.doRandDropFullTimes(dropDataConfig, int(monsterDropDataConfig.DropCount))
|
||||
for itemId, count := range totalItemMap {
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("get item data config is nil, itemId: %v, uid: %v", itemId, player.PlayerID)
|
||||
continue
|
||||
}
|
||||
g.CreateDropGadget(player, entity.pos, uint32(itemDataConfig.GadgetId), itemId, count)
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Game) chestDrop(player *model.Player, entity *Entity) {
|
||||
sceneGroupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
||||
gadgetConfig := sceneGroupConfig.GadgetMap[int32(entity.GetConfigId())]
|
||||
chestDropDataConfig := gdconf.GetChestDropDataByDropTagAndLevel(gadgetConfig.DropTag, gadgetConfig.Level)
|
||||
if chestDropDataConfig == nil {
|
||||
logger.Error("get chest drop data config is nil, gadgetConfig: %v, uid: %v", gadgetConfig, player.PlayerID)
|
||||
return
|
||||
}
|
||||
dropDataConfig := gdconf.GetDropDataById(chestDropDataConfig.DropId)
|
||||
if dropDataConfig == nil {
|
||||
logger.Error("get drop data config is nil, dropId: %v, uid: %v", chestDropDataConfig.DropId, player.PlayerID)
|
||||
return
|
||||
}
|
||||
totalItemMap := g.doRandDropFullTimes(dropDataConfig, int(chestDropDataConfig.DropCount))
|
||||
for itemId, count := range totalItemMap {
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("get item data config is nil, itemId: %v, uid: %v", itemId, player.PlayerID)
|
||||
continue
|
||||
}
|
||||
g.CreateDropGadget(player, entity.pos, uint32(itemDataConfig.GadgetId), itemId, count)
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Game) doRandDropFullTimes(dropDataConfig *gdconf.DropData, times int) map[uint32]uint32 {
|
||||
totalItemMap := make(map[uint32]uint32)
|
||||
for i := 0; i < times; i++ {
|
||||
|
||||
Reference in New Issue
Block a user