Drazhar753 Posted October 15, 2017 Share Posted October 15, 2017 (edited) Hey all So I am currently working on an update of my mod, and one of the spells named Occulent Sight will visually change the players' eyes while the ability is active. Now, my script does work for my current character. But when I got to changing race, sex, or even just the look of my own character, it stopped working correctly. Below is part of my script that is giving me issue. Scriptname AM_OcculentSightFX extends activemagiceffect FormList Property EyePartList Auto ActorBase Property Player Auto HeadPart PlayerEyes = none int keyactivate GlobalVariable Property OcculentSightKeyGlobal Auto Spell Property DetectItemSpell auto MagicEffect Property DetectingMagic auto Sound Property ReleaseSound Auto Sound Property FizzleSound Auto Event OnEffectStart(Actor akTarget, Actor akCaster) keyactivate = OcculentSightKeyGlobal.getvalueint() RegisterForKey(keyactivate) PlayerEyes = Player.GetNthHeadPart(4) ; Saves the players' current eyes before changing them to the new ones < this is the more troubling of lines Player.SetNthHeadPart(EyePartList.getat(0) as headpart, 4) ; changes the players' eyes to glowing ones< this is the more troubling of lines game.getPlayer().QueueNiNodeUpdate() ; Updates the players' nodes to allow the new eyes to display endevent Event OnEffectFinish(Actor Target, Actor Caster) Player.SetNthHeadPart(PlayerEyes, 4) ; Reverts the players' eyes to their previously stored ones game.getPlayer().QueueNiNodeUpdate() endevent Event OnKeyDown(Int aiKeyCode) ; This works fine if(Game.IsFightingControlsEnabled() == true && !Utility.IsInMenuMode()) if(game.getplayer().IsAIEnabled()) If aiKeyCode == keyactivate && game.getplayer().hasmagiceffect(DetectingMagic) == false DetectItemSpell.cast(game.getplayer()) ReleaseSound.play(game.getplayer()) elseif aiKeyCode == keyactivate && game.getplayer().hasmagiceffect(DetectingMagic) == true FizzleSound.play(game.getplayer()) endif endif endif endevent Now the problem is that the data I have gained from the CK wiki about headparts conflicts, or at least I am confused by it. Here it states that eyes are '2', however that does not work for me when placing that in the second parameter of the SetNthHeadpart function, instead I have to use '4', which does indeed work and replace my characters eyes correctly. If I do use 2 it actually replaces a part of my characters' hair. However when switching sex, race or even just headparts, like changing my hair type or adding scars... this seems to screw this all up. So I imagine that adding or removing head parts changes the values of all of them, frustratingly. What I want is to know how to always and specifically be able to get the players' eyes, change the players' eyes and then change them back despite race, sex, or different numbers of headparts. How do I get the eyes headpart reliably? Since I plan on releasing this update when this is done, I'd like this spell to work for everyone no matter what their character looks like, but this is holding me up. I am pretty new to modifying headparts like this, and am confused by what seems to be conflicting information from the CK wiki since here says that eyes are 3, whereas the previous 'here' link says they're 2.... I need a way to reliably determine this and am currently at a loss. Any help will greatly be appreciated! I'd like to share this interesting ability with others in the next update of my mod! :smile: Edited October 15, 2017 by Drazhar753 Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 15, 2017 Share Posted October 15, 2017 (edited) For the Eyes Colors, all you need to do is replace the Eye Texture Set with https://www.creationkit.com/index.php?title=SetEyeTexture_-_Actor your making harder than what it needs to be. That why it not working f*** It, look at this & try not to copy to much I can't bother explaining it, But that my Code & its for a NPC, not the Player. Scriptname PoupAliasCustomizerScript extends ReferenceAlias FormList Property _Poup_HairColorLIST Auto FormList Property _Poup_HairStlyeLIST Auto FormList Property _Poup_EyeColorLIST Auto Int Property aiHairColor = 0 Auto Hidden Int Property aiHairStyle = 0 Auto Hidden Int Property aiEyeColor = 0 Auto Hidden Int aiHairColor_Var = 0 Int aiHairStyle_Var = 0 Int aiEyeColor_Var = 0 Actor akSelf ActorBase akSelfBase Event OnInit() utility.Wait(12) akSelf = self.GetReference() as actor akSelfBase = akSelf.GetBaseObject() as ActorBase EndEvent Function SetUpdateMode() If(self.GetState() == "") self.GoToState("MenuMode") RegisterForSingleUpdate(0.1) EndIf EndFunction Event OnUpdate() If(akSelf.IsOnMount()) RegisterForSingleUpdate(1) ElseIf(IsHeadSlotWorn()) GoToState("HeadGear") else If(aiHairStyle || aiHairColor) HeadPart HairStyle_Def = _Poup_HairStlyeLIST.GetAt(0) as HeadPart ColorForm HairColor = _Poup_HairColorLIST.GetAt(aiHairColor) as ColorForm If(!aiHairStyle) akSelf.QueueNiNodeUpdate() akSelfBase.SetHairColor(HairColor) akSelf.ChangeHeadPart(HairStyle_Def) else HeadPart HairStyle = _Poup_HairStlyeLIST.GetAt(aiHairStyle) as HeadPart akSelfBase.SetHairColor(HairColor) akSelf.ChangeHeadPart(HairStyle_Def) Utility.Wait(0.15) akSelf.QueueNiNodeUpdate() Utility.Wait(0.15) akSelf.ChangeHeadPart(HairStyle) EndIf EndIf If(aiEyeColor) TextureSet PrettyEyes = _Poup_EyeColorLIST.GetAt(aiEyeColor) as TextureSet akSelf.SetEyeTexture(PrettyEyes) EndIf EndIf EndEvent Event OnLoad() RegisterForSingleUpdate(0.1) EndEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) EndEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) If(akBaseObject.HasKeywordString("ArmorHelmet") || akBaseObject.HasKeywordString("ClothingHead")) If(UI.IsMenuOpen("Dialogue Menu") || UI.IsMenuOpen("ContainerMenu")) If(IsHeadSlotWorn()) GoToState("HeadGear") EndIf else akSelf.UnequipItem(akBaseObject) EndIf EndIf EndEvent Bool Function IsHeadSlotWorn() return akSelf.GetWornForm(1) || akSelf.GetWornForm(2) EndFunction State MenuMode Event OnUpdate() If(akSelf.IsOnMount()) RegisterForSingleUpdate(1) else HeadPart HairStyle = _Poup_HairStlyeLIST.GetAt(aiHairStyle) as HeadPart If(aiHairStyle != aiHairStyle_Var) ;PoupUtil.TraceLog("Setting Hair Style") akSelf.ChangeHeadPart(HairStyle) aiHairStyle_Var = aiHairStyle EndIf If(aiHairColor != aiHairColor_Var) ;PoupUtil.TraceLog("Setting Hair Color") ColorForm HairColor = _Poup_HairColorLIST.GetAt(aiHairColor) as ColorForm Utility.Wait(0.15) akSelfBase.SetHairColor(HairColor) akSelf.ChangeHeadPart(HairStyle) aiHairColor_Var = aiHairColor EndIf If(aiEyeColor != aiEyeColor_Var) ;PoupUtil.TraceLog("Setting Eyes Color") TextureSet PrettyEyes = _Poup_EyeColorLIST.GetAt(aiEyeColor) as TextureSet akSelf.SetEyeTexture(PrettyEyes) aiEyeColor_Var = aiEyeColor EndIf self.GoToState("") EndIf EndEvent EndState State HeadGear Event OnUpdate() If(akSelf.IsOnMount()) RegisterForSingleUpdate(1) else If(aiHairStyle || aiHairColor) HeadPart HairStyle_Def = _Poup_HairStlyeLIST.GetAt(0) as HeadPart ColorForm HairColor = _Poup_HairColorLIST.GetAt(aiHairColor) as ColorForm HeadPart HairStyle = _Poup_HairStlyeLIST.GetAt(12) as HeadPart akSelfBase.SetHairColor(HairColor) akSelf.ChangeHeadPart(HairStyle_Def) Utility.Wait(0.15) akSelf.QueueNiNodeUpdate() Utility.Wait(0.15) akSelf.ChangeHeadPart(HairStyle) EndIf If(aiEyeColor) TextureSet PrettyEyes = _Poup_EyeColorLIST.GetAt(aiEyeColor) as TextureSet akSelf.SetEyeTexture(PrettyEyes) EndIf EndIf EndEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) If(akBaseObject.HasKeywordString("ArmorHelmet") || akBaseObject.HasKeywordString("ClothingHead")) If(!IsHeadSlotWorn()) GoToState("") RegisterForSingleUpdate(0.1) EndIf EndIf EndEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) EndEvent EndState State Waiting Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) If(akBaseObject.HasKeywordString("ArmorHelmet") || akBaseObject.HasKeywordString("ClothingHead")) If(!IsHeadSlotWorn()) GoToState("") RegisterForSingleUpdate(0.1) EndIf EndIf EndEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) EndEvent Event OnLoad() EndEvent EndState Edited October 15, 2017 by PeterMartyr Link to comment Share on other sites More sharing options...
Drazhar753 Posted October 15, 2017 Author Share Posted October 15, 2017 (edited) For the Eyes Colors, all you need to do is replace the Eye Texture Set with https://www.creationkit.com/index.php?title=SetEyeTexture_-_Actor your making harder than what it needs to be. That why it not working f*** It, look at this & try not to copy to much I can't bother explaining it, But that my Code & its for a NPC, not the Player. Scriptname PoupAliasCustomizerScript extends ReferenceAlias FormList Property _Poup_HairColorLIST Auto FormList Property _Poup_HairStlyeLIST Auto FormList Property _Poup_EyeColorLIST Auto Int Property aiHairColor = 0 Auto Hidden Int Property aiHairStyle = 0 Auto Hidden Int Property aiEyeColor = 0 Auto Hidden Int aiHairColor_Var = 0 Int aiHairStyle_Var = 0 Int aiEyeColor_Var = 0 Actor akSelf ActorBase akSelfBase Event OnInit() utility.Wait(12) akSelf = self.GetReference() as actor akSelfBase = akSelf.GetBaseObject() as ActorBase EndEvent Function SetUpdateMode() If(self.GetState() == "") self.GoToState("MenuMode") RegisterForSingleUpdate(0.1) EndIf EndFunction Event OnUpdate() If(akSelf.IsOnMount()) RegisterForSingleUpdate(1) ElseIf(IsHeadSlotWorn()) GoToState("HeadGear") else If(aiHairStyle || aiHairColor) HeadPart HairStyle_Def = _Poup_HairStlyeLIST.GetAt(0) as HeadPart ColorForm HairColor = _Poup_HairColorLIST.GetAt(aiHairColor) as ColorForm If(!aiHairStyle) akSelf.QueueNiNodeUpdate() akSelfBase.SetHairColor(HairColor) akSelf.ChangeHeadPart(HairStyle_Def) else HeadPart HairStyle = _Poup_HairStlyeLIST.GetAt(aiHairStyle) as HeadPart akSelfBase.SetHairColor(HairColor) akSelf.ChangeHeadPart(HairStyle_Def) Utility.Wait(0.15) akSelf.QueueNiNodeUpdate() Utility.Wait(0.15) akSelf.ChangeHeadPart(HairStyle) EndIf EndIf If(aiEyeColor) TextureSet PrettyEyes = _Poup_EyeColorLIST.GetAt(aiEyeColor) as TextureSet akSelf.SetEyeTexture(PrettyEyes) EndIf EndIf EndEvent Event OnLoad() RegisterForSingleUpdate(0.1) EndEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) EndEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) If(akBaseObject.HasKeywordString("ArmorHelmet") || akBaseObject.HasKeywordString("ClothingHead")) If(UI.IsMenuOpen("Dialogue Menu") || UI.IsMenuOpen("ContainerMenu")) If(IsHeadSlotWorn()) GoToState("HeadGear") EndIf else akSelf.UnequipItem(akBaseObject) EndIf EndIf EndEvent Bool Function IsHeadSlotWorn() return akSelf.GetWornForm(1) || akSelf.GetWornForm(2) EndFunction State MenuMode Event OnUpdate() If(akSelf.IsOnMount()) RegisterForSingleUpdate(1) else HeadPart HairStyle = _Poup_HairStlyeLIST.GetAt(aiHairStyle) as HeadPart If(aiHairStyle != aiHairStyle_Var) ;PoupUtil.TraceLog("Setting Hair Style") akSelf.ChangeHeadPart(HairStyle) aiHairStyle_Var = aiHairStyle EndIf If(aiHairColor != aiHairColor_Var) ;PoupUtil.TraceLog("Setting Hair Color") ColorForm HairColor = _Poup_HairColorLIST.GetAt(aiHairColor) as ColorForm Utility.Wait(0.15) akSelfBase.SetHairColor(HairColor) akSelf.ChangeHeadPart(HairStyle) aiHairColor_Var = aiHairColor EndIf If(aiEyeColor != aiEyeColor_Var) ;PoupUtil.TraceLog("Setting Eyes Color") TextureSet PrettyEyes = _Poup_EyeColorLIST.GetAt(aiEyeColor) as TextureSet akSelf.SetEyeTexture(PrettyEyes) aiEyeColor_Var = aiEyeColor EndIf self.GoToState("") EndIf EndEvent EndState State HeadGear Event OnUpdate() If(akSelf.IsOnMount()) RegisterForSingleUpdate(1) else If(aiHairStyle || aiHairColor) HeadPart HairStyle_Def = _Poup_HairStlyeLIST.GetAt(0) as HeadPart ColorForm HairColor = _Poup_HairColorLIST.GetAt(aiHairColor) as ColorForm HeadPart HairStyle = _Poup_HairStlyeLIST.GetAt(12) as HeadPart akSelfBase.SetHairColor(HairColor) akSelf.ChangeHeadPart(HairStyle_Def) Utility.Wait(0.15) akSelf.QueueNiNodeUpdate() Utility.Wait(0.15) akSelf.ChangeHeadPart(HairStyle) EndIf If(aiEyeColor) TextureSet PrettyEyes = _Poup_EyeColorLIST.GetAt(aiEyeColor) as TextureSet akSelf.SetEyeTexture(PrettyEyes) EndIf EndIf EndEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) If(akBaseObject.HasKeywordString("ArmorHelmet") || akBaseObject.HasKeywordString("ClothingHead")) If(!IsHeadSlotWorn()) GoToState("") RegisterForSingleUpdate(0.1) EndIf EndIf EndEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) EndEvent EndState State Waiting Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) If(akBaseObject.HasKeywordString("ArmorHelmet") || akBaseObject.HasKeywordString("ClothingHead")) If(!IsHeadSlotWorn()) GoToState("") RegisterForSingleUpdate(0.1) EndIf EndIf EndEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) EndEvent Event OnLoad() EndEvent EndState Did you read the SetEyeTexture function? This will only last until the actor reloads their 3D. This will also not carry over a glowing eye mesh from what is originally a non-glowing mesh. Nor will it carry over in saves, or when your 3d is reloaded, ie turning into a werewolf/vampire lord and possibly switching worldspaces and interior cells. So even if I setup something like yours to update whenever the player changes cells or reloads the game, that still does not solve the issue of no glow. Changing the textureset to a textureset with a glow does not actually glow, since the players' eye mesh is not setup to glow. Hence why I need to change the mesh, not just the textureset.So I don't think I am making this harder than it needs to be, since it's a bit more complicated than just changing the color. But thank you for your input. Edited October 15, 2017 by Drazhar753 Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 15, 2017 Share Posted October 15, 2017 (edited) I re-read your post, when you do ANY ActorBase changes, whether it a player or an NPC, & they lose there 3D, they lose the changes. For the Player create an PalyerAlias, & use the Events OnLoad && OnPlayerLoadGame to preform some maintenance to reapply what is required. Store this info in an INT for these maintenance events, look at my script to get the general idea. I wasn't being rude, I just felt looking at your code, that you didn't need to held by the hand. It was a compliment. But then I felt this need to be explained. Since that what you were missing, nevertheless, I stand by my comment that you were using the wrong functions. :laugh: Edited October 15, 2017 by PeterMartyr Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 15, 2017 Share Posted October 15, 2017 That what happening to you now anyway. Link to comment Share on other sites More sharing options...
Drazhar753 Posted October 15, 2017 Author Share Posted October 15, 2017 (edited) I re-read your post, when you do ANY ActorBase changes, whether it a player or an NPC, & they lose there 3D, they lose the changes. For the Player create an PalyerAlias, & use the Events OnLoad && OnPlayerLoadGame to preform some maintenance to reapply what is required. Store this info in an INT for these maintenance events, look at my script to get the general idea. I wasn't being rude, I just felt looking at your code, that you didn't need to held by the hand. It was a compliment. But then I felt this need to be explained. Since that what you were missing, nevertheless, I stand by my comment that you were using the wrong functions. :laugh: I didn't think you were rude, but I don't think I'm using the wrong functions unless you can tell me how to change the eyes from a non-glowing to glowing and back with seteyetexture. Also changing the players eyes with Player.SetNthHeadPart(EyePartList.getat(0) as headpart, 4) does persist through reload, at least through my testing which has included reloading saves, as well as closing and reloading the game, changing cells etc. Since it is an active magic effect that lasts until dispelled, the information needed is stored in the effect until it ends, so I don't think I need a playeralias for this. However I will look more at your script, as it seems you have determined how to pick out the hair specifically and change that. Maybe I can learn to use that for the eyes. Edited October 15, 2017 by Drazhar753 Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 15, 2017 Share Posted October 15, 2017 I stand corrected, I though SKSE actorbase changes weren't permanent Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 15, 2017 Share Posted October 15, 2017 (edited) I am doing some tests Edited October 15, 2017 by PeterMartyr Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 15, 2017 Share Posted October 15, 2017 I am back & I found something have some patience Link to comment Share on other sites More sharing options...
Drazhar753 Posted October 15, 2017 Author Share Posted October 15, 2017 (edited) I am doing some tests Me too, I am using headpart glowyeyes = EyePartList.getat(0) as headpart Game.GetPlayer().ChangeHeadPart(glowyeyes) this now, this works much better for all races! So this is an improvement thanks to you! So thank you muchly. Now however I must figure out how to store the players' original eyes PlayerEyes = Player.GetNthHeadPart(3) ; This does not work properly due to the issue I was having originally, will pick wrong headparts due to the numbers being different from character to character. Edited October 15, 2017 by Drazhar753 Link to comment Share on other sites More sharing options...
Recommended Posts