Difference between revisions of "A beginner's guide, lesson 7 - Using Scripts in Quests"

→‎Imperial City Phase Two: Editing dialogue and script
imported>Pyrocow2
m (→‎At the Cottage: adding an extra piece of response text)
imported>Pyrocow2
(→‎Imperial City Phase Two: Editing dialogue and script)
 
(21 intermediate revisions by the same user not shown)
Line 30: Line 30:
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.  
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.  


==At the Cottage==
==Cottage Phase==
 
===Entering the cottage===
We cannot rely on dialogue to progress our quest because the courier is dead.
We cannot rely on dialogue to progress our quest because the courier is dead.


Line 53: Line 53:
  ''I found the courier's cottage. I should look around for some clues.''
  ''I found the courier's cottage. I should look around for some clues.''


===Finding the 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.
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.


Line 101: Line 102:
  ''I found some clues for Captain Hubart to work with. I should return to him in Chorrol.''
  ''I found some clues for Captain Hubart to work with. I should return to him in Chorrol.''


===Returning the clues===
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.  


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.
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.


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
Line 167: Line 169:
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)
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)


For the Red Rose topic add this response and add a new topic called BGSmith.
===Leading the player to the next phase===
For the Red Rose topic add this response and add a new topic called ''BGSmith''.


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
Line 184: Line 187:
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsId BGCptHubart == 1
* GetIsId 'BGCptHubart' == 1
* GetStage BGM001 == 50
* GetStage 'BGM001' == 50
|-
|-
!  ADD TOPICS
!  ADD TOPICS
Line 210: Line 213:
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsId BGCptHubart == 1
* GetIsId 'BGCptHubart' == 1
* GetStage BGM001 == 50
* GetStage 'BGM001' == 50
|-
|-
!  ADD TOPICS
!  ADD TOPICS
Line 241: Line 244:
* The Cave system (if you are not using the base files)
* The Cave system (if you are not using the base files)


===Creating Smith===
First we want set up our NPC.   
First we want set up our NPC.   


Line 272: Line 276:
|}
|}


===Information gathering===
The next bit of the quest is a bit tricky.  
The next bit of the quest is a bit tricky.  


Line 314: Line 319:
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.
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===
====Using choices in dialogue====
To do this we will set up a bit of dialogue where the player can choose give Smith some brandy.
To do this we will set up a bit of dialogue where the player can choose give Smith some brandy.


Line 427: Line 432:
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.
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===
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:
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:


Line 460: Line 466:
</pre>
</pre>
|}
|}
 
===Map markers===
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.
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.


Line 473: Line 479:


==Red Rose Hideout Phase==
==Red Rose Hideout Phase==
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.


Objectives: ''This is the climax of our quest. The player will travel to a cave/dungeon, and will finally have his show down with the boss villain. We also want to set up a treasure chest as an additional reward. To make the players task a little harder, we will need to add some goons to fight along the way.''
We will need:
 
We will need  


* Dungeon/Cave system
* Dungeon/Cave system
Line 483: Line 488:
* NPC called Brown
* NPC called Brown
* NPC called Blair
* NPC called Blair
* Key to Browns cell
* Key to Brown's cell
* Key to House
* Key to Uncle's House
* First Deed Document
* First Deed Document
* A special chest.
* A special chest
* Some traps etc.
* Some traps, etc.


===Dungeon Design Ideas===
===Dungeon Design Ideas===


The first thing we will need is a cave system or Dungeon for the player to delve. 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.  
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. Firstly make sure you switch on the snap to guides and the angle rotation guides, it makes life easier. Then open files/preferences and alter the snap to value to 1.
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.


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.


Again the best source of information and design ideas is the game and the CS. You should by now of got into the habit of making note of ‘cool’ locations and looking them up in the CS.  
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.


The cave system I have set up for this tutorial, was created in a hurry. I simply visited other cave systems in the CS, and cut and pasted chambers that I then linked 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.  


It’s funny how you can come full circle. I now realise that the problem with the My First Dungeon tutorial in the Wiki is that it choose 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 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.
 
As I have said the tutorial's dungeon supplied in the files is not the greatest dungeon in the world. Far from it. It is a simple multi chamber linear cave system. This means the PC has very little choice how he progresses. He must make his way through each room, and face each challenge. This is both an advantage and a disadvantage. If I was building this cave system for ‘Full Mod’, I must admit I would have spent much more time on it.
 
It would for instance have been nice to give players alternative paths, so those who prefer to avoid ‘hack and Slash’ trawling could sneak pat a few goons. Of course you would then have to set up a few more traps to keep them on their toes. One of things I have been disappointed about has been the lack of intelligent traps in Oblivion. By that I mean traps and puzzles where you have to stop and think of a solution. The game mechanics don’t easily lend them selves to this but it is a shame.
 
I don’t intend to give you a click by click, bit by bit guide to building dungeons. If you get stuck use the PLAYTEST version as a guide.  


===Dressing the Dungeon===
===Dressing the Dungeon===


Okay, let’s add some bits to help move our story forward. First let’s add an Xmarkerheading close to the interior door. We can then use the marker as a reference in an addition to our growing quest script.
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)
<pre>
     If (player.GetDistance BGRRCaveMarkerRef <= 300)
