Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
quest_isowing.py
Go to the documentation of this file.
1 import quest
2 import Vector
3 import VS
4 import unit
5 import vsrandom
6 import save_util
7 import faction_ships
8 import universe
9 import launch
11  def recoverShipTypes (self):
12  return save_util.loadStringList (self.playernum,"%s_wingships"%self.faction);
13  def genShipTypes (self,num):
14  namelist= []
15  for i in range (num):
16  namelist+= [faction_ships.getRandomFighter (self.faction)]
17  return namelist
18  def putShipTypes (self,names):
19  save_util.saveStringList(self.playernum,"%s_wingships"%self.faction,names);
20  def Respawn (self):
21  for n in self.winglist:
22  if (n):
23  n.Kill()
24  self.names = self.recoverShipTypes ()
25  self.SpawnShips ()
26  def SpawnShips (self):
27  print "spawning"
28  print self.names
29  playa = VS.getPlayer()
30  if (playa):
31  for n in self.names:
32  if (len (n)>0):
33  self.winglist+=[self.SpawnShip (playa,n)]
34  def SpawnShip (self,playa,name):
35  un=launch.launch_wave_around_unit(playa.getFlightgroupName(),
36  playa.getFactionName(),
37  name,
38  "default",
39  1,
40  playa.rSize()+100,
41  playa.rSize()+1000,
42  playa,
43  "")
44  un.setFactionName(self.faction)
45  return un
46  def makeAdversary (self,faction,num):
47  self.adv=[]
48  playa = VS.getPlayer()
49  if (playa):
50  for i in range (num):
51  self.adv+=[launch.launch_wave_around_unit("Shadow",
52  faction,
54  "default",
55  1,
56  playa.rSize()+500,
57  playa.rSize()+2000,
58  playa,
59  "")]
60  def ReName (self):
61  if (self.cname >= len (self.winglist)):
62  self.cname=0
63  else:
64  if (not self.winglist[self.cname]):
65  if (self.names[self.cname]!=''):
66  self.names[self.cname]=''
67  self.putShipTypes(self.names)
68  self.cname+=1
69  def ReTarget (self):
70  if (self.tname >=len (self.adv)):
71  self.tname=0
72  else:
73  ship = self.winglist[self.tname % len (self.winglist) ]
74  if (self.adv[self.tname]):
75  if (ship):
76  self.adv[self.tname].SetTarget (ship)
77  self.tname +=1
78  else:
79  del self.adv[self.tname]
80  def __init__ (self,faction,num,enfaction,ennum):
81  self.faction = faction
82  self.num = num
83  self.winglist=[]
84  self.adv=[]
85  self.cname=0
86  self.tname=0
87  self.respawn=0
88  self.won=0
89  self.norep=0
90  self.begin=0
91  self.enfaction=enfaction
92  self.ennum = ennum
93  def Intro(self):
94  VS.IOmessage (0,"game","all","[%s Enforcers] Under edict 502419 We hereby command"%self.enfaction)
95  VS.IOmessage (0,"game","all","[%s Enforcers] All %s terrorists to power down and prepare to be boarded."%(self.enfaction,self.faction))
96  VS.IOmessage (3,"game","all","[%s Enforcers] You are in violation of anti-terrorist laws."%self.enfaction)
97  VS.IOmessage (4,"game","all","[%s Enforcers] And are conspiring against the legitimate Star Confederacy."%self.enfaction)
98  VS.IOmessage (5,"game","all","[%s Wing] We have nothing to do with your alleged terrorists"%self.faction)
99  VS.IOmessage (5,"game","all","[%s Wing] and are only exercising our freedom of assembly."%self.faction)
100  VS.IOmessage (8,"game","all","[%s Wing] This is a %s wing requesting assistance from any nearby craft! We are being arrested unfairly!"% (self.faction,self.faction))
101  VS.IOmessage (8,"game","all","[%s Wing] Should anyone honor our request for help we would be severely in debt!"% self.faction)
102 
103  def Begin(self):
104  self.begin=1
105  self.respawn=0
106  if (self.isPersistent()):
107  self.won=1
108  self.names = self.recoverShipTypes ()
109  VS.IOmessage (0,"game","all","Establishing link communication.")
110  VS.IOmessage (0,"game","all","[%s Wing] We're back at your service." % self.faction)
111  else:
112  VS.SetAutoStatus (0,-1)
113  self.names = self.genShipTypes (self.num)
114  self.makeAdversary(self.enfaction,self.ennum)
115  self.Intro()
116  #vsrandom.randrange (1,self.num+1))
117  self.SpawnShips ()
118  self.putShipTypes(self.names)
119 
120  def doWin(self):
121  self.won=1
122  if (self.NothingHere()):
123  return
124  VS.SetAutoStatus (0,0)
125  self.makeQuestPersistent()
126  VS.IOmessage (0,"game","all","Thank you for saving us!")
127  VS.IOmessage (0,"game","all","We owe our lives to you...")
128  VS.IOmessage (0,"game","all","So therefore we will go with you and follow your orders where they may take us")
129  VS.IOmessage (0,"game","all","Together we can succeed!")
130  VS.IOmessage (0,"game","news",'TERRORIST FLIGHTGROUP ESCAPES Recently a long sought for %s wing confronted and destroyed %s special forces. "After learning of a recent assembly by these millitants, we had to move at once; it is sad that these militants preemtively struck our forces before retreating like cowards!" said SubCommander Ret in a recent interview with GNN, "We need to warn our citizens of the presence of roaming %s starships...Any sighting of these starships must be reported to %s authorities immediately." Will such slips in confed security cause further problems in the frontier, or will they finally meet their end after a deadly manhunt? The future remains to be seen. The SubCommanders parting words were: "But See to it I will, I can promise you that!"'%(self.faction,self.enfaction,self.faction,self.enfaction))
131  def doLose(self):
132  VS.SetAutoStatus (0,0)
133  self.removeQuest()
134  VS.IOmessage (0,"game","all","Terrorists eliminated! Looks like we have another success to report for %s."%self.enfaction)
135  VS.IOmessage (0,"game","news",'TERRORIST CELL DESTROYED Recently a %s wing was eliminated by %s special forces. "After learning of a recent assembly by these millitants, we had to move at once!" said SubCommander Ret in a recent interview with GNN, "It is good to see such justice served on our frontiers!" Hopefully this will reduce the recent rash of violence in the frontier sectors of our society!'%(self.faction,self.enfaction))
136  if (self.won==0):
137  VS.SetAutoStatus (0,0)
138 
139  def NothingHere(self):
140  for i in self.winglist:
141  if (i):
142  return 0
143  return 1
144 
145  def Execute (self):
146  playa=VS.getPlayer()
147  if (playa.isNull()):
148  if (self.won==1):
149  self.respawn=1
150  return 1
151  if (self.begin==0):
152  self.Begin()
153  if (self.respawn):
154  self.respawn=0
155  self.Respawn()
156  if (len (self.winglist)==0):
157  VS.SetAutoStatus (0,0)
158  return 0
159  if (len (self.adv)==0):
160  if (self.won==0):
161  self.doWin()
162  else:
163  self.ReTarget()
164  self.norep+=1
165  if (self.norep>100):
166  self.ReName()
167  self.norep=0
168  if (self.NothingHere()):
169  self.doLose()
170  return 0
171  return 1
172 
174  def __init__ (self):
175  quest.quest_factory.__init__ (self,"quest_isowing")
176  def create (self):
177  return quest_isowing("ISO",2,"confed",10)