[go: up one dir, main page]

Menu

[r11]: / modules / bounty.py  Maximize  Restore  History

Download this file

183 lines (175 with data), 8.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import universe
from go_to_adjacent_systems import go_to_adjacent_systems
from go_somewhere_significant import go_somewhere_significant
import vsrandom
import Vector
import launch
import faction_ships
import Director
import Briefing
import unit
import VS
import quest
class bounty (Director.Mission):
def SetVar (self,val):
if (self.var_to_set!=''):
quest.removeQuest (self.you.isPlayerStarship(),self.var_to_set,val)
def __init__ (self,minnumsystemsaway, maxnumsystemsaway, creds, run_away, shipdifficulty, tempfaction,jumps=(),var_to_set='',dynfg='',dyntype="",displayLocation=1,greetingText=['It appears we have something in common, privateer.','My name may be on your list, but now your name is on mine.'],dockable_unit=False):
Director.Mission.__init__ (self)
self.firsttime=VS.GetGameTime()
self.newship=dyntype
self.dynfg=dynfg
self.mplay="all"
self.var_to_set = var_to_set
self.istarget=0
self.obj=0
self.curiter=0
self.arrived=0
self.faction = tempfaction
self.difficulty = shipdifficulty
self.runaway=run_away
self.greetingText=greetingText
self.cred=creds
mysys=VS.getSystemFile()
sysfile = VS.getSystemFile()
self.you=VS.getPlayer()
self.enemy=VS.Unit()
self.adjsys=go_to_adjacent_systems (self.you,vsrandom.randrange(minnumsystemsaway,maxnumsystemsaway+1),jumps)
self.dockable_unit=dockable_unit
self.mplay=universe.getMessagePlayer(self.you)
self.displayLocation=displayLocation
if (self.you):
VS.IOmessage (0,"bounty mission",self.mplay,"[Computer] Bounty Mission Objective: (%.2f Credits)" % self.cred)
self.adjsys.Print("From %s system","Procede to %s","Search for target at %s, your final destination","bounty mission",1)
VS.IOmessage (1,"bounty mission",self.mplay,"Target is a %s unit." % (self.faction))
else:
print "aboritng bounty constructor..."
VS.terminateMission (0)
def AdjLocation(self):
print "ADJUSTING LOC"
self.enemy.SetPosition(Vector.Add(self.enemy.LocalPosition(),Vector.Scale(self.enemy.GetVelocity(),-40))) #eta 20 sec
def Win (self,un,terminate):
self.SetVar(1)
VS.IOmessage (0,"bounty mission",self.mplay,"[Computer] #00ff00Bounty Mission Accomplished!")
un.addCredits(self.cred)
if (terminate):
print "you win bounty mission!"
VS.terminateMission(1)
def Lose (self,terminate):
VS.IOmessage(0,"bounty mission",self.mplay,"[Computer] #ff0000Bounty Mission Failed.")
self.SetVar(-1)
if (terminate):
print "lose bounty mission"
VS.terminateMission(0)
def LaunchedEnemies(self,significant):
pass
def Execute (self):
isSig=0
if (self.you.isNull()):
self.Lose (1)
return
if (self.arrived==2):
if (not self.runaway):
if (not self.istarget):
if (self.enemy):
curun=VS.getUnit(self.curiter)
self.curiter+=1
if (curun==self.enemy):
self.enemy.SetTarget(self.you)
elif (curun.isNull()):
self.curiter=0
else:
if (VS.GetGameTime()>self.firsttime+2.5 and self.enemy):
self.firsttime+=1000000
self.AdjLocation()
if (self.enemy.isNull()):
self.Win(self.you,1)
return
elif (self.arrived==1):
significant=self.adjsys.SignificantUnit()
if (significant.isNull ()):
print "sig null"
VS.terminateMission(0)
return
else:
if (self.you.getSignificantDistance(significant)<self.adjsys.distfrombase):
if (self.newship==""):
self.newship=faction_ships.getRandomFighter(self.faction)
#self.enemy=launch.launch_wave_around_unit("Shadow",self.faction,self.newship,"default",1+self.difficulty,3000.0,4000.0,significant)
L = launch.Launch()
L.fg="Shadow"
L.dynfg=self.dynfg
L.type = self.newship
L.faction = self.faction
L.ai = "default"
L.num=1+self.difficulty
L.minradius=3000.0
L.maxradius = 4000.0
try:
L.minradius*=faction_ships.launch_distance_factor
L.maxradius*=faction_ships.launch_distance_factor
except:
pass
self.enemy=L.launch(significant)
self.you.SetTarget(self.enemy)
import universe
universe.greet(self.greetingText,self.enemy,self.you)
self.obj=VS.addObjective("Destroy the %s ship." % (self.enemy.getName ()))
if (self.enemy):
if (self.runaway):
self.enemy.SetTarget(significant) #CHANGE TO SetTarget ==>NOT setTarget<==
self.enemy.ActivateJumpDrive(0)
self.firsttime=VS.GetGameTime()
#self.enemy.SetPosAndCumPos(Vector.Add(self.you.Position(),Vector.Vector(0,0,self.you.rSize()*1.2)))
self.LaunchedEnemies(significant)
self.arrived=2
else:
print "enemy null"
VS.terminateMission(0)
return
else:
if (self.adjsys.Execute()):
self.arrived=1
if (self.newship=="" and self.dynfg==''):
self.newship=faction_ships.getRandomFighter(self.faction)
self.adjsys=go_somewhere_significant(self.you,self.dockable_unit,10000.0,0,'','',self.displayLocation)
if not self.displayLocation:
VS.addObjective("Search/Destroy "+self.faction.capitalize()+" mark");
localdestination=self.adjsys.SignificantUnit().getName()
tmpfg=self.dynfg
if len(tmpfg)==0:
tmpfg="shadow"
VS.IOmessage (3,"bounty mission",self.mplay,"Hunt the %s unit in the %s flightgroup in this system." % (self.newship,tmpfg))
if (self.runaway): #ADD OTHER JUMPING IF STATEMENT CODE HERE
VS.IOmessage (4,"bounty mission",self.mplay,"Target is fleeing to the jump point!")
VS.IOmessage (5,"bounty mission",self.mplay,"Target Destination appears to be %s" % (localdestination))
elif (self.displayLocation):
VS.IOmessage (4,"bounty mission",self.mplay,"Scanners detect bounty target!")
VS.IOmessage (5,"bounty mission",self.mplay,"Coordinates appear near %s" % (localdestination))
else:
print "Location "+str(self.displayLocation)
VS.IOmessage (4,"bounty mission",self.mplay,"[Computer] Mission description indicates bounty target may be in this system.")
def initbriefing(self):
print "ending briefing"
def loopbriefing(self):
print "loop briefing"
Briefing.terminate();
def endbriefing(self):
print "ending briefing"
def initrandom (minns, maxns, credsmin, credsmax, run_away, minshipdifficulty, maxshipdifficulty,jumps=(),var_to_set=''):
you=VS.getPlayer()
tempfaction='aera'
if (you):
name = you.getFactionName ()
factionname=vsrandom.randrange(0,faction_ships.getMaxFactions())
tempfaction=faction_ships.intToFaction(factionname)
i=0
while ((name==tempfaction or name=="unknown") and i<10):
factionname=vsrandom.randrange(0,faction_ships.getMaxFactions())
tempfaction=faction_ships.intToFaction(factionname)
i+=1
sd = vsrandom.random()*(maxshipdifficulty-minshipdifficulty)+minshipdifficulty
return bounty (minns,maxns,(1.0+(sd*0.5))*(vsrandom.random ()*(credsmax-credsmin)+credsmin),run_away,sd,tempfaction,jumps,var_to_set)
else:
print "aborting bounty initrandom"
VS.terminateMission(0)