分为三个文件注册位置:
/home/tlbb1/Public/Data/Script/event/system
Script.dat注册:
;命中率回调
768991=\event\system\Callback_IsHit.lua
;会心率回调
768992=\event\system\Callback_IsCriticalHit.lua
;技能范围回调
768993=\event\system\Callback_SkillRadius.lua
;技能人数回调
768994=\event\system\Callback_ScanUnitForTarget.lua
;升级回调
768995=\event\system\Callback_LevelUpCheck.lua
;瞬移BUFF坐标回调
768996=\event\system\Callback_StdImpact009.lua
;百分比恢复BUFF回调
768997=\event\system\Callback_StdImpact005.lua
;间隔驻留BUFF回调
768998=\event\system\Callback_StdImpact010.lua
;陷阱FadeIn回调
768999=\event\system\Callback_OnSpecialFadeIn.lua
;交易确认回调
769000=\event\system\Callback_ExchangeConfirmation.lua
脚本下载替换大法(必须下载):
回调开启控制:
/home/tlbb1/Server/Config/BaseConfig.ini
参考教程:https://waylee.net/thread-3776-1-1.html
部分回调预览:
Callback_IsCriticalHit.lua
-- 暴击率回调控制
-- @WAYLEE@XUEWU v1.0
-- 脚本ID
x768992_g_ScriptId = 768992
--**********************************
-- 暴击率回调
-- 在暴击判定计算完成后调用,可以修改暴击率和随机数
--**********************************
-- 参数说明:
-- sceneId: 场景ID
-- selfId: 攻击者ObjID
-- targetId: 防御者ObjID
-- IsCriticalHit: 当前是否暴击 (1=暴击, 0=未暴击)
-- nCriticalRate: 当前暴击率 (万分比, 例如3000=30%)
-- nRand: 暴击随机数 (当 nRand < nCriticalRate 时暴击)
-- nSkillID: 技能ID
--
-- 返回值 (两个):
-- newCriticalRate: 新的暴击率 (万分比)
-- newRand: 新的随机数
--
-- 注意:
-- 暴击率为万分比,9999=99.99%
-- 判定逻辑: nCriticalRate > nRand 时暴击
-- 返回两个值可以同时控制暴击率和随机数
--**********************************
function x768992_callback_IsCriticalHit(sceneId, selfId, targetId, IsCriticalHit, nCriticalRate, nRand, nSkillID)
-- 醒目提示: 回调已生效
-- x768992_NotifyTip(sceneId, selfId,
-- "[暴击率回调] 技能ID=" .. tostring(nSkillID) ..
-- " 目标ID=" .. tostring(targetId) ..
-- " 是否暴击=" .. tostring(IsCriticalHit) ..
-- " 暴击率=" .. tostring(nCriticalRate) ..
-- " 随机值=" .. tostring(nRand))
-- 默认不修改,返回原始暴击率和随机数
return nCriticalRate, nRand
end
--**********************************
-- 用法案例 (取消注释即可使用)
--**********************************
-- 用法1: 特定技能必暴击 (设置暴击率为9999,随机数为0)
-- function x768992_callback_IsCriticalHit(sceneId, selfId, targetId, IsCriticalHit, nCriticalRate, nRand, nSkillID)
-- if nSkillID == 12345 then
-- return 9999, 0 -- 9999>0 必暴击
-- end
-- return nCriticalRate, nRand
-- end
-- 用法2: 根据玩家MissionData调整暴击率
-- function x768992_callback_IsCriticalHit(sceneId, selfId, targetId, IsCriticalHit, nCriticalRate, nRand, nSkillID)
-- local critBonus = GetMissionData(sceneId, selfId, 251)
-- if critBonus > 0 then
-- return nCriticalRate + critBonus, nRand
-- end
-- return nCriticalRate, nRand
-- end
-- 用法3: 所有暴击率提升5%
-- function x768992_callback_IsCriticalHit(sceneId, selfId, targetId, IsCriticalHit, nCriticalRate, nRand, nSkillID)
-- return nCriticalRate + 500, nRand -- +500万分比 = +5%
-- end
--**********************************
--醒目提醒
--**********************************
function x768992_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
Callback_IsHit.lua
-- 命中率回调控制
-- @WAYLEE@XUEWU v1.0
-- 脚本ID
x768991_g_ScriptId = 768991
--**********************************
-- 命中率回调
-- 在命中判定计算完成后调用,可以修改命中率和随机数
--**********************************
-- 参数说明:
-- sceneId: 场景ID
-- selfId: 攻击者ObjID
-- targetId: 防御者ObjID
-- bHit: 当前是否命中 (1=命中, 0=闪避)
-- nHitRate: 当前命中率 (千分比, 例如800=80%)
-- nRand: 命中随机数 (当 nRand < nHitRate 时为命中状态)
-- nSkillID: 技能ID
--
-- 返回值 (两个):
-- newHitRate: 新的命中率 (千分比)
-- newRand: 新的随机数
--
-- 注意:
-- 命中率为千分比,1000=100%必中
-- 判定逻辑: nHitRate > nRand 时命中
-- 返回两个值可以同时控制命中率和随机数
--**********************************
function x768991_callback_IsHit(sceneId, selfId, targetId, bHit, nHitRate, nRand, nSkillID)
-- 醒目提示: 回调已生效
-- x768991_NotifyTip(sceneId, selfId,
-- "[命中率回调] 技能ID=" .. tostring(nSkillID) ..
-- " 目标ID=" .. tostring(targetId) ..
-- " 是否命中=" .. tostring(bHit) ..
-- " 命中率=" .. tostring(nHitRate) ..
-- " 随机值=" .. tostring(nRand))
-- 默认不修改,返回原始命中率和随机数
return nHitRate, nRand
end
--**********************************
-- 用法案例 (取消注释即可使用)
--**********************************
-- 用法1: 特定技能必中 (设置命中率为1000,随机数为0)
-- function x768991_callback_IsHit(sceneId, selfId, targetId, bHit, nHitRate, nRand, nSkillID)
-- if nSkillID == 12345 then
-- return 1000, 0 -- 1000>0 必中
-- end
-- return nHitRate, nRand
-- end
-- 用法2: 根据玩家MissionData调整命中率
-- function x768991_callback_IsHit(sceneId, selfId, targetId, bHit, nHitRate, nRand, nSkillID)
-- local hitBonus = GetMissionData(sceneId, selfId, 250)
-- if hitBonus > 0 then
-- return nHitRate + hitBonus, nRand
-- end
-- return nHitRate, nRand
-- end
-- 用法3: 所有命中率提升10%
-- function x768991_callback_IsHit(sceneId, selfId, targetId, bHit, nHitRate, nRand, nSkillID)
-- return nHitRate + 100, nRand -- +100千分比 = +10%
-- end
--**********************************
--醒目提醒
--**********************************
function x768991_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
Callback_ScanUnitForTarget.lua
-- 群体技能扫描目标数量回调控制
-- @WAYLEE@XUEWU v1.0
-- 脚本ID
x768994_g_ScriptId = 768994
--**********************************
-- 群体技能人数影响
-- 在群体技能扫描完目标后、截断目标数量前调用,可以修改最大目标数
-- 同时可以通过 getTargetID 遍历目标列表获取每个目标的ObjID
--**********************************
-- 参数说明:
-- sceneId: 场景ID
-- selfId: 施法者ObjID
-- skillId: 技能ID
-- defaultTargetCount: 扫描到的实际目标数量
-- maxTargetCount: 最大攻击目标数量 (来自技能表配置)
-- targetData: 目标数据 (传给getTargetID使用)
-- getTargetID: 获取目标ObjID的函数 (function)
--
-- getTargetID 用法:
-- local targetID = getTargetID(sceneId, selfId, targetData, index)
-- index 从0开始,范围 0 ~ maxTargetCount-1
-- 返回目标的ObjID,无效时返回nil
--
-- 返回值:
-- newMaxTargetCount: 新的最大目标数 (安全范围:0~254)
-- 返回正整数则替换maxTargetCount
-- 返回0或负数表示C++层不替换(保持原值)
--**********************************
function x768994_callback_ScanUnitForTarget(sceneId, selfId, skillId, defaultTargetCount, maxTargetCount, targetData, getTargetID)
-- 醒目提示: 回调已生效
-- x768994_NotifyTip(sceneId, selfId,
-- "[扫描目标回调] 技能ID=" .. tostring(skillId) ..
-- " 扫描到=" .. tostring(defaultTargetCount) ..
-- " 最大目标=" .. tostring(maxTargetCount))
-- 遍历目标列表示例 (取消注释可查看)
-- local nMax = 0
-- for i = 0, maxTargetCount - 1 do
-- local targetID = getTargetID(sceneId, selfId, targetData, i)
-- if targetID ~= nil and targetID > 0 and targetID <= 29999 then
-- x768994_NotifyTip(sceneId, selfId,
-- "名字:" .. GetName(sceneId, targetID) ..
-- " 目标血量:" .. GetHp(sceneId, targetID) ..
-- " ObjID:" .. targetID)
-- nMax = nMax + 1
-- end
-- end
-- x768994_NotifyTip(sceneId, selfId, "获取到有效obj的数量 " .. tostring(nMax))
-- 默认不修改,返回原始最大目标数
return maxTargetCount
end
--**********************************
-- 用法案例 (取消注释即可使用)
--**********************************
-- 用法1: 特定技能目标数翻倍
-- function x768994_callback_ScanUnitForTarget(sceneId, selfId, skillId, defaultTargetCount, maxTargetCount, targetData, getTargetID)
-- if skillId == 12345 then
-- return maxTargetCount * 2
-- end
-- return maxTargetCount
-- end
-- 用法2: 根据玩家MissionData调整最大目标数
-- function x768994_callback_ScanUnitForTarget(sceneId, selfId, skillId, defaultTargetCount, maxTargetCount, targetData, getTargetID)
-- local targetBonus = GetMissionData(sceneId, selfId, 253)
-- if targetBonus > 0 then
-- return maxTargetCount + targetBonus
-- end
-- return maxTargetCount
-- end
-- 用法3: 命中所有扫描到的目标 (不截断)
-- function x768994_callback_ScanUnitForTarget(sceneId, selfId, skillId, defaultTargetCount, maxTargetCount, targetData, getTargetID)
-- return defaultTargetCount
-- end
-- 用法4: 只攻击血量低于50%的目标 (需要配合其他逻辑)
-- function x768994_callback_ScanUnitForTarget(sceneId, selfId, skillId, defaultTargetCount, maxTargetCount, targetData, getTargetID)
-- local count = 0
-- for i = 0, maxTargetCount - 1 do
-- local targetID = getTargetID(sceneId, selfId, targetData, i)
-- if targetID ~= nil and targetID > 0 and targetID <= 29999 then
-- local hp = GetHp(sceneId, targetID)
-- local maxHp = GetMaxHp(sceneId, targetID)
-- if maxHp > 0 and hp * 100 / maxHp < 50 then
-- count = count + 1
-- end
-- end
-- end
-- if count > 0 then
-- return count
-- end
-- return maxTargetCount
-- end
--**********************************
--醒目提醒
--**********************************
function x768994_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
Callback_SkillRadius.lua
-- 技能范围回调控制
-- @WAYLEE@XUEWU v1.0
-- 脚本ID
x768993_g_ScriptId = 768993
--**********************************
-- 技能范围回调
-- 在群体技能获取半径并经过门派修正后调用,可以修改技能范围半径
--**********************************
-- 参数说明:
-- sceneId: 场景ID
-- selfId: 施法者ObjID
-- skillId: 技能ID
-- currentRadius: 当前半径值 (实际半径*100, 例如500=5.00米)
-- 返回值:
-- newRadius: 新的半径值 (实际半径*100)
-- 返回原始currentRadius表示不修改
-- 返回0或负数表示C++层不替换(保持原值)
-- 返回正整数则替换半径值
--
-- 注意:
-- 半径值为实际半径*100的整数,例如500表示5.00米
-- C++层判定: 如果返回值 > 0,则用返回值/100.0还原为float替换半径
--**********************************
function x768993_callback_SkillRadius(sceneId, selfId, skillId, currentRadius)
-- 醒目提示: 回调已生效
x768993_NotifyTip(sceneId, selfId,
"[技能范围回调] 技能ID=" .. tostring(skillId) ..
" 当前半径=" .. tostring(currentRadius / 100) .. "米")
-- 默认不修改,返回原始半径
return currentRadius
end
--**********************************
-- 用法案例 (取消注释即可使用)
--**********************************
-- 用法1: 特定技能范围扩大50%
-- function x768993_callback_SkillRadius(sceneId, selfId, skillId, currentRadius)
-- if skillId == 12345 then
-- return currentRadius * 150 / 100 -- 扩大50%
-- end
-- return currentRadius
-- end
-- 用法2: 根据玩家MissionData调整技能范围
-- function x768993_callback_SkillRadius(sceneId, selfId, skillId, currentRadius)
-- local rangeBonus = GetMissionData(sceneId, selfId, 252) -- 假设MD252存储范围加成(百分比)
-- if rangeBonus > 0 then
-- return currentRadius * (100 + rangeBonus) / 100
-- end
-- return currentRadius
-- end
-- 用法3: 所有群体技能范围+2米
-- function x768993_callback_SkillRadius(sceneId, selfId, skillId, currentRadius)
-- return currentRadius + 200 -- +200 = +2.00米
-- end
--**********************************
--醒目提醒
--**********************************
function x768993_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
Callback_ExchangeConfirmation.lua
-- 交易确认回调控制
-- 当双方确认交易时触发
-- @WAYLEE@XUEWU v1.0
-- 脚本ID
x769000_g_ScriptId = 769000
--**********************************
-- 交易确认回调
-- sceneId: 场景ID
-- selfId: 发起确认的玩家ID
-- targetId: 交易对方的玩家ID
-- GetData: 获取交易盒数据函数
--
-- GetData 用法:
-- 获取物品信息: local item_id, count = GetData(sceneId, playerId, "ITEM", index)
-- item_id: 物品表索引 (0=空格)
-- count: 叠加数量
-- 获取珍兽信息: local guid_high, guid_low = GetData(sceneId, playerId, "PET", index)
-- guid_high: 珍兽GUID高位 (0=空格)
-- guid_low: 珍兽GUID低位
-- index 范围: 0~4 (物品), 0~4 (珍兽)
--
-- 返回值: 0=允许交易, 非0=阻止交易
--**********************************
function x769000_ExchangeConfirmation(sceneId, selfId, targetId, GetData)
local Allow = 0 -- 默认允许交易
-- --遍历自己的交易物品
-- for i = 0, 4 do
-- local item_id, count = GetData(sceneId, selfId, "ITEM", i)
-- if item_id > 0 then
-- AddGlobalCountNews(sceneId, tostring(i) .. " 物品ID:" .. tostring(item_id) .. " 数量:" .. tostring(count))
-- end
-- end
-- --遍历自己的交易珍兽
-- for i = 0, 4 do
-- local pet_id_H, pet_id_L = GetData(sceneId, selfId, "PET", i)
-- if pet_id_H > 0 then
-- AddGlobalCountNews(sceneId, tostring(i) .. " 珍兽高位:" .. tostring(pet_id_H) .. " 低位:" .. tostring(pet_id_L))
-- end
-- end
-- --遍历对方的交易物品
-- for i = 0, 4 do
-- local item_id, count = GetData(sceneId, targetId, "ITEM", i)
-- if item_id > 0 then
-- AddGlobalCountNews(sceneId, "[对方]" .. tostring(i) .. " 物品ID:" .. tostring(item_id) .. " 数量:" .. tostring(count))
-- end
-- end
-- if Allow ~= 0 then
-- x769000_NotifyTip(sceneId, selfId, "存在违禁品,请检查交易物品后再次尝试。")
-- end
return Allow
end
--============================================================
-- 用法案例(取消注释即可使用)
--============================================================
-- 案例1: 禁止交易指定物品(违禁品检查)
-- function x769000_ExchangeConfirmation(sceneId, selfId, targetId,GetData)
-- local BannedItems = { [12345] = true, [67890] = true } -- 违禁物品ID列表
-- -- 检查双方交易物品
-- for _, playerId in ipairs({selfId, targetId}) do
-- for i = 0, 4 do
-- local item_id, count = GetData(sceneId, playerId, "ITEM", i)
-- if item_id > 0 and BannedItems[item_id] then
-- x769000_NotifyTip(sceneId, selfId, "交易中包含违禁物品,交易已取消。")
-- x769000_NotifyTip(sceneId, targetId, "交易中包含违禁物品,交易已取消。")
-- return 1 -- 阻止交易
-- end
-- end
-- end
-- return 0 -- 允许交易
-- end
-- 案例2: 记录交易日志
-- function x769000_ExchangeConfirmation(sceneId, selfId, targetId, GetData)
-- local log = "[交易] " .. GetName(sceneId, selfId) .. " <-> " .. GetName(sceneId, targetId) .. " 物品:"
-- for i = 0, 4 do
-- local item_id, count = GetData(sceneId, selfId, "ITEM", i)
-- if item_id > 0 then
-- log = log .. " [" .. item_id .. "x" .. count .. "]"
-- end
-- end
-- AddGlobalCountNews(sceneId, log)
-- return 0
-- end
-- 通用提示函数
function x769000_NotifyTip(sceneId, selfId, Msg)
BeginEvent(sceneId)
AddText(sceneId, Msg)
EndEvent(sceneId)
DispatchMissionTips(sceneId, selfId)
end
Callback_LevelUpCheck.lua
-- 升级等级限制回调
-- @WAYLEE@XUEWU v1.0
-- 脚本ID
x768995_g_ScriptId = 768995
--**********************************
-- 升级等级限制回调
-- 在玩家点击升级按钮后、实际升级逻辑执行前调用
-- 可以用来做等级限制、条件检查等
--**********************************
-- 参数说明:
-- sceneId: 场景ID
-- selfId: 玩家ObjID
-- reserved: 保留参数 (当前为0)
--
-- 返回值:
-- 1: 允许升级 (放行,继续执行原升级逻辑)
-- 0: 拒绝升级 (拦截,不执行升级)
--
-- 注意:
-- 原始升级逻辑(经验检查、等级上限等)之前执行
--**********************************
function x768995_callback_LevelUpCheck(sceneId, selfId, reserved)
-- x768995_NotifyTip(sceneId, selfId,
-- "[升级回调] 玩家ObjID=" .. tostring(selfId))
-- 默认放行,允许升级
return 1
end
--**********************************
-- 用法案例 (取消注释即可使用)
--**********************************
-- 用法1: 限制最高等级为89级
-- function x768995_callback_LevelUpCheck(sceneId, selfId, reserved)
-- local level = GetLevel(sceneId, selfId)
-- if level >= 89 then
-- x768995_NotifyTip(sceneId, selfId, "当前服务器最高等级为89级,请关注等级开放公告。")
-- return 0 -- 拒绝升级
-- end
-- return 1 -- 允许升级
-- end
-- 用法2: 根据MissionData控制升级权限
-- function x768995_callback_LevelUpCheck(sceneId, selfId, reserved)
-- local canLevelUp = GetMissionData(sceneId, selfId, 300)
-- if canLevelUp == 0 then
-- x768995_NotifyTip(sceneId, selfId, "您当前无法升级,请完成前置任务。")
-- return 0
-- end
-- return 1
-- end
-- 用法3: 特定等级段需要特殊条件
-- function x768995_callback_LevelUpCheck(sceneId, selfId, reserved)
-- local level = GetLevel(sceneId, selfId)
-- if level == 69 then
-- local questDone = GetMissionData(sceneId, selfId, 301)
-- if questDone ~= 1 then
-- x768995_NotifyTip(sceneId, selfId, "突破70级需要完成飞升任务。")
-- return 0
-- end
-- end
-- return 1
-- end
--**********************************
--醒目提醒
--**********************************
function x768995_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
Callback_OnSpecialFadeIn.lua
-- 陷阱FadeIn回调控制
-- 当陷阱对角色生效时触发
-- @WAYLEE@XUEWU v1.0
-- 脚本ID (与32位共用768990)
x768999_g_ScriptId = 768999
--**********************************
-- 陷阱回调 (Fade In)
-- sceneId: 场景ID
-- selfId: 施暴者(陷阱拥有者ID)
-- targetId: 受害者(被陷阱命中的角色ID)
-- nDataID: 陷阱数据ID
-- nPowerPer: 额外伤害(百分比增伤修正率)
-- SpecialData: 陷阱数据对象(userdata指针)
-- getData: 获取陷阱数据函数 getData(sceneId, selfId, SpecialData, nIndex)
-- setData: 设置陷阱数据函数 setData(sceneId, selfId, SpecialData, nIndex, nValue)
--
-- getData/setData 的 nIndex 含义:
-- 0: 持续时间 (m_nContinuance)
-- 1: 陷阱间隔时间 (m_nInterval)
-- 2: 已经过的间隔时间 (m_nElapsedInterval)
-- 3: 陷阱延迟时间 (m_nDelayTime)
-- 4: 固定伤害修正值 (m_nPowerRefixByValue)
-- 5: 隐身级别 (m_nStealthLevel)
-- 6: 陷阱类别 (m_nClass)
-- 7: 陷阱消失标志 (m_bFadeOut, 0=未消失 1=已消失)
-- 8: 可以激发的次数 (m_nActiveTimes)
-- 9~16: 陷阱回调额外参数 m_aParams[0]~m_aParams[7]
--
-- 返回值: 新的 nPowerPer(百分比增伤修正率)
--**********************************
function x768999_OnSpecialFadeIn(sceneId, selfId, targetId, nDataID, nPowerPer, SpecialData, getData, setData)
-- 默认返回原始增伤率(不修改)
return nPowerPer
end
--============================================================
-- 用法案例(取消注释即可使用)
--============================================================
-- 案例1: 打印陷阱详细信息(调试用)
-- function x768999_OnSpecialFadeIn(sceneId, selfId, targetId, nDataID, nPowerPer, SpecialData, getData, setData)
-- AddGlobalCountNews(sceneId,
-- "#r 陷阱索引:"..nDataID..
-- "#r 0 持续时间:"..getData(sceneId, selfId, SpecialData, 0)..
-- "#r 1 间隔时间:"..getData(sceneId, selfId, SpecialData, 1)..
-- "#r 2 已过时间:"..getData(sceneId, selfId, SpecialData, 2)..
-- "#r 8 激发次数:"..getData(sceneId, selfId, SpecialData, 8)
-- )
-- return nPowerPer
-- end
-- 案例2: 修改陷阱增伤倍率(设为100000%超高伤害)
-- function x768999_OnSpecialFadeIn(sceneId, selfId, targetId, nDataID, nPowerPer, SpecialData, getData, setData)
-- nPowerPer = 100000
-- return nPowerPer
-- end
-- 案例3: 根据任务数据动态设置陷阱激发次数
-- function x768999_OnSpecialFadeIn(sceneId, selfId, targetId, nDataID, nPowerPer, SpecialData, getData, setData)
-- if GetMissionData(sceneId, selfId, 500) == 1 then
-- setData(sceneId, selfId, SpecialData, 8, 10) -- 设置可激发次数为10
-- SetMissionData(sceneId, selfId, 500, 0) -- 重置任务标记
-- end
-- return nPowerPer
-- end
-- 案例4: 给施暴者和受害者发送提示信息
-- function x768999_OnSpecialFadeIn(sceneId, selfId, targetId, nDataID, nPowerPer, SpecialData, getData, setData)
-- x768999_NotifyTip(sceneId, selfId,
-- "施暴者:"..GetName(sceneId, selfId)..
-- " 受害者:"..GetName(sceneId, targetId)..
-- " 使用 "..nDataID.." 号陷阱 增伤 "..nPowerPer.."%")
-- return nPowerPer
-- end
-- 案例5: 根据陷阱ID对特定陷阱加倍伤害
-- function x768999_OnSpecialFadeIn(sceneId, selfId, targetId, nDataID, nPowerPer, SpecialData, getData, setData)
-- if nDataID == 123 then -- 指定陷阱ID
-- nPowerPer = nPowerPer * 2 -- 伤害翻倍
-- end
-- return nPowerPer
-- end
-- 案例6: 读取并修改陷阱持续时间
-- function x768999_OnSpecialFadeIn(sceneId, selfId, targetId, nDataID, nPowerPer, SpecialData, getData, setData)
-- local duration = getData(sceneId, selfId, SpecialData, 0) -- 读取持续时间
-- if duration < 5000 then
-- setData(sceneId, selfId, SpecialData, 0, 10000) -- 延长持续时间到10秒
-- end
-- return nPowerPer
-- end
-- 通用提示函数
function x768999_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
Callback_StdImpact005
-- 百分比恢复BUFF回调 (HP恢复量修改)
-- @WAYLEE@XUEWU v1.0
-- 脚本ID
x768997_g_ScriptId = 768997
--**********************************
-- 百分比恢复BUFF回调
-- 在百分比恢复BUFF(StdImpact005)激活时、HealthIncrement执行前调用
-- 可以用来修改HP恢复量、拦截恢复等
--**********************************
-- 参数说明:
-- sceneId: 场景ID
-- casterObjId: 施法者ObjID (谁施放的BUFF)
-- skillId: 技能ID
-- dataIndex: BUFF索引ID
-- nHP: HP变化量 (已经过百分比和等级计算)
-- targetId: 目标ObjID (被恢复的对象)
--
-- 返回值 (单返回值):
-- nHP: 修改后的HP变化量
--
-- 注意:
-- 此回调仅修改HP恢复量,MP/Rage/StrikePoint不受影响
-- 仅当施法者为玩家(ObjID 15000-29999)时触发回调
--**********************************
function x768997_callback_StdImpact005(sceneId, casterObjId, skillId, dataIndex, nHP, targetId)
-- 默认不修改,原样返回
return nHP
end
--**********************************
-- 用法案例 (取消注释即可使用)
--**********************************
-- 用法1: 记录所有恢复操作
-- function x768997_callback_StdImpact005(sceneId, casterObjId, skillId, dataIndex, nHP, targetId)
-- x768997_NotifyTip(sceneId, targetId,
-- "[恢复回调] 施法者:" .. tostring(casterObjId) .. " 技能:" .. tostring(skillId) ..
-- " BUFF:" .. tostring(dataIndex) .. " HP:" .. tostring(nHP))
-- return nHP
-- end
-- 用法2: 双倍恢复
-- function x768997_callback_StdImpact005(sceneId, casterObjId, skillId, dataIndex, nHP, targetId)
-- return nHP * 2
-- end
-- 用法3: 根据BUFF索引禁止特定恢复
-- function x768997_callback_StdImpact005(sceneId, casterObjId, skillId, dataIndex, nHP, targetId)
-- if dataIndex == 123 then
-- x768997_NotifyTip(sceneId, targetId, "该恢复BUFF已被禁用。")
-- return 0 -- 恢复量设为0
-- end
-- return nHP
-- end
-- 用法4: 自己给自己加BUFF时恢复量减半
-- function x768997_callback_StdImpact005(sceneId, casterObjId, skillId, dataIndex, nHP, targetId)
-- if casterObjId == targetId then
-- return nHP / 2
-- end
-- return nHP
-- end
--**********************************
--醒目提醒
--**********************************
function x768997_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
Callback_StdImpact009.lua
-- 瞬移类BUFF回调 (传送角色到指定位置)
-- @WAYLEE@XUEWU v1.0
-- 脚本ID
x768996_g_ScriptId = 768996
--**********************************
-- 瞬移类BUFF回调
-- 在瞬移类BUFF(StdImpact009)激活时、实际传送执行前调用
-- 可以用来修改传送目标坐标、拦截传送等
--**********************************
-- 参数说明:
-- sceneId: 场景ID
-- selfId: 施法者ObjID
-- fX: 传送目标X坐标 (原始浮点值的整数部分)
-- fZ: 传送目标Z坐标 (原始浮点值的整数部分)
-- DataIndex: BUFF索引ID
--
-- 返回值 (双返回值):
-- fX: 修改后的X坐标 (>0时替换原坐标)
-- fZ: 修改后的Z坐标 (>0时替换原坐标)
--
-- 注意:
-- 此回调仅在同场景传送时触发
-- 跨场景传送不经过此回调
--**********************************
function x768996_callback_StdImpact009(sceneId, selfId, fX, fZ, DataIndex)
-- x768996_NotifyTip(sceneId, selfId,
-- "[瞬移回调] fX:" .. tostring(fX) .. " fZ:" .. tostring(fZ) .. " DataIndex:" .. tostring(DataIndex))
-- 默认不修改坐标,原样返回
return fX, fZ
end
--**********************************
-- 用法案例 (取消注释即可使用)
--**********************************
-- 用法1: 记录所有瞬移操作
-- function x768996_callback_StdImpact009(sceneId, selfId, fX, fZ, DataIndex)
-- x768996_NotifyTip(sceneId, selfId,
-- "[瞬移] 目标坐标: (" .. tostring(fX) .. ", " .. tostring(fZ) .. ") BUFF索引: " .. tostring(DataIndex))
-- return fX, fZ
-- end
-- 用法2: 修改传送坐标到固定位置
-- function x768996_callback_StdImpact009(sceneId, selfId, fX, fZ, DataIndex)
-- fX = 100
-- fZ = 200
-- return fX, fZ
-- end
-- 用法3: 根据BUFF索引拦截特定瞬移 (返回-1使坐标不被替换)
-- function x768996_callback_StdImpact009(sceneId, selfId, fX, fZ, DataIndex)
-- if DataIndex == 123 then
-- x768996_NotifyTip(sceneId, selfId, "该瞬移技能已被禁用。")
-- return -1, -1 -- 坐标<=0不会替换,但原函数仍会执行传送到原坐标
-- end
-- return fX, fZ
-- end
--**********************************
--醒目提醒
--**********************************
function x768996_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
Callback_StdImpact010.lua
-- 间隔驻留BUFF回调 (周期性子BUFF发放控制)
-- @WAYLEE@XUEWU v1.0
-- 脚本ID
x768998_g_ScriptId = 768998
--**********************************
-- 间隔驻留BUFF回调
-- 在间隔驻留BUFF(StdImpact010)每次间隔触发时、子BUFF发放前调用
-- 可以用来拦截子BUFF发放、记录BUFF触发等
--**********************************
-- 参数说明:
-- sceneId: 场景ID
-- selfId: 目标ObjID (被施加BUFF的对象)
-- casterObjId: 施法者ObjID
-- dataIndex: BUFF索引ID
-- continuance: BUFF总持续时间 (毫秒)
-- continuanceElapsed: BUFF已过时间 (毫秒)
--
-- 返回值 (单返回值):
-- 1 = 继续执行子BUFF发放 (默认)
-- 0 = 跳过本次子BUFF发放
--
-- 注意:
-- 此回调在每个间隔周期触发一次
-- 仅当目标为玩家(ObjID 15000-29999)时触发回调
-- 子BUFF的具体效果由BUFF表格配置决定
--**********************************
function x768998_callback_StdImpact010(sceneId, selfId, casterObjId, dataIndex, continuance, continuanceElapsed)
-- 默认允许子BUFF发放
return 1
end
--**********************************
-- 用法案例 (取消注释即可使用)
--**********************************
-- 用法1: 记录每次间隔触发
-- function x768998_callback_StdImpact010(sceneId, selfId, casterObjId, dataIndex, continuance, continuanceElapsed)
-- x768998_NotifyTip(sceneId, selfId,
-- "[间隔BUFF] 施法者:" .. tostring(casterObjId) .. " BUFF:" .. tostring(dataIndex) ..
-- " 已过:" .. tostring(continuanceElapsed) .. "/" .. tostring(continuance))
-- return 1
-- end
-- 用法2: 禁止特定BUFF的子效果发放
-- function x768998_callback_StdImpact010(sceneId, selfId, casterObjId, dataIndex, continuance, continuanceElapsed)
-- if dataIndex == 456 then
-- x768998_NotifyTip(sceneId, selfId, "该间隔BUFF效果已被禁用。")
-- return 0 -- 跳过本次子BUFF发放
-- end
-- return 1
-- end
-- 用法3: BUFF持续一半时间后停止发放子效果
-- function x768998_callback_StdImpact010(sceneId, selfId, casterObjId, dataIndex, continuance, continuanceElapsed)
-- if continuanceElapsed > continuance / 2 then
-- return 0 -- 后半段不再发放
-- end
-- return 1
-- end
--**********************************
--醒目提醒
--**********************************
function x768998_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
Callback_MonsterDrop.lua
-- 爆率回调控制 @WAYLEE
-- 脚本ID
x768990_g_ScriptId = 768990
--**********************************
--事件交互入口
--**********************************
function x768990_OnDefaultEvent( sceneId, selfId,targetId )
end
--**********************************
-- 怪物掉落回调 (Monster Drop Callback)
-- 在怪物死亡计算掉落前调用,可以控制爆率和是否允许掉落
--**********************************
-- 参数说明:
-- sceneId: 场景ID
-- selfId: 玩家ObjID (获得掉落的玩家)
-- monsterObjId: 怪物ObjID
-- monsterDataId:怪物模板ID (DataID)
-- playerLevel: 玩家等级
-- dropData: 掉落数据对象 (用于getData/setData)
-- getData: 获取掉落数据函数
-- setData: 设置掉落数据函数
--
-- getData/setData 索引说明:
-- 0 = sceneId (只读) 场景ID
-- 1 = playerObjId (只读) 玩家ObjID
-- 2 = monsterObjId (只读) 怪物ObjID
-- 3 = monsterDataId (只读) 怪物模板ID
-- 4 = playerLevel (只读) 玩家等级
-- 5 = monsterLevel (只读) 怪物等级
-- 6 = dropBoxId (只读) 掉落箱ID
-- 7 = itemId (读写) 物品ID
-- 8 = itemQuality (读写) 物品品质
-- 9 = dropNotifyId (读写) 掉落公告ID
-- 10 = dropRate (读写) 爆率倍率 (万分比, 10000=100%=不加成, 15000=+50%爆率)
-- 11 = randomValue (只读) 随机值 (万分比)
-- 12 = allowDrop (读写) 是否允许掉落 (1=允许, 0=禁止)
-- 13 = isBoss (只读) 是否BOSS怪物
-- 14 = isTeamDrop (只读) 是否队伍掉落
-- 15 = extraField (读写) 额外字段
--
-- 返回值:
-- 返回值1: 是否允许掉落 (0=禁止掉落, 其他值=允许掉落)
-- 返回值2: 爆率倍率修正 (万分比, 10000=不变, 15000=1.5倍, 5000=0.5倍, 0=使用dropData中的值, 负数=爆率设为0)
--**********************************
function x768990_callback_MonsterDrop(sceneId, selfId, monsterObjId, monsterDataId, playerLevel, dropData, getData, setData)
-- 获取基础信息
local monsterLevel = getData(sceneId, selfId, dropData, 5)
local isBoss = getData(sceneId, selfId, dropData, 13)
local isTeamDrop = getData(sceneId, selfId, dropData, 14)
local currentDropRate = getData(sceneId, selfId, dropData, 10) -- 万分比
-- 调试输出
-- 注意: currentDropRate 是爆率倍率(万分比), 10000=100%=不加成, 15000=150%=+50%爆率
-- x768990_NotifyTip(sceneId, selfId,
-- "怪物掉落回调: 怪物ID=" .. tostring(monsterDataId) ..
-- " 怪物等级=" .. tostring(monsterLevel) ..
-- " 是否BOSS=" .. tostring(isBoss) ..
-- " 爆率倍率=" .. tostring(currentDropRate/100) .. "%")
-- ============ 根据条件修改爆率 ============
local allowDrop = 1 -- 默认允许掉落
local dropRateMultiplier = 10000 -- 默认不修改爆率 (10000 = 100%)
-- 方法1: BOSS怪物爆率提升50%
-- if isBoss == 1 then
-- dropRateMultiplier = 15000 -- 150%
-- end
-- 方法2: 玩家等级比怪物高10级以上,爆率降低50%
-- if playerLevel > monsterLevel + 10 then
-- dropRateMultiplier = 5000 -- 50%
-- end
-- 方法3: 特定怪物禁止掉落
-- if monsterDataId == 12345 then
-- allowDrop = 0 -- 禁止掉落
-- end
-- 方法4: 根据玩家MissionData动态调整爆率
-- local vipLevel = GetMissionData(sceneId, selfId, 100) -- 假设MD100存储VIP等级
-- if vipLevel >= 5 then
-- dropRateMultiplier = 12000 -- VIP5以上爆率+20%
-- end
-- 方法5: 修改dropData中的爆率 (另一种方式)
-- setData(sceneId, selfId, dropData, 10, currentDropRate * 2) -- 爆率翻倍
-- 返回: 是否允许掉落, 爆率倍率
return allowDrop, dropRateMultiplier
end
--**********************************
-- 物品掉落回调 (Item Drop Callback)
-- 在具体物品掉落时调用,可以修改物品ID、品质等
-- 此回调在 my_ItemBoxRuler_CreateItemFromMonsterDrop 中调用
-- 通过线程局部上下文传递玩家和场景对象
--**********************************
-- 参数说明:
-- sceneId: 场景ID
-- selfId: 玩家ObjID
-- dropBoxId: 掉落箱ID
-- itemId: 原始物品ID
-- itemQuality: 原始物品品质
-- dropData: 掉落数据对象 (用于getData/setData)
-- getData: 获取掉落数据函数
-- setData: 设置掉落数据函数
--
-- getData/setData 索引说明:
-- 0 = sceneId (只读) 场景ID
-- 1 = playerObjId (只读) 玩家ObjID
-- 2 = monsterObjId (只读) 怪物ObjID
-- 3 = monsterDataId (只读) 怪物模板ID
-- 4 = playerLevel (只读) 玩家等级
-- 5 = monsterLevel (只读) 怪物等级
-- 6 = dropBoxId (只读) 掉落箱ID
-- 7 = itemId (读写) 物品ID
-- 8 = itemQuality (读写) 物品品质
-- 9 = dropNotifyId (读写) 掉落公告ID
-- 10 = allowDrop (读写) 是否允许掉落 (1=允许, 0=禁止)
-- 11 = newItemId (读写) 新物品ID (0=不修改)
-- 12 = newQuality (读写) 新品质 (0=不修改)
-- 13 = isBoss (只读) 是否BOSS怪物
-- 14 = isTeamDrop (只读) 是否队伍掉落
-- 15 = extraField (读写) 额外字段
--
-- 返回值:
-- 返回值1: 是否允许此物品掉落 (0=禁止, 其他=允许)
-- 返回值2: 新物品ID (0=不修改)
-- 返回值3: 新物品品质 (0=不修改)
--**********************************
function x768990_callback_ItemDrop(sceneId, selfId, dropBoxId, itemId, itemQuality, dropData, getData, setData)
-- 获取基础信息
local monsterObjId = getData(sceneId, selfId, dropData, 2)
local monsterDataId = getData(sceneId, selfId, dropData, 3)
local playerLevel = getData(sceneId, selfId, dropData, 4)
local monsterLevel = getData(sceneId, selfId, dropData, 5)
local dropNotifyId = getData(sceneId, selfId, dropData, 9)
local isBoss = getData(sceneId, selfId, dropData, 13)
local isTeamDrop = getData(sceneId, selfId, dropData, 14)
-- 调试输出
-- x768990_NotifyTip(sceneId, selfId,
-- "物品掉落回调: 掉落箱ID=" .. tostring(dropBoxId) ..
-- " 物品ID=" .. tostring(itemId) ..
-- " 品质=" .. tostring(itemQuality) ..
-- " 怪物ID=" .. tostring(monsterDataId) ..
-- " 是否BOSS=" .. tostring(isBoss))
local allowDrop = 1 -- 允许掉落
local newItemId = 0 -- 不修改物品ID
local newQuality = 0 -- 不修改品质
-- ============ 案例 ============
-- 方法1: 替换特定物品
-- if itemId == 30505013 then
-- newItemId = 10413104 -- 替换为另一个物品
-- end
-- 方法2: 提升品质
-- if itemQuality < 5 then
-- newQuality = itemQuality + 1
-- end
-- 方法3: 禁止特定物品掉落
-- if itemId == 30000000 then
-- allowDrop = 0 -- 禁止掉落
-- end
-- 方法4: BOSS掉落特殊处理
-- if isBoss == 1 then
-- -- BOSS掉落的物品品质+1
-- if itemQuality < 9 then
-- newQuality = itemQuality + 1
-- end
-- end
-- 方法5: 根据玩家等级调整掉落
-- if playerLevel > 80 then
-- -- 高等级玩家有几率获得更好的物品
-- local rand = random(1, 100)
-- if rand <= 10 then
-- newQuality = itemQuality + 1
-- end
-- end
-- 方法6: 通过setData修改数据
-- setData(sceneId, selfId, dropData, 11, 10001002) -- 设置新物品ID
-- setData(sceneId, selfId, dropData, 12, 5) -- 设置新品质
return allowDrop, newItemId, newQuality
end
--**********************************
--醒目提醒
--**********************************
function x768990_NotifyTip( sceneId, selfId, Msg )
BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end