Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
directions_mission.py
Go to the documentation of this file.
1 from go_to_adjacent_systems import *
2 from go_somewhere_significant import *
3 import vsrandom
4 import launch
5 import faction_ships
6 import VS
7 import Briefing
8 import universe
9 import unit
10 import Director
11 import quest
12 class go_none:
13  def Execute(self):
14  return 1
15  def HaveArrived(self):
16  return 1
17  def SignificantUnit(self):
18  return VS.getUnit(0);
19  def __init__(self):
20  pass
21 
22 isambushrunning={}
23 
24 class directions_mission (Director.Mission):
25  def dir_privateSetupPlayer(self,cp):
26  print "setting up mission"
27  print self.jumps
28  self.arrived=0
29  self.wasnull=0
30  self.you=VS.getPlayerX(cp)
32  self.adjsys.Print("You should start in the system named %s","Then jump to %s","Lastly, jump to %s, your final destination","cargo mission",1)
33  def setupPlayer(self,cp):
34  self.dir_privateSetupPlayer(cp)
35  def __init__ (self,savevar,jumps=(),destination=''):
36  Director.Mission.__init__(self);
37  print 'Directions: Starting'
38  global isambushrunning
39  self.var=savevar
40  self.savedCargo=self.getCargo(VS.getPlayer())
41 # print self.savedCargo
42  if (self.var,self.savedCargo) in isambushrunning:
43  #VS.terminateMission(0)
44  print 'Directions: Stopping: directions already running! (before mission restore)'
45  isambushrunning[(self.var,self.savedCargo)]=True
46  self.jumps=jumps
47  self.cp=VS.getCurrentPlayer()
48  self.you=VS.Unit()
49  self.base=VS.Unit()
50  self.arrived=0
51  self.destination=destination
52  self.mplay="all"
53  self.dir_privateSetupPlayer(self.cp)
55  self.obj=0
56  name = self.you.getName ()
57 
58  def takeCargoAndTerminate (self,you, remove=1):
59  global isambushrunning
60  if ((self.var,self.savedCargo) in isambushrunning):
61  del isambushrunning[(self.var,self.savedCargo)]
62  VS.terminateMission(1)
63  return
64 
65  def findUnit(self, name):
66  i = VS.getUnitList()
67  while i.notDone():
68  testun=i.current()
69  i.advance()
70  if testun.getName().lower()==name.lower() or testun.getFullname().lower()==name.lower():
71  return testun
72  i = VS.getUnitList()
73  while i.notDone():
74  testun=i.current()
75  i.advance()
76  if testun.isDockableUnit():
77  return testun
78  return VS.getUnit(0)
79  def getCargo(self,un):
80  lis=[]
81  for i in range(un.numCargo()):
82  if (un.GetCargoIndex(i).GetMissionFlag()):
83  lis.append(un.GetCargoIndex(i).GetContent())
84  return tuple(lis)
85  def checkCargo(self,un):
86  import quest
87  return not (quest.checkSaveValue(self.cp,self.var,0) or quest.checkSaveValue(self.cp,self.var,1) or quest.checkSaveValue(self.cp,self.var,-1) or self.getCargo(un)!=self.savedCargo)
88  def Execute (self):
89  if (VS.getPlayerX(self.cp).isNull()):
90  self.wasnull=1
91  return
92  if (self.arrived and self.base.isNull()):
93  return
94  if (self.wasnull):
95  print "INEQUALITY"
96  if (not self.checkCargo(VS.getPlayerX(self.cp))):
97  self.takeCargoAndTerminate(self.you,1)
98  return
99  else:
100  self.setupPlayer(self.cp)
101  if (not self.you):
102  return
103  if (not self.adjsys.Execute()):
104  return
105  if (self.destination=='' and len(self.jumps)==0):
106  return #obviously wrapper for ambush
107  if (self.arrived):
108  dis=self.you.getSignificantDistance(self.base)
109  if (dis<200):
110  VS.setCompleteness(self.obj,1)
111  if (dis<50 or self.base.isDocked(self.you) or self.you.isDocked(self.base)):
112  self.takeCargoAndTerminate(self.you,1)
113  return
114  else:
115  self.arrived=1
116  self.adjsys=go_none()
117  self.base=self.findUnit(self.destination)
118  self.obj=VS.addObjective("Deliver cargo to %s." % self.destination);
119  VS.setOwner(self.obj,self.you)
120  VS.setCompleteness(self.obj,0)
121 
122 
123 
124 
125 
126