def GeneratePatrolList (self): VS.IOmessage (0,"patrol",self.mplay,"You must get within %f klicks of" % self.distance) count=self.quantity*6 str="" import universe self.patrolpoints=universe.significantUnits() while (len(self.patrolpoints)>self.quantity and len(self.patrolpoints)): del self.patrolpoints[vsrandom.randrange(0,len(self.patrolpoints))] for sig in self.patrolpoints: self.quantity=self.quantity-1 fac =sig.getFactionName() nam =unit.getUnitFullName(sig) enam =unit.getUnitFullName(sig,True) sig.setMissionRelevant() if (fac!="neutral"): obj=VS.addObjective ("Scan %s"%nam) VS.IOmessage (0,"patrol",self.mplay,"%s owned %s " % (fac,enam)) else: if (sig.isPlanet()): nam =unit.getUnitFullName(sig) if (sig.isJumppoint()): obj=VS.addObjective ("Scan Jumppoint %s" % nam) else: obj=VS.addObjective ("Scan %s" % nam) else: obj=VS.addObjective ("Scan Natural Phenomenon: %s" % nam) VS.IOmessage (0,"patrol",self.mplay,"The object %s " % enam) VS.setOwner(int(obj),self.you) VS.setCompleteness(int(obj),0.0) self.objectives+=[int(obj)] self.quantity=0
def GeneratePatrolList(self): VS.IOmessage(0, "patrol", self.mplay, "You must get within %f klicks of" % self.distance) count = self.quantity * 6 str = "" import universe self.patrolpoints = universe.significantUnits() while (len(self.patrolpoints) > self.quantity and len(self.patrolpoints)): del self.patrolpoints[vsrandom.randrange(0, len(self.patrolpoints))] for sig in self.patrolpoints: self.quantity = self.quantity - 1 fac = sig.getFactionName() nam = unit.getUnitFullName(sig) enam = unit.getUnitFullName(sig, True) sig.setMissionRelevant() if (fac != "neutral"): obj = VS.addObjective("Scan %s" % nam) VS.IOmessage(0, "patrol", self.mplay, "%s owned %s " % (fac, enam)) else: if (sig.isPlanet()): nam = unit.getUnitFullName(sig) if (sig.isJumppoint()): obj = VS.addObjective("Scan Jumppoint %s" % nam) else: obj = VS.addObjective("Scan %s" % nam) else: obj = VS.addObjective("Scan Natural Phenomenon: %s" % nam) VS.IOmessage(0, "patrol", self.mplay, "The object %s " % enam) VS.setOwner(int(obj), self.you) VS.setCompleteness(int(obj), 0.0) self.objectives += [int(obj)] self.quantity = 0
def GenerateEnemies(self, jp, you): VS.IOmessage(0, "escort mission", self.mplay, "You must protect %s." % unit.getUnitFullName(jp, True)) count = 0 jp.setMissionRelevant() VS.addObjective("Protect %s from the %s" % (unit.getUnitFullName(jp), self.faction.capitalize().replace("_", " "))) self.objective = VS.addObjective("Destroy All %s Hostiles" % self.faction) VS.setCompleteness(self.objective, 0.0) print("quantity " + str(self.quantity)) while (count < self.quantity): L = launch.Launch() L.fg = "Shadow" L.dynfg = self.dynatkfg if (self.dynatktype == ''): L.type = faction_ships.getRandomFighter(self.faction) else: L.type = self.dynatktype L.ai = "default" L.num = 1 L.minradius = 2000.0 L.maxradius = 4500.0 try: L.minradius *= faction_ships.launch_distance_factor L.maxradius *= faction_ships.launch_distance_factor except: pass L.faction = self.faction launched = L.launch(you) if (count == 0): self.you.SetTarget(launched) if (self.defend): launched.SetTarget(jp) else: launched.SetTarget(you) if (self.dedicatedattack): launched.setFgDirective('B') self.attackers += [launched] count += 1 if (self.respawn == 0 and len(self.attackers) > 0): self.respawn = 1 import universe universe.greet(self.greetingText, self.attackers[0], you) else: VS.IOmessage(0, "escort mission", self.mplay, "Eliminate all %s ships here" % self.faction) self.quantity = 0
def Track(self, shiptype): import VS obj = VS.addObjective("Destroy %s." % (unit.getUnitFullName(shiptype, True))) VS.setOwner(obj, self.you) VS.setCompleteness(obj, -1.0) self.activeships.append((shiptype, obj))
def LaunchAlly(self): import launch import faction_ships import universe L = launch.Launch() L.faction=self.friendlyfaction L.fg="Patrol_Wing" L.dynfg="" 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 L.num=1 L.ai="default" L.type = faction_ships.getRandomCapitol(self.friendlyfaction) self.ally = L.launch(self.you) self.ally.setMissionRelevant() self.allyobj=VS.addObjective("Protect the %s"%unit.getUnitFullName(self.ally)) L.type = faction_ships.getRandomFighter(self.friendlyfaction) import vsrandom L.num=vsrandom.randrange(3,6) L.launch(self.you) universe.greet(self.allygreetingtext,self.ally,self.you)
def Execute (self): if (VS.getSystemName()==self.system and self.player and self.shipyard): if (self.stage==1 and VS.GetGameTime()>=self.timer): if (self.shipyard.getSignificantDistance(self.player) > 20000): print('shipy ret') print("distance" + str(self.shipyard.getSignificantDistance(self.player))) return 1 else: print('killing') pos = self.shipyard.Position() size = 10*self.shipyard.rSize() VS.playAnimation("explosion_orange.ani",pos,size) pos = (pos[0]+.5*size,pos[1],pos[2]) VS.playAnimation("explosion_orange.ani",pos,size) pos = (pos[0]-size,pos[1],pos[2]) VS.playAnimation("explosion_orange.ani",pos,size) VS.playSound("explosion.wav",pos,(1,0,0)) self.shipyard.DealDamageToHull ((10,0,0),self.shipyard.GetHull()*.9) self.timer = VS.GetGameTime()+10 self.stage = 2 if (self.stage==2 and VS.GetGameTime()>=self.timer): VS.IOmessage(0,unit.getUnitFullName(self.shipyard),"all",self.msgColor[0]+"Large Explosion detected... standby...%#@*") 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. " 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. " 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." news.publishNews(text) self.stage = 99 if (self.stage==99 and not VS.getSystemName()==self.system): self.stage += 1 # don't enter this loop anymore self.playernum = -1 self.name = "quest_shipyardbomb" self.removeQuest() return 0 return 1
def GenerateEnemies (self,jp,you): count=0 self.objectivezero=VS.addObjective ("Protect %s from %s" % (unit.getUnitFullName(jp),self.faction)) self.objective = VS.addObjective ("Destroy All %s Hostiles" % self.faction) VS.setCompleteness(self.objective,0.0) print "quantity "+str(self.quantity) while (count<self.quantity): L = launch.Launch() L.fg="Shadow";L.dynfg=self.dynatkfg; if (self.dynatktype==''): L.type=faction_ships.getRandomFighter(self.faction) else: L.type=self.dynatktype L.ai="default";L.num=1;L.minradius=20000.0;L.maxradius=25000.0 try: L.minradius*=faction_ships.launch_distance_factor L.maxradius*=faction_ships.launch_distance_factor except: pass L.faction=self.faction launched=L.launch(you) if (count==0): self.you.SetTarget(launched) if (1): launched.SetTarget (jp) else: launched.SetTarget (you) if (self.dedicatedattack): launched.setFgDirective('B') self.attackers += [ launched ] count+=1 VS.adjustFGRelationModifier(self.younum,launched.getFlightgroupName(),-2); if (self.respawn==0 and len(self.attackers)>0): self.respawn=1 import universe universe.greet(self.greetingText,self.attackers[0],you); else: VS.IOmessage (0,"escort mission",self.mplay,"Eliminate all %s ships here" % self.faction) VS.IOmessage (0,"escort mission",self.mplay,"You must protect %s." % unit.getUnitFullName(jp)) self.quantity=0
def FinishedPatrol (self): if (self.jnum<len(self.patrolpoints)): jpoint =self.patrolpoints[self.jnum] if (jpoint.isNull()): self.DeletePatrolPoint(self.jnum,"Debris") else: if (self.you.getSignificantDistance (jpoint)<self.distance): self.DeletePatrolPoint(self.jnum,unit.getUnitFullName(jpoint)) else: self.jnum+=1 else: self.jnum=0 return (len(self.patrolpoints)==0)
def NoEnemiesInArea (self,jp): if (self.adjsys.DestinationSystem()!=VS.getSystemFile()): return 0 if (self.ship_check_count>=len(self.attackers)): VS.setCompleteness(self.objective,1.0) return 1 un= self.attackers[self.ship_check_count] self.ship_check_count+=1 if (un.isNull() or (un.GetHullPercent()<.7 and self.defendee.getDistance(un)>7000)): return 0 else: VS.setObjective(self.objective,"Destroy the %s"%unit.getUnitFullName(un)) self.ship_check_count=0 return 0
def FinishedPatrol(self): if (self.jnum < len(self.patrolpoints)): jpoint = self.patrolpoints[self.jnum] if (jpoint.isNull()): self.DeletePatrolPoint(self.jnum, "Debris") else: if (self.you.getSignificantDistance(jpoint) < self.distance): self.DeletePatrolPoint(self.jnum, unit.getUnitFullName(jpoint)) else: self.jnum += 1 else: self.jnum = 0 return (len(self.patrolpoints) == 0)
def __init__(self, creds, faction, quantity, category, returntobase, var_when_done=''): Director.Mission.__init__(self) self.newship = "" self.mplay = "all" self.obj = 0 self.enemy = VS.Unit() self.curiter = 0 self.content = "" self.quantity = quantity self.arrived = 0 self.faction = faction self.cred = creds self.category = category self.donevar = var_when_done sysfile = VS.getSystemFile() self.newship = faction_ships.getRandomFighter('merchant') self.you = VS.getPlayer() self.pos = self.you.Position() self.gosig = go_somewhere_significant(self.you, 0, 10000.) self.mplay = universe.getMessagePlayer(self.you) if (self.you): VS.IOmessage( 0, "plunder mission", self.mplay, "Your mission is to destroy a %s merchant unit." % (self.newship)) VS.IOmessage( 1, "plunder mission", self.mplay, "It is orbiting around the %s planet in the system." % (unit.getUnitFullName(self.gosig.SignificantUnit()))) VS.IOmessage( 2, "plunder mission", self.mplay, "After it is destroyed, pick up all %s cargo that got ejected." % self.category) VS.IOmessage( 3, "plunder mission", self.mplay, "Then return to a %s base with your cargo. #00ff00Good luck!" % self.faction) else: print "aboritng plunder constructor..." VS.terminateMission(0)
def SuccessMission (self): self.defendee.setFgDirective('b') self.defendee.setFlightgroupLeader(self.defendee) if (self.incoming): import unit un=unit.getSignificant(vsrandom.randrange(0,20),1,0) if (un.getName()==self.defendee.getName()): un=unit.getSignificant(vsrandom.randrange(0,30),1,0) if (un.getName()==self.defendee.getName()): un=unit.getSignificant(vsrandom.randrange(0,40),1,0) if (un.getName()==self.defendee.getName()): un=unit.getSignificant(vsrandom.randrange(0,30),1,0) if (un.getName()==self.defendee.getName()): un=unit.getSignificant(vsrandom.randrange(0,40),1,0) if (un.getName()!=self.defendee.getName()): self.defendee.performDockingOperations(un,0) #print "docking with "+un.getName() self.todock=un VS.setObjective (self.objectivezero,"Escort To %s" % unit.getUnitFullName(un)) else: self.defendee.ActivateJumpDrive(0) self.defendee.SetTarget(self.adjsys.SignificantUnit()) self.successdelay=VS.GetGameTime()+1
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.enemy.SetTarget(self.you) self.enemy.setFgDirective('B.') self.you.SetTarget(self.enemy) import universe universe.greet(self.greetingText,self.enemy,self.you) self.obj=VS.addObjective("Destroy %s." % (unit.getUnitFullName(self.enemy))) 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=unit.getUnitFullName(self.adjsys.SignificantUnit(),True) 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 Execute(self): if (self.player): #print str(self.player.Position()) # launch the actors if (self.stage <= self.groups and VS.GetGameTime() >= self.timer): #print "group: " +str(self.stage) self.names = fg_util.GetRandomFGNames(self.groups, "confed") shiptype = faction_ships.getRandomCapitolInt( faction_ships.confed) #print "group/name: " + str(self.stage) + "/"+names[self.stage-1] # launch capital ships number = vsrandom.randrange(2, 4) #print ">capital/type: " +str(number)+"/"+shiptype location = Vector.Add(self.object.Position(), (vsrandom.uniform(-10000, 10000), vsrandom.uniform(-10000, 10000), vsrandom.uniform(-10000, 10000))) offset = (vsrandom.uniform(1000, 2000), vsrandom.uniform(1000, 2000), vsrandom.uniform(1000, 2000)) for i in range(number): #self.capital += [launch.launch_wave_around_unit(names[self.stage-1],'confed',shiptype,'sitting_duck',1,5000,20000,self.object)] # launch(name,type,faction,unittype,ai,nr,nrwaves,pos,squadlogo) pos = Vector.Add(location, Vector.Scale(offset, i)) self.capital += [ VS.launch(self.names[self.stage - 1], shiptype, 'confed', 'unit', 'sitting_duck', 1, 1, pos, '') ] # launch fighters number = number * vsrandom.randrange(3, 6) # test: Lancelot, Schroedinger, Quicksilver, Convolution shiptype = faction_ships.getRandomFighterInt( faction_ships.confed) #print ">fighters/type: " + str(number) + "/" + shiptype ship = self.capital[0] for i in range(number): self.fighter += [ launch.launch_wave_around_unit( self.names[self.stage - 1], 'confed', shiptype, 'sitting_duck', 1, 1000, 2000, ship) ] # change orders for capital ships for ship in self.capital: ship.PrimeOrders() unit.faceTaget(ship, self.object) # change orders for fighter ships for ship in self.fighter: #unit.faceTaget(ship, self.capital[0]) ship.PrimeOrders() #ship.SetTarget(self.capital[0]) ship.SetTarget(self.object) #ship.UnFire() #ship.setFgDirective("E.") # escort ship.LoadAIScript("modules/ai_escortpatrol.py") # time between spawning the groups self.timer = VS.GetGameTime() #+10 self.stage += 1 if (self.stage == self.groups + 1 and VS.GetGameTime() > self.timer): self.stage = 10 # publish news if (self.stage == 10 and VS.GetGameTime() > self.timer): text = "JUMP POINT BLOCKADE IN " + self.system + " SYSTEM\\\Intelligence has uncovered Aeran plans to invade Confederation space." text += "As a preventive measure " + str( self.groups ) + " flight groups were dispatched and stationed near the Nethuuleil jump point. " text += "Multiple capital vessels are guarding the jump point while a multitude of fighter escorts is patrolling nearby space." news.publishNews(text) self.timer = VS.GetGameTime() + 5 self.stage = 11 #make some random chatter if (self.stage == 11 and VS.GetGameTime() > self.timer): # select two pilots to chatter flightgroup = 1 #vsrandom.randrange(1,self.groups) numchatters = 0 chatters = [] while (numchatters < 2): chatter = vsrandom.randrange(0, len(self.fighter) - 1) if (self.fighter[chatter].getFlightgroupName() == self.names[flightgroup - 1]): chatters += [chatter] numchatters += 1 VS.IOmessage( 0, unit.getUnitFullName(self.fighter[chatters[0]]), "all", self.msgColor[0] + "... lousy bar on our mothership?") VS.IOmessage( 5, unit.getUnitFullName(self.fighter[chatters[1]]), "all", self.msgColor[1] + "Yeah, bad lighting, and no bar company besides your dull face." ) VS.IOmessage( 10, unit.getUnitFullName(self.fighter[chatters[0]]), "all", self.msgColor[0] + "The drinks selection is not the best I have seen.") VS.IOmessage( 15, unit.getUnitFullName(self.fighter[chatters[1]]), "all", self.msgColor[1] + "And this bartender droid really gets on my nerves.") VS.IOmessage( 20, unit.getUnitFullName(self.fighter[chatters[1]]), "all", self.msgColor[1] + "He never stops talking for an instant.") VS.IOmessage( 25, unit.getUnitFullName(self.fighter[chatters[0]]), "all", self.msgColor[0] + "Guess, we've got to live with that.") VS.IOmessage(30, unit.getUnitFullName(self.fighter[chatters[1]]), "all", self.msgColor[1] + "Yeah.") self.timer = VS.GetGameTime() + 240 self.stage = 12 if (self.stage == 12 and VS.GetGameTime() > self.timer): # select two pilots to chatter flightgroup = 2 #vsrandom.randrange(1,self.groups) numchatters = 0 chatters = [] while (numchatters < 2): chatter = vsrandom.randrange(0, len(self.fighter) - 1) if (self.fighter[chatter].getFlightgroupName() == self.names[flightgroup - 1]): chatters += [chatter] numchatters += 1 VS.IOmessage(0, unit.getUnitFullName(self.fighter[chatters[0]]), "all", self.msgColor[0] + "Phil?") VS.IOmessage(10, unit.getUnitFullName(self.fighter[chatters[1]]), "all", self.msgColor[1] + "What's up, buddy?") VS.IOmessage( 15, unit.getUnitFullName(self.fighter[chatters[0]]), "all", self.msgColor[0] + "The rumor is the Aera are planning an invasion.") 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." ) VS.IOmessage( 35, unit.getUnitFullName(self.fighter[chatters[0]]), "all", self.msgColor[0] + "That's why we are here? Will we have to fight?") VS.IOmessage(40, unit.getUnitFullName(self.fighter[chatters[1]]), "all", self.msgColor[1] + "Calm down, youngling.") VS.IOmessage( 45, unit.getUnitFullName(self.fighter[chatters[1]]), "all", self.msgColor[1] + "The war hasn't quite started yet.") 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." ) VS.IOmessage(55, unit.getUnitFullName(self.fighter[chatters[1]]), "all", self.msgColor[1] + "All staged by the higherups.") 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?" ) VS.IOmessage( 75, unit.getUnitFullName(self.fighter[chatters[1]]), "all", self.msgColor[1] + "Ho, ho. Now stop that blubber. Nobody's gonna die here.") 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." ) self.timer = VS.GetGameTime() + 300 self.stage = 13 # just a temporary backup if (self.stage == 99): #for ship in self.fighter: # ship = VS.getUnit(i) # if (ship.getFlightgroupName()==names[flightgroup]): # print "shipname: " + ship.getFullName() # #ship.setFgDirective("E.") # escort # #VS.PythonAI.XMLScript("++evade.xml") self.stage = 98 #if (self.stage==99 and not VS.getSystemName()==self.system): if (not VS.getSystemName() == self.system): self.stage += 1 # don't enter this loop anymore self.playernum = -1 self.name = "quest_capital" self.removeQuest() return 0
def Execute(self): isSig = 0 if (self.you.isNull()): self.Lose(1) return if (self.arrived == 3): self.gosig.Execute() cargquant = self.you.GetCargo(self.content).GetQuantity() if cargquant < self.quantity: # print "ohnooohnoohno!!!!!!!" VS.IOmessage( 0, "plunder mission", self.mplay, 'Not enough of %s cargo... Get more until you have %d.' % (self.quantity)) VS.setCompleteness(self.obj, 0.) elif self.you.isDocked(self.gosig.SignificantUnit( )) or self.gosig.SignificantUnit().isDocked(self.you): # print "du hast gewonnen!" self.you.removeCargo(self.content, self.quantity, 1) self.Win(self.you, 1) # else: # print 'hihohohiho' elif (self.arrived == 2): cargquant = self.you.GetCargo(self.content).GetQuantity() VS.setCompleteness(self.obj, float(cargquant) / float(self.quantity)) if cargquant == self.quantity: self.arrived = 3 self.gosig = go_somewhere_significant(self.you, 1, 3000., 1, "pirates") self.gosig.SignificantUnit().setCombatRole("INERT") VS.IOmessage( 0, "plunder mission", self.mplay, 'Give all of your cargo to the %s unit.' % (unit.getUnitFullName(self.gosig.SignificantUnit()))) elif (self.arrived == 1): if (self.enemy): self.pos = self.enemy.Position() curun = VS.getUnit(self.curiter) self.curiter += 1 if (curun == self.enemy): self.enemy.SetTarget(self.you) elif (curun.isNull()): self.curiter = 0 if (self.enemy.isNull()): VS.setCompleteness(self.obj, 1.) self.arrived = 2 self.enemy = [] for i in range(self.quantity * 2): launch.launch_wave_around_area("shadow", "upgrades", "generic_cargo", "sitting_duck", 1, 5., 10., self.pos, '', 0).setName(self.content) self.obj = VS.addObjective("Pick up %d %s cargo" % (self.quantity, self.content)) VS.IOmessage( 0, "plunder mission", self.mplay, 'You must now pick up at least %d of the %s cargo.' % (self.quantity, self.content)) else: significant = self.gosig.SignificantUnit() if (significant.isNull()): print "sig null" VS.terminateMission(0) return else: if (self.you.getSignificantDistance(significant) < 10000.0): if (self.newship == ""): self.newship = faction_ships.getRandomFighter( 'merchant') carg = VS.getRandCargo(self.quantity, self.category) if (carg.GetQuantity() == 0): carg = VS.getRandCargo( self.quantity, "") #oh no... could be starships... self.content = carg.GetContent() carg.SetQuantity(self.quantity * 2) self.enemy = launch.launch_wave_around_unit( "shadow", "merchant", self.newship, "default", 1, 200.0, 500.0, self.you) self.enemy.addCargo(carg) VS.setCompleteness(self.gosig.obj, 1.) VS.IOmessage( 0, "plunder mission", self.mplay, 'You must now destroy the %s ship.' % self.newship) VS.IOmessage( 0, "plunder mission", self.mplay, 'That fighter contains the wanted %s cargo in its hold.' % self.content) self.obj = VS.addObjective( "Destroy the %s ship." % (unit.getUnitFullName(self.enemy))) if (self.enemy): self.arrived = 1 else: print "enemy null" VS.terminateMission(0) return
def Execute (self): if (self.player): #print str(self.player.Position()) # launch the actors if (self.stage<=self.groups and VS.GetGameTime()>=self.timer): #print "group: " +str(self.stage) self.names = fg_util.GetRandomFGNames(self.groups,"confed") shiptype = faction_ships.getRandomCapitolInt(faction_ships.confed) #print "group/name: " + str(self.stage) + "/"+names[self.stage-1] # launch capital ships number = vsrandom.randrange(2,4) #print ">capital/type: " +str(number)+"/"+shiptype location = Vector.Add (self.object.Position(),(vsrandom.uniform(-10000,10000), vsrandom.uniform(-10000,10000), vsrandom.uniform(-10000,10000))) offset = (vsrandom.uniform(1000,2000),vsrandom.uniform(1000,2000),vsrandom.uniform(1000,2000)) for i in range(number): #self.capital += [launch.launch_wave_around_unit(names[self.stage-1],'confed',shiptype,'sitting_duck',1,5000,20000,self.object)] # launch(name,type,faction,unittype,ai,nr,nrwaves,pos,squadlogo) pos = Vector.Add (location,Vector.Scale(offset,i)) self.capital += [VS.launch(self.names[self.stage-1],shiptype,'confed','unit','sitting_duck',1,1,pos,'')] # launch fighters number = number*vsrandom.randrange(3,6) # test: Lancelot, Schroedinger, Quicksilver, Convolution shiptype = faction_ships.getRandomFighterInt(faction_ships.confed) #print ">fighters/type: " + str(number) + "/" + shiptype ship = self.capital[0] for i in range(number): self.fighter += [launch.launch_wave_around_unit(self.names[self.stage-1],'confed',shiptype,'sitting_duck',1,1000,2000,ship)] # change orders for capital ships for ship in self.capital: ship.PrimeOrders() unit.faceTaget(ship, self.object) # change orders for fighter ships for ship in self.fighter: #unit.faceTaget(ship, self.capital[0]) ship.PrimeOrders() #ship.SetTarget(self.capital[0]) ship.SetTarget(self.object) #ship.UnFire() #ship.setFgDirective("E.") # escort ship.LoadAIScript("modules/ai_escortpatrol.py") # time between spawning the groups self.timer = VS.GetGameTime() #+10 self.stage += 1 if (self.stage==self.groups+1 and VS.GetGameTime()>self.timer): self.stage = 10 # publish news if (self.stage==10 and VS.GetGameTime()>self.timer): text = "JUMP POINT BLOCKADE IN " + self.system + " SYSTEM\\\Intelligence has uncovered Aeran plans to invade Confederation space." text += "As a preventive measure " + str(self.groups) + " flight groups were dispatched and stationed near the Nethuuleil jump point. " text += "Multiple capital vessels are guarding the jump point while a multitude of fighter escorts is patrolling nearby space." news.publishNews(text) self.timer = VS.GetGameTime()+5 self.stage = 11 #make some random chatter if (self.stage==11 and VS.GetGameTime()>self.timer): # select two pilots to chatter flightgroup = 1 #vsrandom.randrange(1,self.groups) numchatters = 0 chatters = [] while (numchatters<2): chatter = vsrandom.randrange(0,len(self.fighter)-1) if (self.fighter[chatter].getFlightgroupName()==self.names[flightgroup-1]): chatters += [chatter] numchatters += 1 VS.IOmessage (0,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"... lousy bar on our mothership?") VS.IOmessage (5,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"Yeah, bad lighting, and no bar company besides your dull face.") VS.IOmessage (10,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"The drinks selection is not the best I have seen.") VS.IOmessage (15,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"And this bartender droid really gets on my nerves.") VS.IOmessage (20,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"He never stops talking for an instant.") VS.IOmessage (25,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"Guess, we've got to live with that.") VS.IOmessage (30,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"Yeah.") self.timer = VS.GetGameTime()+240 self.stage = 12 if (self.stage==12 and VS.GetGameTime()>self.timer): # select two pilots to chatter flightgroup = 2 #vsrandom.randrange(1,self.groups) numchatters = 0 chatters = [] while (numchatters<2): chatter = vsrandom.randrange(0,len(self.fighter)-1) if (self.fighter[chatter].getFlightgroupName()==self.names[flightgroup-1]): chatters += [chatter] numchatters += 1 VS.IOmessage (0,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"Phil?") VS.IOmessage (10,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"What's up, buddy?") VS.IOmessage (15,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"The rumor is the Aera are planning an invasion.") 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.") VS.IOmessage (35,unit.getUnitFullName(self.fighter[chatters[0]]),"all",self.msgColor[0]+"That's why we are here? Will we have to fight?") VS.IOmessage (40,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"Calm down, youngling.") VS.IOmessage (45,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"The war hasn't quite started yet.") 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.") VS.IOmessage (55,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"All staged by the higherups.") 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?") VS.IOmessage (75,unit.getUnitFullName(self.fighter[chatters[1]]),"all",self.msgColor[1]+"Ho, ho. Now stop that blubber. Nobody's gonna die here.") 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.") self.timer = VS.GetGameTime()+300 self.stage = 13 # just a temporary backup if (self.stage==99): #for ship in self.fighter: # ship = VS.getUnit(i) # if (ship.getFlightgroupName()==names[flightgroup]): # print "shipname: " + ship.getFullName() # #ship.setFgDirective("E.") # escort # #VS.PythonAI.XMLScript("++evade.xml") self.stage = 98 #if (self.stage==99 and not VS.getSystemName()==self.system): if (not VS.getSystemName()==self.system): self.stage += 1 # don't enter this loop anymore self.playernum = -1 self.name = "quest_capital" self.removeQuest() return 0
def __init__ (self,you, landable_only, distance_away_to_trigger,base_only=0,capshipfaction="", dyn_fg="", showObjective=1, forcestarship=0): self.obj=0 self.showObjective=showObjective self.orbitee="" self.capship=0 self.you = you self.arrivedarea=0 self.distfrombase=distance_away_to_trigger significant=VS.Unit() aroundthe="" self.sysfil=VS.getSystemFile() if (landable_only or base_only): randint=vsrandom.randrange(0,128) lim=1 if landable_only and not base_only: lim=10 for i in xrange(lim): significant = unit.getSignificant (randint,landable_only,base_only) if significant.isPlanet(): break else: randint+=1 if (landable_only and not unit.isLandable(significant)) or forcestarship: self.capship=1 if (capshipfaction==""): capshipfaction="merchant" if (self.capship and capshipfaction!=""): if (significant.isNull()): significant=you self.orbitee="%s" % (significant.getName()) self.capship=1 print "orbitee %s " % self.orbitee if (dyn_fg==""): newship=faction_ships.getRandomCapitol(capshipfaction) found=False near=2000.0 far=5000.0 try: near*=faction_ships.launch_distance_factor far*=faction_ships.launch_distance_factor except: pass i=VS.getUnitList() while i.notDone(): testun = i.current() i.advance() if testun.getFactionName()==capshipfaction and faction_ships.isCapital(testun.getName()): significant=moveUnitTo(testun,significant,near) found=True break if (not found): significant=launch.launch_wave_around_unit("Base",capshipfaction,newship,"sitting_duck",1,near,far,significant,"") else: near=5000.0 try: near*=faction_ships.launch_distance_factor except: pass found=False aroundthe=" near "+unit.getUnitFullName(significant,True); i = VS.getUnitList() while i.notDone(): testun = i.current() i.advance() if testun.getFactionName()==capshipfaction and faction_ships.isCapital(testun.getName()): significant=moveUnitTo(testun,significant,near) found=True break if (not found): significant=launch_recycle.launch_dockable_around_unit(dyn_fg,capshipfaction,"sitting_duck",near,significant,4*near,'','Base') significant.setFullname(dyn_fg) else: significant = universe.getRandomJumppoint () if (significant.isNull()): print "ERROR: no significants found in starsystem %s" % (self.sysfil) self.significantun=VS.getPlayer() else: self.significantun=significant self.significantun.setMissionRelevant() #qualifier="the " #if (significant.isPlanet() and significant.isDockableUnit()): # qualifier="" if (self.showObjective): self.obj=VS.addObjective("Visit %s %s" % (self.getSignificantFullName (),aroundthe)) VS.setOwner(self.obj,VS.getPlayer())
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.enemy.SetTarget(self.you) self.enemy.setFgDirective('B.') self.you.SetTarget(self.enemy) universe.greet(self.greetingText, self.enemy, self.you) str_faction = self.faction.split('_')[0] quest.playSoundCockpit('sounds/missions/' + str_faction + '_it-appears-we-have.ogg') self.obj = VS.addObjective( "Destroy %s." % (unit.getUnitFullName(self.enemy))) 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 = unit.getUnitFullName( self.adjsys.SignificantUnit(), True) 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 getSignificantFullName(self): return unit.getUnitFullName(self.significantun,False)
def Print(self,visitstr,fro,dockstr="\0%s",time=0): if (self.capship): visitstr+=(dockstr % (self.orbitee)) thename=unit.getUnitFullName(self.significantun,True) VS.IOmessage(time,fro,universe.getMessagePlayer(self.you),visitstr % (thename) )
def Track(self,shiptype): import VS obj=VS.addObjective("Destroy %s."%(unit.getUnitFullName(shiptype,True))) VS.setOwner(obj,self.you) VS.setCompleteness(obj,-1.0) self.activeships.append((shiptype,obj))
def Execute (self): isSig=0 if (self.you.isNull()): self.Lose (1) return if (self.arrived==3): self.gosig.Execute() cargquant=self.you.GetCargo(self.content).GetQuantity() if cargquant<self.quantity: # print "ohnooohnoohno!!!!!!!" VS.IOmessage(0,"plunder mission",self.mplay,'Not enough of %s cargo... Get more until you have %d.'%(self.quantity)) VS.setCompleteness(self.obj,0.) elif self.you.isDocked(self.gosig.SignificantUnit()) or self.gosig.SignificantUnit().isDocked(self.you): # print "du hast gewonnen!" self.you.removeCargo(self.content,self.quantity,bool(1)) self.Win(self.you,1) # else: # print 'hihohohiho' elif (self.arrived==2): cargquant=self.you.GetCargo(self.content).GetQuantity() VS.setCompleteness(self.obj,float(cargquant)/float(self.quantity)) if cargquant==self.quantity: self.arrived=3 self.gosig=go_somewhere_significant(self.you,1,3000.,1,"pirates") self.gosig.SignificantUnit().setCombatRole("INERT") VS.IOmessage(0,"plunder mission",self.mplay,'Give all of your cargo to the %s unit.'%(unit.getUnitFullName(self.gosig.SignificantUnit()))) elif (self.arrived==1): if (self.enemy): self.pos=self.enemy.Position() curun=VS.getUnit(self.curiter) self.curiter+=1 if (curun==self.enemy): self.enemy.SetTarget(self.you) elif (curun.isNull()): self.curiter=0 if (self.enemy.isNull()): VS.setCompleteness(self.obj,1.) self.arrived=2 self.enemy=[] for i in range(self.quantity*2): launch.launch_wave_around_area("shadow","upgrades","generic_cargo","sitting_duck",1,5.,10.,self.pos,'',0).setName(self.content) self.obj=VS.addObjective("Pick up %d %s cargo"%(self.quantity,self.content)) VS.IOmessage(0,"plunder mission",self.mplay,'You must now pick up at least %d of the %s cargo.'%(self.quantity,self.content)) else: significant=self.gosig.SignificantUnit() if (significant.isNull ()): print("sig null") VS.terminateMission(0) return else: if (self.you.getSignificantDistance(significant)<10000.0): if (self.newship==""): self.newship=faction_ships.getRandomFighter('merchant') carg=VS.getRandCargo(self.quantity,self.category) if (carg.GetQuantity()==0): carg = VS.getRandCargo(self.quantity,"") #oh no... could be starships... self.content=carg.GetContent() carg.SetQuantity(self.quantity*2) self.enemy=launch.launch_wave_around_unit("shadow","merchant",self.newship,"default",1,200.0,500.0,self.you) self.enemy.addCargo(carg) VS.setCompleteness(self.gosig.obj,1.) VS.IOmessage(0,"plunder mission",self.mplay,'You must now destroy the %s ship.'%self.newship) VS.IOmessage(0,"plunder mission",self.mplay,'That fighter contains the wanted %s cargo in its hold.'%self.content) self.obj=VS.addObjective("Destroy the %s ship." % (unit.getUnitFullName(self.enemy))) if (self.enemy): self.arrived=1 else: print("enemy null") VS.terminateMission(0) return
def __init__ (self, creds, faction, quantity, category, returntobase, var_when_done=''): Director.Mission.__init__ (self) self.newship="" self.mplay="all" self.obj=0 self.enemy=VS.Unit() self.curiter=0 self.content="" self.quantity=quantity self.arrived=0 self.faction = faction self.cred=creds self.category=category self.donevar=var_when_done sysfile = VS.getSystemFile() self.newship=faction_ships.getRandomFighter('merchant') self.you=VS.getPlayer() self.pos=self.you.Position() self.gosig=go_somewhere_significant(self.you,0,10000.) self.mplay=universe.getMessagePlayer(self.you) if (self.you): VS.IOmessage (0,"plunder mission",self.mplay,"Your mission is to destroy a %s merchant unit." % (self.newship)) VS.IOmessage (1,"plunder mission",self.mplay,"It is orbiting around the %s planet in the system." % (unit.getUnitFullName(self.gosig.SignificantUnit()))) VS.IOmessage (2,"plunder mission",self.mplay,"After it is destroyed, pick up all %s cargo that got ejected."%self.category) VS.IOmessage (3,"plunder mission",self.mplay,"Then return to a %s base with your cargo. #00ff00Good luck!"%self.faction) else: print("aboritng plunder constructor...") VS.terminateMission (0)