Use a container to store unique items instead of auxiliary variables
This commit is contained in:
parent
b24738aec6
commit
e843ab2505
1
mod/.gitignore
vendored
Normal file
1
mod/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
meta.ini
|
||||
Binary file not shown.
@ -10,7 +10,9 @@ long iCount
|
||||
float fCount
|
||||
float fRemovalChance
|
||||
|
||||
begin function { rCell }
|
||||
array_var aUniques
|
||||
|
||||
begin function { rCell, aUniques }
|
||||
|
||||
DebugPrint "Scanning cell %n for removable items" rCell
|
||||
|
||||
@ -156,9 +158,9 @@ begin function { rCell }
|
||||
continue
|
||||
endif
|
||||
|
||||
if AuxiliaryVariableGetFloat "S" 0 rBase == 0 ; the item is encountered for the first time
|
||||
if eval (Ar_Find rBase aUniques) == Ar_BadNumericIndex ; the item is encountered for the first time
|
||||
DebugPrint "Adding %n to ever scanned list, should only see this once" rBase
|
||||
AuxiliaryVariableSetFloat "S" 1 0 rBase
|
||||
UnfoundLootUniqueStorageRef.AddItem rBase 1 1
|
||||
set rItem to getNextRef
|
||||
continue
|
||||
endif
|
||||
|
||||
@ -14,8 +14,9 @@ float fCount
|
||||
float fRemovalChance
|
||||
array_var itemsToRemoveRefs
|
||||
array_var itemsToRemoveCounts
|
||||
array_var aUniques
|
||||
|
||||
begin function { rCell, rContainer }
|
||||
begin function { rCell, rContainer, aUniques }
|
||||
|
||||
DebugPrint "Delootifying %n..." rContainer
|
||||
|
||||
@ -111,9 +112,9 @@ begin function { rCell, rContainer }
|
||||
continue
|
||||
endif
|
||||
|
||||
if AuxiliaryVariableGetFloat "S" 0 rBase == 0 ; the item is encountered for the first time
|
||||
if eval (Ar_Find rBase aUniques) == Ar_BadNumericIndex ; the item is encountered for the first time
|
||||
DebugPrint "Adding %n to ever scanned list, should only see this once" rBase
|
||||
AuxiliaryVariableSetFloat "S" 1 0 rBase
|
||||
UnfoundLootUniqueStorageRef.AddItem rBase 1 1
|
||||
continue
|
||||
endif
|
||||
|
||||
|
||||
@ -20,6 +20,8 @@ int iCount
|
||||
|
||||
int bDisintegrated
|
||||
|
||||
array_var aUniques
|
||||
|
||||
begin function { rNPC, bDisintegrated }
|
||||
|
||||
set fBasefRemovalChance to call EULxCalculateBaseRemovalChance rNPC
|
||||
@ -31,6 +33,8 @@ begin function { rNPC, bDisintegrated }
|
||||
|
||||
DebugPrint "Scanning %n's inventory." rNPC
|
||||
|
||||
let aUniques := UnfoundLootUniqueStorageRef.GetAllItems
|
||||
|
||||
let itemsToRemoveRefs := ar_construct "array"
|
||||
let itemsToRemoveCounts := ar_construct "array"
|
||||
|
||||
@ -122,6 +126,12 @@ begin function { rNPC, bDisintegrated }
|
||||
continue
|
||||
endif
|
||||
|
||||
if eval (Ar_Find rBase aUniques) == Ar_BadNumericIndex ; the item is encountered for the first time
|
||||
DebugPrint "Adding %n to ever scanned list, should only see this once" rBase
|
||||
UnfoundLootUniqueStorageRef.AddItem rBase 1 1
|
||||
continue
|
||||
endif
|
||||
|
||||
if ListGetFormIndex EULxDeathItems rBase != -1
|
||||
DebugPrint "Skipping death item: %n" rBase
|
||||
continue
|
||||
@ -236,17 +246,19 @@ begin function { rNPC, bDisintegrated }
|
||||
|
||||
printd "SCAN COMPLETE!"
|
||||
|
||||
let aUniques := ar_null
|
||||
|
||||
; NB: The game will CTD if we remove items in the main loop.
|
||||
|
||||
set i to 0
|
||||
set iLimit to ar_size itemsToRemoveRefs
|
||||
let i := 0
|
||||
let iLimit := ar_size itemsToRemoveRefs
|
||||
|
||||
while i < iLimit
|
||||
let rBase := itemsToRemoveRefs[i]
|
||||
let iCount := itemsToRemoveCounts[i]
|
||||
DebugPrint "Removing %g of %n from %n" iCount rBase rNPC
|
||||
rNPC.removeItem rBase iCount 1
|
||||
set i to i + 1
|
||||
let i += 1
|
||||
loop
|
||||
|
||||
let itemsToRemoveRefs := ar_null
|
||||
|
||||
@ -6,6 +6,9 @@ ref rItem
|
||||
int iTemp
|
||||
int iPrecalc
|
||||
int bSkip
|
||||
int bUniquesLoaded
|
||||
|
||||
array_var aUniques
|
||||
|
||||
begin function { rCell }
|
||||
|
||||
@ -32,7 +35,9 @@ begin function { rCell }
|
||||
if GetFirstRefInCell rCell 201 0 0
|
||||
set iPrecalc to 1
|
||||
call EULxPrecalculateRemovalChance
|
||||
call EULxDelootifyCellItems rCell
|
||||
let bUniquesLoaded := 1
|
||||
let aUniques := UnfoundLootUniqueStorageRef.GetAllItems
|
||||
call EULxDelootifyCellItems rCell aUniques
|
||||
endif
|
||||
|
||||
|
||||
@ -97,10 +102,17 @@ begin function { rCell }
|
||||
call EULxPrecalculateRemovalChance
|
||||
endif
|
||||
|
||||
call EULxDelootifyContainer rCell rTemp
|
||||
if bUniquesLoaded == 0
|
||||
let bUniquesLoaded := 1
|
||||
let aUniques := UnfoundLootUniqueStorageRef.GetAllItems
|
||||
endif
|
||||
|
||||
call EULxDelootifyContainer rCell rTemp aUniques
|
||||
|
||||
set rTemp to GetNextRef
|
||||
|
||||
loop
|
||||
|
||||
let aUniques := ar_null
|
||||
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user