Night Vision Script?

Post » Sun Nov 29, 2009 3:02 am

In my TUPAM FO3 mod Cipscis was kind enough to help me get a night vision script working. This script let me bind the N key to the night vision effect and if the player was wearing the helmets I listed in the script then the effect could be toggled on and off this way. Since I no longer have FO3 installed on my computer I cant check my mod for the script I used. I was wondering if someone could help me get a script like this working. Credit would be given in the mod description.
User avatar
Nick Tyler
 
Posts: 3437
Joined: Thu Aug 30, 2007 8:57 am

Post » Sun Nov 29, 2009 3:22 am

Ooh, that requires the IsKeyPressed function, and we don't have that yet because the NVSE isn't out. When we do have it, it might look something like this pseudo-code here

scn SomeQuestScriptfloat fQuestDelayTimeint bDoOnceint bTrapKeybegin gamemodeif bDoOnce == 0 set fQuestDelayTime to 0.1 set bTrapKey to 0 set bDoOnce to 1endifif player.getequipped SomeHelmet || player.getequipped ThisHelmet || player.getequipped ThatHelmet || player.getequipped YetAnotherHelmet if bTrapKey != 1 && iskeypressed   if player.isspelltarget NightVisionAbility != 1   player.addspell NightVisionAbility  else   player.removespell NightVisionAbility  endif elseif bTrapKey && iskeypressed  != 1  set bTrapKey to 0 endifelseif player.isspelltarget NightVisionAbility player.removespell NightVisionAbilityendifend

User avatar
alicia hillier
 
Posts: 3387
Joined: Tue Feb 06, 2007 2:57 am

Post » Sun Nov 29, 2009 3:17 pm