If (GetStage BGM001 == 70)
      SetStage BGM001 80
     If (Player.GetInCell BGmodtSugglersCaveCOPY0000 == 1)
          SetStage BGM001 80
     EndIf
     EndIf
  EndIf
EndIf
</pre>


We can also update the Journal
We can also add a journal entry for stage 80:


''I've Arrived at the Red Rose Brigades Hideout. I will need to move cautiously. I need that house key.''
''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.
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 threat 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 deadra into the first chamber of our dungeon. However, the question is then where do we 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 a week. Consequently this is not a mod I’ll be playing. Bigger doesn’t mean better, more is sometimes less.  
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.
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 near it a letter which informs them about the special treasure chest and Brown's imprisonment.
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 a corpse and the letter. Don’t give the corpse too much inventory, after all this is a freebee. I also added a leveled nuisance creature at the far end of the chamber; this should allow the PC to get to the corpse and then have to deal with the annoyance of a one hit kill creature.
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
The text for the letter is:
<pre><br>
<pre><font face=5>
<font face=5><br>
Dear Smith,
Dear Smith,
<br>
<br>
<br>
<br>
I beg of you, please help me. Blair has gone mad. I have been imprisoned<br>
I beg of you, please help me. Blair has gone mad. I have been imprisoned.<br>
<br>
<br>
It all began when we attacked the White Horse Courier near Chorrol.
It all began when we attacked the White Horse Courier near Chorrol.
It was supposed to be a simple robbery. But when Blair found that the only treasure
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.  
was a key to a house and a deed which had to be registered in the Imperial City he went beserk.  
<br>
<br>
He killed the courier in cold blood. I wanted no part of it.<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
I suggested the gang might do better with me in charge. He accused me of being a
member of our rivals, the Torch Gang. Now he's had me locked up because I know how
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.
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 gang member loyal to me to take this
letter to you. I hope he makes it. Blair is watching my every move.
<br>
<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>
<br>
Your old friend,<br>
Brown</pre>
Brown</pre>


We make and add the following script to the letter
We make and add the following script to the letter


<pre>Scriptname BGM001BrownScript
<pre>Scriptname BGM001BrownsLetterSCRIPT


Begin OnAdd Player
Begin OnAdd Player


   If (GetStage BGm001>= 80)
   If (GetStage BGM001 >= 80)
     SetStage BGm001 90
     SetStage BGM001 90
   EndIf
   EndIf


End</pre>
End</pre>


Again we can bump the stage and enter another journal entry for stage 90
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.''
''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 normal world. Try to use spot lights to pick out the bit you want the PC to see and to hide threats you want to be a surprise.
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? Factions are the answer.
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===
===Factions===


Factions are used in three ways by the game. Firstly they are used to establish a hierarchy or internal structure for organisations the PC can join. Secondly they are used to group NPC’s into teams with similar behaviours; these teams will act to protect each other when threatened. The final use of factions is to collect NPC’s together to allow grouped conditions statements.
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 opens up the faction box from the menu. In the column on the left is a list of all the existing factions. Rick click and select new. Give the Faction a unique name. Say BGRedRoseBrigade. Now, add a name to the top. Red Rose Brigade.  
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 flag at the top which reads hide from player, basic controls whether or not a player can enter the faction or not. Leave this as hidden.
The "Hidden from PC" flag at the top basically controls whether or not a player can enter that faction. Check this box.


The central box controls the ranks and titles within the faction. Note 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. However, since this is only chance we will get to look at lets set up a simple three tier structure for practice.
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.


The final box at the bottom is the most useful.
For us, the ''Interfaction Relations'' box at the bottom will be most useful.
   
   
It controls the disposition of a group to other factions or groups. Again it’s the standard right click new to add a group from the existing list into the disposition modifier box. You need add a numerical modifier ranging from +100 to -100. This modifier is applied to all members of the group.  
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. Rick  click select new, scroll down and find Bandit faction. Select it. Now alter 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.  
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 member to be openly hostile to the PC. This is achieved because there is a faction called the PlayerFaction which has a solitary member, the PC. We can adjust the Red Rose disposition for this faction to -100. This means they will hate us and attack on site.
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.


Add one more disposition entry to make the Red Rose members friendly with other members of their own faction.
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.


Create an NPC. I used the BanditMelee character as a base Template. This character already comes with leveled armour etc. Although the will appear to be naked in the render window.
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.


I also popped in a chest, renamed it so I could alter it contents and add a few coins. The level of a NPC is controlled by the flags and boxes to the left of the character box.  
===Enemy NPCs===
Create an NPC. I used the BanditMelee character as a base template. This character already comes with [[Leveled_Item|leveled item lists]] (even though they will appear to be naked in the preview render).


We can make two choices.
The level of an NPC is controlled by the flags and boxes to the left of the character box.  


'''Level to a value''': In this option we select a pre ordained level for the NPC. The advantage is that we can control how tough a NPC is, and therefore the challenge set by that enemy. This is ideal if we have a particular reward which we feel should be earned by high ranking, or indeed low ranking PC’s. 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.
We can make two choices:


Equally, perhaps the reward is a few coins. Then it may be appropriate to set a simple challenge.
'''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.  


The disadvantage is that if you set an NPC at level 40, only a small number of players will meet this challenge, and many may simple unplug your mod.  
On the other hand, you might even want to make an NPC particularly weak, which you could easily do by setting a low level.


'''Level against PC''': 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 access to all PC’s and does not exclude any. However, it has disadvantages as well. This approach does mean that some times the risk does not match the reward.  
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.  


For this tutorial I have chosen to use the Level against PC method as this is the Oblivion norm. It is of course a matter for each designer to choose. I would suggest that what ever method you choose is consistent through out the mod. If you mix and match you could have the situation where the first goons is 10 levels above your boss, or a situation where after defeating a series of level 2 goons you suddenly encounter a level 30 boss.
'''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.  


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.
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.


The main central chamber will contain 3 NPC’s. Again add the Red Rose Faction to their faction list and delete the others. I used more bandits as a base for these.  
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.


I also set the offset at -1.  
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 a stealthy player a chance. I remove the lighting from the linking corridor and close to the entrance.
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==
==The Final Chamber==
===Setting up the resources===
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.


This consists of a large chamber with two ante chambers. In the first ante chamber we create a cell by placing a door in the corridor. We can use this to house NPC BGBrown. I used the Bandit Boss as a model, but removed his factions.. Remember do not make Brown a member of the 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‘.  


Final we create Blair. He is our Boss. I made him +2 above the PC.  I am going to say very little about this PC, because here is where you get to have the most fun making your own bad guy. Once created
Add ''BGTopViewKey'' (the key to the house) to Blair's inventory. Now create an "uncertified" deed and add this to his inventory.  
 
Add the key to Browns cell door. Make the cell door, locked and set it to ‘Needs a key‘.
 
You will also need to set up the Prize house.
Go to the interior cell BGmodtut4 which is the interior of the house. It has three door. 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 BGDummyPlayer.
Set the interior cell ownership to BGDummyPlayer as well.
Add the BGTopViewKey to the house to Blairs inventory. Now create a ’uncertified’ deed and add this to his inventory.
 
<pre>Deed Text.


''BGTopViewUncertifiedDeed'':
<pre>
<font face=5>
<font face=5>
<BR>
<BR>
Line 646: Line 641:
<BR>
<BR>
The bearer has full ownership rights to all of the structures, flora and land within
The bearer has full ownership rights to all of the structures, flora and land within
the property borders as defined in the Tamerial Construction Charter. The bearer is
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>
responsible for all matters pertaining to or occurring on said property.<BR>
<BR>
<BR>
This document also empowers the bearer transfer rights to reassign the property as he
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
sees fit. The bearer may amend this document to rename the manor  by submitting the
proper forms and payments to the Tamerial Construction Charter and by filing
proper forms and payments to the Tamriel Construction Charter and by filing
duplicate forms with the Documents Division of the Imperial City Archives.
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.</pre>
THIS DOCUMENT MUST BE REGISTERED IN THE IMPERIAL CITY BY A QUALIFIED NOTARY PUBLIC TO GAIN LEGAL FORCE.<BR></pre>


This document explains why we have to return to the Imperial City.
This document explains why we have to return to the Imperial City.


Both Blair and Brown will need special AI’s to get them to work properly.  
Both Blair and Brown will need special AI packages to get them to work properly.  


I also wanted to make sure the player no matter how good a sneak is forced to confront Blair. How do we do this. Easy we script it. We also have set the adventure up so that you have to kill Blair to move the quest on.
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.


How does the game know he is dead? Scripts of course. We can combine both functions into a single script.
===Setting up Blair===
 
Add a new variable to the main quest script called ''BlairGreeted''. Then attach this script to the Blair NPC:<br>
<pre>Scriptname BGBlairDeathScript
<pre>
 
SCN BGBlairSCRIPT
Short DoOnce


Begin OnDeath
Begin OnDeath
 
SetStage BGM001 95
  SetStage BGM001 95
 
End
End


Begin GameMode
Begin GameMode
If BGM001.BlairGreeted == 0
If GetDistance Player <= 500
StartConversation Player GREETING
EndIf
EndIf
End
</pre>


  If ( GetStage BGM001<95 ) && ( DoOnce == 0 )
Then set up the new ''GREETING''.
 
    If ( Player.GetDistance BGBlairRef <= 500)
      StartConversation Player BGMBlairGreet
      Set DoOnce to 1
    EndIf
 
  EndIf
 
End</pre>
 
We now have to set up the conversation. We use the conversation tab rather than the topic tab. Also set this conversation up as a goodbye, to terminate any further discussion.


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
!colspan=2| '''GREETING'''
|-
|-
CONVERSATION
TOPIC TEXT
BGMBlairGreet
"GREETING"
|-
|-
!  RESPONSE
!  RESPONSE
|   
"I heard you've been snooping around. Prepare to die!"
* You are a fool for coming here. Now prepare to die.
|-
|-
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsId  BGBlair == 1
* GetIsID 'BGBlair' == 1
* GetStage BGM001 >= 80
* GetStage 'BGM001' >= 80
|-
|-
!  ADD TOPICS
!  ADD TOPICS
|   
''No add topics''
* (none)
|-
|-
!  RESULT SCRIPT
!  RESULT SCRIPT
|
|
* (none)
<pre>
|}  
Set BGM001.BlairGreeted to 1
StartCombat Player
</pre>
|}
 
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 then update the journal
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 my house key. I should also see if he has a key so I can release Brown. I can then return to the Imperial City to see Vilanus.''
''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.''


