Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
cargo_mission Class Reference
Inheritance diagram for cargo_mission:

Public Member Functions

def initbriefing
 
def loopbriefing
 
def endbriefing
 
def SetVar
 
def GetSomeCargo
 
def __init__
 
def takeCargoAndTerminate
 
def Execute
 

Data Fields

 briefgametime
 
 cargoname
 
 you
 
 base
 
 role
 
 arrived
 
 var_to_set
 
 mplay
 
 capship
 
 faction
 
 cred
 
 difficulty
 
 adjsys
 
 quantity
 

Detailed Description

Definition at line 13 of file cargo_mission.py.

Constructor & Destructor Documentation

def __init__ (   self,
  factionname,
  numsystemsaway,
  cargoquantity,
  missiondifficulty,
  creds,
  launchoncapship,
  time_to_complete,
  category,
  jumps = (),
  var_to_set = '' 
)

Definition at line 48 of file cargo_mission.py.

48 
49  def __init__ (self,factionname, numsystemsaway, cargoquantity, missiondifficulty, creds, launchoncapship, time_to_complete, category,jumps=(),var_to_set=''):
50  Director.Mission.__init__(self);
51  self.you=VS.Unit()
52  self.base=VS.Unit()
53  self.role="ESCORTCAP"
54  self.arrived=0
55  self.var_to_set=var_to_set
56  self.mplay="all"
57 # self.mission_time=VS.GetGameTime()+time_to_complete*100*float(1+numsystemsaway)
58  self.capship= launchoncapship
59  self.faction=factionname
60  self.cred=creds
61  self.difficulty=missiondifficulty
62  self.you=VS.getPlayer()
63  self.adjsys=go_to_adjacent_systems(self.you,numsystemsaway,jumps)
64  self.quantity=cargoquantity
66  if (self.quantity<1):
67  self.quantity=1
68  tempquantity=self.quantity
69  name = self.you.getName ()
70  if (not self.you.isNull()):
71  j=0
72  while j<15:
73  #if j>10:
74  # category = ''
75  carg = self.GetSomeCargo(category)
76  found=False
77  for i in range(self.you.numCargo()):
78  tmpcarg=self.you.GetCargoIndex(i)
79  if (tmpcarg.GetCategory()==category and tmpcarg.GetMissionFlag()) or self.cargoname==tmpcarg.GetContent():
80  print category, tmpcarg.GetCategory()
81  found=True
82  break
83  if not found:
84  newquantity = self.you.addCargo(carg) #I add some cargo
85  if newquantity>0:
86  print "It wasnt found %s"%self.cargoname
87  self.quantity=newquantity
88  break
89  if found and tmpcarg.GetMissionFlag(): #self.cargoname==tmpcarg.GetContent():
90  self.cargoname=tmpcarg.GetContent()
91  self.quantity=int(tmpcarg.GetQuantity())
92  tempquantity=self.quantity
93  print ("already have "+str(self.quantity)+" cargo of this kind "+self.cargoname)
94  break
95  # Else, let's look for another cargo of this kind
96  print ("already have "+str(int(tmpcarg.GetQuantity()))+" non-mission cargo of this kind "+self.cargoname)
97 
98  j+=1
99  else: # While loop's condition failed... i.e. j got too big.
100  if not category:
101  category='generic'
102  VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000Unable to find suitable %s cargo that is not already loaded. Mission canceled."%category)
103  VS.terminateMission (0)
104  return
105  else:
106  VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000Unable to establish communications. Mission failed.")
107  VS.terminateMission (0)
108  return
109 # creds_deducted = (carg.GetPrice()*float(self.quantity)*vsrandom.random()+1)
110 # self.cred += creds_deducted
111  if (tempquantity>0):
112  self.cred*=float(self.quantity)/float(tempquantity)
113  else:
114  VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000You do not have space to add our %s cargo to your ship. Mission failed."%self.cargoname)
115  VS.terminateMission(0)
116  return
117 
118  if (self.quantity==0):
119  VS.IOmessage (2,"cargo mission",self.mplay,"#ff0000You do not have space to add our cargo to the mission. Mission failed.")
120  VS.terminateMission(0)
121  return
122 
123  VS.IOmessage (0,"cargo mission",self.mplay,"Your mission is as follows:" )
124  self.adjsys.Print("You should start in the system named %s","Then jump to %s","Finally, jump to %s, your final destination","cargo mission",1)
125  VS.IOmessage (2,"cargo mission",self.mplay,"Give the cargo to a %s unit or planet." % (self.faction))
126  VS.IOmessage (3,"cargo mission",self.mplay,"You will receive %d of the %s cargo" % (self.quantity,self.cargoname))
127 # VS.IOmessage (4,"cargo mission",self.mplay,"We will deduct %.2f credits from your account for the cargo needed." % (creds_deducted))
128  VS.IOmessage (4,"cargo mission",self.mplay,"You will earn %.2f credits when you deliver our cargo." % (creds))
129  VS.IOmessage (4,"cargo mission",self.mplay,"#00ff00Good luck!")
130 # self.you.addCredits (-creds_deducted)

