diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index f346e57..fe3ddab 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -54,6 +54,7 @@ actionCodes = { Hero_createHeroRpc = 215, Hero_referEquipsRpc = 216, Hero_referRunesRpc = 217, + Hero_createHeroRandomRpc = 218, Hang_startRpc = 251, Hang_checkRpc = 252, diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index 882cad3..10b61a9 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -64,6 +64,12 @@ function _M.get(role, pms) role:award({[itemId] = 100}) end end + elseif pms.pm1 == "FOOD" then + for itemId = 4000 , 5000 do + if csvdb["itemCsv"][itemId] then + role:award({[itemId] = 100}) + end + end else local itemId = tonum(pms.pm1) if not csvdb["itemCsv"][itemId] then diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 5365d82..fb93e86 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -581,4 +581,30 @@ function _M.referRunesRpc(agent, data) return true end +function _M.createHeroRandomRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local itemId = msg.itemId + local itemData = csvdb["itemCsv"][itemId] + if not itemData or itemData.type ~= ItemType.HeroFCommon then return end + local cost = globalCsv.unit_fragment_cost[itemData.quality] + if not cost or role:getItemCount(itemId) < cost then return end + + local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] + if not randomData then return end + + local temp = randomData.random_gift:randWeight(true) + if not temp or not next(temp) then return end + local reward = {} + if role:isHaveHero(temp[1]) then + reward = {[temp[1]] = cost} + else + reward = {[temp[1] + ItemStartId.Hero] = 1} + end + role:costItems({[itemId] = cost}) + reward = role:award(reward) + SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack({reward = reward})) + return true +end + return _M \ No newline at end of file -- libgit2 0.21.2