We have set the quest up so that as well as the reward of the house the player can also get access to the treasure chest if they get the combination this is dictated by setting up a choices dialogue through Brown.  
===Setting up Brown===
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.


Initially we set up a greeting.
Then set up a greeting for Brown:


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
!colspan=2| '''GREETING'''
|-
|-
!  TOPIC
!  TOPIC TEXT
|   
|  GREETING
* GREETING
|-
|-
!  RESPONSE
!  RESPONSE
|   
"Please, please, don't kill me! I had no hand in this. Just let me go."
* Please, Please, don't kill me. I just want to get away from here. Please let me go
|-
|-
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsId BGBrown == 1
* GetIsID 'BGBrown' == 1
* GetStage BGM001 >= 95
* GetStage 'BGM001' >= 95
|-
|-
!  ADD TOPICS
!  ADD TOPICS
|   
|   
* BgBrownChoice1
* BGBrownChoice1
* BgBrownChoice2
* BGBrownChoice2
|-
|-
!  RESULT SCRIPT
!  RESULT SCRIPT
|   
''No result script''
* (none)
|}
|}
The positive response info for BGBrownC1 gives a stage boost, the negative one does not.
 
Each response will advance the quest to a different stage, which will have appropriate journal entries and result scripts.


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
!colspan=2| '''BGBrownChoice1'''
|-
|-
!  TOPIC
!  TOPIC TEXT
|   
You can go.
* BGBrownC1
|-
|-
!  RESPONSE
!  RESPONSE
|   
"Thank you! Thank you! The code is one, four, seven."
* Thank You! Thank you! The code is 1 4 7
|-
|-
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsId BGBrown == 1
* GetIsID 'BGBrown' == 1
* GetStage BGM001 >= 95
* GetStage 'BGM001' >= 95
|-
|-
!  ADD TOPICS
!  ADD TOPICS
|
| ''No add topics''
* (none)
|-
|-
!  RESULT SCRIPT
!  RESULT SCRIPT
|   
|  <pre>SetStage BGM001 100</pre>
<pre>SetStage BGM001 100</pre>
|}
|}


We update the journal and run a bit of script as a result
For stage 100, add the following journal entry:
 
''Brown has given me the code to the Combination Chest I need to enter the numbers 1 4 7 to unlock it. Once I've done that I will need to go and see Vilanus Villa in the Imperial City. Vilanus will need to transfer ownership of my uncle's house to me.''
 
The 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.


  SetQuestObject BGHideoutCELLKey 0
  ''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.''
  SetQuestObject BGHideoutKey 0
SetQuestObject BGBrownLetter 0
SetQuestObject BGPartialLetter 0


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
!colspan=2| '''BGBrownChoice2'''
|-
|-
!  TOPIC
!  TOPIC TEXT
|   
No.
* BGBrownC2
|-
|-
!  RESPONSE
!  RESPONSE
|   
"You'll regret this!"
* Then you'll never learn the entry code.
|-
|-
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsId BGBrown == 1
* GetIsID 'BGBrown' == 1
* GetStage BGM001 >= 95
* GetStage 'BGM001' >= 95
|-
|-
!  ADD TOPICS
!  ADD TOPICS
|   
''No add topics''
* (none)
|-
|-
!  RESULT SCRIPT
!  RESULT SCRIPT
|   
<pre>SetStage BGM001 101</pre>
* (none)
|}
|}


We will need to look at altering Browns behaviour for the final release. We will need to add some AI in the next lesson to get him to run away.
Add another entry for stage 101:


What we do need to look at now is another hefty bit of scripting which controls the treasure chest
''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.''


Again here it is in its entirety. Look through it and try to work out what it is doing.
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.)
 
<pre>
SetQuestObject BGHideoutCELLKey 0
SetQuestObject BGHideoutKey 0
SetQuestObject BGBrownLetter 0
SetQuestObject BGPartialLetter 0
</pre>
 
 
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===
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.
It controls a chest with a three digit combination style lock.


<pre>Scriptname BGCombinationChestScript
<PRE>
SCN BGBlairsChestSCRIPT


Short DigitCount
Short Button1
Short Button1
Short Button2
Short Button2
Short Button3
Short Button3
Short CombiRight
Short Frame
Short ChestOpen
Short Unlocked
Short GoldCount
Short GoldCount
Short DoOnce


Begin OnActivate
Begin OnActivate


   If (ChestOpen == 2)
   If Unlocked == 1
     Activate
     Activate
   Else
   Else
    Set ChestOpen to 1
;Begin combination menu
Set Frame to 1
   EndIf
   EndIf


Line 834: Line 828:


Begin GameMode
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 (ChestOpen == 1)
If Frame == 2
;------------------------------------------------------------
Set Button1 to GetButtonPressed
    If (DigitCount == 0)
If Button1 == -1
      MessageBox, "Please input the first digit of thecombination",
Return
        "0","1","2","3","4","5","6","7","8","9" ;one line
EndIf
      Set DigitCount to 1
MessageBox "Second digit" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
    EndIf
Set Frame to 3
EndIf


    If (DigitCount == 1)
;Save second digit entered, get third digit
      Set Button1 to GetButtonPressed
