410 lines
13 KiB
Lua
410 lines
13 KiB
Lua
JueXueXiuLianOBJ = Up_BaseClass:new()
|
||
|
||
|
||
JueXueXiuLianOBJ._name = "JueXueXiuLianOBJ"
|
||
-- NPCID
|
||
|
||
JueXueXiuLianOBJ.id = { 12 }
|
||
for i, v in ipairs(JueXueXiuLianOBJ.id or {}) do
|
||
Npc.clicknpcCfg[v] = JueXueXiuLianOBJ
|
||
end
|
||
|
||
-- 配置文件
|
||
JueXueXiuLianOBJ.cfg = {
|
||
juexue = Func.require("cfg_绝学修炼"),
|
||
jiesuo = Func.require("cfg_绝学解锁"),
|
||
xilian = {
|
||
{ "灵石", 50, 0 },
|
||
{ "金币", 5000, 1 },
|
||
},
|
||
}
|
||
|
||
local function JueXueXiuLianOBJ_for()
|
||
local tbl = {}
|
||
for i, v in ipairs(JueXueXiuLianOBJ.cfg.juexue) do
|
||
if not tbl[v.calss] then
|
||
tbl[v.calss] = {}
|
||
end
|
||
table.insert(tbl[v.calss], string.format("%d#%d", i, v.cgl))
|
||
end
|
||
return tbl
|
||
end
|
||
|
||
JueXueXiuLianOBJ.qz = JueXueXiuLianOBJ_for()
|
||
---* 加入上线同步数据
|
||
-- Player.sycCfg[JueXueXiuLianOBJ._name] = JueXueXiuLianOBJ.cfg
|
||
|
||
|
||
JueXueXiuLianOBJ.CaChe = {}
|
||
|
||
|
||
function JueXueXiuLianOBJ:up(actor, p1, p2, p3, data)
|
||
if not Npc.CheckNPCRange(actor, 12) then
|
||
return
|
||
end
|
||
|
||
local id = data[1].id
|
||
if not data or not id then
|
||
return
|
||
end
|
||
local open = Player.getkeycount(actor, VarCfg.Player.str["绝学修炼"], id) or nil
|
||
|
||
if not open then
|
||
Func.sendmsg9(actor, "该位置您未没有解锁!")
|
||
return
|
||
end
|
||
|
||
if Func.takeitmes(actor, self.cfg.xilian, true, true) then
|
||
setflagstatus(actor, VarCfg.Falg_fangshua, 1)
|
||
local xilian_id = self:xilian(actor, id)
|
||
|
||
local _oldid = Player.getkeycount(actor, VarCfg.Player.str["绝学修炼"], id)
|
||
if self.cfg.juexue[_oldid] and self.cfg.juexue[_oldid].buff then
|
||
if hasbuff(actor, self.cfg.juexue[_oldid].buff) then
|
||
delbuff(actor, self.cfg.juexue[_oldid].buff)
|
||
end
|
||
end
|
||
|
||
|
||
Player.setkeycount(actor, VarCfg.Player.str["绝学修炼"], id, xilian_id)
|
||
|
||
if self.cfg.juexue[xilian_id].buff then
|
||
if not hasbuff(actor, self.cfg.juexue[xilian_id].buff) then
|
||
addbuff(actor, self.cfg.juexue[xilian_id].buff)
|
||
end
|
||
end
|
||
Func.sendmsg9(actor, string.format("[绝学修炼]:#70|恭喜您洗练成功,获得:#255|%s#215|!", self.cfg.juexue[xilian_id].name))
|
||
|
||
---* 刷新缓存
|
||
self:get_CaChe(actor)
|
||
end
|
||
end
|
||
|
||
function JueXueXiuLianOBJ:jiesuo(actor, p1, p2, p3, data)
|
||
if not Npc.CheckNPCRange(actor, 12) then
|
||
return
|
||
end
|
||
|
||
local id = data[1].id
|
||
if not data or not id then
|
||
return
|
||
end
|
||
|
||
local open = Player.getkeycount(actor, VarCfg.Player.str["绝学修炼"], id) or nil
|
||
|
||
if open then
|
||
Func.sendmsg9(actor, "您已经解锁了该绝学修炼位置!")
|
||
return
|
||
end
|
||
|
||
local cfg = self.cfg.jiesuo[id]
|
||
|
||
if not Func.checkcontion(actor, cfg.checkcontion, false, true) then
|
||
return
|
||
end
|
||
|
||
if Func.takeitmes(actor, cfg.xh, true, true) then
|
||
setflagstatus(actor, VarCfg.Falg_fangshua, 1)
|
||
local xilian_id = self:xilian(actor, id)
|
||
|
||
Player.setkeycount(actor, VarCfg.Player.str["绝学修炼"], id, xilian_id)
|
||
if self.cfg.juexue[xilian_id].buff then
|
||
if not hasbuff(actor, self.cfg.juexue[xilian_id].buff) then
|
||
addbuff(actor, self.cfg.juexue[xilian_id].buff)
|
||
end
|
||
end
|
||
|
||
---* 刷新缓存
|
||
self:get_CaChe(actor)
|
||
end
|
||
end
|
||
|
||
---* 洗练绝学
|
||
function JueXueXiuLianOBJ:xilian(actor, id)
|
||
--* 防刷标识
|
||
if getflagstatus(actor, VarCfg.Falg_fangshua) == 0 then
|
||
return
|
||
end
|
||
|
||
if not id then
|
||
return
|
||
end
|
||
local get_calss = self:get_juexue(actor, id)
|
||
local new_qzCfg = {}
|
||
|
||
for i, v in ipairs(self.qz or {}) do
|
||
if not get_calss[i] then
|
||
for _, qz in ipairs(v) do
|
||
table.insert(new_qzCfg, qz)
|
||
end
|
||
end
|
||
end
|
||
local result1, result2 = ransjstr(table.concat(new_qzCfg, "|"), 1, 3)
|
||
|
||
--* 防刷标识
|
||
setflagstatus(actor, VarCfg.Falg_fangshua, 0)
|
||
return tonumber(result1)
|
||
end
|
||
|
||
function JueXueXiuLianOBJ:get_juexue(actor, id)
|
||
if not id then
|
||
return
|
||
end
|
||
|
||
local juexueCfg = Player.getkeytbl(actor, VarCfg.Player.str["绝学修炼"]) or {}
|
||
local tbl = {}
|
||
for i, v in pairs(juexueCfg or {}) do
|
||
if id and id ~= i then
|
||
tbl[self.cfg.juexue[v].calss] = true
|
||
end
|
||
end
|
||
return tbl
|
||
end
|
||
|
||
function JueXueXiuLianOBJ:get_CaChe(actor)
|
||
local juexueCfg = Player.getkeytbl(actor, VarCfg.Player.str["绝学修炼"]) or {}
|
||
local self_id = getbaseinfo(actor, ConstCfg.gbase.id)
|
||
self.CaChe[self_id] = {}
|
||
|
||
for i, v in pairs(juexueCfg or {}) do
|
||
self.CaChe[self_id][v] = true
|
||
end
|
||
end
|
||
|
||
GameEvent.add(EventCfg.onLoginEnd, function(actor)
|
||
JueXueXiuLianOBJ:get_CaChe(actor)
|
||
end, JueXueXiuLianOBJ)
|
||
|
||
GameEvent.add(EventCfg.onqfloadend, function(actor)
|
||
JueXueXiuLianOBJ:get_CaChe(actor)
|
||
end, JueXueXiuLianOBJ)
|
||
|
||
|
||
|
||
|
||
JueXueXiuLianOBJ.AttackdamageCfg = {
|
||
--* 基本剑术伤害提升5%
|
||
[1] = function(actor, target, hitter, magicId, damage, model, Info)
|
||
if Player.CheckNPCRange(actor, target, 1) and magicId ~= 26 then
|
||
Info._damage = Info._damage + math.floor(Info._damage * 0.05)
|
||
end
|
||
end,
|
||
[2] = function(actor, target, hitter, magicId, damage, model, Info)
|
||
if Player.CheckNPCRange(actor, target, 1) and magicId ~= 26 then
|
||
if Func.random(5) and not hasbuff(actor, 10000) then
|
||
if addbuff(actor, 10000, 5) then
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,忽视目标100%防御,持续5s.#7", "百步穿杨"))
|
||
end
|
||
end
|
||
end
|
||
end,
|
||
|
||
---* 使用刺杀剑术 有5%的概率提升刺杀剑术伤害10% 持续5秒
|
||
[5] = function(actor, target, hitter, magicId, damage, model, Info)
|
||
if magicId == 12 and not Player.CheckNPCRange(actor, target, 1) then
|
||
if Func.random(5) and not hasbuff(actor, 10001) then
|
||
addbuff(actor, 10001, 10)
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,提升刺杀剑术伤害10%%,持续10s.#7", "撕裂长空"))
|
||
end
|
||
|
||
if hasbuff(actor, 10001) then
|
||
Info._damage = Info._damage + math.floor(Info._damage * 0.1)
|
||
end
|
||
end
|
||
end,
|
||
|
||
[9] = function(actor, target, hitter, magicId, damage, model, Info)
|
||
if magicId == 25 then
|
||
Info._damage = Info._damage + math.floor(Info._damage * 0.2)
|
||
end
|
||
end,
|
||
|
||
[16] = function(actor, target, hitter, magicId, damage, model, Info)
|
||
if magicId == 66 then
|
||
Info._damage = Info._damage + math.floor(Info._damage * 0.1)
|
||
end
|
||
end,
|
||
[19] = function(actor, target, hitter, magicId, damage, model, Info)
|
||
if magicId == 56 then
|
||
Info._damage = Info._damage + math.floor(Info._damage * 0.3)
|
||
end
|
||
end,
|
||
}
|
||
|
||
|
||
|
||
JueXueXiuLianOBJ.AttackHumandamageCfg = {
|
||
--* 使用基本剑术有5%概率忽视目标防御持续5秒
|
||
-- [2] = function(actor, target, hitter, magicId, damage, model, Info)
|
||
-- if Player.CheckNPCRange(actor, target, 1) and magicId ~= 26 then
|
||
-- if Func.random(50) and not hasbuff(actor, 10000) then
|
||
-- if addbuff(actor, 10000, 5) then
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,忽视目标100%防御,持续5s.#7", "百步穿杨"))
|
||
-- end
|
||
-- end
|
||
-- end
|
||
-- end,
|
||
}
|
||
|
||
|
||
JueXueXiuLianOBJ.onAttackCfg = {
|
||
--* 攻击有1%概率召唤一只道士骷髅附带绿毒效果(骷髅血量1000)仅仅可召唤1只
|
||
-- [3] = function(actor, target, hitter, magicId, Info)
|
||
-- if magicId == 3 then
|
||
-- if Func.random(1) then
|
||
-- local mmon = getslavebyindex(actor, 0)
|
||
-- if Player.getname(mmon) == "骷髅" then
|
||
-- return
|
||
-- end
|
||
-- recallmob(actor, "骷髅", 7, 65535, 0, 0, 0)
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,召唤一只道士骷髅助力.#7", "刀光剑影"))
|
||
-- end
|
||
-- end
|
||
-- end,
|
||
|
||
---* 使用刺杀剑术有1%概率 冰冻目标2秒
|
||
[4] = function(actor, target, hitter, magicId, Info)
|
||
if magicId == 12 then
|
||
if Func.random(1) then
|
||
makeposion(target, 12, 2, nil, 1)
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,冰冻目标2秒.#7", "游龙戏凤"))
|
||
end
|
||
end
|
||
end,
|
||
---* 使用烈火剑法有10%概率附带 红毒效果 持续10秒
|
||
[13] = function(actor, target, hitter, magicId, Info)
|
||
if magicId == 26 then
|
||
if Func.random(50) then
|
||
makeposion(target, 1, 10, 3, 1)
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,使目标中红毒,持续10秒.#7", "巫毒精灵"))
|
||
end
|
||
end
|
||
end,
|
||
---* 使用烈火剑法有10%概率附带 红毒效果 持续10秒
|
||
[14] = function(actor, target, hitter, magicId, Info)
|
||
if magicId == 26 then
|
||
if Func.random(25) and not hasbuff(target, 10004) then
|
||
if addbuff(target, 10004) then
|
||
playeffect(actor, 30347, 0, 0, 3, 0, 0)
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,使其燃烧当前生命值的1%% 持续4s.#7", "灼热之炎"))
|
||
end
|
||
end
|
||
end
|
||
end,
|
||
---* 开天斩击中单位蛛网2秒
|
||
[17] = function(actor, target, hitter, magicId, Info)
|
||
if magicId == 66 then
|
||
makeposion(target, 13, 2, 0, 1)
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,使目标中蛛网2s.#7", "改天换地"))
|
||
end
|
||
end,
|
||
---* 开天斩可将敌人击退1格且定身1秒
|
||
[18] = function(actor, target, hitter, magicId, Info)
|
||
if magicId == 66 then
|
||
releasemagic(actor, 2015, 1, 3, 1, 0)
|
||
changemode(target, 10, 1)
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,将敌人击退1格并定身1s.#7", "断海裂空"))
|
||
end
|
||
end,
|
||
}
|
||
|
||
|
||
|
||
JueXueXiuLianOBJ.onAttackMonCfg = {
|
||
[6] = function(actor, target, hitter, magicId, Info)
|
||
if magicId == 12 then
|
||
if Info.target_HP < 1000 then
|
||
humanhp(target, "-", 1000)
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,怪物生命不足1000,直接斩杀.#7", "斩妖除魔"))
|
||
end
|
||
end
|
||
end,
|
||
[8] = function(actor, target, hitter, magicId, Info)
|
||
local _cd = Player.getint(actor, VarCfg.Player.int["吸星大法"]) or 0
|
||
if Info.timer > _cd then
|
||
monmove(actor, 6, 4, 0, 0, 1, 1)
|
||
Player.setint(actor, VarCfg.Player.int["吸星大法"], Info.timer + 60)
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,强制将6x6范围内的怪物牵引到自己身边.#7", "吸星大法"))
|
||
end
|
||
end,
|
||
}
|
||
|
||
|
||
JueXueXiuLianOBJ.onAttackPlayCfg = {
|
||
[21] = function(actor, target, hitter, magicId, Info)
|
||
if magicId == 56 and not hasbuff(target, 10006) then
|
||
if addbuff(target, 10006, 5) then
|
||
-- Func.sendmsg(actor, string.format("[技能绝学]:#70|%s#215|触发,使目标无法使用任何药品,持续5s.#7", "剑灵束魂"))
|
||
-- Func.sendmsg(target, string.format("[技能绝学]:#70|对方#7|%s#215|触发,使你无法使用任何药品,持续5s.#7", "剑灵束魂"))
|
||
end
|
||
end
|
||
end,
|
||
}
|
||
|
||
|
||
--------------* 注册攻击事件
|
||
---* 攻击前触发 对人对怪
|
||
local function _onAttackdamage(actor, target, hitter, magicId, damage, model, Info)
|
||
local self_id = getbaseinfo(actor, ConstCfg.gbase.id)
|
||
for i, v in pairs(JueXueXiuLianOBJ.CaChe[self_id]) do
|
||
if JueXueXiuLianOBJ.AttackdamageCfg[i] then
|
||
local func = JueXueXiuLianOBJ.AttackdamageCfg[i]
|
||
func(actor, target, hitter, magicId, damage, model, Info)
|
||
end
|
||
end
|
||
end
|
||
GameEvent.add(EventCfg.onAttackdamage, _onAttackdamage, JueXueXiuLianOBJ)
|
||
|
||
---* 攻击前触发 对人
|
||
local function _onAttackHumandamage(actor, target, hitter, magicId, damage, model, Info)
|
||
local self_id = getbaseinfo(actor, ConstCfg.gbase.id)
|
||
for i, v in pairs(JueXueXiuLianOBJ.CaChe[self_id]) do
|
||
if JueXueXiuLianOBJ.AttackHumandamageCfg[i] then
|
||
local func = JueXueXiuLianOBJ.AttackHumandamageCfg[i]
|
||
func(actor, target, hitter, magicId, damage, model, Info)
|
||
end
|
||
end
|
||
end
|
||
GameEvent.add(EventCfg.onAttackHumandamage, _onAttackHumandamage, JueXueXiuLianOBJ)
|
||
|
||
|
||
---* 攻击后触发 对人对怪
|
||
local function _onAttack(actor, target, hitter, magicId, Info)
|
||
local self_id = getbaseinfo(actor, ConstCfg.gbase.id)
|
||
for i, v in pairs(JueXueXiuLianOBJ.CaChe[self_id]) do
|
||
if JueXueXiuLianOBJ.onAttackCfg[i] then
|
||
local func = JueXueXiuLianOBJ.onAttackCfg[i]
|
||
func(actor, target, hitter, magicId, Info)
|
||
end
|
||
end
|
||
end
|
||
GameEvent.add(EventCfg.onAttack, _onAttack, JueXueXiuLianOBJ)
|
||
|
||
---* 攻击后触发 对怪
|
||
local function _onAttackMon(actor, target, hitter, magicId, Info)
|
||
local self_id = getbaseinfo(actor, ConstCfg.gbase.id)
|
||
for i, v in pairs(JueXueXiuLianOBJ.CaChe[self_id]) do
|
||
if JueXueXiuLianOBJ.onAttackMonCfg[i] then
|
||
local func = JueXueXiuLianOBJ.onAttackMonCfg[i]
|
||
func(actor, target, hitter, magicId, Info)
|
||
end
|
||
end
|
||
end
|
||
GameEvent.add(EventCfg.onAttackMon, _onAttackMon, JueXueXiuLianOBJ)
|
||
|
||
|
||
---* 攻击后触发 对人
|
||
local function _onAttackPlay(actor, target, hitter, magicId, Info)
|
||
local self_id = getbaseinfo(actor, ConstCfg.gbase.id)
|
||
for i, v in pairs(JueXueXiuLianOBJ.CaChe[self_id]) do
|
||
if JueXueXiuLianOBJ.onAttackPlayCfg[i] then
|
||
local func = JueXueXiuLianOBJ.onAttackPlayCfg[i]
|
||
func(actor, target, hitter, magicId, Info)
|
||
end
|
||
end
|
||
end
|
||
GameEvent.add(EventCfg.onAttackPlay, _onAttackPlay, JueXueXiuLianOBJ)
|
||
|
||
|
||
|
||
return JueXueXiuLianOBJ
|