Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
quest_tutorial.py
Go to the documentation of this file.
1 #---------------------------------------------------------------------------------
2 # Vega Strike script for the tutorial quest
3 # Copyright (C) 2008 Vega Strike team
4 # Contact: hellcatv@users.sourceforge.net
5 # Internet: http://vegastrike.sourceforge.net/
6 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
11 #
12 # Author: pyramid
13 # Version: 2008-12-22
14 #
15 #---------------------------------------------------------------------------------
16 
17 # This script is a start to a turorial mission (quest/adventure)
18 # Currently, there is a small navigation tutorial available
19 # You can decline the offer after Oswald says hello by simply not stopping your ship
20 # It is possible to break off the tutorial. The last completed stage is saved
21 # in your savegame and resumes from there.
22 
23 # things that can be improved
24 # (a) include other tutorial parts: targetting, weapons, ...
25 # (b) change the mission name that appears on the hud - not possible currently
26 # (c) make tutorial repeatable after some time
27 # (d) there should be a negative relation adjustment when oswald gets destroyed
28 # (e) fix mission name and delete mission targets after each stage
29 
30 # import used libraries
31 import quest
32 import Director
33 import VS
34 import Vector
35 import universe
36 import unit
37 import vsrandom
38 import launch
39 import news
40 
41 # predefine stages
42 SAVE_KEY = "quest_tutorial"
43 STAGE_DOCKED = 0
44 STAGE_AWAY = 1
45 STAGE_ORBIT = 2
46 STAGE_ACCEPT = 4
47 COMPLETE_TUTORIAL1 = 5
48 COMPLETE_TUTORIAL2 = 6
49 COMPLETE_TUTORIAL3 = 7
50 COMPLETE_TUTORIAL4 = 8
51 COMPLETE_TUTORIAL5 = 10
52 STAGE_DECLINE = 98
53 
54 # the class that will be executed
56  # initialize quest variables
57  def __init__ (self):
58  # initialize variables
59  self.stage = STAGE_DOCKED # tutorial stage
60  self.practice = 0 #sequence within a practice function
61  self.system = VS.getSystemName() # starting system
62  self.player = VS.getPlayer()
63  self.playerhull = VS.getPlayer().GetHull()
64  self.drone = VS.Unit()
65  self.droneshield = 1 # shield before fight
66  self.fight = 0 # how many fight rounds
67  self.dockeddistance = 0
68  self.timer = VS.GetGameTime() # controls the stage timing
69  self.talktime = VS.GetGameTime() #controls individual talk time within animation
70  self.anitime = VS.GetGameTime() # controls the animation time
71  self.stayputtime = 0
72  self.msgColor = "#FFFF99"
73  self.objectives = [] # list of objectives
74  self.objective = 0 # current objective
75  self.startobjectname = ""
76  self.animations = [["com_tutorial_oswald.ani",2]] # the actors and ani duration
77  self.speech = [] # has a list of current sound files for speech
78  self.newsplayed = 0
79 
80  def putSaveValue(self,value, key=SAVE_KEY):
81  Director.eraseSaveData(self.player.isPlayerStarship(),key,0)
82  Director.pushSaveData(self.player.isPlayerStarship(),key,value)
83  return 1
84 
85  def getSaveValue(self,key=SAVE_KEY):
86  if Director.getSaveDataLength(self.player.isPlayerStarship(),key) > 0:
87  #print "----getSaveValue---", int(Director.getSaveData(self.player.isPlayerStarship(),key,0))
88  return int(Director.getSaveData(self.player.isPlayerStarship(),key,0))
89  return 0
90 
91  def playSoundCockpit(self,soundfile):
92  try:
93  VS.playSoundCockpit(soundfile)
94  except AttributeError:
95  VS.playSound(soundfile, self.player.Position(), (0,0,0))
96 
97  # checks if the player has undocked from Atlantis. If so sets next stage.
98  # Has been replaced by the more generic function playerIsUndocked
100  # get the planet object
101  self.startobject = unit.getUnitByName('Atlantis')
102  # target the departing planet to see the distance
103  self.player.SetTarget(self.startobject)
104  # verify if player is still docked at the planet
105  if (self.startobject.isDocked(self.player)):
106  self.dockeddistance = self.startobject.getDistance(self.player)
107  # if the player is not docked and at least 5km away then set next stage number
108  if (not self.startobject.isDocked(self.player) and self.startobject.getDistance(self.player)>(self.dockeddistance+5000)):
109  self.stage = STAGE_AWAY
110  return 0
111 
112  # checks if the player has undocked. if so sets next stage
113  def playerIsUndocked(self):
114  # dockedobject and dockeddistance must be global, i.e prefixed with self
115  # otherwise the script will advance to next stage just after undocking
116  # get the planet object
118  name = self.dockedobject.getName()
119  # verify if player is still docked and set the reference distance
120  if (not name==""):
121  self.dockeddistance = self.dockedobject.getDistance(self.player)
122  self.startobjectname = name
123  # when starting from Atlantis, target the departing planet to see the distance
124  if (name=="Atlantis"):
125  self.player.SetTarget(self.dockedobject)
126  # if the player was never docked or is not docked and at least 1km away then set next stage number
127  if (name=="" or ((not self.startobjectname=="") and (not self.startobjectname=="Atlantis") and self.dockedobject.getDistance(self.player)>(self.dockeddistance+1000))):
128  self.stage = STAGE_AWAY
129  self.timer = VS.GetGameTime()+5
130  return 0
131 
132  def LightMinuteToMeter(self,lightminute):
133  meter = 17987547500 * lightminute
134  return meter
135 
136  # launches a unit aka the drone
137  def launchNewDrone (self):
138  if (not self.player.isNull()):
139  # get the player's position
140  vec = self.player.Position()
141  # set drone position 1000m away from the player
142  vec = Vector.Add(vec,(1000,0,0))
143  # launch the tutorial drone.
144  #VS.launch(name,type,faction,unittype,ai,nr,nrwaves,pos,squadlogo):
145  self.drone = VS.launch("Oswald","Robin.tutorial","klkk_citizen","unit","default",1,1,vec,'')
146  # upgrade drone
147  self.drone.upgrade("quadshield15",0,0,1,0)
148  self.drone.upgrade("armor06",0,0,1,0)
149  # when launching give the player some text and ask him to decide if he wants to participate
150  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Hello traveler.")
151  VS.IOmessage (3,"Oswald","Privateer",self.msgColor+"My name is Oswald and I am offering flight assistance.")
152  VS.IOmessage (8,"Oswald","Privateer",self.msgColor+"Would you like to refresh your space faring skills?")
153  VS.IOmessage (12,"Oswald","Privateer",self.msgColor+"To participate in my tutorial mission, cut your engines with the #9999FFBACKSPACE"+self.msgColor+" key, let me approach you, and stay put until I contact you again.")
154  #VS.playSound("com_tutorial_oswald/oswald_greet.ogg", self.player.Position(), (0,0,0))
155  #VS.musicPlaySong("com_tutorial_oswald/oswald_greet.ogg")
156  # set comm animation parameters
157  # list [start,duration,anilist_entry]
158  self.sequence = [[0,1,0],[3,3,0],[8,2,0],[12,7,0]]
159  # set speech files
160  self.speech = ["com_tutorial_oswald/oswald_greet_01.ogg", "com_tutorial_oswald/oswald_greet_02.ogg", "com_tutorial_oswald/oswald_greet_03.ogg", "com_tutorial_oswald/oswald_greet_04.ogg"]
161  #set talktime start
162  self.talktime = VS.GetGameTime()
163  # on launching the drone, set its position near the player
164  vec = self.player.Position()
165  vec = Vector.Add (vec,(vsrandom.uniform(-2000,2000),
166  vsrandom.uniform(-2000,2000),
167  vsrandom.uniform(-2000,2000)))
168  self.drone.SetPosition(vec)
169  # get rid of all orders, so that strange maneouvers don't happen
170  self.drone.PrimeOrders()
171  # display the drone on HUD
172  self.player.SetTarget(self.drone)
173  # remember the initial shield strength
175  self.fight = 0
176  self.stage += 1
177  #self.stage = COMPLETE_TUTORIAL3 # debug
178  # duration of this part until end of animation
179  self.timer = VS.GetGameTime() + 20
180  return 0
181 
182  # check if drone has been attacked
183  # if so branch off to attack lesson
184  def checkDroneHealth (self):
185  if (unit.getShieldPercent(self.drone)<self.droneshield*0.90):
186  self.drone.PrimeOrders()
187  self.drone.SetTarget(self.player)
188  self.drone.LoadAIScript("fighter.ace")
189  self.drone.setFgDirective("a.")
190  self.savestage = self.stage
191  self.practice = 0
192  #if (self.fight<2):
193  self.fight += 1
194  self.stage = 96
195  return 0
196 
197  # checks distance to drone
198  # if player is too far, the tutorial breaks off
199  def checkDistance (self):
200  if (self.drone.getDistance(self.player)>20000):
201  self.practice = 0
202  self.stage = 97
203  return 0
204 
205  # keeps the drone near the player
206  # the drone doesn't quite orbit
207  # it will approach the player until 1000 meters and then stop
208  def orbitMe (self):
209  #self.player.SetTarget(self.drone)
210  # if the drone is more than 1000m away it will start instructions
211  if (self.drone.getDistance(self.player)>=1100):
212  # orientate the nose of the drone towards the player ship
213  vec = Vector.Sub(self.player.Position(),self.drone.Position())
214  self.drone.SetOrientation((1,0,0),vec)
215  # set velocity proportional to distance from player
216  vec = Vector.Scale(Vector.SafeNorm(vec),self.drone.getDistance(self.player)/10)
217  self.drone.SetVelocity(vec)
218  #self.stayputtime = VS.GetGameTime()
219  # if drone has approached player until 1000m then stop it
220  if (self.drone.getDistance(self.player)<1100):
221  self.drone.SetVelocity((0,0,0))
222  # this is also needed to stop rotation of the drone
223  self.drone.SetAngularVelocity((0,0,0))
224  return 0
225 
226  # check if player stays put close to the drone to accept tutorial
227  def acceptTutorial (self):
228  velocity = Vector.Mag(self.player.GetVelocity())
229  # if the offer has been placed, and player is put for 10s and drone is near
230  if (VS.GetGameTime()>self.timer and self.drone.getDistance(self.player)<1100 and velocity<=10):
231  self.player.SetTarget(self.drone)
232  self.timer = VS.GetGameTime()
233  self.complete = self.getSaveValue()
234  if (self.complete>0):
235  self.stage = self.complete
236  else:
237  self.stage = STAGE_ACCEPT
238  if (VS.GetGameTime()>self.timer and velocity>=10):
239  # allow some time for slowing down and approach if ships were moving
240  if (self.stayputtime>60):
241  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Have a nice journey and come back for a space faring refresher anytime here in Cephid 17.")
242  self.speech = ["com_tutorial_oswald/oswald_bye.ogg"]
243  self.playSoundCockpit(self.speech[0])
244  self.player.commAnimation("com_tutorial_oswald.ani")
245  self.stage = STAGE_DECLINE
246  self.timer = VS.GetGameTime()
247  else:
248  self.stayputtime += 10
249  self.timer = VS.GetGameTime() + 10
250  return 0
251 
252  # play the first part of the tutorial
253  def tutorialComm (self):
254  if (self.practice==0):
255  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Glad I can be of help.")
256  VS.IOmessage (5,"Oswald","Privateer",self.msgColor+"In the first place let's have a look at your heads up display (HUD).")
257  VS.IOmessage (10,"Oswald","Privateer",self.msgColor+"Please do not move your ship in order to better focus on my instructions.")
258  VS.IOmessage (15,"Oswald","Privateer",self.msgColor+"In the upper left corner you can see the communication messages.")
259  VS.IOmessage (20,"Oswald","Privateer",self.msgColor+"Each communication message shows the sender, the game time of the sending, and the message itself, like this one.")
260  VS.IOmessage (25,"Oswald","Privateer",self.msgColor+"To scroll the messages back and forth use the #9999FFPage Up"+self.msgColor+" and #9999FFPage Down"+self.msgColor+" keys. Try it out now.")
261  VS.IOmessage (35,"Oswald","Privateer",self.msgColor+"Good.")
262  VS.IOmessage (37,"Oswald","Privateer",self.msgColor+"Now you can send me a message by pressing the #9999FFF1"+self.msgColor+" key.")
263  # set comm animation parameters
264  self.sequence = [[0,1,0],[5,4,0],[10,4,0],[15,4,0],[20,4,0],[25,5,0],[35,1,0],[37,4,0]]
265  # set speech files
266  self.speech = ["com_tutorial_oswald/oswald_comm_01.ogg", "com_tutorial_oswald/oswald_comm_02.ogg", "com_tutorial_oswald/oswald_comm_03.ogg", "com_tutorial_oswald/oswald_comm_04.ogg", "com_tutorial_oswald/oswald_comm_05.ogg", "com_tutorial_oswald/oswald_comm_06.ogg", "com_tutorial_oswald/oswald_comm_07.ogg", "com_tutorial_oswald/oswald_comm_08.ogg"]
267  self.talktime = VS.GetGameTime()
268  self.timer = VS.GetGameTime()+45
269  self.practice = 1
270  if (self.practice==1 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
271  for index in range (len(self.sequence)):
272  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
273  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
274  # play each soundfile once
275  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
276  self.playSoundCockpit(self.speech[index])
277  self.anitime = VS.GetGameTime()+2
278  if (self.practice==1 and VS.GetGameTime()>=self.timer):
279  self.practice = 2
280  if (self.practice==2 and VS.GetGameTime()>self.timer):
281  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Usually, messages assigned to keys #9999FFF1"+self.msgColor+" and #9999FFF2"+self.msgColor+" are friendly messages which slightly increase you relation with a faction, while the other keys #9999FFF3"+self.msgColor+" and #9999FFF4"+self.msgColor+" decrease your relationship.")
282  VS.IOmessage (14,"Oswald","Privateer",self.msgColor+"Sometimes it can be very useful to send multiple friendly messages to improve your relation with a hostile faction or taunt an enemy into attacking you instead of a ship you are protecting.")
283  VS.IOmessage (26,"Oswald","Privateer",self.msgColor+"That's about it on the messages display.")
284  # set comm animation parameters
285  self.sequence = [[0,12,0],[14,12,0],[26,2,0]]
286  # set speech files
287  self.speech = ["com_tutorial_oswald/oswald_comm_09.ogg", "com_tutorial_oswald/oswald_comm_10.ogg", "com_tutorial_oswald/oswald_comm_11.ogg"]
288  self.talktime = VS.GetGameTime()
289  self.timer = VS.GetGameTime()+30
290  self.practice = 3
291  if (self.practice==3 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
292  for index in range (len(self.sequence)):
293  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
294  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
295  # play each soundfile once
296  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
297  self.playSoundCockpit(self.speech[index])
298  self.anitime = VS.GetGameTime()+2
299  if (self.practice==3 and VS.GetGameTime()>=self.timer):
300  self.practice = 4
301  if (self.practice==4 and VS.GetGameTime()>self.timer):
302  # make sure to reset the counter for the next practice loops
303  self.practice = 0
304  self.timer = VS.GetGameTime()+0
305  self.stage = COMPLETE_TUTORIAL1
306  self.putSaveValue(self.stage)
307  return 0
308 
309  def tutorialNav (self):
310  if (self.practice==0):
311  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Now, let's review the navigation information on your HUD. We'll do theory first, then some practice.")
312  VS.IOmessage (9,"Oswald","Privateer",self.msgColor+"In the lower left corner you will find your ship's shield status in blue, and armor status in orange.")
313  VS.IOmessage (16,"Oswald","Privateer",self.msgColor+"We will come to the text indicators later.")
314  VS.IOmessage (20,"Oswald","Privateer",self.msgColor+"In the middle of the bottom part you have your dashboard with the front radar on the left side and the rear radar on the right side.")
315  VS.IOmessage (29,"Oswald","Privateer",self.msgColor+"The active target will display as a small cross on your radar. Other targets will be dots with their colors representing your relation to them.")
316  VS.IOmessage (38,"Oswald","Privateer",self.msgColor+"Green is friendly, red is hostile, and yellow is neutral. An attacking ship is blue, a targetting ship is light blue, and a locking ship is violet. Neutral and significant objects like planets, stations, wormholes, or suns are white.")
317  VS.IOmessage (53,"Oswald","Privateer",self.msgColor+"The top center part of the dashboard has four round indicators which begin flashing when the following events occur:")
318  VS.IOmessage (59,"Oswald","Privateer",self.msgColor+" (L) means a hostile has missile lock on you")
319  VS.IOmessage (63,"Oswald","Privateer",self.msgColor+" (J) means you are in range of a jump point and your jump drive is ready")
320  VS.IOmessage (67,"Oswald","Privateer",self.msgColor+" (S) means your SPEC drive, needed for faster-than-light (FTL) travel, is activated")
321  VS.IOmessage (73,"Oswald","Privateer",self.msgColor+" (E) means your electronic counter measures (ECM) are active")
322  VS.IOmessage (77,"Oswald","Privateer",self.msgColor+"Below the round indicators are three colored bars")
323  VS.IOmessage (81,"Oswald","Privateer",self.msgColor+" (CAPACITOR) shows your weapons capacitor charge")
324  VS.IOmessage (86,"Oswald","Privateer",self.msgColor+" (DRIVES) shows your SPEC and jump drives energy charge")
325  VS.IOmessage (91,"Oswald","Privateer",self.msgColor+" (FUEL) shows you capacity for in-system travel and overdrive propulsion")
326  VS.IOmessage (97,"Oswald","Privateer",self.msgColor+"The numbers below the bars are your current speed to the left and your set speed to the right.")
327  VS.IOmessage (105,"Oswald","Privateer",self.msgColor+"Below that is the effective SPEC velocity to the left and the flight computer (FCMP) mode to the right.")
328  # set comm animation parameters #8 #13
329  self.sequence = [[0,8,0],[9,6,0],[16,2,0],[20,8,0],[29,8,0],[38,14,0],[53,6,0],[59,3,0],[63,4,0],[67,6,0],[73,4,0],[77,4,0],[81,4,0],[86,4,0],[91,5,0],[97,6,0],[105,6,0]]
330  self.speech = ["com_tutorial_oswald/oswald_nav_01.ogg", "com_tutorial_oswald/oswald_nav_02.ogg", "com_tutorial_oswald/oswald_nav_03.ogg", "com_tutorial_oswald/oswald_nav_04.ogg", "com_tutorial_oswald/oswald_nav_05.ogg", "com_tutorial_oswald/oswald_nav_06.ogg", "com_tutorial_oswald/oswald_nav_07.ogg", "com_tutorial_oswald/oswald_nav_08.ogg", "com_tutorial_oswald/oswald_nav_09.ogg", "com_tutorial_oswald/oswald_nav_10.ogg", "com_tutorial_oswald/oswald_nav_11.ogg", "com_tutorial_oswald/oswald_nav_12.ogg", "com_tutorial_oswald/oswald_nav_13.ogg", "com_tutorial_oswald/oswald_nav_14.ogg", "com_tutorial_oswald/oswald_nav_15.ogg", "com_tutorial_oswald/oswald_nav_16.ogg", "com_tutorial_oswald/oswald_nav_17.ogg"]
331  self.talktime = VS.GetGameTime()
332  self.timer = VS.GetGameTime()+112
333  self.practice = 1
334  if (self.practice==1 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
335  for index in range (len(self.sequence)):
336  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
337  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
338  # play each soundfile once
339  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
340  self.playSoundCockpit(self.speech[index])
341  self.anitime = VS.GetGameTime()+2
342  if (self.practice==1 and VS.GetGameTime()>=self.timer):
343  self.practice = 2
344  if (self.practice==2 and VS.GetGameTime()>self.timer):
345  # make sure to reset the counter for the next practice loops
346  self.practice = 0
347  self.timer = VS.GetGameTime()+0
348  self.stage = COMPLETE_TUTORIAL2
349  self.putSaveValue(self.stage)
350  return 0
351 
352  def practiceNav (self):
353  # practice intro
354  if (self.practice==0):
355  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"So much for theory. Let's do some practice now.")
356  VS.IOmessage (4,"Oswald","Privateer",self.msgColor+"First we'll do some basic navigation and targetting.")
357  self.sequence = [[0,3,0],[4,3,0]]
358  self.speech = ["com_tutorial_oswald/oswald_target_01.ogg", "com_tutorial_oswald/oswald_target_02.ogg"]
359  self.talktime = VS.GetGameTime()
360  self.timer = VS.GetGameTime()+10
361  self.practice = 1
362  if (self.practice==1 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
363  for index in range (len(self.sequence)):
364  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
365  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
366  # play each soundfile once
367  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
368  self.playSoundCockpit(self.speech[index])
369  self.anitime = VS.GetGameTime()+2
370  if (self.practice==1 and VS.GetGameTime()>=self.timer):
371  self.practice = 3
372  if (self.practice==3):
373  # explain basic targetting if drone is not already target
374  if (unit.getUnitFullName(self.player.GetTarget()) != unit.getUnitFullName(self.drone)):
375  nam = unit.getUnitFullName(self.drone)
376  self.objective = VS.addObjective("Target %s" % nam)
377  self.objectives+=[int(self.objective)]
378  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"In the lower right corner you can see the target video display unit (VDU) where you can see your current target.")
379  VS.IOmessage (8,"Oswald","Privateer",self.msgColor+"Target me by repeatedly toggling the #9999FFT"+self.msgColor+" key until you see my ship on the right VDU.")
380  VS.IOmessage (16,"Oswald","Privateer",self.msgColor+"Should you pass me, you may reverse the target selection sequence by pressing the #9999FFShift+T"+self.msgColor+" keys.")
381  # set comm animation parameters
382  self.sequence = [[0,7,0],[8,7,0],[16,6,0]]
383  self.speech = ["com_tutorial_oswald/oswald_target_03.ogg", "com_tutorial_oswald/oswald_target_04.ogg", "com_tutorial_oswald/oswald_target_05.ogg"]
384  self.talktime = VS.GetGameTime()
385  self.timer = VS.GetGameTime()+23
386  self.practice = 4
387  else:
388  self.practice = 5
389  if (self.practice==4 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
390  for index in range (len(self.sequence)):
391  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
392  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
393  # play each soundfile once
394  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
395  self.playSoundCockpit(self.speech[index])
396  self.anitime = VS.GetGameTime()+2
397  if (self.practice==4 and VS.GetGameTime()>=self.timer):
398  self.practice = 5
399  # make the drone the players target
400  if (self.practice==5 and unit.getUnitFullName(self.player.GetTarget())==unit.getUnitFullName(self.drone)):
401  nam = unit.getUnitFullName(self.drone)
402  self.objective = VS.addObjective("Face %s" % nam)
403  self.objectives+=[int(self.objective)]
404  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"OK. Now, orient your ship so that your targetting reticule (cross) points directly at me.")
405  VS.IOmessage (7,"Oswald","Privateer",self.msgColor+"To get my ship into your visual range just turn in the direction of the white target arrow at the edge of your HUD.")
406  VS.IOmessage (14,"Oswald","Privateer",self.msgColor+"When my ship is in your visual range you will notice that it is framed by a target box.")
407  VS.IOmessage (20,"Oswald","Privateer",self.msgColor+"Align your targetting reticule with my ship.")
408  # set comm animation parameters
409  self.sequence = [[0,6,0],[7,6,0],[14,5,0],[20,3,0]]
410  self.speech = ["com_tutorial_oswald/oswald_target_06.ogg", "com_tutorial_oswald/oswald_target_07.ogg", "com_tutorial_oswald/oswald_target_08.ogg", "com_tutorial_oswald/oswald_target_09.ogg"]
411  self.talktime = VS.GetGameTime()
412  self.timer = VS.GetGameTime()+24
413  self.practice = 6
414  if (self.practice==6 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
415  for index in range (len(self.sequence)):
416  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
417  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
418  # play each soundfile once
419  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
420  self.playSoundCockpit(self.speech[index])
421  self.anitime = VS.GetGameTime()+2
422  if (self.practice==6 and VS.GetGameTime()>=self.timer):
423  self.practice = 7
424  if (self.practice==7):
425  # check if the player is facing the drone
426  angle = unit.facingAngleToUnit(self.player,self.drone)
427  #print "facing: " + str(angle)
428  if (angle<=0.05):
429  VS.setCompleteness(self.objectives[self.objective],1.0)
430  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Well done.")
431  VS.IOmessage (2,"Oswald","Privateer",self.msgColor+"Now, turn your ship away from my ship and accelerate to full speed using the #9999FF\\"+self.msgColor+" key.")
432  self.player.commAnimation("com_tutorial_oswald.ani")
433  self.objective = VS.addObjective("Set max velocity")
434  self.objectives+=[int(self.objective)]
435  self.sequence = [[0,1,0],[2,6,0]]
436  self.speech = ["com_tutorial_oswald/oswald_nav_21.ogg", "com_tutorial_oswald/oswald_nav_22.ogg"]
437  self.talktime = VS.GetGameTime()
438  self.timer = VS.GetGameTime()+9
439  self.practice = 8
440  if (self.practice==8 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
441  for index in range (len(self.sequence)):
442  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
443  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
444  # play each soundfile once
445  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
446  self.playSoundCockpit(self.speech[index])
447  self.anitime = VS.GetGameTime()+2
448  if (self.practice==8 and VS.GetGameTime()>=self.timer):
449  self.practice = 9
450  if (self.practice==9):
451  # check if the player is facing away
452  angle = unit.facingAngleToUnit(self.player,self.drone)
453  velocity = Vector.Mag(self.player.GetVelocity())
454  #check if angle to drone is at least 22 degrees (0.20 radians)
455  if (angle>=0.20 and velocity>=295):
456  VS.setCompleteness(self.objectives[self.objective],1.0)
457  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"And now set your velocity reference to zero by pressing the #9999FFBACKSPACE"+self.msgColor+" key and come to a complete stop.")
458  self.player.commAnimation("com_tutorial_oswald.ani")
459  self.player.commAnimation("com_tutorial_oswald.ani")
460  self.playSoundCockpit("com_tutorial_oswald/oswald_nav_23.ogg")
461  self.objective = VS.addObjective("Set full stop")
462  self.objectives+=[int(self.objective)]
463  self.timer = VS.GetGameTime()+9
464  self.practice = 10
465  if (self.practice==10):
466  # check if the player is stopped
467  velocity = Vector.Mag(self.player.GetVelocity())
468  if (velocity<=2):
469  VS.setCompleteness(self.objectives[self.objective],1.0)
470  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"You can also increment your velocity gradually with the #9999FF+"+self.msgColor+" key. Accelerate to 100 m/s now.")
471  self.player.commAnimation("com_tutorial_oswald.ani")
472  self.playSoundCockpit("com_tutorial_oswald/oswald_nav_24.ogg")
473  self.objective = VS.addObjective("Set velocity reference to 100m/s")
474  self.objectives+=[int(self.objective)]
475  self.timer = VS.GetGameTime()+9
476  self.practice = 11
477  if (self.practice==11):
478  # check if the player has velocity >100
479  velocity = Vector.Mag(self.player.GetVelocity())
480  if (velocity>=98 and velocity<=110):
481  VS.setCompleteness(self.objectives[3],1.0)
482  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"In the same way you can reduce your velocity gradually with the #9999FF-"+self.msgColor+" key. Deccelerate to 50 m/s.")
483  self.player.commAnimation("com_tutorial_oswald.ani")
484  self.playSoundCockpit("com_tutorial_oswald/oswald_nav_25.ogg")
485  self.objective = VS.addObjective("Set velocity reference to 50m/s")
486  self.objectives+=[int(self.objective)]
487  self.timer = VS.GetGameTime()+9
488  self.practice = 12
489  if (self.practice==12):
490  # check if the player has velocity <50
491  velocity = Vector.Mag(self.player.GetVelocity())
492  if (velocity<=55 and velocity>=40):
493  VS.setCompleteness(self.objectives[self.objective],1.0)
494  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Great. If you further deccelerate your velocity with the #9999FF-"+self.msgColor+" key you can actually reverse your thrust. Deccelerate now to -20 m/s.")
495  self.player.commAnimation("com_tutorial_oswald.ani")
496  self.playSoundCockpit("com_tutorial_oswald/oswald_nav_26.ogg")
497  self.objective = VS.addObjective("Set velocity reference to -20m/s")
498  self.objectives+=[int(self.objective)]
499  self.timer = VS.GetGameTime()+12
500  self.practice = 13
501  if (self.practice==13):
502  # check if the player has velocity <=-20m/s
503  velocity = unit.getSignedVelocity(self.player)
504  if (velocity<=-18):
505  VS.setCompleteness(self.objectives[self.objective],1.0)
506  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Excellent.")
507  VS.IOmessage (2,"Oswald","Privateer",self.msgColor+"You have learned how to target, orient your ship, accellerate, decellerate, and bring your ship to a stop.")
508  VS.IOmessage (10,"Oswald","Privateer",self.msgColor+"I'm sure this will come in handy during your future endeavors.")
509  # set comm animation parameters
510  self.sequence = [[0,1,0],[2,7,0],[10,4,0]]
511  self.speech = ["com_tutorial_oswald/oswald_nav_27.ogg", "com_tutorial_oswald/oswald_nav_28.ogg", "com_tutorial_oswald/oswald_nav_29.ogg"]
512  self.talktime = VS.GetGameTime()
513  self.timer = VS.GetGameTime()+15
514  self.practice = 14
515  if (self.practice==14 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
516  for index in range (len(self.sequence)):
517  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
518  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
519  # play each soundfile once
520  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
521  self.playSoundCockpit(self.speech[index])
522  self.anitime = VS.GetGameTime()+2
523  if (self.practice==14 and VS.GetGameTime()>=self.timer):
524  self.practice = 15
525  if (self.practice==15):
526  # make sure to reset the counter for the next practice loops
527  self.practice = 0
528  self.timer = VS.GetGameTime()+10
529  self.stage = COMPLETE_TUTORIAL3
530  self.putSaveValue(self.stage)
531  #print "NAV - save: " + str(self.getSaveValue())
532  return 0
533 
534  def practiceSpec (self):
535  # practice intro
536  if (self.practice==0):
537  #self.jump = universe.getRandomJumppoint()
538  self.jump = unit.getUnitByName('JumpToOldziey')
539  nam = unit.getUnitFullName(self.jump)
540  self.objective = VS.addObjective("Target %s" % nam)
541  self.objectives+=[int(self.objective)]
542  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Let's practice some faster than light (FTL) travel now.")
543  VS.IOmessage (5,"Oswald","Privateer",self.msgColor+"Target "+unit.getUnitFullName(self.jump)+" navigation point using the #9999FFN"+self.msgColor+" or the #9999FFShift+N"+self.msgColor+" keys.")
544  self.sequence = [[0,4,0],[5,6,0]]
545  self.speech = ["com_tutorial_oswald/oswald_spec_01.ogg", ""]
546  self.talktime = VS.GetGameTime()
547  self.timer = VS.GetGameTime()+12
548  self.practice = 1
549  if (self.practice==1 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
550  for index in range (len(self.sequence)):
551  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
552  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
553  # play each soundfile once
554  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
555  self.playSoundCockpit(self.speech[index])
556  self.anitime = VS.GetGameTime()+2
557  if (self.practice==1 and VS.GetGameTime()>=self.timer):
558  self.practice = 2
559  if (self.practice==2 and self.player.GetTarget()==self.jump):
560  VS.setCompleteness(self.objectives[self.objective],1.0)
561  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Set your velocity to maximum with the #9999FF\\"+self.msgColor+" key and activate the SPEC auto pilot with the #9999FFA"+self.msgColor+" key to get there. Hang on as this might take a while if you are close to massive objects.")
562  VS.IOmessage (10,"Oswald","Privateer",self.msgColor+"You will notice that your SPEC drive indicator (S) is flashing, which indicates that SPEC is active.")
563  VS.IOmessage (20,"Oswald","Privateer",self.msgColor+"During FTL travel your shields become inactive, as you can see below on your ship VDU.")
564  VS.IOmessage (26,"Oswald","Privateer",self.msgColor+"You will also notice that your steering has no effect on your vessel since the auto pilot has taken over the controls.")
565  VS.IOmessage (32,"Oswald","Privateer",self.msgColor+"You can always interrupt and resume the auto pilot by toggling the #9999FFA"+self.msgColor+" key. You may try that, if you wish.")
566  VS.IOmessage (40,"Oswald","Privateer",self.msgColor+"In the lower left corner, just above your ship staus you will notice two indicators.")
567  VS.IOmessage (45,"Oswald","Privateer",self.msgColor+"SPEC shows you if your SPEC drive is enabled.")
568  VS.IOmessage (47,"Oswald","Privateer",self.msgColor+"AUTO tells you if auto pilot is engaged.")
569  name = unit.getUnitFullName(self.jump)
570  self.objective = VS.addObjective("Approach %s" % name)
571  self.objectives+=[int(self.objective)]
572  # set comm animation parameters
573  self.sequence = [[0,12,0],[12,6,0],[20,6,0],[26,6,0],[32,7,0],[40,4,0],[45,2,0],[47,4,0]]
574  self.speech = ["com_tutorial_oswald/oswald_spec_02.ogg", "", "com_tutorial_oswald/oswald_spec_03.ogg", "", "", "com_tutorial_oswald/oswald_spec_04.ogg", "", ""]
575  self.talktime = VS.GetGameTime()
576  self.timer = VS.GetGameTime()+52
577  self.practice = 3
578  if (self.practice==3 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
579  for index in range (len(self.sequence)):
580  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
581  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
582  # play each soundfile once
583  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
584  self.playSoundCockpit(self.speech[index])
585  self.anitime = VS.GetGameTime()+2
586  if (self.practice==3 and VS.GetGameTime()>=self.timer):
587  self.practice = 4
588  if (self.practice==4 and self.player.getDistance(self.jump)<=10000):
589  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Almost there.")
590  VS.IOmessage (2,"Oswald","Privateer",self.msgColor+"The auto pilot only gives back control some time after the SPEC auto pilot light stopped flashing.")
591  VS.IOmessage (8,"Oswald","Privateer",self.msgColor+"Notice also how your shields start recharing when leaving FTL travel mode.")
592  # set comm animation parameters
593  self.sequence = [[0,1,0],[2,5,0],[8,4,0]]
594  self.speech = ["com_tutorial_oswald/oswald_spec_05.ogg", "", ""]
595  self.talktime = VS.GetGameTime()
596  self.timer = VS.GetGameTime()+14
597  self.practice = 5
598  if (self.practice==5 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
599  for index in range (len(self.sequence)):
600  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
601  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
602  # play each soundfile once
603  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
604  self.playSoundCockpit(self.speech[index])
605  self.anitime = VS.GetGameTime()+2
606  if (self.practice==5 and VS.GetGameTime()>=self.timer):
607  self.practice = 6
608  if (self.practice==6 and self.player.getDistance(self.jump)<=3000):
609  VS.setCompleteness(self.objectives[self.objective],1.0)
610  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Here we are.")
611  VS.IOmessage (1,"Oswald","Privateer",self.msgColor+"You may try out manual FTL travel at this point.")
612  VS.IOmessage (5,"Oswald","Privateer",self.msgColor+"Target the planet Atlantis using your significant objects targetting keys #9999FFN"+self.msgColor+" and #9999FFShift+N"+self.msgColor+".")
613  # set comm animation parameters
614  self.sequence = [[0,1,0],[1,4,0],[5,7,0]]
615  self.speech = ["com_tutorial_oswald/oswald_spec_06.ogg", "", ""]
616  self.talktime = VS.GetGameTime()
617  self.timer = VS.GetGameTime()+12
618  self.practice += 1
619  if (self.practice==7 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
620  for index in range (len(self.sequence)):
621  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
622  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
623  # play each soundfile once
624  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
625  self.playSoundCockpit(self.speech[index])
626  self.anitime = VS.GetGameTime()+2
627  if (self.practice==7 and VS.GetGameTime()>=self.timer):
628  self.practice = 8
629  if (self.practice==8 and VS.GetGameTime()>self.timer):
630  self.destination = unit.getUnitByName('Atlantis')
631  self.distance = self.player.getDistance(self.destination)
632  name = unit.getUnitFullName(self.destination)
633  self.objective = VS.addObjective("Target %s" % name)
634  self.objectives+=[int(self.objective)]
635  self.timer = VS.GetGameTime()
636  self.practice += 1
637  if (self.practice==9 and self.player.GetTarget()==self.destination):
638  VS.setCompleteness(self.objectives[self.objective],1.0)
639  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Roger that. Turn towards the planet, set your velocity to maximum with the #9999FF\\"+self.msgColor+" key, and enable the manual SPEC with the #9999FFShift+A"+self.msgColor+" key to approach the planet.")
640  VS.IOmessage (12,"Oswald","Privateer",self.msgColor+"Make sure that the planet is fairly well centered in your targetting reticule.")
641  VS.IOmessage (17,"Oswald","Privateer",self.msgColor+"Notice how your speed starts increasing gradually after leaving the jump point range.")
642  self.objective = VS.addObjective("Enable manual SPEC")
643  self.objectives+=[int(self.objective)]
644  # set comm animation parameters
645  self.sequence = [[0,12,0],[12,5,0],[17,5,0]]
646  self.speech = ["com_tutorial_oswald/oswald_spec_07.ogg", "", ""]
647  self.talktime = VS.GetGameTime()
648  self.timer = VS.GetGameTime()+22
649  self.practice += 1
650  if (self.practice==10 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
651  for index in range (len(self.sequence)):
652  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
653  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
654  # play each soundfile once
655  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
656  self.playSoundCockpit(self.speech[index])
657  self.anitime = VS.GetGameTime()+2
658  if (self.practice==10 and VS.GetGameTime()>=self.timer):
659  self.practice = 11
660  if (self.practice==11 and self.player.GetTarget()==self.destination):
661  #disabled for now, since max velocity does not return the spec values
662  #velocity = Vector.Mag(self.player.GetVelocity())
663  #print "velocity=" + str(self.player.GetVelocity())
664  #print "magnitude=" + str(velocity)
665  #if (velocity>=5000):
666  if (self.player.getDistance(self.destination)<=(self.distance*0.97)):
667  VS.setCompleteness(self.objectives[self.objective],1.0)
668  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"If your are getting too much off course, stop the SPEC drive toggling the #9999FFShift+A"+self.msgColor+" key, recenter your target, and then re-enable the manual SPEC drive again with the same keys.")
669  VS.IOmessage (13,"Oswald","Privateer",self.msgColor+"When you have approched Atlantis to 10 000km please disble the SPEC drive toggling the #9999FFShift+A"+self.msgColor+" key again and then stop your ship.")
670  name = unit.getUnitFullName(self.destination)
671  self.objective = VS.addObjective("Approach %s" % name)
672  self.objectives+=[int(self.objective)]
673  # set comm animation parameters
674  self.sequence = [[0,12,0],[13,9,0]]
675  self.speech = ["com_tutorial_oswald/oswald_spec_08.ogg", ""]
676  self.talktime = VS.GetGameTime()
677  self.timer = VS.GetGameTime()+22
678  self.practice += 1
679  #else:
680  # self.practice += 2
681  if (self.practice==12 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
682  for index in range (len(self.sequence)):
683  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
684  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
685  # play each soundfile once
686  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
687  self.playSoundCockpit(self.speech[index])
688  self.anitime = VS.GetGameTime()+2
689  if (self.practice==12 and VS.GetGameTime()>=self.timer):
690  self.practice = 13
691  if (self.practice==13 and self.player.getDistance(self.destination)<=10000000):
692  VS.setCompleteness(self.objectives[self.objective],1.0)
693  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"All right.")
694  VS.IOmessage (2,"Oswald","Privateer",self.msgColor+"You have learned how to conveniently travel within the system.")
695  self.speech = ["com_tutorial_oswald/oswald_spec_09.ogg", ""]
696  self.playSoundCockpit(self.speech[0])
697  self.player.commAnimation("com_tutorial_oswald.ani")
698  self.timer = VS.GetGameTime()+7
699  self.practice += 1
700  if (self.practice==14):
701  velocity = Vector.Mag(self.player.GetVelocity())
702  if (velocity>=10 and self.player.getDistance(self.destination)<=2000000):
703  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Bring your ship to full stop before crashing into the planet.")
704  self.speech = ["com_tutorial_oswald/oswald_spec_10.ogg", ""]
705  self.player.commAnimation("com_tutorial_oswald.ani")
706  self.playSoundCockpit(self.speech[0])
707  self.objective = VS.addObjective("Stop your ship")
708  self.objectives+=[int(self.objective)]
709  self.timer = VS.GetGameTime()+10
710  self.practice += 1
711  else:
712  self.practice += 2
713  if (self.practice==15):
714  velocity = Vector.Mag(self.player.GetVelocity())
715  if (velocity<=10):
716  VS.setCompleteness(self.objectives[self.objective],1.0)
717  self.practice += 1
718  if (self.practice==16):
719  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Now dock to the planet, go to the mission computer, and save your game.")
720  VS.IOmessage (5,"Oswald","Privateer",self.msgColor+"Then get yourself a Jump Drive and an Overdrive and come back for more tutoring if you wish.")
721  VS.IOmessage (10,"Oswald","Privateer",self.msgColor+"To dock, turn towards the planet and press the docking clearance request key #9999FFD"+self.msgColor+". A green docking frame will appear.")
722  VS.IOmessage (17,"Oswald","Privateer",self.msgColor+"You may still enable the SPEC drive until you close up on the planet and your velocity matches the set velocity.")
723  VS.IOmessage (24,"Oswald","Privateer",self.msgColor+"When you are within range, press again the #9999FFD"+self.msgColor+" key to dock. The docking distance will depend on the planet or station size that you are docking to.")
724  VS.IOmessage (33,"Oswald","Privateer",self.msgColor+"The larger the object the further away you can dock.")
725  VS.IOmessage (36,"Oswald","Privateer",self.msgColor+"For Atlantis the docking distance is roughly about 990 kilometers.")
726  # set comm animation parameters
727  self.sequence = [[0,5,0],[5,5,0],[10,7,0],[17,6,0],[24,6,0],[33,3,0],[36,5,0]]
728  self.speech = ["com_tutorial_oswald/oswald_spec_11.ogg", "", "", "", "com_tutorial_oswald/oswald_spec_12.ogg", "", ""]
729  self.talktime = VS.GetGameTime()
730  self.timer = VS.GetGameTime()+42
731  self.practice += 1
732  if (self.practice==17 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
733  for index in range (len(self.sequence)):
734  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
735  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
736  # play each soundfile once
737  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
738  self.playSoundCockpit(self.speech[index])
739  self.anitime = VS.GetGameTime()+2
740  if (self.practice==17 and VS.GetGameTime()>=self.timer):
741  self.practice += 1
742  if (self.practice==18 and self.destination.isDocked(self.player)):
743  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"That concludes the navigation part of the tutorial.")
744  self.speech = ["com_tutorial_oswald/oswald_spec_13.ogg"]
745  self.player.commAnimation("com_tutorial_oswald.ani")
746  self.playSoundCockpit(self.speech[0])
747  self.timer = VS.GetGameTime()+3
748  self.practice = 99
749  if (self.practice>=99):
750  # make sure to reset the counter for the next practice loops
751  self.practice = 0
752  self.stage = COMPLETE_TUTORIAL4
753  self.putSaveValue(self.stage)
754  return 0
755 
756  # play the intermezzo when attacked
757  def tutorialIntermezzo (self):
758  # maybe he can have sympathy and make it a lesson if he beats you
759  # like stop before you destroy the player's ship and mouth off about how he hopes you learned
760  # something, 'pirates won't be so forgiving'
761  if (self.practice==0 and self.fight==1):
762  VS.IOmessage (0,"Oswald","Privateer","#FF0000"+"So you want to learn how to dodge lasers, eh?")
763  VS.IOmessage (3,"Oswald","Privateer","#FF0000"+"You aren't the first newbie I've had to put down, and you won't be the last!")
764  # set comm animation parameters
765  self.sequence = [[0,3,0],[3,5,0]]
766  self.speech = ["com_tutorial_oswald/oswald_intermezzo_01.ogg", ""]
767  self.talktime = VS.GetGameTime()
768  self.timer = VS.GetGameTime()+10
769  self.practice = 1
770  if (self.practice==0 and self.fight==2):
771  VS.IOmessage (0,"Oswald","Privateer","#FF0000"+"That's over the border, boy!")
772  VS.IOmessage (2,"Oswald","Privateer","#FF0000"+"May God have mercy upon my enemies, because I won't!")
773  self.speech = ["com_tutorial_oswald/oswald_intermezzo_02.ogg", ""]
774  # set comm animation parameters
775  self.sequence = [[0,2,0],[2,3,0]]
776  self.talktime = VS.GetGameTime()
777  self.timer = VS.GetGameTime()+5
778  self.practice = 1
779  if (self.practice==1 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
780  for index in range (len(self.sequence)):
781  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
782  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
783  # play each soundfile once
784  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
785  self.playSoundCockpit(self.speech[index])
786  self.anitime = VS.GetGameTime()+2
787  if (self.practice==1 and VS.GetGameTime()>=self.timer):
788  self.practice = 4
789  if (self.practice==4 and self.player.GetHull()<=self.playerhull*0.90 and self.fight<2):
790  self.drone.SetTarget(VS.Unit())
791  VS.AdjustRelation(self.drone.getFactionName(),self.player.getFactionName(),99,10)
792  VS.AdjustRelation(self.player.getFactionName(),self.drone.getFactionName(),99,10)
793  self.drone.LoadAIScript("sitting_duck")
794  self.drone.PrimeOrders()
795  self.practice = 5
796  if (self.practice==5):
797  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Enough of this!")
798  VS.IOmessage (1,"Oswald","Privateer",self.msgColor+"I hope you've learned something.")
799  VS.IOmessage (3,"Oswald","Privateer",self.msgColor+"Pirates won't be so forgiving.")
800  VS.IOmessage (5,"Oswald","Privateer",self.msgColor+"And neither will I if you ever play tricks on me again!")
801  # set comm animation parameters
802  self.sequence = [[0,2,0],[3,5,0]]
803  self.speech = ["com_tutorial_oswald/oswald_intermezzo_03.ogg", "", "", ""]
804  self.talktime = VS.GetGameTime()
805  self.timer = VS.GetGameTime()+8
806  self.practice = 6
807  if (self.practice==6 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
808  for index in range (len(self.sequence)):
809  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
810  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
811  # play each soundfile once
812  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
813  self.playSoundCockpit(self.speech[index])
814  self.anitime = VS.GetGameTime()+2
815  if (self.practice==6 and VS.GetGameTime()>=self.timer):
816  self.practice = 7
817  if (self.practice==7 and VS.GetGameTime()>=self.timer):
818  VS.IOmessage (0,"Oswald","Privateer",self.msgColor+"Now let's get back to business, hotshot.")
819  self.speech = ["com_tutorial_oswald/oswald_intermezzo_04.ogg"]
820  self.player.commAnimation("com_tutorial_oswald.ani")
821  self.playSoundCockpit(self.speech[0])
822  self.timer = VS.GetGameTime()+3
823  self.practice = 8
824  if (self.practice==8 and VS.GetGameTime()>=self.timer):
825  self.practice = 99
826  if (self.practice>=99):
828  # make sure to reset the counter for the next practice loops
829  self.practice = 0
830  self.stage = self.savestage
831  return 0
832 
833  # the execute loop for (nearly) each frame
834  def Execute (self):
835  # do not do anything before the player undocks
836  if (self.stage==STAGE_DOCKED):
837  self.complete = self.getSaveValue()
838  if (self.complete==0) and (self.newsplayed==0):
839  # publish news
840  text = "CEPHID SECURITY INITIATIVE GIVES TRAINING FOR FLIGHT SAFETY\\\The Cephid Security Initiative (CSI) is offering training for pilots with the purpose of enhancing flight safety in and out of the system. "
841  text += "A representative said, this training is sponsored by volunteer contributors and open for pilots of all vessel classes. "
842  text += "No matter if you're a greenhorn in space faring or a long-time pilot you may meet one of the volunteers when leaving from a planet or station into space and participate in the training or refresher."
843  news.publishNews(text)
844  self.newsplayed = 1
845  if (self.complete>=98):
846  self.stage = self.complete
847  if (self.complete<98):
848  self.playerIsUndocked()
849 
850  # launch drone if the player did not die
851  if (not self.player.isNull()):
852  # when in space, launch the drone
853  if (self.stage==STAGE_AWAY and VS.GetGameTime()>self.timer):
854  self.launchNewDrone()
855  #self.stage = 7 #debug
856  # play the talk animation
857  if (self.stage==2 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
858  for index in range (len(self.sequence)):
859  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
860  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
861  # play each soundfile once
862  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
863  self.playSoundCockpit(self.speech[index])
864  self.anitime = VS.GetGameTime()+2
865  if (self.stage==2 and VS.GetGameTime()>=self.timer):
866  self.stage = 3
867 
868  if (not self.player.isNull() and not self.drone.isNull()):
869  # check if player is attacking drone
870  if (self.stage<90):
871  self.checkDroneHealth()
872  # check if player is still in system
873  if (self.stage<90 and not VS.getSystemName()==self.system):
874  self.stage = 97
875  # check if player is flying off
876  if (self.stage<90 and self.stage!=COMPLETE_TUTORIAL3 and self.stage!=COMPLETE_TUTORIAL4):
877  self.checkDistance()
878  # when drone is launched, then follow player
879  if (self.stage==3):
880  self.orbitMe()
881  self.acceptTutorial()
882  if (self.stage==STAGE_ACCEPT):
883  self.tutorialComm()
884  if (self.stage==COMPLETE_TUTORIAL1):
885  self.tutorialNav()
886  if (self.stage==COMPLETE_TUTORIAL2):
887  self.practiceNav()
888  if (self.stage==COMPLETE_TUTORIAL3):
889  self.orbitMe()
890  self.practiceSpec()
891  # tutorial is incomplete, so a nice excuse is required
892  if (self.stage==COMPLETE_TUTORIAL4 and VS.GetGameTime()>self.timer):
893  VS.IOmessage (0,"Oswald","player",self.msgColor+"Oops. Sorry, pal. My boss at the Cephid Safety Initiative has an emergency situation I must handle now. I apologize.")
894  VS.IOmessage (9,"Oswald","player",self.msgColor+"Have a nice journey. And come back for more.")
895  self.sequence = [[0,8,0],[9,3,0]]
896  self.speech = ["com_tutorial_oswald/oswald_cancel.ogg", ""]
897  self.talktime = VS.GetGameTime()
898  self.timer = VS.GetGameTime()+12
899  self.stage = 9
900  # play the talk animation
901  if (self.stage==9 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
902  for index in range (len(self.sequence)):
903  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
904  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
905  # play each soundfile once
906  if (VS.GetGameTime()-self.talktime<=self.sequence[index][0]+1):
907  self.playSoundCockpit(self.speech[index])
908  self.anitime = VS.GetGameTime()+2
909  if (self.stage==9 and VS.GetGameTime()>=self.timer):
910  self.stage = 98
911  # drone was attacked, give him a lesson!
912  if (self.stage==96):
913  self.tutorialIntermezzo()
914  # player run off during tutorial, let's break it off then
915  if (self.stage==97 and VS.GetGameTime()>self.timer):
916  VS.IOmessage (0,"Oswald","player",self.msgColor+"Hey! Where are you heading? Come back for more anytime.")
917  VS.IOmessage (4,"Oswald","player",self.msgColor+"Have a good flight and don't break the hull.")
918  self.speech = ["com_tutorial_oswald/oswald_runoff_01.ogg"]
919  self.playSoundCockpit(self.speech[0])
920  self.player.commAnimation("com_tutorial_oswald.ani")
921  self.player.commAnimation("com_tutorial_oswald.ani")
922  self.player.commAnimation("com_tutorial_oswald.ani")
923  self.timer = VS.GetGameTime()+6
924  self.stage = 98
925  # if the turorial was declined
926  if (self.stage==98 and VS.GetGameTime()>self.timer):
927  self.drone.SetVelocity((2000,0,0))
928  self.timer = VS.GetGameTime()+10
929  self.putSaveValue(self.stage)
930  print "Tutorial quest finished"
931  self.stage = 99
932  # let the drone disappear
933  if (self.stage==99 and VS.GetGameTime()>self.timer):
934  self.drone.PrimeOrders()
935  self.playernum = -1
936  self.name = "quest_tutorial"
937  self.removeQuest()
938  self.stage += 1 # don't enter this loop anymore
939  return 0
940  # keep the script alive for execution
941  return 1
942 
943 # call this from the adventure file
945  def __init__ (self):
946  quest.quest_factory.__init__ (self,"quest_tutorial")
947  def create (self):
948  return quest_tutorial()
949 
950 # In order to work properly in mission scripts for testing purposes
951 # it must inherit the Director.Mission class *and* call its constructor.
952 # Unfortunately quests must inherit from the quest class, so you need to use a wrapper class
953 class Executor(Director.Mission):
954  def __init__(self, classesToExecute):
955  Director.Mission.__init__(self)
956  self.classes = classesToExecute
957  def Execute(self):
958  for c in self.classes:
959  c.Execute()