If Frame == 3
      If button1 == -1
Set Button2 to GetButtonPressed
        Return
If Button2 == -1
      Else
Return
        Set DigitCount to 2
EndIf
      EndIf
MessageBox "Third digit" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
    EndIf
Set Frame to 4
EndIf


    If (DigitCount == 2)
;Save third digit entered, then check combination.
      MessageBox, "Please input the second digit of the combination",
If Frame == 4
        "0","1","2","3","4","5","6","7","8","9" ;one line
Set Button3 to GetButtonPressed
      Set DigitCount to 3
If Button3 == -1
    EndIf
Return
EndIf


    If (DigitCount == 3)
If Button1 == 1 && Button2 == 4 && Button3 == 7
      Set Button2 to GetButtonPressed
;Correct combination result
      If Button2 == -1
MessageBox "The combination pad unlocks."
        Return
Set Unlocked to 1
      Else
Set Frame to 0
        Set DigitCount to 4
Else
      EndIf
;Bad combination result
    EndIf
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
</PRE>


    If (DigitCount == 4)
Now it's time to wrap up our little adventure. We move the scene back to the Imperial City.
      MessageBox, "Please input the third digit of the combination",
        "0","1","2","3","4","5","6","7","8","9" ;one line
      Set DigitCount to 5
    EndIf
 
    If (DigitCount == 5)
      Set Button3 to GetButtonPressed
      If button3 == -1
        Return
      Else
        Set DigitCount to 6
      EndIf
    EndIf
;---------------------------------------------------------------
 
    If (DigitCount == 6)
      If Button1 == 1
        Set CombiRight to CombiRight + 1
      EndIf
      If Button2 == 4
        Set CombiRight to CombiRight + 1
      EndIf
      If Button3 == 7
        Set CombiRight to CombiRight +1
      EndIf
    EndIf
 
;---------------------------------------------------------------
 
    If (DigitCount == 6) && (CombiRight ==3)
      Set ChestOpen to 2
      Set DigitCount to 0
      Return
    EndIf
;---------------------------------------------------------------
 
    If (DigitCount == 6) && (CombiRight <= 2)
      MessageBox, "Naughty, naughty. Now take your punishment"
      If (Player.GetItemCount "gold001") >= 100
        Player.RemoveItem "gold001" 100
        BGBlairChestref.AddItem "gold001" 100
        Set DigitCount to 0
        Set ChestOpen to 0
        Return
      Else
        Set GoldCount to Player.GetItemCount "gold001"
        Player.RemoveItem "gold001" GoldCount
        BGBlairChestref.AddItem "Gold001" GoldCount
        Player.AddItem "gold001" 1
        Set DigitCount to 0
        Set ChestOpen to 0
      EndIf
 
    EndIf
;-----------------------------------------------------------------
  ElseIf (ChestOpen == 0)
    Return
  ElseIf (ChestOpen == 2)
    If DoOnce == 0
      Set DoOnce to 1
      Activate
      Return
    EndIf
  Else
    Return
  EndIf
End</pre>
 
In this case we control when the script runs using what I call a two block script. The first block sets up the conditions in which the second block works.
 
<pre>Begin OnActivate
 
  If (ChestOpen == 2)
    Activate
  Else
    Set ChestOpen to 1
  EndIf
 
End</pre>
 
This first block runs only when the chest is activated. It uses a control variable called ChestOpen.
 
This in fact has 3 states or values.
0 = Chest has not been activated and the combination is has not been entered
1 = Chest has been activated and the combination has not been entered
2 = Chest has been activated and the combination has been entered correctly
The Activate function has to be included to get the chest to open. Note since we will attach this script to the chest we need no reference id.
 
The first script checks if we have already opened the chest. If so it opens it again. If not it sets the ChestOpen to 1. This enables the GameMode script.
 
Begin GameMode
 
We use the Chest Open == 1 to enable the main body of the script.
 
  If (ChestOpen == 1)
 
For this we use another variable called DigitCount to help work through the different stages of the script
 
<pre>  If (DigitCount == 0)
    MessageBox, "Please input the first digit of the combination",
      "0","1","2","3","4","5","6","7","8","9" ;should be one line
    Set DigitCount to 1
  EndIf</pre>
 
Note here that the message box statement must all be on one line of code. On some editors the word wrap may make it look like this is on two or even three lines. If you cut and paste, the script editor may pick this up.  The PC can now  select the first digit.
 
<pre>  If (DigitCount == 1)
    Set Button1 to GetButtonPressed
    If Button1 == -1
      Return
    Else
      Set DigitCount to 2
    EndIf
  EndIf</pre>
 
We then set the value of  Button1. We also bump DigitCount up one to enable the next step. If no button is pressed the script halt for that frame only using the return command. We then repeat this process to get the second and third  digits.
<pre>  If (DigitCount == 2)
    MessageBox, "Please input the second digit of the combination",
      "0","1","2","3","4","5","6","7","8","9" ;again, one line
    Set DigitCount to 3
  EndIf
 
  If (DigitCount == 3)
    Set Button2 to GetButtonPressed
    If button2 == -1
      Return
    Else
      Set DigitCount to 4
    EndIf
  EndIf
 
  If (DigitCount == 4)
    MessageBox, "Please input the third digit of the combination",
      "0","1","2","3","4","5","6","7","8","9" ;one line
    Set DigitCount to 5
  EndIf
 
  If (DigitCount == 5)
    Set Button3 to GetButtonPressed
    If button3 == -1
      Return
    Else
      Set DigitCount to 6
    EndIf
  EndIf</pre>
 
