Configurable removal chance multiplier for owned and locked items

This commit is contained in:
Eddoursul 2025-03-20 03:04:17 +01:00
parent e99117ed8b
commit cb25c678e3
9 changed files with 110 additions and 61 deletions

Binary file not shown.

View File

@ -92,9 +92,12 @@ begin function { rCell, aUniques }
endif endif
if rItem.GetOwner if rItem.GetOwner
DebugPrint "%n is an owned item, skipping." rBase DebugPrint "%n is an owned item, applying multiplier %.1f." rBase EULxWorldOwnedRemovalMod
set rItem to getNextRef let fRemovalChance *= EULxWorldOwnedRemovalMod
continue if fRemovalChance == 0
set rItem to getNextRef
continue
endif
endif endif
set iValue to GetSourceModIndex rBase set iValue to GetSourceModIndex rBase

View File

@ -12,11 +12,12 @@ long iValue
long iCount long iCount
float fCount float fCount
float fRemovalChance float fRemovalChance
float fRemovalChanceMult
array_var itemsToRemoveRefs array_var itemsToRemoveRefs
array_var itemsToRemoveCounts array_var itemsToRemoveCounts
array_var aUniques array_var aUniques
begin function { rCell, rContainer, aUniques } begin function { rCell, rContainer, aUniques, fRemovalChanceMult }
DebugPrint "Delootifying %n..." rContainer DebugPrint "Delootifying %n..." rContainer
@ -70,6 +71,8 @@ begin function { rCell, rContainer, aUniques }
DebugPrint "%n is non-removable, type %g." rBase iType DebugPrint "%n is non-removable, type %g." rBase iType
continue continue
endif endif
let fRemovalChance *= fRemovalChanceMult
if IsQuestItem rBase if IsQuestItem rBase
DebugPrint "%n is a quest item, skipping." rBase DebugPrint "%n is a quest item, skipping." rBase

View File

@ -27,7 +27,9 @@ begin function {}
set EULxWorldBaseRemovalChance to GetINIFloat "World:BaseRemovalChance" $sFile set EULxWorldBaseRemovalChance to GetINIFloat "World:BaseRemovalChance" $sFile
set EULxWorldContRemovalChance to GetINIFloat "World:ContRemovalChance" $sFile set EULxWorldContRemovalChance to GetINIFloat "World:ContRemovalChance" $sFile
set EULxWorldSkipLocked to GetINIFloat "World:SkipLocked" $sFile
set EULxWorldLockedRemovalMod to GetINIFloat "World:LockedRemovalMod" $sFile
set EULxWorldOwnedRemovalMod to GetINIFloat "World:OwnedRemovalMod" $sFile
set EULxWorldWeaponRemovalMod to GetINIFloat "World:WeaponRemovalMod" $sFile set EULxWorldWeaponRemovalMod to GetINIFloat "World:WeaponRemovalMod" $sFile
set EULxWorldAmmoRemovalMod to GetINIFloat "World:AmmoRemovalMod" $sFile set EULxWorldAmmoRemovalMod to GetINIFloat "World:AmmoRemovalMod" $sFile

View File

@ -21,7 +21,9 @@ begin function {}
SetINIFloat "World:BaseRemovalChance" EULxWorldBaseRemovalChance $sFile SetINIFloat "World:BaseRemovalChance" EULxWorldBaseRemovalChance $sFile
SetINIFloat "World:ContRemovalChance" EULxWorldContRemovalChance $sFile SetINIFloat "World:ContRemovalChance" EULxWorldContRemovalChance $sFile
SetINIFloat "World:SkipLocked" EULxWorldSkipLocked $sFile
SetINIFloat "World:LockedRemovalMod" EULxWorldLockedRemovalMod $sFile
SetINIFloat "World:OwnedRemovalMod" EULxWorldOwnedRemovalMod $sFile
SetINIFloat "World:WeaponRemovalMod" EULxWorldWeaponRemovalMod $sFile SetINIFloat "World:WeaponRemovalMod" EULxWorldWeaponRemovalMod $sFile
SetINIFloat "World:AmmoRemovalMod" EULxWorldAmmoRemovalMod $sFile SetINIFloat "World:AmmoRemovalMod" EULxWorldAmmoRemovalMod $sFile

