添加怪物、物件生成命令,@@GM命令需要权限
This commit is contained in:
1 parent
082a69d16a
commit
64699c23d7
4 files changed
+122
-8
No files matched your search
@@ -24,9 +24,7 @@ type CommandController struct {
|
||||
// InitController 初始化命令控制器
|
||||
func (c *CommandManager) InitController() {
|
||||
controllerList := []*CommandController{
|
||||
// 权限等级 1: GM 1级
|
||||
c.NewAssignCommandController(),
|
||||
// 权限等级 0: 普通玩家
|
||||
c.NewHelpCommandController(),
|
||||
c.NewGotoCommandController(),
|
||||
c.NewJumpCommandController(),
|
||||
@@ -35,6 +33,8 @@ func (c *CommandManager) InitController() {
|
||||
c.NewAvatarCommandController(),
|
||||
c.NewGiveCommandController(),
|
||||
c.NewKillCommandController(),
|
||||
c.NewMonsterCommandController(),
|
||||
c.NewGadgetCommandController(),
|
||||
c.NewQuestCommandController(),
|
||||
c.NewPointCommandController(),
|
||||
c.NewXLuaDebugCommandController(),
|
||||
@@ -623,6 +623,88 @@ func (c *CommandManager) KillCommand(content *CommandContent) bool {
|
||||
})
|
||||
}
|
||||
|
||||
// 生成怪物命令
|
||||
|
||||
func (c *CommandManager) NewMonsterCommandController() *CommandController {
|
||||
return &CommandController{
|
||||
Name: "生成怪物",
|
||||
AliasList: []string{"monster"},
|
||||
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>生成原魔</color>",
|
||||
UsageList: []string{
|
||||
"{alias} <怪物ID> [数量] [等级] [姿势 (暂时无效)] [坐标X] [坐标Y] [坐标Z] 生成怪物",
|
||||
},
|
||||
Perm: CommandPermNormal,
|
||||
Func: c.MonsterCommand,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CommandManager) MonsterCommand(content *CommandContent) bool {
|
||||
var monsterId uint32 // 怪物id
|
||||
var count uint32 = 1 // 数量
|
||||
var level uint8 = 1 // 等级
|
||||
// var pose uint32 // 姿势
|
||||
var posX = content.AssignPlayer.Pos.X // 坐标x
|
||||
var posY = content.AssignPlayer.Pos.Y // 坐标y
|
||||
var posZ = content.AssignPlayer.Pos.Z // 坐标z
|
||||
|
||||
return content.Dynamic("uint32", func(param any) bool {
|
||||
monsterId = param.(uint32)
|
||||
return true
|
||||
}).Option("uint32", func(param any) bool {
|
||||
count = param.(uint32)
|
||||
return true
|
||||
}).Option("uint8", func(param any) bool {
|
||||
level = param.(uint8)
|
||||
return true
|
||||
}).Option("uint32", func(param any) bool {
|
||||
// pose = param.(uint32)
|
||||
return true
|
||||
}).Option("float64", func(param any) bool {
|
||||
posX = param.(float64)
|
||||
return true
|
||||
}).Option("float64", func(param any) bool {
|
||||
posY = param.(float64)
|
||||
return true
|
||||
}).Option("float64", func(param any) bool {
|
||||
posZ = param.(float64)
|
||||
return true
|
||||
}).Execute(func() bool {
|
||||
c.gmCmd.GMCreateMonster(content.AssignPlayer.PlayerId, monsterId, posX, posY, posZ, count, level)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
// 生成物件命令
|
||||
|
||||
func (c *CommandManager) NewGadgetCommandController() *CommandController {
|
||||
return &CommandController{
|
||||
Name: "生成物件",
|
||||
AliasList: []string{"gadget"},
|
||||
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>生成物件</color>",
|
||||
UsageList: []string{
|
||||
"{alias} <物件ID> [数量] 附近生成物件",
|
||||
},
|
||||
Perm: CommandPermNormal,
|
||||
Func: c.GadgetCommand,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CommandManager) GadgetCommand(content *CommandContent) bool {
|
||||
var gadgetId uint32 // 物件id
|
||||
var count uint32 = 1 // 数量
|
||||
|
||||
return content.Dynamic("uint32", func(param any) bool {
|
||||
gadgetId = param.(uint32)
|
||||
return true
|
||||
}).Option("uint32", func(param any) bool {
|
||||
count = param.(uint32)
|
||||
return true
|
||||
}).Execute(func() bool {
|
||||
c.gmCmd.GMCreateGadget(content.AssignPlayer.PlayerId, gadgetId, count)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
// 管理任务命令
|
||||
|
||||
func (c *CommandManager) NewQuestCommandController() *CommandController {
|
||||
|
||||
@@ -378,23 +378,41 @@ func (g *GMCmd) GMUnlockAllPoint(userId uint32, sceneId uint32) {
|
||||
}
|
||||
|
||||
// GMCreateMonster 在玩家附近创建怪物
|
||||
func (g *GMCmd) GMCreateMonster(userId uint32, monsterId uint32) {
|
||||
func (g *GMCmd) GMCreateMonster(userId uint32, monsterId uint32, posX, posY, posZ float64, count uint32, level uint8) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
GAME.CreateMonster(player, nil, monsterId)
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
logger.Error("world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
if scene == nil {
|
||||
logger.Error("scene is nil, sceneId: %v, uid: %v", player.SceneId, player.PlayerId)
|
||||
return
|
||||
}
|
||||
for i := 0; i < int(count); i++ {
|
||||
GAME.CreateMonster(player, &model.Vector{
|
||||
X: posX,
|
||||
Y: posY,
|
||||
Z: posZ,
|
||||
}, monsterId, level)
|
||||
}
|
||||
}
|
||||
|
||||
// GMCreateGadget 在玩家附近创建物件
|
||||
func (g *GMCmd) GMCreateGadget(userId uint32, gadgetId uint32) {
|
||||
func (g *GMCmd) GMCreateGadget(userId uint32, gadgetId uint32, count uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
GAME.CreateGadget(player, nil, gadgetId, nil)
|
||||
for i := 0; i < int(count); i++ {
|
||||
GAME.CreateGadget(player, nil, gadgetId, nil)
|
||||
}
|
||||
}
|
||||
|
||||
// 系统级GM指令
|
||||
|
||||
@@ -292,6 +292,11 @@ func (g *Game) GmTalkReq(player *model.Player, payloadMsg pb.Message) {
|
||||
g.SendMsg(cmd.GmTalkRsp, player.PlayerId, player.ClientSeq, &proto.GmTalkRsp{Retmsg: "GM函数解析失败", Msg: req.Msg})
|
||||
return
|
||||
}
|
||||
// 判断玩家权限是否足够
|
||||
if CommandPerm(player.CmdPerm) < CommandPermGM {
|
||||
g.SendMsg(cmd.GmTalkRsp, player.PlayerId, player.ClientSeq, &proto.GmTalkRsp{Retmsg: "权限不足", Msg: req.Msg})
|
||||
return
|
||||
}
|
||||
funcName := commandText[:beginIndex]
|
||||
paramList := strings.Split(commandText[beginIndex+1:endIndex], ",")
|
||||
commandMessageInput <- &CommandMessage{
|
||||
|
||||
+11
-2
@@ -1151,12 +1151,15 @@ func (g *Game) SceneGroupCreateEntity(player *model.Player, groupId uint32, conf
|
||||
}
|
||||
|
||||
// CreateMonster 创建怪物实体
|
||||
func (g *Game) CreateMonster(player *model.Player, pos *model.Vector, monsterId uint32) {
|
||||
func (g *Game) CreateMonster(player *model.Player, pos *model.Vector, monsterId uint32, level uint8) uint32 {
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
return
|
||||
return 0
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
if scene == nil {
|
||||
return 0
|
||||
}
|
||||
if pos == nil {
|
||||
pos = &model.Vector{
|
||||
X: player.Pos.X + random.GetRandomFloat64(1.0, 10.0),
|
||||
@@ -1171,7 +1174,13 @@ func (g *Game) CreateMonster(player *model.Player, pos *model.Vector, monsterId
|
||||
monsterId, uint8(random.GetRandomInt32(1, 90)), getTempFightPropMap(),
|
||||
0, 0,
|
||||
)
|
||||
entity := scene.GetEntity(entityId)
|
||||
if entity == nil {
|
||||
return 0
|
||||
}
|
||||
entity.level = level
|
||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
||||
return entityId
|
||||
}
|
||||
|
||||
// CreateGadget 创建物件实体
|
||||
|
||||
Reference in new issue
Block a user