コード例 #1
0
def launch_types_around ( fg, faction, typenumbers, ai, radius, myunit, garbage_collection_distance,logo,fgappend='',skipdj=0,FarApart=1):
    pos = whereTo(radius, myunit)
    nr_ships=0
    for t in typenumbers:
        nr_ships+=t[1]
    debug.debug("before"+str(nr_ships))
    retcontainer=[None]
    if (fgappend=='' and nr_ships>1):
        (nr_ships,pos) = look_for (fg,faction,nr_ships-1,myunit,pos,garbage_collection_distance,retcontainer)
        nr_ships+=1
    debug.debug("after "+str(nr_ships)+ str(retcontainer))
    count=0
    ret=retcontainer[0]
    found=0
    for tn in typenumbers:
        num = tn[1]
        debug.debug("Python launched "+str(faction)+" "+str(tn[0])+" FG "+str(fg)+" with "+str(num)+" ships")
        if num>nr_ships:
            num=nr_ships
        for i in range(num):
            newship=[None]
            debug.debug(pos)
            pos = LaunchNext (fg,faction,tn[0], ai, pos,logo,newship,fgappend,FarApart)
            if (i==0 and found==0):
                ret=newship[0]
                found=1
        nr_ships-=num
        if (nr_ships==0):
            if (not skipdj):
                dj_lib.PlayMusik(0,dj_lib.HOSTILE_NEWLAUNCH_DISTANCE)
            return ret
    if (not skipdj):
        dj_lib.PlayMusik(0,dj_lib.HOSTILE_NEWLAUNCH_DISTANCE)
    return ret
コード例 #2
0
ファイル: launch.py プロジェクト: npetrell/privateer_wcu
def launch(fgname,
           faction,
           type,
           ai,
           nr_ships,
           nr_waves,
           vec,
           logo='',
           useani=1):
    debug.debug("fgname: %s, faction %s" % (fgname, faction))
    debug.debug("type: %s" % (type))
    debug.debug("ai: %s, nr_ships: %d, nr_waves: %d" %
                (ai, nr_ships, nr_waves))
    debug.debug("vec: %s, logo: %s, useani: %d" % (vec, logo, useani))
    #debug.debug('log'+ str( logo) + ' useani '+ str(useani))
    use_diff = usingDifficulty()
    #   if useani:
    #       VS.playAnimation ("warp.ani",vec,300.0)
    if isinstance(type, list) or isinstance(type, tuple):
        debug.debug("inside isinstance conditional (type is list or tuple)")
        for t in type:
            if t.endswith(".blank"):
                isblank = True
                break
    else:
        isblank = type.endswith(".blank")
    debug.debug("isblank = %s" % (isblank))
    # originally, this was
    #   if (not diff or not isblank)
    # which effectively always ignored isblank, since diff is almost never false
    if (not isblank):
        debug.info("Launching non-blank ship(s)")
        ret = VS.launch(fgname, type, faction, "unit", ai, nr_ships, nr_waves,
                        VS.SafeEntrancePoint(vec, 40), logo)
        ship_upgrades.adjust_upgrades(ret)
        dj_lib.PlayMusik(0, dj_lib.HOSTILE_NEWLAUNCH_DISTANCE)
    else:  # only upgrade blank ships (for now)
        debug.info("Launching blank ship(s)")
        rsize = 0.0
        diffic = VS.GetDifficulty()
        #debug.debug("VS.Unit #1")
        ret = VS.Unit()
        for i in range(nr_ships):
            mynew = VS.launch(fgname, type, faction, "unit", ai, 1, nr_waves,
                              VS.SafeEntrancePoint(vec, 40), logo)
            if (i == 0):
                ret = mynew
                rsize = mynew.rSize() * 1.75
            debug.debug("upgradeUnit '%s' using difficulty %.2f ..." %
                        (mynew.getName(), float(diffic)))
            ship_upgrades.upgradeUnit(mynew, diffic)
            debug.debug(
                "'- Done upgrading unit '%s' using difficulty %.2f ..." %
                (mynew.getName(), float(diffic)))
            vec = (
                vec[0] - rsize,
                vec[1],  #-rsize
                vec[2] - rsize)
    dj_lib.PlayMusik(0, dj_lib.HOSTILE_NEWLAUNCH_DISTANCE)
    return ret
コード例 #3
0
def launch_wave_around(fg,
                       faction,
                       ai,
                       nr_ships,
                       capship,
                       radius,
                       myunit,
                       garbage_collection_distance,
                       logo,
                       skipdj=0):
    pos = whereTo(radius, myunit)
    debug.debug("before" + str(nr_ships))
    (nr_ships, pos) = look_for(fg, faction, nr_ships, myunit, pos,
                               garbage_collection_distance)
    debug.debug("after " + str(nr_ships))
    while (nr_ships > 0):
        type = ""
        if (capship):
            type = faction_ships.getRandomCapitol(faction)
        else:
            type = faction_ships.getRandomFighter(faction)
        pos = LaunchNext(fg, faction, type, ai, pos, logo)
        nr_ships -= 1
    if (not skipdj):
        dj_lib.PlayMusik(0, dj_lib.HOSTILE_NEWLAUNCH_DISTANCE)
