Jump to content

Tutorial message when player is close to PowerArmor?


Recommended Posts

Hi everyone - today im trying to get a tutorial message to appear whenever the player gets close to a power armor (furnaiure object)

 

I already have the message set up and ready to go but im not sure where to place the script or on what event to make the game check the distance between power armor and player.

for example - if i put the "GetDistance" function inside "Event OnActivate" it will only apear after ive pressed activate, and if i put the "GetDistance" function inside "Event OnLoad" then the message fires as soon as the power armor is loaded. But non of that is veryusefull here. I need the message to appear whenever the player is <60 units from the power armor.

 

Would i handle this with "GetDistance()"?

((i think so, because i dont know how to attach a trigger volume to the power armor furniture where i could have used "OnTriggerEnter", i bet triggers can't be added to furniture objects and i have no idea how to create a trigger volume via script if such a thing is even possible.))

 

And would i attach this script to a quest or to the power armor furniture?

((i have a feeling that a quest script is needed here to be constantly checking if the player is close to the power armor))

 

Any advice on this one would be appreciated a lot!

Link to comment
Share on other sites

This is horrible dynamic script overhead so you gotta decide if the feature is worth the cost, but a functional outline :

 

0 Start game enabled quest with attached script

1 Create an Xmarker at the player (Quest alias create ref to object is fastest)

2 Register for OnDistanceGreaterThan at double your message range or minimum one cell 4096 units

3 Fire FindAllReferencesWithKeyword(pFurnitureTypePowerArmor, Your message range)

4 If found, pop a message, stop quest .

5 If not move Xmaker to player and Loop to 2

 

Trick is to tune the movement and scan ranges so its not constant. There are some mods that try and do this constantly in player grabbing range = ouch.

Link to comment
Share on other sites

Thankyou SKK50 :)

Ah I didn't realise I would have to put an Xmarker at the player ^.^

 

And Yeh I was afraid of the overhead, I really don't want the script to be constantly firing in the background all the time. it seems really wasteful.

 

I tried using the Gotlineofsight function but I think that will be just as bad.

 

Do you know of anyway to create a trigger at the power armor each time the power armor is moved?

(I guess I'll make another post specifically about triggers later if I can't figure it out from here ^.^)

(maybe a trigger can be attached to an invisible object that can be spawned in with the power armor?)

Link to comment
Share on other sites

Ahhhh, that sounds interesting!

 

Without getting too complicated - I don't think I have a reference. I have a power armor in a cell for testing, but I had planned on making the custom power armor spawn in and replace a vanilla power armor that the player has in the power armor workbench. So, I guess, until the player "creates" the power armor, there would be no reference(?)

 

((I suppose I could put the custom power armor in another cell and moveto player after it is "created", but then if the player wants multiple custom power armors then I'll have to find a way to pull multiple power armors from that cell, maybe a count number that +1 every time a power armor is created and then tie that number back to the reference power armors somehow.))

 

Could that work?

Or would there be a better way to make a reference? Can the game make instance copies of a reference (so the original custom power armor can stay safely locked away in another cell somewhere?)

Link to comment
Share on other sites

You can add a script to the furniture, this would be relative to every PA reference, so you have both, player and furniture reference, to check for the distance and the line of sight using functions like GetDistance, HasDetectionLOS, RegisterForDistanceLessThanEvent, RegisterForDistanceGreaterThanEvent, RegisterForDetectionLOSGain, etc...

Link to comment
Share on other sites

Thanks DieFeM ^.^

 

That is what I was experimenting with before making this post.

I tried Onload and OnActivate (both on the power armor furniture) but the script will then only show the message when activating the power armor or when it first loads into the game - and then it only shoes up the first time, instead of every time I go near it.

 

Any workaround ideas mate?

 

((does the power armor furniture container count as being open when you hover the cursor over it? If it does, the script could intercept that event instead of OnActivate or Onload etc)(I don't think it counts as open though until the player activates it :/ ))

Edited by SandMouseAnarchy
Link to comment
Share on other sites

Message Property msg auto const mandatory

Function ShowMessage()
	If GetDistance(Game.GetPlayer()) < 512.0
		msg.show()
	EndIf
EndFunction

Event OnLoad()
	If Game.GetPlayer().HasDetectionLOS(Self)
		RegisterForDetectionLOSLost(Game.GetPlayer(), Self)
		ShowMessage()
	Else
		RegisterForDetectionLOSGain(Game.GetPlayer(), Self)
	EndIf
EndEvent



Event OnGainLOS(ObjectReference akViewer, ObjectReference akTarget)
	RegisterForDetectionLOSLost(Game.GetPlayer(), Self)
	ShowMessage()
EndEvent



Event OnLostLOS(ObjectReference akViewer, ObjectReference akTarget)
	RegisterForDetectionLOSGain(Game.GetPlayer(), Self)
EndEvent

Its a draft, you'll need to use also RegisterForDistanceLessThanEvent and RegisterForDistanceGreaterThanEvent with their respective events to get it properly working, but that's the general idea...

With the script as is, if you have line of sight and you approach the PA without losing it the message will not display, so you must catch the event for "distance less than" once you gain LOS, and register for los gain on distance less than event etc...

Edited by DieFeM
Link to comment
Share on other sites

DieFeM, thankyou mate, you are a genius!

that script works nicely - i havent managed to get it perfect yet, but hey, the message shows up when the player is close to the power armor now :D

 

This is the latest version of the script...

Scriptname PA_InteractOptions extends ObjectReference

Message Property OptionsMESG Auto

Function ShowMessage()
	If GetDistance(Game.GetPlayer()) < 60
		OptionsMESG.show()
	EndIf
EndFunction

Event OnInit()
	RegisterForDistanceLessThanEvent(Self, Game.GetPlayer(), 512)
EndEvent

Event OnLoad()
	If Game.GetPlayer().HasDetectionLOS(Self)
		RegisterForDetectionLOSLost(Game.GetPlayer(), Self)
		ShowMessage()
	Else
		RegisterForDetectionLOSGain(Game.GetPlayer(), Self)
	EndIf
EndEvent

Event OnGainLOS(ObjectReference akViewer, ObjectReference akTarget)
	RegisterForDetectionLOSLost(Game.GetPlayer(), Self)
	RegisterForDistanceLessThanEvent(Self, Game.GetPlayer(), 512)
	ShowMessage()					
EndEvent

Event OnLostLOS(ObjectReference akViewer, ObjectReference akTarget)
	RegisterForDetectionLOSGain(Game.GetPlayer(), Self)
EndEvent

Event OnDistanceLessThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
	RegisterForDetectionLOSGain(Game.GetPlayer(), Self)
	ShowMessage()
	RegisterForDetectionLOSLost(Game.GetPlayer(), Self)
EndEvent

Edited by SandMouseAnarchy
Link to comment
Share on other sites

  • Recently Browsing   0 members

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