diff --git a/mod/Unfound Loot.esp b/mod/Unfound Loot.esp index a00fe74..dafdbec 100644 Binary files a/mod/Unfound Loot.esp and b/mod/Unfound Loot.esp differ diff --git a/src/EULxINILoadSettings.gek b/src/EULxINILoadSettings.gek index 657b69a..f6ddc18 100644 --- a/src/EULxINILoadSettings.gek +++ b/src/EULxINILoadSettings.gek @@ -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 diff --git a/src/EULxINISaveSettings.gek b/src/EULxINISaveSettings.gek index 64ecbbe..8d331f8 100644 --- a/src/EULxINISaveSettings.gek +++ b/src/EULxINISaveSettings.gek @@ -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 diff --git a/src/EULxOnGameLoad.gek b/src/EULxOnGameLoad.gek index b7863dc..f139ea3 100644 --- a/src/EULxOnGameLoad.gek +++ b/src/EULxOnGameLoad.gek @@ -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 diff --git a/src/EULxOnGameMode.gek b/src/EULxOnGameMode.gek index 6e8a1bc..1156a41 100644 --- a/src/EULxOnGameMode.gek +++ b/src/EULxOnGameMode.gek @@ -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 diff --git a/src/EULxOnSeen.gek b/src/EULxOnSeen.gek index 717c9dd..703a01d 100644 --- a/src/EULxOnSeen.gek +++ b/src/EULxOnSeen.gek @@ -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 diff --git a/src/EULxPrecalculateRemovalChance.gek b/src/EULxPrecalculateRemovalChance.gek index 61f52cb..99bcd1b 100644 --- a/src/EULxPrecalculateRemovalChance.gek +++ b/src/EULxPrecalculateRemovalChance.gek @@ -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 diff --git a/src/EULxPresetSetterFUNCTION.gek b/src/EULxPresetSetterFUNCTION.gek index c1b91dc..85df731 100644 --- a/src/EULxPresetSetterFUNCTION.gek +++ b/src/EULxPresetSetterFUNCTION.gek @@ -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 \ No newline at end of file diff --git a/src/EULxQuestScript.gek b/src/EULxQuestScript.gek index 34543d7..42ff9e5 100644 --- a/src/EULxQuestScript.gek +++ b/src/EULxQuestScript.gek @@ -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