Jump to content

Let's talk about NpcBenchChurchSit01


Recommended Posts

I think the following modification to your code will work, maybe not elegantly.

I've dabbled with forcing sitting npcs into new idles and found that it's simply not going to happen if you don't stop the current idle first. It can be a bit jerky so I added the fade to black, use it or don't totally up to you. Call with TransitionToPraying(True) if you want fade out / fade in. If you don't want fade call it with TransitionToPraying(False)

Scriptname TempTest extends Quest

Idle Property FurniturePraying Auto Const
ObjectReference[] Property ActorsAll auto
Idle Property IdleStop_Loose Auto Const

Function TransitionToPraying(bool bFadeOut)	;Set true if you want fade to black
	int j = 0
	if bFadeOut
		Game.FadeOutGame(True, True, 0.1, 0.1, True)
	EndIf	
	While j < ActorsAll.Length
		WorkshopNPCScript theNPC = ActorsAll[j] as WorkShopNPCScript
		theNPC.PlayIdle(IdleStop_Loose)
		Utility.Wait(0.3)
		theNPC.PlayIdle(FurniturePraying)
		j += 1
	EndWhile
	If bFadeOut
		Utility.wait(0.5)
		Game.FadeOutGame(False, True, 0.1, 0.1, False)
	EndIf	

EndFunction

 

Link to comment
Share on other sites

Pelgar, thanks for this. I will be sure to test it out as I am striving to add this functionality. hereami and LarannKiar have been very helpful in trying to get me to understand ways to make it happen. Hopefully, I can pull it all together.

 

Quick question: What does IdleStop_Loose point to, property wise?

Edited by pepperman35
Link to comment
Share on other sites

Okay, I did a quick test but ran into a little snag, as I didn't seem to be populating the ActorsAll (debug ActorsAll.Length equaled 0). More testing later today after church.

Scriptname NPCTransitionTest extends Quest

WorkshopParentScript Property pWorkshopParent Auto Const Mandatory
Idle Property FurniturePraying Auto Const
Idle Property IdleStop_Loose Auto Const
ReferenceAlias Property Alias_Workshop Auto Const

Function TransitionToPraying(bool bFadeOut)	;Set true if you want fade to black
	; Initialization
	WorkshopScript ThisWorkshop = (Alias_Workshop.GetRef() as WorkshopScript)
	ObjectReference[] ActorsAll = pWorkshopParent.GetWorkshopActors(ThisWorkshop)
	int j = 0
	;
	; Did the array get populated?
	;
	Debug.MessageBox("The number of workshop NPCs for this settlement is " + ActorsAll.Length)
	if bFadeOut
		Game.FadeOutGame(True, True, 0.1, 0.1, True)
	EndIf	
	While j < ActorsAll.Length
		WorkshopNPCScript theNPC = ActorsAll[j] as WorkShopNPCScript
		theNPC.PlayIdle(IdleStop_Loose)
		Utility.Wait(0.3)
		theNPC.PlayIdle(FurniturePraying)
		j += 1
	EndWhile
	If bFadeOut
		Utility.wait(0.5)
		Game.FadeOutGame(False, True, 0.1, 0.1, False)
	EndIf	

EndFunction
Link to comment
Share on other sites

Okay, I got the array sorted out but can see no visual evidence that any transition occurs. NPC continued to sit in the pews in a normal sitting position with no observable activity. The script ran as evidenced in the log. Revised script follows:

Scriptname NPCTransitionTest extends Quest
; Testing out idle transitioning
; Script provided by Pelgar 
; https://forums.nexusmods.com/index.php?/topic/12760599-lets-talk-about-npcbenchchurchsit01/page-2
;
WorkshopParentScript Property pWorkshopParent Auto Const Mandatory
Idle Property FurniturePraying Auto Const
Idle Property IdleStop_Loose Auto Const

Function TransitionToPraying(bool bFadeOut)	;Set true if you want fade to black
	; Initialization
	ObjectReference playerRef = Game.GetPlayer()
	workshopscript thisWorkshop = pWorkshopParent.GetWorkshopFromLocation(playerRef.GetCurrentLocation())
	ObjectReference[] ActorsAll = pWorkshopParent.GetWorkshopActors(thisWorkshop)
	int j = 0
	if bFadeOut
		Game.FadeOutGame(True, True, 0.1, 0.1, True)
	EndIf
	; Debug.Trace("NPCTransitionTestSript: We have this many settlers to work with " + ActorsAll.Length)
	While j < ActorsAll.Length
		WorkshopNPCScript theNPC = ActorsAll[j] as WorkShopNPCScript
		; Debug.Trace("NPCTransitionTestSript: NPC " + j + " = " + theNPC as WorkShopNPCScript)
		theNPC.PlayIdle(IdleStop_Loose)
		Utility.Wait(0.3)
		theNPC.PlayIdle(FurniturePraying)
		j += 1
	EndWhile
	If bFadeOut
		Utility.wait(0.5)
		Game.FadeOutGame(False, True, 0.1, 0.1, False)
	EndIf	