Here's FOOK's, HugePinball's brainchild:
Spoiler
scn FookNVGScript ; by HugePinball, Cipscis, JustinOtherInt bFullChargeInt bNVEquippedInt bTurningOnInt bIsNPressedInt bBeepedInt iSecInt bDoOnceFloat fChargeFloat fChargePercentBegin OnAdd Player	If bFookNVGEnabledGLOB	Else		Return	EndIf	If Player.GetItemCount FookNVGActivatorARMO		If bFookNVGActivatorGLOB		Else			Player.RemoveItem FookNVGActivatorARMO 1 1		EndIf	ElseIf (NVSE == 0) || bFookNVGActivatorGLOB		Set bFookNVGActivatorGLOB to 1		Player.AddItem F 1 1		Player.AddItem FookNVGActivatorARMO 1 1		Player.RemoveItem F 1 1	EndIfEnd;==============================================Begin OnEquip Player	If bFookNVGEnabledGLOB	Else		Return	EndIf	Set bFookNVGIsOnGLOB to 0	Set bNVEquipped to 1	If NVSE	Else		Set bFookNVGActivatorGLOB to 1		Set iFookNVGMeterTypeGLOB to 0	EndIf	If bFookNVGActivatorGLOB		If Player.GetItemCount FookNVGActivatorARMO		Else			Player.AddItem F 1 1			Player.AddItem FookNVGActivatorARMO 1 1			Player.RemoveItem F 1 1		EndIf	EndIf	If iFookNVGChargeDurationGLOB		Set fChargePercent to fCharge / (60 * iFookNVGChargeDurationGLOB) * 100		Set bFullCharge to 1		If bFookNVGMessagesGLOB			If bDoOnce				Return			Else				Set bDoOnce to 1				ShowMessage FookNVGChargeLevelMESG fChargePercent			EndIf		EndIf		If iFookNVGMeterTypeGLOB;			SetUIfloat "HUDMainMenu\_NVCharge" fChargePercent		Else;			SetUIfloat "HUDMainMenu\_NVCharge" -1		EndIf	EndIfEnd;=============================================Begin OnUnequip Player	If bFookNVGEnabledGLOB	Else		Return	EndIf	Set bFookNVGIsOnGLOB to 0	Set bNVEquipped to 0	Set bDoOnce to 0	If iFookNVGChargeDurationGLOB		If NVSE;			SetUIfloat "HUDMainMenu\_NVCharge" -1		EndIf	EndIf	If iFookNVGIMADSetGLOB		If IsImageSpaceActive FookNVGAmberIMAD			RIMOD FookNVGAmberIMAD			PlaySound UIPipBoyLightOff		ElseIf IsImageSpaceActive FookNVGAquaIMAD			RIMOD FookNVGAquaIMAD			PlaySound UIPipBoyLightOff		ElseIf IsImageSpaceActive FookNVGGreenIMAD			RIMOD FookNVGGreenIMAD			PlaySound UIPipBoyLightOff		ElseIf IsImageSpaceActive FookNVGRedIMAD			RIMOD FookNVGRedIMAD			PlaySound UIPipBoyLightOff		ElseIf IsImageSpaceActive FookNVGYellowIMAD			RIMOD FookNVGYellowIMAD			PlaySound UIPipBoyLightOff		EndIf	Else		If IsImageSpaceActive FookNVGAmber02IMAD			RIMOD FookNVGAmber02IMAD			PlaySound UIPipBoyLightOff		ElseIf IsImageSpaceActive FookNVGAqua02IMAD			RIMOD FookNVGAqua02IMAD			PlaySound UIPipBoyLightOff		ElseIf IsImageSpaceActive FookNVGGreen02IMAD			RIMOD FookNVGGreen02IMAD			PlaySound UIPipBoyLightOff		ElseIf IsImageSpaceActive FookNVGRed02IMAD			RIMOD FookNVGRed02IMAD			PlaySound UIPipBoyLightOff		ElseIf IsImageSpaceActive FookNVGYellow02IMAD			RIMOD FookNVGYellow02IMAD			PlaySound UIPipBoyLightOff		EndIf	EndIfEnd;=================================================Begin GameMode	If (bFookNVGEnabledGLOB == 0)		Return	ElseIf (bNVEquipped == 0)		Return	EndIf	If iFookNVGChargeDurationGLOB		Set fChargePercent to fCharge / (60 * iFookNVGChargeDurationGLOB)		If iFookNVGMeterTypeGLOB ; Meter			If bNVEquipped;				SetUIfloat "HUDMainMenu\_NVCharge" fChargePercent			Else;				SetUIfloat "HUDMainMenu\_NVCharge" -1			EndIf		EndIf		If bFookNVGWarningBeepsGLOB			If bNVEquipped				If bFookNVGIsOnGLOB					If bBeeped					ElseIf (fCharge > 0)						If (fCharge < 10)							PlaySound FookNVGChargeBeepSOUN							Set bBeeped to 1						EndIf					EndIf					If (fCharge < iSec)						Set bBeeped to 0						Set iSec to iSec - 1					EndIf				EndIf			EndIf		EndIf		If (fCharge > 0)			If bFookNVGIsOnGLOB				Set fCharge to (fCharge - GetSecondsPassed)			ElseIf fCharge < (60 * iFookNVGChargeDurationGLOB)				Set fCharge to fCharge + GetSecondsPassed * 2				If bFullCharge					Set bFullCharge to 0				EndIf			ElseIf (bFullCharge == 0)				Set bFullCharge to 1				If bFookNVGMessagesGLOB					ShowMessage FookNVGChargedMESG				EndIf			EndIf		ElseIf bFookNVGIsOnGLOB			Set bFookNVGIsOnGLOB to 0			If bFookNVGWarningBeepsGLOB				Set iSec to -1			EndIf			If bFookNVGMessagesGLOB				ShowMessage FookNVGDischargedMESG			EndIf			If bFookNVGActivatorGLOB				Player.UnequipItem FookNVGActivatorARMO 0 1			EndIf		Else ; Recharge			Set fCharge to fCharge + GetSecondsPassed * 2		EndIf ; Track NV charge	EndIf ; NV Charge Meter code	If bFookNVGActivatorGLOB		If Player.GetItemCount FookNVGActivatorARMO			If (Player.GetEquipped FookNVGActivatorARMO != bFookNVGIsOnGLOB)				Set bFookNVGIsOnGLOB to (bFookNVGIsOnGLOB == 0)				If bFookNVGWarningBeepsGLOB					Set bBeeped to bFookNVGIsOnGLOB					If iFookNVGChargeDurationGLOB						Set iSec to fCharge					EndIf				EndIf			EndIf		Else			Player.AddItem F 1 1			Player.AddItem FookNVGActivatorARMO 1 1			Player.RemoveItem F 1 1		EndIf	Else;		If (bIsNPressed != IsKeyPressed FookNVGHotkeyGLOB) ; 'N' key			Set bIsNPressed to (bIsNPressed == 0)			If bIsNPressed ; 'N' pressed				Set bFookNVGIsOnGLOB to (bFookNVGIsOnGLOB == 0)				If bFookNVGIsOnGLOB					If bFookNVGWarningBeepsGLOB						Set bBeeped to 1						If iFookNVGChargeDurationGLOB							Set iSec to fCharge						EndIf					EndIf				EndIf			EndIf;		EndIf	EndIf	If bFookNVGIsOnGLOB		Set bTurningOn to 0		If iFookNVGIMADSetGLOB			If Player.GetEquipped FookNVGGreenFLST				If IsImageSpaceActive FookNVGGreenIMAD				Else					IMOD FookNVGGreenIMAD					Set bTurningOn to 1				EndIf			ElseIf Player.GetEquipped FookNVGRedFLST				If IsImageSpaceActive FookNVGRedIMAD				Else					IMOD FookNVGRedIMAD					Set bTurningOn to 1				EndIf			ElseIf Player.GetEquipped FookNVGAmberFLST				If IsImageSpaceActive FookNVGAmberIMAD				Else					IMOD FookNVGAmberIMAD					Set bTurningOn to 1				EndIf			ElseIf Player.GetEquipped FookNVGYellowFLST				If IsImageSpaceActive FookNVGYellowIMAD				Else					IMOD FookNVGYellowIMAD					Set bTurningOn to 1				EndIf			ElseIf Player.GetEquipped FookNVGAquaFLST				If IsImageSpaceActive FookNVGAquaIMAD				Else					IMOD FookNVGAquaIMAD					Set bTurningOn to 1				EndIf			EndIf		Else			If Player.GetEquipped FookNVGGreenFLST				If IsImageSpaceActive FookNVGGreen02IMAD				Else					IMOD FookNVGGreen02IMAD					Set bTurningOn to 1				EndIf			ElseIf Player.GetEquipped FookNVGRedFLST				If IsImageSpaceActive FookNVGRed02IMAD				Else					IMOD FookNVGRed02IMAD					Set bTurningOn to 1				EndIf			ElseIf Player.GetEquipped FookNVGAmberFLST				If IsImageSpaceActive FookNVGAmber02IMAD				Else					IMOD FookNVGAmber02IMAD					Set bTurningOn to 1				EndIf			ElseIf Player.GetEquipped FookNVGYellowFLST				If IsImageSpaceActive FookNVGYellow02IMAD				Else					IMOD FookNVGYellow02IMAD					Set bTurningOn to 1				EndIf			ElseIf Player.GetEquipped FookNVGAquaFLST				If IsImageSpaceActive FookNVGAqua02IMAD				Else					IMOD FookNVGAqua02IMAD					Set bTurningOn to 1				EndIf			EndIf		EndIf		If bTurningOn			PlaySound FookNVGOnSOUN			If bFookNVGMessagesGLOB				Set fChargePercent to fCharge / (60 * iFookNVGChargeDurationGLOB) * 100				ShowMessage FookNVGChargeLevelMESG fChargePercent			EndIf		EndIf	Else		If iFookNVGIMADSetGLOB			If IsImageSpaceActive FookNVGAmberIMAD				RIMOD FookNVGAmberIMAD				PlaySound UIPipBoyLightOff			ElseIf IsImageSpaceActive FookNVGAquaIMAD				RIMOD FookNVGAquaIMAD				PlaySound UIPipBoyLightOff			ElseIf IsImageSpaceActive FookNVGGreenIMAD				RIMOD FookNVGGreenIMAD				PlaySound UIPipBoyLightOff			ElseIf IsImageSpaceActive FookNVGRedIMAD				RIMOD FookNVGRedIMAD				PlaySound UIPipBoyLightOff			ElseIf IsImageSpaceActive FookNVGYellowIMAD				RIMOD FookNVGYellowIMAD				PlaySound UIPipBoyLightOff			EndIf		Else			If IsImageSpaceActive FookNVGAmber02IMAD				RIMOD FookNVGAmber02IMAD				PlaySound UIPipBoyLightOff			ElseIf IsImageSpaceActive FookNVGAqua02IMAD				RIMOD FookNVGAqua02IMAD				PlaySound UIPipBoyLightOff			ElseIf IsImageSpaceActive FookNVGGreen02IMAD				RIMOD FookNVGGreen02IMAD				PlaySound UIPipBoyLightOff			ElseIf IsImageSpaceActive FookNVGRed02IMAD				RIMOD FookNVGRed02IMAD				PlaySound UIPipBoyLightOff			ElseIf IsImageSpaceActive FookNVGYellow02IMAD				RIMOD FookNVGYellow02IMAD				PlaySound UIPipBoyLightOff			EndIf		EndIf	EndIf	If NVSE;		If bFookNVGIsOnGLOB != GetUIfloat "HUDMainMenu\_NVOn";			SetUIfloat "HUDMainMenu\_NVOn" bFookNVGIsOnGLOB;		EndIf	EndIfEnd
...Parts of it might help. We're gonna have to arm wrestle or something over the 'N' key. I'd suggest making any hotkeys globals so they can be easily altered without script editing by users.

