Delayed bottle filling (WIP)

This commit is contained in:
Eddoursul 2022-07-24 16:13:55 +02:00
parent 5d25082558
commit a11cafb50a
9 changed files with 133 additions and 81 deletions

Binary file not shown.

View File

@ -0,0 +1,2 @@
[Settings]
bFillBottleDelay = 1

View File

@ -1,13 +1,16 @@
if GetNVSEVersionFull < 6.2 if GetNVSEVersionFull < 6.25
MessageBoxEx "Bottle Rinse Repeat requires xNVSE 6.20+." MessageBoxEx "Bottle Rinse Repeat requires xNVSE 6.25+."
return
endif endif
if GetPluginVersion "JohnnyGuitarNVSE" < 325 if GetPluginVersion "JohnnyGuitarNVSE" < 325
MessageBoxEx "Bottle Rinse Repeat requires JohnnyGuitar NVSE 3.25+." MessageBoxEx "Bottle Rinse Repeat requires JohnnyGuitar NVSE 3.25+."
return
endif endif
if GetPluginVersion "JIP LN NVSE" < 55.70 if GetPluginVersion "JIP LN NVSE" < 55.70
MessageBoxEx "Bottle Rinse Repeat requires JIP LN 55.70+." MessageBoxEx "Bottle Rinse Repeat requires JIP LN 55.70+."
return
endif endif
call EBxBootstrap CallAfterSeconds 0.8 EBxBootstrap 1

View File

@ -0,0 +1,42 @@
scn EBxActivateWaterSource
ref rSource
string_var sPrompt
begin function {}
SetGameMainLoopCallback EBxOnCrosshairTracker 0
SetOnControlDownEventHandler EBxOnControlDown 0 5
;SetOnControlUpEventHandler EBxOnControlUp 0 5
;EnableControl 5
let rSource := GetCrosshairRef
if GetCrosshairWater
let sPrompt := playerRef.AuxiliaryVariableGetString "*sDrinkPrompt"
elseif eval IsFormValid rSource && (sPrompt := rSource.GetActivatorPrompt) == ""
let sPrompt := playerRef.AuxiliaryVariableGetString "*sActivatePrompt"
endif
if GetUIFloat "HUDMainMenu\_DUIF3" > 0 ; DarnUI
SetUIStringAlt "HUDMainMenu/InfoWrap/Info/justify_center_hotrect/string" $sPrompt
else
SetUIStringAlt "HUDMainMenu/Info/justify_center_hotrect/string" $sPrompt
endif
sv_destruct sPrompt
if IsFormValid rSource
MessageEx "filling bottles"
call EBxFillFromObject rSource
if rSource.HasScriptBlock 2
rSource.Activate playerRef 1
endif
endif
end

View File

@ -13,6 +13,22 @@ begin function {}
playerRef.AuxiliaryVariableSetString "*sDrinkPrompt" (GetStringSetting "sTargetTypeDrink") playerRef.AuxiliaryVariableSetString "*sDrinkPrompt" (GetStringSetting "sTargetTypeDrink")
playerRef.AuxiliaryVariableSetString "*sActivatePrompt" (GetStringSetting "sTargetTypeActivate") playerRef.AuxiliaryVariableSetString "*sActivatePrompt" (GetStringSetting "sTargetTypeActivate")
; Fix bottle names in English version
if eval $ScotchBottle01Empty01 == "Large Whiskey Bottle"
SetName "Empty Scotch Bottle" ScotchBottle01Empty01
endif
if eval $Milkbottle01 == "Milk Bottle"
SetName "Empty Milk Bottle" Milkbottle01
endif
; INI settings
if FileExists "config\Bottle Rinse Repeat.ini"
set EBxFillBottleDelay to GetINIFloat "Settings:bFillBottleDelay" "Bottle Rinse Repeat.ini"
endif
; Add new items to form lists ; Add new items to form lists
ListAddForm NonAlchoholicDrinks EBxBrahminMilk ListAddForm NonAlchoholicDrinks EBxBrahminMilk
@ -30,16 +46,6 @@ begin function {}
ListAddForm EBxUpgradableToPuraList IrradiatedWaterUnpurified ListAddForm EBxUpgradableToPuraList IrradiatedWaterUnpurified
ListAddForm EBxUpgradableToPurifiedList IrradiatedWaterUnpurified ListAddForm EBxUpgradableToPurifiedList IrradiatedWaterUnpurified
; Fix bottle names in English version
if eval $ScotchBottle01Empty01 == "Large Whiskey Bottle"
SetName "Empty Scotch Bottle" ScotchBottle01Empty01
endif
if eval $Milkbottle01 == "Milk Bottle"
SetName "Empty Milk Bottle" Milkbottle01
endif
; PipBoy icons ; PipBoy icons
SetTexturePath "interface\icons\pipboyimages\items\items_whiskey.dds" WhiskeyBottle01Empty01 SetTexturePath "interface\icons\pipboyimages\items\items_whiskey.dds" WhiskeyBottle01Empty01
@ -111,9 +117,7 @@ begin function {}
if EBxTTW == 0 if EBxTTW == 0
let i := 0 let i := 0
while rItem := ListGetNthForm EBxListNonAlchoholicDrinks i while rItem := ListGetNthForm EBxListNonAlchoholicDrinks i
if ListGetFormIndex NonAlchoholicDrinks rItem == -1 ListAddForm NonAlchoholicDrinks rItem -2 1
ListAddForm NonAlchoholicDrinks rItem
endif
let i += 1 let i += 1
loop loop
endif endif
@ -128,9 +132,7 @@ begin function {}
let i -= 1 let i -= 1
let rItem := ListGetNthForm rList i let rItem := ListGetNthForm rList i
if GetEquipType rItem == 13 if GetEquipType rItem == 13
if ListGetFormIndex AlchoholicDrinks rItem == -1 ListAddForm AlchoholicDrinks rItem -2 1
ListAddForm AlchoholicDrinks rItem
endif
endif endif
loop loop