Member Function Documentation

def endbriefing (   self)

Definition at line 28 of file cargo_mission.py.

References cargo_mission.briefgametime.

28 
29  def endbriefing(self):
30  self.adjsys.endbriefing()
del self.briefgametime
def Execute (   self)

Definition at line 171 of file cargo_mission.py.

References bounty.arrived, cargo_mission.arrived, HTMLParser.base, cargo_mission.base, bounty.mplay, cargo_mission.mplay, bounty.SetVar(), cargo_mission.SetVar(), cargo_mission.takeCargoAndTerminate(), go_to_adjacent_systems.you, bounty.you, and cargo_mission.you.

def Execute (self):
def GetSomeCargo (   self,
  category 
)

Definition at line 35 of file cargo_mission.py.

References debug.debug, and cargo_mission.quantity.

35 
36  def GetSomeCargo(self,category):
37  carg=VS.getRandCargo(self.quantity,category)
38  if (carg.GetQuantity()==0 or category==''):
39  carg = VS.getRandCargo(self.quantity,"") #oh no... could be starships...
40  i=0
41  while i<50 and (carg.GetCategory()[:10]=="Contraband" or carg.GetCategory()[:8]=="upgrades"):
42  debug.debug("contraband and upgrades==bad")
43  carg = VS.getRandCargo(self.quantity,"")
44  i+=1
45  self.cargoname=carg.GetContent()
46  carg.SetMissionFlag(1)
47  return carg
def initbriefing (   self)

Definition at line 14 of file cargo_mission.py.

References cargo_mission.cargoname.

14 
15  def initbriefing(self):
16  VS.IOmessage (0,"cargo mission","briefing","Your mission for today will be to run some %s cargo" % self.cargoname)
17  self.briefgametime = 0
18  self.adjsys.initbriefing()
19 
def loopbriefing (   self)

Definition at line 20 of file cargo_mission.py.

References cargo_mission.briefgametime.

20 
21  def loopbriefing(self):
22  brief_you=self.adjsys.loopbriefing()
23  if (brief_you != -1):
24  VS.IOmessage(0,"cargo mission","briefing","Once there, you must drop the cargo off at a specified unit")
25  if (self.briefgametime==0):
26  self.briefgametime = VS.GetGameTime()
27  elif ((VS.GetGameTime()-self.briefgametime)>5):
Briefing.terminate()
def SetVar (   self,
  val 
)

Definition at line 31 of file cargo_mission.py.

References bounty.var_to_set, and cargo_mission.var_to_set.

31 
32  def SetVar (self,val):
33  if (self.var_to_set!=''):
34  quest.removeQuest (self.you.isPlayerStarship(),self.var_to_set,val)
def takeCargoAndTerminate (   self,
  you,
  remove 
)

Definition at line 131 of file cargo_mission.py.

