Jump to content

Recommended Posts

Posted

I did this one, which I think is the best I can get:

Scriptname DetectionScript extends ObjectReference Const

Message Property OptionsMESG Auto Const Mandatory

Float Property ShowDist = 128.0 Auto Const

Function ShowMessageDist(Actor akActor)
	If GetDistance(akActor) < ShowDist
		RegisterForDistanceGreaterThanEvent(akActor, Self, ShowDist)
		OptionsMESG.Show()
	Else
		RegisterForDistanceLessThanEvent(akActor, Self, ShowDist)
	EndIf
EndFunction

Function ShowMessageLOS(Actor akActor)
	If akActor.HasDetectionLOS(Self)
		RegisterForDetectionLOSLost(akActor, Self)
		OptionsMESG.Show()
	Else
		RegisterForDetectionLOSGain(akActor, Self)
	EndIf
EndFunction

Event OnLoad()
	Actor Player = Game.GetPlayer()
	If Player.HasDetectionLOS(Self)
		RegisterForDetectionLOSLost(Player, Self)
		ShowMessageDist(Player)
	Else
		RegisterForDetectionLOSGain(Player, Self)
		If GetDistance(Player) < ShowDist
			RegisterForDistanceGreaterThanEvent(Player, Self, ShowDist)
		Else
			RegisterForDistanceLessThanEvent(Player, Self, ShowDist)
		EndIf
	EndIf
EndEvent

Event OnUnload()
	UnregisterForAllEvents()
EndEvent

Event OnGainLOS(ObjectReference akViewer, ObjectReference akTarget)
	UnregisterForAllEvents()
	RegisterForDetectionLOSLost(akViewer As Actor, akTarget)
	ShowMessageDist(akViewer As Actor)
EndEvent

Event OnLostLOS(ObjectReference akViewer, ObjectReference akTarget)
	UnregisterForAllEvents()
	RegisterForDetectionLOSGain(akViewer As Actor, akTarget)
EndEvent

Event OnDistanceLessThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
	UnregisterForAllEvents()
	RegisterForDistanceGreaterThanEvent(akObj1, akObj2, ShowDist)
	ShowMessageLOS(akObj1 As Actor)
EndEvent

Event OnDistanceGreaterThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
	UnregisterForAllEvents()
	RegisterForDistanceLessThanEvent(akObj1, akObj2, ShowDist)
EndEvent
Posted

Hey DieFeM mate - 100 points to grifindor if you can help solve another bug - The message keeps showing up as soon as the player exits power armor.

I've tried picking up the OnTutorialEvent event and setting a bool to true/false in the same way you did in that script, but i keep breaking the whole damn thing haha.

 

((obviously, absolutely no obligation to write the fragment for me or anything, just having a little fun haha, ill rack my brain and try solving the OnTutorialEvent problem a little later))

Posted

Try changing the OnLoad event to this:

Event OnLoad()
	Actor Player = Game.GetPlayer()
	If GetDistance(Player) < ShowDist
		RegisterForDistanceGreaterThanEvent(Player, Self, ShowDist)
	Else
		RegisterForDistanceLessThanEvent(Player, Self, ShowDist)
	EndIf
EndEvent
Posted (edited)

Waw, thankyou very much DieFeM! I'm pretty embarrassed to admit my brain must have fallen out of my ass because I wrote that 100 points to grifindor comment on the wrong thread hahaha ^.^ massive oops!

 

I meant to write that on my thread about the vault suit OMod menu ((https://forums.nexusmods.com/index.php?/topic/7387981-infinate-new-game-load-screen-vaultsuit-mod-help/&do=findComment&comment=67627781))

hahaha I'm very sorry mate! Haha ^.^

Edited by SandMouseAnarchy
Posted (edited)

Well... I've tested it a bit more and noticed that, in fact, it was showing the message when you get out of the power armor, so I've fixed it:

Scriptname DetectionScript extends ObjectReference Const

Message Property OptionsMESG Auto Const Mandatory

Float Property ShowDist = 128.0 Auto Const

Function ShowMessageDist(Actor akActor)
	If GetDistance(akActor) < ShowDist
		RegisterForDistanceGreaterThanEvent(akActor, Self, ShowDist)
		OptionsMESG.Show()
	Else
		RegisterForDistanceLessThanEvent(akActor, Self, ShowDist)
	EndIf
EndFunction

Function ShowMessageLOS(Actor akActor)
	If akActor.HasDetectionLOS(Self)
		RegisterForDetectionLOSLost(akActor, Self)
		OptionsMESG.Show()
	Else
		RegisterForDetectionLOSGain(akActor, Self)
	EndIf
EndFunction

Event OnLoad()
	Actor Player = Game.GetPlayer()
	If GetDistance(Player) < ShowDist
		RegisterForDistanceGreaterThanEvent(Player, Self, ShowDist)
	Else
		RegisterForDistanceLessThanEvent(Player, Self, ShowDist)
	EndIf
EndEvent

Event OnActivate(ObjectReference akActionRef)
	If(akActionRef == Game.GetPlayer())
		RegisterForRemoteEvent(Game.GetPlayer(), "OnSit")
	EndIf
EndEvent

Event Actor.OnSit(Actor akActor, ObjectReference akFurniture)
	If(akFurniture == Self)
		UnregisterForAllEvents()
		Utility.Wait(1)
		RegisterForRemoteEvent(akActor, "OnGetUp")
	EndIf
EndEvent

Event Actor.OnGetUp(Actor akActor, ObjectReference akFurniture)
	If(akFurniture == Self)
		UnregisterForRemoteEvent(akActor, "OnGetUp")
		RegisterForDistanceGreaterThanEvent(akActor, Self, ShowDist)
	EndIf
EndEvent

Event OnUnload()
	UnregisterForAllEvents()
EndEvent

Event OnGainLOS(ObjectReference akViewer, ObjectReference akTarget)
	UnregisterForAllEvents()
	RegisterForDetectionLOSLost(akViewer As Actor, akTarget)
	ShowMessageDist(akViewer As Actor)
EndEvent

Event OnLostLOS(ObjectReference akViewer, ObjectReference akTarget)
	UnregisterForAllEvents()
	RegisterForDetectionLOSGain(akViewer As Actor, akTarget)
EndEvent

Event OnDistanceLessThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
	UnregisterForAllEvents()
	RegisterForDistanceGreaterThanEvent(akObj1, akObj2, ShowDist)
	ShowMessageLOS(akObj1 As Actor)
EndEvent

Event OnDistanceGreaterThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
	UnregisterForAllEvents()
	RegisterForDistanceLessThanEvent(akObj1, akObj2, ShowDist)
EndEvent

Note that LOS and distance events must be registered again once they are triggered, but sit and get up events remain registered until you unregister them.

Edited by DieFeM
  • Recently Browsing   0 members

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