|
战神引擎明文源码LOST修改攻速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 hitSpeed = tonumber(avoidPlugValue(self.hitSpeed, true)) or 0
- local ret = math.max(0, def.role.speed.attack - math.min(850, 850)/1)
- return ret
- 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)
- local hitSpeed = tonumber(avoidPlugValue(self.hitSpeed, true)) or 0
- local ret = math.max(0, def.role.speed.attack - math.min(600, 600)/1000)
- return ret
- 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.map.map下一篇:手游战神引擎源码会员挂机等按钮明文代码lua.btnCallbacks
|