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.info("TJ: jumping to [ERROR: you are null]") side = vsrandom.randrange(0,2) faction="confed" ai = vsrandom.randrange(0,6) if (0 and ai==0): ai = "printhello.py" else: ai = "default" if (side==0): faction=faction_ships.get_enemy_of("confed") else: faction=faction_ships.get_friend_of("confed") launched = launch.launch_wave_around_unit ("Shadow",faction,faction_ships.getRandomFighter(faction),ai,vsrandom.randrange(1,10),100.0,2000.0,VS.getPlayer(),'') if (vsrandom.randrange(0,10)==0): launch.launch_wave_around_unit ("ShadowCap",faction,faction_ships.getRandomCapitol(faction),ai,1,2000.0,4000.0,VS.getPlayer(),'')
def GetDiffCargo(diff, base_category, all_category, use_all, dont_use_all=0): """ This function makes a string based on the difficulty. In this way it can be restricted to light or medium mounts when the difficulty is low, avoiding unaffordable weapons """ cat = all_category ch = dont_use_all #this makes ch only 1 if (diff <= 0.2): ch = 1 elif (diff <= 0.4): ch = 2 - vsrandom.randrange(dont_use_all, 3) elif ((diff <= 0.7) or use_all): ch = 3 - vsrandom.randrange(dont_use_all, 4) # ch is 0 if it is any upgrades/Weapon # otherwise it could be light, medium or heavy or some random set # between Light and X (light, medium, heavy) if (ch == 1): cat = "%sLight" % (base_category) elif (ch == 2): cat = "%sMedium" % (base_category) elif (ch == 3): cat = "%sHeavy" % (base_category) debug.debug("Category: %s" % (cat)) return cat
def initrandom(minsysaway, maxsysaway, minsigtopatrol, maxsigtopatrol, mincred, maxcred): nsys = vsrandom.randrange(minsysaway, maxsysaway) nsig = vsrandom.randrange(minsigtopatrol, maxsigtopatrol) return patrol(nsys, nsig, vsrandom.randrange(100.0, 300.0), (1 + nsys * 0.5) * nsig * vsrandom.randrange(mincred, maxcred))
def launch_waves_around_area(fgname, faction, type, ai, nr_ships, nr_waves, r1, r2, pos, logo="", useani=1, skipdj=0): pos = ( (pos[0] + vsrandom.uniform(r1, r2) * vsrandom.randrange(-1, 2, 2)), (pos[1] + vsrandom.uniform(r1, r2) * vsrandom.randrange(-1, 2, 2)), (pos[2] + vsrandom.uniform(r1, r2) * vsrandom.randrange(-1, 2, 2)), ) return launch(fgname, faction, type, ai, nr_ships, nr_waves, pos, logo, useani, skipdj)
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)
def AddSysDict (cursys): #pick random fighter from insysenemies with .3 probability OR pick one from the friendlies list. # debug.debug('Addsysdict') sysfaction=VS.GetGalaxyFaction(cursys) global fgnames, fglists i=0 AddBasesToSystem(sysfaction, cursys) for i in range (1+vsrandom.randrange(fg_util.MinNumFlightgroupsInSystem(cursys)-1,fg_util.MaxNumFlightgroupsInSystem(cursys))): #number of fgs in a system. faction=sysfaction friendly=0 if vsrandom.random()<.3 or sysfaction=='unknown' or sysfaction=='': faction=faction_ships.get_rabble_of(sysfaction) else: faction=faction_ships.get_friend_of(sysfaction) if (faction==sysfaction): friendly=1 if (sysfaction in faction_ships.production_centers): if (cursys in faction_ships.production_centers[sysfaction]): friendly=2 #if (friendly): # debug.debug(faction+" "+sysfaction+" "+cursys) factionnr=faction_ships.factionToInt(faction) global maxshipsinfg typenumbertuple=GenerateFgShips(vsrandom.randrange(maxshipsinfg)+1,factionnr,friendly) fgname=GetNewFGName(faction) fg_util.AddShipsToFG (fgname,faction,typenumbertuple,cursys) return i
def LookForTrouble (faction): global lftiter key = fg_util.MakeFactionKey(faction) numfg=Director.getSaveStringLength(fg_util.ccp,key) if (lftiter>=numfg): lftiter=0 if (0 and numfg): AddFighterTo(Director.getSaveString(fg_util.ccp,key,vsrandom.randrange(0,numfg)),faction,False) if faction in faction_ships.fighterProductionRate: AddFighterTo("Alpha",faction,True) return 0 i = Director.getSaveString(fg_util.ccp,key,lftiter) lftiter+=1 sys = fg_util.FGSystem (i,faction) citizen=VS.isCitizen(faction) if (sys!='nil'): if not citizen: enfac = faction_ships.get_enemy_of(faction) foundanyone=0 l=fg_util.AllFGsInSystem(enfac,sys) j=vsrandom.randrange(0,len(l)+3) if (j<len(l)): foundanyone=1 #FIXME include some sort of measure "can I win" if (vsrandom.randrange(0,5)==0): initiateAttack(i,faction,sys,l[j],enfac) elif (vsrandom.randrange(0,3)==0): randomMovement (i,faction) elif (vsrandom.randrange(0,3)==0): randomMovement (i,faction) return 1
def generateRescueMission( path, rescuelist, totmaxprice=int(VS.vsConfig("dynamic_universe", "missions.rescue.totmaxprice", "21000")), shipminprice=int(VS.vsConfig("dynamic_universe", "missions.rescue.pership.minprice", "4041")), shipmaxprice=int(VS.vsConfig("dynamic_universe", "missions.rescue.pership.maxprice", "8640")), jumpminprice=int(VS.vsConfig("dynamic_universe", "missions.rescue.perjump.minprice", "4041")), jumpmaxprice=int(VS.vsConfig("dynamic_universe", "missions.rescue.perjump.maxprice", "8640")), ): makemissionharder = vsrandom.randrange(0, 2) numships = vsrandom.randrange(1, adjustQuantityDifficulty(6)) + howMuchHarder(makemissionharder) creds = numships * vsrandom.randrange(shipminprice, shipmaxprice) creds += len(path) * vsrandom.randrange(jumpminprice, jumpmaxprice) creds = min(totmaxprice, creds) creds *= getPriceModifier(makemissionharder != 0) if len(path) == 1: mistype = "IN-SYSTEM RESCUE" else: mistype = "RESCUE" writemissionsavegame( "import rescue\nntemp=rescue.rescue(%d,0,'%s',%d,'%s','%s',%s)\nntemp=0" % (creds, rescuelist[0], numships, rescuelist[2], rescuelist[1], str(path)) ) writedescription( "SOS! This is an ejected %s pilot under attack by at least %d %s craft. I request immediate assistance to the %s system and will offer %d credits for a safe return to the local planet where I may recover." % (rescuelist[0], numships, rescuelist[2], processSystem(path[-1]), creds) ) writemissionname("Rescue/Rescue_%s_from_%s_ships" % (rescuelist[0], rescuelist[2]), path, 0) writemissionvars({"MISSION_TYPE": mistype})
def generateEscortLocal(path,fg,fac, waveprice=3500.0 ): if (isNotWorthy(fac)): return typ = fg_util.RandomShipIn(fg,fac) if typ in faction_ships.unescortable: return enfac = faction_ships.get_enemy_of(fac) diff=vsrandom.randrange(1,4) waves=vsrandom.randrange(0,5-diff) incoming=vsrandom.randrange(0,2) enfg =fg_util.AllFGsInSystem(enfac,path[-1]) creds=waveprice*diff*(1+waves); if (len(enfg)): enfg=enfg[vsrandom.randrange(0,len(enfg))] else: enfg='' isFixer=vsrandom.random() addstr="" if isFixer<fixerpct: creds*=2 addstr+="#F#bases/fixers/merchant.spr#Talk to the Merchant#Thank you. I trust that you will safely escort my colleague to the destination.#\n" elif isFixer<guildpct: creds*=1.5 addstr+="#G#Escort#\n" additionalinfo="to the jump point" if (incoming): additionalinfo="from the jump point to a nearby base" writemissionsavegame(addstr+"import escort_local\ntemp=escort_local.escort_local('%s',0,%d,%d,500,%d,%d,'%s',(),'','%s','','%s','%s')"%(enfac,diff,waves,creds,incoming,fac,enfg,fg,typ)) writedescription("Escort %s is required for the %s type %s starship from the %s flightgroup in this system. Attacks from the %s faction are likely. You will be paid %d credits if the starship survives in this starsystem until it reaches its destination."%(additionalinfo,formatShip(typ),fac,fg,enfac,int(creds))) writemissionname("Escort/Escort_%s_%s"%(fac,fg),[path[-1]],isFixerString(addstr))
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 MakeContraband(which): constructor = cargo_mission.cargo_mission numsys = vsrandom.randrange(2, 5) jumps = universe.getAdjacentSystems(VS.getSystemFile(), numsys)[1] diff = vsrandom.randrange(0, 3) creds = numsys * 2500 + diff * 800 args = ('pirates', 0, 6, diff, creds, 1, 1200, 'Contraband', jumps) briefing0 = 'We need some...*cough*... cargo delivered to some of our pirates in a nearby system: ' + Jumplist( jumps ) + ' It\'d be preferable if ye kept the ole po\' off yo back durin the run. Will ya do it for ' + str( creds) + ' creds?' briefing1 = 'Thanks pal; keep it on the d&l if you know my meanin.' vars = { 'MISSION_TYPE': 'CONTRABAND', 'MISSION_SHORTDESC': 'Deliver contraband to %s for %s' % (Jumplist(jumps), creds) } try: vars['MISSION_ID'] = vars['MISSION_ID'] except: vars['MISSION_ID'] = which description = vars['MISSION_SHORTDESC'] AddNewMission(description, args, constructor, briefing0, briefing1, vars, vars) return ("bases/fixers/pirate.spr", "Talk with the Pirate", which)
def generateDefendMission (path,defendfg,defendfac, attackfg,attackfac, baseprice=1200.0 ): if (isNotWorthy(defendfac)): return #defendtyp = fg_util.RandomShipIn(defendfg,defendfac) attacktyp = fg_util.RandomShipIn(attackfg,attackfac) isbase=fg_util.BaseFGInSystemName(path[-1])==defendfg creds=baseprice minq = 1 maxq = adjustQuantityDifficulty(5) makemissionharder=vsrandom.randrange(0,2) quantity = vsrandom.randrange(minq,maxq)+howMuchHarder(makemissionharder) reallydefend = "1" if (vsrandom.randrange(0,4)==0): reallydefend="0" addstr="" creds=creds*quantity+syscreds*len(path) creds*=getPriceModifier(makemissionharder) isFixer=vsrandom.random() if isFixer<fixerpct: creds*=2 addstr+="#F#bases/fixers/confed.spr#Talk to the Confed Officer#Thank you. Your defense will help confed in the long run. We appreciate the support of the bounty hunting community.#\n" elif isFixer<guildpct: creds*=1.5 addstr+="#G#Defend#\n" writemissionsavegame(addstr+"import defend\ntemp=defend.defend('%s', %d, %d, 8000.0, 100000.0, %g, %s, %d, '%s', %s, '%s', '%s', '%s', '%s')\ntemp=0\n"% (attackfac, 0, quantity, creds, reallydefend, isbase, defendfac, str(path), '',attackfg, attacktyp,defendfg)) iscapitol="" if isbase: iscapitol="capital " writedescription("A %s assault wing named %s has jumped in and is moving for an attack on one of our %sassets in the %s system.\nYour task is to eradicate them before they eliminate our starship.\nIntelligence shows that they have %d starships of type %s. Your reward is %d credits."%(attackfac, attackfg, iscapitol, processSystem(path[-1]),quantity, formatShip(attacktyp),creds)) writemissionname("Defend/Defend_%s_from_%s"%(defendfac, attackfac),path,isFixerString(addstr))
def generateEscortLocal(path,fg,fac): if (isNotWorthy(fac)): return typ = fg_util.RandomShipIn(fg,fac) if typ in faction_ships.unescortable: typ = faction_ships.unescortable[typ] enfac = faction_ships.get_enemy_of(fac) diff=vsrandom.randrange(1,4) waves=vsrandom.randrange(0,5-diff) incoming=vsrandom.randrange(0,2) enfg =fg_util.AllFGsInSystem(enfac,path[-1]) creds=3500.0*diff*(1+waves); if (len(enfg)): enfg=enfg[vsrandom.randrange(0,len(enfg))] else: enfg='' isFixer=vsrandom.random() addstr="" if isFixer<fixerpct: creds*=2 addstr+="#F#bases/fixers/merchant.spr#Unterhalte Dich mit dem Kaufmann#Danke. Ich vertraue dir, dass du meinen Geschaeftspartner sicher geleiten wirst, bis er sein Ziel erreicht.#\n" elif isFixer<guildpct: creds*=1.5 addstr+="#G#Escort#\n" additionalinfo="zu dem Sprungpunkt" if (incoming): additionalinfo="von dem Sprungpunkt zu einer nahen Basis" writemissionsavegame(addstr+"import escort_local\ntemp=escort_local.escort_local('%s',0,%d,%d,500,%d,%d,'%s',(),'','%s','','%s','%s')"%(enfac,diff,waves,creds,incoming,fac,enfg,fg,typ)) # From plueschinger to avoid sometimes squadrons and sometimes not # we mention the squadrons or konvois later in the following message if "Squadron" == fg[-8:]: fg = fg[:-9] # end of plueschingers addition writedescription("Eine Eskorte %s ist erforderlich fuer die %s Klasse %s der Raumschiffe aus der %s Schwadron in diesem System. Angriffe von der %s Gruppe sind moeglich. Sie werden bezahlt mit %d Krediten, falls das Raumschiff in diesem Sternensystem ueberlebt, bis es seinen Zielort erreicht."%(additionalinfo,formatShip(typ),fac,fg,enfac,int(creds))) writemissionname("Eskorte/Eskortiere den_%s in dem_%s Konvoi"%(fac,fg),[path[-1]],isFixerString(addstr))
def AddSysDict(cursys): #pick random fighter from insysenemies with .3 probability OR pick one from the friendlies list. # debug.debug('Addsysdict') sysfaction = VS.GetGalaxyFaction(cursys) global fgnames, fglists i = 0 AddBasesToSystem(sysfaction, cursys) for i in range(1 + vsrandom.randrange( fg_util.MinNumFlightgroupsInSystem(cursys) - 1, fg_util.MaxNumFlightgroupsInSystem(cursys)) ): #number of fgs in a system. faction = sysfaction friendly = 0 if vsrandom.random( ) < .3 or sysfaction == 'unknown' or sysfaction == '': faction = faction_ships.get_rabble_of(sysfaction) else: faction = faction_ships.get_friend_of(sysfaction) if (faction == sysfaction): friendly = 1 if (sysfaction in faction_ships.production_centers): if (cursys in faction_ships.production_centers[sysfaction]): friendly = 2 #if (friendly): # debug.debug(faction+" "+sysfaction+" "+cursys) factionnr = faction_ships.factionToInt(faction) global maxshipsinfg typenumbertuple = GenerateFgShips( vsrandom.randrange(maxshipsinfg) + 1, factionnr, friendly) fgname = GetNewFGName(faction) fg_util.AddShipsToFG(fgname, faction, typenumbertuple, cursys) return i
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 AddFighterTo(fgname,fac,isNew=False): sys = VS.getSystemFile() #print 'add fighter' import generate_dyn_universe numsystems = generate_dyn_universe.systemcount[fac] if (VS.GetGalaxyFaction(sys)!=fac): try: homeworlds=faction_ships.production_centers except: homeworlds=faction_ships.homeworlds if fac in homeworlds: if type(homeworlds[fac])==type(""): sys=homeworlds[fac] else: sys=homeworlds[fac][vsrandom.randrange(0,len(homeworlds[fac]))] numfighters = int(generate_dyn_universe.XProductionRate(fac,faction_ships.fighterProductionRate)*numsystems) try: if fac in faction_ships.staticFighterProduction: numfighters+=faction_ships.staticFighterProduction[fac] except: pass if (numfighters<1): if (vsrandom.uniform(0,1)<numfighters): numfighters=1 #print "Generating "+str(numfighters)+ " fighters for "+fac+" at "+sys if isNew: fgk=fg_util.AllFGsInSystem(fac,sys) if len(fgk): fgname=fgk[vsrandom.randrange(0,len(fgk))] stat=6 if fac in faction_ships.fightersPerFG: stat=faction_ships.fightersPerFG[fac] elif "default" in faction_ships.fightersPerFG: stat=faction_ships.fightersPerFG["default"] if fg_util.NumShipsInFG(fgname,fac)+numfighters<=numfighters+stat: isNew=False if isNew: fgname=generate_dyn_universe.GetNewFGName(fac) if numfighters>=1: fg_util.AddShipsToFG (fgname,fac,((faction_ships.getRandomFighter(fac),int(numfighters)),),sys) numcapships = generate_dyn_universe.XProductionRate(fac,faction_ships.capitalProductionRate)*numsystems if (numcapships<1): if (vsrandom.uniform(0,1)>numcapships): return numcapships=1 sys = fg_util.FGSystem(fgname,fac) if (1 or VS.GetGalaxyFaction(sys)!=fac): try: homeworlds=faction_ships.production_centers except: homeworlds=faction_ships.homeworlds if fac in homeworlds: if type(homeworlds[fac])==type(""): sys=homeworlds[fac] else: sys=homeworlds[fac][vsrandom.randrange(0,len(homeworlds[fac]))] cap =faction_ships.getRandomCapitol(fac) #print "Generating "+str(numcapships)+ " capship "+cap+" for "+fac+" at "+sys fg_util.AddShipsToFG(fgname,fac,((cap,int(numcapships)),),sys)
def numPatrolPoints(sysname): try: import faction_ships mmax=faction_ships.numPatrolPoints[sysname] # print "system max "+sysname+" "+str(mmax) return vsrandom.randrange(4,mmax+1) except: return vsrandom.randrange(4,10)
def AddFighterTo(fgname,fac,isNew=False): sys = VS.getSystemFile() #debug.debug('add fighter') numsystems = generate_dyn_universe.systemcount[fac] if (VS.GetGalaxyFaction(sys)!=fac): try: homeworlds=faction_ships.production_centers except: homeworlds=faction_ships.homeworlds if fac in homeworlds: if type(homeworlds[fac])==type(""): sys=homeworlds[fac] else: sys=homeworlds[fac][vsrandom.randrange(0,len(homeworlds[fac]))] numfighters = int(generate_dyn_universe.XProductionRate(fac,faction_ships.fighterProductionRate)*numsystems) try: if fac in faction_ships.staticFighterProduction: numfighters+=faction_ships.staticFighterProduction[fac] except: pass if (numfighters<1): if (vsrandom.uniform(0,1)<numfighters): numfighters=1 #debug.debug("Generating "+str(numfighters)+ " fighters for "+fac+" at "+sys) if isNew: fgk=fg_util.FGsInSystem(fac,sys) if len(fgk): fgname=fgk[vsrandom.randrange(0,len(fgk))] stat=6 if fac in faction_ships.fightersPerFG: stat=faction_ships.fightersPerFG[fac] elif "default" in faction_ships.fightersPerFG: stat=faction_ships.fightersPerFG["default"] if fg_util.NumShipsInFG(fgname,fac)+numfighters<=numfighters+stat: isNew=False if isNew: fgname=generate_dyn_universe.GetNewFGName(fac) if numfighters>=1: fg_util.AddShipsToFG (fgname,fac,((faction_ships.getRandomFighter(fac),int(numfighters)),),sys) numcapships = generate_dyn_universe.XProductionRate(fac,faction_ships.capitalProductionRate)*numsystems if (numcapships<1): if (vsrandom.uniform(0,1)>numcapships): return numcapships=1 sys = fg_util.FGSystem(fgname,fac) if (1 or VS.GetGalaxyFaction(sys)!=fac): try: homeworlds=faction_ships.production_centers except: homeworlds=faction_ships.homeworlds if fac in homeworlds: if type(homeworlds[fac])==type(""): sys=homeworlds[fac] else: sys=homeworlds[fac][vsrandom.randrange(0,len(homeworlds[fac]))] cap =faction_ships.getRandomCapitol(fac) #debug.debug("Generating "+str(numcapships)+ " capship "+cap+" for "+fac+" at "+sys) fg_util.AddShipsToFG(fgname,fac,((cap,int(numcapships)),),sys)
def generateCleansweepMission(path,numplanets,enemy, pricescale = float(VS.vsConfig("dynamic_universe","missions.cleansweep.pricescale","16000")), jumpscale = float(VS.vsConfig("dynamic_universe","missions.cleansweep.jumpscale","1.2")), sweepmod = float(VS.vsConfig("dynamic_universe","missions.cleansweep.pricemod.sweep","4")), capshipmod = float(VS.vsConfig("dynamic_universe","missions.cleansweep.pricemod.capship","4")), forceattackmod = float(VS.vsConfig("dynamic_universe","missions.cleansweep.pricemod.forceattack","0.25")) ): fighterprob=vsrandom.random()*.75+.25; capshipprob=0.0 if (vsrandom.random()<.2): capshipprob=vsrandom.random()*.25; forceattack=vsrandom.randrange(0,2) cleansweep=vsrandom.randrange(0,2) minships=maxships=vsrandom.randrange(1,4) creds = ( pricescale * ( 1+ cleansweep*sweepmod+ capshipprob*capshipmod+ forceattack*forceattackmod ) * minships * fighterprob + jumpscale * syscreds * len(path) ) creds*=getPriceModifier(False) addstr="" isFixer=vsrandom.random() if isFixer<fixerpct: creds*=2 addstr+="#F#bases/fixers/confed.spr#Talk to the Confed Officer#Thank you. Your help makes space a safer place.#\n" elif isFixer<guildpct: creds*=1.5 if (cleansweep): addstr+="#G#Bounty#\n" else: addstr+="#G#Patrol#\n" missiontype="patrol_enemies" additional="" additionalinstructions="" patrolorclean="Patrol" dist=1000 if (cleansweep): dist=1500 additional=",1" patrolorclean="Clean_Sweep" missiontype="cleansweep" additionalinstructions+=" Eliminate all such forces encountered to receive payment." if (capshipprob): additionalinstructions+=" Capital ships are possibly in the area." writemissionsavegame (addstr+"import %s\ntemp=%s.%s(0, %d, %d, %d, %s,'',%d,%d,%f,%f,'%s',%d%s)\ntemp=0\n"%(missiontype,missiontype,missiontype,numplanets, dist, creds, str(path),minships,maxships,fighterprob,capshipprob,enemy,forceattack,additional)) writedescription("Authorities would like a detailed scan of the %s system. We require %d nav locations be visited on the scanning route. The pay for this mission is %d. Encounters with %s forces likely.%s"%(processSystem(path[-1]),numplanets,creds,enemy,additionalinstructions)) ispoint="s" if numplanets==1: ispoint="" if len(path)==1: mistype = 'IN-SYSTEM ATTACK' else: mistype = 'ATTACK' writemissionname("%s/%s_%d_Point%s_in_%s"%(patrolorclean,patrolorclean,numplanets,ispoint, processSystem(path[-1])),path,isFixerString(addstr)) writemissionvars( { 'MISSION_TYPE' : mistype } )
def generateBountyMission( path, fg, fac, baseprice=float(VS.vsConfig("dynamic_universe", "missions.bounty.baseprice", "20000")), runawayprice=float(VS.vsConfig("dynamic_universe", "missions.bounty.runaway", "5000")), diffprice=float(VS.vsConfig("dynamic_universe", "missions.bounty.diffprice", "500")), jumpscale=float(VS.vsConfig("dynamic_universe", "missions.bounty.jumpscale", "1")), capscale=float(VS.vsConfig("dynamic_universe", "missions.bounty.capscale", "4")), ): typ = fg_util.RandomShipIn(fg, fac) cap = faction_ships.isCapital(typ) makemissionharder = vsrandom.randrange(0, 2) diff = vsrandom.randrange(0, adjustQuantityDifficulty(7)) + howMuchHarder(makemissionharder) runaway = vsrandom.random() >= 0.75 creds = baseprice + runawayprice * runaway + diffprice * diff + jumpscale * syscreds * len(path) if cap: creds *= capscale finalprice = creds * getPriceModifier(False) addstr = "" isFixer = vsrandom.random() if isFixer < fixerpct: finalprice *= 2 addstr += "#F#bases/fixers/hunter.spr#Talk with the Bounty Hunter#We will pay you on mission completion. And as far as anyone knows - we never met." if runaway: addstr += "#Also-- we have information that the target may be informed about your attack and may be ready to run. Be quick!" addstr += "#\n" elif isFixer < guildpct: creds *= 1.5 addstr += "#G#Bounty#\n" writemissionsavegame( addstr + "import bounty\ntemp=bounty.bounty(0, 0, %g, %d, %d, '%s', %s, '', '%s','%s')\ntemp=0\n" % (finalprice, runaway, diff, fac, str(path), fg, typ) ) diffstr = "" if diff > 0: diffstr = " The ship in question is thought to have %d starships for protection." % diff if len(path) == 1: mistype = "IN-SYSTEM BOUNTY" else: mistype = "BOUNTY" writedescription( "A %s starship in the %s flightgroup has been harassing operations in the %s system. Reward for the termination of said ship is %d credits.%s" % (formatShip(typ), fg, processSystem(path[-1]), finalprice, diffstr) ) if cap: writemissionname( "Bounty/on_%s_Capital_Vessel_in_%s" % (fac, processSystem(path[-1])), path, isFixerString(addstr) ) else: writemissionname( "Bounty/Bounty_on_%s_starship_in_%s" % (fac, processSystem(path[-1])), path, isFixerString(addstr) ) writemissionvars({"MISSION_TYPE": mistype})
def MakeContraband(which): last_constructor[which] = cargo_mission.cargo_mission numsys=vsrandom.randrange(2,5) jumps=universe.getAdjacentSystems(VS.getSystemFile(),numsys)[1] diff=vsrandom.randrange(0,3) creds=numsys*2500+diff*800 last_args[which] = ('pirates', 0, 6, diff,creds, 1, 1200, 'Contraband',jumps) last_briefing[0][which] = 'We need some...*cough*... cargo delivered to some of our pirates in a nearby system: '+ Jumplist(jumps)+ ' It\'d be preferable if ye kept the ole po\' off yo back durin the run. Will ya do it for '+str(creds)+' creds?' last_briefing[1][which] = 'Thanks pal; keep it on the d&l if you know my meanin.' return ("bases/fixers/pirate.spr","Talk with the Pirate")
def generateRescueMission(path,rescuelist): makemissionharder=vsrandom.randrange(0,2) numships = vsrandom.randrange(1,adjustQuantityDifficulty(6))+howMuchHarder(makemissionharder) creds = (numships+len(path))*vsrandom.randrange(2041,3140) creds*=getPriceModifier(makemissionharder!=0) if (creds>45000): creds=47000 writemissionsavegame("import rescue\nntemp=rescue.rescue(%d,0,'%s',%d,'%s','%s',%s)\nntemp=0"%(creds,rescuelist[0],numships,rescuelist[2],rescuelist[1],str(path))) writedescription("SOS! Ich bin ein %s Pilot in einer Rettungskapsel, der von mindestens %d %s Raumschiffen angegriffen wird. Ich bitte um unverzuegliche Hilfe im %s System und biete dafuer %d Kredite fuer eine sichere Rueckkehr zu einem lokalen Planeten, auf dem ich mich erholen kann."%(rescuelist[0],numships,rescuelist[2],processSystem(path[-1]),creds)) writemissionname("Rettung/Rette_%s vor den_%s_Schiffen"%(rescuelist[0],rescuelist[2]),path,0)
def generateRescueMission(path,rescuelist): makemissionharder=vsrandom.randrange(0,2) numships = vsrandom.randrange(1,adjustQuantityDifficulty(6))+howMuchHarder(makemissionharder) creds = (numships+len(path))*vsrandom.randrange(1041,1640) creds*=getPriceModifier(makemissionharder!=0) if (creds>20000): creds=21000 writemissionsavegame("import rescue\nntemp=rescue.rescue(%d,0,'%s',%d,'%s','%s',%s)\nntemp=0"%(creds,rescuelist[0],numships,rescuelist[2],rescuelist[1],str(path))) writedescription("SOS! This is an ejected %s pilot under attack by at least %d %s craft. I request immediate assistance to the %s system and will offer %d credits for a safe return to the local planet where I may recover."%(rescuelist[0],numships,rescuelist[2],processSystem(path[-1]),creds)) writemissionname("Rescue/Rescue_%s_from_%s_ships"%(rescuelist[0],rescuelist[2]),path,0)
def generateDefendMission(path, defendfg, defendfac, attackfg, attackfac, baseprice=float( VS.vsConfig("dynamic_universe", "missions.defend.baseprice", "5000")), jumpscale=float( VS.vsConfig("dynamic_universe", "missions.defend.jumpscale", "1"))): if (isNotWorthy(defendfac)): return #defendtyp = fg_util.RandomShipIn(defendfg,defendfac) attacktyp = fg_util.RandomShipIn(attackfg, attackfac) isbase = fg_util.BaseFGInSystemName(path[-1]) == defendfg creds = baseprice minq = 1 maxq = adjustQuantityDifficulty(5) makemissionharder = vsrandom.randrange(0, 2) quantity = vsrandom.randrange(minq, maxq) + howMuchHarder(makemissionharder) reallydefend = "1" if (vsrandom.randrange(0, 4) == 0): reallydefend = "0" addstr = "" creds = creds * quantity + jumpscale * syscreds * len(path) creds *= getPriceModifier(makemissionharder) isFixer = vsrandom.random() if isFixer < fixerpct: creds *= 2 addstr += "#F#bases/fixers/confed.spr#Talk to the Confed Officer#Thank you. Your defense will help confed in the long run. We appreciate the support of the bounty hunting community.#\n" elif isFixer < guildpct: creds *= 1.5 addstr += "#G#Defend#\n" writemissionsavegame( addstr + "import defend\ntemp=defend.defend('%s', %d, %d, 8000.0, 100000.0, %g, %s, %d, '%s', %s, '%s', '%s', '%s', '%s')\ntemp=0\n" % (attackfac, 0, quantity, creds, reallydefend, isbase, defendfac, str(path), '', attackfg, attacktyp, defendfg)) iscapitol = "" if isbase: iscapitol = "capital " if len(path) == 1: mistype = 'IN-SYSTEM DEFEND' else: mistype = 'DEFEND' writedescription( "A %s assault wing named %s has jumped in and is moving for an attack on one of our %sassets in the %s system.\nYour task is to eradicate them before they eliminate our starship.\nIntelligence shows that they have %d starships of type %s. Your reward is %d credits." % (attackfac, attackfg, iscapitol, processSystem( path[-1]), quantity, formatShip(attacktyp), creds)) writemissionname("Defend/Defend_%s_from_%s" % (defendfac, attackfac), path, isFixerString(addstr)) writemissionvars({'MISSION_TYPE': mistype})
def GetDiffCargo (diff, base_category, all_category, use_all, postfixes, dont_use_all=0): cat=all_category ch=dont_use_all #this makes ch only 1 if (diff<=0.2): ch=1 elif (diff<=0.4): ch=2-vsrandom.randrange(dont_use_all,3) elif ((diff<=0.7) or use_all): ch=3-vsrandom.randrange(dont_use_all,4) return base_category + postfixes[(ch-1)*len(postfixes)//3]
def whereTo (radius, launch_around): if (type(launch_around)==type( (1,2,3))): pos=launch_around else: pos = launch_around.Position () rsize = ((launch_around.rSize())*5.0)+5.0*radius if (rsize > faction_ships.max_radius): rsize=faction_ships.max_radius return (pos[0]+rsize*vsrandom.randrange(-1,2,2), pos[1]+rsize*vsrandom.randrange(-1,2,2), pos[2]+rsize*vsrandom.randrange(-1,2,2))
def DefaultNumShips(): import vsrandom diff=VS.GetDifficulty() if (diff>.9): return vsrandom.randrange(1,5) if (diff>.5): return vsrandom.randrange(1,4) if (diff>.2): return vsrandom.randrange(1,3) if (vsrandom.randrange(0,4)==0): return 2 return 1
def DefaultNumShips(): """Get number of (opponent) ships to launch based on the difficulty level.""" diff = VS.GetDifficulty() if (diff > .9): return vsrandom.randrange(1, 5) if (diff > .5): return vsrandom.randrange(1, 4) if (diff > .2): return vsrandom.randrange(1, 3) if (vsrandom.randrange(0, 4) == 0): return 2 return 1
def attackFlightgroup (fgname, faction, enfgname, enfaction,iscap): global dnewsman_ if (iscap): battlename=dnewsman_.TYPE_FLEETBATTLE (leader,enleader)=iscap.split(",") else: battlename = dnewsman_.TYPE_BATTLE leader = fg_util.getFgLeaderType(fgname,faction) enleader = fg_util.getFgLeaderType(enfgname,enfaction) sys = fg_util.FGSystem (fgname,faction) ensys = fg_util.FGSystem (enfgname,enfaction) if (sys==ensys): if (0 and VS.systemInMemory(sys)): VS.pushSystem(sys) LaunchEqualShips (fgname,faction,enfgname,enfaction) VS.TargetEachOther (fgname,faction,enfgname,enfaction) VS.popSystem() debug.debug("attackFlightgroup(fgname=%s, faction=%s, enfgname=%s, enfaction=%s, iscap=%s)" % (fgname, faction, enfgname, enfaction, iscap)) SimulatedDukeItOut (fgname,faction,enfgname,enfaction) elif (sys!='nil' and ensys!='nil'): #pursue other flightgroup import universe adjSystemList=universe.getAdjacentSystemList(sys) if ensys in adjSystemList: fg_util.TransferFG (fgname,faction,ensys) else: return 0 else: #debug.error('nil DRAW error') return 0 if (fg_util.NumShipsInFG(fgname,faction)==0): if (fg_util.NumShipsInFG(enfgname,enfaction)==0): dnewsman_.writeDynamicString([str(Director.getSaveData(0,"stardate",0)),battlename,dnewsman_.STAGE_END,faction,enfaction,dnewsman_.SUCCESS_DRAW,str(getImportanceOfSystem(sys)),sys,dnewsman_.KEYWORD_DEFAULT,fgname,leader,enfgname,enleader]) else: dnewsman_.writeDynamicString([str(Director.getSaveData(0,"stardate",0)),battlename,dnewsman_.STAGE_END,faction,enfaction,dnewsman_.SUCCESS_LOSS,str(getImportanceOfSystem(sys)),sys,dnewsman_.KEYWORD_DEFAULT,fgname,leader,enfgname,enleader]) return 0 elif (fg_util.NumShipsInFG(enfgname,enfaction)==0): dnewsman_.writeDynamicString([str(Director.getSaveData(0,"stardate",0)),battlename,dnewsman_.STAGE_END,faction,enfaction,dnewsman_.SUCCESS_WIN,str(getImportanceOfSystem(sys)),sys,dnewsman_.KEYWORD_DEFAULT,fgname,leader,enfgname,enleader]) return 0 if (vsrandom.randrange(0,4)==0): #FIXME if it is advantageous to stop attacking only!! #FIXME add a stop attacking news report? -- this should now be fixed, as a draw is reported (not heavilly tested) #CAUSES TOO MUCH NEWS#Director.pushSaveString(0,"dynamic_news",dynamic_news.makeVarList([str(Director.getSaveData(0,"stardate",0)),battlename,"end",faction,enfaction,"0",str(getImportanceOfSystem(sys)),sys,"all",fgname,leader,enfgname,enleader])) return 0 if (vsrandom.randrange(0,4)==0 and enfgname!=fg_util.BaseFGInSystemName(ensys)): #FIXME if it is advantageous to run away only #FIXME add a retreat news report? -- this should now be fixed, as a draw is reported (not heavilly tested) #CAUSES TOO MUCH NEWS#Director.pushSaveString(0,"dynamic_news",dynamic_news.makeVarList([str(Director.getSaveData(0,"stardate",0)),battlename,"end",faction,enfaction,"-1",str(getImportanceOfSystem(sys)),sys,"all",fgname,leader,enfgname,enleader])) num=VS.GetNumAdjacentSystems(ensys) if (num>0): ensys=VS.GetAdjacentSystem(ensys,vsrandom.randrange(0,num)) fg_util.TransferFG (fgname,faction,ensys) return 1
def generateEscortLocal(path, fg, fac): if isNotWorthy(fac): return typ = fg_util.RandomShipIn(fg, fac) if typ in faction_ships.unescortable: typ = faction_ships.unescortable[typ] enfac = faction_ships.get_enemy_of(fac) diff = vsrandom.randrange(1, 4) waves = vsrandom.randrange(0, 5 - diff) incoming = vsrandom.randrange(0, 2) enfg = fg_util.AllFGsInSystem(enfac, path[-1]) creds = 1050.0 * diff * (1 + waves) if len(enfg): enfg = enfg[vsrandom.randrange(0, len(enfg))] else: enfg = "" isFixer = vsrandom.random() addstr = "" if isFixer < fixerpct: creds *= 2 addstr += "#F#bases/fixers/merchant.spr#Talk to the Merchant#Thank you. I entrust that you will safely guide my collegue until he reaches the destination.#\n" elif isFixer < guildpct: creds *= 1.5 addstr += "#G#Escort#\n" elif use_missioncomputer: addstr += "#C#Escort#\n" additionalinfo = "to the jump point" if incoming: additionalinfo = "from the jump point to a nearby base" randCompany = GetRandomCompanyName() escortb = GetRandomEscortBrief() composedBrief = escortb.replace("$CL", randCompany) composedBrief = composedBrief.replace("$MT", enfac) composedBrief = composedBrief.replace("$DS", processSystem(path[-1])) composedBrief = composedBrief.replace("$PY", str(int(creds))) composedBrief = composedBrief.replace("$AI", additionalinfo) composedBrief = composedBrief.replace("$ET", formatShip(typ)) if len(path) == 1: mistype = "IN-SYSTEM ESCORT" else: mistype = "ESCORT" writedescription(composedBrief) writemissionsavegame( addstr + mission_script_template % dict( module="escort_local", constructor="escort_local", args=(enfac, 0, diff, waves, 500, creds, incoming, fac, (), "", enfg, "", fg, typ), ) ) writemissionname("Escort/Escort_%s_%s" % (fac, fg), [path[-1]], isFixerString(addstr)) writemissionvars({"MISSION_TYPE": mistype})
def newNews(): if (vsrandom.randrange(0,2)!=0): return newsitem = vsrandom.randrange (0,len(news)) newsitem = news[newsitem] player = VS.getMissionOwner() for conditional in newsitem[1]: debug.info("conditioning") if (not conditional): return universe.setFirstSaveData(player,newsitem[0],1) Director.pushSaveString(player,"dynamic_news",'#'+newsitem[2])
def DefaultNumShips(): """Get number of (opponent) ships to launch based on the difficulty level.""" diff=VS.GetDifficulty() if (diff>.9): return vsrandom.randrange(1,5) if (diff>.5): return vsrandom.randrange(1,4) if (diff>.2): return vsrandom.randrange(1,3) if (vsrandom.randrange(0,4)==0): return 2 return 1
def DeletePatrolPoint(self, num, nam): import vsrandom if (vsrandom.random() < self.encounterprob): import faction_ships fac = self.faction if (type(fac) is list or type(fac) is tuple): fac = fac[vsrandom.randrange(0, len(fac))] dynfg = "" import fg_util import VS allfg = fg_util.AllFGsInSystem(fac, VS.getSystemFile()) if (len(allfg)): dynfg = allfg[vsrandom.randrange(0, len(allfg))] for i in range(vsrandom.randrange(self.minships, self.maxships + 1)): import launch L = launch.Launch() if self.fgname == "": fgname = "Patrol" else: fgname = self.fgname L.fg = fgname L.dynfg = dynfg if (vsrandom.random() < self.capshipprob): L.type = faction_ships.getRandomCapitol(fac) else: L.type = faction_ships.getRandomFighter(fac) L.ai = "default" L.faction = fac L.num = 1 L.minradius = 3000.0 L.maxradius = 4000.0 if i == 0: L.fgappend = "" else: L.fgappend = "_" + str(i) try: L.minradius *= faction_ships.launch_distance_factor L.maxradius *= faction_ships.launch_distance_factor except: pass if (self.patrolpoints[num]): newun = L.launch(self.patrolpoints[num]) if (self.forceattack): lead = newun.getFlightgroupLeader() if (lead): lead.SetTarget(self.you) else: newun.setFlightgroupLeader(newun) newun.SetTarget(self.you) newun.setFgDirective("A.") self.Track(newun) patrol.patrol.DeletePatrolPoint(self, num, nam)
def DeletePatrolPoint(self,num,nam): import vsrandom if (vsrandom.random()<self.encounterprob): import faction_ships fac=self.faction if (type(fac) is list or type(fac) is tuple): fac = fac[vsrandom.randrange(0,len(fac))] dynfg="" import fg_util import VS allfg=fg_util.AllFGsInSystem(fac,VS.getSystemFile()) if (len(allfg)): dynfg = allfg[vsrandom.randrange(0,len(allfg))] for i in range(vsrandom.randrange(self.minships,self.maxships+1)): import launch L=launch.Launch() if self.fgname=="": fgname="Patrol" else: fgname = self.fgname L.fg = fgname L.dynfg=dynfg if (vsrandom.random()<self.capshipprob): L.type=faction_ships.getRandomCapitol(fac) else: L.type=faction_ships.getRandomFighter(fac) L.ai="default" L.faction=fac L.num=1 L.minradius=3000.0 L.maxradius=4000.0 if i == 0: L.fgappend="" else: L.fgappend="_"+str(i) try: L.minradius*=faction_ships.launch_distance_factor L.maxradius*=faction_ships.launch_distance_factor except: pass if (self.patrolpoints[num]): newun=L.launch(self.patrolpoints[num]) if (self.forceattack): lead=newun.getFlightgroupLeader() if (lead): lead.SetTarget(self.you) else: newun.setFlightgroupLeader(newun) newun.SetTarget(self.you) newun.setFgDirective("A.") self.Track(newun) patrol.patrol.DeletePatrolPoint(self,num,nam)
def attackFlightgroup (fgname, faction, enfgname, enfaction,iscap): global dnewsman_ if (iscap): battlename=dnewsman_.TYPE_FLEETBATTLE (leader,enleader)=iscap.split(",") else: battlename = dnewsman_.TYPE_BATTLE leader = fg_util.getFgLeaderType(fgname,faction) enleader = fg_util.getFgLeaderType(enfgname,enfaction) sys = fg_util.FGSystem (fgname,faction) ensys = fg_util.FGSystem (enfgname,enfaction) if (sys==ensys): if (0 and VS.systemInMemory(sys)): VS.pushSystem(sys) LaunchEqualShips (fgname,faction,enfgname,enfaction) VS.TargetEachOther (fgname,faction,enfgname,enfaction) VS.popSystem() #debug.debug('duke '+fgname + ' '+enfgname) SimulatedDukeItOut (fgname,faction,enfgname,enfaction) elif (sys!='nil' and ensys!='nil'): #pursue other flightgroup import universe adjSystemList=universe.getAdjacentSystemList(sys) if ensys in adjSystemList: fg_util.TransferFG (fgname,faction,ensys) else: return 0 else: return 0 #debug.debug('nil DRAW error') if (fg_util.NumShipsInFG(fgname,faction)==0): if (fg_util.NumShipsInFG(enfgname,enfaction)==0): dnewsman_.writeDynamicString([str(Director.getSaveData(0,"stardate",0)),battlename,dnewsman_.STAGE_END,faction,enfaction,dnewsman_.SUCCESS_DRAW,str(getImportanceOfSystem(sys)),sys,dnewsman_.KEYWORD_DEFAULT,fgname,leader,enfgname,enleader]) else: dnewsman_.writeDynamicString([str(Director.getSaveData(0,"stardate",0)),battlename,dnewsman_.STAGE_END,faction,enfaction,dnewsman_.SUCCESS_LOSS,str(getImportanceOfSystem(sys)),sys,dnewsman_.KEYWORD_DEFAULT,fgname,leader,enfgname,enleader]) return 0 elif (fg_util.NumShipsInFG(enfgname,enfaction)==0): dnewsman_.writeDynamicString([str(Director.getSaveData(0,"stardate",0)),battlename,dnewsman_.STAGE_END,faction,enfaction,dnewsman_.SUCCESS_WIN,str(getImportanceOfSystem(sys)),sys,dnewsman_.KEYWORD_DEFAULT,fgname,leader,enfgname,enleader]) return 0 if (vsrandom.randrange(0,4)==0): #FIXME if it is advantageous to stop attacking only!! #FIXME add a stop attacking news report? -- this should now be fixed, as a draw is reported (not heavilly tested) #CAUSES TOO MUCH NEWS#Director.pushSaveString(0,"dynamic_news",dynamic_news.makeVarList([str(Director.getSaveData(0,"stardate",0)),battlename,"end",faction,enfaction,"0",str(getImportanceOfSystem(sys)),sys,"all",fgname,leader,enfgname,enleader])) return 0 if (vsrandom.randrange(0,4)==0 and enfgname!=fg_util.BaseFGInSystemName(ensys)): #FIXME if it is advantageous to run away only #FIXME add a retreat news report? -- this should now be fixed, as a draw is reported (not heavilly tested) #CAUSES TOO MUCH NEWS#Director.pushSaveString(0,"dynamic_news",dynamic_news.makeVarList([str(Director.getSaveData(0,"stardate",0)),battlename,"end",faction,enfaction,"-1",str(getImportanceOfSystem(sys)),sys,"all",fgname,leader,enfgname,enleader])) num=VS.GetNumAdjacentSystems(ensys) if (num>0): ensys=VS.GetAdjacentSystem(ensys,vsrandom.randrange(0,num)) fg_util.TransferFG (fgname,faction,ensys) return 1
def MakeContraband(which): constructor = cargo_mission.cargo_mission numsys=vsrandom.randrange(2,5) jumps=universe.getAdjacentSystems(VS.getSystemFile(),numsys)[1] diff=vsrandom.randrange(0,3) creds=numsys*2500+diff*800 args = ('pirates', 0, 6, diff,creds, 1, 1200, 'Contraband',jumps) briefing0 = 'We need some...*cough*... cargo delivered to some of our pirates in a nearby system: '+ Jumplist(jumps)+ ' It\'d be preferable if ye kept the ole po\' off yo back durin the run. Will ya do it for '+str(creds)+' creds?' briefing1 = 'Thanks pal; keep it on the d&l if you know my meanin.' vars = { 'MISSION_TYPE' : 'CONTRABAND', 'MISSION_SHORTDESC' : 'Deliver contraband to %s for %s' % (Jumplist(jumps),creds) } AddNewMission(which,args,constructor,briefing0,briefing1,vars,vars) return ("bases/fixers/pirate.spr","Talk with the Pirate")
def SimulatedDukeItOut (fgname,faction,enfgname,enfaction): ally=fg_util.LandedShipsInFG(fgname,faction) enemy=fg_util.LandedShipsInFG(enfgname,enfaction) if (len(enemy) and len(ally)): allyvictim = vsrandom.randrange(0,len(ally)) allystats = faction_ships.GetStats(ally[allyvictim][0]) envictim = vsrandom.randrange(0,len(enemy)) enstats = faction_ships.GetStats(enemy[envictim][0]) endam = HowMuchDamage(enemy,vsrandom.uniform(0,allystats[1])) if (enfgname==fgname and enfaction==faction): debug.error("FAULT FAULT FAULT") ApplyDamage(enfgname,enfaction,enemy,envictim,enstats,HowMuchDamage(ally,vsrandom.uniform(0,enstats[1])),fgname,faction) ApplyDamage(fgname,faction,ally,allyvictim,allystats,endam,enfgname,enfaction)
def launch_new_wave(self): side = vsrandom.randrange(0, 2) faction = "confed" ai = vsrandom.randrange(0, 2) if (ai == 0): ai = "printhello.py" else: ai = "default" if (side == 0): faction = faction_ships.get_enemy_of("confed") else: faction = faction_ships.get_friend_of("confed") launched = launchShip(faction_ships.getRandomFighter(faction), faction)
def initrandom(factionname, difficulty, creds, entime, numsysaway, jumps=(), var_to_set='', dynfg='', dyntype=''): return escort_mission(factionname, difficulty, 20000, vsrandom.randrange(5000, 7000), vsrandom.randrange(10, 300), creds, entime, numsysaway, jumps, var_to_set, dynfg, dyntype)
def launch_new_wave(self): side = vsrandom.randrange(0,2) faction="confed" ai = vsrandom.randrange(0,2) if (ai==0): ai = "printhello.py" else: ai = "default" if (side==0): faction=faction_ships.get_enemy_of("confed") else: faction=faction_ships.get_friend_of("confed") launched = launchShip(faction_ships.getRandomFighter(faction),faction);
def generateBountyMission(path, fg, fac): typ = fg_util.RandomShipIn(fg, fac) cap = faction_ships.isCapital(typ) makemissionharder = vsrandom.randrange(0, 2) diff = vsrandom.randrange(0, adjustQuantityDifficulty(7)) + howMuchHarder(makemissionharder) runaway = vsrandom.random() >= 0.75 creds = 750 + 1000 * runaway + 450 * diff + syscreds * len(path) if cap: creds *= 4 finalprice = creds + syscreds * len(path) finalprice *= getPriceModifier(False) addstr = "" isFixer = vsrandom.random() if isFixer < fixerpct: finalprice *= 2 addstr += "#F#bases/fixers/hunter.spr#Talk with the Bounty Hunter#We will pay you on mission completion. And as far as anyone knows-- we never met." if runaway: addstr += "#Also-- we have information that the target may be informed about your attack and may be ready to run. Be quick!" addstr += "#\n" elif isFixer < guildpct: creds *= 1.5 addstr += "#G#Bounty#\n" elif use_missioncomputer: addstr += "#C#Bounty#\n" writemissionsavegame( addstr + mission_script_template % dict(module="bounty", constructor="bounty", args=(0, 0, finalprice, runaway, diff, fac, path, "", fg, typ)) ) diffstr = "" if diff > 0: diffstr = " The ship in question is thought to have %d starships for protection." % diff randCompany = GetRandomCompanyName() bountyb = GetRandomBountyBrief() composedBrief = bountyb.replace("$CL", randCompany) composedBrief = composedBrief.replace("$MT", formatShip(typ)) composedBrief = composedBrief.replace("$DS", processSystem(path[-1])) composedBrief = composedBrief.replace("$PY", str(int(finalprice))) if len(path) == 1: mistype = "IN-SYSTEM BOUNTY" else: mistype = "BOUNTY" writedescription(composedBrief) if cap: writemissionname( "Bounty/on_%s_Capital_Vessel_in_%s" % (fac, processSystem(path[-1])), path, isFixerString(addstr) ) else: writemissionname("Bounty/on_%s_starship_in_%s" % (fac, processSystem(path[-1])), path, isFixerString(addstr)) writemissionvars({"MISSION_TYPE": mistype})
def newNews(): if vsrandom.randrange(0, 2) != 0: return newsitem = vsrandom.randrange(0, len(news)) newsitem = news[newsitem] player = VS.getMissionOwner() for conditional in newsitem[1]: print "conditioning" if not conditional: return universe.setFirstSaveData(player, newsitem[0], 1) import Director Director.pushSaveString(player, "dynamic_news", "#" + newsitem[2])
def initrandom(factionname, missiondifficulty, creds_per_jump, launchoncapship, sysmin, sysmax, time_to_complete, category, jumps=(), var_to_set=''): numsys = vsrandom.randrange(sysmin, sysmax) return cargo_mission(factionname, numsys, vsrandom.randrange(4, 15), missiondifficulty, creds_per_jump * float(1 + numsys), launchoncapship, 10.0, category, jumps, var_to_set)
def GetDiffInt (diff): ch=0 if (diff<=0.1): ch=0 elif (diff<=0.3): ch=1-vsrandom.randrange(0,2) elif (diff<=0.5): ch=2-vsrandom.randrange(0,3) elif (diff<=0.7): ch=3-vsrandom.randrange(0,4) elif (diff<=0.9): ch=4-vsrandom.randrange(0,5) else: ch=5-vsrandom.randrange(0,6) return ch
def launch_new_wave(self): side = vsrandom.randrange(0,2) faction="confed" ai = vsrandom.randrange(0,8) if (0 and ai==0): ai = "printhello.py" else: ai = "default" if (side==0): faction=faction_ships.get_enemy_of("confed") else: faction="merchant" launched = launch.launch_wave_around_unit ("Shadow",faction,faction_ships.getRandomFighter(faction),ai,vsrandom.randrange(1,5),100.0,2000.0,VS.getPlayer(),'') if (vsrandom.randrange(0,10)==0 or faction=="luddites"): launch.launch_wave_around_unit ("ShadowCap"+str(vsrandom.randrange(0,10)),faction,faction_ships.getRandomCapitol(faction),ai,1,2000.0,4000.0,VS.getPlayer(),'')
def GetDiffInt(diff): ch = 0 if (diff <= 0.1): ch = 0 elif (diff <= 0.3): ch = 1 - vsrandom.randrange(0, 2) elif (diff <= 0.5): ch = 2 - vsrandom.randrange(0, 3) elif (diff <= 0.7): ch = 3 - vsrandom.randrange(0, 4) elif (diff <= 0.9): ch = 4 - vsrandom.randrange(0, 5) else: ch = 5 - vsrandom.randrange(0, 6) return ch
def generateBountyMission(path, fg, fac, baseprice=1200.0, runawayprice=1000.0, diffprice=450.0, capscale=4.0): typ = fg_util.RandomShipIn(fg, fac) cap = faction_ships.isCapital(typ) makemissionharder = vsrandom.randrange(0, 2) diff = vsrandom.randrange( 0, adjustQuantityDifficulty(7)) + howMuchHarder(makemissionharder) runaway = (vsrandom.random() >= .75) creds = (baseprice + runawayprice * runaway + diffprice * diff + syscreds * len(path)) if (cap): creds *= capscale finalprice = creds + syscreds * len(path) finalprice *= getPriceModifier(False) addstr = "" isFixer = vsrandom.random() if isFixer < fixerpct: finalprice *= 2 addstr += "#F#bases/fixers/hunter.spr#Talk with the Bounty Hunter#We will pay you on mission completion. And as far as anyone knows -- we never met." if (runaway): addstr += '#Also-- we have information that the target may be informed about your attack and may be ready to run. Be quick!' addstr += "#\n" elif isFixer < guildpct: creds *= 1.5 addstr += "#G#Bounty#\n" writemissionsavegame( addstr + "import bounty\ntemp=bounty.bounty(0, 0, %g, %d, %d, '%s', %s, '', '%s','%s')\ntemp=0\n" % (finalprice, runaway, diff, fac, str(path), fg, typ)) diffstr = "" if (diff > 0): diffstr = " The ship in question is thought to have %d starships for protection." % diff writedescription( "A %s starship in the %s flightgroup has been harassing operations in the %s system. Reward for the termination of said ship is %d credits.%s" % (formatShip(typ), fg, processSystem(path[-1]), finalprice, diffstr)) if (cap): writemissionname( "Bounty/on_%s_Capital_Vessel_in_%s" % (fac, processSystem(path[-1])), path, isFixerString(addstr)) else: writemissionname( "Bounty/on_%s_starship_in_%s" % (fac, processSystem(path[-1])), path, isFixerString(addstr))
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 writeDynamicString(self, varlist): """Stores a news story list into the \"dynamic news\" key in the save game.""" varlist = string.join([str(vsrandom.randrange(0, 4194304))] + varlist, ',') import Director Director.pushSaveString(0, "dynamic_news", varlist)
def GetDiffInt(diff): """Convert difficulty (float) to an integer value""" ch = 0 if (diff <= 0.1): ch = 0 elif (diff <= 0.3): ch = 1 - vsrandom.randrange(0, 2) elif (diff <= 0.5): ch = 2 - vsrandom.randrange(0, 3) elif (diff <= 0.7): ch = 3 - vsrandom.randrange(0, 4) elif (diff <= 0.9): ch = 4 - vsrandom.randrange(0, 5) else: ch = 5 - vsrandom.randrange(0, 6) return ch
def getRandIncDec(type): type += vsrandom.randrange(-1, 2, 2) if (type < 0): type = 0 elif (type > 5): type = 5 return type
def GetDiffCargo(diff, base_category, all_category, use_all, postfixes, dont_use_all=0): cat = all_category ch = dont_use_all #this makes ch only 1 if (diff <= 0.2): ch = 1 elif (diff <= 0.4): ch = 2 - vsrandom.randrange(dont_use_all, 3) elif ((diff <= 0.7) or use_all): ch = 3 - vsrandom.randrange(dont_use_all, 4) return base_category + postfixes[(ch - 1) * len(postfixes) // 3]