Nekhanimal: FO3 & FNV have http://geck.gamesas.com/index.php/SetQuestDelay, so the fQuestDelayTime is no longer needed.
User avatar
HARDHEAD
 
Posts: 3499
Joined: Sun Aug 19, 2007 5:49 am

Post » Sun Nov 29, 2009 3:17 pm

Yeah, I've always used N, the script Cipcsis helped me do originally did use the script extender so it didn't make my brain explode like the one you linkeed Justin. I might just have to go with replacing the pipboy light until later. Was hoping to be able to use both the pipboy and the night vision like in my original FO3 mod.
User avatar
Scott
 
Posts: 3385
Joined: Fri Nov 30, 2007 2:59 am

Post » Sun Nov 29, 2009 4:59 am

I'm looking for something similar, yet much more simple. I noticed that the unique weapon "Rat Slayer" (Name in the G.E.C.K. is "WeaponNVVarmintRifleUnique") has the feature "Has Night Vision" flagged in it's options. Unfortunately there is no script attached so it may be hardcoded.

The interesting part is how it works ingame: At daytime there is no nightvision (clear view through the scope). At night though you get night vision. Pretty cool!

My idea was to add a night vision effect to the NCR combat helmet (and maybe other helmets, too) via object effect + a time condition. Something like this:

