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

Jump to navigation Jump to search
→‎Imperial City Phase Two: Editing dialogue and script
imported>Pyrocow2
(→‎Setting up the resources: adding document name)
imported>Pyrocow2
(→‎Imperial City Phase Two: Editing dialogue and script)
 
Line 900: Line 900:
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.
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.


We begin with another dialogue pair involving Vilanus Villa.  
===New dialogue===
We begin by adding more dialogue for Vilanus Villa.


One for before you have the key and deed, the second for when you are successful.
First, set up three new topics:
*BGDeedCheck
*BGRecoverYes
*BGRecoverNo


Again we need to add a small bit of script to the Quest Script to check for this.
Then add a new greeting:
 
<pre>
If (Player.GetItemCount "BGM001HouseDeedUC">=1) && (Player.GetItemCount "BGTopViewKey">=1)
    If DoOnce3 ==0
      Set QuestWon to 1
      Set DoOnce3 to 1
    EndIf
  EndIf
</pre>


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
Line 922: Line 917:
|-
|-
!  RESPONSE
!  RESPONSE
|  "I can't help you until you find the key and deed to the house."
|  "Hello, have you managed to recover the key and deed?"
|-
|-
!  CONDITIONS
!  CONDITIONS
Line 928: Line 923:
* GetIsID 'BGVilanusVilla' == 1
* GetIsID 'BGVilanusVilla' == 1
* GetStage BGM001 >= 20
* GetStage BGM001 >= 20
* GetQuestVariable BGM001.QuestWon == 0
* GetStage BGM001 < 110
|-
|-
!  ADD TOPICS
!  ADD TOPICS
|  ''No add topics''
|  ''No add topics''
|-
!  CHOICES
|
*BGRecoverYes
*BGRecoverNo
|-
|-
!  RESULT SCRIPT
!  RESULT SCRIPT
|  ''No add topics''
|  ''No result script''
|}
|}


and
Then edit the choices.


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
!colspan=2| '''GREETING'''
!colspan=2| '''BGRecoverNo'''
|-
|-
!  TOPIC TEXT
!  TOPIC TEXT
|  "GREETING"
|  "No, not yet."
|-
|-
!  RESPONSE
!  RESPONSE
|  "Hello, have you managed to recover the key and deed?"
|  "I can't help you until you've found both the key and the deed."
|-
|-
!  CONDITIONS
!  CONDITIONS
|   
|   
* GetIsID BGVilanusVilla == 1
* GetIsID 'BGVilanusVilla' == 1
* GetStage BGM001 >= 95
* GetStage 'BGM001' < 95
* GetQuestVariable BGM001.QuestWon == 1
|-
|-
!  ADD TOPICS
!  ADD TOPICS
Line 958: Line 957:
|-
|-
!  RESULT SCRIPT
!  RESULT SCRIPT
|   
''No result script''
<pre>AddTopic BGTopView</pre>
|}
|}
 
<br>
''(Add the topic via script to avoid issue with GREETING Add Topics not always working.)''
 
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| '''BGTopView'''
!colspan=2| '''BGRecoverYes'''
|-
|-
!  TOPIC TEXT
!  TOPIC TEXT
|  "Top View Cottage?"
|  "Yes. Here they are."
|-
|-
!  RESPONSE
!  RESPONSE
|  "Excellent, I will take the deed to the Property Registrar today. Come back tomorrow and I'll complete the transfer."
|  "Excellent. I will take the deed to the property registrar today. Come back tomorrow, the transfer should be complete by then."
|-
|-
!  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>
<pre>
Player.RemoveItem "BGM001HouseDeeduc" 1
Player.RemoveItem BGTopViewUncertifiedDeed 1
SetStage BGM001 110
SetStage BGM001 110
</pre>
</pre>
|}
|}


Stage 110 Journal Update
Stage 110 Journal Update:
  ''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.''
  ''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.
Line 1,034: Line 1,030:
</pre>
</pre>


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.
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.
The DeedDone variable is used to enable dialogue.
#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 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
===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.


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

Navigation menu