Example #1
0
def moveSurroundingCapshipsToSiege(fac,sys):
    suc=0
    for i in xrange(VS.GetNumAdjacentSystems(sys)):
        asys=VS.GetAdjacentSystem(sys,i)
        for fg in fg_util.AllFGsInSystem(fac,asys):
            if fg_util.CapshipInFG(fg,fac):
                suc=1
                fg_util.TransferFG(fg,fac,sys)
    if (not suc):
        for fg in fg_util.AllFGsInSystem(fac,sys):
            if (fg_util.CapshipInFG(fg,fac)):
                suc=1
    return suc
Example #2
0
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 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))
Example #4
0
def LookForSystemWideTrouble(faction,sys):
    fg = fg_util.FGsInSystem(faction,sys)
    for i in fg:
        enemyfac = faction_ships.get_enemy_of (faction)
        efg = fg_util.AllFGsInSystem(enemy,sys)
        if (len(efg)):
            index=vsrandom.randrange(0,len(efg))#FIXME include some sort of measure "can I win"
            initiateAttack(fg,faction,sys,efg[index],enemyfac)
Example #5
0
 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 generateEscortLocal(path,
                        fg,
                        fac,
                        waveprice=float(
                            VS.vsConfig("dynamic_universe",
                                        "missions.escort.local.waveprice",
                                        "5500"))):
    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 = 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 entrust that you will safely guide my collegue until he reaches 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"
    if len(path) == 1:
        mistype = 'IN-SYSTEM ESCORT'
    else:
        mistype = 'ESCORT'
    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))
    writemissionvars({'MISSION_TYPE': mistype})