A beginner's guide, lesson 7 - Using Scripts in Quests
This article has been marked by editors as one needing attention. Please see the Talk page for details. If you can update the article, please do so.
A Beginner's Guide - Contents
| ||
---|---|---|
A. Buildings and Structures | B. Scripts, Quests and NPCs | C. Appendices |
Preamble[edit | edit source]
This is the Seventh in a proposed series of Tutorial Lessons aimed at teaching how to mod TES IV: Oblivion aimed at beginners. It will build up into a Complete Modding Course. Don't worry there are no exams, though there is some homework.
Files[edit | edit source]
I have uploaded some files which we will use to accompany the next few tutorials. It contains
A. BGModTutBase.esp This contains a building, a farmhouse, and a dungeon that we will use as sets in lessons 6, 7 and 8. This file is referred to in the text as the BASE files
B. BGModTutPlayTest.esp This is the interim quest mod illustrating the stage you should have reached prior to polishing the mod. This is referred to in the text as the PLAYTEST files
C. BGModAnvilCheat.esp: This is a small optional cheat mod to give users 5000 septims to allow them to follow this tutorial if they have not completed the quest. (See Introduction to lesson 4)
D. A RTF document containing the text for the first 7 lessons (as requested).
Download the files here.
Introduction[edit | edit source]
We have already begun building a quest. This lesson continues directly where Lesson 6 left off. We have set up a cottage which the PC will need to investigate to gain clues to identify who has stolen the deed and key. We have learned how to add dialogue using Topic/Response combinations and conditional statements to limit who gets to say the dialogue.
We have seen how to use a limited amount of scripting to progress our quest. While there is loads more dialogue to include in this part of the quest, we will focus far more on the use of scripting.
Cottage Phase[edit | edit source]
Entering the cottage[edit | edit source]
We cannot rely on dialogue to progress our quest because the courier is dead.
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.
If (GetStage BGM001 == 30) If (Player.GetInCell BGModCourierCottage == 1) SetStage BGM001 40 EndIf EndIf
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.
Finding the clues[edit | edit source]
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:
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
And this is the script that will be attached to the amulet:
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
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 found some clues for Captain Hubart to work with. I should return to him in Chorrol.
Returning the clues[edit | edit source]
Now we can now set up the next bit of interaction with Hubart.
We use the topic BGCluesFound that was added earlier. We want one response if the player has not collected the clues yet, and another for when they have collected the clue. We can use the quest stage as a condition. Set up the responses so that a new topic called BGRedRose is added if we have the clues.
BGCluesFound | |
---|---|
TOPIC TEXT | "Clues" |
RESPONSE |
|
CONDITIONS |
|
OPTIONS |
|
ADD TOPICS |
|
RESULT SCRIPT |
Player.RemoveItem "BGPartialLetter" 1 Player.RemoveItem "BGEmbossedAmulet" 1 Player.RemoveItem "BGCourierKey" 1 |
The script simulates Cpt. Hubart taking the clues and key from us. The "Say Once" option should be checked because we only want this dialogue and script to run once (obviously), but our condition checks won't ensure that as is. We haven't changed the stage or anything like that.
If the player only has one of the clues, this response will be available:
BGCluesFound | |
---|---|
TOPIC TEXT | "Clues" |
RESPONSE | "I need more to work with." |
CONDITIONS |
|
ADD TOPICS | No add topic |
RESULT SCRIPT | No script |
This is the first time we've checked the OR flag on a condition. If any of the OR conditions are true, we basically get a TRUE for that entire set of OR conditions. So if the player has either the amulet or the paper, the stage is 40, and the actor is Cpt. Hubart, this response will show up. The OR statements by themselves would also work if we had BOTH of the objects (both would be true), but because we already would have changed the stage to 50 in that case, the stage condition here fails and eliminates the response. (50 != 40)
Leading the player to the next phase[edit | edit source]
For the Red Rose topic add this response and add a new topic called BGSmith.
BGRedRose | |
---|---|
TOPIC TEXT | "Red Rose Brigade" |
RESPONSE |
|
CONDITIONS |
|
ADD TOPICS |
|
RESULT SCRIPT | No script |
Finally add the Brandy, if you wish. Alternatively we could omit this and allow the player to make his choices
BGSmith | |
---|---|
TOPIC | "Smith" |
RESPONSE |
|
CONDITIONS |
|
ADD TOPICS | No add topic |
RESULT SCRIPT |
Player.Additem "PotionCyrodiilicBrandy" 1 SetStage BGM001 60 |
To complete this section we need to update the journal and move on to Aleswell.
Add this to the Stage 60 journal entry.
Captain Hubart told me that the amulet I found near the courier's body belongs to a gang of thieves named the Red Rose Brigade. He told me that my best chance of finding them is to talk with an ex-member named Smith, who now lives in Aleswell.
Aleswell Phase[edit | edit source]
This is the last section prior to the big show down. We want to set up a disposition based dialogue in which Smith, once he likes you enough, will give you the location and key to the hidden Red Rose Brigade cave system.
We need to create:
- Hideout Key
- NPC called Smith
- Map marker to the exterior of the Cave system
- The Cave system (if you are not using the base files)
Creating Smith[edit | edit source]
First we want set up our NPC.
I used a member of the Thieves Guild as a base. I stripped out his AI, but I left him as a faction member of the Thieves Guild. This will help fellow guild members get a bit of a boost to their disposition.
I have chosen Aleswell as the location for this part of the quest because it is actually a lousy location to use. Aleswell is the setting for an interesting Miscellaneous Quest. In this quest all the inhabitants of the town are invisible. If the user has completed this quest before they load this mod, there will be no problem. However, if this is the first time a player has entered the inn, they will find themselves immediately involved in this quest. We need to make sure our mod interacts with this quest.
We could use some scripts (see lesson 8) to make Smith invisible along with the rest of the citizens. But, as is so often the case, the simplest solution is to just brush over it with a quick bit of dialogue.
We can set up a GREETING for Smith. Here we use the quest stage for the miscellaneous quest called MS47 Zero Visibility. This is the stage where the people of Aleswell become visible.
GREETING | |
---|---|
TOPIC TEXT | GREETING |
RESPONSE | "This is so weird. Everyone here is invisible. I came here to blend in with the crowd.. just my luck." |
CONDITIONS |
|
ADD TOPICS | No add topic |
RESULT SCRIPT | No script |
Information gathering[edit | edit source]
The next bit of the quest is a bit tricky.
First let’s review what we want to do.
We are going to set up a situation in which Smith is reluctant to tell us any information regarding the hideout until he likes us enough.
This is called an Information refusal. We can set up the refusal very easily.
Let’s do that now.
BGRedRose | |
---|---|
TOPIC TEXT | "Red Rose Brigade" |
RESPONSE | "Hey, I'm done with them. That's all I have to say about that." |
CONDITIONS |
|
OPTIONS |
|
ADD TOPICS |
|
RESULT SCRIPT | No script |
The "Info Refusal" flag will make sure that the topic text does not get grayed out, so that the player knows there is still more information available for that topic.
As long as the disposition to the player is less than 90, Smith will give us the brush off when we talk about the Red Rose Brigade.
Somehow we will need to get that disposition up. If the PC is a member of the Thieves Guild, that will help. We can also bribe the NPC or play the disposition game with him. Of course if the player is good with speech craft, that will also get them a bonus. However, I have deliberately set the threshold high because I want to use the brandy idea we set up in Chorrol.
Using choices in dialogue[edit | edit source]
To do this we will set up a bit of dialogue where the player can choose give Smith some brandy.
First, create the choice topics: BGBrandyYes, and BGBrandyNo.
BGBrandyNo | |
---|---|
TOPIC TEXT | "No, sorry." |
RESPONSE | "Aw, that's a shame..." |
CONDITIONS |
|
ADD TOPICS | No add topics |
RESULT SCRIPT | No result script |
This is just a simple piece of dialogue.
The "Yes" choice will be more complicated. We will have to check the player's inventory to see if they have any brandy, and if they do, run a script to change the player's disposition.
BGBrandyYes | |
---|---|
TOPIC TEXT | "I sure do. Here, have some!" |
RESPONSE | "Wonderful! Uh.. what? Oh no! Has the brandy turned invisible, too?!" |
CONDITIONS |
|
ADD TOPICS | No add topics |
RESULT SCRIPT | No result script |
This is the response that the player will get if they have no brandy. You MUST check the "Run on Target" box for the GetItemCount condition in order for this to work. Otherwise, the GetItemCount will check the Smith NPC's inventory! (The player is the target in this case.)
Before making the next response, quickly go back the Smith NPC that you dropped in AleswellInn. Open up the details for the one you dropped - the reference, not the base NPC itself - and name it BGMSmithREF. The Persistent Reference box should also be checked already.
BGBrandyYes | |
---|---|
TOPIC TEXT | "I sure do. Here, have some!" |
RESPONSE | "Wonderful! Cheers!" |
CONDITIONS |
|
ADD TOPICS | No add topics |
RESULT SCRIPT |
BGMSmithREF.ModDisposition Player 15 Player.RemoveItem "PotionCyrodiilicBrandy" 1 |
The ModDisposition function will simply increase the NPCs disposition towards the player by 15. Then one bottle of brandy will be taken from the player's inventory. Then we'll set up the dialogue that leads to these two choices:
BGBrandy | |
---|---|
TOPIC TEXT | "Brandy" |
RESPONSE | "Yeah, I love the stuff. Have you any to spare?" |
CONDITIONS |
|
CHOICES |
|
ADD TOPICS | No add topics |
RESULT SCRIPT | No result script |
The Choices list is right under the Add Topics list. Add the choice topics in the same way you would add an add topic in.
Success[edit | edit source]
By a combination of speech craft, factions, bribes disposition games and brandy gifts the Player should be able to raise the disposition to 90 eventually. This will trigger the next bit of dialogue and send us towards the quest climax. Return to the BGRedRose topic and add this:
BGRedRose | |
---|---|
TOPIC | "Red Rose Brigade" |
RESPONSE |
|
CONDITIONS |
|
ADD TOPICS | No add topic |
RESULT SCRIPT |
SetStage BGM001 70 Player.Additem "BGHideoutKey" 1 ShowMap BGCaveMapMarker |
Map markers[edit | edit source]
The result script bumps the quest stage to 70 and gives the player the key and map marker. In the quest stage section for stage 70 we can add an appropriate journal entry.
Of course before we do this we need to add the MapMarker to the exterior of our cave. The cave system cell is BGmodtSugglersCaveCOPY0000 in the Interiors worldspace. The cave exterior cell is BGTutMCaveExt in the Tamriel worldspace.
Again we can use the door teleport marker to get ourselves to the exterior location. Drop in a MapMarker and give it a Suitable reference name like BGCaveMapMarker.
Journal entry:
Smith gave me a key for the Red Rose Brigade's hideout. I should go to the hideout and see if I can recover my uncle's key and house deed.
Red Rose Hideout Phase[edit | edit source]
This is the climax of our quest. The player will travel to a cave and finally have his showdown with the Red Rose Brigade. We also want to set up a treasure chest as an additional reward. To make the player's task a little harder, we will need to add some goons to fight along the way.
We will need:
- Dungeon/Cave system
- Letter, adding extra clue from Brown about chest
- Several NPC goons
- NPC called Brown
- NPC called Blair
- Key to Brown's cell
- Key to Uncle's House
- First Deed Document
- A special chest
- Some traps, etc.
Dungeon Design Ideas[edit | edit source]
The first thing we will need is a cave system, or dungeon, for the player to delve into. The dungeon pieces are a little harder to work with compared to the standard building interiors, as they are not complete pieces. Instead they slot together, piece by piece, to create whole rooms.
A lot of the CS building parts work this way. Castles, Large Basements, Caves, ruins, and Dungeons are all created using this slotting method. First, make sure you switch on the snap-to guides and the angle rotation guides; it makes life easier. Then open File->Preferences and change the snap-to value to 1. This alters the sensitivity of the snap, giving a closer fit.
The best source of information and design ideas is the game and the CS. You should get into the habit of making note of ‘cool’ locations or quests and looking them up in the CS to see how they work.
The cave system I set up for this tutorial was created in a hurry. I simply copied chambers from other cave systems in the CS and then pasted them together.
It’s funny how you can come full circle. I now realize that the problem with the My First Dungeon tutorial in the Wiki is that it chose to illustrate its techniques using a dungeon. Had the Wiki went for "My First House" instead, it would have been much better off. However, we now know what we are doing, and working on dungeons should be no problem.
I don’t intend to give you a click by click guide to building dungeons. If you get stuck, use the PLAYTEST version as a guide.
Dressing the Dungeon[edit | edit source]
Ok, let’s add some bits to help move our story forward. First, let's write a piece of script in the main quest script's GameMode block to update the quest stage when the player enters the hideout.
If (GetStage BGM001 == 70) If (Player.GetInCell BGmodtSugglersCaveCOPY0000 == 1) SetStage BGM001 80 EndIf EndIf
We can also add a journal entry for stage 80:
I've arrived at the Red Rose Brigade's hideout. If those thieves stole the deed and house key, I should find them here.
Although this first chamber is quite large, I have decided to limit the threat to a single small random creature: a rat or a crab (LL0NuissanceBeast100). Why? Two reasons: I want to be able to escalate my threat, and I want to build suspense.
One of the design choices you will have to make is how to balance risk against reward. You should also try to escalate the threat as the story progresses. For instance, it would be very easy to throw five or six Daedra into the first chamber of our dungeon. But where do you go from there? If you start with too big a threat then you have little room to escalate that threat later. Also, try to give a little thought to the user who has minimum specifications. I’ve seen a few works in progress where they have designed a really cool crypt with 30 or so monsters in it. But I know that on my poor little PC, I’ll get a frame rate of about 3 frames per week. This is not a mod I'll be playing. Bigger doesn’t mean better, more is sometimes less.
The player is also expecting to meet bad guys. Hopefully he will edge his character down into the first chamber fully expecting an army of trolls. I want to disappoint him. I want him to start to think this is easy before we hit him/her with the big stuff.
I also want to set the scene a little. For this I created another corpse, and placed a letter near it which informs the player about the special treasure chest and Brown's imprisonment.
Make the corpse and the letter. I also added a leveled nuisance creature at the far end of the chamber, so that the player will have to deal with the annoyance of a one hit kill creature after picking up the letter.
The text for the letter is:
<font face=5> Dear Smith, <br> <br> I beg of you, please help me. Blair has gone mad. I have been imprisoned.<br> <br> It all began when we attacked the White Horse Courier near Chorrol. It was supposed to be a simple robbery. But when Blair found out that the only loot was a key and a house deed he went berserk. <br> He killed the courier in cold blood. I wanted no part of it.<br> I suggested the gang might do better with me in charge. He accused me of being a double-agent for our rivals, the Torch Gang. Now he's had me locked up because I know how to open his treasure chest. He wants to kill me but he fears the other gang members might turn on him. <br> Please Smith, send help. I have asked one of the gang members who's loyal to me to take this letter to you. I hope he makes it. Blair is watching my every move. <br> <br> Your old friend,<br> Brown
We make and add the following script to the letter
Scriptname BGM001BrownsLetterSCRIPT Begin OnAdd Player If (GetStage BGM001 >= 80) SetStage BGM001 90 EndIf End
Again we can bump the stage and enter another journal entry for stage 90:
I have found a letter from Brown. It appears the Red Rose leader has imprisoned him. Brown has knowledge of a secret treasure. I should try to talk to him.
Finally, I messed about with the lighting to try to create a little more atmosphere. Clearly, caves should be darker than the outside world. Try to use spot lights to pick out areas you want the PC to notice and to hide threats that you want to be a surprise.
The second chamber will contain a single NPC. We want all the Red Rose Brigade NPC’s to act as a team. How? With Factions.
Factions[edit | edit source]
Factions are used in three ways by the game:
- To establish a hierarchy or internal structure for organizations the PC can join
- To group NPCs into teams with similar behaviors.
- To make groups of NPCs that can be used in condition statements. (e.g., when we used the ICFaction to apply conditions to citizens of the Imperial City)
To create a new faction, open up the Faction box from the Character menu. The column on the left lists all of the existing factions. Rick-click in the column and select New. Give the Faction a unique ID, such as BGRedRoseBrigade. Now, add the name to the top: Red Rose Brigade.
The "Hidden from PC" flag at the top basically controls whether or not a player can enter that faction. Check this box.
The Rank Data box in the center controls the ranks and titles within the faction. Note that the ranks are split to offer the choice of alternative titles based on gender. In the case of our faction, these have no meaning at all.
For us, the Interfaction Relations box at the bottom will be most useful.
It controls the disposition of members of one factions towards members of another faction. The Mod value is a numerical modifier ranging from -100 to +100. This modifier is applied to all members of the group.
The results are cumulative. Let’s say we decide that the Red Rose Brigade is closely affiliated with the various Bandits who occupy Tamriel. We can add a modifier of, say, +70 to that group. Create a new entry for the Bandit faction, and set the modifier to 70. From now on every member of the Red Rose faction will add 70 to there disposition towards bandits. We can add as many groups as we like.
We want the Red Rose members to be openly hostile to the PC. For this we can use PlayerFaction, which has a solitary member: the player. We can adjust the disposition for this faction to -100. This means they will attack the player on sight.
We also want Red Rose members to be friendly with one another. Add another disposition entry for the Red Rose faction itself, with a relatively high disposition value.
Finally, we need to add a separate faction for Brown, so that (1) the Red Rose members don't kill their prisoner and (2) the prisoner won't attack the player. Name it something like BGRRPrisoner. For the prisoner's faction, add a positive disposition towards the player. Then go back to the Red Rose Brigade faction and add a positive disposition towards the prisoner's faction.
Enemy NPCs[edit | edit source]
Create an NPC. I used the BanditMelee character as a base template. This character already comes with leveled item lists (even though they will appear to be naked in the preview render).
The level of an NPC is controlled by the flags and boxes to the left of the character box.
We can make two choices:
Level: In this option we select a specific level for the NPC. The advantage is that we can control exactly how challenging an NPC should be. This is ideal if we have a particular reward which we feel should be earned only by well developed player characters. Suppose you design a one hit kill sword. This is a big reward. The player should have to earn this reward by defeating a big boss.
On the other hand, you might even want to make an NPC particularly weak, which you could easily do by setting a low level.
The disadvantage is that if you set an NPC to level 40, for example, only a small number of players will meet this challenge. Many may simply unplug your mod.
PC Level Offset: This is one of the more controversial developments in Oblivion. Many Morrowind veterans have been particularly vocal in their criticism of this technique. The advantage is that no matter what level your PC is at you will meet a decent challenge which will test your PC. It allows PC's of all levels to access quests. However, it has disadvantages as well. This approach does mean that some times the risk does not match the reward.
For this tutorial I have chosen to use the PC Level Offset method as this is the Oblivion norm. It is, of course, up to each individual designer to choose what they want to do. I would suggest that whatever method you choose is consistent throughout the mod. If you mix and match you could have a situation where the first few goons are 10 levels above the end boss, or where after defeating a series of level 2 goons you suddenly encounter a level 30 boss.
We also want this first goon to be a little bit easier than those coming up so lets set the value to -2 levels using the offset box. The bandit already has a suitable leveled inventory.
The central chamber will contain 3 NPCs. Remember to add the Red Rose Faction to their faction lists and delete the others. I used more bandits as a base for these. I also set the PC level offset to -1.
Finally, I messed around with the lighting a bit. I wanted to give stealthy players a chance to sneak. I removed the lighting from the linking corridor and the entrance.
The Final Chamber[edit | edit source]
Setting up the resources[edit | edit source]
This consists of a large chamber with two antechambers. In the first antechamber we create a cell by placing a door in the corridor. We can use this to house NPC BGBrown. Remember, Brown must be added to the separate prisoner faction.
Finally, we create Blair. He is our Boss. I made his level offset +2. I am going to say very little about this NPC, because this is where you get to have the most fun making your own bad guy. Once created, add the cell door key to his inventory. Make the cell door locked, and set it to ‘Needs a key‘.
Add BGTopViewKey (the key to the house) to Blair's inventory. Now create an "uncertified" deed and add this to his inventory.
BGTopViewUncertifiedDeed:
<font face=5> <BR> <BR> This document hereby states that the bearer is the sole owner and possessor of the domicile currently known as Top View. Said domicile is located North of the Imperial City and South of the city of Bruma in the territory known as Cyrodiil.<BR> <BR> The bearer has full ownership rights to all of the structures, flora and land within the property borders as defined in the Tamriel Construction Charter. The bearer is responsible for all matters pertaining to or occurring on said property.<BR> <BR> This document also empowers the bearer transfer rights to reassign the property as he sees fit. The bearer may amend this document to rename the manor by submitting the proper forms and payments to the Tamriel Construction Charter and by filing duplicate forms with the Documents Division of the Imperial City Archives.<BR> THIS DOCUMENT MUST BE REGISTERED IN THE IMPERIAL CITY BY A QUALIFIED NOTARY PUBLIC TO GAIN LEGAL FORCE.<BR>
This document explains why we have to return to the Imperial City.
Both Blair and Brown will need special AI packages to get them to work properly.
I also want to make sure that the player, no matter how good they are at sneaking, will be forced to confront Blair. How do we do this? Easy, we script it. We will also design the quest so that you will have to kill Blair to move on to the next stage. We can also do this through scripts.
Setting up Blair[edit | edit source]
Add a new variable to the main quest script called BlairGreeted. Then attach this script to the Blair NPC:
SCN BGBlairSCRIPT Begin OnDeath SetStage BGM001 95 End Begin GameMode If BGM001.BlairGreeted == 0 If GetDistance Player <= 500 StartConversation Player GREETING EndIf EndIf End
Then set up the new GREETING.
GREETING | |
---|---|
TOPIC TEXT | "GREETING" |
RESPONSE | "I heard you've been snooping around. Prepare to die!" |
CONDITIONS |
|
ADD TOPICS | No add topics |
RESULT SCRIPT |
Set BGM001.BlairGreeted to 1 StartCombat Player |
In order for this to actually work, we need to change Blair's aggression stat so that he doesn't attack the player on sight (the topic result script will initiate combat for us). Open up the Blair NPC form, and click the AI button. In AI Attributes, set Aggression to 0.
When the PC kills Blair, we can also update the journal by adding an entry for stage 95.
I have killed Blair. I should search his body for the deed and house key. I should also see if he has a key to Brown's cell. I can then return to the Imperial City to see Vilanus.
Setting up Brown[edit | edit source]
We can set up an optional reward for players who choose to free Brown from his cell. Open up Brown's form and make sure he doesn't have a high aggression level, just to make sure Brown won't attack the player on sight. It should at least be lower than whatever positive disposition you gave the prisoner faction towards the player, but it wouldn't hurt to just set it to 0.
Then set up a greeting for Brown:
GREETING | |
---|---|
TOPIC TEXT | GREETING |
RESPONSE | "Please, please, don't kill me! I had no hand in this. Just let me go." |
CONDITIONS |
|
ADD TOPICS |
|
RESULT SCRIPT | No result script |
Each response will advance the quest to a different stage, which will have appropriate journal entries and result scripts.
BGBrownChoice1 | |
---|---|
TOPIC TEXT | You can go. |
RESPONSE | "Thank you! Thank you! The code is one, four, seven." |
CONDITIONS |
|
ADD TOPICS | No add topics |
RESULT SCRIPT | SetStage BGM001 100 |
For stage 100, add the following journal entry:
Brown gave me the code for the combination lock on the chest. I need to enter 1-4-7 to unlock it. Once I've done that, I will need to go see Vilanus Villa in Imperial City. Vilanus will need to transfer ownership of my uncle's house to me.
BGBrownChoice2 | |
---|---|
TOPIC TEXT | No. |
RESPONSE | "You'll regret this!" |
CONDITIONS |
|
ADD TOPICS | No add topics |
RESULT SCRIPT | SetStage BGM001 101 |
Add another entry for stage 101:
I left Brown to rot in his cell. I need to go see Vilanus Villa in Imperial City so he can transfer my uncle's property to me.
The stage result script is used to remove the quest object status from a number of items which are no longer needed and which the PC can now dispose of. This should be applied to BOTH of the possible stages. (Use whichever IDs you chose when creating these items.)
SetQuestObject BGHideoutCELLKey 0 SetQuestObject BGHideoutKey 0 SetQuestObject BGBrownLetter 0 SetQuestObject BGPartialLetter 0
We will need to look at altering Brown's behavior for the final release. We will need to add some AI in the next lesson to get him to run away.
Scripting the chest[edit | edit source]
What we need to look at now is another hefty bit of scripting which will control the combination lock on the treasure chest.
Here it is in its entirety. Look through it and try to work out what it is doing.
It controls a chest with a three digit combination style lock.
SCN BGBlairsChestSCRIPT Short Button1 Short Button2 Short Button3 Short Frame Short Unlocked Short GoldCount Begin OnActivate If Unlocked == 1 Activate Else ;Begin combination menu Set Frame to 1 EndIf End Begin GameMode If Frame != 0 ;Get the first digit If Frame == 1 MessageBox "First digit" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" Set Frame to 2 EndIf ;Save first digit entered, get the second digit If Frame == 2 Set Button1 to GetButtonPressed If Button1 == -1 Return EndIf MessageBox "Second digit" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" Set Frame to 3 EndIf ;Save second digit entered, get third digit If Frame == 3 Set Button2 to GetButtonPressed If Button2 == -1 Return EndIf MessageBox "Third digit" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" Set Frame to 4 EndIf ;Save third digit entered, then check combination. If Frame == 4 Set Button3 to GetButtonPressed If Button3 == -1 Return EndIf If Button1 == 1 && Button2 == 4 && Button3 == 7 ;Correct combination result MessageBox "The combination pad unlocks." Set Unlocked to 1 Set Frame to 0 Else ;Bad combination result MessageBox, "Suddenly your pockets feel a bit lighter." Set Frame to 0 If (Player.GetItemCount "gold001") >= 100 Player.RemoveItem "gold001" 100 AddItem "gold001" 100 Else Set GoldCount to Player.GetItemCount "gold001" Set GoldCount to GoldCount - 1 Player.RemoveItem "gold001" GoldCount AddItem "Gold001" GoldCount EndIf EndIf ;Correct combo EndIf ; Frame 4 EndIf; Frame != 0 End
Now it's time to wrap up our little adventure. We move the scene back to the Imperial City.
Imperial City Phase Two[edit | edit source]
In this phase the player will return to Vilanus, who will set about transferring the ownership of the property to you. We will add a delay so that the player has to wait 24 game hours before the process is finished.
We need:
- A completed version of the deed
- The prize house
- A map marker for the house
To set up the prize house, go to the interior cell BGmodtut4, which is the interior of the house. It has three doors. One leads to the basement. The other two are linked to the exterior. Lock the exterior doors and set the ownership to our old buddy BGDummyOwner. Set the interior cell ownership to BGDummyOwner as well.
New dialogue[edit | edit source]
We begin by adding more dialogue for Vilanus Villa.
First, set up three new topics:
- BGDeedCheck
- BGRecoverYes
- BGRecoverNo
Then add a new greeting:
GREETING | |
---|---|
TOPIC TEXT | "GREETING" |
RESPONSE | "Hello, have you managed to recover the key and deed?" |
CONDITIONS |
|
ADD TOPICS | No add topics |
CHOICES |
|
RESULT SCRIPT | No result script |
Then edit the choices.
BGRecoverNo | |
---|---|
TOPIC TEXT | "No, not yet." |
RESPONSE | "I can't help you until you've found both the key and the deed." |
CONDITIONS |
|
ADD TOPICS | No add topics |
RESULT SCRIPT | No result script |
BGRecoverYes | |
---|---|
TOPIC TEXT | "Yes. Here they are." |
RESPONSE | "Excellent. I will take the deed to the property registrar today. Come back tomorrow, the transfer should be complete by then." |
CONDITIONS |
|
ADD TOPICS |
|
RESULT SCRIPT |
Player.RemoveItem BGTopViewUncertifiedDeed 1 SetStage BGM001 110 |
Stage 110 Journal Update:
Vilanus told me that he is going to take the deed to the property registrar, and that I should check back with him tomorrow when the transfer is complete.
We want to set up a delay of one day before we can collect the finished documents. This gives us an excellent opportunity to look at and practice timers.
Timers[edit | edit source]
Timers are another bit of scripting that gets used again and again. The game uses a number of global variables to report the progress of time.
The two most used are:
We can use the seconds passed to establish timed events. GetSecondsPassed returns a float value, so we must set up a float type variable to save it in.
Here is an example script that takes 10 Septims from the player and then gives them back 25 seconds later.
Scriptname ExampleTimerScript float Timer short State Begin GameMode If State == 0 Set Timer to 25.0 Set State to 1 Player.RemoveItem "gold001" 10 ElseIf State == 1 If Timer > 0 Set Timer to Timer - GetSecondsPassed Else Player.AddItem "gold001" 10 Set State to 2 EndIf EndIf End
If you're writing a script where you're only interested in the number of in-game days that have passed, you can use GameDaysPassed instead (which is a short).
In the quest script add three short variables called State, StartDay, and DeedFinished.
Then add this to the GameMode block:
If GetStage BGM001 == 110 If State == 0 Set StartDay to GameDaysPassed Set State to 1 ElseIf State == 1 If GameDaysPassed > StartDay Set DeedFinished to 1 Set State to 2 EndIf EndIf EndIf
This piece of script goes through three states:
- Stage 110 has begun. Initialize the StartDay value, and change to second state.
- StartDay has been set. Check to see if the value of the current in-game date is more than StartDay (this will be true on any day after the starting day, including the first day after, which is what we want). Change to third state.
- Finished. Do nothing.
More dialogue[edit | edit source]
The DeedFinished variable will tell us when the game day is passed and the deed should be finished. We can use this variable for the next piece of dialogue. There will be two possible responses for this topic. One for when the deed is finished, and one for when it's not.
BGDeedCheck | |
---|---|
TOPIC TEXT | "House Deed" |
RESPONSE | "It should be finished by tomorrow. Check back with me then." |
CONDITIONS |
|
ADD TOPICS | No add topics |
RESULT SCRIPT | No result script |
BGDeedCheck | |
---|---|
TOPIC TEXT | "House Deed" |
RESPONSE |
|
CONDITIONS |
|
ADD TOPICS | No add topics |
RESULT SCRIPT |
Player.AddItem BGTopViewDeed 1 SetStage BGM001 120 |
The new deed, BGTopViewDeed, is just a copy of the old one without the very last line about needing to get it notarized. You do NOT need to make this a quest item. We don't need to force the player to keep it in their inventory.
Journal Update for Stage 120:
The paperwork is finished and I now have a certified deed for the Top View Cottage. I should go visit the property.
Finishing up[edit | edit source]
Add a new map marker outside of the house (in Tamriel->TopViewCottage). Call it BGTopViewMapMarker. Then edit the names of the two exit doors, to something like BGTVDoor1 and BGTVDoor2.
Then add the following quest stage result script for stage 120:
BGTVDoor1.SetOwnership BGTVDoor2.SetOwnership SetCellOwnership BGModTut4 SetCellOwnership BGModTu4Base ShowMap BGTopViewMapMarker
This script transfers ownership of the house doors and cells to the player, and then enables the map marker.
We then complete the quest script with a final block to check when the PC arrives at the house.
If GetStage BGM001 == 120 If Player.GetInCell BGModTut4 || Player.GetInCell BGModTu4Base SetStage BGM001 130 EndIf EndIf
For this stage, you can check the Quest Complete box. Remember, this does not truly end the quest. To do that we must use the StopQuest function.
The final journal entry:
I have reached Top View. I am now free to explore my new home.
Finally, we add this quest stage result script to stage 130.
ModPCFame 1 SetEssential BGVilanusVilla 0 SetEssential BGMSmith 0 SetEssential BGCptHubart 0 StopQuest BGM001
The SetEssential commands remove the essential status from all of the essential characters we created earlier. ModPCFame boosts the player's fame by 1 point (optional). StopQuest stops the quest from running, and disables all of its dialogue.
So there you have it. A completely functional quest.
However, if we really want to wow the public with our release we will need to add some AI to our NPC’s and look at our options regarding Audio and Lip Sync, and that’s what lesson 8 will be about.
Till then, happy modding!
Thanks[edit | edit source]
Thanks to dtom, who posted the guide on the Elder Scrolls Forums that this article is based on.