Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
quest_blockade.py
Go to the documentation of this file.
1 #---------------------------------------------------------------------------------
2 # Vega Strike script for a quest
3 # Copyright (C) 2008 Vega Strike team
4 # Contact: hellcatv@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 # Description: Jump point blockade to an aera system
13 # adapted from original story by richard
14 # Author: pyramid
15 # Version: 2008-04-23
16 #
17 #---------------------------------------------------------------------------------
18 
19 import VS
20 import Director
21 import Vector
22 import quest
23 import unit
24 import launch
25 import faction_ships
26 import fg_util
27 import universe
28 import vsrandom
29 import news
30 
32  def __init__ (self):
33  self.stage = 1
34  self.player = VS.getPlayer()
35  self.timer = VS.GetGameTime()
36  self.system = VS.getSystemName()
37  self.object = unit.getUnitByName('Jump_To_Nethuuleil')
38  self.groups = 2 #vsrandom.randrange(4,8)
39  self.capital = []
40  self.fighter = []
41  self.msgColor = ("#FFFF99","#FF99FF")
42 
43  # things that could be added
44  # (a) more comm chatter
45  # (b) include animations for the different chatting characters
46  # (c) station some ships in the beginning and make more jump in later
47  # (d) there seems to be a bug or slowness in the ai,
48  # the fighters don't stop shooting until after some seconds after launching
49  # when they have a capship as a target at the start
50  def Execute (self):
51  if (self.player):
52  #print str(self.player.Position())
53  # launch the actors
54  if (self.stage<=self.groups and VS.GetGameTime()>=self.timer):
55  #print "group: " +str(self.stage)
56  self.names = fg_util.GetRandomFGNames(self.groups,"confed")
57  shiptype = faction_ships.getRandomCapitolInt(faction_ships.confed)
58  #print "group/name: " + str(self.stage) + "/"+names[self.stage-1]
59  # launch capital ships
60  number = vsrandom.randrange(2,4)
61  #print ">capital/type: " +str(number)+"/"+shiptype
62  location = Vector.Add (self.object.Position(),(vsrandom.uniform(-10000,10000),
63  vsrandom.uniform(-10000,10000),
64  vsrandom.uniform(-10000,10000)))
65  offset = (vsrandom.uniform(1000,2000),vsrandom.uniform(1000,2000),vsrandom.uniform(1000,2000))
66  for i in range(number):
67  #self.capital += [launch.launch_wave_around_unit(names[self.stage-1],'confed',shiptype,'sitting_duck',1,5000,20000,self.object)]
68  # launch(name,type,faction,unittype,ai,nr,nrwaves,pos,squadlogo)
69  pos = Vector.Add (location,Vector.Scale(offset,i))
70  self.capital += [VS.launch(self.names[self.stage-1],shiptype,'confed','unit','sitting_duck',1,1,pos,'')]
71  # launch fighters
72  number = number*vsrandom.randrange(3,6)
73  # test: Lancelot, Schroedinger, Quicksilver, Convolution
74  shiptype = faction_ships.getRandomFighterInt(faction_ships.confed)
75  #print ">fighters/type: " + str(number) + "/" + shiptype
76  ship = self.capital[0]
77  for i in range(number):
78  self.fighter += [launch.launch_wave_around_unit(self.names[self.stage-1],'confed',shiptype,'sitting_duck',1,1000,2000,ship)]
79  # change orders for capital ships
80  for ship in self.capital:
81  ship.PrimeOrders()
82  unit.faceTaget(ship, self.object)
83  # change orders for fighter ships
84  for ship in self.fighter:
85  #unit.faceTaget(ship, self.capital[0])
86  ship.PrimeOrders()
87  #ship.SetTarget(self.capital[0])
88  ship.SetTarget(self.object)
89  #ship.UnFire()
90  #ship.setFgDirective("E.") # escort
91  ship.LoadAIScript("modules/ai_escortpatrol.py")
92  # time between spawning the groups
93  self.timer = VS.GetGameTime() #+10
94  self.stage += 1
95  if (self.stage==self.groups+1 and VS.GetGameTime()>self.timer):
96  self.stage = 10
97  # publish news
98  if (self.stage==10 and VS.GetGameTime()>self.timer):
99  text = "JUMP POINT BLOCKADE IN " + self.system + " SYSTEM\\\Intelligence has uncovered Aeran plans to invade Confederation space."
100  text += "As a preventive measure " + str(self.groups) + " flight groups were dispatched and stationed near the Nethuuleil jump point. "
101  text += "Multiple capital vessels are guarding the jump point while a multitude of fighter escorts is patrolling nearby space."
102  news.publishNews(text)
103  self.timer = VS.GetGameTime()+5
104  self.stage = 11
105  #make some random chatter
106  if (self.stage==11 and VS.GetGameTime()>self.timer):
107  # select two pilots to chatter
108  flightgroup = 1 #vsrandom.randrange(1,self.groups)
109  numchatters = 0
110  chatters = []
111  while (numchatters<2):
112  chatter = vsrandom.randrange(0,len(self.fighter)-1)
113  if (self.fighter[chatter].getFlightgroupName()==self.names[flightgroup-1]):
114  chatters += [chatter]
115  numchatters += 1
116  VS.IOmessage (0,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"... lousy bar on our mothership?")
117  VS.IOmessage (5,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"Yeah, bad lighting, and no bar company besides your dull face.")
118  VS.IOmessage (10,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"The drinks selection is not the best I have seen.")
119  VS.IOmessage (15,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"And this bartender droid really gets on my nerves.")
120  VS.IOmessage (20,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"He never stops talking for an instant.")
121  VS.IOmessage (25,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"Guess, we've got to live with that.")
122  VS.IOmessage (30,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"Yeah.")
123  self.timer = VS.GetGameTime()+240
124  self.stage = 12
125  if (self.stage==12 and VS.GetGameTime()>self.timer):
126  # select two pilots to chatter
127  flightgroup = 2 #vsrandom.randrange(1,self.groups)
128  numchatters = 0
129  chatters = []
130  while (numchatters<2):
131  chatter = vsrandom.randrange(0,len(self.fighter)-1)
132  if (self.fighter[chatter].getFlightgroupName()==self.names[flightgroup-1]):
133  chatters += [chatter]
134  numchatters += 1
135  VS.IOmessage (0,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"Phil?")
136  VS.IOmessage (10,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"What's up, buddy?")
137  VS.IOmessage (15,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"The rumor is the Aera are planning an invasion.")
138  VS.IOmessage (25,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"Maybe no rumor anymore. Probably it's all over the news now.")
139  VS.IOmessage (35,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"That's why we are here? Will we have to fight?")
140  VS.IOmessage (40,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"Calm down, youngling.")
141  VS.IOmessage (45,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"The war hasn't quite started yet.")
142  VS.IOmessage (50,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"I tell ya. This operation is to prepare the worlds for the war.")
143  VS.IOmessage (55,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"All staged by the higherups.")
144  VS.IOmessage (65,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"You think so? And what if you're not right? Will you take care of my 'lil sister if I die?")
145  VS.IOmessage (75,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"Ho, ho. Now stop that blubber. Nobody's gonna die here.")
146  VS.IOmessage (80,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"Just stick to your orders and by dinner time we'll have a big jar of Pilsner and a nice long talk.")
147  self.timer = VS.GetGameTime()+300
148  self.stage = 13
149  # just a temporary backup
150  if (self.stage==99):
151  #for ship in self.fighter:
152  # ship = VS.getUnit(i)
153  # if (ship.getFlightgroupName()==names[flightgroup]):
154  # print "shipname: " + ship.getFullName()
155  # #ship.setFgDirective("E.") # escort
156  # #VS.PythonAI.XMLScript("++evade.xml")
157  self.stage = 98
158  #if (self.stage==99 and not VS.getSystemName()==self.system):
159  if (not VS.getSystemName()==self.system):
160  self.stage += 1 # don't enter this loop anymore
161  self.playernum = -1
162  self.name = "quest_capital"
163  self.removeQuest()
164  return 0
165  #return 1
166 
168  def __init__ (self):
169  quest.quest_factory.__init__ (self,"quest_blockade")
170  def precondition(self,playernum):
171  return quest.findQuest (playernum,"quest_blockade")
172  def create (self):
173  return quest_blockade()
174 
175 class MissionExecutor(Director.Mission):
176 # call this class from the mission file
177  def __init__(self, classesToExecute):
178  Director.Mission.__init__(self)
179  self.classes = classesToExecute
180  def Execute(self):
181  for c in self.classes:
182  c.Execute()