bottle-rinse-repeat/src/EBxOnCrosshair.gek
2022-07-23 17:38:20 +02:00

79 lines
2.1 KiB
Plaintext

scn EBxOnCrosshair
ref rSource
ref rDrink
int iCount
array_var aDrinksToUpgrade
begin function { rSource }
if rSource == 0 ; IsFormValid returns 0 on form 35
return
endif
if GetType rSource != 21 ; activator
if GetCrosshairWater == 0
return
endif
elseif rSource.GetActivatorWaterType == 0
return
endif
let aDrinksToUpgrade := call EBxGetDrinksToUpgrade rSource
if eval 0 >= ar_size aDrinksToUpgrade
let aDrinksToUpgrade := ar_null
return
endif
let rDrink := aDrinksToUpgrade[0]
let iCount := GetMinOf (playerRef.GetItemCount caps001) (playerRef.GetItemCount (aDrinksToUpgrade[1]))
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
elseif eval EBxCanteenSipsMax > 0 && call EBxReplenishCanteen rDrink 1
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
return
endif
DisableControl 5
SetOnControlUpEventHandler EBxOnControlUp 1 5
CallAfterSeconds 0 EBxOnCrosshairAfter
SetGameMainLoopCallback EBxOnCrosshairTracker 1 1 11
end