Exemplo n.º 1
0
def launch_dockable_around_unit(fg,
                                faction,
                                ai,
                                radius,
                                myunit,
                                garbage_collection_distance,
                                logo='',
                                fgappend='',
                                skipdj=0):
    import fg_util
    for i in fg_util.LandedShipsInFG(fg, faction):
        if (i[0] == 'Mule.stock' or i[0] == 'Mule'
                or faction_ships.isCapital(i[0])):
            un = launch_types_around(fg, faction, [i], ai, radius, myunit,
                                     garbage_collection_distance, logo,
                                     fgappend, skipdj)
            if (un.isDockableUnit()):
                return un
    if (fgappend == 'Base'):
        fg = fgappend
    else:
        fg = fg + fgappend
    return launch.launch_wave_around_unit(
        fg, faction, faction_ships.getRandomCapitol(faction), ai, 1, radius,
        radius * 1.5, myunit, logo, 1, skipdj)
Exemplo n.º 2
0
def CapshipInFG(fg,fac):
    key = MakeFGKey(fg,fac)
    for num in xrange(ShipListOffset(),Director.getSaveStringLength(ccp,key),PerShipDataSize()):
        import faction_ships
        shipinquestion=Director.getSaveString(ccp,key,num)
        if (faction_ships.isCapital(shipinquestion)):
            return shipinquestion
    return None
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})
Exemplo n.º 4
0
def launch_dockable_around_unit (fg,faction,ai,radius,myunit,garbage_collection_distance,logo='',fgappend=''):
    for i in fg_util.LandedShipsInFG(fg,faction):
        if (i[0]=='mule.blank' or i[0]=='mule' or faction_ships.isCapital(i[0])):
            un=launch_types_around (fg,faction,[i],ai,radius,myunit,garbage_collection_distance,logo,fgappend)
            if (un.isDockableUnit()):
                return un
    if (fgappend=='Base'):
        fg=fgappend
    else:
        fg=fg+fgappend
    return launch.launch_wave_around_unit(fg,faction,faction_ships.getRandomCapitol(faction),ai,1,radius,radius*1.5,myunit,logo)
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})
Exemplo n.º 6
0
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))
Exemplo n.º 7
0
    def Preprocess(self):
        debug.debug("Entering Preprocess()")
        self._preprocess = 1
        self._dyn_nr_ships = []
        self._nr_ships = self.num
        import faction_ships
        if self.dynfg != '':
            import fg_util
            tn = fg_util.ShipsInFG(self.dynfg, self.faction)
            debug.info('Dynamically launching from SaveString flightgroup ' +
                       self.dynfg + ' with ships: ' + str(tn) + ' faction ' +
                       self.faction)
            knum = 0
            if (tn != [] and self.type != ''):
                for i in range(len(tn)):
                    if (tn[i][0] == self.type):
                        knum = tn[i][1]
                        if (knum > self.num):
                            knum = self.num
                        self._dyn_nr_ships = [(self.type, knum)]
                        del tn[i]
                        break
##          if (tn==[]):
##          print 'Dyn-Launch: tn==[]'
##          self.dynfg=''
            elif (tn == []):
                debug.info("Dyn-Launch: tn==" + str(tn) + ", dynfg=='" +
                           str(self.dynfg) + "' getting random fighter")
                self.type = faction_ships.getRandomFighterInt(
                    faction_ships.factionToInt(self.faction))
                self.fg = self.dynfg
                self.dynfg = ''
            if self.forcetype and len(
                    self._dyn_nr_ships) == 0 and self.type != '':
                self._dyn_nr_ships = [(self.type, 1)]
                knum = 1
            for i in tn:
                if (knum >= self.num):
                    break
                if (self.capitalp or (not faction_ships.isCapital(i[0]))):
                    if (i[1] > self.num - knum):
                        i = (i[0], self.num - knum)
                    self._dyn_nr_ships += [i]
                    knum += i[1]
            self._nr_ships = self.num - knum
Exemplo n.º 8
0
    def Preprocess(self):
        self._preprocess = 1
        self._dyn_nr_ships = []
        self._nr_ships = self.num
        import faction_ships

        if self.dynfg != "":
            import fg_util

            tn = fg_util.ShipsInFG(self.dynfg, self.faction)
            debug.debug(
                "dynamic launching from " + str(tn) + " from flightgroup " + self.dynfg + " faction " + self.faction
            )
            knum = 0
            if tn != [] and self.type != "":
                for i in range(len(tn)):
                    if tn[i][0] == self.type:
                        knum = tn[i][1]
                        if knum > self.num:
                            knum = self.num
                        self._dyn_nr_ships = [(self.type, knum)]
                        del tn[i]
                        break
            ##        if (tn==[]):
            ##          print 'Dyn-Launch: tn==[]'
            ##          self.dynfg=''

            elif tn == []:
                debug.error("Dyn-Launch: tn==[], dynfg=='' Error 47")
                self.type = faction_ships.getRandomFighterInt(faction_ships.factionToInt(self.faction))
                self.fg = self.dynfg
                self.dynfg = ""
            if self.forcetype and len(self._dyn_nr_ships) == 0 and self.type != "":
                self._dyn_nr_ships = [(self.type, 1)]
                knum = 1
            for i in tn:
                if knum >= self.num:
                    break
                if self.capitalp or (not faction_ships.isCapital(i[0])):
                    if i[1] > self.num - knum:
                        i = (i[0], self.num - knum)
                    self._dyn_nr_ships += [i]
                    knum += i[1]
            self._nr_ships = self.num - knum