View File

@ -50,6 +50,8 @@ begin function { iSuccess }
if FileExists "config\Unfound Loot.ini" if FileExists "config\Unfound Loot.ini"
if GetINIFloat "General:Saved" "Unfound Loot.ini" if GetINIFloat "General:Saved" "Unfound Loot.ini"
SetINIFloat "World:ContRemovalChance" EULxWorldContRemovalChance "Unfound Loot.ini" SetINIFloat "World:ContRemovalChance" EULxWorldContRemovalChance "Unfound Loot.ini"
SetINIFloat "World:OwnedRemovalMod" EULxWorldOwnedRemovalMod "Unfound Loot.ini"
SetINIFloat "World:LockedRemovalMod" EULxWorldLockedRemovalMod "Unfound Loot.ini"
endif endif
endif endif
endif endif

View File

@ -6,6 +6,9 @@ ref rItem
int iTemp int iTemp
int bSkip int bSkip
int bUniquesLoaded int bUniquesLoaded
int bOwnedCellMultApplied
float fOwnedCellMult
float fRemovalChanceMult
array_var aUniques array_var aUniques
@ -14,10 +17,16 @@ begin function { rCell }
if EULxWorldBaseRemovalChance == 0 && EULxWorldContRemovalChance == 0 if EULxWorldBaseRemovalChance == 0 && EULxWorldContRemovalChance == 0
return return
endif endif
let fOwnedCellMult := 1.0
if GetOwnerOfCell rCell if GetOwnerOfCell rCell
DebugPrint "%n is an owned cell, skipping." rCell DebugPrint "%n is an owned cell, applying multplier %.1f." rCell EULxWorldOwnedRemovalMod
return let fOwnedCellMult := EULxWorldOwnedRemovalMod
if fOwnedCellMult == 0
return
endif
let bOwnedCellMultApplied := 1
endif endif
if ListGetFormIndex EULxProtectedCells rCell != -1 if ListGetFormIndex EULxProtectedCells rCell != -1
@ -56,7 +65,8 @@ begin function { rCell }
while rTemp while rTemp
set bSkip to 0 let bSkip := 0
let fRemovalChanceMult := fOwnedCellMult
if rTemp.GetDisabled if rTemp.GetDisabled
DebugPrint "%n is disabled, skipping." rTemp DebugPrint "%n is disabled, skipping." rTemp
@ -70,31 +80,35 @@ begin function { rCell }
DebugPrint "%n is empty, skipping." rTemp DebugPrint "%n is empty, skipping." rTemp
set rTemp to GetNextRef set rTemp to GetNextRef
continue continue
elseif rTemp.GetLocked && EULxWorldSkipLocked
DebugPrint "%n is locked, skipping loot reduction." rTemp
set bSkip to 1
elseif rTemp.HasScriptBlock 2 ; OnActivate elseif rTemp.HasScriptBlock 2 ; OnActivate
DebugPrint "%n is scripted, skipping loot reduction." rTemp DebugPrint "%n is scripted, skipping loot reduction." rTemp
set bSkip to 1 set bSkip to 1
elseif rTemp.GetReferenceFlag 33554432 elseif rTemp.GetReferenceFlag 33554432
DebugPrint "%n has the No AI Acquire flag, skipping loot reduction." rTemp DebugPrint "%n has the No AI Acquire flag, skipping loot reduction." rTemp
set bSkip to 1 set bSkip to 1
elseif rTemp.GetOwner
DebugPrint "%n is owned, skipping loot reduction." rTemp
set bSkip to 1
elseif eval 0 < ar_size (rTemp.GetAllItems 49) elseif eval 0 < ar_size (rTemp.GetAllItems 49)
DebugPrint "%n contains a note, skipping loot reduction." rTemp DebugPrint "%n contains a note, skipping loot reduction." rTemp
set bSkip to 1 set bSkip to 1
endif endif
if bSkip == 0 if bSkip == 0
if rTemp.GetLocked
DebugPrint "%n is locked, applying multplier %.1f." rTemp EULxWorldLockedRemovalMod
let fRemovalChanceMult *= EULxWorldLockedRemovalMod
endif
if eval bOwnedCellMultApplied == 0 && rTemp.GetOwner
DebugPrint "%n is owned, applying multplier %.1f." rTemp EULxWorldOwnedRemovalMod
let fRemovalChanceMult *= EULxWorldOwnedRemovalMod
endif
if GetSourceModIndex rTemp != iTemp if GetSourceModIndex rTemp != iTemp
DebugPrint "%n is a mod-added container, skipping." rTemp DebugPrint "%n is a mod-added container, skipping." rTemp
set bSkip to 1 set bSkip to 1
endif endif
endif endif
if bSkip if bSkip || fRemovalChanceMult == 0
foreach rItem <- rTemp foreach rItem <- rTemp
if rItem.GetType == 24 || rItem.GetType == 40 if rItem.GetType == 24 || rItem.GetType == 40
call EULxReduceItemHealth rTemp rItem call EULxReduceItemHealth rTemp rItem
@ -109,7 +123,7 @@ begin function { rCell }
let aUniques := UnfoundLootUniqueStorageRef.GetAllItems let aUniques := UnfoundLootUniqueStorageRef.GetAllItems
endif endif
call EULxDelootifyContainer rCell rTemp aUniques call EULxDelootifyContainer rCell rTemp aUniques fRemovalChanceMult
set rTemp to GetNextRef set rTemp to GetNextRef

