|
战神攻速插件mir2.scenes.main.role.hero明文代码
检测背包物品触发攻速和佩戴装备触发攻速
下方明文代码为完整版,直接复制保存到mir2.scenes.main.role.hero 即可
点击下载攻速插件及明文源码包
- local role = import(".role")
- local hero = class("hero", role)
- table.merge(hero, {
- lastAttackTime = 0,
- lastSpellTime = 0
- })
- hero.ctor = function (self, params)
- hero.super.ctor(self, params)
- self.sex = nil
- self.job = nil
- self.isHelper = params.isHelper
- self.lastAttackTime = 0
- self.endWarModeAction = nil
- self.initEnd(self)
- if params.isPlayer and main_scene.ui.console.autoRat.enableRat then
- self.showAutoRatHint(self)
- end
- return
- end
- hero.showAutoRatHint = function (self)
- if not self.autoRatHintSpr then
- local x, y = self.node:centerPos()
- self.autoRatHintSpr = res.get2("pic/console/autoRat.png"):add2(self.node, 1):pos(x, 108)
- end
- return
- end
- hero.hideAutoRatHint = function (self)
- if self.autoRatHintSpr then
- self.autoRatHintSpr:removeSelf()
- self.autoRatHintSpr = nil
- end
- return
- end
- hero.getParts = function (self, feature)
- local parts = {}
- local sex = feature.get(feature, "sex")
- local weapon = def.role.getHeroWeapon(feature.get(feature, "weapon")*2 + sex)
- local dress = def.role.getHeroDress(feature.get(feature, "dress")*2 + sex)
- local hairImg, hair = def.role.hair(feature)
- self.sex = sex
- self.hair = hair
- local frame = def.role.getDressFrame(0)
- parts.dress = {
- id = dress.Id,
- imgid = string.lower(dress.WhichLib or ""),
- offset = dress.OffSet,
- frame = frame or {}
- }
- parts.weapon = {
- id = weapon.Id,
- imgid = string.lower(weapon.WhichLib or ""),
- offset = weapon.OffSet,
- frame = frame or {}
- }
- if self.sex == 1 then
- parts.weapon.delete = weapon.Id == 1
- else
- parts.weapon.delete = not weapon.Id
- end
- parts.hair = {
- id = hair,
- imgid = hairImg,
- offset = def.role.humFrame*hair,
- frame = frame or {},
- delete = hair == 0
- }
- if dress.WihichEffectLib then
- parts.humEffect = {
- blend = true,
- id = dress.Id,
- imgid = string.lower(dress.WihichEffectLib or ""),
- offset = dress.EffectOffSet,
- offsetEnd = dress.offsetEnd,
- delay = dress.delay,
- alwaysPlay = dress.alwaysPlay,
- frame = frame
- }
- else
- parts.humEffect = {
- delete = true
- }
- end
- return parts, sex
- end
- hero.addAct = function (self, params)
- if self.endWarModeAction then
- self.node:stopAction(self.endWarModeAction)
- end
- if params.type == "hit" or params.type == "spell" or params.type == "heavyHit" or params.type == "bigHit" then
- if params.type == "spell" then
- lastSpellTime = socket.gettime()
- end
- self.lastAttackTime = socket.gettime()
- elseif params.type == "die" then
- if self.isPlayer then
- self.map:setGrayState()
- main_scene.ui.console.autoRat:stop()
- end
- if not params.corpse then
- sound.playSound(sound.s_man_die + self.sex)
- end
- end
- hero.super.addAct(self, params)
- return
- end
- hero.allExecuteEnd = function (self)
- if not self.die and self.last.act then
- local time = socket.gettime() - self.lastAttackTime
- if time < 4 then
- local act = {
- type = "warMode",
- dir = self.last.act.dir or self.dir
- }
- for k, v in pairs(self.sprites) do
- v.play(v, act)
- end
- _, self.endWarModeAction = self.node:runs({
- cc.DelayTime:create(time - 4),
- cc.CallFunc:create(function ()
- self:addStandAct()
- self.endWarModeAction = nil
- return
- end)
- })
- else
- hero.super.allExecuteEnd(self)
- end
- end
- self.isExecuteEnd = true
- return
- end
- hero.getHitTime = function (self)
- local cloth = {
- "会员证",
- "赞助证",
- "首充证"
- }
- local target = g_data.bag:getItemWithShortName(cloth)
- if not target then
- local hitSpeed = tonumber(avoidPlugValue(self.hitSpeed, true)) or 0
- local ret = math.max(0, def.role.speed.attack - math.min(300, hitSpeed*60)/1000)
- main_scene.ui:tip("检测到你背包没有携带会员宝箱,恢复原始速度!")
- return ret
- else
- local hitSpeed = tonumber(avoidPlugValue(self.hitSpeed, true)) or 0
- local ret = math.max(0, def.role.speed.attack - math.min(850, 850)/1)
- main_scene.ui:tip("检测到你背包携带会员宝箱,攻击疯狂加速中!")
-
- return ret
- end
- end
- hero.canNextHit = function (self)
- return self.getHitTime(self) < socket.gettime() - self.lastAttackTime
- end
- hero.getNextMagicDelay = function (self, magicId)
- local time = def.role.speed.spell + g_data.player:getMagicDelay(magicId)/1000
- return (self.lastSpellTime + time) - socket.gettime()
- end
- hero.canNextSpell = function (self, magicId)
- if self.isLocked(self) then
- return false
- end
- return self.getNextMagicDelay(self, magicId) <= 0
- end
- return hero
复制代码 佩戴装备触发攻速
- local role = import(".role")
- local hero = class("hero", role)
- table.merge(hero, {
- lastAttackTime = 0,
- lastSpellTime = 0
- })
- hero.ctor = function (self, params)
- hero.super.ctor(self, params)
- self.sex = nil
- self.job = nil
- self.isHelper = params.isHelper
- self.lastAttackTime = 0
- self.endWarModeAction = nil
- self.initEnd(self)
- if params.isPlayer and main_scene.ui.console.autoRat.enableRat then
- self.showAutoRatHint(self)
- end
- return
- end
- hero.showAutoRatHint = function (self)
- if not self.autoRatHintSpr then
- local x, y = self.node:centerPos()
- self.autoRatHintSpr = res.get2("pic/console/autoRat.png"):add2(self.node, 1):pos(x, 108)
- end
- return
- end
- hero.hideAutoRatHint = function (self)
- if self.autoRatHintSpr then
- self.autoRatHintSpr:removeSelf()
- self.autoRatHintSpr = nil
- end
- return
- end
- hero.getParts = function (self, feature)
- local parts = {}
- local sex = feature.get(feature, "sex")
- local weapon = def.role.getHeroWeapon(feature.get(feature, "weapon")*2 + sex)
- local dress = def.role.getHeroDress(feature.get(feature, "dress")*2 + sex)
- local hairImg, hair = def.role.hair(feature)
- self.sex = sex
- self.hair = hair
- local frame = def.role.getDressFrame(0)
- parts.dress = {
- id = dress.Id,
- imgid = string.lower(dress.WhichLib or ""),
- offset = dress.OffSet,
- frame = frame or {}
- }
- parts.weapon = {
- id = weapon.Id,
- imgid = string.lower(weapon.WhichLib or ""),
- offset = weapon.OffSet,
- frame = frame or {}
- }
- if self.sex == 1 then
- parts.weapon.delete = weapon.Id == 1
- else
- parts.weapon.delete = not weapon.Id
- end
- parts.hair = {
- id = hair,
- imgid = hairImg,
- offset = def.role.humFrame*hair,
- frame = frame or {},
- delete = hair == 0
- }
- if dress.WihichEffectLib then
- parts.humEffect = {
- blend = true,
- id = dress.Id,
- imgid = string.lower(dress.WihichEffectLib or ""),
- offset = dress.EffectOffSet,
- offsetEnd = dress.offsetEnd,
- delay = dress.delay,
- alwaysPlay = dress.alwaysPlay,
- frame = frame
- }
- else
- parts.humEffect = {
- delete = true
- }
- end
- return parts, sex
- end
- hero.addAct = function (self, params)
- if self.endWarModeAction then
- self.node:stopAction(self.endWarModeAction)
- end
- if params.type == "hit" or params.type == "spell" or params.type == "heavyHit" or params.type == "bigHit" then
- if params.type == "spell" then
- lastSpellTime = socket.gettime()
- end
- self.lastAttackTime = socket.gettime()
- elseif params.type == "die" then
- if self.isPlayer then
- self.map:setGrayState()
- main_scene.ui.console.autoRat:stop()
- end
- if not params.corpse then
- sound.playSound(sound.s_man_die + self.sex)
- end
- end
- hero.super.addAct(self, params)
- return
- end
- hero.allExecuteEnd = function (self)
- if not self.die and self.last.act then
- local time = socket.gettime() - self.lastAttackTime
- if time < 4 then
- local act = {
- type = "warMode",
- dir = self.last.act.dir or self.dir
- }
- for k, v in pairs(self.sprites) do
- v.play(v, act)
- end
- _, self.endWarModeAction = self.node:runs({
- cc.DelayTime:create(time - 4),
- cc.CallFunc:create(function ()
- self:addStandAct()
- self.endWarModeAction = nil
- return
- end)
- })
- else
- hero.super.allExecuteEnd(self)
- end
- end
- self.isExecuteEnd = true
- return
- end
- hero.getHitTime = function (self)
- if (not g_data.equip.items[7] or g_data.equip.items[7].getVar("name") ~= "狂风戒指") and (not g_data.equip.items[8] or g_data.equip.items[8].getVar("name") ~= "狂风戒指") then
- local hitSpeed = tonumber(avoidPlugValue(self.hitSpeed, true)) or 0
- local ret = math.max(0, def.role.speed.attack - math.min(300, hitSpeed*60)/1000)
- main_scene.ui:tip("检测到你身上没有携带狂风戒指,恢复原始速度!")
- return ret
- else
- local hitSpeed = tonumber(avoidPlugValue(self.hitSpeed, true)) or 0
- local ret = math.max(0, def.role.speed.attack - math.min(850, 850)/1)
- main_scene.ui:tip("检测到你身上携带狂风戒指,攻击疯狂加速中!")
-
- return ret
- end
- end
- hero.canNextHit = function (self)
- return self.getHitTime(self) < socket.gettime() - self.lastAttackTime
- end
- hero.getNextMagicDelay = function (self, magicId)
- local time = def.role.speed.spell + g_data.player:getMagicDelay(magicId)/1000
- return (self.lastSpellTime + time) - socket.gettime()
- end
- hero.canNextSpell = function (self, magicId)
- if self.isLocked(self) then
- return false
- end
- return self.getNextMagicDelay(self, magicId) <= 0
- end
- return hero
复制代码
|
上一篇:战神mir2.scenes.main.console.widget._def布局明文代码下一篇:战神自定义怪物颜色明文源码mir2.monster.namecfg
|