Split base removal chance for world-placed and container items

This commit is contained in:
Eddoursul 2025-03-20 01:38:58 +01:00
parent e843ab2505
commit e99117ed8b
9 changed files with 65 additions and 43 deletions

Binary file not shown.

View File

@ -25,8 +25,8 @@ begin function {}
; World
set EULxWorldLootRemovalEnabled to GetINIFloat "World:LootRemovalEnabled" $sFile
set EULxWorldBaseRemovalChance to GetINIFloat "World:BaseRemovalChance" $sFile
set EULxWorldContRemovalChance to GetINIFloat "World:ContRemovalChance" $sFile
set EULxWorldSkipLocked to GetINIFloat "World:SkipLocked" $sFile
set EULxWorldWeaponRemovalMod to GetINIFloat "World:WeaponRemovalMod" $sFile

View File

@ -19,8 +19,8 @@ begin function {}
; World
SetINIFloat "World:LootRemovalEnabled" EULxWorldLootRemovalEnabled $sFile
SetINIFloat "World:BaseRemovalChance" EULxWorldBaseRemovalChance $sFile
SetINIFloat "World:ContRemovalChance" EULxWorldContRemovalChance $sFile
SetINIFloat "World:SkipLocked" EULxWorldSkipLocked $sFile
SetINIFloat "World:WeaponRemovalMod" EULxWorldWeaponRemovalMod $sFile

View File

@ -41,4 +41,18 @@ begin function { iSuccess }
endif
endif
if EULxVersion < 4
set EULxVersion to 4
set EULxWorldContRemovalChance to EULxWorldBaseRemovalChance
if EULxSaveToINI
if FileExists "config\Unfound Loot.ini"
if GetINIFloat "General:Saved" "Unfound Loot.ini"
SetINIFloat "World:ContRemovalChance" EULxWorldContRemovalChance "Unfound Loot.ini"
endif
endif
endif
endif
end

View File

@ -8,7 +8,7 @@ begin function {}
SetJohnnyOnLimbGoneEventHandler EULxActorBreakOnDecapitation EULxOnLimbGone 0
if IsModLoaded "JIP MiniMap.esp" == 0
SetJohnnySeenDataEventHandler EULxWorldLootRemovalEnabled EULxOnSeen 0
SetJohnnySeenDataEventHandler 1 EULxOnSeen 0
endif
if GetGameRestarted

View File

@ -4,7 +4,6 @@ ref rCell
ref rTemp
ref rItem
int iTemp
int iPrecalc
int bSkip
int bUniquesLoaded
@ -12,7 +11,7 @@ array_var aUniques
begin function { rCell }
if EULxWorldLootRemovalEnabled == 0
if EULxWorldBaseRemovalChance == 0 && EULxWorldContRemovalChance == 0
return
endif
@ -32,14 +31,18 @@ begin function { rCell }
; Do not call EULxDelootifyCellItems if the cell has no items
if GetFirstRefInCell rCell 201 0 0
set iPrecalc to 1
call EULxPrecalculateRemovalChance
let bUniquesLoaded := 1
let aUniques := UnfoundLootUniqueStorageRef.GetAllItems
call EULxDelootifyCellItems rCell aUniques
if EULxWorldBaseRemovalChance != 0
if GetFirstRefInCell rCell 201 0 0
call EULxPrecalculateRemovalChance EULxWorldBaseRemovalChance
let bUniquesLoaded := 1
let aUniques := UnfoundLootUniqueStorageRef.GetAllItems
call EULxDelootifyCellItems rCell aUniques
endif
endif
if EULxWorldContRemovalChance == 0
return
endif
DebugPrint "Scanning %n (%i) for containers" rCell rCell
@ -47,6 +50,10 @@ begin function { rCell }
set rTemp to GetFirstRefInCell rCell 27 0 0
if rTemp
call EULxPrecalculateRemovalChance EULxWorldContRemovalChance
endif
while rTemp
set bSkip to 0
@ -97,11 +104,6 @@ begin function { rCell }
continue
endif
if iPrecalc == 0
set iPrecalc to 1
call EULxPrecalculateRemovalChance
endif
if bUniquesLoaded == 0
let bUniquesLoaded := 1
let aUniques := UnfoundLootUniqueStorageRef.GetAllItems

View File

@ -1,12 +1,13 @@
scn EULxPrecalculateRemovalChance
int iBaseRemovalChance
float fTemp
begin function {}
begin function { iBaseRemovalChance }
set fTemp to (( EULxLuckModifier / 10 ) * playerRef.getAV luck) / 100
set fTemp to 1 - fTemp
set fTemp to EULxWorldBaseRemovalChance * fTemp
set fTemp to iBaseRemovalChance * fTemp
set fTemp to fTemp / 100
;DebugPrint "Base removal chance %g, luck effect %g%% - new base removal chance %g%%" EULxWorldBaseRemovalChance EULxLuckModifier fTemp

View File

