添加示例项目
This commit is contained in:
63
示例项目/强化增幅药剂/强化增幅药剂.nut
Normal file
63
示例项目/强化增幅药剂/强化增幅药剂.nut
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
文件名:强化药剂.nut
|
||||
路径:强化药剂/强化药剂.nut
|
||||
创建日期:2025-03-10
|
||||
文件用途:使用强化药剂增加强化成功几率
|
||||
*/
|
||||
|
||||
function _Dps_EnhancementPotion_Main_() {
|
||||
// 注册强化进入回调
|
||||
Cb_WongWork_CItemUpgrade_Enter_Func["强化药剂_逻辑"] <- function(args) {
|
||||
local Config = GlobalConfig.Get("强化增幅药剂_Pluto.json");
|
||||
local SUser = User(args[1]);
|
||||
local invenItem = args[2];
|
||||
local upgradeInfo = args[3];
|
||||
|
||||
// 检查开关
|
||||
if (!Config["开关(true/false)"]) {
|
||||
return args;
|
||||
}
|
||||
|
||||
// 检查用户是否拥有强化药剂
|
||||
local hasPotion = Sq_CallFunc(
|
||||
S_Ptr("0x865E994"),
|
||||
"int",
|
||||
["pointer", "int"],
|
||||
SUser.C_Object,
|
||||
Config["强化药剂ID"]
|
||||
);
|
||||
|
||||
if (!hasPotion) {
|
||||
return args;
|
||||
}
|
||||
|
||||
// 读取基础概率
|
||||
local probBase = NativePointer(args[0]).add(0x4EC).readU32();
|
||||
|
||||
// 获取当前强化等级和目标等级
|
||||
local currentLevel = Sq_CallFunc(S_Ptr("0x080F506C"), "int", ["pointer"], invenItem);
|
||||
local targetLevel = currentLevel + 1;
|
||||
|
||||
// 读取原始失败率
|
||||
local originalFailRate = NativePointer(upgradeInfo).add(32).readU32();
|
||||
|
||||
// 获取概率加成值
|
||||
local charac_no = SUser.GetCID().tostring();
|
||||
local boost = Config["默认增加概率"];
|
||||
|
||||
// 检查是否是指定角色,使用指定角色的概率
|
||||
if (Config["指定角色概率"].rawin(charac_no)) {
|
||||
boost = Config["指定角色概率"][charac_no];
|
||||
}
|
||||
|
||||
// 计算新的失败率
|
||||
if (boost > 0) {
|
||||
local boostAmount = (probBase * boost / 100).tointeger();
|
||||
local newFailRate = originalFailRate - boostAmount;
|
||||
if (newFailRate < 0) newFailRate = 0;
|
||||
NativePointer(upgradeInfo).add(32).writeU32(newFailRate);
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user