Difference between revisions of "A beginner's guide, lesson 7 - Using Scripts in Quests"
Jump to navigation
Jump to search
A beginner's guide, lesson 7 - Using Scripts in Quests (edit)
Revision as of 02:12, 31 July 2010
, 02:12, 31 July 2010→At the Cottage: Changing the scripts
imported>Pyrocow2 m (→At the Cottage: clarifying some stuff) |
imported>Pyrocow2 (→At the Cottage: Changing the scripts) |
||
Line 32: | Line 32: | ||
===At the Cottage=== | ===At the Cottage=== | ||
We cannot rely on | We cannot rely on dialogue to progress our quest because the courier is dead. | ||
We | The next stage bump is done via another addition to the main quest script which will check if the player is inside the cottage or not. We can use the [[GetInCell]] function to do this. If you examine the wiki page, you will see that the usage for that function is: | ||
''[ActorID].''GetInCell CellName | |||
The square brackets indicate that providing an ActorID is optional. In this case, the actor ID will be Player. If you're using the base file provided at the beginning of the tutorial, the cell name will be ''BGModCourierCottage''. If not, it will be whatever you called the cottage cell. | |||
When the character enters the cell we want to move to stage 40. We can use the stage to limit when the active part of the script runs. We first need to add stage 40 in the stage tab. Then add this piece of script to the ''GameMode'' block in ''BGM001QuestScript''. | |||
<pre> | <pre> | ||
If (GetStage BGM001 == 30) | If (GetStage BGM001 == 30) | ||
If (Player. | If (Player.GetInCell BGModCourierCottage == 1) | ||
SetStage BGM001 40 | SetStage BGM001 40 | ||
EndIf | EndIf | ||
Line 50: | Line 48: | ||
</pre> | </pre> | ||
In this case, the quest stage acts | In this case, the quest stage acts like a DoOnce type control. During stage 30 of our quest, the game will repeatedly check to see if the player is inside the cottage cell. When the player is finally found inside the cell, the stage will be changed, and this IF block will never be true again (unless the stage is changed back to 30 for some reason). | ||
You can add a journal entry for stage 40 to keep the player updated: | |||
''I found the courier's cottage. I should look around for some clues.'' | |||
Now we need to write a bit of script to handle the two clues we left in the cottage. There's more than one way to do this, but for now we will add a script to each of the clue items, and a couple of new variables to the main quest script. | |||
First, add the two new variables into the main quest script: | |||
Short HasAmulet | |||
Short HasPaper | |||
Then set up the two Object-type scripts. Open the script editor from the Gameplay menu, and make sure to set the script type before saving. | |||
This is the script that will be attached to the torn letter: | |||
<pre> | |||
SCN BGPartialLetterSCRIPT | |||
Begin OnAdd Player | |||
If (BGM001.HasAmulet == 0) | |||
MessageBox "I found a torn document. I should continue to look for more clues." | |||
Else | |||
SetStage BGM001 50 | |||
EndIf | |||
Set BGM001.HasPaper to 1 | |||
End | |||
</pre> | |||
And this is the script that will be attached to the amulet: | |||
<pre> | |||
SCN BGEmbossedAmuletSCRIPT | |||
Begin OnAdd Player | |||
If (BGM001.HasPaper == 0) | |||
MessageBox "I found a strange amulet in the cottage. I should continue to look for more clues." | |||
Else | |||
SetStage BGM001 50 | |||
EndIf | |||
Set BGM001.HasAmulet to 1 | |||
End | |||
</pre> | |||
Add these scripts to the appropriate objects by opening up their details window and selecting them from the Script drop-down menu. | |||
The scripts are very similar. Here's how they work: [[OnAdd]] is a hook that will be called by the object when it is added to an inventory. If you examine the wiki page for OnAdd, you will see that a parameter can be added so that the block is only triggered when the item is added to a particular inventory. In our case, we want that to be the player's inventory, so we used "OnAdd Player". | |||
Then, inside the OnAdd block, we check to see whether or not the player has found the OTHER clue. If the play has NOT found the other clue, we give them a message that tells them to continue looking. If the player DOES have the other clue, they are done looking, and we can bump the quest stage to 50. | |||
After the check, we change the appropriate quest variable to indicate that the player has found that item. | |||
Remember to create stage 50, and then add this journal entry for it: | |||
I should | ''I found some clues for Captain Hubart to work with. I should return to him in Chorrol.'' | ||
Now we can now set up the next bit of interaction with Hubart. | Now we can now set up the next bit of interaction with Hubart. |