@ -22,8 +22,8 @@ begin function { iPreset, bAll }
; World-placed Items
set EULxWorldLootRemovalEnabled to 1
set EULxWorldBaseRemovalChance to 85
set EULxWorldContRemovalChance to 85
set EULxWorldSkipLocked to 1
set EULxWorldWeaponRemovalMod to 1.0
@ -81,6 +81,7 @@ begin function { iPreset, bAll }
set EULxMaxArmorCondition to 30
set EULxWorldBaseRemovalChance to 95
set EULxWorldContRemovalChance to 95
set EULxWorldArmorRemovalMod to 1.0
set EULxWorldMiscRemovalMod to .80 ;sparse interiors
set EULxWorldAmmoRemovalMod to 2.0 ;too much ammo as is
@ -111,6 +112,7 @@ begin function { iPreset, bAll }
set EULxWorldSkipLocked to 0
set EULxWorldBaseRemovalChance to 95
set EULxWorldContRemovalChance to 95
set EULxWorldWeaponRemovalMod to 1.5
set EULxWorldArmorRemovalMod to 0.6
set EULxWorldMiscRemovalMod to 0.33 ; junk doesnt get picked up
@ -140,6 +142,7 @@ begin function { iPreset, bAll }
set EULxMaxArmorCondition to 35
set EULxWorldBaseRemovalChance to 66
set EULxWorldContRemovalChance to 66
set EULxWorldWeaponRemovalMod to 1.5
set EULxWorldCurrencyRemovalMod to 2.0
@ -159,6 +162,4 @@ begin function { iPreset, bAll }
endif
call EULxPrecalculateRemovalChance
end

View File

@ -131,11 +131,12 @@ begin MenuMode 1013
SetMCMFloat 1 0 "_columns" 2
call EULxMCMAddElement 4 "Enabled" EULxWorldLootRemovalEnabled
call EULxMCMAddElement 2 "Base removal chance" EULxWorldBaseRemovalChance
call EULxMCMAddElement 5 "Skip locked containers" EULxWorldSkipLocked
call EULxMCMAddElement 0 "Base removal chance" 0
call EULxMCMAddElement 0 "" 0
call EULxMCMAddElement 2 "World-placed items" EULxWorldBaseRemovalChance
call EULxMCMAddElement 2 "Container items" EULxWorldContRemovalChance
call EULxMCMAddElement 0 "" 0
call EULxMCMAddElement 0 "" 0
@ -151,6 +152,8 @@ begin MenuMode 1013
call EULxMCMAddElement 2.5 "Meds" EULxWorldMedsRemovalMod
call EULxMCMAddElement 2.5 "Food" EULxWorldFoodRemovalMod
call EULxMCMAddElement 2.5 "Misc items" EULxWorldMiscRemovalMod
call EULxMCMAddElement 5 "Skip locked containers" EULxWorldSkipLocked
elseif iSubMenu == 3
@ -254,14 +257,10 @@ begin MenuMode 1013
elseif iSubMenu == 2
if iOption == 1
set EULxWorldLootRemovalEnabled to fValue
SetJohnnySeenDataEventHandler fValue EULxOnSeen 0
elseif iOption == 2
if iOption == 3
set EULxWorldBaseRemovalChance to fValue
elseif iOption == 3
set EULxWorldSkipLocked to fValue
elseif iOption == 4
set EULxWorldContRemovalChance to fValue
elseif iOption == 9
set EULxWorldWeaponRemovalMod to fValue
@ -281,6 +280,8 @@ begin MenuMode 1013
set EULxWorldFoodRemovalMod to fValue
elseif iOption == 17
set EULxWorldMiscRemovalMod to fValue
elseif iOption == 18
set EULxWorldSkipLocked to fValue
endif
elseif iSubMenu == 3
@ -335,8 +336,6 @@ begin MenuMode 1013
endif
call EULxPrecalculateRemovalChance
if EULxSaveToINI
call EULxINISaveSettings
endif
@ -401,8 +400,10 @@ begin MenuMode 1013
elseif iSubMenu == 2
if iOption == 2
call EULxMCMAddScale "Base removal chance" EULxWorldBaseRemovalChance "%" 0 100 0 1
if iOption == 3
call EULxMCMAddScale "Base removal chance - world items" EULxWorldBaseRemovalChance "%" 0 100 0 1
elseif iOption == 4
call EULxMCMAddScale "Base removal chance - containers" EULxWorldContRemovalChance "%" 0 100 0 1
elseif iOption == 9
call EULxMCMAddScale "Weapon multiplier" EULxWorldWeaponRemovalMod "x" 0 10 1 0.1
@ -490,7 +491,9 @@ begin MenuMode 1013
elseif iSubMenu == 2
if iOption == 2
if iOption == 3
SetUIFloat "StartMenu/MCM/_Value" 85
elseif iOption == 4
SetUIFloat "StartMenu/MCM/_Value" 85
elseif iOption == 9 ; weapons
@ -600,12 +603,10 @@ begin MenuMode 1013
SetUIFloat "StartMenu/MCM/*:9/visible" 1
if iMouseover == 1
SetUIString "StartMenu/MCM/*:9/string" "Enable or disable world items reduction."
elseif iMouseover == 2
SetUIString "StartMenu/MCM/*:9/string" "Removal chance for world-placed and 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."
elseif iMouseover == 3
SetUIString "StartMenu/MCM/*:9/string" "Do not remove items from locked containers."
if iMouseover == 3
SetUIString "StartMenu/MCM/*:9/string" "Removal chance for world-placed 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 == 4
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
SetUIStringEx "StartMenu/MCM/*:9/string" "Removal chance multiplier for weapons. Higher = greater chance of these items being removed."
@ -628,6 +629,9 @@ begin MenuMode 1013
elseif iMouseover == 17
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
SetUIFloat "StartMenu/MCM/*:9/visible" 0
endif