Jump to content

[script ?] DLC06WorkshopBarberChair


Recommended Posts

Okay, working on a barber shop for my settlement. I have made an animated barber shop pole FO4_BarberShopPole01.nif) and I would like to play its animation “Play01” when the assigned NPC loads into the station (i.e., DLC06WorkshopBarberChair). Likewise, I would like to stop its animation when the assigned NPC leave the station. The animated barber shop pole would signify that the barber shop was either open or closed, depending on whether an NPC was manning the station or not.

From a scripting perspective what would be the best way to implement this? I suppose I could put a trigger box around the DLC06WorkshopBarberChair and when the NPC enters or leave it, the barber pole animation could play or not. Event OnActivate might be another option but I don’t readily see a way to turn off the animation via that option. Event Actor.OnSit and Actor.OnGetUp might be a third option. How does one determine if an NPC is assigned to and manning the station?

Link to comment
Share on other sites

Okay, working on a barber shop for my settlement. I have made an animated barber shop pole FO4_BarberShopPole01.nif) and I would like to play its animation “Play01” when the assigned NPC loads into the station (i.e., DLC06WorkshopBarberChair). Likewise, I would like to stop its animation when the assigned NPC leave the station. The animated barber shop pole would signify that the barber shop was either open or closed, depending on whether an NPC was manning the station or not.

From a scripting perspective what would be the best way to implement this? I suppose I could put a trigger box around the DLC06WorkshopBarberChair and when the NPC enters or leave it, the barber pole animation could play or not. Event OnActivate might be another option but I don’t readily see a way to turn off the animation via that option. Event Actor.OnSit and Actor.OnGetUp might be a third option. How does one determine if an NPC is assigned to and manning the station?

when NPC is assigned to a furniture ownership should change accordingly, so HasActorRefOwner() could be a way to know that.

If BarberChair.HasActorRefOwner()

Edited by lee3310
Link to comment
Share on other sites

First attempt: Tried OnActivate with the following script applied to the barber chair. NPC is assigned to the station and manning post. Log file shows no evidence of it being activated and of course the barber pole doesn't animate.

Scriptname Bart:BarberShopMannedScript extends ObjectReference Const

ObjectReference Property pFO4_BarberShopPole01 Auto Const Mandatory

Event OnActivate(ObjectReference akActionRef)
	Debug.Trace("Bart:WorkshopBarberMannedScript Barber shop activated by " + akActionRef)
	If (AkActionRef == Game.Getplayer() as ObjectReference == False)
		If self.HasActorRefOwner()
			Debug.Trace("Bart:WorkshopBarberMannedScript Barber shop has changed ownership")
			pFO4_BarberShopPole01.PlayAnimation("Play01")
		EndIf
	EndIf
EndEvent
Link to comment
Share on other sites

You could listen to OnSit and OnGetUp (but it's on the Actor):

https://www.creationkit.com/fallout4/index.php?title=OnSit_-_Actor

https://www.creationkit.com/fallout4/index.php?title=OnGetUp_-_Actor

 

You could register/unregister for remote OnSit/OnGetUp events when the station is assigned/unassigned, by listening for WorkshopActorAssignedToWork and WorkshopActorUnassigned events.

Those two custom events are raised by WorkshopParentScript;

; assign
Var[] kargs = new Var[2]
kargs[0] = assignedObject
kargs[1] = workshopRef
wsTrace("  sending WorkshopActorAssignedToWork event")
SendCustomEvent("WorkshopActorAssignedToWork", kargs)
 
; unassign
Var[] kargs = new Var[2]
kargs[0] = theObject
kargs[1] = workshopRef
wsTrace("  sending WorkshopActorUnassigned event")
SendCustomEvent("WorkshopActorUnassigned", kargs)

So, when NPC is assigned to barber, you register for OnSit/OnGetUp events from the NPC.

When NPC gets OnSit event, check that refFurniture is proper, start the animation.

When NPC gets OnGetUp event, check that refFurniture is proper and stop the animation.

When NPC is unassigned from barber object, stop listening for OnSit/OnGetUp and stop animation.

IIRC if the NPC dies/gets moved to another workshop/etc, an unassigned event is generated.

Link to comment
Share on other sites

Yeah that'll do fine for CK placed stuff.

Just saw the video. Good work pepperman35!

 

Have you planned to turn off the light on the barberpole, when anim is stopped?

I think that is an excellent suggestion, and fairly easy to implement.

 

Edited by pepperman35
Link to comment
Share on other sites

Nice, after watching the video i realized that i didn't understand your question. I thought that you want an NPC to man the barber chair and another one (a client) will sit in the chair, similar to how furniture bar works and only then, the pole animation will play (like a no vacancy sign).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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