Once Digit count is at 6 we can test to see if the combination is indeed 1 4 7. We use another variable called CombiRight to track this. If this reaches 3 the PC has opened the chest.
 
<pre>  If (DigitCount == 6)
    If Button1 == 1
      Set CombiRight to CombiRight +1
    EndIf
    If Button2 == 4
      Set CombiRight to CombiRight +1
    EndIf
    If Button3 == 7
      Set CombiRight to CombiRight +1
    EndIf
  EndIf</pre>
 
We test that CombiRight is indeed 3. If it is we set the chest open variable to 2, and we reset the digit count to zero to end any further progression.
 
<pre>  If (DigitCount == 6) && (CombiRight ==3)
    Set ChestOpen to 2
    Set DigitCount to 0
    Return
  EndIf</pre>
 
If it fails we want to punish the player for his failure, and nothing hurts quite lick taking a chunk of gold off the PC.
 
  If (DigitCount == 6) && (CombiRight <=2)
 
This bit of script displays a message
 
    MessageBox, "Naughty, naughty. Now take your punishment"[/i]
 
Then checks that the PC can afford the ‘fine’
 
  If (Player.GetItemCount "gold001") >= 100
 
It takes away the gold from the PC and then adds it to the chest. It then resets the control variable so the player  can try to open the chest again.
 
    Player.RemoveItem "gold001" 100
    BGBlairChestref.additem "gold001" 100
    Set DigitCount to 0
    Set ChestOpen to 0
    Return
 
Of course the player may not have 100 septims, so we use a variable called gold count which we set to the value of the player’s current gold count
 
    Else
      Set GoldCount to Player.GetItemCount "gold001"
 
Then we take that away and add it to the chest.
 
      Player.RemoveItem "gold001" GoldCount
      BGBlairChestRef.AddItem "Gold001" GoldCount
      Player.AddItem "gold001" 1
      Set DigitCount to 0
      Set ChestOpen to 0
    EndIf
  EndIf
 
Finally we wrap the script up with a couple of brief tidy ups. The first deals with the fact that the game mode block will run every frame while we are in the dungeon cell. Not just the room. Prior to touching the chest the chest open status is 0. If this is so the script returns and does nothing for the frame.
 
  ElseIf (ChestOpen == 0)
    Return
 
This bit opens the chest if we have the correct combination.
 
  ElseIf (ChestOpen == 2)
    If DoOnce == 0
      Set DoOnce to 1
      BGBlairChestRef.Activate Player
      Return
    EndIf
  Else
    Return
  EndIf
End
 
Now its time to wrap up our little adventure. We move the scene back to the Imperial City


==Imperial City Phase Two==
==Imperial City Phase Two==


Objective: ''In this phase the player will again meet Vilanus, who will set about transferring the deeds of the property over to you. After 24 hours you can revisit and he will have the documents ready.''
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 will need


* A second complete deed document
We need:
* The Prize House
* A map marker


We begin with another dialogue pair involving Vilanus Villa.
* A completed version of the deed
* The prize house
* A map marker for the house


One for before you have the key and deed.  
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.


The second for when you are successful.  
===New dialogue===
We begin by adding more dialogue for Vilanus Villa.


Again we need to add a small bit of script to the Quest Script to check for this.
First, set up three new topics:
*BGDeedCheck
*BGRecoverYes
*BGRecoverNo


<pre>  If (Player.GetItemCount "BGM001HouseDeedUC">=1) && (Player.GetItemCount "BGTopViewKey">=1)
Then add a new greeting:
    If DoOnce3 ==0
      Set QuestWon to 1
      Set DoOnce3 to 1
    EndIf
  EndIf</pre>


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
!colspan=2| '''GREETING'''
|-
|-
!  TOPIC
!  TOPIC TEXT
|   
"GREETING"
* GREETING
|-
|-
!  RESPONSE
!  RESPONSE
|   
"Hello, have you managed to recover the key and deed?"
* I can't help you until you find the key and deed.
* You have to go back and get the deed and key. Check if Blair has it.
|-
|-
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsId  BGVilanusVilla == 1
* GetIsID 'BGVilanusVilla' == 1
* GetStage BGM001 >= 80
* GetStage BGM001 >= 20
* GetQuestVariable BGM001.QuestWon == 0
* GetStage BGM001 < 110
|-
|-
!  ADD TOPICS
!  ADD TOPICS
|   
''No add topics''
* (none)
|-
!  CHOICES
|
*BGRecoverYes
*BGRecoverNo
|-
|-
!  RESULT SCRIPT
!  RESULT SCRIPT
|   
''No result script''
* (none)
|}
|}


