Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
quest_debug.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: 2011-03-01
14 #
15 #---------------------------------------------------------------------------------
16 
17 # This script is used for testing the game
18 # and or displaying test variables available through python
19 # It is called through the quest_debug.mission and shouldn't
20 # be activated in the game release
21 
22 # things that can be improved
23 
24 # import used libraries
25 import quest
26 import Director
27 import VS
28 import Vector
29 import universe
30 import unit
31 import vsrandom
32 import launch
33 import news
34 import stardate
35 import string
36 
37 # predefine stages
38 SAVE_KEY = "quest_debug"
39 
40 # the class that will be executed
42  # initialize quest variables
43  def __init__ (self):
44  self.msgColor = "#FFFF00"
45  self.timer = VS.GetGameTime() # controls the interval timing
46  self.player = VS.getPlayer()
47  # show if quest was initialized
48  #print "###debug: quest_debug initialized"
49 
50  def LightMinuteToMeter(self,lightminute):
51  meter = 17987547500 * lightminute
52  return meter
53 
54  # checks if the player has undocked. if so sets next stage
55  def playerIsUndocked(self):
56  # dockedobject and dockeddistance must be global, i.e prefixed with self
57  # otherwise the script will advance to next stage just after undocking
58  # get the planet object
60  name = self.dockedobject.getName()
61  # verify if player is still docked and set the reference distance
62  if (not name==""):
63  self.dockeddistance = self.dockedobject.getDistance(self.player)
64  self.startobjectname = name
65  # when starting from Atlantis, target the departing planet to see the distance
66  if (name=="Atlantis"):
67  self.player.SetTarget(self.dockedobject)
68  # if the player was never docked or is not docked and at least 1km away then set next stage number
69  if (name=="" or ((not self.startobjectname=="") and (not self.startobjectname=="Atlantis") and self.dockedobject.getDistance(self.player)>(self.dockeddistance+1000))):
70  self.stage = STAGE_AWAY
71  self.timer = VS.GetGameTime()+5
72  return 0
73 
74  # the execute loop for (nearly) each frame
75  def Execute (self):
76  #if (not self.player.isNull() and self.playerIsUndocked()):
77  if ( not self.player.isNull() ):
78  # execute every N seconds
79  if (VS.GetGameTime()>self.timer):
80  # print something on the stdout console
81  #print "startime: ", VS.getStarTime(), VS.getStarDate(), stardate.formatStarDate("confed",VS.getStarTime())
82  # print something to the ingame messages
83  VS.IOmessage (0, self.msgColor+"debug"+"#FFFFFF", "Privateer", self.msgColor+"stardate: " + stardate.formatStarDate("confed",VS.getStarTime()) )
84  self.timer = VS.GetGameTime()+20
85  # keep the script alive for execution
86  return 1
87 
88 # call this from the adventure file
90  def __init__ (self):
91  quest.quest_factory.__init__ (self,"quest_debug")
92  def create (self):
93  return quest_debug()
94 
95 # In order to work properly in mission scripts for testing purposes
96 # it must inherit the Director.Mission class *and* call its constructor.
97 # Unfortunately quests must inherit from the quest class, so you need to use a wrapper class
98 class Executor(Director.Mission):
99  def __init__(self, classesToExecute):
100  Director.Mission.__init__(self)
101  self.classes = classesToExecute
102  def Execute(self):
103  for c in self.classes:
104  c.Execute()