def launch_new_wave(self): un = VS.getPlayer() if (vsrandom.randrange(0, 4) == 0): if (un): currentsystem = VS.getSystemFile() numadj = VS.GetNumAdjacentSystems(currentsystem) if (numadj): cursys = VS.GetAdjacentSystem( currentsystem, vsrandom.randrange(0, numadj)) else: cursys = 'enigma_sector/heavens_gate' debug.info("TJ: jumping to " + cursys) un.JumpTo(cursys) else: debug.warn("TJ: jumping to [ERROR: you are null]") return else: siglist = universe.significantUnits() if len(siglist) == 0: debug.info("TJ: siglist empty") return sig = siglist[vsrandom.randrange(0, len(siglist))] if (not sig): debug.info("TJ: sig null") return debug.info("TJ: autopiloting to " + sig.getName()) un.AutoPilotTo(sig, True) un.SetTarget(sig)
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 launch_new_wave(self): un = VS.getPlayer() if (vsrandom.randrange(0,4)==0): if (un): currentsystem = VS.getSystemFile() numadj=VS.GetNumAdjacentSystems(currentsystem) if (numadj): cursys=VS.GetAdjacentSystem(currentsystem,vsrandom.randrange(0,numadj)) else: cursys = 'enigma_sector/heavens_gate' debug.info("TJ: jumping to "+cursys) un.JumpTo(cursys) else: debug.warn("TJ: jumping to [ERROR: you are null]") return else: siglist=universe.significantUnits() if len(siglist)==0: debug.info("TJ: siglist empty") return sig=siglist[vsrandom.randrange(0,len(siglist))] if (not sig): debug.info("TJ: sig null") return debug.info("TJ: autopiloting to "+sig.getName()) un.AutoPilotTo(sig,True) un.SetTarget(sig)
def launchUnits(sys): print "Launching units for "+sys import faction_ships import launch_recycle import universe sig_units=universe.significantUnits() ownerfac= VS.GetGalaxyFaction(sys) jumpcount=0 planetcount=0 # asteroidcount=0 basecount=0 farlen=0 for sig in sig_units: if sig.isJumppoint(): jumpcount+=1 elif sig.isPlanet(): planetcount+=1 # elif sig.isAsteroid(): # asteroidcount+=1 else: basecount+=1 tmplen=Vector.Mag(sig.Position()) if tmplen>farlen: farlen=tmplen for factionnum in range(0,faction_ships.getMaxFactions()-1): faction=faction_ships.intToFaction(factionnum) fglist=filterLaunchedFGs(FGsInSystem(faction,sys)) isHostile=VS.GetRelation(ownerfac,faction)<0 isForeign=faction.find(ownerfac)==-1 if isForeign: if basecount+jumpcount: frac=len(fglist)/float(basecount+jumpcount) else: frac=0.0 else: if basecount+planetcount+jumpcount: frac=len(fglist)/float(planetcount+basecount+jumpcount) else: frac=0.0 if isHostile: for flightgroup in fglist: X=incr_by_abs(vsrandom.uniform(-1.0,1.0),1)*farlen Y=incr_by_abs(vsrandom.uniform(-1.0,1.0),1)*farlen Z=incr_by_abs(vsrandom.uniform(-1.0,1.0),1)*farlen typenumbers=ShipsInFG(flightgroup,faction) #print "Really Far Apart around "+" "+str(X)+" "+str(Y)+" "+str(Z)+" and 10000" debug.debug(" launching "+str(typenumbers) +" for "+faction+" at "+str((X,Y,Z))) launch_recycle.launch_types_around(flightgroup,faction,typenumbers,'default',1,(X,Y,Z),0,'','',1,10000) else: for flightgroup in fglist: #jp = sig.isJumppoint() #if sig.isPlanet() or not isForeign: sig = sig_units[vsrandom.randrange(0,len(sig_units))] typenumbers=ShipsInFG(flightgroup,faction) debug.debug(" XXlaunching "+str(typenumbers) +" for "+faction) print "LALALAUNCHING "+str(typenumbers)+" t "+sig.getName()+":"+sig.getFullname() launch_recycle.launch_types_around(flightgroup,faction,typenumbers,'default',sig.rSize()*vsrandom.randrange(10,100),sig,0,'','',1,10000)
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 launchBases(sys): import universe print 'Launching bases for '+sys fac = VS.GetGalaxyFaction(sys) fgs = BaseFG (fac,sys) sig_units = universe.significantUnits() shipcount=zeros(len(sig_units)) for fg in fgs: launchBase(fg[0],fg[1],fac,sys,sig_units,shipcount)
def launchUnits(sys): debug.info("Launching units for %s", sys) import faction_ships import launch_recycle import universe sig_units=universe.significantUnits() ownerfac= VS.GetGalaxyFaction(sys) jumpcount=0 planetcount=0 # asteroidcount=0 basecount=0 farlen=0 for sig in sig_units: if sig.isJumppoint(): jumpcount+=1 elif sig.isPlanet(): planetcount+=1 # elif sig.isAsteroid(): # asteroidcount+=1 else: basecount+=1 tmplen=Vector.Mag(sig.Position()) if tmplen>farlen: farlen=tmplen for factionnum in xrange(0,faction_ships.getMaxFactions()-1): faction=faction_ships.intToFaction(factionnum) fglist=filterLaunchedFGs(FGsInSystem(faction,sys)) isHostile=VS.GetRelation(ownerfac,faction)<0 isForeign=faction.find(ownerfac)==-1 if isForeign: if basecount+jumpcount: frac=len(fglist)/float(basecount+jumpcount) else: frac=0.0 else: if basecount+planetcount+jumpcount: frac=len(fglist)/float(planetcount+basecount+jumpcount) else: frac=0.0 if isHostile: for flightgroup in fglist: X=incr_by_abs(vsrandom.uniform(-1.0,1.0),1)*farlen Y=incr_by_abs(vsrandom.uniform(-1.0,1.0),1)*farlen Z=incr_by_abs(vsrandom.uniform(-1.0,1.0),1)*farlen XYZ = (X,Y,Z) typenumbers=ShipsInFG(flightgroup,faction) debug.debug("Really Far Apart around %s and 10000",XYZ) debug.debug(" launching %s for %s at %s", typenumbers, faction, XYZ) launch_recycle.launch_types_around(flightgroup,faction,typenumbers,'default',1,XYZ,0,'','',1,10000) else: for flightgroup in fglist: #jp = sig.isJumppoint() #if sig.isPlanet() or not isForeign: sig = sig_units[vsrandom.randrange(0,len(sig_units))] typenumbers=ShipsInFG(flightgroup,faction) debug.debug(" launching %s for %s", typenumbers, faction) launch_recycle.launch_types_around(flightgroup,faction,typenumbers,'default',sig.rSize()*vsrandom.randrange(10,100),sig,0,'','',1,10000)