and
Then edit the choices.


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
!colspan=2| '''BGRecoverNo'''
|-
|-
!  TOPIC
!  TOPIC TEXT
|   
"No, not yet."
* GREETING
|-
|-
!  RESPONSE
!  RESPONSE
|   
"I can't help you until you've found both the key and the deed."
* Hello, Have you managed to recover the deed and key?
|-
|-
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsId  BGVilanusVilla == 1
* GetIsID 'BGVilanusVilla' == 1
* GetStage BGM001 >= 80
* GetStage 'BGM001' < 95
* GetQuestVariable BGM001.QuestWon == 1
|-
|-
!  ADD TOPICS
!  ADD TOPICS
|   
''No add topics''
* none
|-
|-
!  RESULT SCRIPT
!  RESULT SCRIPT
|   
''No result script''
<pre>AddTopic BGTopView</pre>
|}
|}
 
<br>
(add topic via script to avoid issue with GREETINGS add topic's not appearing in the game)
 
For the new topic we add several responses. This first info tell the player to come back later
 
{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
!colspan=2| '''BGRecoverYes'''
|-
|-
!  TOPIC
!  TOPIC TEXT
|   
"Yes. Here they are."
* BGTopView (Top View Cottage?)
|-
|-
!  RESPONSE
!  RESPONSE
|   
"Excellent. I will take the deed to the property registrar today. Come back tomorrow, the transfer should be complete by then."
* Excellent, I will take the deed to the Property Registrar today. Come back tomorrow and I'll complete the transfer.
|-
|-
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsId  BGVilanusVilla == 1
* GetIsID 'BGVilanusVilla' == 1
* GetQuestVariable BGM001.QuestWon == 1
* GetStage 'BGM001' >= 95
* GetItemCount 'BGTopViewKey' == 1
* GetItemCount 'BGTopViewUncertifiedDeed' == 1
|-
|-
!  ADD TOPICS
!  ADD TOPICS
|   
|   
* BGTopView
*BGDeedCheck
|-
|-
!  RESULT SCRIPT
!  RESULT SCRIPT
|   
|   
<pre>Player.RemoveItem "BGM001HouseDeeduc" 1
<pre>
Player.RemoveItem BGTopViewUncertifiedDeed 1
SetStage BGM001 110
SetStage BGM001 110
Stage 110 Journal Update</pre>
</pre>
|}
|}


