figor888 Posted February 21, 2021 Share Posted February 21, 2021 I have just started getting slightly comfortable with Papyrus but there is still so much I don't understand. I have a script I am working on for a trigger box. The quest is about being recruited into the Morag Tong instead of the Dark Brotherhood. I placed a trigger box outside the Orphan Hall in Riften with the attached script. The idea is that if Grelod is Dead a note gets placed in the player's pocket by an unseen Morag Tong agent. .Otherwise, if Grelod is not killed the quest does not progress. I am sure my script has numerous errors so any guidance is very much appreciated. Scriptname MORA_Agent_gives_Note extends ObjectReference ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Quest Property MyQuest AutoInt Property Stageto Set Auto Event OnTriggerEnter(ObjectReference akTriggerRef)InTrigger=0if akTriggerRef == Game.GetPayer() &&if Alias_GrelodAlias.GetActorReference().GetActorBase().IsDeadGame.GetPlayer().AddItem(Vanilath's_Note, 1, true)MyQuest.SetStage(10)debug.notification("A note was slipped in your pocket")ElseifMyQuest.SetStage(10) endifEndEvent Event OnTriggerLeave(ObjectReference akTriggerRef)if (InTrigger > 0)if akTriggerRef == Game.GetPlayer()InTrigger -= 1debug.notification("You look around but see no one")endif EndEvent Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 21, 2021 Share Posted February 21, 2021 A few corrections. Do note that I have not tested for compilation or function. Also included a shut down state so that the script did not try to continue processing on each re-entry after a successful process. Scriptname MORA_Agent_gives_Note extends ObjectReference ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Quest Property MyQuest Auto Int Property StageToSet Auto Book Property Vanilaths_Note Auto ReferenceAlias Property Alias_GrelodAlias Auto Event OnTriggerEnter(ObjectReference akTriggerRef) If MyQuest.IsRunning() && MyQuest.GetStage() < StageToSet If akTriggerRef == Game.GetPayer() && Alias_GrelodAlias.GetActorReference().GetActorBase().IsDead() akTriggerRef.AddItem(Vanilaths_Note, 1, true) MyQuest.SetStage(StageToSet) debug.notification("A note was slipped in your pocket") Elseif MyQuest.SetStage(StageToSet) EndIf EndIf EndEvent Event OnTriggerLeave(ObjectReference akTriggerRef) If MyQuest.IsRunning() && MyQuest.GetStage() == StageToSet if akTriggerRef == Game.GetPlayer() GoToState("AllDone") ; go to the alldone state so that the script does not try processing again debug.notification("You look around but see no one") endif EndIf EndEvent State AllDone Event OnTriggerEnter(ObjectReference akTriggerRef) EndEvent Event OnTriggerLeave(ObjectReference akTriggerRef) EndEvent EndState Link to comment Share on other sites More sharing options...
ReDragon2013 Posted February 21, 2021 Share Posted February 21, 2021 (edited) Many ways lead to Rom. I think its a good idea to add a condition for running quest like IsharaMeradin wrote. MORA_Agent_gives_Note Scriptname MORA_Agent_gives_Note extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/9677123-scripting-help/ Quest PROPERTY myQuest auto Int PROPERTY StagetoSet = 10 auto ; set to 10 as default value ReferenceAlias PROPERTY Alias_GrelodAlias auto ; see quest above, new created by CK Book PROPERTY myNote auto ; Vanilaths_Note ; "The idea is that: if Grelod is Dead a note gets placed in the players pocket by an unseen Morag Tong agent." ; -- EVENTs -- 3 + "Done" EVENT OnInit() Debug.Trace(" OnInit() - for " +self+ " quest = " +myQuest+ ", Alias = " +Alias_GrelodAlias) ; info only ENDEVENT EVENT OnTriggerEnter(ObjectReference akTriggerRef) IF (myQuest) && myQuest.IsRunning() ELSE RETURN ; - STOP - quest property is missing /or/ the quest is not active, ABORT! ENDIF ;--------------------- IF (akTriggerRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not triggered by the player, ABORT! ENDIF ;--------------------- IF Alias_GrelodAlias.GetActorReference().IsDead() gotoState("Done") ; ### STATE ### akTriggerRef.AddItem(myNote, 1, TRUE) Debug.Notification("A note was slipped in your pocket") myQuest.SetStage( StagetoSet ) ; progress the quest ;;; ELSE ; Grelod is not killed the quest does not progress. ENDIF ENDEVENT EVENT OnTriggerLeave(ObjectReference akTriggerRef) ENDEVENT ;=================== state Done ; now we are sure Grelod is dead, still waiting for player is leaving the trigger ;========= EVENT OnTriggerEnter(ObjectReference akTriggerRef) ENDEVENT EVENT OnTriggerLeave(ObjectReference akTriggerRef) IF (akTriggerRef == Game.GetPlayer() as ObjectReference) Debug.Notification("You look around, but cannot see anyone.") self.DisableNoWait() ; switch OFF the trigger self.Delete() ; remove this object from game ENDIF ENDEVENT ;========= endState Do not forget to fill the properties !! Edited February 21, 2021 by ReDragon2013 Link to comment Share on other sites More sharing options...
figor888 Posted February 21, 2021 Author Share Posted February 21, 2021 Thank you both! Your suggestions were extremely helpful! Link to comment Share on other sites More sharing options...
Recommended Posts