完善开场任务流程和OpenState功能
This commit is contained in:
1 parent
864846c9c6
commit
f0e0ae1918
31 files changed
+883
-504
No files matched your search
@@ -1,5 +1,13 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
OPEN_STATE_COND_PLAYER_LEVEL = 1
|
||||
OPEN_STATE_COND_QUEST = 2
|
||||
OPEN_STATE_COND_OFFERING_LEVEL = 3
|
||||
OPEN_STATE_COND_CITY_REPUTATION_LEVEL = 4
|
||||
OPEN_STATE_COND_PARENT_QUEST = 5
|
||||
)
|
||||
|
||||
const (
|
||||
OPEN_STATE_NONE = 0
|
||||
OPEN_STATE_PAIMON = 1
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
PLAYER_PROP_NONE = 0 // 空
|
||||
PLAYER_PROP_EXP = 1001 // 角色经验
|
||||
PLAYER_PROP_BREAK_LEVEL = 1002 // 角色突破等阶
|
||||
PLAYER_PROP_SATIATION_VAL = 1003 // 角色饱食度
|
||||
@@ -15,9 +16,9 @@ const (
|
||||
PLAYER_PROP_IS_WEATHER_LOCKED = 10007 // 游戏内天气锁定
|
||||
PLAYER_PROP_IS_GAME_TIME_LOCKED = 10008 // 游戏内时间锁定
|
||||
PLAYER_PROP_IS_TRANSFERABLE = 10009 // 是否禁止传送 0 1
|
||||
PLAYER_PROP_MAX_STAMINA = 10010 // 最大体力 0-24000
|
||||
PLAYER_PROP_CUR_PERSIST_STAMINA = 10011 // 当前体力 0-PROP_MAX_STAMINA
|
||||
PLAYER_PROP_CUR_TEMPORARY_STAMINA = 10012 // 当前临时体力 暂不确定
|
||||
PLAYER_PROP_MAX_STAMINA = 10010 // 最大耐力 0-24000
|
||||
PLAYER_PROP_CUR_PERSIST_STAMINA = 10011 // 当前耐力 0-PROP_MAX_STAMINA
|
||||
PLAYER_PROP_CUR_TEMPORARY_STAMINA = 10012 // 当前临时耐力 暂不确定
|
||||
PLAYER_PROP_PLAYER_LEVEL = 10013 // 冒险等级
|
||||
PLAYER_PROP_PLAYER_EXP = 10014 // 冒险经验
|
||||
PLAYER_PROP_PLAYER_HCOIN = 10015 // 原石 可以为负数
|
||||
@@ -43,4 +44,11 @@ const (
|
||||
PLAYER_PROP_PLAYER_LEGENDARY_DAILY_TASK_NUM = 10041 // 传说每日任务数量 暂不确定
|
||||
PLAYER_PROP_PLAYER_HOME_COIN = 10042 // 洞天宝钱
|
||||
PLAYER_PROP_PLAYER_WAIT_SUB_HOME_COIN = 10043 // 暂存的洞天宝钱 暂不确定
|
||||
PLAYER_PROP_IS_AUTO_UNLOCK_SPECIFIC_EQUIP = 10044 // 是否自动解锁特殊装备 暂不确定
|
||||
PLAYER_PROP_PLAYER_GCG_COIN = 10045 // 七圣召唤相关
|
||||
PLAYER_PROP_PLAYER_WAIT_SUB_GCG_COIN = 10046 // 七圣召唤相关
|
||||
PLAYER_PROP_PLAYER_ONLINE_TIME = 10047 // 在线时间
|
||||
PLAYER_PROP_PLAYER_CAN_DIVE = 10048 // 是否能潜水 0 1
|
||||
PLAYER_PROP_DIVE_MAX_STAMINA = 10049 // 潜水最大耐力 0-10000
|
||||
PLAYER_PROP_DIVE_CUR_STAMINA = 10050 // 潜水当前耐力 0-PLAYER_PROP_DIVE_MAX_STAMINA
|
||||
)
|
||||
@@ -23,6 +23,7 @@ type AvatarData struct {
|
||||
InitialWeapon int32 `csv:"初始武器,omitempty"`
|
||||
WeaponType int32 `csv:"武器种类,omitempty"`
|
||||
SkillDepotId int32 `csv:"技能库ID,omitempty"`
|
||||
SkillDepotIdList IntArray `csv:"候选技能库ID,omitempty"`
|
||||
PromoteId int32 `csv:"角色突破ID,omitempty"`
|
||||
PromoteRewardLevel IntArray `csv:"角色突破奖励获取等阶,omitempty"`
|
||||
PromoteReward IntArray `csv:"角色突破奖励,omitempty"`
|
||||
|
||||
@@ -126,17 +126,9 @@ func GetAvatarSkillDepotDataMap() map[int32]*AvatarSkillDepotData {
|
||||
return CONF.AvatarSkillDepotDataMap
|
||||
}
|
||||
|
||||
func GetAvatarEnergySkillConfig(avatarId uint32) *AvatarSkillData {
|
||||
if avatarId == 10000005 || avatarId == 10000007 {
|
||||
return nil
|
||||
}
|
||||
// 角色配置
|
||||
avatarDataConfig, exist := CONF.AvatarDataMap[int32(avatarId)]
|
||||
if !exist {
|
||||
return nil
|
||||
}
|
||||
func GetAvatarEnergySkillConfig(skillDepotId uint32) *AvatarSkillData {
|
||||
// 角色技能库配置
|
||||
avatarSkillDepotDataConfig, exist := CONF.AvatarSkillDepotDataMap[avatarDataConfig.SkillDepotId]
|
||||
avatarSkillDepotDataConfig, exist := CONF.AvatarSkillDepotDataMap[int32(skillDepotId)]
|
||||
if !exist {
|
||||
return nil
|
||||
}
|
||||
|
||||
+48
-44
@@ -32,50 +32,52 @@ type GameDataConfig struct {
|
||||
luaPrefix string
|
||||
extPrefix string
|
||||
// 配置表数据
|
||||
SceneDataMap map[int32]*SceneData // 场景
|
||||
SceneLuaConfigMap map[int32]*SceneLuaConfig // 场景LUA配置
|
||||
GroupMap map[int32]*Group // 场景LUA区块group索引
|
||||
LuaStateLruMap map[int32]*LuaStateLru // 场景LUA虚拟机LRU内存淘汰
|
||||
TriggerDataMap map[int32]*TriggerData // 场景LUA触发器
|
||||
ScenePointMap map[int32]*ScenePoint // 场景传送点
|
||||
SceneTagDataMap map[int32]*SceneTagData // 场景标签
|
||||
GatherDataMap map[int32]*GatherData // 采集物
|
||||
GatherDataPointTypeMap map[int32]*GatherData // 采集物场景节点索引
|
||||
WorldAreaDataMap map[int32]*WorldAreaData // 世界区域
|
||||
AvatarDataMap map[int32]*AvatarData // 角色
|
||||
AvatarSkillDataMap map[int32]*AvatarSkillData // 角色技能
|
||||
AvatarSkillDepotDataMap map[int32]*AvatarSkillDepotData // 角色技能库
|
||||
FetterDataMap map[int32]*FetterData // 角色资料解锁
|
||||
FetterDataAvatarIdMap map[int32][]int32 // 角色资料解锁角色id索引
|
||||
ItemDataMap map[int32]*ItemData // 统一道具
|
||||
AvatarLevelDataMap map[int32]*AvatarLevelData // 角色等级
|
||||
AvatarPromoteDataMap map[int32]map[int32]*AvatarPromoteData // 角色突破
|
||||
PlayerLevelDataMap map[int32]*PlayerLevelData // 玩家等级
|
||||
WeaponLevelDataMap map[int32]*WeaponLevelData // 武器等级
|
||||
WeaponPromoteDataMap map[int32]map[int32]*WeaponPromoteData // 角色突破
|
||||
RewardDataMap map[int32]*RewardData // 奖励
|
||||
AvatarCostumeDataMap map[int32]*AvatarCostumeData // 角色时装
|
||||
AvatarFlycloakDataMap map[int32]*AvatarFlycloakData // 角色风之翼
|
||||
ReliquaryMainDataMap map[int32]map[int32]*ReliquaryMainData // 圣遗物主属性
|
||||
ReliquaryAffixDataMap map[int32]map[int32]*ReliquaryAffixData // 圣遗物追加属性
|
||||
QuestDataMap map[int32]*QuestData // 任务
|
||||
ParentQuestMap map[int32]map[int32]*QuestData // 父任务索引
|
||||
DropDataMap map[int32]*DropData // 掉落
|
||||
MonsterDropDataMap map[string]map[int32]*MonsterDropData // 怪物掉落
|
||||
ChestDropDataMap map[string]map[int32]*ChestDropData // 宝箱掉落
|
||||
DungeonDataMap map[int32]*DungeonData // 地牢
|
||||
GadgetDataMap map[int32]*GadgetData // 物件
|
||||
RefreshPolicyDataMap map[int32]*RefreshPolicyData // 刷新策略
|
||||
GCGCharDataMap map[int32]*GCGCharData // 七圣召唤角色卡牌
|
||||
GCGSkillDataMap map[int32]*GCGSkillData // 七圣召唤卡牌技能
|
||||
GachaDropGroupDataMap map[int32]*GachaDropGroupData // 卡池掉落组 临时的
|
||||
SkillStaminaDataMap map[int32]*SkillStaminaData // 角色技能消耗体力 临时的
|
||||
VehicleDataMap map[int32]*VehicleData // 载具
|
||||
OpenStateDataMap map[int32]*OpenStateData // 开放状态
|
||||
WeatherDataMap map[int32]*WeatherData // 天气
|
||||
WeatherTemplateMap map[string]map[int32]*WeatherTemplate // 天气模版
|
||||
SceneWeatherAreaMap map[int32]map[int32]*SceneWeatherArea // 天气区域
|
||||
PubgWorldGadgetDataMap map[int32]*PubgWorldGadgetData // pubg世界物件
|
||||
SceneDataMap map[int32]*SceneData // 场景
|
||||
SceneLuaConfigMap map[int32]*SceneLuaConfig // 场景LUA配置
|
||||
GroupMap map[int32]*Group // 场景LUA区块group索引
|
||||
LuaStateLruMap map[int32]*LuaStateLru // 场景LUA虚拟机LRU内存淘汰
|
||||
TriggerDataMap map[int32]*TriggerData // 场景LUA触发器
|
||||
ScenePointMap map[int32]*ScenePoint // 场景传送点
|
||||
SceneTagDataMap map[int32]*SceneTagData // 场景标签
|
||||
GatherDataMap map[int32]*GatherData // 采集物
|
||||
GatherDataPointTypeMap map[int32]*GatherData // 采集物场景节点索引
|
||||
WorldAreaDataMap map[int32]*WorldAreaData // 世界区域
|
||||
AvatarDataMap map[int32]*AvatarData // 角色
|
||||
AvatarSkillDataMap map[int32]*AvatarSkillData // 角色技能
|
||||
AvatarSkillDepotDataMap map[int32]*AvatarSkillDepotData // 角色技能库
|
||||
FetterDataMap map[int32]*FetterData // 角色资料解锁
|
||||
FetterDataAvatarIdMap map[int32][]int32 // 角色资料解锁角色id索引
|
||||
ItemDataMap map[int32]*ItemData // 统一道具
|
||||
AvatarLevelDataMap map[int32]*AvatarLevelData // 角色等级
|
||||
AvatarPromoteDataMap map[int32]map[int32]*AvatarPromoteData // 角色突破
|
||||
PlayerLevelDataMap map[int32]*PlayerLevelData // 玩家等级
|
||||
WeaponLevelDataMap map[int32]*WeaponLevelData // 武器等级
|
||||
WeaponPromoteDataMap map[int32]map[int32]*WeaponPromoteData // 角色突破
|
||||
RewardDataMap map[int32]*RewardData // 奖励
|
||||
AvatarCostumeDataMap map[int32]*AvatarCostumeData // 角色时装
|
||||
AvatarFlycloakDataMap map[int32]*AvatarFlycloakData // 角色风之翼
|
||||
ReliquaryMainDataMap map[int32]map[int32]*ReliquaryMainData // 圣遗物主属性
|
||||
ReliquaryAffixDataMap map[int32]map[int32]*ReliquaryAffixData // 圣遗物追加属性
|
||||
QuestDataMap map[int32]*QuestData // 任务
|
||||
ParentQuestMap map[int32]map[int32]*QuestData // 父任务索引
|
||||
DropDataMap map[int32]*DropData // 掉落
|
||||
MonsterDropDataMap map[string]map[int32]*MonsterDropData // 怪物掉落
|
||||
ChestDropDataMap map[string]map[int32]*ChestDropData // 宝箱掉落
|
||||
DungeonDataMap map[int32]*DungeonData // 地牢
|
||||
GadgetDataMap map[int32]*GadgetData // 物件
|
||||
RefreshPolicyDataMap map[int32]*RefreshPolicyData // 刷新策略
|
||||
GCGCharDataMap map[int32]*GCGCharData // 七圣召唤角色卡牌
|
||||
GCGSkillDataMap map[int32]*GCGSkillData // 七圣召唤卡牌技能
|
||||
GachaDropGroupDataMap map[int32]*GachaDropGroupData // 卡池掉落组 临时的
|
||||
SkillStaminaDataMap map[int32]*SkillStaminaData // 角色技能消耗体力 临时的
|
||||
VehicleDataMap map[int32]*VehicleData // 载具
|
||||
OpenStateDataMap map[int32]*OpenStateData // 开放状态
|
||||
WeatherDataMap map[int32]*WeatherData // 天气
|
||||
WeatherTemplateMap map[string]map[int32]*WeatherTemplate // 天气模版
|
||||
SceneWeatherAreaMap map[int32]map[int32]*SceneWeatherArea // 天气区域
|
||||
PubgWorldGadgetDataMap map[int32]*PubgWorldGadgetData // pubg世界物件
|
||||
MonsterRelationshipDataMap map[int32]*MonsterRelationshipData // 怪物关联
|
||||
MonsterDataMap map[int32]*MonsterData // 怪物
|
||||
}
|
||||
|
||||
func InitGameDataConfig() {
|
||||
@@ -184,6 +186,8 @@ func (g *GameDataConfig) load(loadSceneLua bool) {
|
||||
g.loadWeatherTemplateData() // 天气模版
|
||||
g.loadSceneWeatherArea() // 天气区域
|
||||
g.loadPubgWorldGadgetData() // pubg世界物件
|
||||
g.loadMonsterRelationshipData() // 怪物关联
|
||||
g.loadMonsterData() // 怪物
|
||||
}
|
||||
|
||||
// CSV相关
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package gdconf
|
||||
|
||||
import (
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
|
||||
// MonsterData 怪物配置表
|
||||
type MonsterData struct {
|
||||
MonsterId int32 `csv:"ID"`
|
||||
Name string `csv:"名称$text_name_Name,omitempty"`
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadMonsterData() {
|
||||
g.MonsterDataMap = make(map[int32]*MonsterData)
|
||||
monsterDataList := make([]*MonsterData, 0)
|
||||
readTable[MonsterData](g.txtPrefix+"MonsterData.txt", &monsterDataList)
|
||||
for _, monsterData := range monsterDataList {
|
||||
g.MonsterDataMap[monsterData.MonsterId] = monsterData
|
||||
}
|
||||
logger.Info("MonsterData count: %v", len(g.MonsterDataMap))
|
||||
}
|
||||
|
||||
func GetMonsterDataById(monsterId int32) *MonsterData {
|
||||
return CONF.MonsterDataMap[monsterId]
|
||||
}
|
||||
|
||||
func GetMonsterDataMap() map[int32]*MonsterData {
|
||||
return CONF.MonsterDataMap
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package gdconf
|
||||
|
||||
import (
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
|
||||
// MonsterRelationshipData 怪物关联配置表
|
||||
type MonsterRelationshipData struct {
|
||||
MonsterRelationshipId int32 `csv:"编号"`
|
||||
DropModel string `csv:"掉落模型,omitempty"`
|
||||
MonsterModel string `csv:"怪物模型,omitempty"`
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadMonsterRelationshipData() {
|
||||
g.MonsterRelationshipDataMap = make(map[int32]*MonsterRelationshipData)
|
||||
monsterRelationshipDataList := make([]*MonsterRelationshipData, 0)
|
||||
readTable[MonsterRelationshipData](g.txtPrefix+"MonsterRelationshipData.txt", &monsterRelationshipDataList)
|
||||
for _, monsterRelationshipData := range monsterRelationshipDataList {
|
||||
g.MonsterRelationshipDataMap[monsterRelationshipData.MonsterRelationshipId] = monsterRelationshipData
|
||||
}
|
||||
logger.Info("MonsterRelationshipData count: %v", len(g.MonsterRelationshipDataMap))
|
||||
}
|
||||
|
||||
func GetMonsterRelationshipDataById(monsterRelationshipId int32) *MonsterRelationshipData {
|
||||
return CONF.MonsterRelationshipDataMap[monsterRelationshipId]
|
||||
}
|
||||
|
||||
func GetMonsterRelationshipDataMap() map[int32]*MonsterRelationshipData {
|
||||
return CONF.MonsterRelationshipDataMap
|
||||
}
|
||||
|
||||
func GetDropModelByMonsterModel(monsterModel string) string {
|
||||
for _, monsterRelationshipData := range CONF.MonsterRelationshipDataMap {
|
||||
if monsterRelationshipData.MonsterModel == monsterModel {
|
||||
return monsterRelationshipData.DropModel
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
type OpenStateData struct {
|
||||
OpenStateId int32 `csv:"ID"`
|
||||
DefaultOpen int32 `csv:"默认是否开启,omitempty"`
|
||||
AllowClientReq int32 `csv:"客户端能否发起功能,omitempty"`
|
||||
AllowClientReq int32 `csv:"客户端能否发起功能开启,omitempty"`
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadOpenStateData() {
|
||||
|
||||
@@ -91,6 +91,7 @@ type Monster struct {
|
||||
Level int32 `json:"level"`
|
||||
AreaId int32 `json:"area_id"`
|
||||
DropTag string `json:"drop_tag"` // 关联MonsterDropData表
|
||||
DropId int32 `json:"drop_id"`
|
||||
IsOneOff bool `json:"isOneoff"`
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,24 @@ func (d *Dao) SetRedisPlayerList(playerList []*model.Player) {
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteRedisPlayer 删除玩家数据
|
||||
func (d *Dao) DeleteRedisPlayer(userId uint32) {
|
||||
startTime := time.Now().UnixNano()
|
||||
var err error = nil
|
||||
if d.redisCluster != nil {
|
||||
err = d.redisCluster.Del(context.TODO(), d.GetRedisPlayerKey(userId)).Err()
|
||||
} else {
|
||||
err = d.redis.Del(context.TODO(), d.GetRedisPlayerKey(userId)).Err()
|
||||
}
|
||||
if err != nil {
|
||||
logger.Error("delete player from redis error: %v", err)
|
||||
return
|
||||
}
|
||||
endTime := time.Now().UnixNano()
|
||||
costTime := endTime - startTime
|
||||
logger.Debug("delete player from redis cost time: %v ns", costTime)
|
||||
}
|
||||
|
||||
// 基于redis的玩家离线数据分布式锁实现
|
||||
|
||||
const (
|
||||
|
||||
@@ -38,8 +38,8 @@ func (c *CommandManager) InitController() {
|
||||
c.NewQuestCommandController(),
|
||||
c.NewPointCommandController(),
|
||||
c.NewWeatherCommandController(),
|
||||
c.NewXLuaDebugCommandController(),
|
||||
c.NewGcgCommandController(),
|
||||
c.NewClearCommandController(),
|
||||
c.NewDebugCommandController(),
|
||||
}
|
||||
c.RegAllController(controllerList...)
|
||||
}
|
||||
@@ -330,6 +330,7 @@ func (c *CommandManager) NewItemCommandController() *CommandController {
|
||||
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>管理你的物品</color>",
|
||||
UsageList: []string{
|
||||
"{alias} add <物品ID/all> [数量] 添加物品",
|
||||
"{alias} clear 清除全部物品",
|
||||
},
|
||||
Perm: CommandPermNormal,
|
||||
Func: c.ItemCommand,
|
||||
@@ -370,6 +371,9 @@ func (c *CommandManager) ItemCommand(content *CommandContent) bool {
|
||||
}
|
||||
c.gmCmd.GMAddItem(content.AssignPlayer.PlayerId, uint32(itemId), count)
|
||||
content.SendSuccMessage(content.Executor, "已给予物品,指定UID:%v,物品ID:%v,数量:%v。", content.AssignPlayer.PlayerId, itemId, count)
|
||||
case "clear":
|
||||
c.gmCmd.GMClearItem(content.AssignPlayer.PlayerId)
|
||||
content.SendSuccMessage(content.Executor, "已清除全部物品,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
@@ -718,6 +722,7 @@ func (c *CommandManager) NewQuestCommandController() *CommandController {
|
||||
UsageList: []string{
|
||||
"{alias} <add/accept> <任务ID> 接受任务",
|
||||
"{alias} finish <任务ID/all> 完成任务",
|
||||
"{alias} clear all 清除全部任务",
|
||||
},
|
||||
Perm: CommandPermNormal,
|
||||
Func: c.QuestCommand,
|
||||
@@ -763,6 +768,9 @@ func (c *CommandManager) QuestCommand(content *CommandContent) bool {
|
||||
}
|
||||
c.gmCmd.GMFinishQuest(content.AssignPlayer.PlayerId, uint32(questId))
|
||||
content.SendSuccMessage(content.Executor, "已完成玩家任务,指定UID:%v,任务ID:%v。", content.AssignPlayer.PlayerId, questId)
|
||||
case "clear":
|
||||
c.gmCmd.GMClearQuest(content.AssignPlayer.PlayerId)
|
||||
content.SendSuccMessage(content.Executor, "已清除全部任务,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
@@ -850,55 +858,100 @@ func (c *CommandManager) WeatherCommand(content *CommandContent) bool {
|
||||
})
|
||||
}
|
||||
|
||||
// xLua调试命令
|
||||
// 清除命令
|
||||
|
||||
func (c *CommandManager) NewXLuaDebugCommandController() *CommandController {
|
||||
func (c *CommandManager) NewClearCommandController() *CommandController {
|
||||
return &CommandController{
|
||||
Name: "xLua调试",
|
||||
AliasList: []string{"xluadebug"},
|
||||
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>开关xLua调试</color>",
|
||||
Name: "清除",
|
||||
AliasList: []string{"clear"},
|
||||
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>清除</color>",
|
||||
UsageList: []string{
|
||||
"{alias} 开关xLua调试",
|
||||
"{alias} all 清除玩家数据",
|
||||
},
|
||||
Perm: CommandPermGM,
|
||||
Func: c.XLuaDebugCommand,
|
||||
Perm: CommandPermNormal,
|
||||
Func: c.ClearCommand,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CommandManager) XLuaDebugCommand(content *CommandContent) bool {
|
||||
return content.Execute(func() bool {
|
||||
// 主动开关客户端XLUA调试
|
||||
if !content.AssignPlayer.XLuaDebug {
|
||||
content.AssignPlayer.XLuaDebug = true
|
||||
content.SendSuccMessage(content.Executor, "已开启客户端XLUA调试,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
} else {
|
||||
content.AssignPlayer.XLuaDebug = false
|
||||
content.SendSuccMessage(content.Executor, "已关闭客户端XLUA调试,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
func (c *CommandManager) ClearCommand(content *CommandContent) bool {
|
||||
var mode string // 模式
|
||||
|
||||
return content.Dynamic("string", func(param any) bool {
|
||||
// 模式
|
||||
mode = param.(string)
|
||||
return true
|
||||
}).Execute(func() bool {
|
||||
switch mode {
|
||||
case "all":
|
||||
c.gmCmd.GMClearPlayer(content.AssignPlayer.PlayerId)
|
||||
content.SendSuccMessage(content.Executor, "已清除玩家数据,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
// 七圣召唤测试命令
|
||||
// 调试命令
|
||||
|
||||
func (c *CommandManager) NewGcgCommandController() *CommandController {
|
||||
func (c *CommandManager) NewDebugCommandController() *CommandController {
|
||||
return &CommandController{
|
||||
Name: "七圣召唤测试",
|
||||
AliasList: []string{"gcgtest"},
|
||||
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>测试七圣召唤</color>",
|
||||
Name: "调试",
|
||||
AliasList: []string{"debug"},
|
||||
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>调试</color>",
|
||||
UsageList: []string{
|
||||
"{alias} 测试七圣召唤",
|
||||
"{alias} freemode 自由探索模式",
|
||||
"{alias} openstate 解锁全部功能",
|
||||
"{alias} clearworld 清除大世界数据",
|
||||
"{alias} notsave 本次离线回档",
|
||||
"{alias} xluaswitch 开关xLua",
|
||||
"{alias} gcgtest 七圣召唤测试",
|
||||
},
|
||||
Perm: CommandPermGM,
|
||||
Func: c.GcgCommand,
|
||||
Perm: CommandPermNormal,
|
||||
Func: c.DebugCommand,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CommandManager) GcgCommand(content *CommandContent) bool {
|
||||
return content.Execute(func() bool {
|
||||
// 开始七圣召唤对局
|
||||
GAME.GCGStartChallenge(content.AssignPlayer)
|
||||
content.SendSuccMessage(content.Executor, "已开始七圣召唤对局,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
func (c *CommandManager) DebugCommand(content *CommandContent) bool {
|
||||
var mode string // 模式
|
||||
|
||||
return content.Dynamic("string", func(param any) bool {
|
||||
// 模式
|
||||
mode = param.(string)
|
||||
return true
|
||||
}).Execute(func() bool {
|
||||
switch mode {
|
||||
case "freemode":
|
||||
c.gmCmd.GMFreeMode(content.AssignPlayer.PlayerId)
|
||||
content.SendSuccMessage(content.Executor, "已开启自由探索模式,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
return true
|
||||
case "openstate":
|
||||
c.gmCmd.GMUnlockAllOpenState(content.AssignPlayer.PlayerId)
|
||||
content.SendSuccMessage(content.Executor, "已解锁全部功能,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
return true
|
||||
case "clearworld":
|
||||
c.gmCmd.GMClearWorld(content.AssignPlayer.PlayerId)
|
||||
content.SendSuccMessage(content.Executor, "已清除大世界数据,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
return true
|
||||
case "notsave":
|
||||
c.gmCmd.GMNotSave(content.AssignPlayer.PlayerId)
|
||||
content.SendSuccMessage(content.Executor, "已设置本次离线回档,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
return true
|
||||
case "xluaswitch":
|
||||
if !content.AssignPlayer.XLuaDebug {
|
||||
content.AssignPlayer.XLuaDebug = true
|
||||
content.SendSuccMessage(content.Executor, "已开启客户端XLUA调试,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
} else {
|
||||
content.AssignPlayer.XLuaDebug = false
|
||||
content.SendSuccMessage(content.Executor, "已关闭客户端XLUA调试,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
}
|
||||
return true
|
||||
case "gcgtest":
|
||||
GAME.GCGStartChallenge(content.AssignPlayer)
|
||||
content.SendSuccMessage(content.Executor, "已开始七圣召唤对局,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
+43
-26
@@ -330,23 +330,7 @@ func (g *GMCmd) GMUnlockPoint(userId uint32, sceneId uint32, pointId uint32) {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
dbWorld := player.GetDbWorld()
|
||||
dbScene := dbWorld.GetSceneById(sceneId)
|
||||
if dbScene == nil {
|
||||
logger.Error("db scene is nil, uid: %v", sceneId)
|
||||
return
|
||||
}
|
||||
scenePointMapConfig := gdconf.GetScenePointMapBySceneId(int32(sceneId))
|
||||
if scenePointMapConfig == nil {
|
||||
logger.Error("scene point config is nil, sceneId: %v", sceneId)
|
||||
return
|
||||
}
|
||||
// 解锁锚点
|
||||
dbScene.UnlockPoint(pointId)
|
||||
GAME.SendMsg(cmd.ScenePointUnlockNotify, player.PlayerId, player.ClientSeq, &proto.ScenePointUnlockNotify{
|
||||
SceneId: sceneId,
|
||||
PointList: []uint32{pointId},
|
||||
})
|
||||
GAME.UnlockPlayerTransPoint(player, sceneId, pointId)
|
||||
}
|
||||
|
||||
// GMUnlockAllPoint 解锁场景全部锚点
|
||||
@@ -462,6 +446,7 @@ func (g *GMCmd) GMClearQuest(userId uint32) {
|
||||
return
|
||||
}
|
||||
player.DbQuest = nil
|
||||
GAME.AcceptQuest(player, false)
|
||||
GAME.LogoutPlayer(userId)
|
||||
}
|
||||
|
||||
@@ -476,6 +461,47 @@ func (g *GMCmd) GMClearWorld(userId uint32) {
|
||||
GAME.LogoutPlayer(userId)
|
||||
}
|
||||
|
||||
// GMNotSave 离线回档
|
||||
func (g *GMCmd) GMNotSave(userId uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
player.NotSave = true
|
||||
}
|
||||
|
||||
// GMUnlockAllOpenState 解锁全部功能开放状态
|
||||
func (g *GMCmd) GMUnlockAllOpenState(userId uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
for _, openStateData := range gdconf.GetOpenStateDataMap() {
|
||||
player.OpenStateMap[uint32(openStateData.OpenStateId)] = 1
|
||||
}
|
||||
GAME.LogoutPlayer(userId)
|
||||
}
|
||||
|
||||
// GMFreeMode 自由探索模式
|
||||
func (g *GMCmd) GMFreeMode(userId uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
player.PropMap[constant.PLAYER_PROP_IS_FLYABLE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_IS_WEATHER_LOCKED] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_IS_GAME_TIME_LOCKED] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_IS_TRANSFERABLE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_IS_MP_MODE_AVAILABLE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_CAN_DIVE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_DIVE_MAX_STAMINA] = 10000
|
||||
player.PropMap[constant.PLAYER_PROP_DIVE_CUR_STAMINA] = 10000
|
||||
GAME.SendMsg(cmd.PlayerPropNotify, player.PlayerId, player.ClientSeq, GAME.PacketPlayerPropNotify(player))
|
||||
}
|
||||
|
||||
// 系统级GM指令
|
||||
|
||||
// TODO 不知道为什么0个参数的函数会反射调用失败
|
||||
@@ -714,12 +740,3 @@ func (g *GMCmd) GetPlayerPos(userId uint32) (*model.Vector, *model.Vector) {
|
||||
}
|
||||
return GAME.GetPlayerPos(player), player.GetPos()
|
||||
}
|
||||
|
||||
func (g *GMCmd) NotSavePlayer(userId uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
player.OfflineNotSave = true
|
||||
}
|
||||
@@ -127,6 +127,9 @@ func (r *RouteManager) initRoute() {
|
||||
cmd.GetChatEmojiCollectionReq: GAME.GetChatEmojiCollectionReq,
|
||||
cmd.SetPlayerPropReq: GAME.SetPlayerPropReq,
|
||||
cmd.SetOpenStateReq: GAME.SetOpenStateReq,
|
||||
cmd.PlayerStartMatchReq: GAME.PlayerStartMatchReq,
|
||||
cmd.PlayerCancelMatchReq: GAME.PlayerCancelMatchReq,
|
||||
cmd.PlayerConfirmMatchReq: GAME.PlayerConfirmMatchReq,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ func (t *TickManager) onTickSecond(now int64) {
|
||||
if world.GetOwner().Pause {
|
||||
continue
|
||||
}
|
||||
scene.ChangeGameTime(scene.GetGameTime() + 1)
|
||||
GAME.ChangeGameTime(scene, scene.GetGameTime()+1)
|
||||
}
|
||||
}
|
||||
// GCG游戏Tick
|
||||
|
||||
@@ -194,7 +194,7 @@ func (u *UserManager) UserOfflineSave(player *model.Player, changeGsInfo *Change
|
||||
player.Online = false
|
||||
player.OfflineTime = uint32(time.Now().Unix())
|
||||
player.TotalOnlineTime += uint32(time.Now().UnixMilli()) - player.OnlineTime
|
||||
if player.OfflineNotSave {
|
||||
if player.NotSave {
|
||||
LOCAL_EVENT_MANAGER.GetLocalEventChan() <- &LocalEvent{
|
||||
EventId: UserOfflineSaveToDbFinish,
|
||||
Msg: &PlayerOfflineInfo{
|
||||
@@ -596,6 +596,9 @@ func (u *UserManager) UserCopyAndSave(exitSave bool) {
|
||||
if player.PlayerId < PlayerBaseUid {
|
||||
continue
|
||||
}
|
||||
if player.NotSave {
|
||||
continue
|
||||
}
|
||||
playerList = append(playerList, player)
|
||||
}
|
||||
sort.Stable(playerList)
|
||||
|
||||
@@ -793,7 +793,7 @@ func (w *World) CreateScene(sceneId uint32) *Scene {
|
||||
playerMap: make(map[uint32]*model.Player),
|
||||
entityMap: make(map[uint32]*Entity),
|
||||
groupMap: make(map[uint32]*Group),
|
||||
gameTime: 18 * 60,
|
||||
gameTime: 0,
|
||||
createTime: time.Now().UnixMilli(),
|
||||
meeoIndex: 0,
|
||||
}
|
||||
|
||||
@@ -508,9 +508,9 @@ func (g *Game) UpdatePlayerAvatarFightProp(userId uint32, avatarId uint32) {
|
||||
}
|
||||
|
||||
dbAvatar := player.GetDbAvatar()
|
||||
avatar, ok := dbAvatar.AvatarMap[avatarId]
|
||||
if !ok {
|
||||
logger.Error("avatar is nil, avatarId: %v", avatar)
|
||||
avatar, exist := dbAvatar.AvatarMap[avatarId]
|
||||
if !exist {
|
||||
logger.Error("avatar not exist, avatarId: %v", avatar.AvatarId)
|
||||
return
|
||||
}
|
||||
// 角色初始化面板
|
||||
@@ -523,6 +523,53 @@ func (g *Game) UpdatePlayerAvatarFightProp(userId uint32, avatarId uint32) {
|
||||
g.SendMsg(cmd.AvatarFightPropNotify, userId, player.ClientSeq, avatarFightPropNotify)
|
||||
}
|
||||
|
||||
func (g *Game) ChangePlayerAvatarElementType(player *model.Player, elementType int) {
|
||||
dbAvatar := player.GetDbAvatar()
|
||||
avatar := dbAvatar.AvatarMap[dbAvatar.MainCharAvatarId]
|
||||
switchSkillDepotId := uint32(0)
|
||||
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatar.AvatarId))
|
||||
if avatarDataConfig == nil {
|
||||
return
|
||||
}
|
||||
for _, skillDepotId := range avatarDataConfig.SkillDepotIdList {
|
||||
skillDepotDataConfig := gdconf.GetAvatarSkillDepotDataById(skillDepotId)
|
||||
if skillDepotDataConfig == nil {
|
||||
continue
|
||||
}
|
||||
avatarSkillDataConfig := gdconf.GetAvatarSkillDataById(skillDepotDataConfig.EnergySkill)
|
||||
if avatarSkillDataConfig == nil {
|
||||
continue
|
||||
}
|
||||
if avatarSkillDataConfig.CostElemType != int32(elementType) {
|
||||
continue
|
||||
}
|
||||
switchSkillDepotId = uint32(skillDepotId)
|
||||
break
|
||||
}
|
||||
dbAvatar.SwitchSkillDepot(avatar.AvatarId, switchSkillDepotId)
|
||||
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
entityId := world.GetPlayerWorldAvatarEntityId(player, avatar.AvatarId)
|
||||
|
||||
g.SendMsg(cmd.AvatarSkillDepotChangeNotify, player.PlayerId, player.ClientSeq, &proto.AvatarSkillDepotChangeNotify{
|
||||
EntityId: entityId,
|
||||
AvatarGuid: avatar.Guid,
|
||||
SkillDepotId: switchSkillDepotId,
|
||||
SkillLevelMap: avatar.SkillLevelMap,
|
||||
})
|
||||
|
||||
g.SendMsg(cmd.AbilityChangeNotify, player.PlayerId, player.ClientSeq, &proto.AbilityChangeNotify{
|
||||
EntityId: entityId,
|
||||
AbilityControlBlock: g.PacketAbilityControlBlock(avatar.AvatarId, switchSkillDepotId),
|
||||
})
|
||||
|
||||
dbAvatar.SetCurrEnergy(avatar.AvatarId, 0, true)
|
||||
g.UpdatePlayerAvatarFightProp(player.PlayerId, avatar.AvatarId)
|
||||
}
|
||||
|
||||
/************************************************** 打包封装 **************************************************/
|
||||
|
||||
// PacketAvatarInfo 转换角色信息
|
||||
|
||||
+77
-13
@@ -10,10 +10,47 @@ import (
|
||||
"hk4e/gs/model"
|
||||
"hk4e/pkg/logger"
|
||||
"hk4e/protocol/proto"
|
||||
|
||||
pb "google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
/************************************************** 接口请求 **************************************************/
|
||||
|
||||
func (g *Game) PlayerSetPauseReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.PlayerSetPauseReq)
|
||||
player.Pause = req.IsPaused
|
||||
g.SendMsg(cmd.PlayerSetPauseRsp, player.PlayerId, player.ClientSeq, new(proto.PlayerSetPauseRsp))
|
||||
}
|
||||
|
||||
func (g *Game) SetPlayerPropReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.SetPlayerPropReq)
|
||||
for _, propValue := range req.PropList {
|
||||
logger.Debug("player set prop, key: %v, value: %v, uid: %v", propValue.Type, propValue.Val, player.PlayerId)
|
||||
player.PropMap[propValue.Type] = uint32(propValue.Val)
|
||||
}
|
||||
g.SendMsg(cmd.SetPlayerPropRsp, player.PlayerId, player.ClientSeq, new(proto.SetPlayerPropRsp))
|
||||
}
|
||||
|
||||
func (g *Game) SetOpenStateReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.SetOpenStateReq)
|
||||
logger.Debug("player set open state, key: %v, value: %v, uid: %v", req.Key, req.Value, player.PlayerId)
|
||||
openStateDataConfig := gdconf.GetOpenStateDataById(int32(req.Key))
|
||||
if openStateDataConfig == nil {
|
||||
logger.Error("get open state data config is nil, key: %v", req.Key)
|
||||
return
|
||||
}
|
||||
if openStateDataConfig.AllowClientReq == 0 {
|
||||
g.SendError(cmd.SetOpenStateRsp, player, &proto.SetOpenStateRsp{})
|
||||
return
|
||||
}
|
||||
g.ChangePlayerOpenState(player, req.Key, req.Value)
|
||||
|
||||
g.SendMsg(cmd.SetOpenStateRsp, player.PlayerId, player.ClientSeq, &proto.SetOpenStateRsp{
|
||||
Key: req.Key,
|
||||
Value: req.Value,
|
||||
})
|
||||
}
|
||||
|
||||
/************************************************** 游戏功能 **************************************************/
|
||||
|
||||
// HandlePlayerExpAdd 玩家冒险阅历增加处理
|
||||
@@ -46,24 +83,24 @@ func (g *Game) HandlePlayerExpAdd(userId uint32) {
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_EXP] -= uint32(playerLevelConfig.Exp)
|
||||
}
|
||||
// 更新玩家属性
|
||||
playerPropNotify := &proto.PlayerPropNotify{
|
||||
PropMap: make(map[uint32]*proto.PropValue),
|
||||
}
|
||||
playerPropNotify.PropMap[uint32(constant.PLAYER_PROP_PLAYER_LEVEL)] = g.PacketPropValue(
|
||||
g.SendMsg(cmd.PlayerPropNotify, player.PlayerId, player.ClientSeq, g.PacketPlayerPropNotify(
|
||||
player,
|
||||
constant.PLAYER_PROP_PLAYER_LEVEL,
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_LEVEL],
|
||||
)
|
||||
playerPropNotify.PropMap[uint32(constant.PLAYER_PROP_PLAYER_EXP)] = g.PacketPropValue(
|
||||
constant.PLAYER_PROP_PLAYER_EXP,
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_EXP],
|
||||
)
|
||||
g.SendMsg(cmd.PlayerPropNotify, userId, player.ClientSeq, playerPropNotify)
|
||||
))
|
||||
}
|
||||
|
||||
func (g *Game) ChangePlayerOpenState(player *model.Player, key uint32, value uint32) {
|
||||
player.OpenStateMap[key] = value
|
||||
g.SendMsg(cmd.OpenStateChangeNotify, player.PlayerId, player.ClientSeq, &proto.OpenStateChangeNotify{
|
||||
OpenStateMap: map[uint32]uint32{key: value},
|
||||
})
|
||||
}
|
||||
|
||||
/************************************************** 打包封装 **************************************************/
|
||||
|
||||
func (g *Game) PacketPlayerDataNotify(player *model.Player) *proto.PlayerDataNotify {
|
||||
playerDataNotify := &proto.PlayerDataNotify{
|
||||
ntf := &proto.PlayerDataNotify{
|
||||
NickName: player.NickName,
|
||||
ServerTime: uint64(time.Now().UnixMilli()),
|
||||
IsFirstLoginToday: true,
|
||||
@@ -71,7 +108,34 @@ func (g *Game) PacketPlayerDataNotify(player *model.Player) *proto.PlayerDataNot
|
||||
PropMap: make(map[uint32]*proto.PropValue),
|
||||
}
|
||||
for k, v := range player.PropMap {
|
||||
playerDataNotify.PropMap[k] = g.PacketPropValue(k, v)
|
||||
ntf.PropMap[k] = g.PacketPropValue(k, v)
|
||||
}
|
||||
return playerDataNotify
|
||||
return ntf
|
||||
}
|
||||
|
||||
func (g *Game) PacketPlayerPropNotify(player *model.Player, propList ...uint32) *proto.PlayerPropNotify {
|
||||
ntf := &proto.PlayerPropNotify{
|
||||
PropMap: make(map[uint32]*proto.PropValue),
|
||||
}
|
||||
if len(propList) == 0 {
|
||||
for k, v := range player.PropMap {
|
||||
ntf.PropMap[k] = g.PacketPropValue(k, v)
|
||||
}
|
||||
} else {
|
||||
for _, k := range propList {
|
||||
v := player.PropMap[k]
|
||||
ntf.PropMap[k] = g.PacketPropValue(k, v)
|
||||
}
|
||||
}
|
||||
return ntf
|
||||
}
|
||||
|
||||
func (g *Game) PacketOpenStateUpdateNotify(player *model.Player) *proto.OpenStateUpdateNotify {
|
||||
ntf := &proto.OpenStateUpdateNotify{
|
||||
OpenStateMap: make(map[uint32]uint32),
|
||||
}
|
||||
for k, v := range player.OpenStateMap {
|
||||
ntf.OpenStateMap[k] = v
|
||||
}
|
||||
return ntf
|
||||
}
|
||||
@@ -6,8 +6,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"hk4e/gdconf"
|
||||
|
||||
"hk4e/common/constant"
|
||||
"hk4e/gs/model"
|
||||
"hk4e/pkg/logger"
|
||||
@@ -34,13 +32,6 @@ func (g *Game) PingReq(player *model.Player, payloadMsg pb.Message) {
|
||||
})
|
||||
}
|
||||
|
||||
func (g *Game) PlayerSetPauseReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.PlayerSetPauseReq)
|
||||
isPaused := req.IsPaused
|
||||
player.Pause = isPaused
|
||||
g.SendMsg(cmd.PlayerSetPauseRsp, player.PlayerId, player.ClientSeq, new(proto.PlayerSetPauseRsp))
|
||||
}
|
||||
|
||||
func (g *Game) TowerAllDataReq(player *model.Player, payloadMsg pb.Message) {
|
||||
towerAllDataRsp := &proto.TowerAllDataRsp{
|
||||
TowerScheduleId: 29,
|
||||
@@ -303,36 +294,12 @@ func (g *Game) GmTalkReq(player *model.Player, payloadMsg pb.Message) {
|
||||
g.SendMsg(cmd.GmTalkRsp, player.PlayerId, player.ClientSeq, &proto.GmTalkRsp{Retmsg: "执行成功", Msg: req.Msg})
|
||||
}
|
||||
|
||||
func (g *Game) PacketOpenStateUpdateNotify() *proto.OpenStateUpdateNotify {
|
||||
openStateUpdateNotify := &proto.OpenStateUpdateNotify{
|
||||
OpenStateMap: make(map[uint32]uint32),
|
||||
}
|
||||
// 先暂时开放全部功能模块
|
||||
for _, data := range gdconf.GetOpenStateDataMap() {
|
||||
openStateUpdateNotify.OpenStateMap[uint32(data.OpenStateId)] = 1
|
||||
}
|
||||
return openStateUpdateNotify
|
||||
}
|
||||
|
||||
func (g *Game) GetChatEmojiCollectionReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.GetChatEmojiCollectionReq)
|
||||
_ = req
|
||||
g.SendMsg(cmd.GetChatEmojiCollectionRsp, player.PlayerId, player.ClientSeq, new(proto.GetChatEmojiCollectionRsp))
|
||||
}
|
||||
|
||||
func (g *Game) SetPlayerPropReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.SetPlayerPropReq)
|
||||
for _, propValue := range req.PropList {
|
||||
player.PropMap[propValue.Type] = uint32(propValue.Val)
|
||||
}
|
||||
g.SendMsg(cmd.SetPlayerPropRsp, player.PlayerId, player.ClientSeq, new(proto.SetPlayerPropRsp))
|
||||
}
|
||||
|
||||
func (g *Game) SetOpenStateReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.SetOpenStateReq)
|
||||
g.SendMsg(cmd.SetOpenStateRsp, player.PlayerId, player.ClientSeq, &proto.SetOpenStateRsp{Key: req.Key, Value: req.Value})
|
||||
}
|
||||
|
||||
func (g *Game) PacketPropValue(key uint32, value any) *proto.PropValue {
|
||||
propValue := new(proto.PropValue)
|
||||
propValue.Type = key
|
||||
|
||||
@@ -713,10 +713,26 @@ func (g *Game) EvtDoSkillSuccNotify(player *model.Player, payloadMsg pb.Message)
|
||||
// 处理技能开始的耐力消耗
|
||||
g.SkillStartStamina(player, ntf.CasterId, ntf.SkillId)
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_SKILL, "", int32(ntf.SkillId))
|
||||
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
return
|
||||
}
|
||||
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
||||
dbAvatar := player.GetDbAvatar()
|
||||
avatar := dbAvatar.AvatarMap[activeAvatarId]
|
||||
if avatar == nil {
|
||||
return
|
||||
}
|
||||
avatarSkillDataConfig := gdconf.GetAvatarEnergySkillConfig(avatar.SkillDepotId)
|
||||
if avatarSkillDataConfig == nil {
|
||||
return
|
||||
}
|
||||
if int32(ntf.SkillId) == avatarSkillDataConfig.AvatarSkillId {
|
||||
dbAvatar.SetCurrEnergy(activeAvatarId, 0, false)
|
||||
g.UpdatePlayerAvatarFightProp(player.PlayerId, activeAvatarId)
|
||||
}
|
||||
|
||||
if !WORLD_MANAGER.IsAiWorld(world) {
|
||||
return
|
||||
}
|
||||
|
||||
+21
-25
@@ -111,7 +111,7 @@ func (g *Game) GetPlayerItemCount(userId uint32, itemId uint32) uint32 {
|
||||
}
|
||||
}
|
||||
|
||||
// AddPlayerItem 玩家添加物品
|
||||
// AddPlayerItem 添加玩家物品
|
||||
func (g *Game) AddPlayerItem(userId uint32, itemList []*ChangeItem, isHint bool, hintReason uint16) bool {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
@@ -119,10 +119,8 @@ func (g *Game) AddPlayerItem(userId uint32, itemList []*ChangeItem, isHint bool,
|
||||
return false
|
||||
}
|
||||
dbItem := player.GetDbItem()
|
||||
playerPropNotify := &proto.PlayerPropNotify{
|
||||
PropMap: make(map[uint32]*proto.PropValue),
|
||||
}
|
||||
storeItemChangeNotify := &proto.StoreItemChangeNotify{
|
||||
propList := make([]uint32, 0)
|
||||
changeNtf := &proto.StoreItemChangeNotify{
|
||||
StoreType: proto.StoreType_STORE_PACK,
|
||||
ItemList: make([]*proto.Item, 0),
|
||||
}
|
||||
@@ -131,7 +129,7 @@ func (g *Game) AddPlayerItem(userId uint32, itemList []*ChangeItem, isHint bool,
|
||||
if exist {
|
||||
// 物品为虚拟物品 角色属性物品数量增加
|
||||
player.PropMap[prop] += changeItem.ChangeCount
|
||||
playerPropNotify.PropMap[prop] = g.PacketPropValue(prop, int64(player.PropMap[prop]))
|
||||
propList = append(propList, prop)
|
||||
// 特殊属性变化处理函数
|
||||
switch changeItem.ItemId {
|
||||
case constant.ITEM_ID_PLAYER_EXP:
|
||||
@@ -155,12 +153,12 @@ func (g *Game) AddPlayerItem(userId uint32, itemList []*ChangeItem, isHint bool,
|
||||
},
|
||||
},
|
||||
}
|
||||
storeItemChangeNotify.ItemList = append(storeItemChangeNotify.ItemList, pbItem)
|
||||
changeNtf.ItemList = append(changeNtf.ItemList, pbItem)
|
||||
}
|
||||
if len(playerPropNotify.PropMap) > 0 {
|
||||
g.SendMsg(cmd.PlayerPropNotify, userId, player.ClientSeq, playerPropNotify)
|
||||
if len(propList) > 0 {
|
||||
g.SendMsg(cmd.PlayerPropNotify, userId, player.ClientSeq, g.PacketPlayerPropNotify(player, propList...))
|
||||
}
|
||||
g.SendMsg(cmd.StoreItemChangeNotify, userId, player.ClientSeq, storeItemChangeNotify)
|
||||
g.SendMsg(cmd.StoreItemChangeNotify, userId, player.ClientSeq, changeNtf)
|
||||
if isHint {
|
||||
if hintReason == 0 {
|
||||
hintReason = uint16(proto.ActionReasonType_ACTION_REASON_SUBFIELD_DROP)
|
||||
@@ -181,7 +179,7 @@ func (g *Game) AddPlayerItem(userId uint32, itemList []*ChangeItem, isHint bool,
|
||||
return true
|
||||
}
|
||||
|
||||
// CostPlayerItem 玩家消耗物品
|
||||
// CostPlayerItem 消耗玩家物品
|
||||
func (g *Game) CostPlayerItem(userId uint32, itemList []*ChangeItem) bool {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
@@ -189,14 +187,12 @@ func (g *Game) CostPlayerItem(userId uint32, itemList []*ChangeItem) bool {
|
||||
return false
|
||||
}
|
||||
dbItem := player.GetDbItem()
|
||||
playerPropNotify := &proto.PlayerPropNotify{
|
||||
PropMap: make(map[uint32]*proto.PropValue),
|
||||
}
|
||||
storeItemChangeNotify := &proto.StoreItemChangeNotify{
|
||||
propList := make([]uint32, 0)
|
||||
changeNtf := &proto.StoreItemChangeNotify{
|
||||
StoreType: proto.StoreType_STORE_PACK,
|
||||
ItemList: make([]*proto.Item, 0),
|
||||
}
|
||||
storeItemDelNotify := &proto.StoreItemDelNotify{
|
||||
delNtf := &proto.StoreItemDelNotify{
|
||||
StoreType: proto.StoreType_STORE_PACK,
|
||||
GuidList: make([]uint64, 0),
|
||||
}
|
||||
@@ -210,7 +206,7 @@ func (g *Game) CostPlayerItem(userId uint32, itemList []*ChangeItem) bool {
|
||||
if exist {
|
||||
// 物品为虚拟物品 角色属性物品数量减少
|
||||
player.PropMap[prop] -= changeItem.ChangeCount
|
||||
playerPropNotify.PropMap[prop] = g.PacketPropValue(prop, int64(player.PropMap[prop]))
|
||||
propList = append(propList, prop)
|
||||
// 特殊属性变化处理函数
|
||||
switch changeItem.ItemId {
|
||||
case constant.ITEM_ID_PLAYER_EXP:
|
||||
@@ -232,20 +228,20 @@ func (g *Game) CostPlayerItem(userId uint32, itemList []*ChangeItem) bool {
|
||||
},
|
||||
},
|
||||
}
|
||||
storeItemChangeNotify.ItemList = append(storeItemChangeNotify.ItemList, pbItem)
|
||||
changeNtf.ItemList = append(changeNtf.ItemList, pbItem)
|
||||
} else if count == 0 {
|
||||
storeItemDelNotify.GuidList = append(storeItemDelNotify.GuidList, dbItem.GetItemGuid(changeItem.ItemId))
|
||||
delNtf.GuidList = append(delNtf.GuidList, dbItem.GetItemGuid(changeItem.ItemId))
|
||||
}
|
||||
}
|
||||
|
||||
if len(playerPropNotify.PropMap) > 0 {
|
||||
g.SendMsg(cmd.PlayerPropNotify, userId, player.ClientSeq, playerPropNotify)
|
||||
if len(propList) > 0 {
|
||||
g.SendMsg(cmd.PlayerPropNotify, userId, player.ClientSeq, g.PacketPlayerPropNotify(player, propList...))
|
||||
}
|
||||
if len(storeItemChangeNotify.ItemList) > 0 {
|
||||
g.SendMsg(cmd.StoreItemChangeNotify, userId, player.ClientSeq, storeItemChangeNotify)
|
||||
if len(changeNtf.ItemList) > 0 {
|
||||
g.SendMsg(cmd.StoreItemChangeNotify, userId, player.ClientSeq, changeNtf)
|
||||
}
|
||||
if len(storeItemDelNotify.GuidList) > 0 {
|
||||
g.SendMsg(cmd.StoreItemDelNotify, userId, player.ClientSeq, storeItemDelNotify)
|
||||
if len(delNtf.GuidList) > 0 {
|
||||
g.SendMsg(cmd.StoreItemDelNotify, userId, player.ClientSeq, delNtf)
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
+59
-10
@@ -101,6 +101,14 @@ func (g *Game) OnLogin(userId uint32, clientSeq uint32, gateAppId string, player
|
||||
player.Rot = &model.Vector{X: 0, Y: 307, Z: 0}
|
||||
}
|
||||
|
||||
dbQuest := player.GetDbQuest()
|
||||
for _, quest := range dbQuest.GetQuestMap() {
|
||||
if quest.State == constant.QUEST_STATE_UNFINISHED {
|
||||
quest.State = constant.QUEST_STATE_UNSTARTED
|
||||
g.StartQuest(player, quest.QuestId, false)
|
||||
}
|
||||
}
|
||||
|
||||
if player.IsBorn {
|
||||
g.LoginNotify(userId, clientSeq, player)
|
||||
if req.TargetUid != 0 {
|
||||
@@ -152,21 +160,62 @@ func (g *Game) CreatePlayer(userId uint32) *model.Player {
|
||||
player.Signature = ""
|
||||
player.HeadImage = 10000007
|
||||
player.PropMap = make(map[uint32]uint32)
|
||||
player.OpenStateMap = make(map[uint32]uint32)
|
||||
player.ChatMsgMap = make(map[uint32][]*model.ChatMsg)
|
||||
|
||||
player.SceneId = 3
|
||||
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_LEVEL] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_IS_SPRING_AUTO_USE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_SPRING_AUTO_USE_PERCENT] = 100
|
||||
player.PropMap[constant.PLAYER_PROP_IS_FLYABLE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_IS_TRANSFERABLE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_MAX_STAMINA] = 24000
|
||||
player.PropMap[constant.PLAYER_PROP_CUR_PERSIST_STAMINA] = 24000
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_RESIN] = 160
|
||||
player.PropMap[constant.PLAYER_PROP_CUR_PERSIST_STAMINA] = 10000
|
||||
player.PropMap[constant.PLAYER_PROP_CUR_TEMPORARY_STAMINA] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_LEVEL] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_EXP] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_HCOIN] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_SCOIN] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_MP_SETTING_TYPE] = 2
|
||||
player.PropMap[constant.PLAYER_PROP_IS_MP_MODE_AVAILABLE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_RESIN] = 160
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_WAIT_SUB_HCOIN] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_WAIT_SUB_SCOIN] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_MCOIN] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_WAIT_SUB_MCOIN] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_LEGENDARY_KEY] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_CUR_CLIMATE_METER] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_CUR_CLIMATE_TYPE] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_CUR_CLIMATE_AREA_ID] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_CUR_CLIMATE_AREA_CLIMATE_TYPE] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL_LIMIT] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL_ADJUST_CD] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_LEGENDARY_DAILY_TASK_NUM] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_HOME_COIN] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_PLAYER_WAIT_SUB_HOME_COIN] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_IS_AUTO_UNLOCK_SPECIFIC_EQUIP] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_IS_SPRING_AUTO_USE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_SPRING_AUTO_USE_PERCENT] = 50
|
||||
player.PropMap[constant.PLAYER_PROP_IS_FLYABLE] = 0
|
||||
player.PropMap[constant.PLAYER_PROP_IS_WEATHER_LOCKED] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_IS_GAME_TIME_LOCKED] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_IS_TRANSFERABLE] = 1
|
||||
player.PropMap[constant.PLAYER_PROP_MAX_STAMINA] = 10000
|
||||
|
||||
player.OpenStateMap[constant.OPEN_STATE_DERIVATIVE_MALL] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_PHOTOGRAPH] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_GUIDE_RELIC_PROM] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_GUIDE_TALENT] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_RELIQUARY_PROMOTE] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_SHOP_TYPE_RECOMMANDED] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_RELIQUARY_UPGRADE] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_WEAPON_AWAKEN] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_WEAPON_PROMOTE] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_WEAPON_UPGRADE] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_AVATAR_TALENT] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_AVATAR_PROMOTE] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_RESIN] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_SHOP_TYPE_GENESISCRYSTAL] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_SHOP_TYPE_GIFTPACKAGE] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_BATTLE_PASS] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_SHOP_TYPE_BLACKSMITH] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_SHOP_TYPE_PAIMON] = 1
|
||||
player.OpenStateMap[constant.OPEN_STATE_SHOP_TYPE_VIRTUAL_SHOP] = 1
|
||||
|
||||
sceneLuaConfig := gdconf.GetSceneLuaConfigById(int32(player.SceneId))
|
||||
if sceneLuaConfig != nil {
|
||||
@@ -215,7 +264,7 @@ func (g *Game) LoginNotify(userId uint32, clientSeq uint32, player *model.Player
|
||||
g.SendMsg(cmd.StoreWeightLimitNotify, userId, clientSeq, g.PacketStoreWeightLimitNotify())
|
||||
g.SendMsg(cmd.PlayerStoreNotify, userId, clientSeq, g.PacketPlayerStoreNotify(player))
|
||||
g.SendMsg(cmd.AvatarDataNotify, userId, clientSeq, g.PacketAvatarDataNotify(player))
|
||||
g.SendMsg(cmd.OpenStateUpdateNotify, userId, clientSeq, g.PacketOpenStateUpdateNotify())
|
||||
g.SendMsg(cmd.OpenStateUpdateNotify, userId, clientSeq, g.PacketOpenStateUpdateNotify(player))
|
||||
g.SendMsg(cmd.QuestListNotify, userId, clientSeq, g.PacketQuestListNotify(player))
|
||||
g.SendMsg(cmd.FinishedParentQuestNotify, userId, clientSeq, g.PacketFinishedParentQuestNotify(player))
|
||||
g.SendMsg(cmd.AllMarkPointNotify, player.PlayerId, player.ClientSeq, &proto.AllMarkPointNotify{MarkList: g.PacketMapMarkPointList(player)})
|
||||
|
||||
+103
-101
@@ -16,38 +16,110 @@ import (
|
||||
|
||||
/************************************************** 接口请求 **************************************************/
|
||||
|
||||
// PlayerApplyEnterMpReq 世界敲门请求
|
||||
func (g *Game) PlayerApplyEnterMpReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.PlayerApplyEnterMpReq)
|
||||
targetUid := req.TargetUid
|
||||
|
||||
playerApplyEnterMpRsp := &proto.PlayerApplyEnterMpRsp{
|
||||
TargetUid: targetUid,
|
||||
}
|
||||
g.SendMsg(cmd.PlayerApplyEnterMpRsp, player.PlayerId, player.ClientSeq, playerApplyEnterMpRsp)
|
||||
|
||||
g.PlayerApplyEnterWorld(player, targetUid)
|
||||
rsp := &proto.PlayerApplyEnterMpRsp{TargetUid: req.TargetUid}
|
||||
g.SendMsg(cmd.PlayerApplyEnterMpRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
g.PlayerApplyEnterWorld(player, req.TargetUid)
|
||||
}
|
||||
|
||||
// PlayerApplyEnterMpResultReq 世界敲门处理请求
|
||||
func (g *Game) PlayerApplyEnterMpResultReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.PlayerApplyEnterMpResultReq)
|
||||
applyUid := req.ApplyUid
|
||||
isAgreed := req.IsAgreed
|
||||
|
||||
playerApplyEnterMpResultRsp := &proto.PlayerApplyEnterMpResultRsp{
|
||||
ApplyUid: applyUid,
|
||||
IsAgreed: isAgreed,
|
||||
rsp := &proto.PlayerApplyEnterMpResultRsp{
|
||||
ApplyUid: req.ApplyUid,
|
||||
IsAgreed: req.IsAgreed,
|
||||
}
|
||||
g.SendMsg(cmd.PlayerApplyEnterMpResultRsp, player.PlayerId, player.ClientSeq, playerApplyEnterMpResultRsp)
|
||||
|
||||
g.PlayerDealEnterWorld(player, applyUid, isAgreed)
|
||||
g.SendMsg(cmd.PlayerApplyEnterMpResultRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
g.PlayerDealEnterWorld(player, req.ApplyUid, req.IsAgreed)
|
||||
}
|
||||
|
||||
// PlayerGetForceQuitBanInfoReq 获取强退禁令信息请求
|
||||
func (g *Game) PlayerGetForceQuitBanInfoReq(player *model.Player, payloadMsg pb.Message) {
|
||||
ok := true
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
if worldPlayer.SceneLoadState != model.SceneEnterDone {
|
||||
ok = false
|
||||
}
|
||||
}
|
||||
if !ok {
|
||||
g.SendError(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
|
||||
return
|
||||
}
|
||||
g.SendSucc(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{})
|
||||
}
|
||||
|
||||
// BackMyWorldReq 返回单人世界请求
|
||||
func (g *Game) BackMyWorldReq(player *model.Player, payloadMsg pb.Message) {
|
||||
// 其他玩家
|
||||
ok := g.PlayerLeaveWorld(player, false, proto.PlayerQuitFromMpNotify_BACK_TO_MY_WORLD)
|
||||
if !ok {
|
||||
g.SendError(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
|
||||
return
|
||||
}
|
||||
g.SendSucc(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{})
|
||||
}
|
||||
|
||||
// ChangeWorldToSingleModeReq 转换单人模式请求
|
||||
func (g *Game) ChangeWorldToSingleModeReq(player *model.Player, payloadMsg pb.Message) {
|
||||
// 房主
|
||||
ok := g.PlayerLeaveWorld(player, false, proto.PlayerQuitFromMpNotify_HOST_NO_OTHER_PLAYER)
|
||||
if !ok {
|
||||
g.SendError(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
|
||||
return
|
||||
}
|
||||
g.SendSucc(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{})
|
||||
}
|
||||
|
||||
// SceneKickPlayerReq 剔除玩家请求
|
||||
func (g *Game) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.SceneKickPlayerReq)
|
||||
targetUid := req.TargetUid
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
if player.PlayerId != world.GetOwner().PlayerId {
|
||||
g.SendError(cmd.SceneKickPlayerRsp, player, &proto.SceneKickPlayerRsp{})
|
||||
return
|
||||
}
|
||||
targetPlayer := USER_MANAGER.GetOnlineUser(targetUid)
|
||||
if targetPlayer == nil {
|
||||
logger.Error("player is nil, uid: %v", targetUid)
|
||||
return
|
||||
}
|
||||
ok := g.PlayerLeaveWorld(targetPlayer, false, proto.PlayerQuitFromMpNotify_KICK_BY_HOST)
|
||||
if !ok {
|
||||
g.SendError(cmd.SceneKickPlayerRsp, player, &proto.SceneKickPlayerRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
|
||||
return
|
||||
}
|
||||
ntf := &proto.SceneKickPlayerNotify{
|
||||
TargetUid: targetUid,
|
||||
KickerUid: player.PlayerId,
|
||||
}
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
g.SendMsg(cmd.SceneKickPlayerNotify, worldPlayer.PlayerId, worldPlayer.ClientSeq, ntf)
|
||||
}
|
||||
rsp := &proto.SceneKickPlayerRsp{
|
||||
TargetUid: targetUid,
|
||||
}
|
||||
g.SendMsg(cmd.SceneKickPlayerRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
}
|
||||
|
||||
// JoinPlayerSceneReq 进入他人世界请求
|
||||
func (g *Game) JoinPlayerSceneReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.JoinPlayerSceneReq)
|
||||
|
||||
joinPlayerSceneRsp := new(proto.JoinPlayerSceneRsp)
|
||||
joinPlayerSceneRsp.Retcode = int32(proto.Retcode_RET_JOIN_OTHER_WAIT)
|
||||
g.SendMsg(cmd.JoinPlayerSceneRsp, player.PlayerId, player.ClientSeq, joinPlayerSceneRsp)
|
||||
rsp := &proto.JoinPlayerSceneRsp{
|
||||
Retcode: int32(proto.Retcode_RET_JOIN_OTHER_WAIT),
|
||||
}
|
||||
g.SendMsg(cmd.JoinPlayerSceneRsp, player.PlayerId, player.ClientSeq, rsp)
|
||||
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
@@ -79,83 +151,16 @@ func (g *Game) JoinPlayerSceneReq(player *model.Player, payloadMsg pb.Message) {
|
||||
g.JoinOtherWorld(player, hostPlayer)
|
||||
}
|
||||
|
||||
func (g *Game) PlayerGetForceQuitBanInfoReq(player *model.Player, payloadMsg pb.Message) {
|
||||
ok := true
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
if worldPlayer.SceneLoadState != model.SceneEnterDone {
|
||||
ok = false
|
||||
}
|
||||
}
|
||||
|
||||
if !ok {
|
||||
g.SendError(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
|
||||
return
|
||||
}
|
||||
g.SendSucc(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{})
|
||||
// PlayerStartMatchReq 开始匹配请求
|
||||
func (g *Game) PlayerStartMatchReq(player *model.Player, payloadMsg pb.Message) {
|
||||
}
|
||||
|
||||
func (g *Game) BackMyWorldReq(player *model.Player, payloadMsg pb.Message) {
|
||||
// 其他玩家
|
||||
ok := g.PlayerLeaveWorld(player, false)
|
||||
|
||||
if !ok {
|
||||
g.SendError(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
|
||||
return
|
||||
}
|
||||
g.SendSucc(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{})
|
||||
// PlayerCancelMatchReq 取消匹配请求
|
||||
func (g *Game) PlayerCancelMatchReq(player *model.Player, payloadMsg pb.Message) {
|
||||
}
|
||||
|
||||
func (g *Game) ChangeWorldToSingleModeReq(player *model.Player, payloadMsg pb.Message) {
|
||||
// 房主
|
||||
ok := g.PlayerLeaveWorld(player, false)
|
||||
|
||||
if !ok {
|
||||
g.SendError(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
|
||||
return
|
||||
}
|
||||
g.SendSucc(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{})
|
||||
}
|
||||
|
||||
func (g *Game) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.SceneKickPlayerReq)
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
if player.PlayerId != world.GetOwner().PlayerId {
|
||||
g.SendError(cmd.SceneKickPlayerRsp, player, &proto.SceneKickPlayerRsp{})
|
||||
return
|
||||
}
|
||||
targetUid := req.TargetUid
|
||||
targetPlayer := USER_MANAGER.GetOnlineUser(targetUid)
|
||||
if targetPlayer == nil {
|
||||
logger.Error("player is nil, uid: %v", targetUid)
|
||||
return
|
||||
}
|
||||
ok := g.PlayerLeaveWorld(targetPlayer, false)
|
||||
if !ok {
|
||||
g.SendError(cmd.SceneKickPlayerRsp, player, &proto.SceneKickPlayerRsp{}, proto.Retcode_RET_MP_TARGET_PLAYER_IN_TRANSFER)
|
||||
return
|
||||
}
|
||||
|
||||
sceneKickPlayerNotify := &proto.SceneKickPlayerNotify{
|
||||
TargetUid: targetUid,
|
||||
KickerUid: player.PlayerId,
|
||||
}
|
||||
for _, worldPlayer := range world.GetAllPlayer() {
|
||||
g.SendMsg(cmd.SceneKickPlayerNotify, worldPlayer.PlayerId, worldPlayer.ClientSeq, sceneKickPlayerNotify)
|
||||
}
|
||||
|
||||
sceneKickPlayerRsp := &proto.SceneKickPlayerRsp{
|
||||
TargetUid: targetUid,
|
||||
}
|
||||
g.SendMsg(cmd.SceneKickPlayerRsp, player.PlayerId, player.ClientSeq, sceneKickPlayerRsp)
|
||||
// PlayerConfirmMatchReq 确认匹配请求
|
||||
func (g *Game) PlayerConfirmMatchReq(player *model.Player, payloadMsg pb.Message) {
|
||||
}
|
||||
|
||||
/************************************************** 游戏功能 **************************************************/
|
||||
@@ -370,8 +375,9 @@ func (g *Game) HostEnterMpWorld(hostPlayer *model.Player) {
|
||||
g.SendMsg(cmd.PlayerEnterSceneNotify, hostPlayer.PlayerId, hostPlayer.ClientSeq, hostPlayerEnterSceneNotify)
|
||||
}
|
||||
|
||||
func (g *Game) PlayerLeaveWorld(player *model.Player, force bool) bool {
|
||||
func (g *Game) PlayerLeaveWorld(player *model.Player, force bool, reason proto.PlayerQuitFromMpNotify_QuitReason) bool {
|
||||
if force {
|
||||
g.SendMsg(cmd.PlayerQuitFromMpNotify, player.PlayerId, player.ClientSeq, &proto.PlayerQuitFromMpNotify{Reason: reason})
|
||||
g.ReLoginPlayer(player.PlayerId, true)
|
||||
return true
|
||||
}
|
||||
@@ -388,6 +394,7 @@ func (g *Game) PlayerLeaveWorld(player *model.Player, force bool) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
g.SendMsg(cmd.PlayerQuitFromMpNotify, player.PlayerId, player.ClientSeq, &proto.PlayerQuitFromMpNotify{Reason: reason})
|
||||
g.ReLoginPlayer(player.PlayerId, true)
|
||||
return true
|
||||
}
|
||||
@@ -425,7 +432,7 @@ func (g *Game) WorldRemovePlayer(world *World, player *model.Player) {
|
||||
if worldPlayer.PlayerId == world.GetOwner().PlayerId {
|
||||
continue
|
||||
}
|
||||
g.PlayerLeaveWorld(worldPlayer, true)
|
||||
g.PlayerLeaveWorld(worldPlayer, true, proto.PlayerQuitFromMpNotify_KICK_BY_HOST_LOGOUT)
|
||||
}
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
@@ -447,11 +454,6 @@ func (g *Game) WorldRemovePlayer(world *World, player *model.Player) {
|
||||
}
|
||||
|
||||
if world.IsMultiplayerWorld() {
|
||||
playerQuitFromMpNotify := &proto.PlayerQuitFromMpNotify{
|
||||
Reason: proto.PlayerQuitFromMpNotify_BACK_TO_MY_WORLD,
|
||||
}
|
||||
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)})
|
||||
}
|
||||
|
||||
+61
-40
@@ -32,41 +32,6 @@ func (g *Game) AddQuestContentProgressReq(player *model.Player, payloadMsg pb.Me
|
||||
|
||||
/************************************************** 游戏功能 **************************************************/
|
||||
|
||||
// AddQuestProgress 添加任务进度
|
||||
func (g *Game) AddQuestProgress(player *model.Player, req *proto.AddQuestContentProgressReq) {
|
||||
dbQuest := player.GetDbQuest()
|
||||
updateQuestIdList := make([]uint32, 0)
|
||||
for _, quest := range dbQuest.GetQuestMap() {
|
||||
questDataConfig := gdconf.GetQuestDataById(int32(quest.QuestId))
|
||||
if questDataConfig == nil {
|
||||
logger.Error("get quest data config is nil, questId: %v", quest.QuestId)
|
||||
continue
|
||||
}
|
||||
for index, finishCond := range questDataConfig.FinishCondList {
|
||||
if len(finishCond.Param) != 1 {
|
||||
continue
|
||||
}
|
||||
if req.ContentType != uint32(finishCond.Type) || req.Param != uint32(finishCond.Param[0]) {
|
||||
continue
|
||||
}
|
||||
dbQuest.AddQuestProgress(quest.QuestId, index, req.AddProgress)
|
||||
updateQuestIdList = append(updateQuestIdList, quest.QuestId)
|
||||
}
|
||||
}
|
||||
for _, questId := range updateQuestIdList {
|
||||
quest := dbQuest.GetQuestById(questId)
|
||||
if quest == nil {
|
||||
logger.Error("get quest is nil, questId: %v", quest.QuestId)
|
||||
continue
|
||||
}
|
||||
ntf := &proto.QuestProgressUpdateNotify{
|
||||
QuestId: quest.QuestId,
|
||||
FinishProgressList: quest.FinishProgressList,
|
||||
}
|
||||
g.SendMsg(cmd.QuestProgressUpdateNotify, player.PlayerId, player.ClientSeq, ntf)
|
||||
}
|
||||
}
|
||||
|
||||
// AcceptQuest 接取当前条件下能接取到的全部任务
|
||||
func (g *Game) AcceptQuest(player *model.Player, notifyClient bool) {
|
||||
dbQuest := player.GetDbQuest()
|
||||
@@ -149,7 +114,6 @@ func (g *Game) AcceptQuest(player *model.Player, notifyClient bool) {
|
||||
}
|
||||
g.SendMsg(cmd.QuestListUpdateNotify, player.PlayerId, player.ClientSeq, ntf)
|
||||
}
|
||||
// TODO 判断任务是否能开始
|
||||
for _, questId := range addQuestIdList {
|
||||
g.StartQuest(player, questId, notifyClient)
|
||||
}
|
||||
@@ -160,7 +124,7 @@ func (g *Game) StartQuest(player *model.Player, questId uint32, notifyClient boo
|
||||
dbQuest := player.GetDbQuest()
|
||||
dbQuest.StartQuest(questId)
|
||||
|
||||
g.QuestExec(player, questId)
|
||||
g.QuestExec(player, questId, QuestExecTypeStart)
|
||||
g.QuestStartTriggerCheck(player, questId)
|
||||
|
||||
if notifyClient {
|
||||
@@ -176,13 +140,30 @@ func (g *Game) StartQuest(player *model.Player, questId uint32, notifyClient boo
|
||||
}
|
||||
}
|
||||
|
||||
// QuestExec 任务开始执行触发操作
|
||||
func (g *Game) QuestExec(player *model.Player, questId uint32) {
|
||||
const (
|
||||
QuestExecTypeFinish = iota
|
||||
QuestExecTypeFail
|
||||
QuestExecTypeStart
|
||||
)
|
||||
|
||||
// QuestExec 任务执行触发操作
|
||||
func (g *Game) QuestExec(player *model.Player, questId uint32, questExecType int) {
|
||||
questDataConfig := gdconf.GetQuestDataById(int32(questId))
|
||||
if questDataConfig == nil {
|
||||
return
|
||||
}
|
||||
for _, questExec := range questDataConfig.StartExecList {
|
||||
var questExecList []*gdconf.QuestExec = nil
|
||||
switch questExecType {
|
||||
case QuestExecTypeFinish:
|
||||
questExecList = questDataConfig.ExecList
|
||||
case QuestExecTypeFail:
|
||||
questExecList = questDataConfig.FailExecList
|
||||
case QuestExecTypeStart:
|
||||
questExecList = questDataConfig.StartExecList
|
||||
default:
|
||||
return
|
||||
}
|
||||
for _, questExec := range questExecList {
|
||||
switch questExec.Type {
|
||||
case constant.QUEST_EXEC_TYPE_NOTIFY_GROUP_LUA:
|
||||
case constant.QUEST_EXEC_TYPE_REFRESH_GROUP_SUITE:
|
||||
@@ -202,6 +183,42 @@ func (g *Game) QuestExec(player *model.Player, questId uint32) {
|
||||
continue
|
||||
}
|
||||
g.AddSceneGroupSuite(player, uint32(groupId), uint8(suiteId))
|
||||
case constant.QUEST_EXEC_TYPE_SET_OPEN_STATE:
|
||||
if len(questExec.Param) != 2 {
|
||||
continue
|
||||
}
|
||||
key, err := strconv.Atoi(questExec.Param[0])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
value, err := strconv.Atoi(questExec.Param[1])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
g.ChangePlayerOpenState(player, uint32(key), uint32(value))
|
||||
case constant.QUEST_EXEC_TYPE_UNLOCK_POINT:
|
||||
if len(questExec.Param) != 2 {
|
||||
continue
|
||||
}
|
||||
sceneId, err := strconv.Atoi(questExec.Param[0])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
pointId, err := strconv.Atoi(questExec.Param[1])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
g.UnlockPlayerTransPoint(player, uint32(sceneId), uint32(pointId))
|
||||
case constant.QUEST_EXEC_TYPE_UNLOCK_AREA:
|
||||
case constant.QUEST_EXEC_TYPE_CHANGE_AVATAR_ELEMET:
|
||||
if len(questExec.Param) != 1 {
|
||||
continue
|
||||
}
|
||||
elementType, err := strconv.Atoi(questExec.Param[0])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
g.ChangePlayerAvatarElementType(player, elementType)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,6 +302,9 @@ func (g *Game) TriggerQuest(player *model.Player, cond int32, complexParam strin
|
||||
dbQuest.ForceFinishQuest(quest.QuestId)
|
||||
updateQuestIdList = append(updateQuestIdList, quest.QuestId)
|
||||
}
|
||||
if quest.State == constant.QUEST_STATE_FINISHED {
|
||||
g.QuestExec(player, quest.QuestId, QuestExecTypeFinish)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(updateQuestIdList) > 0 {
|
||||
@@ -337,6 +357,7 @@ func (g *Game) TriggerQuest(player *model.Player, cond int32, complexParam strin
|
||||
ParentQuestState: 1,
|
||||
IsFinished: true,
|
||||
ChildQuestList: childQuestList,
|
||||
QuestVar: make([]int32, 5),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+12
-3
@@ -840,9 +840,6 @@ func (g *Game) GetNeighborGroup(sceneId uint32, pos *model.Vector) map[uint32]*g
|
||||
|
||||
// AddSceneGroup 加载场景组
|
||||
func (g *Game) AddSceneGroup(player *model.Player, scene *Scene, groupConfig *gdconf.Group) {
|
||||
if groupConfig == nil {
|
||||
return
|
||||
}
|
||||
group := scene.GetGroupById(uint32(groupConfig.Id))
|
||||
if group != nil {
|
||||
return
|
||||
@@ -853,6 +850,7 @@ func (g *Game) AddSceneGroup(player *model.Player, scene *Scene, groupConfig *gd
|
||||
logger.Error("invalid suiteId: %v, uid: %v", initSuiteId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
// logger.Debug("add scene group, groupId: %v, initSuiteId: %v, uid: %v", groupConfig.Id, initSuiteId, player.PlayerId)
|
||||
g.AddSceneGroupSuiteCore(player, scene, uint32(groupConfig.Id), uint8(initSuiteId))
|
||||
// ntf := &proto.GroupSuiteNotify{
|
||||
// GroupMap: make(map[uint32]uint32),
|
||||
@@ -884,6 +882,12 @@ func (g *Game) AddSceneGroup(player *model.Player, scene *Scene, groupConfig *gd
|
||||
|
||||
// RemoveSceneGroup 卸载场景组
|
||||
func (g *Game) RemoveSceneGroup(player *model.Player, scene *Scene, groupConfig *gdconf.Group) {
|
||||
// logger.Debug("remove scene group, groupId: %v, uid: %v", groupConfig.Id, player.PlayerId)
|
||||
for _, triggerData := range gdconf.GetTriggerDataMap() {
|
||||
if groupConfig.Id == triggerData.GroupId {
|
||||
return
|
||||
}
|
||||
}
|
||||
group := scene.GetGroupById(uint32(groupConfig.Id))
|
||||
if group == nil {
|
||||
// logger.Error("group not exist, groupId: %v, uid: %v", groupConfig.Id, player.PlayerId)
|
||||
@@ -901,6 +905,7 @@ func (g *Game) RemoveSceneGroup(player *model.Player, scene *Scene, groupConfig
|
||||
|
||||
// AddSceneGroupSuite 向场景组中添加场景小组
|
||||
func (g *Game) AddSceneGroupSuite(player *model.Player, groupId uint32, suiteId uint8) {
|
||||
// logger.Debug("add scene group suite, groupId: %v, suiteId: %v, uid: %v", groupId, suiteId, player.PlayerId)
|
||||
groupConfig := gdconf.GetSceneGroup(int32(groupId))
|
||||
if groupConfig == nil {
|
||||
logger.Error("get group config is nil, groupId: %v, uid: %v", groupId, player.PlayerId)
|
||||
@@ -1177,6 +1182,10 @@ func (g *Game) CreateMonster(player *model.Player, pos *model.Vector, monsterId
|
||||
|
||||
// CreateGadget 创建物件实体
|
||||
func (g *Game) CreateGadget(player *model.Player, pos *model.Vector, gadgetId uint32, normalEntity *GadgetNormalEntity) uint32 {
|
||||
if gadgetId == 0 {
|
||||
logger.Error("create gadget id is zero, pos: %+v, normalEntity: %+v, uid: %v", pos, normalEntity, player.PlayerId)
|
||||
return 0
|
||||
}
|
||||
if normalEntity == nil {
|
||||
normalEntity = &GadgetNormalEntity{
|
||||
isDrop: false,
|
||||
|
||||
@@ -418,14 +418,7 @@ func (g *Game) SetPlayerStamina(player *model.Player, stamina uint32) {
|
||||
// 设置玩家的耐力
|
||||
player.PropMap[constant.PLAYER_PROP_CUR_PERSIST_STAMINA] = stamina
|
||||
// logger.Debug("player stamina set, stamina: %v", stamina)
|
||||
g.PlayerPropNotify(player, constant.PLAYER_PROP_CUR_PERSIST_STAMINA)
|
||||
g.SendMsg(cmd.PlayerPropNotify, player.PlayerId, player.ClientSeq, g.PacketPlayerPropNotify(player, constant.PLAYER_PROP_CUR_PERSIST_STAMINA))
|
||||
}
|
||||
|
||||
/************************************************** 打包封装 **************************************************/
|
||||
|
||||
func (g *Game) PlayerPropNotify(player *model.Player, playerPropId uint32) {
|
||||
playerPropNotify := new(proto.PlayerPropNotify)
|
||||
playerPropNotify.PropMap = make(map[uint32]*proto.PropValue)
|
||||
playerPropNotify.PropMap[playerPropId] = g.PacketPropValue(playerPropId, int64(player.PropMap[playerPropId]))
|
||||
g.SendMsg(cmd.PlayerPropNotify, player.PlayerId, player.ClientSeq, playerPropNotify)
|
||||
}
|
||||
+42
-36
@@ -363,17 +363,37 @@ func (g *Game) PacketSceneTeamUpdateNotify(world *World, player *model.Player) *
|
||||
SgvDynamicValueMap: nil,
|
||||
},
|
||||
WeaponAbilityInfo: empty,
|
||||
AbilityControlBlock: new(proto.AbilityControlBlock),
|
||||
AbilityControlBlock: g.PacketAbilityControlBlock(worldAvatar.GetAvatarId(), worldPlayerAvatar.SkillDepotId),
|
||||
}
|
||||
if world.IsMultiplayerWorld() {
|
||||
sceneTeamAvatar.AvatarInfo = g.PacketAvatarInfo(worldPlayerAvatar)
|
||||
sceneTeamAvatar.SceneAvatarInfo = g.PacketSceneAvatarInfo(worldPlayerScene, worldPlayer, worldAvatar.GetAvatarId())
|
||||
}
|
||||
// 角色的ability控制块
|
||||
acb := sceneTeamAvatar.AbilityControlBlock
|
||||
abilityId := 0
|
||||
// 默认ability
|
||||
for _, abilityHashCode := range constant.DEFAULT_ABILITY_HASH_CODE {
|
||||
sceneTeamUpdateNotify.SceneTeamAvatarList = append(sceneTeamUpdateNotify.SceneTeamAvatarList, sceneTeamAvatar)
|
||||
}
|
||||
return sceneTeamUpdateNotify
|
||||
}
|
||||
|
||||
// PacketAbilityControlBlock 角色的ability控制块
|
||||
func (g *Game) PacketAbilityControlBlock(avatarId uint32, skillDepotId uint32) *proto.AbilityControlBlock {
|
||||
acb := &proto.AbilityControlBlock{
|
||||
AbilityEmbryoList: make([]*proto.AbilityEmbryo, 0),
|
||||
}
|
||||
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(avatarId))
|
||||
if avatarDataConfig != nil {
|
||||
for _, abilityHashCode := range avatarDataConfig.AbilityHashCodeList {
|
||||
abilityId++
|
||||
ae := &proto.AbilityEmbryo{
|
||||
AbilityId: uint32(abilityId),
|
||||
@@ -382,35 +402,21 @@ func (g *Game) PacketSceneTeamUpdateNotify(world *World, player *model.Player) *
|
||||
}
|
||||
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, ae)
|
||||
}
|
||||
// 角色ability
|
||||
avatarDataConfig := gdconf.GetAvatarDataById(int32(worldAvatar.GetAvatarId()))
|
||||
if avatarDataConfig != nil {
|
||||
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, ae)
|
||||
}
|
||||
}
|
||||
// 技能库ability
|
||||
skillDepot := gdconf.GetAvatarSkillDepotDataById(int32(worldPlayerAvatar.SkillDepotId))
|
||||
if skillDepot != nil && len(skillDepot.AbilityHashCodeList) != 0 {
|
||||
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, ae)
|
||||
}
|
||||
}
|
||||
// TODO 队伍ability
|
||||
// TODO 装备ability
|
||||
sceneTeamUpdateNotify.SceneTeamAvatarList = append(sceneTeamUpdateNotify.SceneTeamAvatarList, sceneTeamAvatar)
|
||||
}
|
||||
return sceneTeamUpdateNotify
|
||||
// 技能库ability
|
||||
skillDepot := gdconf.GetAvatarSkillDepotDataById(int32(skillDepotId))
|
||||
if skillDepot != nil && len(skillDepot.AbilityHashCodeList) != 0 {
|
||||
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, ae)
|
||||
}
|
||||
}
|
||||
// TODO 队伍ability
|
||||
// TODO 装备ability
|
||||
return acb
|
||||
}
|
||||
+68
-45
@@ -71,32 +71,12 @@ func (g *Game) SceneTransToPointReq(player *model.Player, payloadMsg pb.Message)
|
||||
func (g *Game) UnlockTransPointReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.UnlockTransPointReq)
|
||||
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
g.SendError(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{})
|
||||
ret := g.UnlockPlayerTransPoint(player, req.SceneId, req.PointId)
|
||||
if ret != proto.Retcode_RET_SUCC {
|
||||
g.SendError(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{}, ret)
|
||||
return
|
||||
}
|
||||
owner := world.GetOwner()
|
||||
dbWorld := owner.GetDbWorld()
|
||||
dbScene := dbWorld.GetSceneById(req.SceneId)
|
||||
if dbScene == nil {
|
||||
g.SendError(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{}, proto.Retcode_RET_POINT_NOT_UNLOCKED)
|
||||
return
|
||||
}
|
||||
unlock := dbScene.CheckPointUnlock(req.PointId)
|
||||
if unlock {
|
||||
g.SendError(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{}, proto.Retcode_RET_POINT_ALREAY_UNLOCKED)
|
||||
return
|
||||
}
|
||||
dbScene.UnlockPoint(req.PointId)
|
||||
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_UNLOCK_TRANS_POINT, "", int32(req.SceneId), int32(req.PointId))
|
||||
|
||||
g.SendMsg(cmd.ScenePointUnlockNotify, player.PlayerId, player.ClientSeq, &proto.ScenePointUnlockNotify{
|
||||
SceneId: req.SceneId,
|
||||
PointList: []uint32{req.PointId},
|
||||
UnhidePointList: nil,
|
||||
})
|
||||
g.SendSucc(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{})
|
||||
}
|
||||
|
||||
@@ -106,25 +86,25 @@ func (g *Game) GetScenePointReq(player *model.Player, payloadMsg pb.Message) {
|
||||
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("world is nil, worldId: %v, uid: %v", world.GetId(), player.PlayerId)
|
||||
logger.Error("get world is nil, worldId: %v, uid: %v", world.GetId(), player.PlayerId)
|
||||
g.SendError(cmd.GetScenePointRsp, player, &proto.GetScenePointRsp{})
|
||||
return
|
||||
}
|
||||
owner := world.GetOwner()
|
||||
if owner == nil {
|
||||
logger.Error("owner is nil, worldId: %v", world.GetId())
|
||||
logger.Error("get owner is nil, worldId: %v", world.GetId())
|
||||
g.SendError(cmd.GetScenePointRsp, player, &proto.GetScenePointRsp{})
|
||||
return
|
||||
}
|
||||
dbWorld := owner.GetDbWorld()
|
||||
if dbWorld == nil {
|
||||
logger.Error("db world is nil, uid: %v", player.PlayerId)
|
||||
logger.Error("get dbWorld is nil, uid: %v", player.PlayerId)
|
||||
g.SendError(cmd.GetScenePointRsp, player, &proto.GetScenePointRsp{})
|
||||
return
|
||||
}
|
||||
dbScene := dbWorld.GetSceneById(req.SceneId)
|
||||
if dbScene == nil {
|
||||
logger.Error("db scene is nil, sceneId: %v, uid: %v", req.SceneId, player.PlayerId)
|
||||
logger.Error("get dbScene is nil, sceneId: %v, uid: %v", req.SceneId, player.PlayerId)
|
||||
g.SendError(cmd.GetScenePointRsp, player, &proto.GetScenePointRsp{})
|
||||
return
|
||||
}
|
||||
@@ -298,7 +278,15 @@ func (g *Game) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Message) {
|
||||
logger.Error("scene is nil, sceneId: %v, uid: %v", player.SceneId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
g.ChangeGameTime(player, scene, gameTime)
|
||||
logger.Debug("change game time, gameTime: %v, uid: %v", gameTime, player.PlayerId)
|
||||
g.ChangeGameTime(scene, gameTime)
|
||||
|
||||
// 设置玩家天气
|
||||
climateType := GAME.GetWeatherAreaClimate(player.WeatherInfo.WeatherAreaId)
|
||||
// 跳过相同的天气
|
||||
if climateType != player.WeatherInfo.ClimateType {
|
||||
g.SetPlayerWeather(player, player.WeatherInfo.WeatherAreaId, climateType)
|
||||
}
|
||||
|
||||
changeGameTimeRsp := &proto.ChangeGameTimeRsp{
|
||||
CurGameTime: scene.GetGameTime(),
|
||||
@@ -454,6 +442,10 @@ func (g *Game) GadgetInteractReq(player *model.Player, payloadMsg pb.Message) {
|
||||
case constant.GADGET_TYPE_ENERGY_BALL:
|
||||
// TODO 元素能量球吸收
|
||||
interactType = proto.InteractType_INTERACT_PICK_ITEM
|
||||
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
||||
dbAvatar := player.GetDbAvatar()
|
||||
dbAvatar.SetCurrEnergy(activeAvatarId, 0, true)
|
||||
g.UpdatePlayerAvatarFightProp(player.PlayerId, activeAvatarId)
|
||||
case constant.GADGET_TYPE_GATHER_OBJECT:
|
||||
// 采集物摘取
|
||||
interactType = proto.InteractType_INTERACT_GATHER
|
||||
@@ -520,11 +512,31 @@ func (g *Game) ExitTransPointRegionNotify(player *model.Player, payloadMsg pb.Me
|
||||
|
||||
/************************************************** 游戏功能 **************************************************/
|
||||
|
||||
// ChangeGameTime 修改游戏场景时间
|
||||
func (g *Game) ChangeGameTime(player *model.Player, scene *Scene, gameTime uint32) {
|
||||
logger.Debug("change game time, gameTime: %v, uid: %v", gameTime, player.PlayerId)
|
||||
scene.ChangeGameTime(gameTime)
|
||||
// UnlockPlayerTransPoint 解锁锚点
|
||||
func (g *Game) UnlockPlayerTransPoint(player *model.Player, sceneId uint32, pointId uint32) proto.Retcode {
|
||||
dbWorld := player.GetDbWorld()
|
||||
dbScene := dbWorld.GetSceneById(sceneId)
|
||||
if dbScene == nil {
|
||||
logger.Error("get dbScene is nil, sceneId: %v, uid: %v", sceneId, player.PlayerId)
|
||||
return proto.Retcode_RET_POINT_NOT_UNLOCKED
|
||||
}
|
||||
unlock := dbScene.CheckPointUnlock(pointId)
|
||||
if unlock {
|
||||
logger.Error("point already unlock, sceneId: %v, pointId: %v, uid: %v", sceneId, pointId, player.PlayerId)
|
||||
return proto.Retcode_RET_POINT_ALREAY_UNLOCKED
|
||||
}
|
||||
dbScene.UnlockPoint(pointId)
|
||||
GAME.SendMsg(cmd.ScenePointUnlockNotify, player.PlayerId, player.ClientSeq, &proto.ScenePointUnlockNotify{
|
||||
SceneId: sceneId,
|
||||
PointList: []uint32{pointId},
|
||||
})
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_UNLOCK_TRANS_POINT, "", int32(sceneId), int32(pointId))
|
||||
return proto.Retcode_RET_SUCC
|
||||
}
|
||||
|
||||
// ChangeGameTime 修改游戏场景时间
|
||||
func (g *Game) ChangeGameTime(scene *Scene, gameTime uint32) {
|
||||
scene.ChangeGameTime(gameTime)
|
||||
for _, scenePlayer := range scene.GetAllPlayer() {
|
||||
playerGameTimeNotify := &proto.PlayerGameTimeNotify{
|
||||
GameTime: scene.GetGameTime(),
|
||||
@@ -532,14 +544,6 @@ func (g *Game) ChangeGameTime(player *model.Player, scene *Scene, gameTime uint3
|
||||
}
|
||||
g.SendMsg(cmd.PlayerGameTimeNotify, scenePlayer.PlayerId, scenePlayer.ClientSeq, playerGameTimeNotify)
|
||||
}
|
||||
|
||||
// 设置玩家天气
|
||||
climateType := GAME.GetWeatherAreaClimate(player.WeatherInfo.WeatherAreaId)
|
||||
// 跳过相同的天气
|
||||
if climateType == player.WeatherInfo.ClimateType {
|
||||
return
|
||||
}
|
||||
GAME.SetPlayerWeather(player, player.WeatherInfo.WeatherAreaId, climateType)
|
||||
}
|
||||
|
||||
func (g *Game) monsterDrop(player *model.Player, entity *Entity) {
|
||||
@@ -549,9 +553,20 @@ func (g *Game) monsterDrop(player *model.Player, entity *Entity) {
|
||||
return
|
||||
}
|
||||
monsterConfig := sceneGroupConfig.MonsterMap[int32(entity.GetConfigId())]
|
||||
monsterDropDataConfig := gdconf.GetMonsterDropDataByDropTagAndLevel(monsterConfig.DropTag, monsterConfig.Level)
|
||||
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)
|
||||
logger.Error("get monster drop data config is nil, monsterConfig: %+v, uid: %v", monsterConfig, player.PlayerId)
|
||||
return
|
||||
}
|
||||
dropDataConfig := gdconf.GetDropDataById(monsterDropDataConfig.DropId)
|
||||
@@ -566,7 +581,11 @@ func (g *Game) monsterDrop(player *model.Player, entity *Entity) {
|
||||
logger.Error("get item data config is nil, itemId: %v, uid: %v", itemId, player.PlayerId)
|
||||
continue
|
||||
}
|
||||
g.CreateDropGadget(player, entity.GetPos(), uint32(itemDataConfig.GadgetId), itemId, count)
|
||||
if itemDataConfig.GadgetId != 0 {
|
||||
g.CreateDropGadget(player, entity.GetPos(), uint32(itemDataConfig.GadgetId), itemId, count)
|
||||
} else {
|
||||
g.AddPlayerItem(player.PlayerId, []*ChangeItem{{ItemId: itemId, ChangeCount: count}}, true, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,7 +598,7 @@ func (g *Game) chestDrop(player *model.Player, entity *Entity) {
|
||||
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)
|
||||
logger.Error("get chest drop data config is nil, gadgetConfig: %+v, uid: %v", gadgetConfig, player.PlayerId)
|
||||
return
|
||||
}
|
||||
dropDataConfig := gdconf.GetDropDataById(chestDropDataConfig.DropId)
|
||||
@@ -594,7 +613,11 @@ func (g *Game) chestDrop(player *model.Player, entity *Entity) {
|
||||
logger.Error("get item data config is nil, itemId: %v, uid: %v", itemId, player.PlayerId)
|
||||
continue
|
||||
}
|
||||
g.CreateDropGadget(player, entity.GetPos(), uint32(itemDataConfig.GadgetId), itemId, count)
|
||||
if itemDataConfig.GadgetId != 0 {
|
||||
g.CreateDropGadget(player, entity.GetPos(), uint32(itemDataConfig.GadgetId), itemId, count)
|
||||
} else {
|
||||
g.AddPlayerItem(player.PlayerId, []*ChangeItem{{ItemId: itemId, ChangeCount: count}}, true, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+41
-43
@@ -102,7 +102,14 @@ func (a *DbAvatar) InitAvatarFightProp(avatar *Avatar) {
|
||||
avatar.FightPropMap[constant.FIGHT_PROP_CRITICAL_HURT] = avatarDataConfig.CriticalHurt
|
||||
// 元素充能
|
||||
avatar.FightPropMap[constant.FIGHT_PROP_CHARGE_EFFICIENCY] = 1.0
|
||||
a.SetCurrEnergy(avatar, avatar.CurrEnergy, true)
|
||||
avatarSkillDataConfig := gdconf.GetAvatarEnergySkillConfig(avatar.SkillDepotId)
|
||||
if avatarSkillDataConfig == nil {
|
||||
logger.Error("get avatar energy skill is nil, skillDepotId: %v", avatar.SkillDepotId)
|
||||
return
|
||||
}
|
||||
fightPropEnergy := constant.ELEMENT_TYPE_FIGHT_PROP_ENERGY_MAP[int(avatarSkillDataConfig.CostElemType)]
|
||||
avatar.FightPropMap[uint32(fightPropEnergy.MaxEnergy)] = float32(avatarSkillDataConfig.CostElemVal)
|
||||
avatar.FightPropMap[uint32(fightPropEnergy.CurEnergy)] = float32(avatar.CurrEnergy)
|
||||
}
|
||||
|
||||
func (a *DbAvatar) AddAvatar(player *Player, avatarId uint32) {
|
||||
@@ -111,20 +118,6 @@ func (a *DbAvatar) AddAvatar(player *Player, avatarId uint32) {
|
||||
logger.Error("avatar data config is nil, avatarId: %v", avatarId)
|
||||
return
|
||||
}
|
||||
skillDepotId := int32(0)
|
||||
// 主角可以切换属性 技能库要单独设置 这里默认给风元素的技能库
|
||||
if avatarId == 10000005 {
|
||||
skillDepotId = 504
|
||||
} else if avatarId == 10000007 {
|
||||
skillDepotId = 704
|
||||
} else {
|
||||
skillDepotId = avatarDataConfig.SkillDepotId
|
||||
}
|
||||
avatarSkillDepotDataConfig := gdconf.GetAvatarSkillDepotDataById(skillDepotId)
|
||||
if avatarSkillDepotDataConfig == nil {
|
||||
logger.Error("avatar skill depot data config is nil, skillDepotId: %v", skillDepotId)
|
||||
return
|
||||
}
|
||||
avatar := &Avatar{
|
||||
AvatarId: avatarId,
|
||||
LifeState: constant.LIFE_STATE_ALIVE,
|
||||
@@ -137,7 +130,7 @@ func (a *DbAvatar) AddAvatar(player *Player, avatarId uint32) {
|
||||
CurrEnergy: 0,
|
||||
FetterList: make([]uint32, 0),
|
||||
SkillLevelMap: make(map[uint32]uint32),
|
||||
SkillDepotId: uint32(skillDepotId),
|
||||
SkillDepotId: 0,
|
||||
FlyCloak: 140001,
|
||||
Costume: 0,
|
||||
BornTime: time.Now().Unix(),
|
||||
@@ -151,47 +144,52 @@ func (a *DbAvatar) AddAvatar(player *Player, avatarId uint32) {
|
||||
PromoteRewardMap: make(map[uint32]bool, len(avatarDataConfig.PromoteRewardMap)),
|
||||
}
|
||||
|
||||
avatar.CurrHP = float64(avatarDataConfig.GetBaseHpByLevel(avatar.Level))
|
||||
// 角色突破奖励领取状态
|
||||
for promoteLevel := range avatarDataConfig.PromoteRewardMap {
|
||||
avatar.PromoteRewardMap[promoteLevel] = false
|
||||
}
|
||||
|
||||
a.AvatarMap[avatarId] = avatar
|
||||
a.SwitchSkillDepot(avatarId, uint32(avatarDataConfig.SkillDepotId))
|
||||
a.InitAvatar(player, avatar)
|
||||
}
|
||||
|
||||
func (a *DbAvatar) SwitchSkillDepot(avatarId uint32, skillDepotId uint32) {
|
||||
avatar, exist := a.AvatarMap[avatarId]
|
||||
if !exist {
|
||||
logger.Error("avatar not exist, avatarId: %v", avatarId)
|
||||
return
|
||||
}
|
||||
avatarSkillDepotDataConfig := gdconf.GetAvatarSkillDepotDataById(int32(skillDepotId))
|
||||
if avatarSkillDepotDataConfig == nil {
|
||||
logger.Error("avatar skill depot data config is nil, skillDepotId: %v", skillDepotId)
|
||||
return
|
||||
}
|
||||
avatar.SkillDepotId = skillDepotId
|
||||
// 元素爆发1级
|
||||
avatar.SkillLevelMap[uint32(avatarSkillDepotDataConfig.EnergySkill)] = 1
|
||||
for _, skillId := range avatarSkillDepotDataConfig.Skills {
|
||||
// 小技能1级
|
||||
avatar.SkillLevelMap[uint32(skillId)] = 1
|
||||
}
|
||||
avatar.CurrHP = float64(avatarDataConfig.GetBaseHpByLevel(avatar.Level))
|
||||
|
||||
// 角色突破奖励领取状态
|
||||
for promoteLevel := range avatarDataConfig.PromoteRewardMap {
|
||||
avatar.PromoteRewardMap[promoteLevel] = false
|
||||
}
|
||||
|
||||
a.InitAvatar(player, avatar)
|
||||
a.AvatarMap[avatarId] = avatar
|
||||
}
|
||||
|
||||
func (a *DbAvatar) SetCurrEnergy(avatar *Avatar, value float64, max bool) {
|
||||
var avatarSkillDataConfig *gdconf.AvatarSkillData = nil
|
||||
if avatar.AvatarId == 10000005 || avatar.AvatarId == 10000007 {
|
||||
avatarSkillDepotDataConfig := gdconf.GetAvatarSkillDepotDataById(int32(avatar.SkillDepotId))
|
||||
if avatarSkillDepotDataConfig == nil {
|
||||
return
|
||||
}
|
||||
avatarSkillDataConfig = gdconf.GetAvatarSkillDataById(avatarSkillDepotDataConfig.EnergySkill)
|
||||
if avatarSkillDataConfig == nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
avatarSkillDataConfig = gdconf.GetAvatarEnergySkillConfig(avatar.AvatarId)
|
||||
func (a *DbAvatar) SetCurrEnergy(avatarId uint32, value float64, max bool) {
|
||||
avatar, exist := a.AvatarMap[avatarId]
|
||||
if !exist {
|
||||
logger.Error("avatar not exist, avatarId: %v", avatarId)
|
||||
return
|
||||
}
|
||||
avatarSkillDataConfig := gdconf.GetAvatarEnergySkillConfig(avatar.SkillDepotId)
|
||||
if avatarSkillDataConfig == nil {
|
||||
logger.Error("get avatar energy skill is nil, avatarId: %v", avatar.AvatarId)
|
||||
logger.Error("get avatar energy skill is nil, skillDepotId: %v", avatar.SkillDepotId)
|
||||
return
|
||||
}
|
||||
fightPropEnergy := constant.ELEMENT_TYPE_FIGHT_PROP_ENERGY_MAP[int(avatarSkillDataConfig.CostElemType)]
|
||||
avatar.FightPropMap[uint32(fightPropEnergy.MaxEnergy)] = float32(avatarSkillDataConfig.CostElemVal)
|
||||
if max {
|
||||
avatar.FightPropMap[uint32(fightPropEnergy.CurEnergy)] = float32(avatarSkillDataConfig.CostElemVal)
|
||||
avatar.CurrEnergy = float64(avatarSkillDataConfig.CostElemVal)
|
||||
} else {
|
||||
avatar.FightPropMap[uint32(fightPropEnergy.CurEnergy)] = float32(value)
|
||||
avatar.CurrEnergy = value
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@ type Player struct {
|
||||
OfflineTime uint32 // 离线时间点
|
||||
TotalOnlineTime uint32 // 累计在线时长
|
||||
PropMap map[uint32]uint32 // 玩家属性表
|
||||
OpenStateMap map[uint32]uint32 // 功能开放状态
|
||||
SceneId uint32 // 场景
|
||||
Pos *Vector // 坐标
|
||||
Rot *Vector // 朝向
|
||||
@@ -79,7 +80,7 @@ type Player struct {
|
||||
WeatherInfo *WeatherInfo `bson:"-" msgpack:"-"` // 天气信息
|
||||
ClientVersion int `bson:"-" msgpack:"-"` // 玩家在线的客户端版本
|
||||
OfflineClear bool `bson:"-" msgpack:"-"` // 是否离线时清除账号数据
|
||||
OfflineNotSave bool `bson:"-" msgpack:"-"` // 是否离线时不保存账号数据
|
||||
NotSave bool `bson:"-" msgpack:"-"` // 是否离线回档
|
||||
RemoteWorldPlayerNum uint32 `bson:"-" msgpack:"-"` // 远程展示世界内人数
|
||||
// 特殊数据
|
||||
ChatMsgMap map[uint32][]*ChatMsg `bson:"-" msgpack:"-"` // 聊天信息 数据量偏大 只从db读写 不保存到redis
|
||||
|
||||
@@ -60,7 +60,8 @@ func (c *CmdProtoMap) registerMessage() {
|
||||
c.regMsg(WorldPlayerRTTNotify, func() any { return new(proto.WorldPlayerRTTNotify) }) // 世界玩家RTT时延
|
||||
c.regMsg(PlayerDataNotify, func() any { return new(proto.PlayerDataNotify) }) // 玩家信息通知 昵称、属性表等
|
||||
c.regMsg(PlayerPropNotify, func() any { return new(proto.PlayerPropNotify) }) // 玩家属性表通知
|
||||
c.regMsg(OpenStateUpdateNotify, func() any { return new(proto.OpenStateUpdateNotify) }) // 游戏功能模块开放状态更新通知
|
||||
c.regMsg(OpenStateUpdateNotify, func() any { return new(proto.OpenStateUpdateNotify) }) // 功能开放状态更新通知
|
||||
c.regMsg(OpenStateChangeNotify, func() any { return new(proto.OpenStateChangeNotify) }) // 功能开放状态改变通知
|
||||
c.regMsg(PlayerTimeNotify, func() any { return new(proto.PlayerTimeNotify) }) // 玩家累计在线时长通知
|
||||
c.regMsg(ServerTimeNotify, func() any { return new(proto.ServerTimeNotify) }) // 服务器时间通知
|
||||
c.regMsg(WindSeedClientNotify, func() any { return new(proto.WindSeedClientNotify) }) // 客户端XLUA调试通知
|
||||
@@ -74,8 +75,8 @@ func (c *CmdProtoMap) registerMessage() {
|
||||
c.regMsg(GmTalkNotify, func() any { return new(proto.GmTalkNotify) }) // GM命令执行通知
|
||||
c.regMsg(SetPlayerPropReq, func() any { return new(proto.SetPlayerPropReq) }) // 设置玩家属性表请求
|
||||
c.regMsg(SetPlayerPropRsp, func() any { return new(proto.SetPlayerPropRsp) }) // 设置玩家属性表响应
|
||||
c.regMsg(SetOpenStateReq, func() any { return new(proto.SetOpenStateReq) }) // 设置游戏功能模块开放状态请求
|
||||
c.regMsg(SetOpenStateRsp, func() any { return new(proto.SetOpenStateRsp) }) // 设置游戏功能模块开放状态响应
|
||||
c.regMsg(SetOpenStateReq, func() any { return new(proto.SetOpenStateReq) }) // 设置功能开放状态请求
|
||||
c.regMsg(SetOpenStateRsp, func() any { return new(proto.SetOpenStateRsp) }) // 设置功能开放状态响应
|
||||
|
||||
// 场景
|
||||
c.regMsg(PlayerSetPauseReq, func() any { return new(proto.PlayerSetPauseReq) }) // 玩家暂停请求
|
||||
@@ -190,6 +191,7 @@ func (c *CmdProtoMap) registerMessage() {
|
||||
c.regMsg(EvtAiSyncCombatThreatInfoNotify, func() any { return new(proto.EvtAiSyncCombatThreatInfoNotify) }) // 通知
|
||||
c.regMsg(EntityConfigHashNotify, func() any { return new(proto.EntityConfigHashNotify) }) // 通知
|
||||
c.regMsg(MonsterAIConfigHashNotify, func() any { return new(proto.MonsterAIConfigHashNotify) }) // 通知
|
||||
c.regMsg(AbilityChangeNotify, func() any { return new(proto.AbilityChangeNotify) }) // ability切换通知
|
||||
|
||||
// 队伍
|
||||
c.regMsg(ChangeAvatarReq, func() any { return new(proto.ChangeAvatarReq) }) // 更换角色请求 切人
|
||||
@@ -233,6 +235,16 @@ func (c *CmdProtoMap) registerMessage() {
|
||||
c.regMsg(GuestBeginEnterSceneNotify, func() any { return new(proto.GuestBeginEnterSceneNotify) }) // 他人开始进入世界通知
|
||||
c.regMsg(GuestPostEnterSceneNotify, func() any { return new(proto.GuestPostEnterSceneNotify) }) // 他人进入世界完成通知
|
||||
c.regMsg(PlayerPreEnterMpNotify, func() any { return new(proto.PlayerPreEnterMpNotify) }) // 他人正在进入世界通知
|
||||
c.regMsg(PlayerStartMatchReq, func() any { return new(proto.PlayerStartMatchReq) }) // 开始匹配请求
|
||||
c.regMsg(PlayerStartMatchRsp, func() any { return new(proto.PlayerStartMatchRsp) }) // 开始匹配响应
|
||||
c.regMsg(PlayerCancelMatchReq, func() any { return new(proto.PlayerCancelMatchReq) }) // 取消匹配请求
|
||||
c.regMsg(PlayerCancelMatchRsp, func() any { return new(proto.PlayerCancelMatchRsp) }) // 取消匹配响应
|
||||
c.regMsg(PlayerConfirmMatchReq, func() any { return new(proto.PlayerConfirmMatchReq) }) // 确认匹配请求
|
||||
c.regMsg(PlayerConfirmMatchRsp, func() any { return new(proto.PlayerConfirmMatchRsp) }) // 确认匹配响应
|
||||
c.regMsg(PlayerMatchInfoNotify, func() any { return new(proto.PlayerMatchInfoNotify) }) // 匹配信息通知
|
||||
c.regMsg(PlayerMatchStopNotify, func() any { return new(proto.PlayerMatchStopNotify) }) // 匹配停止通知
|
||||
c.regMsg(PlayerMatchSuccNotify, func() any { return new(proto.PlayerMatchSuccNotify) }) // 匹配成功通知
|
||||
c.regMsg(PlayerMatchAgreedResultNotify, func() any { return new(proto.PlayerMatchAgreedResultNotify) }) // 匹配允许进入世界通知
|
||||
|
||||
// 社交
|
||||
c.regMsg(SetPlayerBirthdayReq, func() any { return new(proto.SetPlayerBirthdayReq) }) // 设置生日请求
|
||||
@@ -350,25 +362,24 @@ func (c *CmdProtoMap) registerMessage() {
|
||||
c.regMsg(VehicleInteractRsp, func() any { return new(proto.VehicleInteractRsp) }) // 载具交互响应
|
||||
c.regMsg(VehicleStaminaNotify, func() any { return new(proto.VehicleStaminaNotify) }) // 载具耐力消耗通知
|
||||
|
||||
// 七圣召唤
|
||||
c.regMsg(GCGBasicDataNotify, func() any { return new(proto.GCGBasicDataNotify) }) // GCG基本数据通知
|
||||
c.regMsg(GCGLevelChallengeNotify, func() any { return new(proto.GCGLevelChallengeNotify) }) // GCG等级挑战通知
|
||||
c.regMsg(GCGDSBanCardNotify, func() any { return new(proto.GCGDSBanCardNotify) }) // GCG禁止的卡牌通知
|
||||
c.regMsg(GCGDSDataNotify, func() any { return new(proto.GCGDSDataNotify) }) // GCG数据通知 (解锁的内容)
|
||||
c.regMsg(GCGTCTavernChallengeDataNotify, func() any { return new(proto.GCGTCTavernChallengeDataNotify) }) // GCG酒馆挑战数据通知
|
||||
c.regMsg(GCGTCTavernInfoNotify, func() any { return new(proto.GCGTCTavernInfoNotify) }) // GCG酒馆信息通知
|
||||
c.regMsg(GCGTavernNpcInfoNotify, func() any { return new(proto.GCGTavernNpcInfoNotify) }) // GCG酒馆NPC信息通知
|
||||
c.regMsg(GCGGameBriefDataNotify, func() any { return new(proto.GCGGameBriefDataNotify) }) // GCG游戏简要数据通知
|
||||
c.regMsg(GCGAskDuelReq, func() any { return new(proto.GCGAskDuelReq) }) // GCG游戏对局信息请求
|
||||
c.regMsg(GCGAskDuelRsp, func() any { return new(proto.GCGAskDuelRsp) }) // GCG游戏对局信息响应
|
||||
c.regMsg(GCGInitFinishReq, func() any { return new(proto.GCGInitFinishReq) }) // GCG游戏初始化完成请求
|
||||
c.regMsg(GCGInitFinishRsp, func() any { return new(proto.GCGInitFinishRsp) }) // GCG游戏初始化完成响应
|
||||
c.regMsg(GCGMessagePackNotify, func() any { return new(proto.GCGMessagePackNotify) }) // GCG游戏消息包通知
|
||||
c.regMsg(GCGHeartBeatNotify, func() any { return new(proto.GCGHeartBeatNotify) }) // GCG游戏心跳包通知
|
||||
c.regMsg(GCGOperationReq, func() any { return new(proto.GCGOperationReq) }) // GCG游戏客户端操作请求
|
||||
c.regMsg(GCGOperationRsp, func() any { return new(proto.GCGOperationRsp) }) // GCG游戏客户端操作响应
|
||||
c.regMsg(GCGSkillPreviewNotify, func() any { return new(proto.GCGSkillPreviewNotify) }) // GCG游戏技能预览通知
|
||||
// TODO 客户端开始GCG游戏
|
||||
// TODO 七圣召唤
|
||||
c.regMsg(GCGBasicDataNotify, func() any { return new(proto.GCGBasicDataNotify) }) // GCG基本数据通知
|
||||
c.regMsg(GCGLevelChallengeNotify, func() any { return new(proto.GCGLevelChallengeNotify) }) // GCG等级挑战通知
|
||||
c.regMsg(GCGDSBanCardNotify, func() any { return new(proto.GCGDSBanCardNotify) }) // GCG禁止的卡牌通知
|
||||
c.regMsg(GCGDSDataNotify, func() any { return new(proto.GCGDSDataNotify) }) // GCG数据通知 (解锁的内容)
|
||||
c.regMsg(GCGTCTavernChallengeDataNotify, func() any { return new(proto.GCGTCTavernChallengeDataNotify) }) // GCG酒馆挑战数据通知
|
||||
c.regMsg(GCGTCTavernInfoNotify, func() any { return new(proto.GCGTCTavernInfoNotify) }) // GCG酒馆信息通知
|
||||
c.regMsg(GCGTavernNpcInfoNotify, func() any { return new(proto.GCGTavernNpcInfoNotify) }) // GCG酒馆NPC信息通知
|
||||
c.regMsg(GCGGameBriefDataNotify, func() any { return new(proto.GCGGameBriefDataNotify) }) // GCG游戏简要数据通知
|
||||
c.regMsg(GCGAskDuelReq, func() any { return new(proto.GCGAskDuelReq) }) // GCG游戏对局信息请求
|
||||
c.regMsg(GCGAskDuelRsp, func() any { return new(proto.GCGAskDuelRsp) }) // GCG游戏对局信息响应
|
||||
c.regMsg(GCGInitFinishReq, func() any { return new(proto.GCGInitFinishReq) }) // GCG游戏初始化完成请求
|
||||
c.regMsg(GCGInitFinishRsp, func() any { return new(proto.GCGInitFinishRsp) }) // GCG游戏初始化完成响应
|
||||
c.regMsg(GCGMessagePackNotify, func() any { return new(proto.GCGMessagePackNotify) }) // GCG游戏消息包通知
|
||||
c.regMsg(GCGHeartBeatNotify, func() any { return new(proto.GCGHeartBeatNotify) }) // GCG游戏心跳包通知
|
||||
c.regMsg(GCGOperationReq, func() any { return new(proto.GCGOperationReq) }) // GCG游戏客户端操作请求
|
||||
c.regMsg(GCGOperationRsp, func() any { return new(proto.GCGOperationRsp) }) // GCG游戏客户端操作响应
|
||||
c.regMsg(GCGSkillPreviewNotify, func() any { return new(proto.GCGSkillPreviewNotify) }) // GCG游戏技能预览通知
|
||||
c.regMsg(GCGStartChallengeByCheckRewardReq, func() any { return new(proto.GCGStartChallengeByCheckRewardReq) }) // GCG开始挑战来自检测奖励请求
|
||||
c.regMsg(GCGStartChallengeByCheckRewardRsp, func() any { return new(proto.GCGStartChallengeByCheckRewardRsp) }) // GCG开始挑战来自检测奖励响应
|
||||
c.regMsg(GCGStartChallengeReq, func() any { return new(proto.GCGStartChallengeReq) }) // GCG开始挑战请求
|
||||
@@ -385,7 +396,7 @@ func (c *CmdProtoMap) registerMessage() {
|
||||
c.regMsg(QuestProgressUpdateNotify, func() any { return new(proto.QuestProgressUpdateNotify) }) // 任务进度更新通知
|
||||
c.regMsg(QuestGlobalVarNotify, func() any { return new(proto.QuestGlobalVarNotify) }) // 任务全局变量通知
|
||||
|
||||
// 家园
|
||||
// TODO 家园
|
||||
c.regMsg(GetPlayerHomeCompInfoReq, func() any { return new(proto.GetPlayerHomeCompInfoReq) })
|
||||
c.regMsg(HomeGetBasicInfoReq, func() any { return new(proto.HomeGetBasicInfoReq) })
|
||||
c.regMsg(GetHomeExchangeWoodInfoReq, func() any { return new(proto.GetHomeExchangeWoodInfoReq) })
|
||||
|
||||
Reference in new issue
Block a user