Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
quest_dispute.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: A small dispute about docking priority between a merchant and an
13 # ISO ship. Based on a story and original script by PeteyG
14 # Author: pyramid
15 # Version: 2008-04-20
16 #
17 #---------------------------------------------------------------------------------
18 
19 # import used libraries
20 import quest
21 import Director
22 import VS
23 import Vector
24 import universe
25 import unit
26 import launch
27 import news
28 
30  def __init__ (self):
31  self.player = VS.getPlayer()
32  self.stage = 1
33  self.timer = VS.GetGameTime()
34  self.talktime = VS.GetGameTime()
35  self.anitime = VS.GetGameTime()
36  self.merColor = "#99FFFF"
37  self.socColor = "#FF9999"
38  # This will get an agricultural station from the system, and assign it to 'station'
39  # this station is the only one that has only one docking port, thus fits perfectly
40  # into this quest theme
41  self.station = unit.getUnitByName('Agricultural_Station')
42 
43  # the flow of the quest
44  # (0) check if player is in system
45  # (1) launch the actor units
46  # (2) start docking dispute conversation
47  # (3) play dispute comm animation
48  # (4) start armed conflict
49  # (5) socialist call for help
50  # (6) play comm animation
51  # (7) wait for player interaction - check who's still alive
52  # (11) socialist reward
53  # (21) merchant reward
54  # (12/22) play the comm animation
55  # (30) let the winner dock at the station
56  # (99) finish quest
57  # there could be more variety:
58  # (a) confed militia flying in to get the trouble makers
59  # (b) destoyed ships spawning escape pods
60  # (c) some provoking conversation during the conflict
61  # (d) breaking off the battle after some time (and off to dock)
62  # (e) station calling for the guys to stop hitting her
63  def Execute (self):
64  if (self.player and self.station):
65  # launches the particpating actors
66  if (self.stage==1 and VS.GetGameTime()>self.timer and self.station.getDistance(self.player)<50000):
67  self.stageLaunchActors()
68  self.stage = 2
69 
70  # checks to see if the self.player is within 10km of the station to initiate the dispute
71  if (self.stage==2 and VS.GetGameTime()>self.timer and self.station.getDistance(self.player)<15000):
72  self.stageDockingDispute()
73  self.talktime = VS.GetGameTime()
74  self.stage = 3
75 
76  # play the talk animation
77  if (self.stage==3 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
78  # check which animation to play
79  for index in range (len(self.sequence)):
80  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
81  # play the animation
82  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
83  # this is how long one animation takes
84  self.anitime = VS.GetGameTime()+2
85  if (self.stage==3 and VS.GetGameTime()>=self.timer):
86  self.stage = 4
87 
88  # get the merchant to attack
89  if (self.stage==4 and VS.GetGameTime()>self.timer):
90  # the two ships start to attack each other
91  self.merchant.SetTarget(self.socialist)
92  VS.AdjustRelation(self.merchant.getFactionName(),self.socialist.getFactionName(),-5,1)
93  self.merchant.LoadAIScript("default")
94  # attack directive - no ai change, no target change
95  self.merchant.setFgDirective("A.")
96  self.timer = VS.GetGameTime()+5
97  self.stage = 5
98 
99  # get the socialist to attack
100  if (self.stage==5 and VS.GetGameTime()>self.timer):
101  # the privateer gets involved... or does he?
102  VS.IOmessage (0,"[Lenin's Mercy]","privateer",self.socColor+"Mayday! We are under attack! Privateer, please help us... we are no match for them. We have wounded on board!")
103  VS.IOmessage (6,"[VulCorp Transport A-5]","privateer",self.merColor+"Privateer, if you look the other way... you will be duly compensated.")
104  self.animations = [["com_dispute_socialist.ani",2],["com_dispute_merchant.ani",2]]
105  self.sequence = [[0,6,0],[6,4,1]]
106  self.talktime = VS.GetGameTime()
107  VS.AdjustRelation(self.socialist.getFactionName(),self.merchant.getFactionName(),-5,1)
108  self.socialist.SetTarget(self.merchant)
109  self.socialist.LoadAIScript("default")
110  self.socialist.setFgDirective("A.")
111  self.timer = VS.GetGameTime()+10
112  self.stage = 6
113 
114  # play the talk animation
115  if (self.stage==6 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
116  for index in range (len(self.sequence)):
117  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
118  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
119  self.anitime = VS.GetGameTime()+2
120  if (self.stage==6 and VS.GetGameTime()>=self.timer):
121  self.stage = 7
122 
123  # we need to refresh the ai during battle since it lasts for only 7 seconds
124  if (self.stage==7 and VS.GetGameTime()>self.timer):
125  self.merchant.LoadAIScript("default")
126  self.socialist.LoadAIScript("default")
127  self.timer = VS.GetGameTime()+2
128 
129  # evaluate the conflict result
130  if (self.stage==7 and self.merchant.isNull()):
131  VS.IOmessage (0,"[VulCorp Transport A-5]","all",self.merColor+"Oh nooooo...!!!!!")
132  self.player.commAnimation("com_dispute_merchant.ani")
133  self.stage = 11
134  if (self.stage==7 and self.socialist.isNull()):
135  VS.IOmessage (0,"[Lenin's Mercy]","all",self.socColor+"Liberte! Egalite!! Fraternite...!!!!!")
136  self.player.commAnimation("com_dispute_socialist.ani")
137  self.stage = 21
138 
139  # if the merchant has died, give player the socialist reward
140  if (self.stage==11 and VS.GetGameTime()>self.timer):
141  self.socialist.PrimeOrders()
142  VS.IOmessage (0,"[Lenin's Mercy]","privateer",self.socColor+"Thank you, Privateer! The Interstellar Socialist Organization is in your debt. We are getting our wounded to the base's medical facility.")
143  VS.IOmessage (5,"[Lenin's Mercy]","privateer",self.socColor+"We have no money... but we are transmitting you the coordinates of the cargo we dumped to make room for the attack victims. Do with it what you will.")
144  VS.IOmessage (10,"[Lenin's Mercy]","privateer",self.socColor+"You have made a friend with the ISO today. Have a safe journey.")
145  self.animations = [["com_dispute_socialist.ani",2]]
146  self.sequence = [[0,15,0]]
147  self.talktime = VS.GetGameTime()
148  # launches various types of cargo as reward
149  # launch_wave_around_unit (fgname, faction, type, ai, nr_ships, minradius, maxradius, my_unit,logo='',useani=1,skipdj=0)
150  self.cargo = launch.launch_wave_around_unit("Cargo",'neutral','iron_ore.cargo',"default",2,3000,6000,self.player)
151  self.cargo = launch.launch_wave_around_unit("Cargo",'neutral','tungsten_ore.cargo',"default",2,3000,6000,self.player)
152  self.cargo = launch.launch_wave_around_unit("Cargo",'neutral','generic_cargo',"default",16,3000,6000,self.player)
153  # reputation with ISO goes up. Not sure of the numbers
154  VS.AdjustRelation(self.player.getFactionName(),self.socialist.getFactionName(),1,5)
155  # publish news
156  text = "PRIVATEER SAVES SHIPLOAD OF WOUNDED\\\Today, an unprecedented dispute about landing priorities took place close to a station in the Regallis system of Sol sector. "
157  text += "A merchant was delivering a priority shipment to a station in the system while an ISO transport vessel requested emergency landing having twelve rescued passengers on board who were previously wounded in a pirate attack. "
158  text += "A privateer approaching that base at the same time, and assisting the dispute, reacted to the situation before security forces could arrive at the scene and promptly removed the capitalist bloodsucker, thus saving many lives. "
159  text += "Presently, the injured are being taken care of at the medical facilities of the station with two heavily wounded remaining under intensive care."
160  news.publishNews(text)
161  # set next stage conditions
162  self.timer = VS.GetGameTime()+15
163  self.winner = self.socialist
164  self.stage = 12
165 
166  # play the talk animation
167  if (self.stage==12 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
168  for index in range (len(self.sequence)):
169  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
170  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
171  self.anitime = VS.GetGameTime()+2
172  if (self.stage==12 and VS.GetGameTime()>=self.timer):
173  self.stage = 30
174 
175  # if the merchant ship is still alive
176  if (self.stage==21 and VS.GetGameTime()>self.timer):
177  self.merchant.PrimeOrders()
178  # if the merchant is still friends with the self.player, the merchant gives him a nice chunk of cash
179  if (5 > -.1):
180  VS.IOmessage (0,"[VulCorp Transport A-5]","privateer",self.merColor+"Privateer, thank you for your cooperation.")
181  VS.IOmessage (3,"[VulCorp Transport A-5]","privateer",self.merColor+"We will be able to make a killing on this shipment thanks to you. Here are 15000 credits for your trouble.")
182  self.animations = [["com_dispute_merchant.ani",2]]
183  self.sequence = [[0,8,0]]
184  self.talktime = VS.GetGameTime()
185  self.player.addCredits(15000)
186  # rep with merchants goes up
187  VS.AdjustRelation(self.player.getFactionName(),self.merchant.getFactionName(),.1,.5)
188  # publish news
189  text = "MALICIOUS MERCHANT MASSACRES MARXIST MERCY MISSION\\\Today, an unprecedented dispute about landing priorities took place close to a station in the Regallis system of Sol sector. "
190  text += "A merchant was delivering a priority shipment to a station in the system while an ISO transport vessel requested emergency landing having twelve rescued passengers on board who were previously wounded in a pirate attack. "
191  text += "Before security forces could arrive at the scene the merchant pilot promptly applied his own justice scheme thus reducing the other vessel cum content to space dust."
192  news.publishNews(text)
193  # set next stage conditions
194  self.timer = VS.GetGameTime()+8
195  self.winner = self.merchant
196  self.stage = 22
197 
198  # play the talk animation
199  if (self.stage==22 and VS.GetGameTime()<self.timer and VS.GetGameTime()>=self.anitime):
200  for index in range (len(self.sequence)):
201  if (VS.GetGameTime()-self.talktime>=self.sequence[index][0] and VS.GetGameTime()-self.talktime<=self.sequence[index][0]+self.sequence[index][1]):
202  self.player.commAnimation(self.animations[self.sequence[index][2]][0])
203  self.anitime = VS.GetGameTime()+2
204  if (self.stage==22 and VS.GetGameTime()>=self.timer):
205  self.stage = 30
206 
207  # let the remaining ship approach the station and dock
208  if (self.stage==30 and VS.GetGameTime()>self.timer):
209  self.timer = VS.GetGameTime()+5
210  #if (not self.station.isDocked(self.winner)):
211  if (not self.winner.isNull()):
212  # performDockingOperations is unusable
213  # 1st it lets the ship fly through the stations
214  # 2nd it doesn't dock the unit
215  #self.winner.performDockingOperations(self.station,1)
217  else:
218  self.stage = 99
219 
220  if (self.stage==99 and VS.GetGameTime()>self.timer):
221  self.playernum = -1
222  self.name = "quest_dispute"
223  self.removeQuest()
224  self.stage += 1 # don't enter this loop anymore
225  return 0
226  return 1
227 
228  def stageLaunchActors(self):
229  radius = self.station.rSize()
230  # launch the two freighters
231  self.merchant = launch.launch_wave_around_unit("VulCorp Transport A-5","merchant_guild","Plowshare","ai_sitting_duck.py",1,radius,radius*2,self.station)
232  self.socialist = launch.launch_wave_around_unit("Lenin's Mercy","ISO","Llama","ai_sitting_duck.py",1,radius,radius*2,self.station)
233  # make the ship a real sitting duck, won't accept any other orders
234  self.merchant.PrimeOrders()
235  self.socialist.PrimeOrders()
236  # make the actors oriented towards the station
237  unit.faceTaget(self.merchant, self.station)
238  unit.faceTaget(self.socialist, self.station)
239  # make the actors fly close to the docking port
240  self.merchant.performDockingOperations(self.station,False)
241  self.socialist.performDockingOperations(self.station,False)
242 
244  # the comm interchange between the two ships
245  VS.IOmessage (0,"[VulCorp Transport A-5]","all",self.merColor+"VulCorp Transport alpha five requesting priority docking.")
246  VS.IOmessage (5,"[VulCorp Transport A-5]","all",self.merColor+"We have a load of spare parts that needs to be delivered within the next half hour, or else we don't get paid.")
247  VS.IOmessage (15,"[Lenin's Mercy]","all",self.socColor+"Negative, transport Lenin's Mercy requesting emergency docking. We have thirteen critically injured passengers.")
248  VS.IOmessage (25,"[Lenin's Mercy]","all",self.socColor+"We picked them up after a squadron of pirates attacked their ship. They need immediate medical attention!")
249  VS.IOmessage (35,"[VulCorp Transport A-5]","all",self.merColor+"Station control, might we remind you that we have a contract with your base? We demand priority in the docking queue so we can complete our transaction.")
250  VS.IOmessage (45,"[Lenin's Mercy]","all",self.socColor+"You capitalist pigs! We have dying men and women on board, and all you can think about is your filthy money!")
251  VS.IOmessage (55,"[VulCorp Transport A-5]","all",self.merColor+"Socialist vessel: Stay out of the docking queue or you will be fired upon. We will not let a bunch of bleeding communists turn this major deal sour!")
252  VS.IOmessage (65,"[Lenin's Mercy]","all",self.socColor+"Negative, VulCorp Transport. The lives of our passengers are worth more than your profits!")
253  VS.IOmessage (75,"[VulCorp Transport A-5]","all",self.merColor+"All batteries! Open fire!!")
254  # initialize the animation parameters
255  # the animations to be alternated - animation file and animation duration
256  self.animations = [["com_dispute_merchant.ani",2],["com_dispute_socialist.ani",2]]
257  # states the beginning, duration, and animation number to be played
258  self.sequence = [[0,10,0],[15,15,1],[35,5,0],[45,5,1],[55,5,0],[65,5,1],[75,4,0]]
259  # set the beginning of the talk sequence
260  self.talktime = VS.GetGameTime()
261  self.timer = VS.GetGameTime()+80
262 
264 # call this class from the adventure file
265  def __init__ (self):
266  quest.quest_factory.__init__ (self,"quest_dispute")
267  def create (self):
268  return quest_dispute()
269 
270 class Executor(Director.Mission):
271 # call this class from the mission file
272  def __init__(self, classesToExecute):
273  Director.Mission.__init__(self)
274  self.classes = classesToExecute
275  def Execute(self):
276  for c in self.classes:
277  c.Execute()