Jump to content

Help making npc's see/detect you when using a headlamp


vizex1

Recommended Posts

I don't know how hard it will be, but I really want to make some kind of mod that fixes the problem where using a headlamp doesn't affect stealth.

For example if you light up your pip boy enemies can see you more easily because the pipboy illuminates you. If you use a headlamp, the light does not hit you so npc's won't notice you even if your pointing your light directly at them. This effect persists even in directional flashlight mods.

 

I have a very little modding experience and no scripting experience. So I tried to find simple solutions, looking all over google, and the creation kit website.

I think the key is the player.getlightlevel value. It gets high when using pipboy light, but does not change when using headlamps. One idea I have is to have a secondary light(maybe a copy of defaultpipboylight) activate on the player at the same time the flashlight is turned on. That way your being illuminated while your headlamp is on. Then i just reduce the radius of the defaultpipboylightcopy to maybe 50 and fade to 10 so that it illuminates only you while your headlamp illuminates what's in front of you.

But first I need to figure out a way to detect when the pipboylight is on or off, or if it's even possible.

 

-----------------

I was trying to do this and to get the message "Turned on" and "Turned off" to appear. IsEnabled can't be use on the light property. I read that it's because it's a form and not an object reference. How do I reference forms? or use them in scripts? I'm trying to detect when that light is activated and when it is not.

 

 

Scriptname FLDETECT_Test9 extends Quest


int MyTimerInterval = 10 const
int MyTimerID = 1 const

Event OnInit()
StartTimer(MyTimerInterval, MyTimerID)
Debug.Notification("Script Initialized")
Debug.Trace("Script Initialized")
EndEvent

Event OnTimer(int aiTimerID)
If (aiTimerID == MyTimerID)
StartTimer(MyTimerInterval, MyTimerID)
If(defaultpipboylight.IsDisabled())
Debug.Notification("Turned off")
Debug.Trace("Turned off")
StartTimer(MyTimerInterval, MyTimerID)
Else
If(defaultpipboylight.IsEnabled())
Debug.Notification("Turned on")
Debug.Trace("Turned on")
StartTimer(MyTimerInterval, MyTimerID)
EndIf
Endif
Endif
EndEvent

Light Property defaultpipboylight Auto Const

-----------------

Can anyone help me with this?

Or even better does anyone have a solution of their own for illuminating the player when you turn on a headlamp(power armor or mining helmet)?

There is also another method of activating a perk instead of illuminating the player and adding the Mod Detection Light entry point. But i'd also need it to activate only when the flashlight is on.

Thanks if anyone is able to help.

Link to comment
Share on other sites

A cheap solution: Decrease the sneak skill while the lamp is on. (Through some script)

 

That's a good idea. I'm not sure how light and sound detection apply to the sneak perk, but maybe I'll mess around with it.

However, though I need to figure out how to detect when the pipboy light is on or off in the script.

 

Try using Animation events "pipboyLightOn", "pipboyLightOff" - RegisterForAnimationEvent() etc.

 

 

In this topic:

https://forums.nexusmods.com/index.php?/topic/5535332-detecting-when-player-is-using-flashlight-mission-impossible/?p=49274442

 

Someone was asking a similar thing to me and he made this code which uses those animation events. I also i tried it and got it to work, however, like he stated, the message only triggers when you go into your pipboy menu, it doesn't trigger when you turn your pipboy light on or off for some reason.

Scriptname LightTestThing extends ReferenceAlias

actor playerref

Event OnInit()
PlayerRef= Game.GetPlayer()
RegisterforAnimationEvent(playerref,"pipboyLightOn")
RegisterforAnimationEvent(playerref,"pipboyLightOff")
EndEvent


Event OnAnimationEvent(ObjectReference akSource, string asEventName)
	if(asEventName=="pipboyLightOn")
		Debug.Notification("Light on")
		Debug.Trace("Light on")
	elseIf(asEventName=="pipboyLightOff")
		Debug.Notification("Light off")
		Debug.Trace("Light off")
	endif
EndEvent

Any idea if there is a way to get this to work? My code was sort of based on this, but since this didn't work that's why I was trying the if(light.isdisabled()) code.

Edited by vizex1
Link to comment
Share on other sites

Aha... Tried to attach script directly to Pipboy, as suggested there? Actually, that always intrigued me as well, like the way to close PipBoy from inside a holotape, but i can't test custom scripts, maybe IsTorchOut condition? Funny, i still haven't tried, gonna check finally.

Link to comment
Share on other sites

How do I attach a script to the pipboy? I tried making a quest and an alias that references the object pipboy but when i try to save the quest i get "quest contains aliases with invalid dependencies." the warning says it uses a non-preceding UNKNOWN alias. The alias cannot be filled."

Link to comment
Share on other sites

Suppose, it must be on a base form for Pipboy - alias can't be initialized, while an object is inside container/inventory. (btw, you can't initialize an alias with a base object form, unless it's a "Create object" or Unique actor alias).

IsTorchOut doesn't seem to work, i have pipboy spotlight, but doubt it makes any difference. Strange enough still, there is IsPlayerRadioOn condition, but none for built-in light source.

 

Actually, there is nothing wrong with headlamp - when you direct a light beam into somebody's eyes in darkness, obviously, he can't see you, that's realistic : ))

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...