diff --git a/Bottle Rinse Repeat.esp b/Bottle Rinse Repeat.esp index 5a45110..d868622 100644 Binary files a/Bottle Rinse Repeat.esp and b/Bottle Rinse Repeat.esp differ diff --git a/config/Bottle Rinse Repeat.ini b/config/Bottle Rinse Repeat.ini new file mode 100644 index 0000000..9006f18 --- /dev/null +++ b/config/Bottle Rinse Repeat.ini @@ -0,0 +1,2 @@ +[Settings] +bFillBottleDelay = 1 diff --git a/nvse/plugins/scripts/gr_bottle_rinse_repeat.txt b/nvse/plugins/scripts/gr_bottle_rinse_repeat.txt index 82f7fb3..3743dee 100644 --- a/nvse/plugins/scripts/gr_bottle_rinse_repeat.txt +++ b/nvse/plugins/scripts/gr_bottle_rinse_repeat.txt @@ -1,13 +1,16 @@ -if GetNVSEVersionFull < 6.2 - MessageBoxEx "Bottle Rinse Repeat requires xNVSE 6.20+." +if GetNVSEVersionFull < 6.25 + MessageBoxEx "Bottle Rinse Repeat requires xNVSE 6.25+." + return endif if GetPluginVersion "JohnnyGuitarNVSE" < 325 MessageBoxEx "Bottle Rinse Repeat requires JohnnyGuitar NVSE 3.25+." + return endif if GetPluginVersion "JIP LN NVSE" < 55.70 MessageBoxEx "Bottle Rinse Repeat requires JIP LN 55.70+." + return endif -call EBxBootstrap +CallAfterSeconds 0.8 EBxBootstrap 1 diff --git a/src/EBxActivateWaterSource.gek b/src/EBxActivateWaterSource.gek new file mode 100644 index 0000000..0e1e481 --- /dev/null +++ b/src/EBxActivateWaterSource.gek @@ -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 \ No newline at end of file diff --git a/src/EBxBootstrap.gek b/src/EBxBootstrap.gek index 7b030a3..251e2f8 100644 --- a/src/EBxBootstrap.gek +++ b/src/EBxBootstrap.gek @@ -13,6 +13,22 @@ begin function {} playerRef.AuxiliaryVariableSetString "*sDrinkPrompt" (GetStringSetting "sTargetTypeDrink") 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 ListAddForm NonAlchoholicDrinks EBxBrahminMilk @@ -30,16 +46,6 @@ begin function {} ListAddForm EBxUpgradableToPuraList 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 SetTexturePath "interface\icons\pipboyimages\items\items_whiskey.dds" WhiskeyBottle01Empty01 @@ -111,9 +117,7 @@ begin function {} if EBxTTW == 0 let i := 0 while rItem := ListGetNthForm EBxListNonAlchoholicDrinks i - if ListGetFormIndex NonAlchoholicDrinks rItem == -1 - ListAddForm NonAlchoholicDrinks rItem - endif + ListAddForm NonAlchoholicDrinks rItem -2 1 let i += 1 loop endif @@ -128,9 +132,7 @@ begin function {} let i -= 1 let rItem := ListGetNthForm rList i if GetEquipType rItem == 13 - if ListGetFormIndex AlchoholicDrinks rItem == -1 - ListAddForm AlchoholicDrinks rItem - endif + ListAddForm AlchoholicDrinks rItem -2 1 endif loop diff --git a/src/EBxOnControlDown.gek b/src/EBxOnControlDown.gek new file mode 100644 index 0000000..72a8c87 --- /dev/null +++ b/src/EBxOnControlDown.gek @@ -0,0 +1,10 @@ +scn EBxOnControlDown + +int iControl + +begin function { iControl } + + ; start countdown + playerRef.AuxiliaryVariableErase "*timer" + +end diff --git a/src/EBxOnControlUp.gek b/src/EBxOnControlUp.gek index 18ca754..61f655f 100644 --- a/src/EBxOnControlUp.gek +++ b/src/EBxOnControlUp.gek @@ -6,33 +6,23 @@ string_var sPrompt begin function { iControl } - SetGameMainLoopCallback EBxOnCrosshairTracker 0 - - SetOnControlUpEventHandler EBxOnControlUp 0 5 - EnableControl 5 - - let rSource := GetCrosshairRef - - call EBxFillFromObject rSource - - if GetCrosshairWater - let sPrompt := playerRef.AuxiliaryVariableGetString "*sDrinkPrompt" - elseif eval (sPrompt := rSource.GetActivatorPrompt) == "" - let sPrompt := playerRef.AuxiliaryVariableGetString "*sActivatePrompt" + if eval EBxFillBottleDelay > 0 && playerRef.AuxiliaryVariableGetFloat "*timer" < EBxFillBottleDelay + MessageEx "Normal activation" + let rSource := GetCrosshairRef + if IsFormValid rSource + rSource.Activate playerRef 1 + endif + playerRef.AuxiliaryVariableErase "*timer" + return 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 + if EBxFillBottleDelay <= 0 + call EBxActivateWaterSource endif - sv_destruct sPrompt + playerRef.AuxiliaryVariableErase "*timer" - if IsFormValid rSource - if rSource.HasScriptBlock 2 - rSource.Activate playerRef 1 - endif - endif + EnableControl 5 + SetOnControlUpEventHandler EBxOnControlUp 0 5 end diff --git a/src/EBxOnCrosshair.gek b/src/EBxOnCrosshair.gek index 924fdb3..187c817 100644 --- a/src/EBxOnCrosshair.gek +++ b/src/EBxOnCrosshair.gek @@ -4,6 +4,9 @@ ref rSource ref rDrink int iCount array_var aDrinksToUpgrade +string_var sOrigPrompt +string_var sPrompt +string_var sBottles begin function { rSource } @@ -11,7 +14,7 @@ begin function { rSource } return endif - if GetType rSource != 21 ; activator + if rSource.GetType != 21 ; activator if GetCrosshairWater == 0 return endif @@ -31,48 +34,37 @@ begin function { rSource } let aDrinksToUpgrade := ar_null if iCount > 0 - - 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 - + let sBottles := sv_construct "%g bottle%{s%}" iCount (iCount > 1) elseif eval EBxCanteenSipsMax > 0 && call EBxReplenishCanteen rDrink 1 + let sBottles := "canteen" + else + return + endif - if GetCrosshairWater - SetStringSetting "sTargetTypeDrink" ("Fill canteen with " + $rDrink) - elseif eval rSource.GetActivatorPrompt != "" - playerRef.AuxiliaryVariableSetString "*ap" (rSource.GetActivatorPrompt) - rSource.SetActivatorPrompt ("Fill canteen with " + $rDrink) + if GetCrosshairWater + 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 - SetStringSetting "sTargetTypeActivate" ("Fill canteen with " + $rDrink) + let sPrompt := "Fill" endif - + let sPrompt := sv_construct "%z %z with %n" sPrompt sBottles rDrink + rSource.SetActivatorPrompt $sPrompt + CallAfterSeconds 0 ({} => rSource.SetActivatorPrompt $sOrigPrompt) else - return + 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 DisableControl 5 + SetOnControlDownEventHandler EBxOnControlDown 1 5 SetOnControlUpEventHandler EBxOnControlUp 1 5 - CallAfterSeconds 0 EBxOnCrosshairAfter - SetGameMainLoopCallback EBxOnCrosshairTracker 1 1 11 end diff --git a/src/EBxOnCrosshairTracker.gek b/src/EBxOnCrosshairTracker.gek index b90c6e2..f9bd960 100644 --- a/src/EBxOnCrosshairTracker.gek +++ b/src/EBxOnCrosshairTracker.gek @@ -6,12 +6,22 @@ begin function {} 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 return endif if eval rSource := GetCrosshairRef - if GetType rSource == 21 ; activator + if rSource.GetType == 21 ; activator if rSource.GetActivatorWaterType return endif @@ -22,6 +32,7 @@ begin function {} SetGameMainLoopCallback EBxOnCrosshairTracker 0 + SetOnControlDownEventHandler EBxOnControlDown 0 5 SetOnControlUpEventHandler EBxOnControlUp 0 5 EnableControl 5