Object Effect XYZ --> with Base Effect "CateyeBaseEffect" --> Condition....

And that's where I need help. I need a condition that either checks if it's between two specidifc times (like ">= 8.00pm" and "<= 6.00am") or that just checks whether its night or day. If that is possible.
User avatar
Jessica White
 
Posts: 3419
Joined: Sun Aug 20, 2006 5:03 am

Post » Sun Nov 29, 2009 10:56 am

Yeah, I've always used N, the script Cipcsis helped me do originally did use the script extender so it didn't make my brain explode like the one you linkeed Justin. I might just have to go with replacing the pipboy light until later. Was hoping to be able to use both the pipboy and the night vision like in my original FO3 mod.


Both of the above scripts depend on the script extender, Justin's just has a lot more functionality and stuff. The Beta of the script extender is out, so the script will theoretically work, but I'd wait until they release a stable version with making the mod public.
User avatar
Syaza Ramali
 
Posts: 3466
Joined: Wed Jan 24, 2007 10:46 am

Post » Sun Nov 29, 2009 6:00 pm

Both of the above scripts depend on the script extender, Justin's just has a lot more functionality and stuff. The Beta of the script extender is out, so the script will theoretically work, but I'd wait until they release a stable version with making the mod public.


Yeah.
User avatar
Becky Cox
 
