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

Jump to navigation Jump to search
m
→‎At the Cottage: clarifying some stuff
imported>Pyrocow2
(Adding Beginner's Guide TOC)
imported>Pyrocow2
m (→‎At the Cottage: clarifying some stuff)
Line 40: Line 40:
The GetDistance function returns a numerical value which indicates how far away a reference is from a specified point. (Distance is measure in UNITS with one game unit roughly equal to 1.5 cm)
The GetDistance function returns a numerical value which indicates how far away a reference is from a specified point. (Distance is measure in UNITS with one game unit roughly equal to 1.5 cm)


We will use the distance 300 which is fairly close to but not necessarily on top of the x marker we made. When the character gets close 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. Now add this below the current IF-End if block inside the begin block of our quest script.
We will use the distance 300 which is fairly close to but not necessarily on top of the x marker we made. When the character gets close we want to move to stage 40. We can use the stage to limit when the active part of the script runs. We first need to add stage 40 in the stage tab. Then add this piece of script to the ''GameMode'' block in ''BGM001QuestScript''.


<pre>
  If (GetStage BGM001 == 30)
  If (GetStage BGM001 == 30)
   If (Player.GetDistance BGCourierLodgeXMarker <= 300)
   If (Player.GetDistance BGCourierLodgeXMarker <= 300)
Line 47: Line 48:
   EndIf
   EndIf
  EndIf
  EndIf
</pre>


In this case the quest stage acts as a DoOnce type control.  
In this case, the quest stage acts as a DoOnce type control.  


Now we need to write a bit of script to check if and when the player collects the two clues needed to allow Hubart to identify the criminal gang.
Now we need to write a bit of script to check if and when the player collects the two clues we left in the cottage.


We have to set up a counter variable which I have called QObjectCount. (Type short). Each time a player adds one of the quest objects to their inventory we need to bump this counter by one.   
We have to set up a counter variable which I have called ''QObjectCount'' (a Short). Each time the player adds one of the quest objects to their inventory, we need to bump this counter by one.   


We also want to know when each item is picked up so we can display a suitable message informing the player to keep looking. Again this is hand holding, and can be left out for a greater challenge and a deeper immersion.  
We also want to know when each item is picked up so we can display a suitable message informing the player to keep looking. Again this is hand holding, and can be left out for a greater challenge and a deeper immersion.  


We are going to write some script. Experienced scripter will throw their hands up at the clumsy nature of this bit of the script, but it gets the job done and I believe it is easier to follow the logic of why each line is added in this version.  
We are going to write some script. Experienced scripters will throw their hands up at the clumsy nature of this bit of the script, but it gets the job done and I believe it is easier to follow the logic of why each line is added in this version.  


Perhaps one of the greats will re-write this in a more concise form at some point.
Perhaps one of the greats will re-write this in a more concise form at some point.


So we declare the three variables to add to our variable list at the top of the script. You will notice that the list keeps growing as we find we need new variables.
So we declare the three variables to add to our variable list at the top of the quest script (''BGM001QuestScript''). You will notice that the list keeps growing as we find we need new variables.


  Short Qobjectcount
  Short QObjectCount
  Short Count1Once
  Short Count1Once
  Short Count2Once
  Short Count2Once
Anonymous user

Navigation menu