2022-07-23 15:38:20 +00:00
|
|
|
scn EBxReplenishCanteen
|
|
|
|
|
|
|
|
ref rNewDrink
|
|
|
|
ref rCurrentDrink
|
|
|
|
ref rCanteen
|
2022-07-25 20:26:10 +00:00
|
|
|
ref rPreordVaultCanteen
|
2022-07-23 15:38:20 +00:00
|
|
|
int iCount
|
|
|
|
int iNewDrink
|
|
|
|
int bCheckOnly
|
|
|
|
|
|
|
|
begin function { rNewDrink, bCheckOnly }
|
|
|
|
|
2022-07-25 20:26:10 +00:00
|
|
|
if EBxReplenishableCanteen == 0
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
if playerRef.GetItemCount EBxVault13Canteen == 0
|
|
|
|
let ref rPreordVaultCanteen := GetFormFromMod "FalloutNV.esm" "1735D2" ; PreordVaultCanteen
|
|
|
|
if eval ! IsFormValid rPreordVaultCanteen || playerRef.GetItemCount rPreordVaultCanteen == 0
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2022-07-23 15:38:20 +00:00
|
|
|
let iNewDrink := ListGetFormIndex EBxCanteenEffects rNewDrink
|
|
|
|
|
|
|
|
if iNewDrink == -1 ; unknown type, fallback to Purified Water
|
|
|
|
set rNewDrink to WaterPurified
|
|
|
|
set iNewDrink to ListGetFormIndex EBxCanteenEffects rNewDrink
|
|
|
|
endif
|
|
|
|
|
|
|
|
let rCurrentDrink := ListGetNthForm EBxCanteenEffects EBxCanteenDrink
|
|
|
|
|
|
|
|
if IsFormValid rCurrentDrink == 0 ; invalid EBxCanteenDrink value, also fallback to Purified Water
|
|
|
|
set rCurrentDrink to WaterPurified
|
|
|
|
set EBxCanteenDrink to ListGetFormIndex EBxCanteenEffects rCurrentDrink
|
|
|
|
endif
|
|
|
|
|
|
|
|
if rNewDrink == rCurrentDrink
|
|
|
|
elseif rCurrentDrink == IrradiatedWaterUnpurified ; any replacement will do
|
|
|
|
elseif (rCurrentDrink != WaterPurified && rCurrentDrink != EBxBrahminMilk) && (rNewDrink == WaterPurified || rNewDrink == EBxBrahminMilk)
|
|
|
|
elseif playerRef.GetItemCount EBxVault13Canteen > 0
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
let iCount := EBxCanteenSipsMax - playerRef.GetItemCount EBxVault13Canteen
|
|
|
|
|
|
|
|
if bCheckOnly
|
|
|
|
SetFunctionValue (EBxCanteenDrink != iNewDrink || iCount > 0)
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
if iCount > 0
|
2022-07-25 20:26:10 +00:00
|
|
|
let rPreordVaultCanteen := GetFormFromMod "FalloutNV.esm" "1735D2" ; PreordVaultCanteen
|
|
|
|
if IsFormValid rPreordVaultCanteen
|
|
|
|
playerRef.RemoveItem rPreordVaultCanteen 1 1
|
|
|
|
endif
|
2022-07-23 15:38:20 +00:00
|
|
|
playerRef.AddItem EBxVault13Canteen iCount 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
set rCanteen to EBxVault13CanteenEffect
|
|
|
|
SetNameEx "%n" rNewDrink rCanteen
|
|
|
|
|
|
|
|
if EBxCanteenDrink != iNewDrink || iCount > 0
|
|
|
|
PlaySound ITMBottleDown 1
|
|
|
|
set rCanteen to EBxVault13Canteen
|
|
|
|
MessageEx "%n has been replenished with %n." rCanteen rNewDrink
|
|
|
|
endif
|
|
|
|
|
|
|
|
set EBxCanteenDrink to iNewDrink
|
|
|
|
|
|
|
|
end
|