local _M = {} local redisproxy = redisproxy function _M.clientRequest(agent, data) local msg = MsgPack.unpack(data) local role = agent.role local action = _M[msg.cmd] local bin = MsgPack.pack({ cmd = "指令失败" }) if not action then SendPacket(actionCodes.Gm_receiveResponse, bin) return true end local ret = action(role, msg) bin = MsgPack.pack({ cmd = ret }) SendPacket(actionCodes.Gm_receiveResponse, bin) return true end function _M.testhotfix(role, pms) return csvdb["itemCsv"][1]["name"] .. " -=- " .. globalCsv["codeVersion"] .. " -=- " .. role:getItemCount(123) .. " -=- " .. table.pack(next(role.heros))[2]:getBattleValue() end function _M.ignoreout(role, pms) pms = pms or {} local status = tonum(pms.pm1, 1) if status == 1 then -- 忽视 role:updateProperty({field = "ignoreMt", value = 1}) else -- 解除 role:updateProperty({field = "ignoreMt", value = 0}) end role:mylog("gm_action", {desc = "ignoreout", key1 = pms.sender}) return "指令生效" end function _M.ban(role, pms) local now = skynet.timex() local time = tonum(pms.pm1, 1) local ctype = tonum(pms.pm2, 0) local isBan = role:getProperty("banTime") <= now role:setBan(time, ctype) if time > 0 then role:sendGmMsg("server_accountBanned_1") local agent = datacenter.get("agent", role:getProperty("id")) if agent then skynet.timeout(50, function () skynet.call(agent.gate_serv, "lua", "forcekick", agent.fd) end) end end role:mylog("gm_action", {desc = "ban", int1 = time, int2 = ctype, key1 = pms.sender}) return isBan and "解封杀成功" or "封杀成功" end function _M.unban(role, pms) role:setBan(0, 0) role:mylog("gm_action", {desc = "unban", key1 = pms.sender}) return "解封杀成功" end function _M.gmmsg(role, pms) role:sendGmMsg(pms.pm1, true) local agent = datacenter.get("agent", role:getProperty("id")) if agent then skynet.timeout(50, function () skynet.call(agent.gate_serv, "lua", "forcekick", agent.fd) end) end role:mylog("gm_action", {desc = "gmmsg", text1 = pms.pm1, key1 = pms.sender}) return "指令成功" end function _M.silent(role, pms) local pm1 = tonum(pms.pm1) if pm1 < 1 then role:updateProperty({field = "silent", value = 0}) return "解禁言成功" end role:updateProperty({field = "silent", value = specTime({hour = 0}, skynet.timex()) + pm1 * 86400}) role:mylog("gm_action", {desc = "silent", int1 = pms.pm1, key1 = pms.sender}) return "禁言成功" end function _M.pvp_cross_head(role, pms) role:awardExpireItem(tonum(pms.expire), pms.reward, {log = {desc = "pvpCHead"}}) return "成功" end local helpDes = {{"描述", "指令", "参数1", "参数2" ,"参数3"}} table.insert(helpDes, {"获得角色" , "hero", "角色类型"}) function _M.hero(role, pms) local heroType = tonum(pms.pm1) if not role:addHero({type = heroType, log = {desc = "gm"}}) then return "失败" end role:mylog("gm_action", {desc = "hero", int1 = heroType, key1 = pms.sender}) return "成功" end table.insert(helpDes, {"角色升级" , "herol", "角色类型", "增加等级"}) function _M.herol(role, pms) local heroType = tonum(pms.pm1) local addLevel = tonum(pms.pm2) local hero = role:isHaveHero(heroType) local MaxLv = 200 if not hero then return "不存在的英雄类型" end if hero:getProperty("breakL") >= #csvdb["unit_breakCsv"] and hero:getProperty("level") >= MaxLv then return "等级已满" end local nextLevel = math.min(addLevel + hero:getProperty("level"), MaxLv) for i = 0, #csvdb["unit_breakCsv"] do local upLimit = csvdb["unit_breakCsv"][i].levelLimit local lowLimit = csvdb["unit_breakCsv"][i - 1] and csvdb["unit_breakCsv"][i - 1].levelLimit or 0 if upLimit > nextLevel and lowLimit <= nextLevel then local addbl = i - hero:getProperty("breakL") if addbl > 0 then hero:updateProperty({field = "breakL", delta = addbl}) end end end addLevel = math.min(hero:getMaxLevel() - hero:getProperty("level"), addLevel) hero:updateProperty({field = "level", delta = addLevel}) role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) role:mylog("gm_action", {desc = "herol", int1 = heroType, int2 = addLevel, key1 = pms.sender}) return "成功" end table.insert(helpDes, {"全部角色升级" , "herola", "增加等级"}) function _M.herola(role, pms) local addLevel = tonum(pms.pm1) for _, hero in pairs(role.heros) do _M.herol(role, {pm1 = hero:getProperty("type"), pm2 = addLevel}) end role:mylog("gm_action", {desc = "herola", int1 = addLevel, key1 = pms.sender}) return "成功" end table.insert(helpDes, {"获得装备" , "equip", "装备类型" , "装备等级", "装备个数"}) function _M.equip(role, pms) local typ = tonum(pms.pm1) local level = tonum(pms.pm2) local count = tonum(pms.pm3) role:addEquip(typ, level, count, {log = {desc = "gm"}}) role:mylog("gm_action", {desc = "equip", int1 = typ, int2 = level, long1 = count, key1 = pms.sender}) return "成功" end table.insert(helpDes, {"获得零件" , "rune", "零件类型", "零件id"}) function _M.rune(role, pms) local typ = tonum(pms.pm1) local id = tonum(pms.pm2) local result = role:addRune({type = typ,id = id, log = {desc = "gm"}}) role:mylog("gm_action", {desc = "rune", int1 = typ, int2 = id, key1 = pms.sender}) return result end table.insert(helpDes, {"通关挂机副本", "fb", "挂卡id"}) function _M.fb(role, pms) -- 直接通关 local carbonId = tonum(pms.pm1) if not csvdb["idle_battleCsv"][carbonId] then return "不存在的carbon" end local addPre addPre = function(carbonId) local carbonData = csvdb["idle_battleCsv"][carbonId] for _, pre in ipairs(carbonData.prepose:toArray(true, "=")) do role:hangFinish(pre) role:checkTaskEnter("HangPass", {id = pre}) addPre(pre) end end role:hangFinish(carbonId) addPre(carbonId) role:mylog("gm_action", {desc = "fb", int1 = carbonId, key1 = pms.sender}) role:checkTaskEnter("HangPass", {id = carbonId}) return "成功" end table.insert(helpDes, {"抵达挂机副本", "fbc", "副本id"}) function _M.fbc(role, pms) -- 直接通关 local carbonId = tonum(pms.pm1) if not csvdb["idle_battleCsv"][carbonId] then return "不存在的carbon" end local passCarbon = {} local addPre addPre = function(carbonId) local carbonData = csvdb["idle_battleCsv"][carbonId] for _, pre in ipairs(carbonData.prepose:toArray(true, "=")) do role:hangFinish(pre) role:checkTaskEnter("HangPass", {id = pre}) addPre(pre) end end role:updateProperty({field = "hangPass", value = {}}) addPre(carbonId) role:mylog("gm_action", {desc = "fbc", int1 = carbonId, key1 = pms.sender}) return "成功" end -- table.insert(helpDes, {"好感度", "love", "角色类型", "好感度等级", "好感度经验"}) -- function _M.love(role, pms) -- local heroType = tonum(pms.pm1) -- local level = tonum(pms.pm2) -- local exp = tonum(pms.pm3) -- local curPlus = csvdb["unit_love_plusCsv"][heroType] -- if not curPlus then return "参数错误" end -- level = math.max(math.min(curPlus.limit, level), 0) -- local curEffect = csvdb["unit_love_effectCsv"][level] -- exp = math.max(math.min(curEffect.loveValue, exp) , 0) -- for _, hero in pairs(role.heros) do -- if hero:getProperty("type") == heroType then -- hero:updateProperty({field = "loveL", value = level}) -- hero:updateProperty({field = "loveExp", value = exp}) -- if role:getProperty("loveStatus"):getv(heroType, 0) < level then -- role:changeUpdates({{type = "loveStatus", field = heroType, value = level}}) -- 总的 -- end -- role:checkTaskEnter("LoveBreak", {heroType = heroType, loveL = level}) -- end -- end -- return "成功" -- end table.insert(helpDes, {"玩家经验", "exp", "经验"}) function _M.exp(role, pms) local exp = tonum(pms.pm1) exp = math.floor(math.max(exp, 0)) role:addPlayExp(exp, {log = {desc = "gm"}}) role:mylog("gm_action", {desc = "exp", int1 = exp, key1 = pms.sender}) return "成功" end table.insert(helpDes, {"获得物品", "get", "物品ID", "个数"}) table.insert(helpDes, {"获得所有物品", "get", "ALL"}) table.insert(helpDes, {"获得所有装备", "get", "EQUIP"}) table.insert(helpDes, {"获得所有零件", "get", "RUNE"}) table.insert(helpDes, {"获得所有碎片", "get", "FRAG"}) table.insert(helpDes, {"获得所有食物", "get", "FOOD"}) table.insert(helpDes, {"获得所有角色", "get", "HERO"}) function _M.get(role, pms) if pms.pm1 == "ALL" then local reward = {} for id, data in pairs(csvdb["gm_getallCsv"]) do if csvdb["itemCsv"][id] then reward[id] = data.number end end role:award(reward, {log = {desc = "gm"}}) elseif pms.pm1 == "EQUIP" then for itemId = 7000 , 8000 do if csvdb["itemCsv"][itemId] then role:award({[itemId] = 100}, {log = {desc = "gm"}}) end end elseif pms.pm1 == "RUNE" then for itemId = 2000 , 3000 do if csvdb["itemCsv"][itemId] then role:award({[itemId] = 1}, {log = {desc = "gm"}}) end end elseif pms.pm1 == "FRAG" then for itemId = 100 , 400 do if csvdb["itemCsv"][itemId] then role:award({[itemId] = 100}, {log = {desc = "gm"}}) end end elseif pms.pm1 == "FOOD" then for itemId = 4000 , 5000 do if csvdb["itemCsv"][itemId] then role:award({[itemId] = 100}, {log = {desc = "gm"}}) end end elseif pms.pm1 == "HERO" then for itemId = 400 , 700 do if csvdb["itemCsv"][itemId] then role:award({[itemId] = 1}, {log = {desc = "gm"}}) end end else local itemId = tonum(pms.pm1) if not csvdb["itemCsv"][itemId] then return "物品不存在" end local count = tonum(pms.pm2, 1) role:award({[itemId] = count}, {log = {desc = "gm"}}) role:mylog("gm_action", {desc = "get", int1 = itemId, int2 = count, key1 = pms.sender}) end return "成功" end table.insert(helpDes, {"冒险清除" , "advc"}) function _M.advc(role, pms) local advTeam = role:getProperty("advTeam") advTeam.player = nil local reward = role:getProperty("advItems"):toNumMap() for itemId, count in pairs(reward) do reward[itemId] = math.ceil(count * globalCsv.adv_fail_reward_ratio / 100) -- 奖励相当于失败 end role:award(reward, {log = {desc = "gm"}}) role:updateProperties({ advInfo = {}, advTeam = advTeam, advItems = "", advAFGet = {}, advAFWear = {}, }, notNotify) role.advData = nil role:mylog("gm_action", {desc = "advc", key1 = pms.sender}) return "成功" end table.insert(helpDes, {"冒险次数恢复", "advf"}) function _M.advf(role, pms) role:updateProperty({field = "advC", value = 0}) role.dailyData:updateProperty({field = "advElC", value = 0}) role:mylog("gm_action", {desc = "advf", key1 = pms.sender}) return "成功" end table.insert(helpDes, {"冒险通关", "adv", "章节id", "层数"}) function _M.adv(role, pms) local chapterId = tonum(pms.pm1) local layer = tonum(pms.pm2) local advCsv = csvdb["adv_chapterCsv"][chapterId] if not advCsv then return "不存在的章节" end if math.floor(chapterId / 100) ~= 2 then layer = math.min(layer, advCsv.limitlevel) end local advPass = role:getProperty("advPass") if (advPass[chapterId] or 0) < layer then advPass[chapterId] = layer role:updateProperty({field = "advPass", value = advPass}) end role:mylog("gm_action", {desc = "adv", int1 = chapterId, int2 = layer, key1 = pms.sender}) return "成功" end table.insert(helpDes, {"冒险到达指定层", "advt", "章节id", "层数", "地图id(选)"}) function _M.advt(role, pms) local chapterId = tonum(pms.pm1) local layer = tonum(pms.pm2) local mapId = tonum(pms.pm3) local advCsv = csvdb["adv_chapterCsv"][chapterId] if not advCsv then return "不存在的章节" end local status = _M.adv(role, {pm1 = chapterId, pm2 = layer - 1}) if status ~= "成功" then return status end local advData = role:getAdvData() if advData:isRunning() then advData:forceOver() end advData:initByChapter({ chapterId = chapterId, level = layer, isEnter = true, debugMapId = mapId, }) role:mylog("gm_action", {desc = "advt", int1 = chapterId, int2 = layer, key1 = pms.sender}) return "成功" end table.insert(helpDes, {"冒险队等级增加", "advl", "经验"}) function _M.advl(role, pms) local exp = tonum(pms.pm1) role:addAdvLvExp(math.max(0, exp)) role:mylog("gm_action", {desc = "advl", int1 = exp, key1 = pms.sender}) return "成功" end -- table.insert(helpDes, {"冒险内等级增加", "advcl", "经验值"}) -- function _M.advcl(role, pms) -- local exp = tonum(pms.pm1) -- local advData = role:getAdvData() -- if not advData.chapterId then -- return "先随便开启一关" -- end -- advData.battle.player:addExp(exp) -- advData:saveDB() -- role:mylog("gm_action", {desc = "advcl", int1 = exp, key1 = pms.sender}) -- return "成功" -- end table.insert(helpDes, {"挂机清除" , "idlec"}) function _M.idlec(role, pms) role:updateProperty({field = "hangInfo", value = {}}) role:updateProperty({field = "hangBag", value = {}}) role:mylog("gm_action", {desc = "idlec", key1 = pms.sender}) role.advData = nil return "成功" end table.insert(helpDes, {"冒险内可使用道具", "advit", "ALL"}) table.insert(helpDes, {"冒险内消耗道具", "advit", "itemId", "count"}) function _M.advit(role, pms) local reward = {} if pms.pm1 == "ALL" then for k, v in pairs(csvdb["adv_itemCsv"]) do if csvdb["itemCsv"][k] and v.effect ~= 0 then reward[k] = 1 end end for k , v in pairs(csvdb["adv_artifactCsv"]) do if v[1].unlock == 0 then reward[k] = 1 end end else local itemId = tonum(pms.pm1) local count = tonum(pms.pm2) reward[itemId] = count role:mylog("gm_action", {desc = "advit", int1 = itemId, int2 = count, key1 = pms.sender}) end local adv = role:getAdvData() adv:award(reward, {log = {desc = "gm"}}) return "成功" end table.insert(helpDes, {"爬塔到指定层", "tower", "层数"}) function _M.tower(role, pms) local level = tonum(pms.pm1, 1) if not csvdb["tower_battleCsv"][level] then return "不存在" end role:updateProperty({field = "towerInfo", value = {c = globalCsv.tower_count_limit, l = level}}) role:mylog("gm_action", {desc = "tower", int1 = level, key1 = pms.sender}) return "成功" end table.insert(helpDes, {"发送邮件", "email", "id", "奖励"}) function _M.email(role, pms) local id = tonum(pms.pm1, 0) local reward = pms.pm2 redisproxy:insertEmail({ roleId = role:getProperty("id"), emailId = id, createtime = skynet.timex(), title = id == 0 and "来自GM的邮件!" or nil, stitle = id == 0 and "GM测试" or nil, content = id == 0 and "测试内容测试内容!!!\n\t 巴拉巴拉!" or nil, attachments = id == 0 and reward or nil, rewardPms = id ~= 0 and reward or nil, }) role:mylog("gm_action", {desc = "email", int1 = id, key1 = pms.sender}) return "成功" end table.insert(helpDes, {"引导", "guide", "skip/reset"}) function _M.guide(role, pms) local cmd = pms.pm1 or "un" if cmd == "SKIP" then role:updateProperty({field = "newerGuide", value = "9999=1"}) local str = "" for _, set in pairs(csvdb["guide_mainCsv"]) do str = str:setv(set[1].major * 1000,1) for _,data in ipairs(set) do if data["break"] ~= 0 then str = str:setv(data.major * 1000 + data.minor,1) end end end role:updateProperty({field = "funcGuide", value = str}) role:mylog("gm_action", {desc = "sguide", key1 = pms.sender}) elseif cmd == "RESET" then local id = tonum(pms.pm2, 0) if id == 0 then role:updateProperties({ newerGuide = "1=1", funcGuide = "", }, notNotify) elseif id == 1 then role:updateProperty({field = "newerGuide", value = "1=1"}) elseif id == 2 then role:updateProperty({field = "funcGuide", value = ""}) end role:mylog("gm_action", {desc = "cguide", int1 = id, key1 = pms.sender}) end return "成功" end function _M.helpRpc(agent, data) SendPacket(actionCodes.Gm_helpRpc, MsgPack.pack({help = helpDes})) return true end function _M.test(role, pms) local id = tonum(pms.pm1, 0) --local hero = require ("actions.HeroAction") --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) print(role:getPaybackReward(0, 10000)) return "成功" end -- 充值回调 function _M.ayncPurchase(role, params) return role:handlePurchase(params) or "" end function _M.cz(role, pms) local id = tonum(pms.pm1) local csvData = csvdb["shop_rechargeCsv"][id] if not csvData then return "充值id错误, 查看shop_recharge.csv" end role:recharge({ id = id, transactionId = "GM", order = "GM", pay_time = skynet.timex(), }) role:mylog("gm_action", {desc = "recharge", int1 = id, key1 = pms.sender}) return "指令成功" end return _M