465 lines
14 KiB
Lua
465 lines
14 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.bookPos = 9
|
||
JueXueXiuLianOBJ.bookName = "武林秘籍"
|
||
JueXueXiuLianOBJ.bookVarKeys = {
|
||
VarCfg.item.int["绝学修炼_1"],
|
||
VarCfg.item.int["绝学修炼_2"],
|
||
VarCfg.item.int["绝学修炼_3"],
|
||
VarCfg.item.int["绝学修炼_4"],
|
||
}
|
||
|
||
|
||
function JueXueXiuLianOBJ:up(actor, p1, p2, p3, data)
|
||
if not Npc.CheckNPCRange(actor, 12) then
|
||
return
|
||
end
|
||
|
||
if not data or not data[1] then
|
||
return
|
||
end
|
||
local id = data[1].id
|
||
if not id then
|
||
return
|
||
end
|
||
|
||
local bookItem = self:getBookItem(actor)
|
||
if not bookItem then
|
||
return
|
||
end
|
||
local open = self:getBookJueXue(bookItem, id)
|
||
|
||
if open <= 0 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 = self:getBookJueXue(bookItem, 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
|
||
|
||
|
||
self:setBookJueXue(actor, bookItem, 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))
|
||
end
|
||
end
|
||
|
||
function JueXueXiuLianOBJ:jiesuo(actor, p1, p2, p3, data)
|
||
if not Npc.CheckNPCRange(actor, 12) then
|
||
return
|
||
end
|
||
|
||
if not data or not data[1] then
|
||
return
|
||
end
|
||
local id = data[1].id
|
||
if not id then
|
||
return
|
||
end
|
||
|
||
local bookItem = self:getBookItem(actor)
|
||
if not bookItem then
|
||
return
|
||
end
|
||
local open = self:getBookJueXue(bookItem, id)
|
||
|
||
if open > 0 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)
|
||
|
||
self:setBookJueXue(actor, bookItem, 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
|
||
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:getBookItem(actor, tips)
|
||
local bookItem = GetItemByPos(actor, self.bookPos)
|
||
if not bookItem or bookItem == "0" then
|
||
if tips ~= false then
|
||
Func.sendmsg9(actor, "请先佩戴武林秘籍!")
|
||
end
|
||
return nil
|
||
end
|
||
|
||
local itemName = getiteminfo(actor, bookItem, ConstCfg.iteminfo.name)
|
||
if itemName ~= self.bookName then
|
||
if tips ~= false then
|
||
Func.sendmsg9(actor, "请先佩戴武林秘籍!")
|
||
end
|
||
return nil
|
||
end
|
||
return bookItem
|
||
end
|
||
|
||
function JueXueXiuLianOBJ:getBookJueXue(bookItem, id)
|
||
local key = self.bookVarKeys[id]
|
||
if not key then
|
||
return 0
|
||
end
|
||
return Item.getint(bookItem, key) or 0
|
||
end
|
||
|
||
function JueXueXiuLianOBJ:getBookJueXueTbl(actor)
|
||
local bookItem = self:getBookItem(actor, false)
|
||
local tbl = {}
|
||
if not bookItem then
|
||
return tbl
|
||
end
|
||
|
||
for i, key in ipairs(self.bookVarKeys or {}) do
|
||
tbl[i] = Item.getint(bookItem, key) or 0
|
||
end
|
||
return tbl
|
||
end
|
||
|
||
function JueXueXiuLianOBJ:setBookJueXue(actor, bookItem, id, juexueId)
|
||
local key = self.bookVarKeys[id]
|
||
if not key then
|
||
return
|
||
end
|
||
Item.setint(actor, bookItem, key, juexueId or 0)
|
||
end
|
||
|
||
function JueXueXiuLianOBJ:get_juexue(actor, id)
|
||
if not id then
|
||
return
|
||
end
|
||
|
||
local juexueCfg = self:getBookJueXueTbl(actor)
|
||
local tbl = {}
|
||
for i, v in pairs(juexueCfg or {}) do
|
||
if id ~= i and v > 0 and self.cfg.juexue[v] then
|
||
tbl[self.cfg.juexue[v].calss] = true
|
||
end
|
||
end
|
||
return tbl
|
||
end
|
||
|
||
function JueXueXiuLianOBJ:hasJueXue(actor, juexueId)
|
||
if not juexueId then
|
||
return false
|
||
end
|
||
|
||
local juexueCfg = self:getBookJueXueTbl(actor)
|
||
for i, v in pairs(juexueCfg or {}) do
|
||
if v == juexueId then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
|
||
|
||
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(100) 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(100) 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) and Func.random(30) 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)
|
||
for i, v in pairs(JueXueXiuLianOBJ:getBookJueXueTbl(actor)) do
|
||
if v > 0 and JueXueXiuLianOBJ.AttackdamageCfg[v] then
|
||
local func = JueXueXiuLianOBJ.AttackdamageCfg[v]
|
||
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)
|
||
for i, v in pairs(JueXueXiuLianOBJ:getBookJueXueTbl(actor)) do
|
||
if v > 0 and JueXueXiuLianOBJ.AttackHumandamageCfg[v] then
|
||
local func = JueXueXiuLianOBJ.AttackHumandamageCfg[v]
|
||
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)
|
||
for i, v in pairs(JueXueXiuLianOBJ:getBookJueXueTbl(actor)) do
|
||
if v > 0 and JueXueXiuLianOBJ.onAttackCfg[v] then
|
||
local func = JueXueXiuLianOBJ.onAttackCfg[v]
|
||
func(actor, target, hitter, magicId, Info)
|
||
end
|
||
end
|
||
end
|
||
GameEvent.add(EventCfg.onAttack, _onAttack, JueXueXiuLianOBJ)
|
||
|
||
---* 攻击后触发 对怪
|
||
local function _onAttackMon(actor, target, hitter, magicId, Info)
|
||
for i, v in pairs(JueXueXiuLianOBJ:getBookJueXueTbl(actor)) do
|
||
if v > 0 and JueXueXiuLianOBJ.onAttackMonCfg[v] then
|
||
local func = JueXueXiuLianOBJ.onAttackMonCfg[v]
|
||
func(actor, target, hitter, magicId, Info)
|
||
end
|
||
end
|
||
end
|
||
GameEvent.add(EventCfg.onAttackMon, _onAttackMon, JueXueXiuLianOBJ)
|
||
|
||
|
||
---* 攻击后触发 对人
|
||
local function _onAttackPlay(actor, target, hitter, magicId, Info)
|
||
for i, v in pairs(JueXueXiuLianOBJ:getBookJueXueTbl(actor)) do
|
||
if v > 0 and JueXueXiuLianOBJ.onAttackPlayCfg[v] then
|
||
local func = JueXueXiuLianOBJ.onAttackPlayCfg[v]
|
||
func(actor, target, hitter, magicId, Info)
|
||
end
|
||
end
|
||
end
|
||
GameEvent.add(EventCfg.onAttackPlay, _onAttackPlay, JueXueXiuLianOBJ)
|
||
|
||
|
||
|
||
JueXueXiuLianOBJ.allowFunc = {"up", "jiesuo"}
|
||
|
||
return JueXueXiuLianOBJ
|