Exemplo n.º 9
0
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))
Exemplo n.º 10
0
    def Preprocess (self):
        debug.debug("Entering Preprocess()")
        self._preprocess=1
        self._dyn_nr_ships=[]
        self._nr_ships=self.num
        import faction_ships
        if self.dynfg != '':
            import fg_util
            tn=fg_util.ShipsInFG(self.dynfg,self.faction)
            debug.info('Dynamically launching from SaveString flightgroup '+self.dynfg + ' with ships: '+str(tn)+' faction '+ self.faction)
            knum=0
            if (tn!=[] and self.type!=''):
                for i in range (len(tn)):
                    if (tn[i][0]==self.type):
                        knum=tn[i][1]
                        if (knum>self.num):
                            knum=self.num
                        self._dyn_nr_ships=[(self.type,knum)]
                        del tn[i]
                        break
##          if (tn==[]):
##          print 'Dyn-Launch: tn==[]'
##          self.dynfg=''
            elif (tn==[]):
                debug.info("Dyn-Launch: tn=="+str(tn)+", dynfg=='"+str(self.dynfg)+"' getting random fighter")
                self.type=faction_ships.getRandomFighterInt(faction_ships.factionToInt(self.faction))
                self.fg = self.dynfg
                self.dynfg=''
            if self.forcetype and len(self._dyn_nr_ships)==0 and self.type!='':
                self._dyn_nr_ships=[(self.type,1)]
                knum=1
            for i in tn:
                if (knum>=self.num):
                    break
                if (self.capitalp or (not faction_ships.isCapital(i[0])) ):
                    if (i[1]>self.num-knum):
                        i = (i[0],self.num-knum)
                    self._dyn_nr_ships+=[i]
                    knum+=i[1]
            self._nr_ships=self.num-knum
Exemplo n.º 11
0
    def Preprocess (self):
        self._preprocess=1
        self._dyn_nr_ships=[]
        self._nr_ships=self.num
        import faction_ships
        if self.dynfg!='':
            import fg_util
            tn=fg_util.ShipsInFG(self.dynfg,self.faction)
            print 'dynamic launching from '+str(tn)+' from flightgroup '+self.dynfg + ' faction '+ self.faction
            knum=0
            if (tn!=[] and self.type!=''):
                for i in range (len(tn)):
                    if (tn[i][0]==self.type):
                        knum=tn[i][1]
                        if (knum>self.num):
                            knum=self.num
                        self._dyn_nr_ships=[(self.type,knum)]
                        del tn[i]
                        break
##        if (tn==[]):
##          print 'Dyn-Launch: tn==[]'
##          self.dynfg=''
          
            elif (tn==[]):
                print "Dyn-Launch: tn==[], dynfg==\'\' Error 47"
                self.type=faction_ships.getRandomFighterInt(faction_ships.factionToInt(self.faction))
                self.fg = self.dynfg        
                self.dynfg=''
            if self.forcetype and len(self._dyn_nr_ships)==0 and self.type!='':
                self._dyn_nr_ships=[(self.type,1)]
                knum=1
            for i in tn:
                if (knum>=self.num):
                    break
                if (self.capitalp or (not faction_ships.isCapital(i[0])) ):
                    if (i[1]>self.num-knum):
                        i = (i[0],self.num-knum)
                    self._dyn_nr_ships+=[i]
                    knum+=i[1]
            self._nr_ships=self.num-knum
Exemplo n.º 12
0
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()>=.75)
    creds=1000+2000*runaway+500*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#Unterhalte Dich mit dem Kopfgeldjaeger#Wir bezahlen dich bei erfolgreicher Beendung der Mission. Und noch ein weiser Ratschlag auf deinen Weg -- Wir haben uns niemals getroffen."
        if (runaway):
            addstr += '#Ausserdem-- wir haben Informationen, dass das Angriffsziel ueber Deinen Angriff informiert sein koennte und bereit ist zu verschwinden. Beeil Dich!'
        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==1):
        diffstr="Es wird vermutet, dass das feindliche Schiff einen Geleitschutz von einem Raumschiff hat."
    if (diff>1):
        diffstr="Es wird vermutet, dass das feindliche Schiff einen Geleitschutz von %d Raumschiffen hat."%diff
    writedescription("Ein %s Raumschiff aus der %s hat unsere Operationen im %s System gestoert. Die Belohnung fuer die Vernichtung des genannten Schiffes betraegt %d Kredite. %s"%(formatShip(typ),fg, processSystem(path[-1]), finalprice,diffstr))
    # change faction names like pirates to piraten
    if "es" == fac[-2:]:
        fac = fac[:-1] + "n"
    if (cap):
        writemissionname ("Kopfgeldjagd/Jagd auf ein_%s_Kriegsschiff im_%s_System"%(fac,processSystem(path[-1])),path,isFixerString(addstr))
    else:
        writemissionname ("Kopfgeldjagd/Jagd auf ein_%s_Raumschiff im_%s_System"%(fac,processSystem(path[-1])),path,isFixerString(addstr))
Exemplo n.º 13
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())
Exemplo n.º 14
0
def getImportanceOfType (typ):
    import faction_ships
    if (faction_ships.isCapital(typ)):
        return 1
    return .5
Exemplo n.º 15
0
def numShips(i):
    if (faction_ships.isCapital(i[0])):
        return i[1]*10
    return i[1]