Skip to content
alexdunn edited this page Sep 17, 2014 · 6 revisions
Understanding Quest Scripts

There are three types of Papyrus scripts that you can find within a Quest's menus:

  1. Quest Stage Fragments. These scripts are found in the Papyrus Fragment tab of the Quest Stages. They are executed when their corresponding quest stage is activated.
  2. Quest Scripts. These scripts are located in the Scripts tab of a Quest. They are attached to a script and run for as long as the script is active.
  3. Quest Alias Scripts. These scripts are associated with a Reference Alias that has been added to the Quest in its Quest Aliases tab. These scripts are attached to their ReferenceAliases when the quest is activated. They do not interfere with any scripts that might be attached to the base object because these scripts are not actually attached to the base object, but rather a ReferenceAlias that points to that base object. Inside a ReferenceAlias script you can get the base object with self.GetReference().
Using a Story Manager Event Instead of Attaching a Script to an Object

It's good practice to activate scripts through the Story Manager rather than attaching scripts to existing items in the game. This increases mod compatibility. As an example, here we'll create a Story Manager event with a quest that activates a script whenever the player dies.

  1. Object Window -> Character -> Quest. Right click on any Quest -> New.
  • Quest Data
    • Event -> Kill Actor Event
    • Set the ID to a name to be used in the Creation Kit, such as "SkaarPlayerDeathQuest"
  • Quest Stages
    • Right click on left-hand pane -> New. Index -> 0.
    • Select Start Up Stage. This makes this stage the first stage that's activated for this quest.
    • Right click on the Log Entry area -> New. This adds an EMPTY log entry. Leave it this way. This way, it won't show anything in the player's quest log.
    • In the Papyrus Fragment tab, add some code to it: Debug.Notification("Player death quest fired")
  1. Object Window -> Character -> Sm Event Node -> Kill Actor Event
  2. Right click on the very top node -> New Quest Node
  3. Click on the newly created "Stacked Quest Node *"
  4. Put a name for the node in the ID box, such as "SkaarKillPlayerQuestNode". Select "Shares Event". This makes sure the Story Manager doesn't stop on this event when it doesn't qualify for the given situation.
  5. Right click on your Stacked Quest Node -> New Quest -> Select your quest.
  6. Click on your Stacked Quest Node. Right click in the Node Conditions area -> New.
  • Condition Function: GetIsID
  • INVALID: Player
  • Comparison: ==
  • Value: 1.0000
  • Run on: Event Data -> Victim

Now, if you die in the game you'll see this notification at the top of the screen.

Dynamically attach a script to an object from any script in-game
  1. Create a new Quest and set it to fire on Script Event.
  2. Add an alias in the "Quest Aliases" tab for the object that you want to attach the script to when the quest is run. Add the script to the alias.
  3. Create a keyword to identify this event.
  4. Add a Quest Node to the Script Event in SM Event Node. Add your quest to that node. Set the quest's condition to Event Data -> GetIsID -> MyKeyword.
  5. To start your quest and activate the script associated with it, send the quest event from any script in the game:
Keyword.GetKeyword("MyKeyword").SendStoryEvent(None, None, None, 0)
Quest Debugging
  • Show the currently active quest in the in-game console: ShowQuestTargets
Q&A
  • Is there any way to know in a script attached to a Quest Alias what object was added to the player when it was activated via a Player Add Item story event? It is possible to know what Form was added, but not what ObjectReference was added. For this reason, you can't fill a Quest Alias with the ObjectReference that was added to the player. To know which Form was added, add a script to your Quest that responds to Event OnStoryAddToPlayer.