修复主线任务至蒙德城
This commit is contained in:
1 parent
f0e0ae1918
commit
346b583f64
16 files changed
+649
-199
No files matched your search
@@ -0,0 +1,46 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
ITEM_USE_NONE = 0
|
||||
ITEM_USE_ACCEPT_QUEST = 1
|
||||
ITEM_USE_TRIGGER_ABILITY = 2
|
||||
ITEM_USE_GAIN_AVATAR = 3
|
||||
ITEM_USE_ADD_EXP = 4
|
||||
ITEM_USE_RELIVE_AVATAR = 5
|
||||
ITEM_USE_ADD_BIG_TALENT_POINT = 6
|
||||
ITEM_USE_ADD_PERSIST_STAMINA = 7
|
||||
ITEM_USE_ADD_TEMPORARY_STAMINA = 8
|
||||
ITEM_USE_ADD_CUR_STAMINA = 9
|
||||
ITEM_USE_ADD_CUR_HP = 10
|
||||
ITEM_USE_ADD_ELEM_ENERGY = 11
|
||||
ITEM_USE_ADD_ALL_ENERGY = 12
|
||||
ITEM_USE_ADD_DUNGEON_COND_TIME = 13
|
||||
ITEM_USE_ADD_WEAPON_EXP = 14
|
||||
ITEM_USE_ADD_SERVER_BUFF = 15
|
||||
ITEM_USE_DEL_SERVER_BUFF = 16
|
||||
ITEM_USE_UNLOCK_COOK_RECIPE = 17
|
||||
ITEM_USE_OPEN_RANDOM_CHEST = 20
|
||||
ITEM_USE_MAKE_GADGET = 24
|
||||
ITEM_USE_ADD_ITEM = 25
|
||||
ITEM_USE_GRANT_SELECT_REWARD = 26
|
||||
ITEM_USE_ADD_SELECT_ITEM = 27
|
||||
ITEM_USE_GAIN_FLYCLOAK = 28
|
||||
ITEM_USE_GAIN_NAME_CARD = 29
|
||||
ITEM_USE_UNLOCK_PAID_BATTLE_PASS_NORMAL = 30
|
||||
ITEM_USE_GAIN_CARD_PRODUCT = 31
|
||||
ITEM_USE_UNLOCK_FORGE = 32
|
||||
ITEM_USE_UNLOCK_COMBINE = 33
|
||||
ITEM_USE_UNLOCK_CODEX = 34
|
||||
ITEM_USE_CHEST_SELECT_ITEM = 35
|
||||
ITEM_USE_GAIN_RESIN_CARD_PRODUCT = 36
|
||||
ITEM_USE_ADD_RELIQUARY_EXP = 37
|
||||
ITEM_USE_UNLOCK_FURNITURE_FORMULA = 38
|
||||
ITEM_USE_UNLOCK_FURNITURE_SUITE = 39
|
||||
ITEM_USE_ADD_CHANNELLER_SLAB_BUFF = 40
|
||||
ITEM_USE_GAIN_COSTUME = 41
|
||||
ITEM_USE_ADD_TREASURE_MAP_BONUS_REGION_FRAGMENT = 42
|
||||
ITEM_USE_COMBINE_ITEM = 43
|
||||
ITEM_USE_UNLOCK_HOME_MODULE = 44
|
||||
ITEM_USE_UNLOCK_HOME_BGM = 45
|
||||
ITEM_USE_ADD_REGIONAL_PLAY_VAR = 46
|
||||
)
|
||||
+57
-1
@@ -4,6 +4,11 @@ import (
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
|
||||
type ItemUse struct {
|
||||
UseOption int32
|
||||
UseParam []string
|
||||
}
|
||||
|
||||
// ItemData 道具分类分表整合配置表
|
||||
type ItemData struct {
|
||||
// 公共表头字段
|
||||
@@ -12,9 +17,22 @@ type ItemData struct {
|
||||
Weight int32 `csv:"重量,omitempty"`
|
||||
RankLevel int32 `csv:"排序权重,omitempty"`
|
||||
GadgetId int32 `csv:"物件ID,omitempty"`
|
||||
|
||||
// 材料
|
||||
MaterialType int32 `csv:"材料类型,omitempty"`
|
||||
AutoUse int32 `csv:"获得即使用,omitempty"`
|
||||
Use1Option int32 `csv:"[使用]1操作,omitempty"`
|
||||
Use1Param1 string `csv:"[使用]1参数1,omitempty"`
|
||||
Use1Param2 string `csv:"[使用]1参数2,omitempty"`
|
||||
Use1Param3 string `csv:"[使用]1参数3,omitempty"`
|
||||
Use1Param4 string `csv:"[使用]1参数4,omitempty"`
|
||||
Use1Param5 string `csv:"[使用]1参数5,omitempty"`
|
||||
Use2Option int32 `csv:"[使用]2操作,omitempty"`
|
||||
Use2Param1 string `csv:"[使用]2参数1,omitempty"`
|
||||
Use2Param2 string `csv:"[使用]2参数2,omitempty"`
|
||||
|
||||
ItemUseList []*ItemUse
|
||||
|
||||
// 武器
|
||||
EquipType int32 `csv:"武器种类,omitempty"`
|
||||
EquipLevel int32 `csv:"武器阶数,omitempty"`
|
||||
@@ -24,7 +42,9 @@ type ItemData struct {
|
||||
EquipBaseExp int32 `csv:"武器初始经验,omitempty"`
|
||||
AwakenMaterial int32 `csv:"精炼道具,omitempty"`
|
||||
AwakenCoinCost IntArray `csv:"精炼摩拉消耗,omitempty"`
|
||||
SkillAffix []int32
|
||||
|
||||
SkillAffix []int32
|
||||
|
||||
// 圣遗物
|
||||
ReliquaryType int32 `csv:"圣遗物类别,omitempty"`
|
||||
MainPropDepotId int32 `csv:"主属性库ID,omitempty"`
|
||||
@@ -39,6 +59,42 @@ func (g *GameDataConfig) loadItemData() {
|
||||
itemDataList := make([]*ItemData, 0)
|
||||
readTable[ItemData](g.txtPrefix+fileName, &itemDataList)
|
||||
for _, itemData := range itemDataList {
|
||||
itemData.ItemUseList = make([]*ItemUse, 0)
|
||||
if itemData.Use1Option != 0 {
|
||||
useParam := make([]string, 0)
|
||||
if itemData.Use1Param1 != "" {
|
||||
useParam = append(useParam, itemData.Use1Param1)
|
||||
}
|
||||
if itemData.Use1Param2 != "" {
|
||||
useParam = append(useParam, itemData.Use1Param2)
|
||||
}
|
||||
if itemData.Use1Param3 != "" {
|
||||
useParam = append(useParam, itemData.Use1Param3)
|
||||
}
|
||||
if itemData.Use1Param4 != "" {
|
||||
useParam = append(useParam, itemData.Use1Param4)
|
||||
}
|
||||
if itemData.Use1Param5 != "" {
|
||||
useParam = append(useParam, itemData.Use1Param5)
|
||||
}
|
||||
itemData.ItemUseList = append(itemData.ItemUseList, &ItemUse{
|
||||
UseOption: itemData.Use1Option,
|
||||
UseParam: useParam,
|
||||
})
|
||||
}
|
||||
if itemData.Use2Option != 0 {
|
||||
useParam := make([]string, 0)
|
||||
if itemData.Use2Param1 != "" {
|
||||
useParam = append(useParam, itemData.Use2Param1)
|
||||
}
|
||||
if itemData.Use2Param2 != "" {
|
||||
useParam = append(useParam, itemData.Use2Param2)
|
||||
}
|
||||
itemData.ItemUseList = append(itemData.ItemUseList, &ItemUse{
|
||||
UseOption: itemData.Use2Option,
|
||||
UseParam: useParam,
|
||||
})
|
||||
}
|
||||
itemData.SkillAffix = make([]int32, 0)
|
||||
if itemData.SkillAffix1 != 0 {
|
||||
itemData.SkillAffix = append(itemData.SkillAffix, itemData.SkillAffix1)
|
||||
|
||||
+54
-2
@@ -4,10 +4,29 @@ import (
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
|
||||
type HpDrop struct {
|
||||
Id int32 // ID
|
||||
HpPercent int32 // 血量百分比
|
||||
}
|
||||
|
||||
// MonsterData 怪物配置表
|
||||
type MonsterData struct {
|
||||
MonsterId int32 `csv:"ID"`
|
||||
Name string `csv:"名称$text_name_Name,omitempty"`
|
||||
MonsterId int32 `csv:"ID"`
|
||||
Name string `csv:"名称$text_name_Name,omitempty"`
|
||||
HpBase float32 `csv:"基础生命值,omitempty"`
|
||||
AttackBase float32 `csv:"基础攻击力,omitempty"`
|
||||
DefenseBase float32 `csv:"基础防御力,omitempty"`
|
||||
Critical float32 `csv:"暴击率,omitempty"`
|
||||
CriticalHurt float32 `csv:"暴击伤害,omitempty"`
|
||||
Drop1Id int32 `csv:"[掉落]1ID,omitempty"`
|
||||
Drop1HpPercent int32 `csv:"[掉落]1血量百分比,omitempty"`
|
||||
Drop2Id int32 `csv:"[掉落]2ID,omitempty"`
|
||||
Drop2HpPercent int32 `csv:"[掉落]2血量百分比,omitempty"`
|
||||
Drop3Id int32 `csv:"[掉落]3ID,omitempty"`
|
||||
Drop3HpPercent int32 `csv:"[掉落]3血量百分比,omitempty"`
|
||||
KillDropId int32 `csv:"击杀掉落ID,omitempty"`
|
||||
|
||||
HpDropList []*HpDrop // 血量掉落列表
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadMonsterData() {
|
||||
@@ -15,6 +34,25 @@ func (g *GameDataConfig) loadMonsterData() {
|
||||
monsterDataList := make([]*MonsterData, 0)
|
||||
readTable[MonsterData](g.txtPrefix+"MonsterData.txt", &monsterDataList)
|
||||
for _, monsterData := range monsterDataList {
|
||||
monsterData.HpDropList = make([]*HpDrop, 0)
|
||||
if monsterData.Drop1Id != 0 {
|
||||
monsterData.HpDropList = append(monsterData.HpDropList, &HpDrop{
|
||||
Id: monsterData.Drop1Id,
|
||||
HpPercent: monsterData.Drop1HpPercent,
|
||||
})
|
||||
}
|
||||
if monsterData.Drop2Id != 0 {
|
||||
monsterData.HpDropList = append(monsterData.HpDropList, &HpDrop{
|
||||
Id: monsterData.Drop2Id,
|
||||
HpPercent: monsterData.Drop2HpPercent,
|
||||
})
|
||||
}
|
||||
if monsterData.Drop3Id != 0 {
|
||||
monsterData.HpDropList = append(monsterData.HpDropList, &HpDrop{
|
||||
Id: monsterData.Drop3Id,
|
||||
HpPercent: monsterData.Drop3HpPercent,
|
||||
})
|
||||
}
|
||||
g.MonsterDataMap[monsterData.MonsterId] = monsterData
|
||||
}
|
||||
logger.Info("MonsterData count: %v", len(g.MonsterDataMap))
|
||||
@@ -27,3 +65,17 @@ func GetMonsterDataById(monsterId int32) *MonsterData {
|
||||
func GetMonsterDataMap() map[int32]*MonsterData {
|
||||
return CONF.MonsterDataMap
|
||||
}
|
||||
|
||||
// TODO 成长属性要读表
|
||||
|
||||
func (m *MonsterData) GetBaseHpByLevel(level uint8) float32 {
|
||||
return m.HpBase * float32(level)
|
||||
}
|
||||
|
||||
func (m *MonsterData) GetBaseAttackByLevel(level uint8) float32 {
|
||||
return m.AttackBase * float32(level)
|
||||
}
|
||||
|
||||
func (m *MonsterData) GetBaseDefenseByLevel(level uint8) float32 {
|
||||
return m.DefenseBase * float32(level)
|
||||
}
|
||||
@@ -18,9 +18,11 @@ type QuestExec struct {
|
||||
|
||||
// QuestData 任务配置表
|
||||
type QuestData struct {
|
||||
QuestId int32 `csv:"子任务ID"`
|
||||
ParentQuestId int32 `csv:"父任务ID,omitempty"`
|
||||
Sequence int32 `csv:"序列,omitempty"`
|
||||
QuestId int32 `csv:"子任务ID"`
|
||||
ParentQuestId int32 `csv:"父任务ID,omitempty"`
|
||||
Sequence int32 `csv:"序列,omitempty"`
|
||||
ItemIdList IntArray `csv:"[任务道具]ID,omitempty"`
|
||||
ItemCountList IntArray `csv:"[任务道具]数量,omitempty"`
|
||||
// 领取条件
|
||||
AcceptCondCompose int32 `csv:"[领取条件]组合,omitempty"`
|
||||
AcceptCondType1 int32 `csv:"[领取条件]1类型,omitempty"`
|
||||
|
||||
@@ -53,12 +53,12 @@ func (g *GameDataConfig) loadSceneWeatherArea() {
|
||||
logger.Info("SceneWeatherArea count: %v", count)
|
||||
}
|
||||
|
||||
func GetSceneWeatherAreaMapBySceneIdAndWeatherAreaId(sceneId int32, WeatherAreaId int32) *SceneWeatherArea {
|
||||
func GetSceneWeatherAreaMapBySceneIdAndWeatherAreaId(sceneId int32, weatherAreaId int32) *SceneWeatherArea {
|
||||
value, exist := CONF.SceneWeatherAreaMap[sceneId]
|
||||
if !exist {
|
||||
return nil
|
||||
}
|
||||
return value[WeatherAreaId]
|
||||
return value[weatherAreaId]
|
||||
}
|
||||
|
||||
func GetSceneWeatherAreaMap() map[int32]map[int32]*SceneWeatherArea {
|
||||
|
||||
@@ -130,6 +130,9 @@ func (r *RouteManager) initRoute() {
|
||||
cmd.PlayerStartMatchReq: GAME.PlayerStartMatchReq,
|
||||
cmd.PlayerCancelMatchReq: GAME.PlayerCancelMatchReq,
|
||||
cmd.PlayerConfirmMatchReq: GAME.PlayerConfirmMatchReq,
|
||||
cmd.QuestCreateEntityReq: GAME.QuestCreateEntityReq,
|
||||
cmd.QuestDestroyEntityReq: GAME.QuestDestroyEntityReq,
|
||||
cmd.QuestDestroyNpcReq: GAME.QuestDestroyNpcReq,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,36 @@ func (s *Scene) CreateEntityWeapon(pos, rot *model.Vector) uint32 {
|
||||
return s.CreateEntity(entity)
|
||||
}
|
||||
|
||||
func (s *Scene) CreateEntityMonster(pos, rot *model.Vector, monsterId uint32, level uint8, fightProp map[uint32]float32, configId, groupId uint32) uint32 {
|
||||
func (s *Scene) CreateEntityMonster(pos, rot *model.Vector, monsterId uint32, level uint8, configId, groupId uint32) uint32 {
|
||||
fpm := map[uint32]float32{
|
||||
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(50.0),
|
||||
constant.FIGHT_PROP_CUR_HP: float32(50.0),
|
||||
constant.FIGHT_PROP_MAX_HP: float32(50.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),
|
||||
constant.FIGHT_PROP_ELEC_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_GRASS_SUB_HURT: float32(0.1),
|
||||
constant.FIGHT_PROP_WATER_SUB_HURT: float32(0.1),
|
||||
}
|
||||
monsterDataConfig := gdconf.GetMonsterDataById(int32(monsterId))
|
||||
if monsterDataConfig == nil {
|
||||
logger.Error("get monster data config is nil, monsterId: %v", monsterId)
|
||||
return 0
|
||||
}
|
||||
fpm[constant.FIGHT_PROP_BASE_ATTACK] = monsterDataConfig.GetBaseAttackByLevel(level)
|
||||
fpm[constant.FIGHT_PROP_CUR_ATTACK] = monsterDataConfig.GetBaseAttackByLevel(level)
|
||||
fpm[constant.FIGHT_PROP_BASE_DEFENSE] = monsterDataConfig.GetBaseDefenseByLevel(level)
|
||||
fpm[constant.FIGHT_PROP_CUR_DEFENSE] = monsterDataConfig.GetBaseDefenseByLevel(level)
|
||||
fpm[constant.FIGHT_PROP_BASE_HP] = monsterDataConfig.GetBaseHpByLevel(level)
|
||||
fpm[constant.FIGHT_PROP_CUR_HP] = monsterDataConfig.GetBaseHpByLevel(level)
|
||||
fpm[constant.FIGHT_PROP_MAX_HP] = monsterDataConfig.GetBaseHpByLevel(level)
|
||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_MONSTER)
|
||||
entity := &Entity{
|
||||
id: entityId,
|
||||
@@ -149,7 +178,7 @@ func (s *Scene) CreateEntityMonster(pos, rot *model.Vector, monsterId uint32, le
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
lastMoveSceneTimeMs: 0,
|
||||
lastMoveReliableSeq: 0,
|
||||
fightProp: fightProp,
|
||||
fightProp: fpm,
|
||||
entityType: constant.ENTITY_TYPE_MONSTER,
|
||||
level: level,
|
||||
monsterEntity: &MonsterEntity{
|
||||
|
||||
@@ -377,9 +377,8 @@ func (g *Game) AddPlayerAvatar(userId uint32, avatarId uint32) {
|
||||
}
|
||||
// 判断玩家是否已有该角色
|
||||
dbAvatar := player.GetDbAvatar()
|
||||
_, ok := dbAvatar.AvatarMap[avatarId]
|
||||
if ok {
|
||||
// TODO 如果已有转换命座材料
|
||||
_, exist := dbAvatar.AvatarMap[avatarId]
|
||||
if exist {
|
||||
return
|
||||
}
|
||||
dbAvatar.AddAvatar(player, avatarId)
|
||||
@@ -402,6 +401,13 @@ func (g *Game) AddPlayerAvatar(userId uint32, avatarId uint32) {
|
||||
IsInTeam: false,
|
||||
}
|
||||
g.SendMsg(cmd.AvatarAddNotify, userId, player.ClientSeq, avatarAddNotify)
|
||||
|
||||
dbTeam := player.GetDbTeam()
|
||||
if len(dbTeam.GetActiveTeam().GetAvatarIdList()) >= 4 {
|
||||
return
|
||||
}
|
||||
activeTeam := dbTeam.GetActiveTeam()
|
||||
g.ChangeTeam(player, uint32(dbTeam.GetActiveTeamId()), append(activeTeam.GetAvatarIdList(), avatarId), dbTeam.GetActiveAvatarId())
|
||||
}
|
||||
|
||||
// AddPlayerFlycloak 给予玩家风之翼
|
||||
|
||||
+17
-2
@@ -43,7 +43,7 @@ func (g *Game) SetOpenStateReq(player *model.Player, payloadMsg pb.Message) {
|
||||
g.SendError(cmd.SetOpenStateRsp, player, &proto.SetOpenStateRsp{})
|
||||
return
|
||||
}
|
||||
g.ChangePlayerOpenState(player, req.Key, req.Value)
|
||||
g.ChangePlayerOpenState(player.PlayerId, req.Key, req.Value)
|
||||
|
||||
g.SendMsg(cmd.SetOpenStateRsp, player.PlayerId, player.ClientSeq, &proto.SetOpenStateRsp{
|
||||
Key: req.Key,
|
||||
@@ -90,13 +90,28 @@ func (g *Game) HandlePlayerExpAdd(userId uint32) {
|
||||
))
|
||||
}
|
||||
|
||||
func (g *Game) ChangePlayerOpenState(player *model.Player, key uint32, value uint32) {
|
||||
func (g *Game) ChangePlayerOpenState(userId uint32, key uint32, value uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
player.OpenStateMap[key] = value
|
||||
g.SendMsg(cmd.OpenStateChangeNotify, player.PlayerId, player.ClientSeq, &proto.OpenStateChangeNotify{
|
||||
OpenStateMap: map[uint32]uint32{key: value},
|
||||
})
|
||||
}
|
||||
|
||||
func (g *Game) AddPlayerNameCard(userId uint32, nameCardId uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
dbSocial := player.GetDbSocial()
|
||||
dbSocial.UnlockNameCard(nameCardId)
|
||||
}
|
||||
|
||||
/************************************************** 打包封装 **************************************************/
|
||||
|
||||
func (g *Game) PacketPlayerDataNotify(player *model.Player) *proto.PlayerDataNotify {
|
||||
|
||||
@@ -198,6 +198,7 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
||||
}
|
||||
|
||||
fightProp := defEntity.GetFightProp()
|
||||
maxHp := fightProp[constant.FIGHT_PROP_MAX_HP]
|
||||
currHp := fightProp[constant.FIGHT_PROP_CUR_HP]
|
||||
if currHp == 0.0 {
|
||||
return
|
||||
@@ -240,6 +241,18 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
||||
}
|
||||
}
|
||||
case constant.ENTITY_TYPE_MONSTER:
|
||||
monsterDataConfig := gdconf.GetMonsterDataById(int32(defEntity.GetMonsterEntity().GetMonsterId()))
|
||||
if monsterDataConfig == nil {
|
||||
logger.Error("get monster data config is nil, monsterId: %v", defEntity.GetMonsterEntity().GetMonsterId())
|
||||
break
|
||||
}
|
||||
lastHpPercent := (currHp - deltaHp) / maxHp * 100.0
|
||||
currHpPercent := currHp / maxHp * 100.0
|
||||
for _, hpDrop := range monsterDataConfig.HpDropList {
|
||||
if hpDrop.HpPercent >= int32(currHpPercent) && hpDrop.HpPercent <= int32(lastHpPercent) {
|
||||
g.monsterDrop(player, MonsterDropTypeHp, hpDrop.Id, defEntity)
|
||||
}
|
||||
}
|
||||
if currHp == 0.0 {
|
||||
g.KillEntity(player, scene, defEntity.GetId(), proto.PlayerDieType_PLAYER_DIE_GM)
|
||||
}
|
||||
@@ -1068,6 +1081,9 @@ func (g *Game) handleGadgetEntityBeHitLow(player *model.Player, entity *Entity,
|
||||
} else if strings.Contains(gadgetDataConfig.ServerLuaScript, "SubfieldDrop_WoodenObject_Broken") {
|
||||
// 木箱破碎
|
||||
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_GM)
|
||||
} else if strings.Contains(gadgetDataConfig.ServerLuaScript, "Gear_MovingTarget") {
|
||||
g.ChangeGadgetState(player, entity.GetId(), constant.GADGET_STATE_ACTION01)
|
||||
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+127
-56
@@ -1,6 +1,8 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"hk4e/common/constant"
|
||||
"hk4e/gdconf"
|
||||
"hk4e/gs/model"
|
||||
@@ -17,60 +19,102 @@ import (
|
||||
func (g *Game) UseItemReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.UseItemReq)
|
||||
// 是否拥有物品
|
||||
item, ok := player.GameObjectGuidMap[req.Guid].(*model.Item)
|
||||
if !ok {
|
||||
item, exist := player.GameObjectGuidMap[req.Guid].(*model.Item)
|
||||
if !exist {
|
||||
logger.Error("item not exist, weaponGuid: %v", req.Guid)
|
||||
g.SendError(cmd.UseItemRsp, player, &proto.UseItemRsp{}, proto.Retcode_RET_ITEM_NOT_EXIST)
|
||||
return
|
||||
}
|
||||
// 获取物品配置表
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(item.ItemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("item data config is nil, itemId: %v", item.ItemId)
|
||||
g.SendError(cmd.UseItemRsp, player, &proto.UseItemRsp{})
|
||||
return
|
||||
}
|
||||
// 获取角色
|
||||
avatar, ok := player.GameObjectGuidMap[req.TargetGuid].(*model.Avatar)
|
||||
if !ok {
|
||||
logger.Error("avatar not exist, avatarGuid: %v", req.TargetGuid)
|
||||
g.SendError(cmd.UseItemRsp, player, &proto.UseItemRsp{})
|
||||
return
|
||||
}
|
||||
// 根据物品的材料类型做不同操作
|
||||
switch itemDataConfig.MaterialType {
|
||||
case constant.MATERIAL_TYPE_FOOD:
|
||||
// 复活
|
||||
g.RevivePlayerAvatar(player, avatar.AvatarId)
|
||||
case constant.MATERIAL_TYPE_NOTICE_ADD_HP:
|
||||
// 回血
|
||||
default:
|
||||
g.SendError(cmd.UseItemRsp, player, &proto.UseItemRsp{})
|
||||
return
|
||||
}
|
||||
// 消耗物品
|
||||
changeItemList := []*ChangeItem{
|
||||
{
|
||||
ItemId: item.ItemId,
|
||||
ChangeCount: 1,
|
||||
},
|
||||
}
|
||||
if !g.CostPlayerItem(player.PlayerId, changeItemList) {
|
||||
ok := g.CostPlayerItem(player.PlayerId, []*ChangeItem{{ItemId: item.ItemId, ChangeCount: req.Count}})
|
||||
if !ok {
|
||||
logger.Error("item count not enough, uid: %v", player.PlayerId)
|
||||
g.SendError(cmd.UseItemRsp, player, &proto.UseItemRsp{}, proto.Retcode_RET_ITEM_COUNT_NOT_ENOUGH)
|
||||
return
|
||||
}
|
||||
useItemRsp := &proto.UseItemRsp{
|
||||
|
||||
for count := uint32(0); count < req.Count; count++ {
|
||||
g.UseItem(player.PlayerId, item.ItemId, req.TargetGuid)
|
||||
}
|
||||
|
||||
rsp := &proto.UseItemRsp{
|
||||
Guid: req.Guid,
|
||||
TargetGuid: req.TargetGuid,
|
||||
ItemId: item.ItemId,
|
||||
OptionIdx: 0,
|
||||
OptionIdx: req.OptionIdx,
|
||||
}
|
||||
g.SendMsg(cmd.UseItemRsp, player.PlayerId, player.ClientSeq, useItemRsp)
|
||||
g.SendMsg(cmd.UseItemRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
}
|
||||
|
||||
/************************************************** 游戏功能 **************************************************/
|
||||
|
||||
func (g *Game) UseItem(userId uint32, itemId uint32, targetParam ...uint64) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("item data config is nil, itemId: %v", itemId)
|
||||
return
|
||||
}
|
||||
for _, itemUse := range itemDataConfig.ItemUseList {
|
||||
switch itemUse.UseOption {
|
||||
case constant.ITEM_USE_GAIN_AVATAR:
|
||||
if len(itemUse.UseParam) != 1 {
|
||||
continue
|
||||
}
|
||||
avatarId, err := strconv.Atoi(itemUse.UseParam[0])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
dbAvatar := player.GetDbAvatar()
|
||||
_, exist := dbAvatar.AvatarMap[uint32(avatarId)]
|
||||
if !exist {
|
||||
g.AddPlayerAvatar(userId, uint32(avatarId))
|
||||
} else {
|
||||
g.AddPlayerItem(userId, []*ChangeItem{{ItemId: itemId + 100, ChangeCount: 1}}, true, 0)
|
||||
}
|
||||
case constant.ITEM_USE_RELIVE_AVATAR:
|
||||
if len(targetParam) != 1 {
|
||||
continue
|
||||
}
|
||||
avatar, exist := player.GameObjectGuidMap[targetParam[0]].(*model.Avatar)
|
||||
if !exist {
|
||||
logger.Error("avatar not exist, avatarGuid: %v", targetParam[0])
|
||||
continue
|
||||
}
|
||||
g.RevivePlayerAvatar(player, avatar.AvatarId)
|
||||
case constant.ITEM_USE_ADD_SERVER_BUFF:
|
||||
// 草泥马回血要走ability
|
||||
case constant.ITEM_USE_GAIN_FLYCLOAK:
|
||||
if len(itemUse.UseParam) != 1 {
|
||||
continue
|
||||
}
|
||||
flyCloakId, err := strconv.Atoi(itemUse.UseParam[0])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
g.AddPlayerFlycloak(userId, uint32(flyCloakId))
|
||||
case constant.ITEM_USE_GAIN_NAME_CARD:
|
||||
if len(itemUse.UseParam) != 0 {
|
||||
continue
|
||||
}
|
||||
g.AddPlayerNameCard(userId, itemId)
|
||||
case constant.ITEM_USE_GAIN_COSTUME:
|
||||
if len(itemUse.UseParam) != 1 {
|
||||
continue
|
||||
}
|
||||
costumeId, err := strconv.Atoi(itemUse.UseParam[0])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
g.AddPlayerCostume(userId, uint32(costumeId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type ChangeItem struct {
|
||||
ItemId uint32
|
||||
ChangeCount uint32
|
||||
@@ -118,20 +162,31 @@ func (g *Game) AddPlayerItem(userId uint32, itemList []*ChangeItem, isHint bool,
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return false
|
||||
}
|
||||
itemMap := make(map[uint32]uint32)
|
||||
for _, changeItem := range itemList {
|
||||
itemMap[changeItem.ItemId] += changeItem.ChangeCount
|
||||
}
|
||||
dbItem := player.GetDbItem()
|
||||
propList := make([]uint32, 0)
|
||||
changeNtf := &proto.StoreItemChangeNotify{
|
||||
StoreType: proto.StoreType_STORE_PACK,
|
||||
ItemList: make([]*proto.Item, 0),
|
||||
}
|
||||
for _, changeItem := range itemList {
|
||||
prop, exist := constant.VIRTUAL_ITEM_PROP[changeItem.ItemId]
|
||||
for itemId, addCount := range itemMap {
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
continue
|
||||
}
|
||||
if itemDataConfig.AutoUse == 1 {
|
||||
continue
|
||||
}
|
||||
prop, exist := constant.VIRTUAL_ITEM_PROP[itemId]
|
||||
if exist {
|
||||
// 物品为虚拟物品 角色属性物品数量增加
|
||||
player.PropMap[prop] += changeItem.ChangeCount
|
||||
player.PropMap[prop] += addCount
|
||||
propList = append(propList, prop)
|
||||
// 特殊属性变化处理函数
|
||||
switch changeItem.ItemId {
|
||||
switch itemId {
|
||||
case constant.ITEM_ID_PLAYER_EXP:
|
||||
// 冒险阅历
|
||||
g.HandlePlayerExpAdd(userId)
|
||||
@@ -142,14 +197,14 @@ func (g *Game) AddPlayerItem(userId uint32, itemList []*ChangeItem, isHint bool,
|
||||
if dbItem.GetItemMapLen() > constant.STORE_PACK_LIMIT_MATERIAL+constant.STORE_PACK_LIMIT_FURNITURE {
|
||||
return false
|
||||
}
|
||||
dbItem.AddItem(player, changeItem.ItemId, changeItem.ChangeCount)
|
||||
dbItem.AddItem(player, itemId, addCount)
|
||||
}
|
||||
pbItem := &proto.Item{
|
||||
ItemId: changeItem.ItemId,
|
||||
Guid: dbItem.GetItemGuid(changeItem.ItemId),
|
||||
ItemId: itemId,
|
||||
Guid: dbItem.GetItemGuid(itemId),
|
||||
Detail: &proto.Item_Material{
|
||||
Material: &proto.Material{
|
||||
Count: dbItem.GetItemCount(changeItem.ItemId),
|
||||
Count: dbItem.GetItemCount(itemId),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -176,6 +231,18 @@ func (g *Game) AddPlayerItem(userId uint32, itemList []*ChangeItem, isHint bool,
|
||||
}
|
||||
g.SendMsg(cmd.ItemAddHintNotify, userId, player.ClientSeq, itemAddHintNotify)
|
||||
}
|
||||
for itemId, addCount := range itemMap {
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_OBTAIN_ITEM, "", int32(itemId))
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
continue
|
||||
}
|
||||
if itemDataConfig.AutoUse == 1 {
|
||||
for count := uint32(0); count < addCount; count++ {
|
||||
g.UseItem(userId, itemId)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -186,6 +253,10 @@ func (g *Game) CostPlayerItem(userId uint32, itemList []*ChangeItem) bool {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return false
|
||||
}
|
||||
itemMap := make(map[uint32]uint32)
|
||||
for _, changeItem := range itemList {
|
||||
itemMap[changeItem.ItemId] += changeItem.ChangeCount
|
||||
}
|
||||
dbItem := player.GetDbItem()
|
||||
propList := make([]uint32, 0)
|
||||
changeNtf := &proto.StoreItemChangeNotify{
|
||||
@@ -196,32 +267,32 @@ func (g *Game) CostPlayerItem(userId uint32, itemList []*ChangeItem) bool {
|
||||
StoreType: proto.StoreType_STORE_PACK,
|
||||
GuidList: make([]uint64, 0),
|
||||
}
|
||||
for _, changeItem := range itemList {
|
||||
for itemId, costCount := range itemMap {
|
||||
// 检查剩余道具数量
|
||||
count := g.GetPlayerItemCount(player.PlayerId, changeItem.ItemId)
|
||||
if count < changeItem.ChangeCount {
|
||||
count := g.GetPlayerItemCount(player.PlayerId, itemId)
|
||||
if count < costCount {
|
||||
return false
|
||||
}
|
||||
prop, exist := constant.VIRTUAL_ITEM_PROP[changeItem.ItemId]
|
||||
prop, exist := constant.VIRTUAL_ITEM_PROP[itemId]
|
||||
if exist {
|
||||
// 物品为虚拟物品 角色属性物品数量减少
|
||||
player.PropMap[prop] -= changeItem.ChangeCount
|
||||
player.PropMap[prop] -= costCount
|
||||
propList = append(propList, prop)
|
||||
// 特殊属性变化处理函数
|
||||
switch changeItem.ItemId {
|
||||
switch itemId {
|
||||
case constant.ITEM_ID_PLAYER_EXP:
|
||||
// 冒险阅历应该也没人会去扣吧?
|
||||
g.HandlePlayerExpAdd(userId)
|
||||
}
|
||||
} else {
|
||||
// 物品为普通物品 直接扣除
|
||||
dbItem.CostItem(player, changeItem.ItemId, changeItem.ChangeCount)
|
||||
dbItem.CostItem(player, itemId, costCount)
|
||||
}
|
||||
count = g.GetPlayerItemCount(player.PlayerId, changeItem.ItemId)
|
||||
count = g.GetPlayerItemCount(player.PlayerId, itemId)
|
||||
if count > 0 {
|
||||
pbItem := &proto.Item{
|
||||
ItemId: changeItem.ItemId,
|
||||
Guid: dbItem.GetItemGuid(changeItem.ItemId),
|
||||
ItemId: itemId,
|
||||
Guid: dbItem.GetItemGuid(itemId),
|
||||
Detail: &proto.Item_Material{
|
||||
Material: &proto.Material{
|
||||
Count: count,
|
||||
@@ -230,7 +301,7 @@ func (g *Game) CostPlayerItem(userId uint32, itemList []*ChangeItem) bool {
|
||||
}
|
||||
changeNtf.ItemList = append(changeNtf.ItemList, pbItem)
|
||||
} else if count == 0 {
|
||||
delNtf.GuidList = append(delNtf.GuidList, dbItem.GetItemGuid(changeItem.ItemId))
|
||||
delNtf.GuidList = append(delNtf.GuidList, dbItem.GetItemGuid(itemId))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+138
-6
@@ -30,6 +30,62 @@ func (g *Game) AddQuestContentProgressReq(player *model.Player, payloadMsg pb.Me
|
||||
g.AcceptQuest(player, true)
|
||||
}
|
||||
|
||||
func (g *Game) QuestCreateEntityReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.QuestCreateEntityReq)
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(req.Entity.GetItemId()))
|
||||
if itemDataConfig == nil {
|
||||
g.SendError(cmd.QuestCreateEntityRsp, player, &proto.QuestCreateEntityRsp{})
|
||||
return
|
||||
}
|
||||
pos := &model.Vector{X: float64(req.Entity.Pos.X), Y: float64(req.Entity.Pos.Y), Z: float64(req.Entity.Pos.Z)}
|
||||
entityId := g.CreateDropGadget(player, pos, uint32(itemDataConfig.GadgetId), req.Entity.GetItemId(), 1)
|
||||
if entityId == 0 {
|
||||
g.SendError(cmd.QuestCreateEntityRsp, player, &proto.QuestCreateEntityRsp{})
|
||||
return
|
||||
}
|
||||
rsp := &proto.QuestCreateEntityRsp{
|
||||
QuestId: req.QuestId,
|
||||
EntityId: entityId,
|
||||
Entity: req.Entity,
|
||||
ParentQuestId: req.ParentQuestId,
|
||||
IsRewind: req.IsRewind,
|
||||
}
|
||||
g.SendMsg(cmd.QuestCreateEntityRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
}
|
||||
|
||||
func (g *Game) QuestDestroyEntityReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.QuestDestroyEntityReq)
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
g.SendError(cmd.QuestDestroyEntityRsp, player, &proto.QuestDestroyEntityRsp{})
|
||||
return
|
||||
}
|
||||
scene := world.GetSceneById(req.SceneId)
|
||||
entity := scene.GetEntity(req.EntityId)
|
||||
if entity == nil {
|
||||
g.SendError(cmd.QuestDestroyEntityRsp, player, &proto.QuestDestroyEntityRsp{})
|
||||
return
|
||||
}
|
||||
scene.DestroyEntity(req.EntityId)
|
||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{req.EntityId})
|
||||
rsp := &proto.QuestDestroyEntityRsp{
|
||||
QuestId: req.QuestId,
|
||||
SceneId: req.SceneId,
|
||||
EntityId: req.EntityId,
|
||||
}
|
||||
g.SendMsg(cmd.QuestDestroyEntityRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
}
|
||||
|
||||
func (g *Game) QuestDestroyNpcReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.QuestDestroyNpcReq)
|
||||
logger.Debug("quest destroy npc, npcId: %v, parentQuestId: %v, uid: %v", req.NpcId, req.ParentQuestId, player.PlayerId)
|
||||
rsp := &proto.QuestDestroyNpcRsp{
|
||||
NpcId: req.NpcId,
|
||||
ParentQuestId: req.ParentQuestId,
|
||||
}
|
||||
g.SendMsg(cmd.QuestDestroyNpcRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
}
|
||||
|
||||
/************************************************** 游戏功能 **************************************************/
|
||||
|
||||
// AcceptQuest 接取当前条件下能接取到的全部任务
|
||||
@@ -195,7 +251,7 @@ func (g *Game) QuestExec(player *model.Player, questId uint32, questExecType int
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
g.ChangePlayerOpenState(player, uint32(key), uint32(value))
|
||||
g.ChangePlayerOpenState(player.PlayerId, uint32(key), uint32(value))
|
||||
case constant.QUEST_EXEC_TYPE_UNLOCK_POINT:
|
||||
if len(questExec.Param) != 2 {
|
||||
continue
|
||||
@@ -219,6 +275,65 @@ func (g *Game) QuestExec(player *model.Player, questId uint32, questExecType int
|
||||
continue
|
||||
}
|
||||
g.ChangePlayerAvatarElementType(player, elementType)
|
||||
case constant.QUEST_EXEC_TYPE_SET_IS_FLYABLE:
|
||||
if len(questExec.Param) != 1 {
|
||||
continue
|
||||
}
|
||||
value, err := strconv.Atoi(questExec.Param[0])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
player.PropMap[constant.PLAYER_PROP_IS_FLYABLE] = uint32(value)
|
||||
g.SendMsg(cmd.PlayerPropNotify, player.PlayerId, player.ClientSeq, g.PacketPlayerPropNotify(player, constant.PLAYER_PROP_IS_FLYABLE))
|
||||
case constant.QUEST_EXEC_TYPE_SET_IS_WEATHER_LOCKED:
|
||||
if len(questExec.Param) != 1 {
|
||||
continue
|
||||
}
|
||||
value, err := strconv.Atoi(questExec.Param[0])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
player.PropMap[constant.PLAYER_PROP_IS_WEATHER_LOCKED] = uint32(value)
|
||||
g.SendMsg(cmd.PlayerPropNotify, player.PlayerId, player.ClientSeq, g.PacketPlayerPropNotify(player, constant.PLAYER_PROP_IS_WEATHER_LOCKED))
|
||||
case constant.QUEST_EXEC_TYPE_SET_IS_GAME_TIME_LOCKED:
|
||||
if len(questExec.Param) != 1 {
|
||||
continue
|
||||
}
|
||||
value, err := strconv.Atoi(questExec.Param[0])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
player.PropMap[constant.PLAYER_PROP_IS_GAME_TIME_LOCKED] = uint32(value)
|
||||
g.SendMsg(cmd.PlayerPropNotify, player.PlayerId, player.ClientSeq, g.PacketPlayerPropNotify(player, constant.PLAYER_PROP_IS_GAME_TIME_LOCKED))
|
||||
case constant.QUEST_EXEC_TYPE_SET_IS_TRANSFERABLE:
|
||||
if len(questExec.Param) != 1 {
|
||||
continue
|
||||
}
|
||||
value, err := strconv.Atoi(questExec.Param[0])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
player.PropMap[constant.PLAYER_PROP_IS_TRANSFERABLE] = uint32(value)
|
||||
g.SendMsg(cmd.PlayerPropNotify, player.PlayerId, player.ClientSeq, g.PacketPlayerPropNotify(player, constant.PLAYER_PROP_IS_TRANSFERABLE))
|
||||
case constant.QUEST_EXEC_TYPE_SET_GAME_TIME:
|
||||
if len(questExec.Param) != 1 {
|
||||
continue
|
||||
}
|
||||
hour, err := strconv.Atoi(questExec.Param[0])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||
continue
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
if scene == nil {
|
||||
logger.Error("scene is nil, sceneId: %v, uid: %v", player.SceneId, player.PlayerId)
|
||||
continue
|
||||
}
|
||||
g.ChangeGameTime(scene, uint32(hour*60))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,15 +356,13 @@ func (g *Game) TriggerQuest(player *model.Player, cond int32, complexParam strin
|
||||
dbQuest := player.GetDbQuest()
|
||||
updateQuestIdList := make([]uint32, 0)
|
||||
for _, quest := range dbQuest.GetQuestMap() {
|
||||
if quest.State == constant.QUEST_STATE_FINISHED {
|
||||
continue
|
||||
}
|
||||
questDataConfig := gdconf.GetQuestDataById(int32(quest.QuestId))
|
||||
if questDataConfig == nil {
|
||||
continue
|
||||
}
|
||||
// TODO 实在不知道客户端要在怎样的情况下 才会发长按10006这个技能 这里先临时改表解决了
|
||||
// 是走ability体系计算出来的 操了
|
||||
if questDataConfig.QuestId == 35303 {
|
||||
questDataConfig.FinishCondList[0].Param[0] = 10067
|
||||
}
|
||||
for _, questCond := range questDataConfig.FinishCondList {
|
||||
if questCond.Type != cond {
|
||||
continue
|
||||
@@ -294,6 +407,11 @@ func (g *Game) TriggerQuest(player *model.Player, cond int32, complexParam strin
|
||||
dbQuest.ForceFinishQuest(quest.QuestId)
|
||||
updateQuestIdList = append(updateQuestIdList, quest.QuestId)
|
||||
case constant.QUEST_FINISH_COND_TYPE_SKILL:
|
||||
// TODO 实在不知道客户端要在怎样的情况下 才会发长按10006这个技能 这里先临时改表解决了
|
||||
// 是走ability体系计算出来的 操了
|
||||
if quest.QuestId == 35303 {
|
||||
questCond.Param[0] = 10067
|
||||
}
|
||||
// 使用技能 参数1:技能id
|
||||
ok := matchParamEqual(questCond.Param, param, 1)
|
||||
if !ok {
|
||||
@@ -301,9 +419,23 @@ func (g *Game) TriggerQuest(player *model.Player, cond int32, complexParam strin
|
||||
}
|
||||
dbQuest.ForceFinishQuest(quest.QuestId)
|
||||
updateQuestIdList = append(updateQuestIdList, quest.QuestId)
|
||||
case constant.QUEST_FINISH_COND_TYPE_OBTAIN_ITEM:
|
||||
// 获得道具 参数1:道具id
|
||||
ok := matchParamEqual(questCond.Param, param, 1)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
dbQuest.ForceFinishQuest(quest.QuestId)
|
||||
updateQuestIdList = append(updateQuestIdList, quest.QuestId)
|
||||
}
|
||||
if quest.State == constant.QUEST_STATE_FINISHED {
|
||||
g.QuestExec(player, quest.QuestId, QuestExecTypeFinish)
|
||||
if len(questDataConfig.ItemIdList) != 0 {
|
||||
for index, itemId := range questDataConfig.ItemIdList {
|
||||
questItem := []*ChangeItem{{ItemId: uint32(itemId), ChangeCount: uint32(questDataConfig.ItemCountList[index])}}
|
||||
g.AddPlayerItem(player.PlayerId, questItem, true, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-31
@@ -244,8 +244,10 @@ func (g *Game) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) {
|
||||
|
||||
// 设置玩家天气
|
||||
weatherAreaId := g.GetPlayerInWeatherAreaId(player, player.GetPos())
|
||||
climateType := GAME.GetWeatherAreaClimate(weatherAreaId)
|
||||
GAME.SetPlayerWeather(player, weatherAreaId, climateType)
|
||||
if weatherAreaId != 0 {
|
||||
climateType := GAME.GetWeatherAreaClimate(weatherAreaId)
|
||||
GAME.SetPlayerWeather(player, weatherAreaId, climateType)
|
||||
}
|
||||
}
|
||||
|
||||
g.UpdateWorldScenePlayerInfo(player, world)
|
||||
@@ -711,7 +713,7 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d
|
||||
switch entity.GetEntityType() {
|
||||
case constant.ENTITY_TYPE_MONSTER:
|
||||
// 随机掉落
|
||||
g.monsterDrop(player, entity)
|
||||
g.monsterDrop(player, MonsterDropTypeKill, 0, entity)
|
||||
// 怪物死亡触发器检测
|
||||
g.MonsterDieTriggerCheck(player, group)
|
||||
case constant.ENTITY_TYPE_GADGET:
|
||||
@@ -1011,7 +1013,7 @@ func (g *Game) CreateConfigEntity(scene *Scene, groupId uint32, entityConfig any
|
||||
return scene.CreateEntityMonster(
|
||||
&model.Vector{X: float64(monster.Pos.X), Y: float64(monster.Pos.Y), Z: float64(monster.Pos.Z)},
|
||||
&model.Vector{X: float64(monster.Rot.X), Y: float64(monster.Rot.Y), Z: float64(monster.Rot.Z)},
|
||||
uint32(monster.MonsterId), uint8(monster.Level), getTempFightPropMap(), uint32(monster.ConfigId), groupId,
|
||||
uint32(monster.MonsterId), uint8(monster.Level), uint32(monster.ConfigId), groupId,
|
||||
)
|
||||
case *gdconf.Npc:
|
||||
npc := entityConfig.(*gdconf.Npc)
|
||||
@@ -1061,28 +1063,6 @@ func (g *Game) CreateConfigEntity(scene *Scene, groupId uint32, entityConfig any
|
||||
return 0
|
||||
}
|
||||
|
||||
// TODO 临时写死
|
||||
func getTempFightPropMap() map[uint32]float32 {
|
||||
fpm := map[uint32]float32{
|
||||
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(50.0),
|
||||
constant.FIGHT_PROP_CUR_HP: float32(50.0),
|
||||
constant.FIGHT_PROP_MAX_HP: float32(50.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),
|
||||
constant.FIGHT_PROP_ELEC_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_GRASS_SUB_HURT: float32(0.1),
|
||||
constant.FIGHT_PROP_WATER_SUB_HURT: float32(0.1),
|
||||
}
|
||||
return fpm
|
||||
}
|
||||
|
||||
// SceneGroupCreateEntity 创建场景组配置物件实体
|
||||
func (g *Game) SceneGroupCreateEntity(player *model.Player, groupId uint32, configId uint32, entityType uint8) {
|
||||
// 添加到初始小组
|
||||
@@ -1168,7 +1148,7 @@ func (g *Game) CreateMonster(player *model.Player, pos *model.Vector, monsterId
|
||||
rot.Y = random.GetRandomFloat64(0.0, 360.0)
|
||||
entityId := scene.CreateEntityMonster(
|
||||
pos, rot,
|
||||
monsterId, uint8(random.GetRandomInt32(1, 90)), getTempFightPropMap(),
|
||||
monsterId, uint8(random.GetRandomInt32(1, 90)),
|
||||
0, 0,
|
||||
)
|
||||
entity := scene.GetEntity(entityId)
|
||||
@@ -1216,12 +1196,13 @@ func (g *Game) CreateGadget(player *model.Player, pos *model.Vector, gadgetId ui
|
||||
}
|
||||
|
||||
// CreateDropGadget 创建掉落物的物件实体
|
||||
func (g *Game) CreateDropGadget(player *model.Player, pos *model.Vector, gadgetId, itemId, count uint32) {
|
||||
g.CreateGadget(player, pos, gadgetId, &GadgetNormalEntity{
|
||||
func (g *Game) CreateDropGadget(player *model.Player, pos *model.Vector, gadgetId, itemId, count uint32) uint32 {
|
||||
entityId := g.CreateGadget(player, pos, gadgetId, &GadgetNormalEntity{
|
||||
isDrop: true,
|
||||
itemId: itemId,
|
||||
count: count,
|
||||
})
|
||||
return entityId
|
||||
}
|
||||
|
||||
// GetPosIsInWeatherArea 获取坐标是否在指定的天气区域
|
||||
@@ -1229,7 +1210,6 @@ func (g *Game) GetPosIsInWeatherArea(posX, posZ float64, sceneId, weatherAreaId
|
||||
// 获取场景天气区域配置表
|
||||
weatherAreaConfig := gdconf.GetSceneWeatherAreaMapBySceneIdAndWeatherAreaId(int32(sceneId), int32(weatherAreaId))
|
||||
if weatherAreaConfig == nil {
|
||||
logger.Error("scene weather area config not exist, sceneId: %v, weatherAreaId: %v", sceneId, weatherAreaId)
|
||||
return false
|
||||
}
|
||||
// 寻找玩家所在范围内的天气区域
|
||||
@@ -1253,7 +1233,6 @@ func (g *Game) GetPlayerInWeatherAreaId(player *model.Player, newPos *model.Vect
|
||||
// 获取场景天气区域配置表
|
||||
sceneWeatherAreaMap := gdconf.GetSceneWeatherAreaMap()[int32(player.SceneId)]
|
||||
if sceneWeatherAreaMap == nil {
|
||||
logger.Error("scene weather area map not exist, sceneId: %v", player.SceneId)
|
||||
return 0
|
||||
}
|
||||
// 寻找玩家所在范围内的天气区域
|
||||
@@ -1293,6 +1272,9 @@ func (g *Game) SceneWeatherAreaCheck(player *model.Player, oldPos *model.Vector,
|
||||
}
|
||||
// 获取当前所在的天气区域
|
||||
weatherAreaId := g.GetPlayerInWeatherAreaId(player, newPos)
|
||||
if weatherAreaId == 0 {
|
||||
return
|
||||
}
|
||||
// 判断天气区域是否变更
|
||||
if player.WeatherInfo.WeatherAreaId == weatherAreaId {
|
||||
return
|
||||
|
||||
+66
-61
@@ -16,97 +16,60 @@ import (
|
||||
|
||||
func (g *Game) ChangeAvatarReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.ChangeAvatarReq)
|
||||
targetAvatarGuid := req.Guid
|
||||
targetAvatar, ok := player.GameObjectGuidMap[targetAvatarGuid].(*model.Avatar)
|
||||
targetAvatar, ok := player.GameObjectGuidMap[req.Guid].(*model.Avatar)
|
||||
if !ok {
|
||||
logger.Error("target avatar error, avatarGuid: %v", targetAvatarGuid)
|
||||
logger.Error("target avatar error, avatarGuid: %v", req.Guid)
|
||||
g.SendError(cmd.ChangeAvatarRsp, player, &proto.ChangeAvatarRsp{})
|
||||
return
|
||||
}
|
||||
|
||||
g.ChangeAvatar(player, targetAvatar.AvatarId)
|
||||
|
||||
changeAvatarRsp := &proto.ChangeAvatarRsp{
|
||||
CurGuid: targetAvatarGuid,
|
||||
rsp := &proto.ChangeAvatarRsp{
|
||||
CurGuid: req.Guid,
|
||||
}
|
||||
g.SendMsg(cmd.ChangeAvatarRsp, player.PlayerId, player.ClientSeq, changeAvatarRsp)
|
||||
g.SendMsg(cmd.ChangeAvatarRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
}
|
||||
|
||||
func (g *Game) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.SetUpAvatarTeamReq)
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
if world.IsMultiplayerWorld() {
|
||||
g.SendError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
|
||||
return
|
||||
}
|
||||
teamId := req.TeamId
|
||||
avatarGuidList := req.AvatarTeamGuidList
|
||||
currAvatarGuid := req.CurAvatarGuid
|
||||
|
||||
if teamId <= 0 || teamId >= 5 {
|
||||
g.SendError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
|
||||
return
|
||||
}
|
||||
avatarGuidList := req.AvatarTeamGuidList
|
||||
dbTeam := player.GetDbTeam()
|
||||
selfTeam := teamId == uint32(dbTeam.GetActiveTeamId())
|
||||
if (selfTeam && len(avatarGuidList) == 0) || len(avatarGuidList) > 4 {
|
||||
if (teamId == uint32(dbTeam.GetActiveTeamId()) && len(avatarGuidList) == 0) || len(avatarGuidList) > 4 {
|
||||
g.SendError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
|
||||
return
|
||||
}
|
||||
avatarIdList := make([]uint32, 0)
|
||||
dbAvatar := player.GetDbAvatar()
|
||||
for _, avatarGuid := range avatarGuidList {
|
||||
for avatarId, avatar := range dbAvatar.AvatarMap {
|
||||
if avatarGuid == avatar.Guid {
|
||||
avatarIdList = append(avatarIdList, avatarId)
|
||||
}
|
||||
}
|
||||
}
|
||||
dbTeam.GetTeamByIndex(uint8(teamId - 1)).SetAvatarIdList(avatarIdList)
|
||||
|
||||
avatarTeamUpdateNotify := &proto.AvatarTeamUpdateNotify{
|
||||
AvatarTeamMap: make(map[uint32]*proto.AvatarTeam),
|
||||
}
|
||||
for teamIndex, team := range dbTeam.TeamList {
|
||||
avatarTeam := &proto.AvatarTeam{
|
||||
TeamName: team.Name,
|
||||
AvatarGuidList: make([]uint64, 0),
|
||||
}
|
||||
for _, avatarId := range team.GetAvatarIdList() {
|
||||
avatarTeam.AvatarGuidList = append(avatarTeam.AvatarGuidList, dbAvatar.AvatarMap[avatarId].Guid)
|
||||
}
|
||||
avatarTeamUpdateNotify.AvatarTeamMap[uint32(teamIndex)+1] = avatarTeam
|
||||
}
|
||||
g.SendMsg(cmd.AvatarTeamUpdateNotify, player.PlayerId, player.ClientSeq, avatarTeamUpdateNotify)
|
||||
|
||||
if selfTeam {
|
||||
// player.TeamConfig.UpdateTeam()
|
||||
world.SetPlayerLocalTeam(player, avatarIdList)
|
||||
world.UpdateMultiplayerTeam()
|
||||
world.UpdatePlayerWorldAvatar(player)
|
||||
|
||||
currAvatarGuid := req.CurAvatarGuid
|
||||
currAvatar, ok := player.GameObjectGuidMap[currAvatarGuid].(*model.Avatar)
|
||||
avatar, ok := player.GameObjectGuidMap[avatarGuid].(*model.Avatar)
|
||||
if !ok {
|
||||
logger.Error("avatar error, avatarGuid: %v", currAvatarGuid)
|
||||
g.SendError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
|
||||
return
|
||||
}
|
||||
currAvatarId := currAvatar.AvatarId
|
||||
currAvatarIndex := world.GetPlayerAvatarIndexByAvatarId(player, currAvatarId)
|
||||
dbTeam.CurrAvatarIndex = uint8(currAvatarIndex)
|
||||
world.SetPlayerAvatarIndex(player, currAvatarIndex)
|
||||
|
||||
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world, player)
|
||||
g.SendMsg(cmd.SceneTeamUpdateNotify, player.PlayerId, player.ClientSeq, sceneTeamUpdateNotify)
|
||||
avatarIdList = append(avatarIdList, avatar.AvatarId)
|
||||
}
|
||||
currAvatar, ok := player.GameObjectGuidMap[currAvatarGuid].(*model.Avatar)
|
||||
if !ok {
|
||||
logger.Error("get curr avatar error, avatarGuid: %v", currAvatarGuid)
|
||||
g.SendError(cmd.SetUpAvatarTeamRsp, player, &proto.SetUpAvatarTeamRsp{})
|
||||
return
|
||||
}
|
||||
|
||||
setUpAvatarTeamRsp := &proto.SetUpAvatarTeamRsp{
|
||||
g.ChangeTeam(player, teamId, avatarIdList, currAvatar.AvatarId)
|
||||
|
||||
rsp := &proto.SetUpAvatarTeamRsp{
|
||||
TeamId: req.TeamId,
|
||||
CurAvatarGuid: req.CurAvatarGuid,
|
||||
AvatarTeamGuidList: req.AvatarTeamGuidList,
|
||||
}
|
||||
g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerId, player.ClientSeq, setUpAvatarTeamRsp)
|
||||
g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
}
|
||||
|
||||
func (g *Game) ChooseCurAvatarTeamReq(player *model.Player, payloadMsg pb.Message) {
|
||||
@@ -128,7 +91,6 @@ func (g *Game) ChooseCurAvatarTeamReq(player *model.Player, payloadMsg pb.Messag
|
||||
}
|
||||
dbTeam.CurrTeamIndex = uint8(teamId) - 1
|
||||
dbTeam.CurrAvatarIndex = 0
|
||||
// player.TeamConfig.UpdateTeam()
|
||||
world.SetPlayerAvatarIndex(player, 0)
|
||||
world.SetPlayerLocalTeam(player, team.GetAvatarIdList())
|
||||
world.UpdateMultiplayerTeam()
|
||||
@@ -318,6 +280,49 @@ func (g *Game) ChangeAvatar(player *model.Player, targetAvatarId uint32) {
|
||||
g.SendToSceneA(scene, cmd.SceneEntityAppearNotify, player.ClientSeq, sceneEntityAppearNotify, 0)
|
||||
}
|
||||
|
||||
func (g *Game) ChangeTeam(player *model.Player, teamId uint32, avatarIdList []uint32, currAvatarId uint32) {
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
if world.IsMultiplayerWorld() {
|
||||
return
|
||||
}
|
||||
|
||||
dbTeam := player.GetDbTeam()
|
||||
dbTeam.GetTeamByIndex(uint8(teamId - 1)).SetAvatarIdList(avatarIdList)
|
||||
|
||||
avatarTeamUpdateNotify := &proto.AvatarTeamUpdateNotify{
|
||||
AvatarTeamMap: make(map[uint32]*proto.AvatarTeam),
|
||||
}
|
||||
dbAvatar := player.GetDbAvatar()
|
||||
for teamIndex, team := range dbTeam.TeamList {
|
||||
avatarTeam := &proto.AvatarTeam{
|
||||
TeamName: team.Name,
|
||||
AvatarGuidList: make([]uint64, 0),
|
||||
}
|
||||
for _, avatarId := range team.GetAvatarIdList() {
|
||||
avatarTeam.AvatarGuidList = append(avatarTeam.AvatarGuidList, dbAvatar.AvatarMap[avatarId].Guid)
|
||||
}
|
||||
avatarTeamUpdateNotify.AvatarTeamMap[uint32(teamIndex)+1] = avatarTeam
|
||||
}
|
||||
g.SendMsg(cmd.AvatarTeamUpdateNotify, player.PlayerId, player.ClientSeq, avatarTeamUpdateNotify)
|
||||
|
||||
if teamId == uint32(dbTeam.GetActiveTeamId()) {
|
||||
world.SetPlayerLocalTeam(player, avatarIdList)
|
||||
world.UpdateMultiplayerTeam()
|
||||
world.UpdatePlayerWorldAvatar(player)
|
||||
|
||||
currAvatarIndex := world.GetPlayerAvatarIndexByAvatarId(player, currAvatarId)
|
||||
dbTeam.CurrAvatarIndex = uint8(currAvatarIndex)
|
||||
world.SetPlayerAvatarIndex(player, currAvatarIndex)
|
||||
|
||||
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world, player)
|
||||
g.SendMsg(cmd.SceneTeamUpdateNotify, player.PlayerId, player.ClientSeq, sceneTeamUpdateNotify)
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************** 打包封装 **************************************************/
|
||||
|
||||
func (g *Game) PacketSceneTeamUpdateNotify(world *World, player *model.Player) *proto.SceneTeamUpdateNotify {
|
||||
|
||||
+59
-30
@@ -546,35 +546,55 @@ func (g *Game) ChangeGameTime(scene *Scene, gameTime uint32) {
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Game) monsterDrop(player *model.Player, entity *Entity) {
|
||||
sceneGroupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
||||
if sceneGroupConfig == nil {
|
||||
logger.Error("get scene group config is nil, groupId: %v, uid: %v", entity.GetGroupId(), player.PlayerId)
|
||||
return
|
||||
}
|
||||
monsterConfig := sceneGroupConfig.MonsterMap[int32(entity.GetConfigId())]
|
||||
dropTag := ""
|
||||
if monsterConfig.DropTag != "" {
|
||||
dropTag = monsterConfig.DropTag
|
||||
} else {
|
||||
monsterDataConfig := gdconf.GetMonsterDataById(monsterConfig.MonsterId)
|
||||
if monsterDataConfig == nil {
|
||||
logger.Error("get monster data config is nil, monsterId: %v, uid: %v", monsterConfig.MonsterId, player.PlayerId)
|
||||
const (
|
||||
MonsterDropTypeHp = iota
|
||||
MonsterDropTypeKill
|
||||
)
|
||||
|
||||
func (g *Game) monsterDrop(player *model.Player, monsterDropType int, hpDropId int32, entity *Entity) {
|
||||
dropId := int32(0)
|
||||
dropCount := int32(0)
|
||||
switch monsterDropType {
|
||||
case MonsterDropTypeHp:
|
||||
dropId = hpDropId
|
||||
dropCount = 1
|
||||
case MonsterDropTypeKill:
|
||||
sceneGroupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
||||
if sceneGroupConfig == nil {
|
||||
logger.Error("get scene group config is nil, groupId: %v, uid: %v", entity.GetGroupId(), player.PlayerId)
|
||||
return
|
||||
}
|
||||
dropTag = gdconf.GetDropModelByMonsterModel(monsterDataConfig.Name)
|
||||
monsterConfig := sceneGroupConfig.MonsterMap[int32(entity.GetConfigId())]
|
||||
if monsterConfig.DropId != 0 {
|
||||
dropId = monsterConfig.DropId
|
||||
dropCount = 1
|
||||
} else {
|
||||
dropTag := ""
|
||||
if monsterConfig.DropTag != "" {
|
||||
dropTag = monsterConfig.DropTag
|
||||
} else {
|
||||
monsterDataConfig := gdconf.GetMonsterDataById(monsterConfig.MonsterId)
|
||||
if monsterDataConfig == nil {
|
||||
logger.Error("get monster data config is nil, monsterId: %v, uid: %v", monsterConfig.MonsterId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
dropTag = gdconf.GetDropModelByMonsterModel(monsterDataConfig.Name)
|
||||
}
|
||||
monsterDropDataConfig := gdconf.GetMonsterDropDataByDropTagAndLevel(dropTag, monsterConfig.Level)
|
||||
if monsterDropDataConfig == nil {
|
||||
logger.Error("get monster drop data config is nil, monsterConfig: %+v, uid: %v", monsterConfig, player.PlayerId)
|
||||
return
|
||||
}
|
||||
dropId = monsterDropDataConfig.DropId
|
||||
dropCount = monsterDropDataConfig.DropCount
|
||||
}
|
||||
}
|
||||
monsterDropDataConfig := gdconf.GetMonsterDropDataByDropTagAndLevel(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)
|
||||
dropDataConfig := gdconf.GetDropDataById(dropId)
|
||||
if dropDataConfig == nil {
|
||||
logger.Error("get drop data config is nil, dropId: %v, uid: %v", monsterDropDataConfig.DropId, player.PlayerId)
|
||||
logger.Error("get drop data config is nil, dropId: %v, uid: %v", dropId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
totalItemMap := g.doRandDropFullTimes(dropDataConfig, int(monsterDropDataConfig.DropCount))
|
||||
totalItemMap := g.doRandDropFullTimes(dropDataConfig, int(dropCount))
|
||||
for itemId, count := range totalItemMap {
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
@@ -596,17 +616,26 @@ func (g *Game) chestDrop(player *model.Player, entity *Entity) {
|
||||
return
|
||||
}
|
||||
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
|
||||
dropId := int32(0)
|
||||
dropCount := int32(0)
|
||||
if gadgetConfig.ChestDropId != 0 {
|
||||
dropId = gadgetConfig.ChestDropId
|
||||
dropCount = 1
|
||||
} else {
|
||||
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
|
||||
}
|
||||
dropId = chestDropDataConfig.DropId
|
||||
dropCount = chestDropDataConfig.DropCount
|
||||
}
|
||||
dropDataConfig := gdconf.GetDropDataById(chestDropDataConfig.DropId)
|
||||
dropDataConfig := gdconf.GetDropDataById(dropId)
|
||||
if dropDataConfig == nil {
|
||||
logger.Error("get drop data config is nil, dropId: %v, uid: %v", chestDropDataConfig.DropId, player.PlayerId)
|
||||
logger.Error("get drop data config is nil, dropId: %v, uid: %v", dropId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
totalItemMap := g.doRandDropFullTimes(dropDataConfig, int(chestDropDataConfig.DropCount))
|
||||
totalItemMap := g.doRandDropFullTimes(dropDataConfig, int(dropCount))
|
||||
for itemId, count := range totalItemMap {
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
|
||||
@@ -395,6 +395,12 @@ func (c *CmdProtoMap) registerMessage() {
|
||||
c.regMsg(ServerCondMeetQuestListUpdateNotify, func() any { return new(proto.ServerCondMeetQuestListUpdateNotify) }) // 服务器动态任务列表更新通知
|
||||
c.regMsg(QuestProgressUpdateNotify, func() any { return new(proto.QuestProgressUpdateNotify) }) // 任务进度更新通知
|
||||
c.regMsg(QuestGlobalVarNotify, func() any { return new(proto.QuestGlobalVarNotify) }) // 任务全局变量通知
|
||||
c.regMsg(QuestCreateEntityReq, func() any { return new(proto.QuestCreateEntityReq) }) // 任务创建实体请求
|
||||
c.regMsg(QuestCreateEntityRsp, func() any { return new(proto.QuestCreateEntityRsp) }) // 任务创建实体响应
|
||||
c.regMsg(QuestDestroyEntityReq, func() any { return new(proto.QuestDestroyEntityReq) }) // 任务销毁实体请求
|
||||
c.regMsg(QuestDestroyEntityRsp, func() any { return new(proto.QuestDestroyEntityRsp) }) // 任务销毁实体响应
|
||||
c.regMsg(QuestDestroyNpcReq, func() any { return new(proto.QuestDestroyNpcReq) }) // 任务销毁npc请求
|
||||
c.regMsg(QuestDestroyNpcRsp, func() any { return new(proto.QuestDestroyNpcRsp) }) // 任务销毁npc响应
|
||||
|
||||
// TODO 家园
|
||||
c.regMsg(GetPlayerHomeCompInfoReq, func() any { return new(proto.GetPlayerHomeCompInfoReq) })
|
||||
|
||||
Reference in new issue
Block a user