Making an NPC unlock terminals

Post » Fri May 13, 2011 12:00 pm

I was wondering if there any ways to make an NPC unlock terminals.

The idea is to talk to the NPC, tell him to unlock the nearest terminal, he then moves to the nearest terminal and unlocks it.

The problem I have is that I can't find a way to get the ref ID of the nearest terminal without the player looking at it/activating it already.

It would probably be easier to just enhance the menu you get when activating a terminal, and add an option to this menu like "Let NPC unlock the terminal."

But there's already so many mods changing menus so I'd prefer to do it another way.

Does anyone have an idea how this could be done?

Thanks for any help or insight! :hugs:
User avatar
Rik Douglas
 
Posts: 3385
Joined: Sat Jul 07, 2007 1:40 pm

Post » Sat May 14, 2011 12:29 am

I can think of a way using FOSE commands - that's if you are referring to an ability that an NPC has to unlock any random terminal from any mod. You would use the FOSE ref-walk to get the reference of terminals in the cell then check each terminal found to make sure its the closest, then just use the unlock command with the ref. Just one thing though. Sometimes locked terminal are locked to control the flow of a quest, by unlocking them pre-maturely, you run the rusk of botching up some quests.
User avatar
Beast Attire
 
Posts: 3456
Joined: Tue Oct 09, 2007 5:33 am

Post » Sat May 14, 2011 12:42 am

From the vanilla game, I do recall that Dr. Li unlocks a terminal in the Taft Tunnels that lets the group continue through the tunnels. In that you will find the terminal setup, the NPC Idle marker/xMarker they used and any scripts attached to Li or the terminal that allowed the NPC to do the work. I have no idea myself how its done, but that's one "live" example you can study.

Luck,

Miax
User avatar
hannaH
 
Posts: 3513
Joined: Tue Aug 15, 2006 4:50 am

Post » Sat May 14, 2011 12:37 am

If you use this method (a perk) http://www.gamesas.com/index.php?/topic/1100863-getting-the-activated-target-ref-from-an-activation-perk/, and if another mod (like FWE) has also made a Perk for hacking terminals, the selections from both Perks will be merged/presented to the player.

I had already finished my script for a follower hacking terminals and I used the ref walk to find the terminal nearest the player - within about 200 units. You can create a form list of forbidden terminals and check against that when doing the ref walk. I'll be using the Perk method for NPC lockpicking.

Also, the hacking and lockpicking is all simulated by the script using skill level and various other factors to determine failure/success/lockout.

The NPC doesn't actually activate the terminal or lock. Just like MQ05ldEnclaveWaveSCRIPT simulates Doctor Li hacking of the Taft tunnel terminal and opens the door.
User avatar
kirsty joanne hines
 
Posts: 3361
Joined: Fri Aug 18, 2006 10:06 am

Post » Fri May 13, 2011 11:13 am

Thank you all for the answers

Can you tell me more about the FOSE ref-walk?

I've searched the FOSE documentation but I didn't find anything on it.

Regards
User avatar
Silvia Gil
 
Posts: 3433
Joined: Mon Nov 20, 2006 9:31 pm

Post » Fri May 13, 2011 1:09 pm

Here is a ref walk that might work. I had some problems validating it, and There may be a few things missing or flat out wrong (like the form list index control). But it should give you an idea of how to setup a script to perform a ref-walk and store the refs of locked terminals and check them for their proximity to the player.


scn FindALockedTerminalRefScriptShort DepthShort CountShort FoundFloat mDistanceFloat cDistanceRef rCurRefBegin GameMode	;Depth = how many cells to check, 0 for interior cells, 3 for exterior	Set Depth to 3 * (player.IsInInterior ==0)	;rCurRef is assigned to the first Terminal in the Cell Depth area, 23=Terminals	set rCurRef to GetFirstRef 23 Depth 0		;Define the Ref walk loop begining point	Label 10	;Check to see if the found ref is a valid ref	if (rCurRef)		;Is the termianl locked?		If rCurRef.GetLocked == 1			;Yes, so add it to a form list for future reference			rCurRef.ListAddReference MyRefList 0		Endif		;Prevent the 'apple' bug		Set rCurRef to Apple		;Assign the next ref in the ref-walk		Set rCurRef to GetNextRef				;Loop the code for the next ref in the ref walk		Goto 10		;Once there are no more valid refs, the ref-walk will end	endif	; Assign a maximum distance for any found terminal	Set mDistance to 99999	;Reset the index of the closest found terminal 	Set Found to -1	;Get the number of terminals found that were stored in the form list in the ref-walk	Set Count to ListGetCount MyRefList	;Define the starting point for looping through all the found locked terminals	Label 15	;Ensure there is at least one found terminal left to check	If Count > -1		; Assign rCurRef to the last terminal in the form list		Set rCurRef to ListGetNthForm MyRefList Count		;Determine the distance from the player to the found terminal		Set cDistance to Player.GetDistance rCurRef		;Is the distance shorter than the last found terminal (or less than max for the first found terminal)		If cDistance < mDistance			;Yes, so, lets save the index of this terminal			Set Found to count						;And lets update the maximum distance so the next found terminal must be closer than this one was			Set mDistance to cDistance		Endif		;Set the loop to check the previous ref in the form list		Set Count to Count -1		;Loop though the code again with the next previous form list entry		Goto 15	;No more form list entries to check	EndIf	;Did we find any locked terminals within our max distance?	If found > -1		;Yes, so lets retrieve its ref from the form list at the index saved in 'Found'		Set rCurRef to ListGetNthForm MyRefList Found		;rCurRef will now be the closest locked terminal. So you can use it to do whatever your want		;Add your code here knowing that rCurRef is the reference of the closest locked terminal	Endif	End

