Disallowed negative cost for set/get_inven_ap_cost

This commit is contained in:
NovaRain
2026-05-11 13:34:59 +08:00
parent a67fa86116
commit 7542e224dd
+3 -3
View File
@@ -820,7 +820,7 @@ skipDrag:
}
static int invenApCost, invenApCostDef;
static char invenApQPReduction;
static signed char invenApQPReduction;
static __declspec(naked) void inven_ap_cost_hack() {
__asm {
@@ -837,13 +837,13 @@ inline static void ApplyInvenApCostPatch() {
}
void __fastcall Inventory::SetInvenApCost(int cost) {
invenApCost = cost;
invenApCost = (cost < 0) ? 0 : cost;
if (!onlyOnceAP) ApplyInvenApCostPatch();
}
long Inventory::GetInvenApCost() {
long perkLevel = fo::func::perk_level(*fo::ptr::obj_dude, fo::PERK_quick_pockets);
return invenApCost - (invenApQPReduction * perkLevel);
return max(0, invenApCost - (invenApQPReduction * perkLevel));
}
void Inventory::OnGameReset() {