Exemplo n.º 1
0
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)
Exemplo n.º 2
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
Exemplo n.º 3
0
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 AddSysDict(cursys):
    global _generatedsys, _last_progress_percent
    #pick random fighter from insysenemies with .3 probability OR pick one from the friendlies list.
    #       debug.debug('Addsysdict')
    sysfaction = VS.GetGalaxyFaction(cursys)

    numflightgroups = 1 + vsrandom.randrange(
        fg_util.MinNumFlightgroupsInSystem(cursys) - 1,
        fg_util.MaxNumFlightgroupsInSystem(cursys))

    #debug.debug("Initializing system %s with %d flightgroups... " % (cursys,numflightgroups))
    progress_percent = (_generatedsys / getSystemCount())
    if progress_percent - _last_progress_percent > 0.01:
        ShowProgress.setProgressBar("loading", progress_percent)
        ShowProgress.setProgressMessage(
            "loading",
            "Generating dynamic universe (%.2f%%)" % (100 * progress_percent))
        _last_progress_percent = progress_percent
    _generatedsys += 1

    global fgnames, fglists
    i = 0
    AddBasesToSystem(sysfaction, cursys)
    adjsystems = getAdjacentSystemList(cursys)
    for i in range(len(faction_ships.factions)):
        thisfac = faction_ships.factions[i]
        thisfactionnr = faction_ships.factionToInt(thisfac)
        rel = VS.GetRelation(sysfaction, thisfac)
        iscit = VS.isCitizen(thisfac)
        if iscit and thisfac.find(sysfaction) != -1:
            #debug.debug("generating spc civilian for "+cursys+" faction "+thisfac)
            #do somethign special for this military faction
            if thisfac == sysfaction:
                pass
            elif iscit:
                for neighbor in adjsystems:
                    if (VS.GetRelation(thisfac, VS.GetGalaxyFaction(neighbor))
                            > -.05):
                        #fgname=cursys+"->"+neighbor
                        fgname = "(CivReg) " + GetNewFGName(thisfac)
                        typenumbertuple = GenerateCivilianFgShips(
                            thisfac, thisfactionnr, True)
                        fg_util.AddShipsToFG(fgname, thisfac, typenumbertuple,
                                             cursys)
                fgname = "Insystem_" + cursys
                typenumbertuple = GenerateCivilianFgShips(
                    thisfac, thisfactionnr, False)
        if iscit:
            #debug.debug("generating gen civilian for "+cursys+" faction "+thisfac)
            if VS.GetRelation(
                    thisfac,
                    sysfaction) > -.05:  #brave citizens of the new order...
                fgname = GetNewFGName(thisfac)
                typenumbertuple = GenerateCivilianFgShips(
                    thisfac, thisfactionnr, True)
                fg_util.AddShipsToFG(fgname, thisfac, typenumbertuple, cursys)
    friendlychance = .7
    if cursys in faction_ships.fortress_systems:
        friendlychance = faction_ships.fortress_systems[cursys]
        #debug.debug('enemy chance for '+cursys +'= '+str(friendlychance))
    for i in range(numflightgroups):  #number of fgs in a system.
        faction = sysfaction
        friendly = 0
        if not sysfaction or sysfaction == 'unknown' or vsrandom.random(
        ) > friendlychance:
            faction = faction_ships.get_rabble_of_no_citizen(
                sysfaction)  #why even have citizens on the list then
        else:
            faction = faction_ships.get_friend_of_no_citizen(
                sysfaction
            )  #likewise--- maybe this should be a faction_ships fix
            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