10
src/EBxOnControlDown.gek Normal file
View File

@ -0,0 +1,10 @@
scn EBxOnControlDown
int iControl
begin function { iControl }
; start countdown
playerRef.AuxiliaryVariableErase "*timer"
end

View File

@ -6,33 +6,23 @@ string_var sPrompt
begin function { iControl } begin function { iControl }
SetGameMainLoopCallback EBxOnCrosshairTracker 0 if eval EBxFillBottleDelay > 0 && playerRef.AuxiliaryVariableGetFloat "*timer" < EBxFillBottleDelay
MessageEx "Normal activation"
SetOnControlUpEventHandler EBxOnControlUp 0 5
EnableControl 5
let rSource := GetCrosshairRef let rSource := GetCrosshairRef
call EBxFillFromObject rSource
if GetCrosshairWater
let sPrompt := playerRef.AuxiliaryVariableGetString "*sDrinkPrompt"
elseif eval (sPrompt := rSource.GetActivatorPrompt) == ""
let sPrompt := playerRef.AuxiliaryVariableGetString "*sActivatePrompt"
endif
if GetUIFloat "HUDMainMenu\_DUIF3" > 0 ; DarnUI
SetUIStringAlt "HUDMainMenu/InfoWrap/Info/justify_center_hotrect/string" $sPrompt
else
SetUIStringAlt "HUDMainMenu/Info/justify_center_hotrect/string" $sPrompt
endif
sv_destruct sPrompt
if IsFormValid rSource if IsFormValid rSource
if rSource.HasScriptBlock 2
rSource.Activate playerRef 1 rSource.Activate playerRef 1
endif endif
playerRef.AuxiliaryVariableErase "*timer"
return
endif endif
if EBxFillBottleDelay <= 0
call EBxActivateWaterSource
endif
playerRef.AuxiliaryVariableErase "*timer"
EnableControl 5
SetOnControlUpEventHandler EBxOnControlUp 0 5
end end

View File

