添加示例项目
This commit is contained in:
134
示例项目/强化相关概率提升/强化增幅锻造.nut
Normal file
134
示例项目/强化相关概率提升/强化增幅锻造.nut
Normal file
@@ -0,0 +1,134 @@
|
||||
function _Dps_Upgrade_Boost_Main_() {
|
||||
_Dps_Upgrade_Boost_Logic_();
|
||||
}
|
||||
|
||||
function _Dps_Upgrade_Boost_Main_Reload_(OldConfig) {
|
||||
_Dps_Upgrade_Boost_Logic_();
|
||||
}
|
||||
|
||||
function _Dps_Upgrade_Boost_Logic_() {
|
||||
|
||||
Cb_WongWork_CItemUpgrade_Enter_Func._Upgrade_Boost <- function(args) {
|
||||
local SUser = User(args[1]);
|
||||
local characNo = SUser.GetCID();
|
||||
local invenItem = args[2];
|
||||
local upgradeInfo = args[3];
|
||||
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 isAmplify = _UpgradeBoostHelper.hasAmplifyAbility(invenItem);
|
||||
local upgradeType = isAmplify ? "增幅" : "强化";
|
||||
|
||||
local boost = _UpgradeBoostHelper.getFinalBoost(SUser, targetLevel, upgradeType);
|
||||
|
||||
if (boost > 0) {
|
||||
local boostAmount = (probBase * boost / 100).tointeger();
|
||||
local newFailRate = originalFailRate - boostAmount;
|
||||
if (newFailRate < 0) newFailRate = 0;
|
||||
NativePointer(upgradeInfo).add(32).writeU32(newFailRate);
|
||||
}
|
||||
}
|
||||
|
||||
Cb_WongWork_CItemUpgrade_Separate_Enter_Func._Separate_Boost <- function(args) {
|
||||
local thisPtr = args[0];
|
||||
local SUser = User(args[1]);
|
||||
local invenItem = args[2];
|
||||
local upgradeInfo = args[3];
|
||||
|
||||
local originalFailRate = NativePointer(upgradeInfo).add(4).readU32();
|
||||
local probBase = NativePointer(thisPtr).add(400).readU32();
|
||||
local currentLevel = NativePointer(invenItem).add(51).readU8();
|
||||
local targetLevel = currentLevel + 1;
|
||||
|
||||
local boost = _UpgradeBoostHelper.getFinalBoost(SUser, targetLevel, "锻造");
|
||||
|
||||
if (boost > 0) {
|
||||
local boostAmount = ((probBase / 10) * boost / 100).tointeger();
|
||||
local newFailRate = originalFailRate + boostAmount;
|
||||
if (newFailRate > 10000) newFailRate = 10000;
|
||||
NativePointer(upgradeInfo).add(4).writeU32(newFailRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _UpgradeBoostHelper {
|
||||
|
||||
function hasAmplifyAbility(invenItem) {
|
||||
return NativePointer(invenItem).add(17).readU8() != 0;
|
||||
}
|
||||
|
||||
function isInRange(level, rangeStr) {
|
||||
local parts = split(rangeStr, "-");
|
||||
|
||||
if (parts.len() == 1) {
|
||||
return level == parts[0].tointeger();
|
||||
} else if (parts.len() == 2) {
|
||||
local min = parts[0].tointeger();
|
||||
local max = parts[1].tointeger();
|
||||
return level >= min && level <= max;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getBoostFromConfig(config, level, upgradeType) {
|
||||
if (!config.rawin(upgradeType)) return 0;
|
||||
|
||||
local typeConfig = config[upgradeType];
|
||||
|
||||
if (typeof typeConfig == "array") {
|
||||
foreach (rule in typeConfig) {
|
||||
if (rule.rawin("目标等级") && rule.rawin("加成")) {
|
||||
if (_UpgradeBoostHelper.isInRange(level, rule["目标等级"])) {
|
||||
return rule["加成"];
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (typeof typeConfig == "table") {
|
||||
local levelKey = level.tostring();
|
||||
if (typeConfig.rawin(levelKey)) {
|
||||
return typeConfig[levelKey];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function getFinalBoost(user, level, upgradeType) {
|
||||
local Config = GlobalConfig.Get("强化相关概率配置.json");
|
||||
local characNo = user.GetCID();
|
||||
|
||||
// 1. 检查VIP
|
||||
foreach (vip in Config["VIP配置"]) {
|
||||
if (vip["角色ID"] == characNo) {
|
||||
return _UpgradeBoostHelper.getBoostFromConfig(vip, level, upgradeType);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 检查穿戴物品(叠加)
|
||||
local InvenObj = user.GetInven();
|
||||
if (!InvenObj) return 0;
|
||||
|
||||
local totalBoost = 0;
|
||||
|
||||
foreach (itemCfg in Config["物品配置"]) {
|
||||
local itemObj = InvenObj.GetSlot(Inven.INVENTORY_TYPE_BODY, itemCfg["槽位"]);
|
||||
if (itemObj.IsEmpty) continue;
|
||||
|
||||
local itemId = itemObj.GetIndex();
|
||||
|
||||
if (itemId == itemCfg["物品ID"]) {
|
||||
local itemBoost = _UpgradeBoostHelper.getBoostFromConfig(itemCfg, level, upgradeType);
|
||||
totalBoost += itemBoost;
|
||||
}
|
||||
}
|
||||
|
||||
return totalBoost;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user