Posts: 3389
Joined: Thu Jun 22, 2006 8:38 am

Post » Sun Nov 29, 2009 2:47 am

Hey Drag0ntamer, nice to see you around.

I couldn't find the script that I helped you with way back, so I wrote one from scratch that should have the same functionality. This script, when used as a quest script, should allow the player to toggle an imagespace modifier via the "N" key, so long as the player is wearing a helmet within a specified form list. If the player stops wearing such a helmet while the imagespace modifier is applied, it will be removed:
Spoiler
int bIsNPressedBegin GameMode	; Toggle night vision when the "N" key is pressed	if bIsNPressed != IsKeyPressed 49 ; N		set bIsNPressed to IsKeyPressed 49		if bIsNPressed			if IsImagespaceActive NightVision				RemoveImageSpaceModifier NightVision			else				ApplyImagespaceModifier NightVision			endif		endif	endif	; Remove night vision if the player stops wearing approved equipment	if IsImagespaceActive NightVision		if player.GetEquipped NightVisionHelmetFormList		else			RemoveImagespaceModifier NightVision		endif	endifEnd

The FOOK script that JustinOther posted has similar functionality, but FOOK has a lot of extra stuff like different coloured imagespace modifiers, and a significant portion of the script is dedicated to the "charge" functionality.

Cipscis
User avatar
Chase McAbee
 
Posts: 3315
Joined: Sat Sep 08, 2007 5:59 am

Post » Sun Nov 29, 2009 4:50 pm

Hey Drag0ntamer, nice to see you around.

I couldn't find the script that I helped you with way back, so I wrote one from scratch that should have the same functionality. This script, when used as a quest script, should allow the player to toggle an imagespace modifier via the "N" key, so long as the player is wearing a helmet within a specified form list. If the player stops wearing such a helmet while the imagespace modifier is applied, it will be removed:
Spoiler
int bIsNPressedBegin GameMode	; Toggle night vision when the "N" key is pressed	if bIsNPressed != IsKeyPressed 49 ; N		set bIsNPressed to IsKeyPressed 49		if bIsNPressed			if IsImagespaceActive NightVision				RemoveImageSpaceModifier NightVision			else				ApplyImagespaceModifier NightVision			endif		endif	endif	; Remove night vision if the player stops wearing approved equipment	if IsImagespaceActive NightVision		if player.GetEquipped NightVisionHelmetFormList		else			RemoveImagespaceModifier NightVision		endif	endifEnd

The FOOK script that JustinOther posted has similar functionality, but FOOK has a lot of extra stuff like different coloured imagespace modifiers, and a significant portion of the script is dedicated to the "charge" functionality.

Cipscis


Awesome, thanks Cipcis! Glad to see you around as well. Does this require NVSE? I tried to catch you on MSN a few tims, guess the timezone difference makes that much harder then I remembered lol.
User avatar
Stay-C
 
Posts: 3514
Joined: Sun Jul 16, 2006 2:04 am

Post » Sun Nov 29, 2009 3:21 am

Yeah, NVSE is required in order to detect the keypress via http://fose.silverlock.org/fose_command_doc.html#IsKeyPressed.

Uni's been keeping me busy lately, but that's over now and I bought New Vegas last night, so you can expect to see me around more often for a while now.

Cipscis
User avatar
Tom
 
Posts: 3463
Joined: Sun Aug 05, 2007 7:39 pm

Post » Sun Nov 29, 2009 1:58 pm

Yeah, NVSE is required in order to detect the keypress via http://fose.silverlock.org/fose_command_doc.html#IsKeyPressed.

Uni's been keeping me busy lately, but that's over now and I bought New Vegas last night, so you can expect to see me around more often for a while now.

Cipscis


Nice, I will try and get this working.
User avatar
Louise Lowe
 
Posts: 3262
Joined: Fri Jul 28, 2006 9:08 am

Post » Sun Nov 29, 2009 8:31 am

How do I get the G.E.C.K to work with NVSE?

EDIT: I tried the method listed in the NVSE readme but it says the path or file name is incorrect...

