Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
quest_shipyardbomb.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@users.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: Shipyard bomb explodes in the system
13 # adapted from original story by richard
14 # Author: pyramid
15 # Version: 2008-04-24
16 #
17 #---------------------------------------------------------------------------------
18 
19 import VS
20 import quest
21 import Director
22 import Vector
23 import unit
24 import vsrandom
25 import news
26 
28 
29  def __init__ (self):
30  self.player = VS.getPlayer()
31  self.stage = 1
32  self.timer = VS.GetGameTime()
33  self.msgColor = ("#FF9999","#FF99FF")
34  self.system = VS.getSystemName()
35  self.shipyard = unit.getUnitByName('Shipyard')
36 
37  # things to add:
38  # (a) the ship being built and debris
39  # (b) patrol disptach from shipyards
40  # (c) late arriving police forces
41  def Execute (self):
42  if (VS.getSystemName()==self.system and self.player and self.shipyard):
43  if (self.stage==1 and VS.GetGameTime()>=self.timer):
44  if (self.shipyard.getSignificantDistance(self.player) > 20000):
45  print 'shipy ret'
46  print "distance" + str(self.shipyard.getSignificantDistance(self.player))
47  return 1
48  else:
49  print 'killing'
50  pos = self.shipyard.Position()
51  size = 10*self.shipyard.rSize()
52  VS.playAnimation("explosion_orange.ani",pos,size)
53  pos = (pos[0]+.5*size,pos[1],pos[2])
54  VS.playAnimation("explosion_orange.ani",pos,size)
55  pos = (pos[0]-size,pos[1],pos[2])
56  VS.playAnimation("explosion_orange.ani",pos,size)
57  VS.playSound("explosion.wav",pos,(1,0,0))
58  self.shipyard.DealDamageToHull ((10,0,0),self.shipyard.GetHull()*.9)
59  self.timer = VS.GetGameTime()+10
60  self.stage = 2
61  if (self.stage==2 and VS.GetGameTime()>=self.timer):
62  VS.IOmessage(0,unit.getUnitFullName(self.shipyard),"all",self.msgColor[0]+"Large Explosion detected... standby...%#@*")
63  text = "NAVAL SHIPYARDS HIT BY BOMB\\\Disaster struck the Confederate Naval Shipyards orbiting Alpha Centauri hours ago, when a powerful explosive device detonated, crippling a fleet carrier that was nearing completion. "
64  text += "At least a dozen casualties were reported with an unknown number of injured, and salvage crews are still working hard to clear the area of wreckage. "
65  text += "A team from the CSP (Confederate Security Police) arrived at the shipyards mere hours after the incident, and an investigation has been launched to determine who the perpetrators of this attack were, whether they were human terrorists or agents of an alien power."
66  news.publishNews(text)
67  self.stage = 99
68  if (self.stage==99 and not VS.getSystemName()==self.system):
69  self.stage += 1 # don't enter this loop anymore
70  self.playernum = -1
71  self.name = "quest_shipyardbomb"
72  self.removeQuest()
73  return 0
74  return 1
75 
77  def __init__ (self):
78  quest.quest_factory.__init__ (self,"quest_shipyardbomb")
79  def precondition(self,playernum):
80  return 1
81  def create (self):
82  return quest_shipyardbomb()
83 
84 class MissionExecutor(Director.Mission):
85 # call this class from the mission file
86  def __init__(self, classesToExecute):
87  Director.Mission.__init__(self)
88  self.classes = classesToExecute
89  def Execute(self):
90  for c in self.classes:
91  c.Execute()