@ -4,6 +4,9 @@ ref rSource
ref rDrink ref rDrink
int iCount int iCount
array_var aDrinksToUpgrade array_var aDrinksToUpgrade
string_var sOrigPrompt
string_var sPrompt
string_var sBottles
begin function { rSource } begin function { rSource }
@ -11,7 +14,7 @@ begin function { rSource }
return return
endif endif
if GetType rSource != 21 ; activator if rSource.GetType != 21 ; activator
if GetCrosshairWater == 0 if GetCrosshairWater == 0
return return
endif endif
@ -31,47 +34,36 @@ begin function { rSource }
let aDrinksToUpgrade := ar_null let aDrinksToUpgrade := ar_null
if iCount > 0 if iCount > 0
let sBottles := sv_construct "%g bottle%{s%}" iCount (iCount > 1)
if GetCrosshairWater
if iCount > 1
SetStringSetting "sTargetTypeDrink" ("Fill " + $iCount + " bottles with " + $rDrink)
else
SetStringSetting "sTargetTypeDrink" ("Fill " + $iCount + " bottle with " + $rDrink)
endif
elseif eval rSource.GetActivatorPrompt != ""
playerRef.AuxiliaryVariableSetString "*ap" (rSource.GetActivatorPrompt)
if iCount > 1
rSource.SetActivatorPrompt ("Fill " + $iCount + " bottles with " + $rDrink)
else
rSource.SetActivatorPrompt ("Fill " + $iCount + " bottle with " + $rDrink)
endif
else
if iCount > 1
SetStringSetting "sTargetTypeActivate" ("Fill " + $iCount + " bottles with " + $rDrink)
else
SetStringSetting "sTargetTypeActivate" ("Fill " + $iCount + " bottle with " + $rDrink)
endif
endif
elseif eval EBxCanteenSipsMax > 0 && call EBxReplenishCanteen rDrink 1 elseif eval EBxCanteenSipsMax > 0 && call EBxReplenishCanteen rDrink 1
let sBottles := "canteen"
if GetCrosshairWater
SetStringSetting "sTargetTypeDrink" ("Fill canteen with " + $rDrink)
elseif eval rSource.GetActivatorPrompt != ""
playerRef.AuxiliaryVariableSetString "*ap" (rSource.GetActivatorPrompt)
rSource.SetActivatorPrompt ("Fill canteen with " + $rDrink)
else
SetStringSetting "sTargetTypeActivate" ("Fill canteen with " + $rDrink)
endif
else else
return return
endif endif
DisableControl 5 if GetCrosshairWater
SetOnControlUpEventHandler EBxOnControlUp 1 5 let sPrompt := sv_construct "%{Drink or hold to fill%}%{Fill%} %z with %n" (EBxFillBottleDelay > 0) (EBxFillBottleDelay <= 0) sBottles rDrink
SetStringSetting "sTargetTypeDrink" $sPrompt
CallAfterSeconds 0 ({} => SetStringSetting "sTargetTypeDrink" (playerRef.AuxiliaryVariableGetString "*sDrinkPrompt"))
elseif eval rSource.GetActivatorPrompt != ""
let sOrigPrompt := rSource.GetActivatorPrompt
if EBxFillBottleDelay > 0
let sPrompt := $(rSource.GetActivatorPrompt) + " or hold to fill"
else
let sPrompt := "Fill"
endif
let sPrompt := sv_construct "%z %z with %n" sPrompt sBottles rDrink
rSource.SetActivatorPrompt $sPrompt
CallAfterSeconds 0 ({} => rSource.SetActivatorPrompt $sOrigPrompt)
else
let sPrompt := sv_construct "%{Activate or hold to fill%}%{Fill%} %z with %n" (EBxFillBottleDelay > 0) (EBxFillBottleDelay <= 0) sBottles rDrink
SetStringSetting "sTargetTypeActivate" $sPrompt
CallAfterSeconds 0 ({} => SetStringSetting "sTargetTypeActivate" (playerRef.AuxiliaryVariableGetString "*sActivatePrompt"))
endif
CallAfterSeconds 0 EBxOnCrosshairAfter DisableControl 5
SetOnControlDownEventHandler EBxOnControlDown 1 5
SetOnControlUpEventHandler EBxOnControlUp 1 5
SetGameMainLoopCallback EBxOnCrosshairTracker 1 1 11 SetGameMainLoopCallback EBxOnCrosshairTracker 1 1 11

View File

@ -6,12 +6,22 @@ begin function {}
if MenuMode == 0 if MenuMode == 0
if eval EBxFillBottleDelay > 0 && IsControlDisabled 5 && IsKeyPressed (GetControl 5) 2
if playerRef.AuxiliaryVariableGetFloat "*timer" < EBxFillBottleDelay
playerRef.AuxiliaryVariableSetFloat "*timer" (playerRef.AuxiliaryVariableGetFloat "*timer" + GetSecondsPassed)
else
MessageEx "activating source"
call EBxActivateWaterSource
return
endif
endif
if GetCrosshairWater if GetCrosshairWater
return return
endif endif
if eval rSource := GetCrosshairRef if eval rSource := GetCrosshairRef
if GetType rSource == 21 ; activator if rSource.GetType == 21 ; activator
if rSource.GetActivatorWaterType if rSource.GetActivatorWaterType
return return
endif endif
@ -22,6 +32,7 @@ begin function {}
SetGameMainLoopCallback EBxOnCrosshairTracker 0 SetGameMainLoopCallback EBxOnCrosshairTracker 0
SetOnControlDownEventHandler EBxOnControlDown 0 5
SetOnControlUpEventHandler EBxOnControlUp 0 5 SetOnControlUpEventHandler EBxOnControlUp 0 5
EnableControl 5 EnableControl 5