コード例 #4
0
ファイル: launch.py プロジェクト: yutiansut/Vegastrike-taose
def launch(fgname,
           faction,
           type,
           ai,
           nr_ships,
           nr_waves,
           vec,
           logo='',
           useani=1,
           skipdj=0):
    #  print 'log'+ str( logo) + ' useani '+ str(useani)
    diff = usingDifficulty()
    #    if useani:
    #        VS.playAnimation ("warp.ani",vec,300.0)
    if (not diff or (type.find(".blank") == -1 and -1 == type.find(".stock"))):
        for i in range(nr_ships):
            ret = VS.launch(fgname, type, faction, "unit", ai, 1, nr_waves,
                            VS.SafeEntrancePoint(vec, 40), logo)
            unit.moveOutOfPlayerPath(ret)
        if (not skipdj):
            dj_lib.PlayMusik(0, dj_lib.HOSTILE_NEWLAUNCH_DISTANCE)
        return ret
    rsize = 0.0
    diffic = VS.GetDifficulty()
    ret = VS.Unit()
    for i in range(nr_ships):
        mynew = VS.launch(fgname, type, faction, "unit", ai, 1, nr_waves,
                          VS.SafeEntrancePoint(vec, 40), logo)
        unit.moveOutOfPlayerPath(mynew)
        if (i == 0):
            ret = mynew
            rsize = mynew.rSize() * 1.75
        ship_upgrades.upgradeUnit(mynew, diffic)
        vec = (
            vec[0] - rsize,
            vec[1],  #-rsize
            vec[2] - rsize)
    if (not skipdj):
        dj_lib.PlayMusik(0, dj_lib.HOSTILE_NEWLAUNCH_DISTANCE)
    return ret
コード例 #5
0
import dj_lib
dj_lib.PlayMusik()

コード例 #6
0
    def launch_near(self, un, forceLaunch=False):
        if (VS.GetGameTime() < 10 and not forceLaunch):
            debug.debug("hola!")
            return
        cursys = VS.getSystemFile()
        cursysfaction = VS.GetGalaxyFaction(cursys)

        #   Computing probability numbers is relatively expensive,
        # accessing multiple times FG/Galaxy/Universe API.
        #   Although with some optimization it becomes acceptable on
        # a director loop, this is still much better: we compute
        # probabilities roughly once per system entry, and then just
        # launch a single flightgroup per director execution (to spread
        # launch load in time and make it less intrusive on gameplay -
        # ie, stutter less noticeably). Outside code will take care
        # of ceasing to call this function when no more flightgroups
        # are needed.

        # Validate probability cache
        if    (cursysfaction != self.probability_cache[0]) \
           or (cursys != self.probability_cache[1]) \
           or (faction_ships.getMaxFactions() != len(self.probability_cache[2])):
            debug.debug('Probability numbers:')
            psum = 0
            probs = []
            for factionnum in range(faction_ships.getMaxFactions()):
                faction = faction_ships.intToFaction(factionnum)
                num = fg_util.NumFactionFGsInSystem(
                    faction,
                    cursys)  # will count bases... but... much quicker.
                if num == 1:
                    #cannot accept counting bases in this case...
                    num = len(fg_util.FGsInSystem(faction, cursys))

                avg = float(num) / float(
                    fg_util.MaxNumFlightgroupsInSystem(
                        cursys))  #/float(numsigs)
                fortress_level = 0
                if cursys in faction_ships.fortress_systems:
                    foretress_level = faction_ships.fortress_systems[cursys]
                    avg *= (not (VS.GetRelation(cursysfaction, faction) < 0
                                 and cursys in faction_ships.fortress_systems)
                            ) * fortress_level + (1 - fortress_level)
                debug.debug('Chance for %s ship: %g' % (faction, avg))
                probs.append(avg)
                psum += avg
            self.probability_cache = (cursysfaction, cursys, probs, psum)
        else:
            debug.debug('Probability numbers cached.')

        # Launch a single random flightgroup in the bunch
        rnd = vsrandom.random() * self.probability_cache[3]
        p = 0
        for factionnum in range(len(self.probability_cache[2])):
            p += self.probability_cache[2][factionnum]
            if (p >= rnd):
                #now we know that we will generate some ships!
                faction = faction_ships.intToFaction(factionnum)
                fglist = fg_util.FGsInSystem(faction, cursys)
                for k in range(10):  #try 10 times
                    flightgroup = fglist[vsrandom.randrange(len(fglist))]
                    typenumbers = fg_util.GetShipsInFG(flightgroup, faction)
                    if not len(typenumbers):
                        continue
                    debug.debug('FG Name: "%s", ShipTypes: %s' %
                                (flightgroup, str(typenumbers)))
                    launch_recycle.launch_types_around(
                        flightgroup, faction, typenumbers, 'default',
                        self.generation_distance * vsrandom.random() * 0.9, un,
                        self.generation_distance * vsrandom.random() * 2, '',
                        '', 100)
                    break
                # assume after 10 tries we launched a flightgroup, we're done here
                break

        # Update DJ
        dj_lib.PlayMusik(0, dj_lib.HOSTILE_NEWLAUNCH_DISTANCE)