Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
escort_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 escort_num=0
13 class escort_mission (Director.Mission):
14  you=VS.Unit()
15  escortee=VS.Unit()
16  adjsys=0
17  arrived=0
18  mplay="all"
19  def __init__ (self,factionname, missiondifficulty, our_dist_from_jump, dist_from_jump, distance_from_base, creds, enemy_time, numsysaway,jumps=(),var_to_set='',dynfg='', dyntype=''):
20  Director.Mission.__init__(self);
21  self.you = VS.getPlayer();
22  self.role= "ESCORTCAP"
23  self.gametime=VS.GetGameTime()
24  self.adjsys=go_to_adjacent_systems(self.you, numsysaway,jumps)
25  self.var_to_set = var_to_set;
26  print "e"
27  self.adjsys.Print("You should start in the system named %s","Then jump to %s","Finally, jump to %s, your final destination","escort mission",1)
28  print "f"
29  self.distfrombase=distance_from_base
30  print "g"
31  self.faction=factionname
32  global escort_num
33  escort_num+=1
34  #self.escortee = launch.launch_wave_around_unit("Escort"+str(escort_num),
35  # self.faction,
36  # faction_ships.getRandomFighter("merchant"),
37  # "default",
38  # 1,
39  # self.you.rSize(),
40  # 2.0*self.you.rSize(),
41  # self.you,
42  # "")
43  L=launch.Launch()
44  L.fgappend = str(escort_num)
45  L.fg ="Escort"
46  L.faction=self.faction
47  if (dynfg=='' and dyntype==''):
48  L.type = faction_ships.getRandomFighter("merchant")
49  else:
50  L.type = dyntype
51  L.forcetype=True
52  L.dynfg = dynfg
53  L.ai = "default"
54  L.num=1
55  L.minradius = 2.0*self.you.rSize()
56  L.maxradius = 3.0*self.you.rSize()
57  self.escortee=L.launch(self.you)
58  self.escortee.setMissionRelevant()
59  self.escortee.upgrade("jump_drive",0,0,0,1)
60  self.you.SetTarget(self.escortee)
61  print "h"
62  self.escortee.setFlightgroupLeader(self.you)
63  print "dd"
64  self.difficulty=missiondifficulty
65  self.creds = creds
66  def initbriefing(self):
67  print "ending briefing"
68  def loopbriefing(self):
69  print "loop briefing"
70  Briefing.terminate();
71  def endbriefing(self):
72  print "ending briefing"
73  def Execute (self):
74  if (VS.GetGameTime()-self.gametime>10):
75  self.escortee.setFgDirective('F')
76  if self.you.isNull():
77  VS.IOmessage (0,"escort",self.mplay,"#ff0000You were to protect your escort. Mission failed.")
78  VS.terminateMission(0)
79  return
80  self.escortee.setFlightgroupLeader(self.you)
81  #print 'name: '+self.escortee.getFlightgroupLeader().getName()
82  #self.escortee.SetVelocity(self.you.GetVelocity())
83  if (self.escortee.isNull()):
84  VS.IOmessage (0,"escort",self.mplay,"#ff0000You were to protect your escort. Mission failed.")
85  universe.punish(self.you,self.faction,self.difficulty)
86  if (self.var_to_set!=''):
87  quest.removeQuest (self.you.isPlayerStarship(),self.var_to_set,-1)
88  VS.terminateMission(0)
89  return
90  if (not self.adjsys.Execute()):
91  if (self.arrived):
92  self.adjsys.SignificantUnit().setSpeed(0.0)
93  self.adjsys.SignificantUnit().SetVelocity((0.0,0.0,0.0))
94  return
95  if (not self.arrived):
96  self.arrived=1
97  self.adjsys=go_somewhere_significant (self.you,1,self.distfrombase+15*self.escortee.rSize(),self.difficulty<=1,self.faction)
98  self.role = self.adjsys.SignificantUnit().getCombatRole()
99  self.adjsys.SignificantUnit().setCombatRole("INERT");
100  self.adjsys.Print ("You must escort your starship to the %s","defend","docked around the %s", 0)
101  elif (self.you.getDistance(self.escortee)<2000):
102  self.you.addCredits(self.creds)
103  VS.AdjustRelation(self.you.getFactionName(),self.faction,self.difficulty*.01,1)
104  VS.IOmessage (0,"escort",self.mplay,"#00ff00Excellent work! You have completed this mission!")
105  self.escortee.setFgDirective('b')
106  self.escortee.setFlightgroupLeader(self.escortee)
107  self.escortee.performDockingOperations(self.adjsys.SignificantUnit(),0)
108  self.adjsys.SignificantUnit().setCombatRole(self.role);
109  if (self.var_to_set!=''):
110  quest.removeQuest (self.you.isPlayerStarship(),self.var_to_set,1)
111  VS.terminateMission(1)
112 def initrandom (factionname,difficulty,creds,entime,numsysaway,jumps=(),var_to_set='',dynfg='',dyntype=''):
113  return escort_mission(factionname,difficulty,20000,vsrandom.randrange(5000,7000),vsrandom.randrange(10,300),creds,entime,numsysaway,jumps,var_to_set,dynfg,dyntype)