ReDragon2013 Posted December 16, 2018 Share Posted December 16, 2018 (edited) I do not have experience with VoiceType changing, and in particular SKSE special functions. Maybe next sample can be useful for understanding.SampleAliasVoiceTypeScript Scriptname SampleAliasVoiceTypeScript extends ReferenceAlias ; https://forums.nexusmods.com/index.php?/topic/7227756-changing-actors-voice-type-via-script/ ; SeraphimKensai wrote: "I'm working on a script that is attempting to change an actors' voice and was confused about how to go about doing it." VoiceType PROPERTY newVoiceType auto ; fill with CK VoiceType originalVT ; voiceType holder only ; -- EVENTs -- EVENT OnInit() IF SKSE.GetVersion() gotoState("SKSE") ; ### STATE ### RegisterForSingleUpdateGameTime(0.0) ELSE gotoState("NoSKSE") ; ### STATE ### ENDIF ENDEVENT EVENT OnUpdateGameTime() myF_Test() ; run the test ENDEVENT ;=============================== State SKSE ;========= EVENT OnCellLoad() ENDEVENT EVENT OnLoad() ENDEVENT EVENT OnUnLoad() ENDEVENT EVENT OnActivate(ObjectReference akActionRef) ENDEVENT ;======= endState ;=============================== State NoSKSE ;=========== EVENT OnBeginState() Debug.Trace(self+" SKSE not loaded..") ENDEVENT EVENT OnCellLoad() IF SKSE.GetVersion() gotoState("SKSE") ; ### STATE ### switch state, because SKSE is ready now RegisterForSingleUpdateGameTime(0.0) ENDIF ENDEVENT ;======= endState ; -- FUNCTION -- ; ****************************************************************************** ; -- Race.psc -- SKSE modified ; VoiceType FUNCTION GetDefaultVoiceType(Bool female) native ; returns the races default voice type ; FUNCTION SetDefaultVoiceType(Bool female, VoiceType voice) native ; sets the races default voice type ; -- ActorBase.psc -- SKSE modified ; VoiceType FUNCTION GetVoiceType() native ; gets the Actors voicetype ; FUNCTION SetVoiceType(VoiceType nVoice) native ; sets the Actors voicetype ; ****************************************************************************** ;------------------ FUNCTION myF_Test() ;------------------ actor aRef = self.GetActorReference() ;actor aRef = self.GetReference() as Actor ; equal to above, but it needs two temp variables, not one ; https://www.creationkit.com/index.php?title=GetActorBase_-_Actor actorBase AB = aRef.GetActorBase() ;actorBase AB = aRef.GetBaseObject() as ActorBase ; equal to above, but it needs two temp variables, not one oiginalVT = AB.GetVoiceType() ;* global script variable Debug.Trace(self) Debug.Trace("---------------------------------------------------------------------------") Debug.Trace(" (before) actor = " +aRef+ ", ActorBase = " +AB+ ", VoiceType = " +originalVT) AB.SetVoiceType(newVoiceType) Debug.Trace(" (after) actor = " +aRef+ ", ActorBase = " +AB+ ", VoiceType = " +AB.GetVoiceType()) ;-------------------------------- race r = aRef.GetRace() voiceType VT ;* local function variable IF (AB.GetSex() == 0) ; male VT = r.GetDefaultVoiceType(False) ELSE ;IF (i == 1) ; female VT = r.GetDefaultVoiceType(TRUE) ENDIF Debug.Trace("Try to set default VoiceType by race..") Debug.Trace(" (before) race = " +r+ ", ActorBase = " +AB+ ", VoiceType: current = " +AB.GetVoiceType()+ ", default = " +VT+ ", original = " +originalVT) r.SetDefaultVoiceType(AB.GetSex() as Bool, VT) ; male == False, female == TRUE Debug.Trace(" (after) race = " +r+ ", ActorBase = " +AB+ ", VoiceType: current = " + AB.GetVoiceType() + " == " +originalVT+ " ?") ;-------------------------------- AB.SetVoiceType(originalVT) Debug.Trace(" (after) actor = " +aRef+ ", ActorBase = " +AB+ ", VoiceType: current = " + AB.GetVoiceType() + " == " +originalVT+ " ?") ENDFUNCTION Edited December 16, 2018 by ReDragon2013 Link to comment Share on other sites More sharing options...
PeterMartyr Posted December 21, 2018 Share Posted December 21, 2018 SKSE codes that change the ActorBase of a NPC require a Maintenance Code on Player Load Game else it will always break. Consider that has well. They are not save persistence. That must be factored into the equation has well. So you need Two Scripts to pull this off. Link to comment Share on other sites More sharing options...
SeraphimKensai Posted December 21, 2018 Author Share Posted December 21, 2018 Got an example of how to make the necessary maintenance script? Would you attach that directly to the actor itself as well or to the effect? Link to comment Share on other sites More sharing options...
Recommended Posts