Jump to content

How can a Robot tell it is in the Robot Workbench?


PJMail

Recommended Posts

There seems no way I can find to tell a Robot is being worked on in the Robot Workbench (via scripts/effects/conditions on that Robot).

They are not unconscious, sitting (maybe because Robots don't generate 'OnSit' events - only 'OnGetUp'), waiting, or have any extra keyword attached that I can find. The Robot Workbench is done entirely in game code (no scripts) so nothing I can look at.

 

I am not even sure the Player can tell, as there is only an 'onrobotmodified' or 'onrobotcreated' event at the end when you exit the bench..

 

I did see "isInRobotWorkbench" in the console (help workbench 1) but it returns nothing and I can't find it in scripting.

 

Any thoughts?

Link to comment
Share on other sites

With F4SE:

Function MyFunction()

	Actor MyRobot
	ObjectReference FurnitureRef
	FurnitureRef = MyRobot.GetFurnitureReference()      ; F4SE actor script function

	If MyRobot.GetSitState() == 3 && FurnitureRef.HasKeyword(AnimsFurnWorkbenchRobot) && FurnitureRef.HasKeyword(DLC01WorkbenchRobotKeyword)
		; Robot is sitting in a robot workbench
	EndIf

EndFunction

 

 

 

Without F4SE, maybe this:

 

 

Function MyFunction()

	Actor MyRobot
	Furniture RobotWorkbenchBaseForm
	ObjectReference ClosestRobotWorkbench
	Radius = 5.0                             ; If an actor is sitting in a furniture, the distance between the actor and the furniture should be 0. So if FindClosestReferenceOfTypeFromRef finds anything at all and MyActor.GetSitState() returns 3, most likely the robot is sitting in a robot workbench. (Radius = 5.0 should be enough.. I don't think it's possible that the distance between the roots of the robot's and the workbench's mesh is less than 5.0 if the robot is not sitting in it).

	ClosestRobotWorkbench = Game.FindClosestReferenceOfTypeFromRef(RobotWorkbenchBaseForm, MyRobot, Radius)

	If ClosestRobotWorkbench && MyRobot.GetSitState() == 3
		; Robot is (most likely) sitting in a robot workbench
	EndIf

EndFunction

 

 

 

Conditions:

 

 

CurrentFurnitureHasKeyword "AnimsFurnWorkbenchRobot" == 1     AND
CurrentFurnitureHasKeyword "DLC01WorkbenchRobotKeyword" == 1

Run on : Subject

 

 

 

 

 

IsCurrentFurnitureObj "WorkbenchRobot" == 1

Run on : Subject

 

 

 

 

 

; You mentioned the console but there's also a Condition "IsInRobotWorkbench", maybe you could try it:

IsInRobotWorkbench == 1

Run on: Subject

 

 

 

 

By the way, robots don't generate OnSit events? That's interesting..
Edited by LarannKiar
Link to comment
Share on other sites

Unfortunately they are not 'sitting' when at the Robot workbench (I mentioned that) - which removed all the easy checks.

D*mn Bethesda for just hacking it in via base game code rather than nice furniture interactions, keywords, and 'stay still' packages.

 

I didn't try GetFurnitureReference() because I want a fix that doesn't require F4SE, and they are not sitting so I doubt there is an associated furniture.

 

I considered FindClosestReferenceOfTypeFromRef but it would trigger even when they are 'near' the Workbench (no 'onsitting' check remember) - and Automatrons hug you like a lover so they are ALWAYS friggen close when using the workbench!

 

I simply want to put a check in the effects script for robots so annoying effects aren't triggered when you flip through their various Omod parts - so needs to be quick.

 

Oh well, I will just release my 'fix stuck Red head light' mod as a 'problem remover' rather than a total 'problem preventer'.

Edited by PJMail
Link to comment
Share on other sites

And I know they don't generate 'onsit' as sitstate = 3 when they are on a Vertibird, yet any magiceffect scripts on the Automatron don't receive an 'onsit' event when boarding, but they DO receive an 'onGetup' when they exit.

Link to comment
Share on other sites

Which nif? The workbench?

 

Looked - and the Workbench has a whole bunch of animations built in - but looks like just to move the arms etc.

Anything more than that is beyond me...

Edited by PJMail
Link to comment
Share on other sites

Unfortunately they are not 'sitting' when at the Robot workbench (I mentioned that) - which removed all the easy checks.

 

So the robot is just standing on the platform with "GetSitState() == 0" and "IsOnMount() == 0"? That's unfortunate...

 

But maybe you could try this:

 

 

Event OnQuestInit()
	RegisterForRemoteEvent(Game.GetPlayer(), "OnSit")
EndEvent

Event Actor.OnSit(ObjectReference akFurniture)

	If akFurniture.HasKeyword(DLC01WorkbenchRobotKeyword) && akFurniture.HasKeyword(AnimsFurnWorkbenchRobot)		; Robot Workbench?
		Utility.Wait(0.3)			; Wait for the robot to teleport onto the platform
		ObjectReference ClosestWorkbenchRobotRef = GetClosestWorkbenchRobotRef(akFurniture)
	EndIf

EndEvent

; Returns the closest moddable robot to WorkbenchRef
ObjectReference Function GetClosestWorkbenchRobotRef(ObjectReference WorkbenchRef)

	ObjectReference ClosestWorkbenchRobotRef

	If WorkbenchRef

		; Get all nearby robots
		ObjectReference[] NearbyRobots = WorkbenchRef.FindAllReferencesWithKeyword(ActorTypeRobot, 50.0)

		; Find the closest one
		If NearbyRobots.Length > 0
			Int Index
			While NearbyRobots.Length > Index
			ObjectReference LoopRobotRef = NearbyRobots[Index]
			If LoopRobotRef && LoopRobotRef.HasKeyword(DLC01ModdableBot)		; Moddable robot?
				If !ClosestWorkbenchRobotRef
					ClosestWorkbenchRobotRef = LoopRobotRef
				Else
					If ClosestWorkbenchRobotRef.GetDistance(WorkbenchRef) > LoopRobotRef.GetDistance(WorkbenchRef)
						ClosestWorkbenchRobotRef = LoopRobotRef
					Endif
				EndIf
			EndIf
			Index = Index + 1
		EndWhile

		Return ClosestWorkbenchRobotRef

	EndIf

EndFunction 

 

 

If there really is no "IsInRobotWorkbench" bool function then I guess this is as realiable as it gets. But if you find something better, post it here, I might want to use it someday. :)

 

D*mn Bethesda for just hacking it in via base game code rather than nice furniture interactions, keywords, and 'stay still' packages.

 

Well, judging by the amount of default objects (and their purposes, e.g., "RobotWorkBench_CurieReplacementModList"...), the game code must be pretty messy..

Link to comment
Share on other sites

Enormously messy - also look at how they 'replace' Codsworth with a moddable robot. And the duplicate Mr.Handy omods (old ones on codsworth and new ones for robot workbench).

And all those modlists!

 

Tracking the player to get this info is just far too messy for the small returns. I was hoping for a 'sneaky' trick (something the workbench touched on the robot) - but no.

As you say "GetSitState() == 0" and "IsOnMount() == 0". Even their own robot effect scripts don't work (they listen for 'onsit' to disable some effects - which is why the effects never stop)

 

Bugthesda. Giving up on it for now, and will just release my mod without a permanent fix in it.

 

Thanks anyway @LarannKiar.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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