Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
patrol_ambush.py
Go to the documentation of this file.
1 from go_to_adjacent_systems import *
2 import vsrandom
3 import launch
4 import faction_ships
5 import VS
6 import Briefing
7 import universe
8 import unit
9 import quest
10 import Director
11 import ambush
13  def __init__ (self, num_significants_to_patrol, distance_from_base, creds, savevar,systems,delay,faction,numenemies,dyntype='',dynfg='',greetingText=["Hello there, smuggler. Prepare to die!", "The price on your head is big enough that I missed my lunch"],directions=[],destination=''):
14  ambush.ambush.__init__(self,savevar,systems,delay,faction,numenemies,dyntype,dynfg,greetingText,directions,destination)
15  self.jnum=0
16  self.cred=creds
17  self.patrolpoints = []
18  self.objectives = []
19  self.distance = distance_from_base
20  you = VS.getPlayer()
21  self.quantity=num_significants_to_patrol
22  name = you.getName ()
24  self.AdjustFaction=False
25 
26  def terminate(self):
27  if (quest.checkSaveValue(self.cp,self.var,0) or quest.checkSaveValue(self.cp,self.var,-1)):
29  def SuccessMission (self):
30  if (quest.checkSaveValue(self.cp,self.var,0) or quest.checkSaveValue(self.cp,self.var,-1) or quest.checkSaveValue(self.cp,self.var,1)):
31  VS.getPlayerX(self.cp).addCredits (self.cred)
32  VS.terminateMission(0)
33 
34  def GeneratePatrolList (self):
35  VS.IOmessage (0,"patrol",self.mplay,"You must get within %f klicks of" % self.distance)
36  count=self.quantity*2
37  str=""
38  while (self.quantity>0 and count > 0):
39  count -= 1
40  sig = unit.getSignificant (vsrandom.randrange (0,128),0,0)
41  if (not sig.isNull()):
42  if (not (sig in self.patrolpoints)):
43  self.patrolpoints += [sig]
44  self.quantity=self.quantity-1
45  fac =sig.getFactionName()
46  nam =sig.getName ()
47  if (fac!="neutral"):
48  obj=VS.addObjective ("Scan %s's %s"% (fac,nam))
49  VS.IOmessage (0,"patrol",self.mplay,"%s owned %s " % (fac,nam))
50  else:
51  if (sig.isPlanet()):
52  if (sig.isJumppoint()):
53  obj=VS.addObjective ("Scan Jumppoint %s" % nam)
54  else:
55  obj=VS.addObjective ("Scan Planet %s" % nam)
56  else:
57  obj=VS.addObjective ("Scan Natural Phenomenon: %s" % nam)
58  VS.IOmessage (0,"patrol",self.mplay,"The object %s " % nam)
59  VS.setOwner(int(obj),VS.getPlayerX(self.cp))
60  VS.setCompleteness(int(obj),-1.0)
61  self.objectives+=[int(obj)]
62 
63  self.quantity=0
64 
65  def DeletePatrolPoint (self,num,nam):
66  VS.IOmessage (0,"patrol",self.mplay,"[Computer] %s scanned, data saved..."%nam)
67  VS.setCompleteness(self.objectives[self.jnum],1.0)
68  del self.objectives[self.jnum]
69  del self.patrolpoints[self.jnum]
70  def FinishedPatrol (self,playa):
71  if (self.jnum<len(self.patrolpoints)):
72  jpoint =self.patrolpoints[self.jnum]
73  VS.setOwner(self.objectives[self.jnum],playa)
74  if (jpoint.isNull()):
75  self.DeletePatrolPoint(self.jnum,"Debris")
76  else:
77  if (playa.getSignificantDistance (jpoint)<self.distance):
78  self.DeletePatrolPoint(self.jnum,jpoint.getName())
79  else:
80  self.jnum+=1
81  else:
82  self.jnum=0
83  return (len(self.patrolpoints)==0)
84  def Execute (self):
86  playa=VS.getPlayerX(self.cp)
87  if (playa.isNull()):
88  return
89  if (self.inescapable):
90  if (self.quantity>0):
91  self.GeneratePatrolList ()
92  else:
93  if (self.FinishedPatrol(playa)):
94  self.SuccessMission()
95  if (self.havelaunched):
96  if (not self.enemy.isNull()):
97  if (self.enemy.getUnitSystemFile()==playa.getUnitSystemFile()):
98  self.enemy.SetTarget(playa)