"Alternately you can create a shortcut to nvse_loader.exe, open the properties window and add "-editor" to the Target field."
User avatar
Taylor Tifany
 
Posts: 3555
Joined: Sun Jun 25, 2006 7:22 am

Post » Sun Nov 29, 2009 5:14 am

Make a shortcut to NVSE_Loader.exe, then add the http://i196.photobucket.com/albums/aa150/JustinCoherent/Fallout%203/Parameter.png after the target in the shortcut's properties.

Edit: Don't forget the space after the target.
User avatar
Eric Hayes
 
Posts: 3392
Joined: Mon Oct 29, 2007 1:57 am

Post » Sun Nov 29, 2009 2:03 pm

Make a shortcut to NVSE_Loader.exe, then add the http://i196.photobucket.com/albums/aa150/JustinCoherent/Fallout%203/Parameter.png after the target in the shortcut's properties.

Edit: Don't forget the space after the target.


LOL. I was doing it wrong. The screenshot helped. Thanks! I feel so stupid right now... >.<
User avatar
Jennifer Rose
 
Posts: 3432
Joined: Wed Jan 17, 2007 2:54 pm

Post » Sun Nov 29, 2009 3:10 am

Here is the script I came up with...

scn TUPAMNightVisionint bIsNPressedBegin GameMode	; Toggle night vision when the "N" key is pressed	if bIsNPressed != IsKeyPressed 49 ; N		set bIsNPressed to IsKeyPressed 49		if bIsNPressed			if IsImagespaceActive DTNightVision1				RemoveImageSpaceModifier DTNightVision1				RemoveImageSpaceModifier DTNightVision2				PlaySound UIPipBoyLightOff			else				ApplyImagespaceModifier DTNightVision1				ApplyImagespaceModifier DTNightVision2 				PlaySound UIPipBoyLightOff			endif		endif	endif	; Remove night vision if the player stops wearing approved equipment	if IsImagespaceActive DTNightVision15		if player.GetEquipped NightVisionHelmetFormList		else			RemoveImagespaceModifier DTNightVision1               RemoveImagespaceModifier DTNightVision2			PlaySound UIPipBoyLightOff		endif	endifEnd

However it does not work for some reaosn. Everything looks correct as far as I can tell but the script never runs.
User avatar
Nikki Lawrence
 
Posts: 3317
Joined: Sat Jul 01, 2006 2:27 am

Post » Sun Nov 29, 2009 3:49 pm

What type of script is it? If you're using a quest script, as I expect you are, make sure the script processing delay is fairly low (somewhere around 0.1 seconds should be good) so that it can accurately detect keypresses. By default, quest scripts are only processed every 5 seconds, so you'd have to hold the "N" key for up to 5 seconds in order for it to register.

Maybe try adding some http://fose.silverlock.org/fose_command_doc.html#PrintToConsole lines in there to see sections of the code are running.

Cipscis
User avatar
WTW
 
Posts: 3313
Joined: Wed May 30, 2007 7:48 pm

Post » Sun Nov 29, 2009 3:33 am

What type of script is it? If you're using a quest script, as I expect you are, make sure the script processing delay is fairly low (somewhere around 0.1 seconds should be good) so that it can accurately detect keypresses. By default, quest scripts are only processed every 5 seconds, so you'd have to hold the "N" key for up to 5 seconds in order for it to register.

Maybe try adding some http://fose.silverlock.org/fose_command_doc.html#PrintToConsole lines in there to see sections of the code are running.

Cipscis


I am using a quest script. I think I am missing a part though. Can you get on MSN so it'd be easier to communicate? I thought you had to make an actual quest for the script to run off of but I cannot locate where quests are in the G.E.C.K to make one.

EDIT: Aparently quest is under Actor Data. Gonna mess with those and see if I can remember how to do it.
User avatar
Rachael
 
Posts: 3412
Joined: Sat Feb 17, 2007 2:10 pm

Post » Sun Nov 29, 2009 9:38 am

Got it working thanks!
User avatar
DarkGypsy
 
Posts: 3309
Joined: Tue Jan 23, 2007 11:32 am


Return to Fallout: New Vegas