Jump to content

Detecting when player is using Flashlight, mission impossible?


vkz89q

Recommended Posts

So, I'm trying to detect when player has flashlight on. So far I have tried these things:

 

- Attach script to DefaultPipboyLight Light, Creation kit wiki says they should extend ObjectReference script. I can't get any event, not even oninit to fire from it. Testing on new game so that doesn't work or I'm doing something horribly wrong.

 

- Tried to give player simple perk with 100x damage just to see if I can get any condition to fire when light is on.. According to default object windown in ck, light equip slot is LeftHand, but I tried everything related to equip slot and none reacts to flashlight at all. Also tried everything related to torch and bibed slot etc.. nothing works.

 

- Also tried giving DefaultPipBoyLight keyword and check with conditions wornhaskeyword etc etc, on a new game but nothing works.

 

- I got one condition that kinda works. GetLightLevel. When pipboy flashlight is off, in dark areas lightlevel is like 10-20 and with pipboy light on it's always 75. BUT, this does NOT work for power armor helmet light or mining helm because the light does not hit player :sleep: Also, it can't detect if you are sitting in light turrets light or have pip boy light hitting you. It would be GOOD enough if it worked with other flashlights than pipboy too.

 

 

I thought this would be simple.. after all you get sound, hud icon and light when you turn that light on. Still I can't find a way to detect it. Any ideas where to look next, I'm running out of ideas? I tried to look F4SE functions too but didn't find anything helpful.

 

This is the script I tried on defaultpipboylight and it even compiles:

Scriptname defaultPipboyLightScripttest extends ObjectReference


Event OnActivate(ObjectReference akActionRef) 
	Debug.Notification("Light on1")
endEvent

Event OnEquipped(Actor akActor) 
	Debug.Notification("Light on2")
endEvent

Event OnOpen(ObjectReference akActionRef) 
	Debug.Notification("Light on3")
endEvent

Event OnClose(ObjectReference akActionRef) 
	Debug.Notification("Light on4")
EndEvent

Event OnGrab() 
	Debug.Notification("Light on5")
EndEvent

Event OnLockStateChanged() 
	Debug.Notification("Light on6")
endEvent

Event OnRelease() 
	Debug.Notification("Light on7")
EndEvent

Event OnUnequipped(Actor akActor) 
		Debug.Notification("Light on8")
EndEvent

Event OnInit()
	Debug.Notification("Light")
	RegisterForDetectionLOSGain(Game.GetPlayer(), self)
EndEvent

Event OnGainLOS(ObjectReference akViewer, ObjectReference akTarget)
	Debug.Notification("liiiiiiiiiight")
EndEvent
Edited by vkz89q
Link to comment
Share on other sites

Okay bud, you got a good one here. :)

 

There's got to be something in ObjectReference that fires on light activates. Looking through the OR event list.. have you tried OnLoad()? According to the wiki, it triggers when the object's "3D is loaded and ready". Since DefaultPipBoyLight is a Light object, that might be your trigger.

 

OnGrab, OnRelease, etc.. those would probably pertain to the Pipboy itself as an object, not the light. And OnOpen() wants a container.

Link to comment
Share on other sites

@vkz89q

that's some awesome ideas and code,

and thanks for sharing.

 

I think there's a few ways to achieve that.

If I had more context as the to envisaged use of such 'detect when player.pipboyLight.on"

then I can probably provide more useful brainstorming hehe.

 

 

 

if you are attempting

check status

is.PlayerPipboyLight.on?

for some AI overhaul or so,

it would be easier to make a get-that-PipboyLightStatus routine,

and check what state the pipboy button is at...

L for keyboard,

Circle or B for console etc.

for PC, you're tracking the light-button,

on console, you're detecting for a 1,5 second B or Circle press event.

 

that button command has a particular keyword, but it alludes me at the moment...

you'd store a table of that, holding the most recent 5 or arbitrary cutoff,

and the AGI would attack the most recent lightsource + soundsource etc.

or, randomly in the direction towards last-known-position.

 

we could populate a papyrus, json, xml, python etc array or

"table of fail" / "table of values"...

 

you'll probably also want a 'history buffer' -

where was the player light on -

playerLastPosition refID etc.

this will let you splinter cell/dishonored/thief towards LastKnownLocation.

 

If however, you're trying to make texture surfaces interact with Player Pipboy Light

(say, the Player Pipboy UV Blacklight, or Player Pipboy "Code-View Matrix Light/Alpha pre-vis anytime light")

that will be a little more tricky.

kudos though to those modders who have made those mods thus far;

enhanced view is EXCELLENT to be able to make everything transparent and see through it,

batman style.

 

that's a comparison of the viewing angle of PlayerEyeLocationRef,

to the texture itself... so, present PlayerCamera position relative to the Texture determines the Adam7 or layer-data on the viewing angle for the texture.

that's how they achieved some sweet effects in Halo and in Bethesda's Doom and in Portal etc.

that's an LoS from lightsource type deal -

is Object in LoS to lightsource AND lightsource on?

it can become very much an A* in A floatingpoint metapredicate problem...

 

the history of DOOM and DukeNukem "2D 3D" games is insightful.

they were sprites which changed relative to viewing angle.

Kojima's reflections on that recently are insightful - that's how Kojima approached the light/dark problem.

 

 

 

I hope there's something there of use,

and I look forward to seeing what other modders have to reflect on this,

particularly shavkacagarikia etc.

Link to comment
Share on other sites

Thanks for the ideas guys. The mod idea here is simple: Make sneaking during night VERY HARD when flashlight is on. It makes perfect sense, right?

 

F4SE actually has functions to detect keypresses.. but I can see one problem already. When you enter door to new area(loading screen), flashlight turns off and somehow would need to catch that too.

 

I tried to search if there is already mod that does what I want, but I can't find anything, which makes me wonder that it's not that easy to detect :confused:

 

If anyone knows the "secret" and doesn't want to share it, please, make a mod that makes sneaking with flashlight hard :smile:

 

I will keep trying things you guys suggested later today.

Link to comment
Share on other sites

why not just put in a hook to the animation event for light on / light off on the pipboy?

 

Okay, I tried:

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

It works... but not when light is turned off or on.. only when you close/open whole pipboy :pinch: (going to menu)

Link to comment
Share on other sites

Try this but extend the pipboy and not player - not sure if it will work but perhaps the animation event is played on the pipboy and not the player!

I am assuming that animation event exists!

 

 

Scriptname LightTestThing extends ObjectReference

Event OnInit()
RegisterforAnimationEvent(self,"pipboyLightOn")
RegisterforAnimationEvent(self,"pipboyLightOff")
EndEvent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)

if(asEventName=="pipboyLightOn" && akSource == Game.GetPlayer())
Debug.Notification("Light on")
Debug.Trace("Light on")

elseIf(asEventName=="pipboyLightOff" && akSource == Game.GetPlayer())

Debug.Notification("Light off")
Debug.Trace("Light off")
endif
EndEvent

Edited by gargorias
Link to comment
Share on other sites

  • Recently Browsing   0 members

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