DieFeM Posted February 26, 2019 Share Posted February 26, 2019 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 Link to comment Share on other sites More sharing options...
SandMouseAnarchy Posted February 27, 2019 Author Share Posted February 27, 2019 DieFeM, you legend!! That latest script works really well! Far better than what i cobbled togeather haha! Thankyou again mate! Link to comment Share on other sites More sharing options...
SandMouseAnarchy Posted February 27, 2019 Author Share Posted February 27, 2019 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)) Link to comment Share on other sites More sharing options...
DieFeM Posted February 28, 2019 Share Posted February 28, 2019 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 Link to comment Share on other sites More sharing options...
SandMouseAnarchy Posted February 28, 2019 Author Share Posted February 28, 2019 (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 February 28, 2019 by SandMouseAnarchy Link to comment Share on other sites More sharing options...
DieFeM Posted February 28, 2019 Share Posted February 28, 2019 (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 February 28, 2019 by DieFeM Link to comment Share on other sites More sharing options...
SandMouseAnarchy Posted February 28, 2019 Author Share Posted February 28, 2019 DieFeM, that works great now mate! super sharp. thankyou again mate :) Link to comment Share on other sites More sharing options...
Recommended Posts