User avatar
Bigze Stacks
 
Posts: 3309
Joined: Sun May 20, 2007 5:07 pm

Post » Fri May 13, 2011 5:24 pm

I thought ref-walk was something completely different.

Judging by its name, I thought it's used to make an NPC walk to a specific reference.

Right now, I have a perk added to the player when the NPC joins his party (and remove it again when the NPC is waiting/fired) that lets you choose an option when you activate a terminal: "Let the NPC unlock the terminal."

And if you choose that option, I have the NPC moveto to the referenced terminal (got this with GetCrosshairRef) and unlock it. Well okay, the NPC doesn't really unlock it, it just looks like it.

Or it's supposed to look like it. Because moveto just teleports the NPC to the terminal... sometimes on top of it... which is obviously bad.

And I thought ref-walk would allow me to make the NPC actually walk up to the terminal, then I could make him play an animation and the terminal gets unlocked.

So uh, do I even need a ref-walk? I'm a little confused now, sorry.
User avatar
Bek Rideout
 
Posts: 3401
Joined: Fri Mar 02, 2007 7:00 pm

Post » Fri May 13, 2011 7:16 pm

Just throwing an idea out there, but could you do something similiar to what Dogmeat does when you say 'Get me ammo' and he runs off to grab the nearest ammo, just modify it to be terminals, and instead of grabbing it, then unlock it. Would that be plausable?
User avatar
Brittany Abner
 
Posts: 3401
Joined: Wed Oct 24, 2007 10:48 pm

Post » Fri May 13, 2011 10:24 pm

Dogmeat uses a find package. I don't think you can select 'locked terminal' in a find package.

But you can use the 'ref-walk' to locate the reference to the locked terminal, then have an XMarker somewhere already in the game and use a command like:

MyXmarker.moveto rCurRef

Then have a Travel AI package start on your NPC that moves him/her to the xmarker. That would get your NPC to the terminal.

Or, since you are actually interacting with the terminal and are getting an option to have the NPC unlock it, you might be able to set a quest variable to the ref of the terminal in your perk. Something like:

Set MyQuest.TerminalRef to GetSelf

Then use TerminalRef to move your Xmarker there and do the same as above.

Though I am not positive this will work from a perk, since the script doesn't exactly run on the terminal.

Alternately you could just use the perk start script to move your xmarker to the player (as he is standing next to the terminal in question) and do the same as above. But without the ref of the terminal, I don't see how you can get your NPC to 'use' it. You could get the NPC to use a desk terminal, but I don't think the wall terminals will animate to an open state where the keyboard is available for the NPC to 'type' on.
User avatar
priscillaaa
 
Posts: 3309
Joined: Sat Dec 30, 2006 8:22 pm

Post » Fri May 13, 2011 10:08 pm

I thought ref-walk was something completely different.

Judging by its name, I thought it's used to make an NPC walk to a specific reference.

Right now, I have a perk added to the player when the NPC joins his party (and remove it again when the NPC is waiting/fired) that lets you choose an option when you activate a terminal: "Let the NPC unlock the terminal."

And if you choose that option, I have the NPC moveto to the referenced terminal (got this with GetCrosshairRef) and unlock it. Well okay, the NPC doesn't really unlock it, it just looks like it.

Or it's supposed to look like it. Because moveto just teleports the NPC to the terminal... sometimes on top of it... which is obviously bad.

And I thought ref-walk would allow me to make the NPC actually walk up to the terminal, then I could make him play an animation and the terminal gets unlocked.

So uh, do I even need a ref-walk? I'm a little confused now, sorry.


Well if you are using HugePinball's Perk method and already have the ref to the terminal you want your NPC to hack, set in a quest script , you just need the XMarker and the travel package like Pkleiss mentioned. You don't need a REF walk. In the Perk result script, along with the GetCrossHairREF function, you need to set another quest variable to enable a block of code in the quest script to move the xmarker to the TerminalRef, then wait for a few frames before triggering the travel AI package. when the travel package ends, you can have it reset the variable condition that triggers it, and play an idle animation - UseOpenTerminalStanding.

The problem you will run into trying to use this animation as-is, is that there are conditions on it that pretty much restrict it to two unique terminals. I had to create my own idle entry, pointed to the same animation file, and added my own quest conditions for it to run.
User avatar
The Time Car
 
Posts: 3435
Joined: Sat Oct 27, 2007 7:13 pm


Return to Fallout 3