新增技能CD减少系统

This commit is contained in:
admin 2026-06-13 02:08:55 +08:00
parent 8756d822a5
commit 71a932d6db
3 changed files with 84 additions and 1 deletions

View file

@ -47,6 +47,9 @@ function ReloadAttOBJ.main(actor)
---* 技能威力
ReloadAttOBJ:MagicPower(actor)
---* 减少技能CD
MagicOBJ:pushSkillCD(actor)
local sever_time = Sys.getint(VarCfg.sys.int["开区时间戳"]) or 0
if os.time() < sever_time + 86400 then
Player.setint(actor, VarCfg.Player.int["攻击力排行榜"], getbaseinfo(actor, ConstCfg.gbase.custom_attr, 4))
@ -233,7 +236,7 @@ function ReloadAttOBJ:MagicPower(actor)
end
end
----* 登陆刷新
----* 登陆刷新----* 登陆刷新
GameEvent.add(EventCfg.onLogin, function(actor)
ReloadAttOBJ.main(actor)
end, ReloadAttOBJ, 2)

View file

@ -109,4 +109,78 @@ function magselffunc2014(actor)
end
end
---* ========== 技能CD事件系统 ==========
MagicOBJ.SkillCD_handlers = {}
---* 注册技能CD减少源
---* key: 唯一标识(如"套装_xxx")
---* callback: function(actor) -> {{skillId, cdMs}, ...} or nil
function MagicOBJ:regSkillCD(key, callback)
if not key or not callback then
LOGPrint("regSkillCD 注册失败: key或callback为空")
return
end
MagicOBJ.SkillCD_handlers[key] = callback
end
---* 注销技能CD减少源
function MagicOBJ:unregSkillCD(key)
MagicOBJ.SkillCD_handlers[key] = nil
end
---* 推送技能CD刷新事件(外部统一入口)
function MagicOBJ:pushSkillCD(actor)
local cdMap = {}
for key, callback in pairs(self.SkillCD_handlers or {}) do
local ok, ret = pcall(callback, actor)
if ok and ret then
for _, v in ipairs(ret) do
local skillId, cdMs = v[1], v[2]
if skillId and cdMs and cdMs > 0 then
if not cdMap[skillId] or cdMs < cdMap[skillId] then
cdMap[skillId] = cdMs
end
end
end
end
end
for skillId, cdMs in pairs(cdMap) do
SetSkillMaxCD(actor, skillId, cdMs)
end
end
---* 套装技能CD配置
MagicOBJ.SuitSkillCD = {
[2001] = {{66, 1000},{26, 1000},{56, 1000}}, -- 开天斩/烈火剑法/逐日剑法 CD=1秒
[2002] = {{66, 2000},{26, 2000},{56, 2000}}, -- 开天斩/烈火剑法/逐日剑法 CD=2秒
[2003] = {{66, 3000},{56, 3000},{26, 3000}}, -- 开天斩/烈火剑法/逐日剑法 CD=3秒
[2004] = {{66, 4000},{56, 4000},{26, 4000}}, -- 刺杀剑术/开天斩/烈火剑法 CD=4秒
}
---* 注册根据已激活套装减少技能CD
MagicOBJ:regSkillCD("套装技能CD", function(actor)
local suits = GetActiveEquipSuits(actor) or {}
local result = {}
for _, suitId in ipairs(suits) do
local cfg = MagicOBJ.SuitSkillCD[suitId]
if cfg then
for _, v in ipairs(cfg) do
table.insert(result, v)
end
end
end
if #result > 0 then
return result
end
return nil
end)
---* 登录时推送技能CD
GameEvent.add(EventCfg.onLogin, function(actor)
MagicOBJ:pushSkillCD(actor)
end, MagicOBJ)
return MagicOBJ

View file

@ -18,6 +18,7 @@ function takeoffbeforeex(actor, makeIndex, where)
GameEvent.push(EventCfg.onTakebeforOffEx, actor, makeIndex, where, Info)
return Info.bool
end
@ -25,13 +26,18 @@ end
function takeonex(actor, makeIndex, where, itemName)
local Info = {}
GameEvent.push(EventCfg.onTakeOnEx, actor, makeIndex, where, itemName)
MagicOBJ:pushSkillCD(actor)
end
---* 角色脱下任意装备后触发
function takeoffex(actor, makeIndex, where, itemName)
GameEvent.push(EventCfg.onTakeOffEx, actor, makeIndex, where, itemName)
MagicOBJ:pushSkillCD(actor)
end
return TakeOBJ