View File

@ -24,7 +24,9 @@ begin function { iPreset, bAll }
set EULxWorldBaseRemovalChance to 85 set EULxWorldBaseRemovalChance to 85
set EULxWorldContRemovalChance to 85 set EULxWorldContRemovalChance to 85
set EULxWorldSkipLocked to 1
set EULxWorldOwnedRemovalMod to 0
set EULxWorldLockedRemovalMod to 0
set EULxWorldWeaponRemovalMod to 1.0 set EULxWorldWeaponRemovalMod to 1.0
set EULxWorldArmorRemovalMod to 0.5 ; less chance of removing rad suits and such set EULxWorldArmorRemovalMod to 0.5 ; less chance of removing rad suits and such
@ -109,7 +111,8 @@ begin function { iPreset, bAll }
set EULxMaxArmorCondition to 20 set EULxMaxArmorCondition to 20
set EULxLuckModifier to 0 set EULxLuckModifier to 0
set EULxWorldSkipLocked to 0 set EULxWorldOwnedRemovalMod to 0.2
set EULxWorldLockedRemovalMod to 0.2
set EULxWorldBaseRemovalChance to 95 set EULxWorldBaseRemovalChance to 95
set EULxWorldContRemovalChance to 95 set EULxWorldContRemovalChance to 95

View File