References cargo_mission.cargoname, bounty.cred, cargo_mission.cred, debug.debug, bounty.difficulty, cargo_mission.difficulty, ambush.faction, SystemInformation.faction, bounty.faction, ShipTracker.faction, cargo_mission.faction, go_to_adjacent_systems.faction, Launch.faction, ClearFactionRecord.faction, PushRelation.faction, PopRelation.faction, LaunchWingmen.faction, ChangeSystemOwner.faction, ChangeShipOwners.faction, bounty.mplay, cargo_mission.mplay, universe.punish(), cargo_mission.quantity, cargo_mission.role, bounty.SetVar(), cargo_mission.SetVar(), go_to_adjacent_systems.you, bounty.you, and cargo_mission.you.

132  def takeCargoAndTerminate (self,you, remove):
133  removenum=0 #if you terminate without remove, you are SKREWED
134  self.base.setCombatRole(self.role)
135  if (remove):
136  removenum=you.removeCargo(self.cargoname,self.quantity,1)
137  debug.debug("removed %d" % removenum)
138  mpart=VS.GetMasterPartList()
139  newcarg=mpart.GetCargo(self.cargoname)
140  newcarg.SetQuantity(removenum)
141  #self.base.addCargo(newcarg)#not for resale
142  has=self.you.hasCargo(self.cargoname)
143  if (has):
144  has=self.you.removeCargo(self.cargoname,has,1)
145  newcarg.SetMissionFlag(0)
146  newcarg.SetQuantity(has)
147  self.you.addCargo(newcarg) #It seems that removing and then adding it again is the only way...
148  if ((removenum>=self.quantity) or (self.quantity==0) or removenum>=1):
149  VS.IOmessage (0,"cargo mission",self.mplay,"#00ff00Excellent work pilot.")
150  VS.IOmessage (0,"cargo mission",self.mplay,"#00ff00You have been rewarded for your effort as agreed.")
151  VS.IOmessage (0,"cargo mission",self.mplay,"#00ff00Your excellent work will be remembered.")
152  you.addCredits(self.cred)
153  VS.AdjustRelation(you.getFactionName(),self.faction,.01*self.difficulty,1)
154  self.SetVar(1)
155  VS.terminateMission(1)
156  return
157  else:
158  VS.IOmessage (0,"cargo mission",self.mplay,"#ff0000You did not follow through on your end of the deal.")
159  if (self.difficulty<1):
160  VS.IOmessage (0,"cargo mission",self.mplay,"#ff0000Your pay will be reduced")
161  VS.IOmessage (0,"cargo mission",self.mplay,"#ff0000And we will consider if we will accept you on future missions.")
162  addcred=(float(removenum)/(float(self.quantity*(1+self.difficulty))))*self.cred
163  you.addCredits(addcred)
164  else:
165  VS.IOmessage (0,"cargo mission",self.mplay,"#ff0000You will not be paid!")
166  universe.punish(self.you,self.faction,self.difficulty)
167  self.SetVar(-1)
168  VS.terminateMission(0)
169  return
170 

Field Documentation

adjsys

Definition at line 62 of file cargo_mission.py.

arrived

Definition at line 53 of file cargo_mission.py.

base

Definition at line 51 of file cargo_mission.py.

briefgametime

Definition at line 16 of file cargo_mission.py.

capship

Definition at line 57 of file cargo_mission.py.

cargoname

Definition at line 44 of file cargo_mission.py.

cred

Definition at line 59 of file cargo_mission.py.

difficulty

Definition at line 60 of file cargo_mission.py.

faction

Definition at line 58 of file cargo_mission.py.

mplay

Definition at line 55 of file cargo_mission.py.

quantity

Definition at line 63 of file cargo_mission.py.

role

Definition at line 52 of file cargo_mission.py.

var_to_set

Definition at line 54 of file cargo_mission.py.

you

Definition at line 50 of file cargo_mission.py.


The documentation for this class was generated from the following file: