pepperman35 Posted April 27, 2023 Share Posted April 27, 2023 As some of you know, I have been working tirelessly on a working church concept for my mod. Under normal circumstance, I call the congregation to the church, and then call the pastor in to peach the sermon. At the end of the sermon, I play a song and dismiss the settlers. I call the function below to achieve this last part via a script fragment tied into the end of the pastor’s sermon (i.e., dialog quest). Function DismissCongregration() ; This function is called after the pastor finishes his sermon. It serves to ; dismiss the congregration, return the invisible worshippers to their ; holding cell and returns control to the player ; ; Dismiss the congregration ; FO4_SummonCongregationQuest.SetStage(20) ; ; Play some church music ; FO4_ChurchMusic01.play(FO4_MusicMarker01) ; ; Return the pastor to his house ; FO4_PastorSummonState.SetValue(0 as float) Alias_PastorAllen.GetActorReference().EvaluatePackage() ; ; Return NPC stand-in workshipers to their holding cell ; Alias_FemaleWorshiper.GetReference().moveto(FemaleWorshipperOrigin.GetReference()) Alias_FemaleWorshiper.GetActorReference().SetAlpha(1.0) ;enable player controls SermonInputLayer.EnablePlayerControls() Game.SetPlayerAIDriven(false) SermonInputLayer.delete() SermonInputLayer = None FO4_PlayerPew.BlockActivation(false) EndFunction I have been doing a fair amount of testing recently to ensure the four sermons sound right. For this testing, I had started a new game (cocing to the settlement) directly from the start menu, claimed the workstation, recruited the settlers, and then proceeded to the church. I called the settlers to the church, and then saved the game. Now upon opening the save, the song plays (i.e., it shouldn’t be playing as I have not called the pastor nor has any sermon been given. This suggests something is amiss, but what?What might cause the sound file to play without being called, and more importantly, how to I make it stop that nonsense? Link to comment Share on other sites More sharing options...
Fantafaust Posted April 28, 2023 Share Posted April 28, 2023 You need to put some debug messages in your event/function blocks so you can see which one is running, as it gets run. You might also throw the music play in an If block that checks that the stage on your quest actually IS set to 20. ie If FO4_SummonCongregationQuest.GetStage() == 20 FO4_ChurchMusic01.play(FO4_MusicMarker01) EndIf Link to comment Share on other sites More sharing options...
pepperman35 Posted April 28, 2023 Author Share Posted April 28, 2023 I put the debug traces in and the IF segment, but the result is the same. I checked the log, and the traces are not there meaning the function was not called. Yet, somehow the sound was played. Perplexing indeed. Scriptname SermonSceneSupportScript extends Quest ; / Script placed on the pastors dialogue quest ; ╔═════════════════════════════════════════════════╗ ; ║ Properties ║ ; ╚═════════════════════════════════════════════════╝ Quest Property FO4_SummonCongregationQuest Auto Const Mandatory GlobalVariable Property FO4_PastorSummonState Auto Const Mandatory ReferenceAlias Property Alias_FemaleWorshiper Auto Const Mandatory ReferenceAlias Property Alias_PastorAllen Auto Const Mandatory ReferenceAlias Property Alias_Player Auto Const Mandatory ReferenceAlias Property FemaleWorshipperOrigin Auto Const Mandatory ObjectReference Property FO4_FemaleWorshipperMarker Auto Const Mandatory ObjectReference Property FO4_MusicMarker01 Auto Const Mandatory ObjectReference Property FO4_PlayerPew Auto Const Mandatory Sound Property FO4_ChurchMusic01 Auto Const Mandatory Spell Property QuietReflection Auto Const Spell Property FO4_DivineInspiration Auto Const Spell Property FO4_DivineRevelation Auto Const Spell Property FO4_Enlightenment Auto Const MagicEffect Property QuietReflectionEffect Auto Const MagicEffect Property FO4_DivineInspirationEffect Auto Const MagicEffect Property FO4_DivineRevelationEffect Auto Const MagicEffect Property FO4_EnlightenmentEffect Auto Const workshopparentscript Property WorkshopParent Auto Const Mandatory InputEnableLayer Property SermonInputLayer Auto Hidden Function ForcePlayertoSit() ; After requesting a word from the Lord this function is called to place two ; invisible players into the scence for sound bytes. The function will also ; force the player into a chuch pew and disable their controls ; Move the male and female NPC worshippers into the scene and turn them invisible Alias_FemaleWorshiper.GetReference().moveto(FO4_FemaleWorshipperMarker) Alias_FemaleWorshiper.GetActorReference().SetAlpha(0.0) ; ; Move the player and force him into a church pew ; Alias_Player.GetReference().moveto(FO4_PlayerPew) ; ; Disable player controls so that he remains seated throughout the sermon ; SermonInputLayer = InputEnableLayer.Create() SermonInputLayer.DisablePlayerControls() game.ForceFirstPerson() ; Memo: Not sure if the next two lines are needed as we are forcing the player into the pew ; via moveto. Could not get the travel/sit AI package to work. game.SetPlayerAIDriven(true) Alias_Player.GetActorReference().EvaluatePackage() ; Give a little bit of time to ensure the player get loaded into the pew then block activation Utility.Wait(0.2) FO4_PlayerPew.BlockActivation(true, true) EndFunction Idle Property FO4_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 = WorkshopParent.GetWorkshopFromLocation(playerRef.GetCurrentLocation()) ObjectReference[] ActorsAll = WorkshopParent.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) ; Add a bit of randomization for the praying ; Get a random number between 0.1 and 1 float random1 = Utility.RandomFloat(0.1, 0.3) float random2 = Utility.RandomFloat(1, 3) Utility.Wait(random1/random2) theNPC.PlayIdle(FO4_FurniturePraying) j += 1 EndWhile If bFadeOut Utility.wait(0.5) Game.FadeOutGame(False, True, 0.1, 0.1, False) EndIf EndFunction Function DismissCongregration() ; This function is called after the pastor finishes his sermon. It serves to ; dismiss the congregration, return the invisible worshippers to their ; holding cell and returns control ; to the player ; ; Dismiss the congregration ; Debug.Trace("SermonSceneSupportScript: The DismissCongregration function has been called") FO4_SummonCongregationQuest.SetStage(20) ; ; Play some church music ; If FO4_SummonCongregationQuest.GetStage() == 20 Debug.Trace("SermonSceneSupportScript: It is safe to play some music now") FO4_ChurchMusic01.play(FO4_MusicMarker01) EndIf ; FO4_ChurchMusic01.play(FO4_MusicMarker01) ; ; Return the pastor to his house ; FO4_PastorSummonState.SetValue(0 as float) Alias_PastorAllen.GetActorReference().EvaluatePackage() ; ; Return NPC stand-in workshipers to their holding cell ; Alias_FemaleWorshiper.GetReference().moveto(FemaleWorshipperOrigin.GetReference()) Alias_FemaleWorshiper.GetActorReference().SetAlpha(1.0) ; ; Enable player controls ; SermonInputLayer.EnablePlayerControls() Game.SetPlayerAIDriven(false) SermonInputLayer.delete() SermonInputLayer = None FO4_PlayerPew.BlockActivation(false) ; ; Reward the player for listening to the sermon ; Randomly select a reward ; int RandomReward = Utility.RandomInt(1, 4) Actor myPlayerREF = Game.GetPlayer() If (RandomReward == 1) If myPlayerREF.HasMagicEffect(QuietReflectionEffect) == 0 debug.trace("SermonSceneSupportScript: Casting Quiet Reflection on Player") QuietReflection.Cast(myPlayerREF, myPlayerREF) EndIf ElseIf (RandomReward == 2) If myPlayerREF.HasMagicEffect(FO4_DivineInspirationEffect) == 0 debug.trace("SermonSceneSupportScript: Casting Divine Inspiration on Player") FO4_DivineInspiration.Cast(myPlayerREF, myPlayerREF) EndIf ElseIf (RandomReward == 3) If myPlayerREF.HasMagicEffect(FO4_DivineRevelationEffect) == 0 debug.trace("SermonSceneSupportScript: Casting Divine Revelation on Player") FO4_DivineRevelation.Cast(myPlayerREF, myPlayerREF) EndIf ElseIf (RandomReward == 4) If myPlayerREF.HasMagicEffect(FO4_EnlightenmentEffect) == 0 debug.trace("SermonSceneSupportScript: Casting Enlightenment on Player") FO4_Enlightenment.Cast(myPlayerREF, myPlayerREF) EndIf EndIf EndFunction Link to comment Share on other sites More sharing options...
niston Posted April 29, 2023 Share Posted April 29, 2023 Just speculating: Perhaps a sound marker is left over from testing?That the engine then plays on load? Link to comment Share on other sites More sharing options...
pepperman35 Posted April 29, 2023 Author Share Posted April 29, 2023 Pepper tips his hat to niston in appreciation. Brilliant! Sound markers, enable, disable, scripting, clean up neglect, testing…sigh. The path to knowledge can be painful as well as humbling. Thank you niston. Link to comment Share on other sites More sharing options...
niston Posted April 29, 2023 Share Posted April 29, 2023 Glad you got it sorted :) Link to comment Share on other sites More sharing options...
Recommended Posts