圣遗物升级临时版本

This commit is contained in:
flswld committed 2023-11-15 01:50:26 +08:00
1 parent 17f3a7b466
commit 12f2c96024
17 files changed
+278 -254

No files matched your search

+1 -1
View File
@@ -9,6 +9,7 @@ max_size = 10485760
[hk4e]
client_proto_proxy_enable = false # 是否开启客户端协议代理功能
forward_mode_enable = false # 是否开启网关到机器人的转发功能
register_all_proto_message = true # 注册全部pb消息
[hk4e_robot]
region_list_url = "https://hk4e.flswld.com/query_region_list" # 一级dispatch地址
@@ -30,7 +31,6 @@ client_move_speed = 10 # 客户端模拟移动速度
client_move_range_ext = 100 # 客户端模拟移动区域半径
forward_checksum = "" # 转发模式强制指定校验和
forward_checksum_client_version = "" # 转发模式强制指定校验和客户端版本
register_all_proto_message = true # 注册全部pb消息
[mq]
nats_url = "nats://nats:4222"
+17 -17
View File
@@ -39,22 +39,23 @@ type Redis struct {
// Hk4e 原神服务器
type Hk4e struct {
KcpAddr string `toml:"kcp_addr"` // kcp地址 该地址只用来注册到节点服务器 填网关的外网地址 网关本地监听为0.0.0.0
KcpPort int32 `toml:"kcp_port"` // kcp端口号
TcpModeEnable bool `toml:"tcp_mode_enable"` // 是否开启tcp模式 需要hook客户端网络库才能支持 共用kcp端口号
GameDataConfigPath string `toml:"game_data_config_path"` // 配置表路径
ClientProtoProxyEnable bool `toml:"client_proto_proxy_enable"` // 是否开启客户端协议代理功能
ForwardModeEnable bool `toml:"forward_mode_enable"` // 是否开启网关到机器人的转发功能
Version string `toml:"version"` // 支持的客户端协议版本号 三位数字 多个以逗号分隔 如300,310,315,320
GateTcpMqAddr string `toml:"gate_tcp_mq_addr"` // 访问网关tcp直连消息队列的地址 填网关的内网地址
GateTcpMqPort int32 `toml:"gate_tcp_mq_port"` // tcp消息队列端口号
LoginSdkUrl string `toml:"login_sdk_url"` // 网关登录验证token的sdk服务器地址 目前填dispatch的内网地址
LoginSdkAccountKey string `toml:"login_sdk_account_key"` // sdk服务器账号验证的签名密钥
LoadSceneLuaConfig bool `toml:"load_scene_lua_config"` // 是否加载场景详情LUA配置数据
DispatchUrl string `toml:"dispatch_url"` // 二级dispatch地址 将域名改为dispatch的外网地址
ForwardRegionUrl string `toml:"forward_region_url"` // 转发的一级dispatch地址
ForwardDispatchUrl string `toml:"forward_dispatch_url"` // 转发的二级dispatch地址
GmAuthKey string `toml:"gm_auth_key"` // gm认证密钥
KcpAddr string `toml:"kcp_addr"` // kcp地址 该地址只用来注册到节点服务器 填网关的外网地址 网关本地监听为0.0.0.0
KcpPort int32 `toml:"kcp_port"` // kcp端口号
TcpModeEnable bool `toml:"tcp_mode_enable"` // 是否开启tcp模式 需要hook客户端网络库才能支持 共用kcp端口号
GameDataConfigPath string `toml:"game_data_config_path"` // 配置表路径
ClientProtoProxyEnable bool `toml:"client_proto_proxy_enable"` // 是否开启客户端协议代理功能
ForwardModeEnable bool `toml:"forward_mode_enable"` // 是否开启网关到机器人的转发功能
Version string `toml:"version"` // 支持的客户端协议版本号 三位数字 多个以逗号分隔 如300,310,315,320
GateTcpMqAddr string `toml:"gate_tcp_mq_addr"` // 访问网关tcp直连消息队列的地址 填网关的内网地址
GateTcpMqPort int32 `toml:"gate_tcp_mq_port"` // tcp消息队列端口号
LoginSdkUrl string `toml:"login_sdk_url"` // 网关登录验证token的sdk服务器地址 目前填dispatch的内网地址
LoginSdkAccountKey string `toml:"login_sdk_account_key"` // sdk服务器账号验证的签名密钥
LoadSceneLuaConfig bool `toml:"load_scene_lua_config"` // 是否加载场景详情LUA配置数据
DispatchUrl string `toml:"dispatch_url"` // 二级dispatch地址 将域名改为dispatch的外网地址
ForwardRegionUrl string `toml:"forward_region_url"` // 转发的一级dispatch地址
ForwardDispatchUrl string `toml:"forward_dispatch_url"` // 转发的二级dispatch地址
GmAuthKey string `toml:"gm_auth_key"` // gm认证密钥
RegisterAllProtoMessage bool `toml:"register_all_proto_message"` // 注册全部pb消息
}
// Hk4eRobot 原神机器人
@@ -78,7 +79,6 @@ type Hk4eRobot struct {
ClientMoveRangeExt int32 `toml:"client_move_range_ext"` // 客户端模拟移动区域半径
ForwardChecksum string `toml:"forward_checksum"` // 转发模式强制指定校验和
ForwardChecksumClientVersion string `toml:"forward_checksum_client_version"` // 转发模式强制指定校验和客户端版本
RegisterAllProtoMessage bool `toml:"register_all_proto_message"` // 注册全部pb消息
}
// MQ 消息队列
+3 -3
View File
@@ -1,9 +1,9 @@
package constant
const (
STORE_PACK_LIMIT_WEIGHT = 30000 // 背包重量限制
STORE_PACK_LIMIT_WEIGHT = 50000 // 背包重量限制
STORE_PACK_LIMIT_WEAPON = 2000 // 武器容量限制
STORE_PACK_LIMIT_RELIQUARY = 1500 // 圣遗物容量限制
STORE_PACK_LIMIT_MATERIAL = 2000 // 材料容量限制
STORE_PACK_LIMIT_RELIQUARY = 5000 // 圣遗物容量限制
STORE_PACK_LIMIT_MATERIAL = 5000 // 材料容量限制
STORE_PACK_LIMIT_FURNITURE = 2000 // 家具容量限制
)
+2 -2
View File
@@ -285,11 +285,11 @@ func (g *Game) EndlessLoopCheck(checkType int) {
EndlessLoopHandleFunc()
}
case EndlessLoopCheckTypeTriggerQuest:
if checkCount > 100 {
if checkCount > 10000 {
EndlessLoopHandleFunc()
}
case EndlessLoopCheckTypeUseItem:
if checkCount > 100 {
if checkCount > 1000 {
EndlessLoopHandleFunc()
}
case EndlessLoopCheckTypeCallLuaFunc:
+77 -164
View File
@@ -5,6 +5,7 @@ import (
"strconv"
"strings"
"hk4e/common/constant"
"hk4e/gdconf"
"hk4e/pkg/logger"
)
@@ -31,7 +32,6 @@ func (c *CommandManager) InitController() {
c.NewEquipCommandController(),
c.NewItemCommandController(),
c.NewAvatarCommandController(),
c.NewGiveCommandController(),
c.NewKillCommandController(),
c.NewMonsterCommandController(),
c.NewGadgetCommandController(),
@@ -265,11 +265,11 @@ func (c *CommandManager) JumpCommand(content *CommandContent) bool {
func (c *CommandManager) NewEquipCommandController() *CommandController {
return &CommandController{
Name: "武器",
AliasList: []string{"equip", "weapon"},
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>武器</color>",
Name: "装备",
AliasList: []string{"equip"},
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>装备</color>",
UsageList: []string{
"{alias} add <武器ID/all> [武器等级] [突破等级] 添加武器",
"{alias} add <武器ID/圣遗物ID/all> [等级] [突破] [精炼] 添加武器/圣遗物",
},
Perm: CommandPermNormal,
Func: c.EquipCommand,
@@ -277,10 +277,11 @@ func (c *CommandManager) NewEquipCommandController() *CommandController {
}
func (c *CommandManager) EquipCommand(content *CommandContent) bool {
var mode string // 模式
var param1 string // 参数1
var level uint8 = 1 // 武器等级
var promote uint8 // 突破等级
var mode string // 模式
var param1 string // 参数1
var level uint8 = 1 // 等级
var promote uint8 // 突破
var refinement uint8 // 精炼
return content.Dynamic("string", func(param any) bool {
// 模式
@@ -291,30 +292,44 @@ func (c *CommandManager) EquipCommand(content *CommandContent) bool {
param1 = param.(string)
return true
}).Option("uint8", func(param any) bool {
// 武器等级
// 等级
level = param.(uint8)
return true
}).Option("uint8", func(param any) bool {
// 突破等级
// 突破
promote = param.(uint8)
return true
}).Option("uint8", func(param any) bool {
// 精炼
refinement = param.(uint8)
return true
}).Execute(func() bool {
switch mode {
case "add":
// 添加武器
// 判断是否要添加全部武器
if param1 == "all" {
c.gmCmd.GMAddAllWeapon(content.AssignPlayer.PlayerId, 1, level, promote, 0)
content.SendSuccMessage(content.Executor, "已给予所有武器,指定UID:%v,武器等级:%v,突破等级:%v。", content.AssignPlayer.PlayerId, level, promote)
c.gmCmd.GMAddAllWeapon(content.AssignPlayer.PlayerId, 1, level, promote, refinement)
c.gmCmd.GMAddAllReliquary(content.AssignPlayer.PlayerId, 1)
content.SendSuccMessage(content.Executor, "已添加所有武器圣遗物,指定UID:%v,等级:%v,突破:%v,精炼:%v。", content.AssignPlayer.PlayerId, level, promote, refinement)
return true
}
// 物品id
itemId, err := strconv.ParseUint(param1, 10, 32)
if err != nil {
return false
}
c.gmCmd.GMAddWeapon(content.AssignPlayer.PlayerId, uint32(itemId), 1, level, promote, 0)
content.SendSuccMessage(content.Executor, "已给予武器,指定UID:%v,武器ID:%v,武器等级:%v,突破等级:%v。", content.AssignPlayer.PlayerId, itemId, level, promote)
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
if itemDataConfig == nil {
return false
}
switch itemDataConfig.Type {
case constant.ITEM_TYPE_WEAPON:
c.gmCmd.GMAddWeapon(content.AssignPlayer.PlayerId, uint32(itemId), 1, level, promote, refinement)
content.SendSuccMessage(content.Executor, "已添加武器,指定UID:%v,武器ID:%v,等级:%v,突破:%v,精炼:%v。", content.AssignPlayer.PlayerId, itemId, level, promote, refinement)
case constant.ITEM_TYPE_RELIQUARY:
c.gmCmd.GMAddReliquary(content.AssignPlayer.PlayerId, uint32(itemId), 1)
content.SendSuccMessage(content.Executor, "已添加圣遗物,指定UID:%v,圣遗物ID:%v。", content.AssignPlayer.PlayerId, itemId)
default:
return false
}
default:
return false
}
@@ -322,7 +337,7 @@ func (c *CommandManager) EquipCommand(content *CommandContent) bool {
})
}
// 管理物品命令
// 管理道具命令
func (c *CommandManager) NewItemCommandController() *CommandController {
return &CommandController{
@@ -331,7 +346,7 @@ func (c *CommandManager) NewItemCommandController() *CommandController {
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>道具</color>",
UsageList: []string{
"{alias} add <道具ID/all> [数量] 添加道具",
"{alias} clear 清除全部道具",
"{alias} clear <道具ID/all> [数量] 清除道具",
},
Perm: CommandPermNormal,
Func: c.ItemCommand,
@@ -358,23 +373,41 @@ func (c *CommandManager) ItemCommand(content *CommandContent) bool {
}).Execute(func() bool {
switch mode {
case "add":
// 添加物品
// 判断是否要添加全部物品
if param1 == "all" {
c.gmCmd.GMAddAllItem(content.AssignPlayer.PlayerId, count)
content.SendSuccMessage(content.Executor, "已给予所有物品,指定UID:%v,数量:%v。", content.AssignPlayer.PlayerId, count)
c.gmCmd.GMAddAllItem(content.AssignPlayer.PlayerId)
content.SendSuccMessage(content.Executor, "已添加所有道具,指定UID:%v。", content.AssignPlayer.PlayerId)
return true
}
// 物品id
itemId, err := strconv.ParseUint(param1, 10, 32)
if err != nil {
return false
}
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
if itemDataConfig == nil {
return false
}
if itemDataConfig.Type == constant.ITEM_TYPE_WEAPON {
c.gmCmd.GMAddWeapon(content.AssignPlayer.PlayerId, uint32(itemId), 1, 1, 0, 0)
return true
}
if itemDataConfig.Type == constant.ITEM_TYPE_RELIQUARY {
c.gmCmd.GMAddReliquary(content.AssignPlayer.PlayerId, uint32(itemId), 1)
return true
}
c.gmCmd.GMAddItem(content.AssignPlayer.PlayerId, uint32(itemId), count)
content.SendSuccMessage(content.Executor, "已给予物品,指定UID:%v,物品ID:%v,数量:%v。", content.AssignPlayer.PlayerId, 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)
if param1 == "all" {
c.gmCmd.GMClearItem(content.AssignPlayer.PlayerId)
content.SendSuccMessage(content.Executor, "已清除全部道具,指定UID:%v。", content.AssignPlayer.PlayerId)
return true
}
itemId, err := strconv.ParseUint(param1, 10, 32)
if err != nil {
return false
}
c.gmCmd.GMCostItem(content.AssignPlayer.PlayerId, uint32(itemId), count)
content.SendSuccMessage(content.Executor, "已清除道具,指定UID:%v,道具ID:%v,数量:%v。", content.AssignPlayer.PlayerId, itemId, count)
default:
return false
}
@@ -416,7 +449,7 @@ func (c *CommandManager) AvatarCommand(content *CommandContent) bool {
// 判断是否要添加全部角色
if param1 == "all" {
c.gmCmd.GMAddAllAvatar(content.AssignPlayer.PlayerId, 1, 0)
content.SendSuccMessage(content.Executor, "已给予所有角色,指定UID:%v。", content.AssignPlayer.PlayerId)
content.SendSuccMessage(content.Executor, "已添加所有角色,指定UID:%v。", content.AssignPlayer.PlayerId)
return true
}
// 角色id
@@ -425,141 +458,7 @@ func (c *CommandManager) AvatarCommand(content *CommandContent) bool {
return false
}
c.gmCmd.GMAddAvatar(content.AssignPlayer.PlayerId, uint32(avatarId), 1, 0)
content.SendSuccMessage(content.Executor, "已给予角色,指定UID:%v,角色ID:%v。", content.AssignPlayer.PlayerId, avatarId)
default:
return false
}
return true
})
}
// 给予命令
func (c *CommandManager) NewGiveCommandController() *CommandController {
return &CommandController{
Name: "物品",
AliasList: []string{"give"},
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>物品</color>",
UsageList: []string{
"模式:ID / item (所有物品) / weapon (所有武器) / reliquary (所有圣遗物) / avatar (所有角色) / costume (所有时装) / flycloak (所有风之翼) / all (全部)\n不要加上括号内的中文!!",
"{alias} <模式> [数量] 给予指定物品",
"数量仅物品、武器、圣遗物可用",
},
Perm: CommandPermNormal,
Func: c.GiveCommand,
}
}
func (c *CommandManager) GiveCommand(content *CommandContent) bool {
// 给予物品
var mode string // 给予的模式
var itemId uint32 // 物品id
var count uint32 = 1 // 数量
return content.Dynamic("string", func(param any) bool {
value := param.(string)
// 给予的物品
switch value {
case "item", "weapon", "reliquary", "avatar", "costume", "flycloak", "all":
// 所有武器 所有圣遗物 所有角色 所有时装 所有风之翼 一切
mode = value
default:
id, err := strconv.ParseUint(value, 10, 32)
if err != nil {
return false
}
mode = "id"
itemId = uint32(id)
}
return true
}).Option("uint32", func(param any) bool {
value := param.(uint32)
// 参数1
count = value
return true
}).Execute(func() bool {
switch mode {
case "id":
// 判断是否为物品
_, ok := GAME.GetAllItemDataConfig()[int32(itemId)]
if ok {
// 给予玩家物品
c.gmCmd.GMAddItem(content.AssignPlayer.PlayerId, itemId, count)
content.SendSuccMessage(content.Executor, "已给予物品,指定UID:%v,ID:%v,数量:%v。", content.AssignPlayer.PlayerId, itemId, count)
return true
}
// 判断是否为武器
_, ok = GAME.GetAllWeaponDataConfig()[int32(itemId)]
if ok {
// 给予玩家武器
c.gmCmd.GMAddWeapon(content.AssignPlayer.PlayerId, itemId, count, 1, 0, 0)
content.SendSuccMessage(content.Executor, "已给予武器,指定UID:%v,ID:%v,数量:%v。", content.AssignPlayer.PlayerId, itemId, count)
return true
}
// 判断是否为圣遗物
_, ok = GAME.GetAllReliquaryDataConfig()[int32(itemId)]
if ok {
// 给予玩家圣遗物
c.gmCmd.GMAddReliquary(content.AssignPlayer.PlayerId, itemId, count)
content.SendSuccMessage(content.Executor, "已给予圣遗物,指定UID:%v,ID:%v,数量:%v。", content.AssignPlayer.PlayerId, itemId, count)
return true
}
// 判断是否为角色
_, ok = GAME.GetAllAvatarDataConfig()[int32(itemId)]
if ok {
// 给予玩家角色
c.gmCmd.GMAddAvatar(content.AssignPlayer.PlayerId, itemId, 1, 0)
content.SendSuccMessage(content.Executor, "已给予角色,指定UID:%v,ID:%v。", content.AssignPlayer.PlayerId, itemId)
return true
}
// 判断是否为时装
if gdconf.GetAvatarCostumeDataById(int32(itemId)) != nil {
// 给予玩家时装
c.gmCmd.GMAddCostume(content.AssignPlayer.PlayerId, itemId)
content.SendSuccMessage(content.Executor, "已给予时装,指定UID:%v,ID:%v。", content.AssignPlayer.PlayerId, itemId)
return true
}
// 判断是否为风之翼
if gdconf.GetAvatarFlycloakDataById(int32(itemId)) != nil {
// 给予玩家风之翼
c.gmCmd.GMAddFlycloak(content.AssignPlayer.PlayerId, itemId)
content.SendSuccMessage(content.Executor, "已给予风之翼,指定UID:%v,ID:%v。", content.AssignPlayer.PlayerId, itemId)
return true
}
// 都执行到这里那肯定是都不匹配
content.SetElse(func() {
// 物品id不存在
content.SendFailMessage(content.Executor, "不存在的物品,ID:%v。", itemId)
})
return false
case "item":
// 给予玩家所有物品
c.gmCmd.GMAddAllItem(content.AssignPlayer.PlayerId, count)
content.SendSuccMessage(content.Executor, "已给予所有物品,指定UID:%v,数量:%v。", content.AssignPlayer.PlayerId, count)
case "weapon":
// 给予玩家所有武器
c.gmCmd.GMAddAllWeapon(content.AssignPlayer.PlayerId, count, 1, 0, 0)
content.SendSuccMessage(content.Executor, "已给予所有武器,指定UID:%v,数量:%v。", content.AssignPlayer.PlayerId, count)
case "reliquary":
// 给予玩家所有圣遗物
c.gmCmd.GMAddAllReliquary(content.AssignPlayer.PlayerId, count)
content.SendSuccMessage(content.Executor, "已给予所有圣遗物,指定UID:%v,数量:%v。", content.AssignPlayer.PlayerId, count)
case "avatar":
// 给予玩家所有角色
c.gmCmd.GMAddAllAvatar(content.AssignPlayer.PlayerId, 1, 0)
content.SendSuccMessage(content.Executor, "已给予所有角色,指定UID:%v。", content.AssignPlayer.PlayerId)
case "costume":
// 给予玩家所有时装
c.gmCmd.GMAddAllCostume(content.AssignPlayer.PlayerId)
content.SendSuccMessage(content.Executor, "已给予所有时装,指定UID:%v。", content.AssignPlayer.PlayerId)
case "flycloak":
// 给予玩家所有风之翼
c.gmCmd.GMAddAllFlycloak(content.AssignPlayer.PlayerId)
content.SendSuccMessage(content.Executor, "已给予所有风之翼,指定UID:%v。", content.AssignPlayer.PlayerId)
case "all":
// 给予玩家所有内容
c.gmCmd.GMAddAll(content.AssignPlayer.PlayerId)
content.SendSuccMessage(content.Executor, "已给予所有内容,指定UID:%v。", content.AssignPlayer.PlayerId)
content.SendSuccMessage(content.Executor, "已添加角色,指定UID:%v,角色ID:%v。", content.AssignPlayer.PlayerId, avatarId)
default:
return false
}
@@ -964,6 +863,7 @@ func (c *CommandManager) NewWudiCommandController() *CommandController {
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>无敌</color>",
UsageList: []string{
"{alias} global avatar <on/off> 开关玩家无敌",
"{alias} global monster <on/off> 开关怪物无敌",
},
Perm: CommandPermNormal,
Func: c.WudiCommand,
@@ -1004,6 +904,19 @@ func (c *CommandManager) WudiCommand(content *CommandContent) bool {
default:
return false
}
case "monster":
switch param1 {
case "on":
c.gmCmd.GMSetMonsterWudi(content.AssignPlayer.PlayerId, true)
content.SendSuccMessage(content.Executor, "已开启怪物无敌,指定UID:%v。", content.AssignPlayer.PlayerId)
return true
case "off":
c.gmCmd.GMSetMonsterWudi(content.AssignPlayer.PlayerId, false)
content.SendSuccMessage(content.Executor, "已关闭怪物无敌,指定UID:%v。", content.AssignPlayer.PlayerId)
return true
default:
return false
}
default:
return false
}
+46 -31
View File
@@ -40,21 +40,21 @@ func (g *GMCmd) GMTeleportPlayer(userId, sceneId uint32, posX, posY, posZ float6
)
}
// GMAddItem 给予玩家物品
// GMAddItem 添加玩家道具
func (g *GMCmd) GMAddItem(userId, itemId, itemCount uint32) {
GAME.AddPlayerItem(userId, []*ChangeItem{
{
ItemId: itemId,
ChangeCount: itemCount,
},
}, true, 0)
GAME.AddPlayerItem(userId, []*ChangeItem{{ItemId: itemId, ChangeCount: itemCount}}, true, 0)
}
// GMAddWeapon 给予玩家武器
// GMCostItem 消耗玩家道具
func (g *GMCmd) GMCostItem(userId, itemId, itemCount uint32) {
GAME.CostPlayerItem(userId, []*ChangeItem{{ItemId: itemId, ChangeCount: itemCount}})
}
// GMAddWeapon 添加玩家武器
func (g *GMCmd) GMAddWeapon(userId, itemId, itemCount uint32, level, promote, refinement uint8) {
// 武器数量
for i := uint32(0); i < itemCount; i++ {
// 给予武器
// 添加武器
weaponId := GAME.AddPlayerWeapon(userId, itemId)
// 获取玩家
player := USER_MANAGER.GetOnlineUser(userId)
@@ -75,21 +75,21 @@ func (g *GMCmd) GMAddWeapon(userId, itemId, itemCount uint32, level, promote, re
weapon.Exp = 0
// 设置武器精炼
weapon.Refinement = refinement
// 更新武器的物品数据
// 道具背包更新
GAME.SendMsg(cmd.StoreItemChangeNotify, player.PlayerId, player.ClientSeq, GAME.PacketStoreItemChangeNotifyByWeapon(weapon))
}
}
// GMAddReliquary 给予玩家圣遗物
// GMAddReliquary 添加玩家圣遗物
func (g *GMCmd) GMAddReliquary(userId, itemId, itemCount uint32) {
// 圣遗物数量
for i := uint32(0); i < itemCount; i++ {
// 给予圣遗物
// 添加圣遗物
GAME.AddPlayerReliquary(userId, itemId)
}
}
// GMAddAvatar 给予玩家角色
// GMAddAvatar 添加玩家角色
func (g *GMCmd) GMAddAvatar(userId, avatarId uint32, level, promote uint8) {
// 添加角色
GAME.AddPlayerAvatar(userId, avatarId)
@@ -115,39 +115,39 @@ func (g *GMCmd) GMAddAvatar(userId, avatarId uint32, level, promote uint8) {
GAME.SendMsg(cmd.AvatarPropNotify, player.PlayerId, player.ClientSeq, GAME.PacketAvatarPropNotify(avatar))
}
// GMAddCostume 给予玩家时装
// GMAddCostume 添加玩家时装
func (g *GMCmd) GMAddCostume(userId, costumeId uint32) {
// 添加时装
GAME.AddPlayerCostume(userId, costumeId)
}
// GMAddFlycloak 给予玩家风之翼
// GMAddFlycloak 添加玩家风之翼
func (g *GMCmd) GMAddFlycloak(userId, flycloakId uint32) {
// 添加风之翼
GAME.AddPlayerFlycloak(userId, flycloakId)
}
// GMAddAllItem 给予玩家所有物品
func (g *GMCmd) GMAddAllItem(userId, itemCount uint32) {
// GMAddAllItem 添加玩家所有道具
func (g *GMCmd) GMAddAllItem(userId uint32) {
GAME.LogoutPlayer(userId)
itemList := make([]*ChangeItem, 0)
for itemId := range GAME.GetAllItemDataConfig() {
itemList = append(itemList, &ChangeItem{
ItemId: uint32(itemId),
ChangeCount: itemCount,
ChangeCount: 1,
})
}
GAME.AddPlayerItem(userId, itemList, false, 0)
}
// GMAddAllWeapon 给予玩家所有武器
// GMAddAllWeapon 添加玩家所有武器
func (g *GMCmd) GMAddAllWeapon(userId, itemCount uint32, level, promote, refinement uint8) {
for itemId := range GAME.GetAllWeaponDataConfig() {
g.GMAddWeapon(userId, uint32(itemId), itemCount, level, promote, refinement)
}
}
// GMAddAllReliquary 给予玩家所有圣遗物
// GMAddAllReliquary 添加玩家所有圣遗物
func (g *GMCmd) GMAddAllReliquary(userId, itemCount uint32) {
GAME.LogoutPlayer(userId)
for itemId := range GAME.GetAllReliquaryDataConfig() {
@@ -155,41 +155,41 @@ func (g *GMCmd) GMAddAllReliquary(userId, itemCount uint32) {
}
}
// GMAddAllAvatar 给予玩家所有角色
// GMAddAllAvatar 添加玩家所有角色
func (g *GMCmd) GMAddAllAvatar(userId uint32, level, promote uint8) {
for avatarId := range GAME.GetAllAvatarDataConfig() {
g.GMAddAvatar(userId, uint32(avatarId), level, promote)
}
}
// GMAddAllCostume 给予玩家所有时装
// GMAddAllCostume 添加玩家所有时装
func (g *GMCmd) GMAddAllCostume(userId uint32) {
for costumeId := range gdconf.GetAvatarCostumeDataMap() {
g.GMAddCostume(userId, uint32(costumeId))
}
}
// GMAddAllFlycloak 给予玩家所有风之翼
// GMAddAllFlycloak 添加玩家所有风之翼
func (g *GMCmd) GMAddAllFlycloak(userId uint32) {
for flycloakId := range gdconf.GetAvatarFlycloakDataMap() {
g.GMAddFlycloak(userId, uint32(flycloakId))
}
}
// GMAddAll 给予玩家所有内容
// GMAddAll 添加玩家所有内容
func (g *GMCmd) GMAddAll(userId uint32) {
GAME.LogoutPlayer(userId)
// 给予玩家所有物品
g.GMAddAllItem(userId, 9999)
// 给予玩家所有武器
// 添加玩家所有道具
g.GMAddAllItem(userId)
// 添加玩家所有武器
g.GMAddAllWeapon(userId, 1, 90, 6, 4)
// 给予玩家所有圣遗物
// 添加玩家所有圣遗物
g.GMAddAllReliquary(userId, 5)
// 给予玩家所有角色
// 添加玩家所有角色
g.GMAddAllAvatar(userId, 90, 6)
// 给予玩家所有时装
// 添加玩家所有时装
g.GMAddAllCostume(userId)
// 给予玩家所有风之翼
// 添加玩家所有风之翼
g.GMAddAllFlycloak(userId)
}
@@ -538,6 +538,21 @@ func (g *GMCmd) GMSetPlayerWuDi(userId uint32, open bool) {
player.WuDi = open
}
// GMSetMonsterWudi 开启关闭场景内怪物无敌
func (g *GMCmd) GMSetMonsterWudi(userId uint32, open bool) {
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
logger.Error("player is nil, uid: %v", userId)
return
}
world := WORLD_MANAGER.GetWorldById(player.WorldId)
if world == nil {
return
}
scene := world.GetSceneById(player.GetSceneId())
scene.SetMonsterWudi(open)
}
// GMSetPlayerEnergyInf 开启关闭玩家角色无限能量
func (g *GMCmd) GMSetPlayerEnergyInf(userId uint32, open bool) {
player := USER_MANAGER.GetOnlineUser(userId)
+2
View File
@@ -135,6 +135,8 @@ func (r *RouteManager) initRoute() {
cmd.QuestDestroyNpcReq: GAME.QuestDestroyNpcReq,
cmd.AvatarSkillUpgradeReq: GAME.AvatarSkillUpgradeReq,
cmd.UnlockAvatarTalentReq: GAME.UnlockAvatarTalentReq,
cmd.ReliquaryUpgradeReq: GAME.ReliquaryUpgradeReq,
cmd.ReliquaryPromoteReq: GAME.ReliquaryPromoteReq,
}
}
+1
View File
@@ -65,6 +65,7 @@ func (w *WorldManager) CreateWorld(owner *model.Player) *World {
multiplayerTeam: CreateMultiplayerTeam(),
peerList: make([]*model.Player, 0),
aiWorldAoi: nil,
bulletPhysicsEngine: nil,
}
world.mpLevelEntityId = world.GetNextWorldEntityId(constant.ENTITY_TYPE_MP_LEVEL)
w.worldMap[worldId] = world
+17 -8
View File
@@ -14,14 +14,15 @@ import (
// Scene 场景数据结构
type Scene struct {
id uint32
world *World
playerMap map[uint32]*model.Player
entityMap map[uint32]*Entity // 场景中全部的实体
groupMap map[uint32]*Group // 场景中按group->suite分类的实体
gameTime uint32 // 游戏内提瓦特大陆的时间
createTime int64 // 场景创建时间
meeoIndex uint32 // 客户端风元素染色同步协议的计数器
id uint32
world *World
playerMap map[uint32]*model.Player
entityMap map[uint32]*Entity // 场景中全部的实体
groupMap map[uint32]*Group // 场景中按group->suite分类的实体
gameTime uint32 // 游戏内提瓦特大陆的时间
createTime int64 // 场景创建时间
meeoIndex uint32 // 客户端风元素染色同步协议的计数器
monsterWudi bool // 是否开启场景内怪物无敌
}
func (s *Scene) GetId() uint32 {
@@ -60,6 +61,14 @@ func (s *Scene) SetMeeoIndex(meeoIndex uint32) {
s.meeoIndex = meeoIndex
}
func (s *Scene) GetMonsterWudi() bool {
return s.monsterWudi
}
func (s *Scene) SetMonsterWudi(monsterWudi bool) {
s.monsterWudi = monsterWudi
}
func (s *Scene) ChangeGameTime(time uint32) {
s.gameTime = time % 1440
}
-2
View File
@@ -531,7 +531,6 @@ func (g *Game) AddPlayerFlycloak(userId uint32, flyCloakId uint32) {
dbAvatar := player.GetDbAvatar()
for _, flycloak := range dbAvatar.FlyCloakList {
if flycloak == flyCloakId {
logger.Error("player has flycloak, flycloakId: %v", flyCloakId)
return
}
}
@@ -554,7 +553,6 @@ func (g *Game) AddPlayerCostume(userId uint32, costumeId uint32) {
dbAvatar := player.GetDbAvatar()
for _, costume := range dbAvatar.CostumeList {
if costume == costumeId {
logger.Error("player has costume, costumeId: %v", costumeId)
return
}
}
+3 -1
View File
@@ -22,7 +22,7 @@ func (g *Game) PingReq(player *model.Player, payloadMsg pb.Message) {
now := uint32(time.Now().Unix())
// 客户端与服务器时间相差太过严重
if math.Abs(float64(now-player.ClientTime)) > 600.0 {
logger.Debug("abs of client time and server time above 600s, uid: %v", player.PlayerId)
logger.Debug("abs of client time and server time above 600s, clientTime: %v, uid: %v", player.ClientTime, player.PlayerId)
}
player.LastKeepaliveTime = now
@@ -353,6 +353,7 @@ func (g *Game) PacketPropValue(key uint32, value any) *proto.PropValue {
return propValue
}
// GetPlayerPos 获取玩家实时位置
func (g *Game) GetPlayerPos(player *model.Player) *model.Vector {
world := WORLD_MANAGER.GetWorldById(player.WorldId)
if world == nil {
@@ -365,6 +366,7 @@ func (g *Game) GetPlayerPos(player *model.Player) *model.Vector {
return entity.GetPos()
}
// GetPlayerRot 获取玩家实时朝向
func (g *Game) GetPlayerRot(player *model.Player) *model.Vector {
world := WORLD_MANAGER.GetWorldById(player.WorldId)
if world == nil {
+3
View File
@@ -200,6 +200,9 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
case constant.ENTITY_TYPE_AVATAR:
g.SubPlayerAvatarHp(player.PlayerId, defEntity.GetAvatarEntity().GetAvatarId(), attackResult.Damage, false, proto.ChangHpReason_CHANGE_HP_SUB_MONSTER)
case constant.ENTITY_TYPE_MONSTER:
if scene.GetMonsterWudi() {
return
}
fightProp := defEntity.GetFightProp()
currHp := fightProp[constant.FIGHT_PROP_CUR_HP]
maxHp := fightProp[constant.FIGHT_PROP_MAX_HP]
+22 -19
View File
@@ -7,6 +7,7 @@ import (
"hk4e/gdconf"
"hk4e/gs/model"
"hk4e/pkg/logger"
"hk4e/pkg/object"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
@@ -112,6 +113,8 @@ func (g *Game) UseItem(userId uint32, itemId uint32, targetParam ...uint64) {
continue
}
g.AddPlayerCostume(userId, uint32(costumeId))
default:
logger.Error("use option not support, useOption: %v, uid: %v", itemUse.UseOption, userId)
}
}
}
@@ -178,7 +181,13 @@ func (g *Game) AddPlayerItem(userId uint32, itemList []*ChangeItem, isHint bool,
if itemDataConfig == nil {
continue
}
if itemDataConfig.AutoUse == 1 {
if itemDataConfig.Type == constant.ITEM_TYPE_WEAPON {
continue
}
if itemDataConfig.Type == constant.ITEM_TYPE_RELIQUARY {
continue
}
if object.ConvInt64ToBool(int64(itemDataConfig.AutoUse)) {
continue
}
prop, exist := constant.VIRTUAL_ITEM_PROP[itemId]
@@ -238,7 +247,7 @@ func (g *Game) AddPlayerItem(userId uint32, itemList []*ChangeItem, isHint bool,
if itemDataConfig == nil {
continue
}
if itemDataConfig.AutoUse == 1 {
if object.ConvInt64ToBool(int64(itemDataConfig.AutoUse)) {
for count := uint32(0); count < addCount; count++ {
g.UseItem(userId, itemId)
}
@@ -273,6 +282,8 @@ func (g *Game) CostPlayerItem(userId uint32, itemList []*ChangeItem) bool {
count := g.GetPlayerItemCount(player.PlayerId, itemId)
if count < costCount {
return false
} else if count == costCount {
delNtf.GuidList = append(delNtf.GuidList, dbItem.GetItemGuid(itemId))
}
prop, exist := constant.VIRTUAL_ITEM_PROP[itemId]
if exist {
@@ -290,32 +301,24 @@ func (g *Game) CostPlayerItem(userId uint32, itemList []*ChangeItem) bool {
dbItem.CostItem(player, itemId, costCount)
}
count = g.GetPlayerItemCount(player.PlayerId, itemId)
if count > 0 {
pbItem := &proto.Item{
ItemId: itemId,
Guid: dbItem.GetItemGuid(itemId),
Detail: &proto.Item_Material{
Material: &proto.Material{
Count: count,
},
pbItem := &proto.Item{
ItemId: itemId,
Guid: dbItem.GetItemGuid(itemId),
Detail: &proto.Item_Material{
Material: &proto.Material{
Count: count,
},
}
changeNtf.ItemList = append(changeNtf.ItemList, pbItem)
} else if count == 0 {
delNtf.GuidList = append(delNtf.GuidList, dbItem.GetItemGuid(itemId))
},
}
changeNtf.ItemList = append(changeNtf.ItemList, pbItem)
}
if len(propList) > 0 {
g.SendMsg(cmd.PlayerPropNotify, userId, player.ClientSeq, g.PacketPlayerPropNotify(player, propList...))
}
if len(changeNtf.ItemList) > 0 {
g.SendMsg(cmd.StoreItemChangeNotify, userId, player.ClientSeq, changeNtf)
}
g.SendMsg(cmd.StoreItemChangeNotify, userId, player.ClientSeq, changeNtf)
if len(delNtf.GuidList) > 0 {
g.SendMsg(cmd.StoreItemDelNotify, userId, player.ClientSeq, delNtf)
}
return true
}
+69 -1
View File
@@ -8,10 +8,78 @@ import (
"hk4e/pkg/random"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
pb "google.golang.org/protobuf/proto"
)
/************************************************** 接口请求 **************************************************/
func (g *Game) ReliquaryUpgradeReq(player *model.Player, payloadMsg pb.Message) {
req := payloadMsg.(*proto.ReliquaryUpgradeReq)
reliquary, ok := player.GameObjectGuidMap[req.TargetReliquaryGuid].(*model.Reliquary)
if !ok {
g.SendError(cmd.ReliquaryUpgradeRsp, player, &proto.ReliquaryUpgradeRsp{})
return
}
if len(req.ItemParamList) != 0 {
itemList := make([]*ChangeItem, 0)
for _, itemParam := range req.ItemParamList {
itemList = append(itemList, &ChangeItem{
ItemId: itemParam.ItemId,
ChangeCount: itemParam.Count,
})
}
ok := g.CostPlayerItem(player.PlayerId, itemList)
if !ok {
g.SendError(cmd.ReliquaryUpgradeRsp, player, &proto.ReliquaryUpgradeRsp{})
return
}
}
if len(req.FoodReliquaryGuidList) != 0 {
reliquaryIdList := make([]uint64, 0)
for _, foodReliquaryGuid := range req.FoodReliquaryGuidList {
foodReliquary, ok := player.GameObjectGuidMap[foodReliquaryGuid].(*model.Reliquary)
if !ok {
g.SendError(cmd.ReliquaryUpgradeRsp, player, &proto.ReliquaryUpgradeRsp{})
return
}
reliquaryIdList = append(reliquaryIdList, foodReliquary.ReliquaryId)
}
g.CostPlayerReliquary(player.PlayerId, reliquaryIdList)
}
oldLevel := reliquary.Level
oldAppendPropList := make([]uint32, 0)
for _, appendPropId := range reliquary.AppendPropIdList {
oldAppendPropList = append(oldAppendPropList, appendPropId)
}
// TODO 暂时先瞎鸡巴强化
reliquary.Level += 1
reliquary.Exp += 100
if reliquary.Level%5 == 0 {
g.AppendReliquaryProp(reliquary, 1)
}
g.SendMsg(cmd.StoreItemChangeNotify, player.PlayerId, player.ClientSeq, g.PacketStoreItemChangeNotifyByReliquary(reliquary))
rsp := &proto.ReliquaryUpgradeRsp{
OldLevel: uint32(oldLevel),
CurLevel: uint32(reliquary.Level),
TargetReliquaryGuid: req.TargetReliquaryGuid,
CurAppendPropList: reliquary.AppendPropIdList,
PowerUpRate: 5,
OldAppendPropList: oldAppendPropList,
}
g.SendMsg(cmd.ReliquaryUpgradeRsp, player.PlayerId, player.ClientSeq, rsp)
}
func (g *Game) ReliquaryPromoteReq(player *model.Player, payloadMsg pb.Message) {
req := payloadMsg.(*proto.ReliquaryPromoteReq)
logger.Debug("ReliquaryPromoteReq: %+v", req)
g.SendMsg(cmd.ReliquaryPromoteRsp, player.PlayerId, player.ClientSeq, new(proto.ReliquaryPromoteRsp))
}
/************************************************** 游戏功能 **************************************************/
func (g *Game) GetAllReliquaryDataConfig() map[int32]*gdconf.ItemData {
@@ -176,7 +244,7 @@ func (g *Game) CostPlayerReliquary(userId uint32, reliquaryIdList []uint64) {
logger.Error("reliquary cost error, reliquaryId: %v", reliquaryId)
return
}
storeItemDelNotify.GuidList = append(storeItemDelNotify.GuidList, reliquaryId)
storeItemDelNotify.GuidList = append(storeItemDelNotify.GuidList, reliquaryGuid)
}
g.SendMsg(cmd.StoreItemDelNotify, userId, player.ClientSeq, storeItemDelNotify)
}
+1 -1
View File
@@ -89,7 +89,7 @@ func (r *DbReliquary) AddReliquary(player *Player, itemId uint32, reliquaryId ui
reliquary := &Reliquary{
ReliquaryId: reliquaryId,
ItemId: itemId,
Level: 1,
Level: 0,
Exp: 0,
Promote: 0,
Lock: false,
+9 -3
View File
@@ -36,9 +36,9 @@ type Player struct {
TotalOnlineTime uint32 // 累计在线时长
PropMap map[uint32]uint32 // 玩家属性表
OpenStateMap map[uint32]uint32 // 功能开放状态
SceneId uint32 // 场景
Pos *Vector // 坐标
Rot *Vector // 朝向
SceneId uint32 // 存档场景
Pos *Vector // 存档坐标 非实时
Rot *Vector // 存档朝向 非实时
CmdPerm uint8 // 玩家命令权限等级
DbSocial *DbSocial // 社交
DbItem *DbItem // 道具
@@ -93,6 +93,8 @@ type Player struct {
RemoteWorldPlayerNum uint32 `bson:"-"` // 远程展示世界内人数 在线同步到redis 不保存到db
}
// 存档场景
func (p *Player) GetSceneId() uint32 {
if p.IsInMp {
return p.MpSceneId
@@ -109,6 +111,8 @@ func (p *Player) SetSceneId(sceneId uint32) {
}
}
// 存档坐标
func (p *Player) GetPos() *Vector {
if p.IsInMp {
return &Vector{X: p.MpPos.X, Y: p.MpPos.Y, Z: p.MpPos.Z}
@@ -129,6 +133,8 @@ func (p *Player) SetPos(pos *Vector) {
}
}
// 存档朝向
func (p *Player) GetRot() *Vector {
if p.IsInMp {
return &Vector{X: p.MpRot.X, Y: p.MpRot.Y, Z: p.MpRot.Z}
+5 -1
View File
@@ -30,7 +30,7 @@ func NewCmdProtoMap() (r *CmdProtoMap) {
r.cmdNameCmdIdMap = make(map[string]uint16)
r.cmdIdProtoObjCacheMap = make(map[uint16]*sync.Pool)
r.cmdIdProtoObjFastNewMap = make(map[uint16]func() any)
if config.GetConfig().Hk4e.ForwardModeEnable || config.GetConfig().Hk4eRobot.RegisterAllProtoMessage {
if config.GetConfig().Hk4e.ForwardModeEnable || config.GetConfig().Hk4e.RegisterAllProtoMessage {
r.registerAllMessage()
} else {
r.registerMessage()
@@ -350,6 +350,10 @@ func (c *CmdProtoMap) registerMessage() {
c.regMsg(SetEquipLockStateRsp, func() any { return new(proto.SetEquipLockStateRsp) }) // 设置装备上锁状态响应
c.regMsg(TakeoffEquipReq, func() any { return new(proto.TakeoffEquipReq) }) // 装备卸下请求
c.regMsg(TakeoffEquipRsp, func() any { return new(proto.TakeoffEquipRsp) }) // 装备卸下响应
c.regMsg(ReliquaryUpgradeReq, func() any { return new(proto.ReliquaryUpgradeReq) }) // 圣遗物升级请求
c.regMsg(ReliquaryUpgradeRsp, func() any { return new(proto.ReliquaryUpgradeRsp) }) // 圣遗物升级响应
c.regMsg(ReliquaryPromoteReq, func() any { return new(proto.ReliquaryPromoteReq) }) // 圣遗物突破请求
c.regMsg(ReliquaryPromoteRsp, func() any { return new(proto.ReliquaryPromoteRsp) }) // 圣遗物突破响应
// 商店
c.regMsg(GetShopmallDataReq, func() any { return new(proto.GetShopmallDataReq) }) // 商店信息请求