sm

立即登录 | 账号注册

积分: 0 |用户组: 游客

搜索
服务器租用 传奇3一条龙 996 支付平台源码 无法下载点击此处反馈
查看: 668|回复: 0

[传奇手游源码] 手游战神引擎源码会员挂机等按钮明文代码lua.btnCallbacks

[复制链接]

826

主题

36

回帖

23万

积分

霸王教主

积分
236504
发表于 2023-5-15 18:12:02 | 显示全部楼层 |阅读模式
手游战神引擎源码会员挂机等按钮明文代码mir2.scenes.main.console.btnCallbacks

  1. local common = import("..common.common")
  2. local magic = import("..common.magic")
  3. local helper = import("..common.helper.helper")
  4. local btnCallbacks = class("btnCallbacks")

  5. table.merge(btnCallbacks, {
  6.         console
  7. })

  8. btnCallbacks.ctor = function (self, console)
  9.         self.console = console

  10.         return
  11. end
  12. btnCallbacks.handle = function (self, btntype, ...)
  13.         self["handle_" .. btntype](self, ...)

  14.         return
  15. end
  16. btnCallbacks.handle_normal = function (self, btn)
  17.         sound.playSound("103")

  18.         local key = nil

  19.         if type(btn) == "string" then
  20.                 key = btn
  21.         else
  22.                 key = btn.config.key
  23.         end

  24.         if key == "btnChat" then
  25.                 main_scene.ui:togglePanel("chat")
  26.         else
  27.                 if key == "btnHide" then
  28.                         local needHides = {
  29.                                 "rocker",
  30.                                 "hp",
  31.                                 "exp",
  32.                                 "chat",
  33.                                 "btnChat"
  34.                         }

  35.                         local function has(key)
  36.                                 for i, v in ipairs(needHides) do
  37.                                         if v == key then
  38.                                                 return true
  39.                                         end
  40.                                 end

  41.                                 return
  42.                         end

  43.                         btn.isHide = not btn.isHide

  44.                         if btn.isHide then
  45.                                 btn.btn:setTex(res.gettex2("pic/console/btn_show.png"))
  46.                                 btn.run(btn, cc.MoveTo:create(0.1, cc.p(btn.data.x, 21)))
  47.                         else
  48.                                 btn.btn:setTex(res.gettex2("pic/console/btn_hide.png"))
  49.                                 btn.run(btn, cc.MoveTo:create(0.1, cc.p(btn.data.x, btn.data.y)))
  50.                         end

  51.                         for k, v in pairs(self.console.widgets) do
  52.                                 if (v ~= btn and v.config.class == "btnMove") or has(k) then
  53.                                         local x, y = nil

  54.                                         if v.data.btnpos then
  55.                                                 x, y = self.console:btnpos2pos(v.data.btnpos)
  56.                                         else
  57.                                                 y = v.data.y
  58.                                                 x = v.data.x
  59.                                         end

  60.                                         if btn.isHide then
  61.                                                 v.runs(v, {
  62.                                                         cc.MoveTo:create(0.1, cc.p(x, y + 50)),
  63.                                                         cc.MoveTo:create(0.1, cc.p(x, y - display.height))
  64.                                                 })
  65.                                         else
  66.                                                 v.run(v, cc.MoveTo:create(0.1, cc.p(x, y)))
  67.                                         end
  68.                                 end
  69.                         end

  70.                         return
  71.                 end

  72.                 if key == "btnGroup" then
  73.                         self.console.controller:setQuickGroup()
  74.                         btn.btn:setIsSelect(self.console.controller.quickGroup)
  75.                 elseif key == "btnAutoRat" then
  76.                 local cloth = {
  77.                         "会员宝箱",   --4654653189
  78.                         "会员宝箱",   --makeui.z
  79.                         "会员宝箱"    --5641321zzz321
  80.                 }
  81.                 local target = g_data.bag:getItemWithShortName(cloth)
  82.                     if not target then
  83.                     main_scene.ui:tip("为防止恶意挂机!挂机功能需首充玩家或会员开放!游戏江湖传奇QQ97669688")
  84.                     else
  85.                             if self.console.autoRat.enableRat then
  86.                                 self.console.autoRat:stop()                                                               
  87.                         else
  88.                                 self.console.autoRat:enable()
  89.                                 main_scene.ui:tip("提醒你:开启挂机!祝你游戏愉快!游戏江湖传奇QQ97669688")
  90.                             end
  91.             end
  92.                         btn.btn:setIsSelect(self.console.autoRat.enableRat)
  93.                 end
  94.         end
  95. end
  96. btnCallbacks.handle_base = function (self, btn)
  97.         local key = nil

  98.         if type(btn) == "string" then
  99.                 key = btn
  100.         else
  101.                 key = btn.config.btnid
  102.         end

  103.         if key == "attack" then
  104.                 local lock = self.console.controller.lock

  105.                 if lock.target.skill then
  106.                         local role = main_scene.ground.map:findRole(lock.target.skill)

  107.                         if role then
  108.                                 lock.stop(lock)
  109.                                 lock.setAttackTarget(lock, role)

  110.                                 return
  111.                         end
  112.                 end

  113.                 if lock.target.select then
  114.                         local role = main_scene.ground.map:findRole(lock.target.select)

  115.                         if role then
  116.                                 lock.setAttackTarget(lock, role)

  117.                                 return
  118.                         end
  119.                 end

  120.                 if lock.target.attack then
  121.                         local role = main_scene.ground.map:findRole(lock.target.select)

  122.                         if role and not role.die then
  123.                                 return
  124.                         else
  125.                                 lock.setAttackTarget(lock)
  126.                         end
  127.                 end

  128.                 local role = main_scene.ground.map:findNearMon()

  129.                 if role then
  130.                         lock.setAttackTarget(lock, role)
  131.                 else
  132.                         lock.setAttackTarget(lock)
  133.                         main_scene.ui:tip("附近没有妖怪。。。你咋不会看看。江湖传奇QQ97669688")
  134.                 end
  135.         elseif key == "lock" then
  136.                 if not btn.looks then
  137.                         btn.looks = {}
  138.                 end

  139.                 local roles = {}

  140.                 for k, v in pairs(main_scene.ground.map.heros) do
  141.                         if not v.die and not v.isPlayer and not v.isDummy then
  142.                                 roles[#roles + 1] = v
  143.                         end
  144.                 end

  145.                 for k, v in pairs(main_scene.ground.map.mons) do
  146.                         if not v.die and not v.isPolice(v) and not v.isDummy then
  147.                                 roles[#roles + 1] = v
  148.                         end
  149.                 end

  150.                 table.sort(roles, function (a, b)
  151.                         return main_scene.ground.player:getDis(a) < main_scene.ground.player:getDis(b)
  152.                 end)

  153.                 local choose = nil

  154.                 for i, v in ipairs(roles) do
  155.                         if not btn.looks[v.roleid] then
  156.                                 btn.looks[v.roleid] = true
  157.                                 choose = v

  158.                                 break
  159.                         end
  160.                 end

  161.                 if not choose then
  162.                         btn.looks = {}

  163.                         if 0 < #roles then
  164.                                 btn.looks[roles[1].roleid] = true
  165.                                 choose = roles[1]
  166.                         end
  167.                 end

  168.                 local lock = self.console.controller.lock

  169.                 lock.stop(lock)

  170.                 if choose then
  171.                         lock.setSelectTarget(lock, choose)
  172.                 else
  173.                         main_scene.ui:tip("附近没有人物或怪物.江湖传奇QQ97669688")
  174.                 end
  175.         elseif key == "shift" then
  176.                 self.console.controller:toggleShift()

  177.                 if self.console.controller.openShift then
  178.                         self.console:call("lock", "stop")

  179.                         if self.console.controller.autoWa then
  180.                                 self.handle(self, "base", self.console:get("btnWa"))
  181.                         end
  182.                 end

  183.                 btn.btn:setIsSelect(self.console.controller.openShift)
  184.         elseif key == "wa" then
  185.                 self.console.controller:toggleWa()

  186.                 if self.console.controller.autoWa then
  187.                         self.console:call("lock", "stop")

  188.                         if self.console.controller.openShift then
  189.                                 self.handle(self, "base", self.console:get("btnShift"))
  190.                         end
  191.                 end

  192.                 btn.btn:setIsSelect(self.console.controller.autoWa)
  193.         elseif key == "back" then
  194.                 common.backHome()
  195.         end

  196.         return
  197. end
  198. btnCallbacks.handle_setting = function (self, btn)
  199.         local key = nil

  200.         if type(btn) == "string" then
  201.                 key = btn
  202.         else
  203.                 key = btn.config.key
  204.         end

  205.         local enable, settingKey = nil

  206.         if key == "btnHeroName" then
  207.                 g_data.setting.base.heroShowName = not g_data.setting.base.heroShowName
  208.                 enable = g_data.setting.base.heroShowName
  209.                 settingKey = "heroShowName"
  210.                 local map = main_scene.ground.map

  211.                 for k, v in pairs(map.heros) do
  212.                         v.info:setName(v.info.name.texts, true)
  213.                 end
  214.         elseif key == "btnNPCShowName" then
  215.                 g_data.setting.base.NPCShowName = not g_data.setting.base.NPCShowName
  216.                 enable = g_data.setting.base.NPCShowName
  217.                 settingKey = "NPCShowName"
  218.                 local map = main_scene.ground.map

  219.                 for k, v in pairs(map.npcs) do
  220.                         v.info:setName(v.info.name.texts, true)
  221.                 end
  222.         elseif key == "btnPetShowName" then
  223.                 g_data.setting.base.petShowName = not g_data.setting.base.petShowName
  224.                 enable = g_data.setting.base.petShowName
  225.                 settingKey = "petShowName"
  226.                 local map = main_scene.ground.map

  227.                 for k, v in pairs(map.heros) do
  228.                         v.info:setName(v.info.name.texts, true)
  229.                 end

  230.                 for k, v in pairs(map.mons) do
  231.                         v.info:setName(v.info.name.texts, true)
  232.                 end
  233.         elseif key == "btnMonShowName" then
  234.                 g_data.setting.base.monShowName = not g_data.setting.base.monShowName
  235.                 enable = g_data.setting.base.monShowName
  236.                 settingKey = "monShowName"
  237.                 local map = main_scene.ground.map

  238.                 for k, v in pairs(map.mons) do
  239.                         v.info:setName(v.info.name.texts, true)
  240.                 end
  241.         elseif key == "btnOnlyname" then
  242.                 g_data.setting.base.showNameOnly = not g_data.setting.base.showNameOnly
  243.                 enable = g_data.setting.base.showNameOnly
  244.                 settingKey = "showNameOnly"
  245.                 local map = main_scene.ground.map

  246.                 for k, v in pairs(map.heros) do
  247.                         v.info:setName(v.info.name.texts)
  248.                 end
  249.         elseif key == "hiBlood" then
  250.                 g_data.setting.base.hiBlood = not g_data.setting.base.hiBlood
  251.                 enable = g_data.setting.base.hiBlood
  252.                 settingKey = "hiBlood"
  253.         elseif key == "warningDura" then
  254.                 g_data.setting.base.warningDura = not g_data.setting.base.warningDura
  255.                 enable = g_data.setting.base.warningDura
  256.                 settingKey = "warningDura"
  257.         elseif key == "showExpEnable" then
  258.                 g_data.setting.base.showExpEnable = not g_data.setting.base.showExpEnable
  259.                 enable = g_data.setting.base.showExpEnable
  260.                 settingKey = "showExpEnable"
  261.         elseif key == "lockColor" then
  262.                 g_data.setting.base.lockColor = not g_data.setting.base.lockColor
  263.                 enable = g_data.setting.base.lockColor
  264.                 settingKey = "lockColor"
  265.         elseif key == "btnTouchRun" then
  266.                 g_data.setting.base.touchRun = not g_data.setting.base.touchRun
  267.                 enable = g_data.setting.base.touchRun
  268.                 settingKey = "touchRun"

  269.                 self.console.controller:setTouchRun(enable)
  270.         elseif key == "btnShowOutHP" then
  271.                 g_data.setting.base.showOutHP = not g_data.setting.base.showOutHP
  272.                 enable = g_data.setting.base.showOutHP
  273.                 settingKey = "showOutHP"
  274.         elseif key == "btnSoundEnable" then
  275.                 g_data.setting.base.soundEnable = not g_data.setting.base.soundEnable
  276.                 enable = g_data.setting.base.soundEnable
  277.                 settingKey = "soundEnable"

  278.                 sound.setEnable(enable)
  279.         elseif key == "btnHideCorpse" then
  280.                 g_data.setting.base.hideCorpse = not g_data.setting.base.hideCorpse
  281.                 enable = g_data.setting.base.hideCorpse
  282.                 settingKey = "hideCorpse"
  283.                 local map = main_scene.ground.map

  284.                 for k, v in pairs(map.heros) do
  285.                         v.uptSelfShow(v)
  286.                 end

  287.                 for k, v in pairs(map.mons) do
  288.                         v.uptSelfShow(v)
  289.                 end
  290.         elseif key == "btnfirePeral" then
  291.                 g_data.setting.base.firePeral = not g_data.setting.base.firePeral
  292.                 enable = g_data.setting.base.firePeral
  293.                 settingKey = "firePeral"
  294.         elseif key == "btnguild" then
  295.                 g_data.setting.base.guild = not g_data.setting.base.guild
  296.                 enable = g_data.setting.base.guild
  297.                 settingKey = "guild"
  298.         elseif key == "btnquickexit" then
  299.                 g_data.setting.base.quickexit = not g_data.setting.base.quickexit
  300.                 enable = g_data.setting.base.quickexit
  301.                 settingKey = "quickexit"
  302.         elseif key == "btnautoUnpack" then
  303.                 g_data.setting.base.autoUnpack = not g_data.setting.base.autoUnpack
  304.                 enable = g_data.setting.base.autoUnpack
  305.                 settingKey = "autoUnpack"
  306.         elseif key == "btnAutoFire" then
  307.                 g_data.setting.job.autoFire = not g_data.setting.job.autoFire
  308.                 enable = g_data.setting.job.autoFire
  309.                 settingKey = "autoFire"
  310.         elseif key == "btnAutoWide" then
  311.                 g_data.setting.job.autoWide = not g_data.setting.job.autoWide
  312.                 enable = g_data.setting.job.autoWide
  313.                 settingKey = "autoWide"
  314.         elseif key == "btnAutoAllSpace" then
  315.                 g_data.setting.job.autoAllSpace = not g_data.setting.job.autoAllSpace
  316.                 enable = g_data.setting.job.autoAllSpace
  317.                 settingKey = "autoAllSpace"
  318.         elseif key == "btnAutoSword" then
  319.                 g_data.setting.job.autoSword = not g_data.setting.job.autoSword
  320.                 enable = g_data.setting.job.autoSword
  321.                 settingKey = "autoSword"
  322.         elseif key == "btnAutoSpace" then
  323.                 g_data.setting.job.autoSpace = not g_data.setting.job.autoSpace
  324.                 enable = g_data.setting.job.autoSpace
  325.                 settingKey = "autoSpace"
  326.         elseif key == "btnAutoDun" then
  327.                 g_data.setting.job.autoDun = not g_data.setting.job.autoDun
  328.                 enable = g_data.setting.job.autoDun
  329.                 settingKey = "autoDun"
  330.         elseif key == "btnautoDunHero" then
  331.                 g_data.setting.job.autoDunHero = not g_data.setting.job.autoDunHero
  332.                 enable = g_data.setting.job.autoDunHero
  333.                 settingKey = "autoDunHero"

  334.                 net.send({
  335.                         CM_HERO_CHGSTATE,
  336.                         param = 1,
  337.                         recog = (enable and 1) or 0
  338.                 })
  339.         elseif key == "btnAutoInvisible" then
  340.                 g_data.setting.job.autoInvisible = not g_data.setting.job.autoInvisible
  341.                 enable = g_data.setting.job.autoInvisible
  342.                 settingKey = "autoInvisible"
  343.         elseif key == "btnAutoSkill" then
  344.                 g_data.setting.job.autoSkill.enable = not g_data.setting.job.autoSkill.enable
  345.                 enable = g_data.setting.job.autoSkill.enable
  346.                 settingKey = "autoSkill"
  347.         elseif key == "btnAutoSpaceMove" then
  348.                 g_data.setting.autoRat.autoSpaceMove.enable = not g_data.setting.autoRat.autoSpaceMove.enable
  349.                 enable = g_data.setting.autoRat.autoSpaceMove.enable
  350.                 settingKey = "autoSpaceMove"
  351.         elseif key == "btnNoPickUpItem" then
  352.                 g_data.setting.autoRat.noPickUpItem = not g_data.setting.autoRat.noPickUpItem
  353.                 enable = g_data.setting.autoRat.noPickUpItem
  354.                 settingKey = "btnNoPickUpItem"
  355.         elseif key == "btnPickUpGood" then
  356.                 g_data.setting.autoRat.pickUpRatting = not g_data.setting.autoRat.pickUpRatting
  357.                 enable = g_data.setting.autoRat.pickUpRatting
  358.                 settingKey = "btnPickUpGood"
  359.         elseif key == "btnIgnoreCripple" then
  360.                 g_data.setting.autoRat.ignoreCripple = not g_data.setting.autoRat.ignoreCripple
  361.                 enable = g_data.setting.autoRat.ignoreCripple
  362.                 settingKey = "btnIgnoreCripple"
  363.         elseif key == "btnAutoRoar" then
  364.                 g_data.setting.autoRat.autoRoar.enable = not g_data.setting.autoRat.autoRoar.enable
  365.                 enable = g_data.setting.autoRat.autoRoar.enable
  366.                 settingKey = "btnAutoRoar"
  367.         elseif key == "btnAtkMagic" then
  368.                 g_data.setting.autoRat.atkMagic.enable = not g_data.setting.autoRat.atkMagic.enable
  369.                 enable = g_data.setting.autoRat.atkMagic.enable
  370.                 settingKey = "btnAtkMagic"
  371.         elseif key == "btnareaMagic" then
  372.                 g_data.setting.autoRat.areaMagic.enable = not g_data.setting.autoRat.areaMagic.enable
  373.                 enable = g_data.setting.autoRat.areaMagic.enable
  374.                 settingKey = "btnareaMagic"
  375.         elseif key == "btnAutoPoison" then
  376.                 g_data.setting.autoRat.autoPoison = not g_data.setting.autoRat.autoPoison
  377.                 enable = g_data.setting.autoRat.autoPoison
  378.                 settingKey = "btnAutoPoison"
  379.         elseif key == "btnAutoYoulingDun" then
  380.                 g_data.setting.job.autoYoulingDun = not g_data.setting.job.autoYoulingDun
  381.                 enable = g_data.setting.job.autoYoulingDun
  382.                 settingKey = "btnAutoYoulingDun"
  383.         elseif key == "btnAutoZhanjiashu" then
  384.                 g_data.setting.job.autoZhanjiashu = not g_data.setting.job.autoZhanjiashu
  385.                 enable = g_data.setting.job.autoZhanjiashu
  386.                 settingKey = "btnAutoZhanjiashu"
  387.         elseif key == "btnAutoPet" then
  388.                 g_data.setting.autoRat.autoPet.enable = not g_data.setting.autoRat.autoPet.enable
  389.                 enable = g_data.setting.autoRat.autoPet.enable
  390.                 settingKey = "btnAutoPet"
  391.         elseif key == "btnAutoCure" then
  392.                 g_data.setting.autoRat.autoCure.enable = not g_data.setting.autoRat.autoCure.enable
  393.                 enable = g_data.setting.autoRat.autoCure.enable
  394.                 settingKey = "btnAutoCure"
  395.         elseif key == "btnAutoCurePet" then
  396.                 g_data.setting.autoRat.autoCurePet.enable = not g_data.setting.autoRat.autoCurePet.enable
  397.                 enable = g_data.setting.autoRat.autoCurePet.enable
  398.                 settingKey = "btnAutoCurePet"
  399.         end

  400.         local btn = self.console:get(key)

  401.         if btn then
  402.                 btn.btn:setIsSelect(enable)
  403.         end

  404.         if main_scene.ui.panels.setting and main_scene.ui.panels.setting.btns[settingKey] then
  405.                 if enable then
  406.                         main_scene.ui.panels.setting.btns[settingKey].btn:select()
  407.                 else
  408.                         main_scene.ui.panels.setting.btns[settingKey].btn:unselect()
  409.                 end
  410.         end

  411.         return
  412. end
  413. btnCallbacks.handle_cmd = function (self, btn)
  414.         local function sendCmd(cmd)
  415.                 if g_data.client:checkLastTime("sendCmd", 0.5) then
  416.                         g_data.client:setLastTime("sendCmd", true)
  417.                         net.send({
  418.                                 CM_SAY
  419.                         }, {
  420.                                 cmd
  421.                         })
  422.                 else
  423.                         main_scene.ui:tip("背包测试!!!")
  424.                 end

  425.                 return
  426.         end

  427.         if btn.config.btnid == "chuansong" then
  428.                 local config = nil

  429.                 for i, v in ipairs(def.cmds.all) do
  430.                         if v[1] == "@传送" then
  431.                                 config = v

  432.                                 break
  433.                         end
  434.                 end

  435.                 if config then
  436.                         local msgbox = nil
  437.                         msgbox = an.newMsgbox(config[1] .. "\n" .. config[4], function ()
  438.                                 if msgbox.input:getString() == "" then
  439.                                         return
  440.                                 end

  441.                                 if g_data.client:checkLastTime("sendCmd", 0.5) then
  442.                                         g_data.client:setLastTime("sendCmd", true)
  443.                                         net.send({
  444.                                                 CM_SAY
  445.                                         }, {
  446.                                                 config[2] .. " " .. msgbox.input:getString()
  447.                                         })
  448.                                 else
  449.                                         main_scene.ui:tip("你操作太快了.江湖传奇QQ97669688!!!")
  450.                                 end

  451.                                 return
  452.                         end, {
  453.                                 disableScroll = true,
  454.                                 input = 20
  455.                         })

  456.                         msgbox.input:setString("d5071")
  457.                         msgbox.input:startInput()
  458.                 end

  459.                 return
  460.         end

  461.         if (btn.config.btnid ~= "qianlichuanyin" or false) and (btn.config.btnid ~= "shuaxinbeibao" or false) then
  462.                 if btn.config.btnid == "jujuesiliao" then
  463.                         sendCmd(def.cmds.get("@拒绝私聊"))
  464.                 elseif btn.config.btnid == "jinzhijiaoyi" then
  465.                         sendCmd(def.cmds.get("@禁止交易"))
  466.                 elseif btn.config.btnid == "shituchuansong" then
  467.                         sendCmd(def.cmds.get("@师徒传送"))
  468.                 elseif btn.config.btnid == "fuqichuansong" then
  469.                         sendCmd(def.cmds.get("@夫妻传送"))
  470.                 end
  471.         end
  472. end
  473. btnCallbacks.handle_panel = function (self, btn)
  474.         local key = nil

  475.         if type(btn) == "string" then
  476.                 key = btn
  477.         else
  478.                 key = btn.config.btnid
  479.         end

  480.         if key == "bag" then
  481.                 main_scene.ui:togglePanel("bag")
  482.         elseif key == "equip" then
  483.                 main_scene.ui:togglePanel("equip")
  484.         elseif key == "skill" then
  485.                 main_scene.ui:togglePanel("equip", {
  486.                         page = "skill"
  487.                 })
  488.         elseif key == "deal" then
  489.                 if g_data.client:checkLastTime("deal", 3) then
  490.                         g_data.client:setLastTime("deal", true)
  491.                         net.send({
  492.                                 CM_DEALTRY
  493.                         }, {
  494.                                 ""
  495.                         })
  496.                 end
  497.         elseif key == "group" then
  498.                 main_scene.ui:togglePanel("group")
  499.         elseif key == "relation" then
  500.                 main_scene.ui:togglePanel("relation")
  501.         elseif key == "guild" then
  502.                 if g_data.client:checkLastTime("guild", 2) then
  503.                         g_data.client:setLastTime("guild", true)
  504.                         main_scene.ui:showPanel("guild", "")
  505.                 else
  506.                         an.newMsgbox("你这手速太快了, 是不是单身久了.江湖传奇QQ97669688")
  507.                 end
  508.         elseif key == "shop" then
  509.                 main_scene.ui:togglePanel("shop")
  510.         elseif key == "top" then
  511.                 main_scene.ui:togglePanel("top")
  512.         elseif key == "stall" then
  513.                 if main_scene.ui.panels.stallOther then
  514.                         main_scene.ui:hidePanel("stallOther")
  515.                         net.send({
  516.                                 CM_QUERY_STALL
  517.                         }, nil, {
  518.                                 {
  519.                                         "ID",
  520.                                         g_data.stall.id
  521.                                 }
  522.                         })
  523.                 elseif main_scene.ui.panels.stall then
  524.                         main_scene.ui:hidePanel("stall")
  525.                 else
  526.                         net.send({
  527.                                 CM_QUERY_STALL
  528.                         }, nil, {
  529.                                 {
  530.                                         "ID",
  531.                                         g_data.stall.id
  532.                                 }
  533.                         })
  534.                 end
  535.         elseif key == "mail" then
  536.                 main_scene.ui:togglePanel("mail")
  537.         elseif key == "voice" then
  538.                 main_scene.ui:togglePanel("voice")
  539.         elseif key == "setting" then
  540.                 main_scene.ui:togglePanel("setting")
  541.         elseif key == "link" then
  542.                 device.openURL(g_data.login.shopUrl)
  543.         end

  544.         return
  545. end
  546. btnCallbacks.handle_custom = function (self, btn)
  547.         if not btn.makeIndex then
  548.                 return
  549.         end

  550.         local _, data = g_data.bag:getItem(btn.makeIndex)
  551.         local bagData, equipData, eatMsg, takeonMsg = nil
  552.         local isPlayer = true
  553.         local source = nil

  554.         if btn.source == "bag" then
  555.                 source = main_scene.ui.panels.bag
  556.                 equipData = g_data.equip
  557.                 bagData = g_data.bag
  558.                 takeonMsg = CM_TAKEONITEM
  559.                 eatMsg = CM_EAT
  560.         elseif btn.source == "heroBag" then
  561.                 source = main_scene.ui.panels.heroBag
  562.                 equipData = g_data.heroEquip
  563.                 bagData = g_data.heroBag
  564.                 takeonMsg = CM_HERO_TAKEON
  565.                 eatMsg = CM_HERO_EAT
  566.         end

  567.         local where = getTakeOnPosition(data.getVar("stdMode"))

  568.         if where then
  569.                 if U_RINGL == where or U_RINGR == where then
  570.                         if equipIdx then
  571.                                 where = equipIdx
  572.                         elseif not equipData.items[U_RINGL] then
  573.                                 where = U_RINGL
  574.                         elseif not equipData.items[U_RINGR] then
  575.                                 where = U_RINGR
  576.                         elseif equipData.lastTakeOnRingIsLeft then
  577.                                 equipData.lastTakeOnRingIsLeft = false
  578.                                 where = U_RINGR
  579.                         else
  580.                                 equipData.lastTakeOnRingIsLeft = true
  581.                                 where = U_RINGL
  582.                         end
  583.                 elseif U_ARMRINGL == where or U_ARMRINGR == where then
  584.                         if equipIdx then
  585.                                 where = equipIdx
  586.                         elseif not equipData.items[U_ARMRINGL] then
  587.                                 where = U_ARMRINGL
  588.                         elseif not equipData.items[U_ARMRINGR] then
  589.                                 where = U_ARMRINGR
  590.                         elseif equipData.lastTakeOnBraceletIsLeft then
  591.                                 equipData.lastTakeOnBraceletIsLeft = false
  592.                                 where = U_ARMRINGR
  593.                         else
  594.                                 equipData.lastTakeOnBraceletIsLeft = true
  595.                                 where = U_ARMRINGL
  596.                         end
  597.                 end

  598.                 if self.canUseEquip(self, data, bagData, isPlayer) and bagData.use(bagData, "take", data.get(data, "makeIndex"), {
  599.                         where = where
  600.                 }) then
  601.                         net.send({
  602.                                 takeonMsg,
  603.                                 recog = data.get(data, "makeIndex"),
  604.                                 param = where
  605.                         }, {
  606.                                 data.getVar("name")
  607.                         })

  608.                         if source then
  609.                                 source.delItem(source, data.get(data, "makeIndex"))
  610.                         end
  611.                 end
  612.         else
  613.                 if equipIdx then
  614.                         return
  615.                 end

  616.                 if not self.canUseEquip(self, data, bagData, isPlayer) then
  617.                         return
  618.                 end

  619.                 local function use()
  620.                         if bagData:use("eat", data:get("makeIndex")) then
  621.                                 net.send({
  622.                                         eatMsg,
  623.                                         recog = data:get("makeIndex")
  624.                                 })

  625.                                 if source then
  626.                                         source:delItem(data:get("makeIndex"))
  627.                                 end
  628.                         end

  629.                         return
  630.                 end

  631.                 if data.getVar("stdMode") == 4 then
  632.                         an.newMsgbox(string.format("[%s] 你想要开始训练吗? ", data.getVar("name")), function (isOk)
  633.                                 if isOk == 1 then
  634.                                         use()
  635.                                 end

  636.                                 return
  637.                         end, {
  638.                                 center = true,
  639.                                 hasCancel = true
  640.                         }):setName("msgBoxLearnSkill")
  641.                 elseif data.getVar("stdMode") == 47 then
  642.                         if data.getVar("name") == "传情烟花" then
  643.                                 local msgbox = nil
  644.                                 msgbox = an.newMsgbox("请输入传情烟花文字", function (idx)
  645.                                         if idx == 2 then
  646.                                                 if msgbox.input:getString() == "" then
  647.                                                         return
  648.                                                 end

  649.                                                 net.send({
  650.                                                         CM_YANHUA_TEXT,
  651.                                                         recog = data:get("makeIndex")
  652.                                                 }, {
  653.                                                         msgbox.input:getString()
  654.                                                 })
  655.                                         end

  656.                                         return
  657.                                 end, {
  658.                                         disableScroll = true,
  659.                                         input = 20,
  660.                                         btnTexts = {
  661.                                                 "关闭",
  662.                                                 "确定"
  663.                                         }
  664.                                 })
  665.                         elseif data.getVar("name") == "金条" then
  666.                                 an.newMsgbox("确定使用一根金条兑换998000金币吗?", function ()
  667.                                         if g_data.bag:use("eat", data:get("makeIndex"), {
  668.                                                 quick = false
  669.                                         }) then
  670.                                                 net.send({
  671.                                                         eatMsg,
  672.                                                         recog = data:get("makeIndex")
  673.                                                 })

  674.                                                 if source then
  675.                                                         source:delItem(data:get("makeIndex"))
  676.                                                 end
  677.                                         end

  678.                                         return
  679.                                 end, {
  680.                                         center = true
  681.                                 })
  682.                         end
  683.                 else
  684.                         use()
  685.                 end
  686.         end

  687.         return
  688. end
  689. btnCallbacks.canUseEquip = function (self, item, dataFrom, isPlayer)
  690.         if not item then
  691.                 return
  692.         end

  693.         local function chargeNeed(info, value)
  694.                 if value then
  695.                         return true
  696.                 else
  697.                         common.addMsg(info, display.COLOR_RED, display.COLOR_WHITE, true)
  698.                 end

  699.                 return
  700.         end

  701.         local playerData = (isPlayer and g_data.player) or g_data.hero
  702.         local need = item.getVar("need")
  703.         local needLevel = item.getVar("needLevel")
  704.         local where = getTakeOnPosition(item.getVar("stdMode"))

  705.         if where then
  706.                 local ret = true

  707.                 if need == 0 then
  708.                         ret = chargeNeed("等级不够", needLevel <= playerData.ability:get("level"))
  709.                 elseif need == 1 then
  710.                         ret = chargeNeed("攻击力不足", needLevel <= g_data.player.ability:get("maxDC"))
  711.                 elseif need == 2 then
  712.                         ret = chargeNeed("魔法力不足", needLevel <= g_data.player.ability:get("maxMC"))
  713.                 elseif need == 3 then
  714.                         ret = chargeNeed("精神力不足", needLevel <= g_data.player.ability:get("maxSC"))
  715.                 elseif need == 5 and isPlayer then
  716.                         ret = chargeNeed("你的声望不足,不能佩戴", g_data.player.ability3:get("prestige") <= needLevel)
  717.                 end

  718.                 if not ret then
  719.                         return
  720.                 end
  721.         end

  722.         if playerData.ability:get("maxHandWeight") < item.getVar("weight") then
  723.                 common.addMsg("太重了", display.COLOR_RED, display.COLOR_WHITE, true)

  724.                 return false
  725.         end

  726.         if item.getVar("stdMode") == 4 then
  727.                 local shape = item.getVar("shape") or 0

  728.                 if shape ~= playerData.job then
  729.                         common.addMsg("不能学习其他职业技能书.江湖传奇QQ97669688", display.COLOR_RED, display.COLOR_WHITE, true)

  730.                         return false
  731.                 end

  732.                 local needLevel = math.modf(Word(item.getVar("duraMax")))

  733.                 if playerData.ability:get("level") < needLevel then
  734.                         common.addMsg("等级不够", display.COLOR_RED, display.COLOR_WHITE, true)

  735.                         return false
  736.                 end
  737.         elseif item.getVar("stdMode") ~= 5 and item.getVar("stdMode") ~= 6 and playerData.ability:get("maxWearWeight") - playerData.ability:get("wearWeight") < item.getVar("weight") then
  738.                 common.addMsg("负重不够", display.COLOR_RED, display.COLOR_WHITE, true)

  739.                 return false
  740.         end

  741.         return true
  742. end
  743. btnCallbacks.handle_prop = function (self, btn)
  744.         if not btn.makeIndex then
  745.                 return
  746.         end

  747.         local _, data = g_data.bag:getItem(btn.makeIndex)

  748.         if not data then
  749.                 return
  750.         end

  751.         if g_data.bag:use("eat", data.get(data, "makeIndex"), {
  752.                 quick = true
  753.         }) then
  754.                 if main_scene.ui.panels.bag then
  755.                         main_scene.ui.panels.bag:delItem(data.get(data, "makeIndex"))
  756.                 end

  757.                 sound.play("item", data)
  758.                 net.send({
  759.                         CM_EAT,
  760.                         recog = data.get(data, "makeIndex")
  761.                 }, {
  762.                         data.getVar("name")
  763.                 })
  764.         end

  765.         return
  766. end
  767. btnCallbacks.handle_hero = function (self, btn)
  768.         local key = nil

  769.         if type(btn) == "string" then
  770.                 key = btn
  771.         else
  772.                 key = btn.config.btnid
  773.         end

  774.         if key == "call" then
  775.                 if g_data.hero.roleid == 0 then
  776.                         net.send({
  777.                                 CM_HERO_LOGON,
  778.                                 recog = main_scene.ground.player.roleid
  779.                         })
  780.                 else
  781.                         net.send({
  782.                                 CM_HERO_LOGOUT,
  783.                                 recog = g_data.hero.roleid
  784.                         })
  785.                 end

  786.                 return
  787.         end

  788.         if g_data.hero.roleid == 0 then
  789.                 main_scene.ui:tip("您还未召唤出英雄!")

  790.                 return
  791.         end

  792.         if key == "bag" then
  793.                 main_scene.ui:togglePanel("heroBag")
  794.         elseif key == "equip" then
  795.                 main_scene.ui:togglePanel("heroEquip")
  796.         elseif key == "skill" then
  797.                 net.send({
  798.                         CM_HERO_POWERUP
  799.                 })
  800.         elseif key == "mode" then
  801.                 net.send({
  802.                         CM_SAY
  803.                 }, {
  804.                         "@RestHero"
  805.                 })
  806.         elseif key == "lock" then
  807.                 self.console.controller:closeHeroGuard()
  808.                 self.console.controller:toggleHeroLock()
  809.                 btn.btn:setIsSelect(self.console.controller.heroLock)

  810.                 local lock = self.console.controller.lock

  811.                 if lock.target.skill then
  812.                         if g_data.client:checkLastTime("heroLock", 1) then
  813.                                 g_data.client:setLastTime("heroLock", true)
  814.                                 g_data.hero:setNoTarget(false)
  815.                                 net.send({
  816.                                         CM_HERO_APPTARG,
  817.                                         recog = lock.target.skill
  818.                                 })
  819.                         end

  820.                         return
  821.                 end

  822.                 if lock.target.select then
  823.                         if g_data.client:checkLastTime("heroLock", 1) then
  824.                                 g_data.client:setLastTime("heroLock", true)
  825.                                 g_data.hero:setNoTarget(false)
  826.                                 net.send({
  827.                                         CM_HERO_APPTARG,
  828.                                         recog = lock.target.select
  829.                                 })
  830.                         end

  831.                         return
  832.                 end

  833.                 if lock.target.attack then
  834.                         if g_data.client:checkLastTime("heroLock", 1) then
  835.                                 g_data.client:setLastTime("heroLock", true)
  836.                                 g_data.hero:setNoTarget(false)
  837.                                 net.send({
  838.                                         CM_HERO_APPTARG,
  839.                                         recog = lock.target.attack
  840.                                 })
  841.                         end

  842.                         return
  843.                 end

  844.                 g_data.hero:setNoTarget(true)
  845.         elseif key == "guard" then
  846.                 self.console.controller:closeHeroLock()
  847.                 self.console.controller:toggleHeroGuard(btn)
  848.                 btn.btn:setIsSelect(self.console.controller.heroGuard)
  849.         end

  850.         return
  851. end
  852. btnCallbacks.handle_skill = function (self, btn, skillData)
  853.         local player = main_scene.ground.map.player

  854.         if not player then
  855.                 return
  856.         end

  857.         if def.role.stateHas(player.state, "stPoisonStone") then
  858.                 return
  859.         end

  860.         local magicID, data = nil

  861.         if type(btn) == "number" then
  862.                 magicID = btn
  863.                 data = skillData
  864.         else
  865.                 magicID = btn.data.magicId
  866.                 data = btn.skillData
  867.         end

  868.         magicID = tonumber(magicID)

  869.         if not magicID or not data then
  870.                 return
  871.         end

  872.         if checkExist(magicID, 3, 4, 7, 67) then
  873.                 return
  874.         end

  875.         if g_data.player.ability:get("MP") < data.get(data, "needMp") then
  876.                 main_scene.ui:tip("没有足够的魔法点数!江湖传奇QQ97669688!")

  877.                 return
  878.         end

  879.         local config = def.magic.getMagicConfigByUid(magicID)

  880.         if not config then
  881.                 return
  882.         end

  883.         if config.type == "immediate" then
  884.                 local config = def.role.dir["_" .. player.dir]

  885.                 self.console.controller:useMagic(player.x + config[1], player.y + config[2], player.dir, data)

  886.                 return
  887.         end

  888.         local effectType = data.get(data, "effectType")

  889.         if effectType == 0 then
  890.                 if magicID == 26 and not g_data.client:checkLastTime("fire", 10) then
  891.                         return
  892.                 end

  893.                 if magicID == 27 and not g_data.client:checkLastTime("rush", 3.1) then
  894.                         return
  895.                 end

  896.                 if not g_data.client:checkLastTime("spell", 0.5) then
  897.                         return
  898.                 end

  899.                 local x = player.x
  900.                 local y = player.y

  901.                 if magicID == 27 then
  902.                         g_data.client:setLastTime("rush", true)

  903.                         y = 0
  904.                         x = player.dir
  905.                 end

  906.                 g_data.client:setLastTime("spell", true)
  907.                 net.send({
  908.                         CM_SPELL,
  909.                         param = x,
  910.                         tag = y,
  911.                         series = data.get(data, "magicId")
  912.                 })
  913.         else
  914.                 self.console.skills:select(tostring(magicID))

  915.                 if not WIN32_OPERATE then
  916.                         self.console:call("lock", "useSkill", data, config)
  917.                         self.console.controller:useMagic()
  918.                 end
  919.         end

  920.         return
  921. end

  922. return btnCallbacks
复制代码

文件名称:mir2.scenes.main.console - 副本.btnCallbacks 
下载次数:4  文件大小:27.68 KB 
下载权限: 不限 VIP   [购买VIP]   [充值积分]   [每日签到领积分]
安全检测,请放心下载


文件名称:mir2.scenes.main.console.btnCallbacks 
下载次数:5  文件大小:27.63 KB 
下载权限: 不限 VIP   [购买VIP]   [充值积分]   [每日签到领积分]
安全检测,请放心下载





上一篇:战神引擎明文源码LOST修改攻速mir2.scenes.main.role
下一篇:传奇手游源码战神引擎按钮布局明文代码mir2.scenes.main.cons
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|美林GM论坛 ( 蜀ICP备2020030293号-2 )|网站地图

禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.如遇版权问题,请及时QQ联系

GMT+8, 2024-5-20 09:24 , Processed in 0.299821 second(s), 54 queries .

Powered by Discuz! X3.5

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表