soupdragon1234 Posted March 23, 2017 Share Posted March 23, 2017 (edited) Best timing would be, everytime player dismounts. But there's no event for on player dismount or such thing. What would be possible? Thank you for your time. Greetings, Tasheni You can register for an animation event that will be called when the player mounts/dismounts i.e. Event OnInit() ; or some other event or function RegisterForAnimationEvent(PlayerREF, "SoundPlay.NPCHorseDismount") ; register our dismount event on the player EndEvent Event OnAnimationEvent(ObjectReference akSource, string asEventName) ; animation event called If asEventName == "SoundPlay.NPCHorseDismount" ; player has dismounted, so do interesting stuff here Endif EndEventSubstitute "NPCHorseDismount" for "NPCHorseMount" as required. You can call: UnregisterForAnimationEvent(PlayerREF, "SoundPlay.NPCHorseDismount") when you're done. This script would be attached to the quest directly or to the horse actor? I've always attached it to a player alias on a quest but it might work if attached directly to a non-vanilla actor (not if they're disabled though and not if they're unloaded either) Its probably safer to attach it to a player alias. Edited March 23, 2017 by soupdragon1234 Link to comment Share on other sites More sharing options...
Tasheni Posted March 23, 2017 Author Share Posted March 23, 2017 Hi soupdragon1234, thank you for your code, I will try out, it will be very useful for further developing. I think, you didn't read my edit. I tested that the timing for changing the race after dismounting is not a good one for different reasons - so the saddle vanishes immediately after changing the race, because npcs can't wear saddles - I think. If player only dismount for collecting or fighting, this is quite unrealistic to saddle off the horse. This script would be attached to the quest directly or to the horse actor? Link to comment Share on other sites More sharing options...
ReDragon2013 Posted March 25, 2017 Share Posted March 25, 2017 (edited) Summary of your issue:Horse + Talking // Keyword PROPERTY ActorTypeNPC auto--------------------"I have my horse that I can talk to.The dialog is attached to a quest, that is start enabled.It works, if I've mounted the horse. But I want to show this up, when I chose the Talk option.""I have no problems with the dialog itself""It is the ride-activator, that hinders me to talk to the horse without mounting."Horse + Riding // Keyword PROPERTY ActorTypeHorse auto-------------------"The ride horse activator only shows up, if the actor has a keyword = ActorTypeHorse."At a guess: "If I simply remove the keyword from the actor and add ActorTypeNPC,he should talk to me like every other companion."You assumed:"If it is simply not possible to remove that ActorTypeHorse from the actor, perhapsit is possible to replace the whole actor with another one. So I have to make a second horse,similar to the first horse, but with ActorTypeNPC on it.This could be the base horse, that I'm able to talk to.""Is there a function to replace actors?"IsharaMeradin: "instead of replacing the actor.. you could have a separate quest with an alias for the horse that applies the ActorTypeHorse keyword.""This quest could be started with a dialog option to ride the horse and then stopped whenever the player has dismounted or so many seconds after dismount."Answer Tasheni: "it could be that there are problems with some situations, as you mentioned the fast dismount to loot or something like that."ReDragon2013: You should use an actor script with race switch.Sometimes later you wrote: "I had another idea and that works for the first race switching, but not for switch back"- My horse is first the npc.- Quest is start enabled.- No need anymore for the activation menu.- I talk to the horse and than script runs to switch the horse to horserace and saddles it up."How can I get it switched back to the npc race with a script in the quest or attached to the actor?Best timing would be, everytime player dismounts. But there's no event for on player dismount or such thing."next actor script could be useful: Scriptname Tasheni_HorseSwitchSCRIPT extends Actor {written by ReDragon 2017, animation names by soupdragon1234} ;; IF Game.GetPlayer().GetAnimationVariableBool("bIsRiding") ; ; player is riding a horse. ;; ENDIF Race PROPERTY HorseRace_NPC auto ; new horse race with keyword ActorTypeNPC // you started with Race PROPERTY HorseRace auto ; vanilla horse race with keyword ActorTypeHorse // you switched to them after talking with your horse Int iSwitchRace ; -- FUNCTIONs -- 2 ;------------------------------ FUNCTION myF_Switch2HorseRace() ; external called only ;------------------------------ ; "The default will set the actors race back to the original race." (wiki) ; self.SetRace(None) == self.SetRace() self.SetRace(HorseRace) ;;; self.EvaluatePackage() ; ** ENDFUNCTION ;------------------------------------ FUNCTION myF_Register4Anim(Bool bYes) ;------------------------------------ IF ( bYES ) ; bYES == TRUE ; register for animation RegisterForAnimationEvent(Game.GetPlayer() as ObjectReference, "SoundPlay.NPCHorseDismount") RETURN ; - STOP - ENDIF ;--------------------- IF ( iSwitchRace > 0) ; bYES == False iSwitchRace = 0 UnRegisterForAnimationEvent(Game.GetPlayer() as ObjectReference, "SoundPlay.NPCHorseDismount") self.SetRace(HorseRace_NPC) ENDIF ENDFUNCTION ; -- EVENTs -- 3 EVENT OnUnLoad() ; player lost the horse for whatever reason ;============= ;;; self.BlockActivation(False) myF_Register4Anim(False) ; unregister ENDEVENT EVENT OnRaceSwitchComplete() ;========================= iSwitchRace += 1 IF (iSwitchRace == 1) ; the first switch was made from external quest script you are talking with horse, like that: ; Tasheni_HorseSwitchSCRIPT.myF_Switch2HorseRace() Debug.Notification("First Horse race switch completed!") myF_Register4Anim(TRUE) ENDIF IF (iSwitchRace == 2) Debug.Notification("Second Horse race switch completed!") ENDIF self.EvaluatePackage() ; ** ENDEVENT EVENT OnAnimationEvent(ObjectReference akSource, String asEventName) ;===================== IF (akSource == Game.GetPlayer() as ObjectReference) ELSE RETURN ;- STOP - not the player, but only the player may trigger this event ENDIF ;-------------------- ;IF (asEventName == "SoundPlay.NPCHorseMount") ; RETURN ; - STOP - player has mounted the horse ;ENDIF ;--------------------- IF (asEventName == "SoundPlay.NPCHorseDismount") ; player has dismounted myF_Register4Anim(False) ; unregister ENDIF ENDEVENT ;EVENT OnActivate(ObjectReference actionRef) ;IF (actionRef == Game.GetPlayer() as ObjectReference) ;ELSE ; RETURN ; - STOP - / -2 not the player ;ENDIF ;--------------------- ;IF (actionRef as Actor).IsSneaking() ; Debug.Notification("HorseActivator: Sneaking not allowed!") ; RETURN ; - STOP - / -1 player is sneaking the horse ;ENDIF ;;--------------------- ; IF self.IsActivationBlocked() ; ELSE ; ; http://www.creationkit.com/index.php?title=BlockActivation_-_ObjectReference ; self.BlockActivation(TRUE) ; ENDIF ; int i = HorseActivateMESSAGE.Show() ; ;IF (i == 0) ; myQuest.setStage(10) ; let us talk ;;; self.Activate(self as ObjectReference, TRUE) ; activate the horse by itself ; RETURN ; - STOP - /0 activate for talking with this horse ;ENDIF ;--------------------- ;IF (i == 1) ; self.Activate(actionRef, TRUE) ; activate the horse by the player, like normal horse activation ; RETURN ; - STOP - /1 activate for horse riding ;ENDIF ;--------------------- ;IF (i == 2) ; RETURN ; - STOP - /2 do nothing ;ENDIF ;--------------------- ; Debug.Notification("HorseActivator: Unexpected button!") ;ENDEVENT Edited March 25, 2017 by ReDragon2013 Link to comment Share on other sites More sharing options...
ReDragon2013 Posted March 25, 2017 Share Posted March 25, 2017 I would like to give you another information about talking. I found some useful things about aRef.SetActorValue("variable01", f) the following get the actorvalue of actor "aRef", which has to be filled before. float f = aRef.GetActorValue("variable01")in the actor script above you can use that float f = self.GetActorValue("variable01")inside the vanilla script "CarriageSystemScript.psc", which extends Quest conditional you'll find that code. Topic PROPERTY DialogueCarriageChatterTopic auto EVENT OnUpdate() currentDriver.SetActorValue("variable01", 2) ; to allow chatter currentDriver.Say(DialogueCarriageChatterTopic) Utility.Wait(6.0) currentDriver.SetActorValue("variable01", 0) ; turn it back off ENDEVENT currentDriver.SetActorValue("Variable01", 3) ; to allow "waiting" chatter Link to comment Share on other sites More sharing options...
Tasheni Posted March 26, 2017 Author Share Posted March 26, 2017 (edited) Hi ReDragon2013,I'm overwhelmed by your engagement for this thing. I need some time to take a look at these new scripts. I tested all other from Ishara and supdragon1234 and yours. All compile fine and give me necessary notifications, the switch back to the npc race seems to work, but no dialog options after switching back the race.. I tried to keep it simple and used this example for further testing:https://www.reddit.com/r/skyrimmods/comments/3egvnw/papyrushelp_storing_playeroriginalrace_and/ I stored the actor's race into a quest, the switch to horse race finished through dialog. I made a shout with an OnEffectStart event and called the quest that stores the original race and set the race back to it. That seem to work, the saddle vanishes immediately from the horse, because npc can't wear this saddle. But the weird thing is, that afterwards no talk activator shows up, only the ride activator. I doublechecked all, can't find any faults. So the switch back to original race doesn't clear the activator value??? I tried it with player dialog talking to another npc attaching the script to the end of dialog - same result. The last I tried was to kick out my custom horse race and used the vanilla horse race. Switching to custom npc race works, back to vanilla race works, but activator stays ride.I've tried it for the last two weeks nearly every day for hours, but now I have to put it aside, because I want to release the mod at beginning of May and there's so much to do until then. I will take a look at your scripts tomorrow and try it for the last time.Thank you so much for your patience and help, that means a lot to me. I assure you: I'm not done with this thing, but it has to wait til I have more time to care for.Goodnight. Greetings, Tasheni Edited March 26, 2017 by Tasheni Link to comment Share on other sites More sharing options...
Tasheni Posted March 29, 2017 Author Share Posted March 29, 2017 (edited) Edit: Problem is solved. It is simple the Event OnEquipped(Actor akActor) attached to the ring, that works. I'm happy :smile: :smile: :)A special thank you for all your helping - I assure you, I get better every day with your help and my trying. So next round is on. I decided to replace the whole actor. It works fine, if I attach the scripts at a dialog.First horse is a NPC. I talk to it and after that it disables the NPC and enables the horse. Activate button changes to "Ride". I attached the switching back to a dialog of my companion and this works fine. Horse is disabled and NPC enabled.Then I tried to get this script to work, if player equips a certain ring. I used this script attached to the ring, it compiles, but in game nothing happens (sorry, I have no idea, how the spoiler function is working): Scriptname _ValaChangeWhenRingEquipped extends Quest Actor Property PlayerRef Auto ObjectReference Property ValaHorse Auto ObjectReference Property ValaNPC Auto Actor Property Vala AutoArmor Property Ring AutoArmor Property Saddle Auto Function IsEquipped() If (Game.GetPlayer().IsEquipped(Ring)) If (ValaNPC.IsDisabled() == True) ValaHorse.disable () ValaNPC.enable () float az = PlayerRef.GetAngleZ() ValaNPC.MoveTo(PlayerRef, 80.0*Math.sin(az), 80.0*Math.cos(az), 10.0, 0) Utility.Wait(3.0) Vala.UnequipItem(Saddle) Vala.RemoveItem(Saddle) Vala.EvaluatePackage() Else Debug.Notification("NPC is disabled") EndIf EndIfEndFunction I tried it also attaching it directly to a reference alias (player) in the quest. I looked at the script from Ishara and modified it a little bit and got this, also attached to the ring: Scriptname _ValaChangeWhenRingEquipped extends ReferenceAlias Actor Property PlayerRef Auto ObjectReference Property ValaHorse Auto ObjectReference Property ValaNPC Auto Actor Property Vala AutoArmor Property Ring AutoArmor Property Saddle Auto Bool Function PlayerEquippedRing() If Game.GetPlayer().IsEquipped(Ring) == true RegisterForSingleUpdate(2.5) Debug.Notification("No Ring") Else Debug.Notification("Ring equipped") EndIfEndFunctionEvent OnUpdate() If PlayerEquippedRing() == true If (ValaNPC.IsDisabled() == True) ValaHorse.disable () ValaNPC.enable () float az = PlayerRef.GetAngleZ() ValaNPC.MoveTo(PlayerRef, 80.0*Math.sin(az), 80.0*Math.cos(az), 10.0, 0) Utility.Wait(3.0) Vala.UnequipItem(Saddle) Vala.RemoveItem(Saddle) Vala.EvaluatePackage() Else Debug.Notification("NPC is disabled") EndIf EndIf EndEvent It compiles, but nothing happens in game, if player equips the ring, also not, if attached to the alias. What works is this, directly attached to a companion dialog: Scriptname _ValaChangeToNPC Extends TopicInfo HiddenActor Property PlayerRef Auto ObjectReference Property ValaHorse Auto ObjectReference Property ValaNPC Auto Actor Property Vala AutoArmor Property Ring AutoArmor Property Saddle Auto;BEGIN FRAGMENT Fragment_1Function Fragment_1(ObjectReference akSpeakerRef)Actor akSpeaker = akSpeakerRef as Actor;BEGIN CODEValaHorse.disable ()ValaNPC.enable ()float az = PlayerRef.GetAngleZ()ValaNPC.MoveTo(PlayerRef, 80.0*Math.sin(az), 80.0*Math.cos(az), 10.0, 0) Utility.Wait(3.0)Vala.UnequipItem(Saddle)Vala.RemoveItem(Saddle)Vala.EvaluatePackage();END CODEEndFunction;END FRAGMENT;END FRAGMENT CODE - Do not edit anything between this and the begin comment That works pretty good. What must I change to get it to work with the ring? Thank you for your time and your patience. Greetings, Tasheni Edited March 29, 2017 by Tasheni Link to comment Share on other sites More sharing options...
ReDragon2013 Posted March 31, 2017 Share Posted March 31, 2017 (edited) Hi, it seems to me you are in panic mode. Oder es auf deutsch zu sagen: "Du siehst den Wald vor lauter Bäumen nicht!".Before I can help you, you have to give answers: You wrote: next script is working for you Scriptname _ValaChangeToNPC Extends TopicInfo Hidden 1. Who is akSpeaker here? the player, and only the player? 2. What time is the fragment running, if you go into talking with your horse, or if you leave the talk? What horse is enabled while talking to the player? ValaHorse.disable () ValaNPC.enable () 3. You are using two horses now, right? Why do you use an actor Vala and playerRef, it doesnt make sense imho? ObjectReference Property ValaHorse auto ObjectReference Property ValaNPC auto Actor Property Vala auto 4. If you have the saddle as armor, why do you want to use a ring for horse actor changing? You could take a copy of vanilla saddle object and attach the script you need to that object. To make finding of akSpeaker easier, I changed the topicinfo script as follow: Scriptname _ValaChangeToNPC Extends TopicInfo Hidden ; https://forums.nexusmods.com/index.php?/topic/5464827-perk-entry-point-needs-a-script-but-what-to-put-in/page-3 ; Tasheni: "What must I change to get it to work with the ring?" ;BEGIN FRAGMENT Fragment_1 Function Fragment_1(ObjectReference akSpeakerRef) Actor akSpeaker = akSpeakerRef as Actor ;BEGIN CODE ValaHorse.Disable() ValaNPC.Enable() myF_Move(akSpeaker) Utility.Wait(3.0) (ValaNPC as Actor).UnequipItem(Saddle) ValaNPC.RemoveItem(Saddle) (ValaNPC as Actor).EvaluatePackage() akSpeaker.AddItem(Ring) ; give player the ring ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment ;Actor Property PlayerRef Auto ; DO NOT USE !!! ;Actor Property Vala auto ObjectReference Property ValaHorse auto ObjectReference Property ValaNPC auto Armor Property Ring auto Armor Property Saddle auto FUNCTION myF_Move(Actor aRef) ;---------------------------- IF (aRef == Game.GetPlayer()) Debug.Notification("Player speaks to me!") ENDIF float az = aRef.GetAngleZ() float fx = Math.Sin(az) * 80.0 float fy = Math.cos(az) * 80.0 ValaNPC.MoveTo(aRef as ObjectReference, fx, fy, 10.0, 0) ENDFUNCTION Edited March 31, 2017 by ReDragon2013 Link to comment Share on other sites More sharing options...
Tasheni Posted April 18, 2017 Author Share Posted April 18, 2017 (edited) Hi, it seems to me you are in panic mode. Oder es auf deutsch zu sagen: "Du siehst den Wald vor lauter Bäumen nicht!".You're absolutely right, because I'm no coder and not experienced in modding but a stubborn one :smile:Tonight it's too late, but tomorrow I will take a look at this script and test it and then will answer your questions.For now have a very warm thank you and good night. Greetings, Tasheni Edit on April 19: I think you have not read that I solved the problem so far, I wrote at 29.03: Edit: Problem is solved. It is simple the Event OnEquipped(Actor akActor) attached to the ring, that works. I'm happy :smile: :smile: :smile:A special thank you for all your helping - I assure you, I get better every day with your help and my trying. But I owe you some answers and I will give them at the other thread, because I'm working out the next step: https://forums.nexusmods.com/index.php?/topic/5553117-ride-and-talk-horse-script-needs-improvement/ Please be patient and look over there. Thank you. Edited April 19, 2017 by Tasheni Link to comment Share on other sites More sharing options...
Recommended Posts