def initiateAttack (fgname,faction,sys,enfgname,enfaction): capitala = fg_util.CapshipInFG(fgname,faction) capitalb = fg_util.CapshipInFG(enfgname,enfaction) iscap = None if capitala and capitalb: iscap = capitala+','+capitalb if (fg_util.BaseFGInSystemName(sys)==fgname): fg=(enfgname,enfaction)#this is for a base... self defence efg=(fgname,faction) else: fg = (fgname,faction) efg = (enfgname,enfaction) #FIXME can overwrite the attacking groups!! if (not efg in defendlist): if (iscap): global reportbegin if (reportbegin==0): global dnewsman_ dnewsman_.writeDynamicString([str(Director.getSaveData(0,"stardate",0)),dnewsman_.TYPE_FLEETBATTLE,dnewsman_.STAGE_BEGIN,faction,enfaction,dnewsman_.SUCCESS_DRAW,str(getImportanceOfSystem(sys)),sys,dnewsman_.KEYWORD_DEFAULT,fgname,capitala,enfgname,capitalb]) reportbegin+=1 reportbegin=reportbegin%10 if (fg in attacklist): defender = attacklist[fg] del defendlist[(defender[0],defender[1])] attacklist[fg]=(efg[0],efg[1],iscap) defendlist[efg]=(fg[0],fg[1],iscap)
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 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 randomMovement(fg,fac): import universe import fg_util citizen=VS.isCitizen(fac) sys=fg_util.FGSystem(fg,fac) convoywhere=fg.find("->") if (convoywhere!=-1): endpoints=[fg[0:convoywhere],fg[convoywhere+2:]] if fg.find("Insys")!=-1: return#can't go about moving insys fgs away if (sys!='nil' and fg!=fg_util.BaseFGInSystemName(sys)): l = universe.getAdjacentSystemList(sys) nthis = fg_util.NumFactionFGsInSystem(fac,sys) if (len(l)): suggestednewsys = l[vsrandom.randrange(0,len(l))] sugfac=VS.GetGalaxyFaction(suggestednewsys) sugrel=VS.GetRelation(fac,sugfac) if convoywhere==-1 and (((fac.find(sugfac)!=-1 or sugrel>.5) and citizen) or not citizen): fg_util.TransferFG( fg,fac,suggestednewsys); #debug.debug('moving '+fg+' from '+sys+' to '+ suggestednewsys) else: for i in l: ifac = VS.GetGalaxyFaction(i) #if (ifac==fac and nthis > fg_util.NumFactionFGsInSystem(fac,i)): # suggestednewsys = i likes=False if convoywhere!=-1: if endpoints[0]==i or endpoints[1]==i: likes=True elif VS.GetRelation(fac,ifac)>.5: likes=True if (likes): fg_util.TransferFG(fg,fac,i) return #debug.debug('moving '+fg+' from '+sys+' to '+ suggestednewsys) fg_util.TransferFG( fg,fac,suggestednewsys); else: pass #debug.debug("flightgroup "+fg+" in system "+sys + " is stuck")
def AddBasesToSystem(faction, sys): if (sys in doNotAddBasesTo): return slash = sys.find("/") if (slash != -1): if (sys[0:slash] in doNotAddBasesTo): return if faction in faction_ships.factions: fsfac = list(faction_ships.factions).index(faction) numbases = 0 # numplanets=VS.GetGalaxyProperty(sys,"num_planets"); numjumppoints = VS.GetNumAdjacentSystems(sys) if (numjumppoints < 4): if (vsrandom.random() >= .25): numbases = 1 elif (vsrandom.random() >= .005): if (numjumppoints < 7): numbases = vsrandom.randrange(1, int(numjumppoints // 2) + 1) elif numjumppoints == 7: numbases = vsrandom.randrange(1, 6) else: numbases = vsrandom.randrange(1, numjumppoints + 1) if numbases == 0: return shiplist = [] nums = [] for i in range(numbases): whichbase = faction_ships.bases[fsfac][vsrandom.randrange( 0, len(faction_ships.bases[fsfac]))] if whichbase in shiplist: nums[shiplist.index(whichbase)] += 1 else: shiplist += [whichbase] nums.append(1) tn = [] for i in range(len(shiplist)): tn += [(shiplist[i], nums[i])] fg_util.AddShipsToFG(fg_util.BaseFGInSystemName(sys), faction, tn, sys)
def generateDefendMission (path,defendfg,defendfac, attackfg,attackfac): if (isNotWorthy(defendfac)): return #defendtyp = fg_util.RandomShipIn(defendfg,defendfac) attacktyp = fg_util.RandomShipIn(attackfg,attackfac) isbase=fg_util.BaseFGInSystemName(path[-1])==defendfg creds=1000 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#Unterhalte Dich mit dem konfoederiertem Offizier#Danke. Dein Engagement wird den Konfoederierten auf lange Sicht helfen. Wir schaetzen die Unterstuetzung durch die Gemeinschaft der Kopfgeldjaeger sehr.#\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="Kriegs-" if quantity == 1: starship = "Raumschiff" else: starship = "Raumschiffen" # change faction names like pirates to piraten if "es" == attackfac[-2:]: attackfac = attackfac[:-1] + "n" writedescription("Eine %s Angriffsschwadron mit dem Namen %s ist mit der Absicht hierher gesprungen, eines von unseren %sSchiffen in dem %s System anzugreifen.\n Deine Aufgabe ist es, sie zu vernichten bevor sie unser Raumschiff eliminieren.\n Unser Geheimdienst vermutet, dass die Schwadron aus %d %s der %s Klasse besteht. Deine Belohnung betraegt %d Kredite."%(attackfac, attackfg, iscapitol, processSystem(path[-1]),quantity,starship,formatShip(attacktyp),creds)) writemissionname("Schutz/Beschuetze die_%s vor den_%s"%(defendfac, attackfac),path,isFixerString(addstr))