''I have met with Vilanus Villa again. He has taken the deed to Top View and will complete the registration. I should come back in 24 hours to complete the transfer.''
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
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'''
===Timers===


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.  
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
The two most used are:


GetSecondsPassed  
*[[GetSecondsPassed]]
GameDaysPassed  
*[[GameDaysPassed]]


We can use the seconds passed to establish timed events. We must use a float variable to interact with the GetSecondsPassed function.  
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.


Ok this example script is really pointless it takes 10 septims from the player, then gives them back 25 seconds later.
Here is an example script that takes 10 Septims from the player and then gives them back 25 seconds later.  
However, the structure is what counts.  


If you change the bits in bold to suit your needs, you will have a perfectly functional timer script.
<pre>
 
Scriptname ExampleTimerScript
The Remove function can be replaced with any script you want to run prior to the countdown.
 
The 25 controls how long the script will run for.
 
The Add function can be replaced by whatever you want to happen after the event.
 
<pre>Scriptname ExampleTimerScript


float Timer
float Timer
short DoOnce
short State


Begin GameMode
Begin GameMode
   If SetZero == 0  
   If State == 0  
     Set Timer to 25
     Set Timer to 25.0
     Set DoOnce to 1
     Set State to 1
     Player.RemoveItem ‘gold001’ 10
     Player.RemoveItem "gold001" 10
   Else
   ElseIf State == 1
     If Timer > 0
     If Timer > 0
       Set Timer to Timer - GetSecondsPassed
       Set Timer to Timer - GetSecondsPassed
     Else
     Else
       Player.AddItem ‘gold001’ 10
       Player.AddItem "gold001" 10
      Set State to 2
     EndIf
     EndIf
   EndIf
   EndIf


End</pre>
End
</pre>


When you plan to script longer events where precision is not essential you can use the courser GameDaysPassed function.  
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 we add some variables called StartDay, Timer, and DeedDone.
In the quest script add three short variables called ''State'', ''StartDay'', and ''DeedFinished''.


<pre> If(GetStage BGM001 == 110)
Then add this to the GameMode block:
    If(Timer == 0)
<pre>
      Set StartDay to GameDaysPassed
If GetStage BGM001 == 110
      Set Timer to 1
If State == 0
    EndIf
Set StartDay to GameDaysPassed
  EndIf
Set State to 1
 
ElseIf State == 1
  If (Timer == 1)
If GameDaysPassed > StartDay
    If (( GameDaysPassed - StartDay ) >= 1 )
Set DeedFinished to 1
      Set DeedDone to 1
Set State to 2
      Set Timer to 2
EndIf
    Else
EndIf
    EndIf
EndIf
  EndIf</pre>
</pre>
The timer variable controls which bits of script work.  
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.


The DeedDone variable is used to enable dialogue.
===More dialogue===
 
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.
The key pair of script lines are
 
Set StartDay to GameDaysPassed
 
(( GameDaysPassed - StartDay ) >= 1 )
 
You replace the number 1 with the number of days you want the event to last.
 
When the deed has not been completed ( DeedDone == 0) use


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
!colspan=2| '''BGDeedCheck'''
|-
|-
!  TOPIC
!  TOPIC TEXT
|   
"House Deed"
* BGTopView (Top View Cottage?)
|-
|-
!  RESPONSE
!  RESPONSE
|   
"It should be finished by tomorrow. Check back with me then."
* I haven't quite finished the paperwork check with me later.
|-
|-
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsId  BGVilanusVilla == 1
* GetIsID 'BGVilanusVilla' == 1
* GetQuestVariable BGM001.QuestWon == 1
* GetStage 'BGM001' == 110
* GetQuestVariable BGM001.DeedDone == 0
* GetQuestVariable 'BGM001.DeedFinished' == 0
|-
|-
!  ADD TOPICS
!  ADD TOPICS
|   
''No add topics''
* (none)
|-
|-
!  RESULT SCRIPT
!  RESULT SCRIPT
|   
''No result script''
* (none)
|}
|}
 
<br>
Once the deed is done you produce this message
 
{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
!colspan=2| '''BGDeedCheck'''
|-
|-
!  TOPIC
!  TOPIC TEXT
|   
"House Deed"
* BGTopView (Top View Cottage?)
|-
|-
!  RESPONSE
!  RESPONSE
|
|
* Congratulations, you are new the proud Owner of Top View.
*"The paperwork went through and you are now the owner of the Top View cottage."
* Here is the paperwork. I'll mark it's location on the map for you.
*"Here's the certified deed. I'll mark the location of the house on your map."
* May the gods be with you.
*"May the Gods be with you."
|-
|-
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsId  BGVilanusVilla == 1
* GetIsID 'BGVilanusVilla' == 1
* GetQuestVariable BGM001.QuestWon == 1
* GetStage 'BGM001' == 110
* GetQuestVariable BGM001.DeedDone == 0
* GetQuestVariable 'BGM001.DeedFinished' == 1
|-
|-
!  ADD TOPICS
!  ADD TOPICS
|   
''No add topics''
* (none)
|-
|-
!  RESULT SCRIPT
!  RESULT SCRIPT
|
|
<pre>SetStage BGM001 120</pre>
<pre>
Player.AddItem BGTopViewDeed 1
SetStage BGM001 120
</pre>
|}
|}
<br>


and add a Journal Update for Stage 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.


''Vilanus has completed the paperwork. I should now go visit my new home.''
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.''


Once again we need to add a mapmarker to the outside of the house. Call it BGTopViewMapMarker.
===Finishing up===
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''.


And the following quest stage result script is then added and complied
Then add the following quest stage result script for stage 120:


'''Results Script'''
<pre>
BGTVDoor1.SetOwnership
BGTVDoor2.SetOwnership
SetCellOwnership BGModTut4
SetCellOwnership BGModTu4Base
ShowMap BGTopViewMapMarker
</pre>


Player.additem "BGM001HouseDeed" 1
This script transfers ownership of the house doors and cells to the player, and then enables the map marker.
TopViewPlayerDoor1Ref.SetOwnership
TopViewPlayerDoor2Ref.SetOwnership
SetCellOwnership Bgmodtut4
SetCellOwnership Bgmodtu4base
ShowMap BGTopViewMapMarker


This script does the ownership transfer.
We then complete the quest script with a final block to check when the PC arrives at the house.


It sets the ownership of the two doors, and the two interior cells to the player.
<pre>
 
If GetStage BGM001 == 120
It also adds the finished certified document. Note this document is not a quest item.
If Player.GetInCell BGModTut4 || Player.GetInCell BGModTu4Base
 
SetStage BGM001 130
We can also add the following as an end of quest reply from Vilanus.
EndIf
 
EndIf
{| border="1" cellpadding="5"
</pre>
|-
!  TOPIC
* BGTopView (Top View Cottage?)
|-
!  RESPONSE
* I hope you enjoy the house.
|-
!  CONDITIONS*
|
* GetIsId  BGVilanusVilla == 1
* GetQuestVariable BGM001.QuestWon == 1
* GetQuestVariable BGM001.DeedDone == 1
* GetStage BGM001 >= 120
|-
!  ADD TOPICS
* (none)
|-
!  RESULT SCRIPT
* (none)
|}


We then complete the quest script with a final block to check when the PC arrives at the house. Of course we will need
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.


<pre> If (GetStage BGM001 == 120)
The final journal entry:
    If (Player.GetDistance BGTopViewXMarker <= 300)
  ''I have reached Top View. I am now free to explore my new home.''
      SetStage BGM001 130
    EndIf
  EndIf</pre>


This gives a final journal entry. We should also mark the quest as complete using the tab. Remember this does not end the quest. To do that we must use the StopQuest function
Finally, we add this quest stage result script to stage 130.


''I have reached Top View. I am now free to explore my new home.''
<pre>
 
ModPCFame 1
And finally we add this result script. This removes the essential status from the three essential characters so you can go ahead and kill them now. It boosts the player fame (optional), and finally stops the quest.
SetEssential BGVilanusVilla 0
SetEssential BGMSmith 0
SetEssential BGCptHubart 0
StopQuest BGM001
</pre>


ModPCFame 1
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.
SetEssential BGVilanusVilla 0
SetEssential BGMSmith 0
SetEssential BGCptHubart 0
StopQuest BGM001
So there you have it. A complete functional quest.  
So there you have it. A completely functional quest.  


However, if you 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 is what lesson 8 will be about.
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.'''
'''Till then, happy modding!'''


== Thanks ==
== Thanks ==
Anonymous user