@ -143,6 +143,12 @@ begin MenuMode 1013
call EULxMCMAddElement 0 "Removal chance multipliers" 0 call EULxMCMAddElement 0 "Removal chance multipliers" 0
call EULxMCMAddElement 0 "" 0 call EULxMCMAddElement 0 "" 0
call EULxMCMAddElement 2.5 "Owned items" EULxWorldOwnedRemovalMod
call EULxMCMAddElement 2.5 "Locked containers" EULxWorldLockedRemovalMod
call EULxMCMAddElement 0 "" 0
call EULxMCMAddElement 0 "" 0
call EULxMCMAddElement 2.5 "Weapons" EULxWorldWeaponRemovalMod call EULxMCMAddElement 2.5 "Weapons" EULxWorldWeaponRemovalMod
call EULxMCMAddElement 2.5 "Ammo" EULxWorldAmmoRemovalMod call EULxMCMAddElement 2.5 "Ammo" EULxWorldAmmoRemovalMod
call EULxMCMAddElement 2.5 "Apparel" EULxWorldArmorRemovalMod call EULxMCMAddElement 2.5 "Apparel" EULxWorldArmorRemovalMod
@ -152,7 +158,6 @@ begin MenuMode 1013
call EULxMCMAddElement 2.5 "Meds" EULxWorldMedsRemovalMod call EULxMCMAddElement 2.5 "Meds" EULxWorldMedsRemovalMod
call EULxMCMAddElement 2.5 "Food" EULxWorldFoodRemovalMod call EULxMCMAddElement 2.5 "Food" EULxWorldFoodRemovalMod
call EULxMCMAddElement 2.5 "Misc items" EULxWorldMiscRemovalMod call EULxMCMAddElement 2.5 "Misc items" EULxWorldMiscRemovalMod
call EULxMCMAddElement 5 "Skip locked containers" EULxWorldSkipLocked
elseif iSubMenu == 3 elseif iSubMenu == 3
@ -263,25 +268,28 @@ begin MenuMode 1013
set EULxWorldContRemovalChance to fValue set EULxWorldContRemovalChance to fValue
elseif iOption == 9 elseif iOption == 9
set EULxWorldWeaponRemovalMod to fValue set EULxWorldOwnedRemovalMod to fValue
elseif iOption == 10 elseif iOption == 10
set EULxWorldAmmoRemovalMod to fValue set EULxWorldLockedRemovalMod to fValue
elseif iOption == 11
set EULxWorldArmorRemovalMod to fValue
elseif iOption == 12
set EULxWorldCurrencyRemovalMod to fValue
elseif iOption == 13 elseif iOption == 13
set EULxWorldAlcoholRemovalMod to fValue set EULxWorldWeaponRemovalMod to fValue
elseif iOption == 14 elseif iOption == 14
set EULxWorldChemsRemovalMod to fValue set EULxWorldAmmoRemovalMod to fValue
elseif iOption == 15 elseif iOption == 15
set EULxWorldMedsRemovalMod to fValue set EULxWorldArmorRemovalMod to fValue
elseif iOption == 16 elseif iOption == 16
set EULxWorldFoodRemovalMod to fValue set EULxWorldCurrencyRemovalMod to fValue
elseif iOption == 17 elseif iOption == 17
set EULxWorldMiscRemovalMod to fValue set EULxWorldAlcoholRemovalMod to fValue
elseif iOption == 18 elseif iOption == 18
set EULxWorldSkipLocked to fValue set EULxWorldChemsRemovalMod to fValue
elseif iOption == 19
set EULxWorldMedsRemovalMod to fValue
elseif iOption == 20
set EULxWorldFoodRemovalMod to fValue
elseif iOption == 21
set EULxWorldMiscRemovalMod to fValue
endif endif
elseif iSubMenu == 3 elseif iSubMenu == 3
@ -406,24 +414,29 @@ begin MenuMode 1013
call EULxMCMAddScale "Base removal chance - containers" EULxWorldContRemovalChance "%" 0 100 0 1 call EULxMCMAddScale "Base removal chance - containers" EULxWorldContRemovalChance "%" 0 100 0 1
elseif iOption == 9 elseif iOption == 9
call EULxMCMAddScale "Weapon multiplier" EULxWorldWeaponRemovalMod "x" 0 10 1 0.1 call EULxMCMAddScale "Owned items multiplier" EULxWorldOwnedRemovalMod "x" 0 1 1 0.1
elseif iOption == 10 elseif iOption == 10
call EULxMCMAddScale "Locked containers multiplier" EULxWorldLockedRemovalMod "x" 0 1 1 0.1
elseif iOption == 13
call EULxMCMAddScale "Weapon multiplier" EULxWorldWeaponRemovalMod "x" 0 10 1 0.1
elseif iOption == 14
call EULxMCMAddScale "Ammo multiplier" EULxWorldAmmoRemovalMod "x" 0 10 1 0.1 call EULxMCMAddScale "Ammo multiplier" EULxWorldAmmoRemovalMod "x" 0 10 1 0.1
elseif iOption == 11 elseif iOption == 15
call EULxMCMAddScale "Armor multiplier" EULxWorldArmorRemovalMod "x" 0 10 1 0.1 call EULxMCMAddScale "Armor multiplier" EULxWorldArmorRemovalMod "x" 0 10 1 0.1
elseif iOption == 12 elseif iOption == 16
call EULxMCMAddScale "Currencies multiplier" EULxWorldCurrencyRemovalMod "x" 0 10 1 0.1 call EULxMCMAddScale "Currencies multiplier" EULxWorldCurrencyRemovalMod "x" 0 10 1 0.1
elseif iOption == 13 elseif iOption == 17
call EULxMCMAddScale "Alcohol multiplier" EULxWorldAlcoholRemovalMod "x" 0 10 1 0.1 call EULxMCMAddScale "Alcohol multiplier" EULxWorldAlcoholRemovalMod "x" 0 10 1 0.1
elseif iOption == 14 elseif iOption == 18
call EULxMCMAddScale "Chems multiplier" EULxWorldChemsRemovalMod "x" 0 10 1 0.1 call EULxMCMAddScale "Chems multiplier" EULxWorldChemsRemovalMod "x" 0 10 1 0.1
elseif iOption == 15 elseif iOption == 19
call EULxMCMAddScale "Meds multiplier" EULxWorldMedsRemovalMod "x" 0 10 1 0.1 call EULxMCMAddScale "Meds multiplier" EULxWorldMedsRemovalMod "x" 0 10 1 0.1
elseif iOption == 16 elseif iOption == 20
call EULxMCMAddScale "Food multiplier" EULxWorldFoodRemovalMod "x" 0 10 1 0.1 call EULxMCMAddScale "Food multiplier" EULxWorldFoodRemovalMod "x" 0 10 1 0.1
elseif iOption == 17 elseif iOption == 21
call EULxMCMAddScale "Misc items multiplier" EULxWorldMiscRemovalMod "x" 0 10 1 0.1 call EULxMCMAddScale "Misc items multiplier" EULxWorldMiscRemovalMod "x" 0 10 1 0.1
endif endif
@ -496,25 +509,30 @@ begin MenuMode 1013
elseif iOption == 4 elseif iOption == 4
SetUIFloat "StartMenu/MCM/_Value" 85 SetUIFloat "StartMenu/MCM/_Value" 85
elseif iOption == 9 ; weapons elseif iOption == 9 ; owned
SetUIFloat "StartMenu/MCM/_Value" 0.0
elseif iOption == 10 ; locked
SetUIFloat "StartMenu/MCM/_Value" 0.0
elseif iOption == 13 ; weapons
SetUIFloat "StartMenu/MCM/_Value" 1.0 SetUIFloat "StartMenu/MCM/_Value" 1.0
elseif iOption == 10 ; ammo elseif iOption == 14 ; ammo
SetUIFloat "StartMenu/MCM/_Value" 1.0 SetUIFloat "StartMenu/MCM/_Value" 1.0
elseif iOption == 11 ; armor elseif iOption == 15 ; armor
SetUIFloat "StartMenu/MCM/_Value" 0.5 SetUIFloat "StartMenu/MCM/_Value" 0.5
elseif iOption == 12 ; currencies elseif iOption == 16 ; currencies
SetUIFloat "StartMenu/MCM/_Value" 2.0 SetUIFloat "StartMenu/MCM/_Value" 2.0
elseif iOption == 13 ; alcohol elseif iOption == 17 ; alcohol
SetUIFloat "StartMenu/MCM/_Value" 1.0 SetUIFloat "StartMenu/MCM/_Value" 1.0
elseif iOption == 14 ; chems elseif iOption == 18 ; chems
SetUIFloat "StartMenu/MCM/_Value" 1.0 SetUIFloat "StartMenu/MCM/_Value" 1.0
elseif iOption == 15 ; meds elseif iOption == 19 ; meds
SetUIFloat "StartMenu/MCM/_Value" 1.0 SetUIFloat "StartMenu/MCM/_Value" 1.0
elseif iOption == 16 ; food elseif iOption == 20 ; food
SetUIFloat "StartMenu/MCM/_Value" 1.3 SetUIFloat "StartMenu/MCM/_Value" 1.3
elseif iOption == 17 ; misc elseif iOption == 21 ; misc
SetUIFloat "StartMenu/MCM/_Value" 0.3 SetUIFloat "StartMenu/MCM/_Value" 0.3
endif endif
@ -609,29 +627,31 @@ begin MenuMode 1013
SetUIString "StartMenu/MCM/*:9/string" "Removal chance for container items. We get a random number between 0 and 100 and compare it with 100. If the number is smaller, the item gets removed. Set to 0 to disable." SetUIString "StartMenu/MCM/*:9/string" "Removal chance for container items. We get a random number between 0 and 100 and compare it with 100. If the number is smaller, the item gets removed. Set to 0 to disable."
elseif iMouseover == 9 elseif iMouseover == 9
SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for weapons. Higher = greater chance of these items being removed." SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for owned items. Higher = greater chance of these items being removed. Set to 0 to not remove at all."
elseif iMouseover == 10 elseif iMouseover == 10
SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for items in locked containers. Higher = greater chance of these items being removed. Set to 0 to not remove at all."
elseif iMouseover == 13
SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for weapons. Higher = greater chance of these items being removed."
elseif iMouseover == 14
SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for ammo. Higher = greater chance of these items being removed." SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for ammo. Higher = greater chance of these items being removed."
elseif iMouseover == 11 elseif iMouseover == 15
SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for armor. Higher = greater chance of these items being removed." SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for armor. Higher = greater chance of these items being removed."
elseif iMouseover == 12 elseif iMouseover == 16
SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for currencies. Higher = greater chance of these items being removed." SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for currencies. Higher = greater chance of these items being removed."
elseif iMouseover == 13 elseif iMouseover == 17
SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for alcohol. Higher = greater chance of these items being removed." SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for alcohol. Higher = greater chance of these items being removed."
elseif iMouseover == 14 elseif iMouseover == 18
SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for chems. Higher = greater chance of these items being removed." SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for chems. Higher = greater chance of these items being removed."
elseif iMouseover == 15 elseif iMouseover == 19
SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for healing items. Higher = greater chance of these items being removed." SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for healing items. Higher = greater chance of these items being removed."
elseif iMouseover == 16 elseif iMouseover == 20
SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for food, water, and soft drinks. Higher = greater chance of these items being removed." SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for food, water, and soft drinks. Higher = greater chance of these items being removed."
elseif iMouseover == 17 elseif iMouseover == 21
SetUIString "StartMenu/MCM/*:9/string" "Removal chance multiplier for misc items. Higher = greater chance of these items being removed." SetUIString "StartMenu/MCM/*:9/string" "Removal chance multiplier for misc items. Higher = greater chance of these items being removed."
elseif iMouseover == 18
SetUIString "StartMenu/MCM/*:9/string" "Do not remove items from locked containers."
else else
SetUIFloat "StartMenu/MCM/*:9/visible" 0 SetUIFloat "StartMenu/MCM/*:9/visible" 0
endif endif