EndFunction
Link to comment
Share on other sites

Okay, made that change and tested again. Unfortunately, I am still not see anything happening at the NPC level. Obviously, I am going something wrong, but what that is exactly I know not.

Scriptname NPCTransitionTest extends Quest
; Testing out idle transitioning
; Script provided by Pelgar 
; https://forums.nexusmods.com/index.php?/topic/12760599-lets-talk-about-npcbenchchurchsit01/page-2
;
WorkshopParentScript Property pWorkshopParent Auto Const Mandatory
Idle Property FurniturePraying Auto Const
Idle Property IdleStop_Loose Auto Const

Function TransitionToPraying(bool bFadeOut)	;Set true if you want fade to black
	; Initialization
	ObjectReference playerRef = Game.GetPlayer()
	workshopscript thisWorkshop = pWorkshopParent.GetWorkshopFromLocation(playerRef.GetCurrentLocation())
	ObjectReference[] ActorsAll = pWorkshopParent.GetWorkshopActors(thisWorkshop)
	int j = 0
	if bFadeOut
		Game.FadeOutGame(True, True, 0.1, 0.1, True)
	EndIf
	Debug.Trace("NPCTransitionTestSript: We have this many settlers to work with " + ActorsAll.Length)
	While j < ActorsAll.Length
		; WorkshopNPCScript theNPC = ActorsAll[j] as WorkShopNPCScript
		Actor theNPC = ActorsAll[j] as Actor
		Debug.Trace("NPCTransitionTestSript: NPC " + j + " = " + theNPC as Actor)
		theNPC.PlayIdle(IdleStop_Loose)
		Utility.Wait(0.3)
		theNPC.PlayIdle(FurniturePraying)
		j += 1
	EndWhile
	If bFadeOut
		Utility.wait(0.5)
		Game.FadeOutGame(False, True, 0.1, 0.1, False)
	EndIf	

EndFunction
Link to comment
Share on other sites

I honestly don't know what may be going on here. Possibly the package that is seating the npcs is forcing the current animation especially if it has a script in the OnChange event or a forced idle attached to it.

I would probably also play around with the timing of the Wait(0.3) between the two calls to PlayIdle. A value of 1.0 would give a full one second wait between playidle calls, probably overkill but should make sure that the idlestop anim is playing on the npc before playing the FurniturePraying idle.

Link to comment
Share on other sites

I was curious as to why this was not working so I made a quick test mod to see if I could make it happen.
In the CK I made a copy of NpcBenchChurchSit01 and deleted AnimFurnPraying [KYWD:00140F74] then added AnimFurnChairSitAnims [KYWD:00030BB2].
I had a settler sit on the bench in game and tried the FurniturePraying idle on her via the console. I got the exact same results you've been
getting, nothing happened. I then took a look at the idle itself in F04Edit and found the problem or actually problems.
The first problem was there was a condition on the idle: (Subject.CurrentFurnitureHasKeyword(AnimFurnPraying [KYWD:00140F74]) = 1.000000 AND).
With the AnimFurnPraying Keyword removed from my test bench it didn't have a chance of playing. Unfortunatly adding the keyword to my bench
didn't help. I continued looking at the FurniturePraying idle and found it didn't have an animation file. I don't know exactly how they get
the furniture idles working so I made a copy of FurniturePraying using F04Edits Copy as new record right click menu.
I did this in FO4Edit becasue it's really easy to do there and I don't have a clue how to do it in the CK.
Changes I made to FurniturePraying:
EDID-Editor ID: PelgFurniturePraying (Of course you should name it something that works for you)
ENAM - Animation Event: dyn_activationloop
ANAM - Related Idle Animations
Related Idle Anamation #0 (Parent): NULL - Null Reference [00000000] (Double click then hit delete)
Related Idle Animation #1 (Previous Sibling): Null
Flags: Parent (Double click then check Parent)
GNAM - Animation File: Actors\Character\Animations\Furniture\Pray\IdleLoop.hkx

 

https://youtu.be/uv_gYif7Nr4

Link to comment
Share on other sites

  • Recently Browsing   0 members

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