Пример #1
0
    def __init__( self, game, nSystems=3, nPlanets=12, nAsteroidFields=9 ):
    
        self.nSystems = nSystems
        self.nPlanets = nPlanets
        self.nAsteroidFields = nAsteroidFields

        self.distBetweenSuns = 30000
        self.distBetweenSunsMod = 4000
        self.planetDistFromSun = 9000 # also asteroids
        self.planetDistFromSunMod = 5000 # also asteroids
        self.minDistBetweenPlanets = 1000

        self.player = None

        self.harvestersAtSpawn = 4
        self.wantedBadGuys = 0

        Scenario.__init__(self, game )
        
        self.suns = []
        self.planets = []
        game.astres = []

        self.ennemyShips = []

        self.generate( game )
Пример #2
0
    def __init__(self, game):
        Scenario.__init__(self, game)

        self.harvestersAtSpawn = 4
        self.wantedBadGuys = 10

        self.sol = Sun(game.stats.S_SOL, 0, 0)
        self.mercury = Planet(game.stats.P_MERCURY, -4100, 1400)  # 4332
        self.venus = Planet(game.stats.P_VENUS, 5000, 2200)  # 5462
        self.earth = Planet(game.stats.P_EARTH, -3100, 6700)  # 7382
        self.mars = Planet(game.stats.P_MARS_1, -7800, -2200)  # 8104
        self.moon = Planet(game.stats.P_MOON, -3900, 6400)
        self.jupiter = Planet(game.stats.P_JUPITER, -12000, -4800)  # 12924
        self.saturn = Planet(game.stats.P_SATURN, 13000, 2500)  # 13238
        self.neptune = Planet(game.stats.P_NEPTUNE, 15000, 7000)  # 16552

        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth

        self.blackHole = BlackHole(game.stats.BH_0, 10000, -10000)

        for i in xrange(10):  # civilians around self.earth
            dist = randint(100, 800)
            angle = 2 * pi * random()

            (x, y) = (self.earth.xp + dist * cos(angle),
                      self.earth.yp + dist * sin(angle))
            s = Ship(game.stats.CIVILIAN_0, AiCivilian(), x, y, -20)
            game.objects.append(s)

        for i in range(60):  # asteroids between self.saturn and self.neptune
            dist = 15000
            angle = (1 - 2 * random()) * pi / 10 + pi / 7
            asteroid = Asteroid(game, self.sol.xp + dist * cos(angle),
                                self.sol.yp + dist * sin(angle), 300)
            game.harvestables.append(asteroid)

        for i in range(50):  # asteroids outer self.mars
            dist = 9000
            angle = (1 - 2 * random()) * pi / 8 + pi * 9 / 8  # 2*random()*pi #
            asteroid = Asteroid(game, self.sol.xp + dist * cos(angle),
                                self.sol.yp + dist * sin(angle), 200)
            game.harvestables.append(asteroid)

        game.astres = [
            self.sol, self.mercury, self.venus, self.earth, self.moon,
            self.mars, self.jupiter, self.saturn, self.neptune, self.moon,
            self.blackHole
        ]

        for i in xrange(self.wantedBadGuys):
            self.addRandomNpc(game)
Пример #3
0
    def __init__(self, game):
        Scenario.__init__(self, game )

        self.harvestersAtSpawn = 4
        self.wantedBadGuys = 10

        self.sol = Sun( game.stats.S_SOL, 0, 0 )
        self.mercury = Planet( game.stats.P_MERCURY, -4100, 1400 ) # 4332
        self.venus = Planet( game.stats.P_VENUS, 5000, 2200 ) # 5462
        self.earth = Planet( game.stats.P_EARTH, -3100, 6700 ) # 7382
        self.mars = Planet( game.stats.P_MARS_1, -7800, -2200 ) # 8104
        self.moon = Planet( game.stats.P_MOON, -3900, 6400 )
        self.jupiter = Planet( game.stats.P_JUPITER, -12000, -4800 ) # 12924
        self.saturn = Planet( game.stats.P_SATURN, 13000, 2500 ) # 13238
        self.neptune = Planet( game.stats.P_NEPTUNE, 15000, 7000 ) # 16552

        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth

        self.blackHole = BlackHole( game.stats.BH_0, 10000, -10000 )
        
        for i in xrange( 10 ): # civilians around self.earth
            dist = randint( 100, 800 )
            angle = 2*pi*random()

            (x,y) = (self.earth.xp+dist*cos(angle), self.earth.yp+dist*sin(angle))
            s = Ship( game.stats.CIVILIAN_0, AiCivilian(), x, y, -20 )
            game.objects.append( s )

        for i in range( 60 ): # asteroids between self.saturn and self.neptune
            dist = 15000
            angle = (1-2*random())*pi/10+pi/7
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )

        for i in range( 50 ): # asteroids outer self.mars
            dist = 9000
            angle = (1-2*random())*pi/8+pi*9/8 # 2*random()*pi # 
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 200 )
            game.harvestables.append( asteroid )

        game.astres = [self.sol, self.mercury, self.venus, self.earth, self.moon, self.mars, self.jupiter, self.saturn, self.neptune, self.moon, self.blackHole ]

        for i in xrange( self.wantedBadGuys ):
            self.addRandomNpc( game )
Пример #4
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):

        stats = Stats()
        #    stats.R_HUMAN.turrets = [ stats.T_SOLAR_0 ]
        #    stats.R_HUMAN.missiles = []
        #    stats.R_HUMAN.ships = []
        stats.PlayableShips = {}

        steps = []
        for i in xrange(8):
            steps.append(
                Step(goal=lambda self, game: not filter(
                    lambda ship: ship.alive, self.ennemyShips),
                     onBegin=lambda self, game, stepNbr=i + 1: self.
                     stepFunction(game, stepNbr),
                     failure=lambda self, game: not self.player.flagship or
                     not self.player.flagship.alive,
                     texts=[(1, "Clear the area.")]))

        Scenario.__init__(self, game, steps=steps, stats=stats)

        self.sol = Sun(game.stats.S_SOL, 4000, 0)

        for i in range(75):  # asteroids
            asteroid = Asteroid(game, -2000, 0, 800)
            game.harvestables.append(asteroid)

        game.astres = [self.sol]

        self.player = None
        self.startingPoint = (-1000, 0)

        self.ennemyPosition = (-2000, 0)
        self.ennemy = Faction(game.stats.R_EXTRA, "Unknown")
        game.addPlayer(self.ennemy)

        self.infestedAsteroid = Asteroid(game, self.ennemyPosition[0],
                                         self.ennemyPosition[1], 0)
        game.harvestables.append(self.infestedAsteroid)

        self.ennemyShips = []
Пример #5
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
    
        stats = Stats()
    #    stats.R_HUMAN.turrets = [ stats.T_SOLAR_0 ]
    #    stats.R_HUMAN.missiles = []
    #    stats.R_HUMAN.ships = []
        stats.PlayableShips = {}
        
        steps = []
        for i in xrange( 8 ):
            steps.append( Step( 
                goal=lambda self, game: not filter( lambda ship: ship.alive, self.ennemyShips ),
                onBegin=lambda self, game, stepNbr=i+1: self.stepFunction( game, stepNbr ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (1,"Clear the area.")] )
                )
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
        
        self.sol = Sun( game.stats.S_SOL, 4000, 0 )

        for i in range( 75 ): # asteroids
            asteroid = Asteroid( game, -2000, 0, 800 )
            game.harvestables.append( asteroid )
            
        game.astres = [ self.sol ]
        
        self.player = None
        self.startingPoint = ( -1000, 0 )
        
        self.ennemyPosition = ( -2000, 0 )
        self.ennemy = Faction( game.stats.R_EXTRA, "Unknown" )
        game.addPlayer( self.ennemy )
        
        self.infestedAsteroid = Asteroid( game, self.ennemyPosition[0], self.ennemyPosition[1], 0 )
        game.harvestables.append( self.infestedAsteroid )
        
        self.ennemyShips = []
Пример #6
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
        
        stats = Stats()
        stats.R_HUMAN.turrets = [ stats.T_LASER_SR_1, stats.T_LASER_SR_0,
stats.T_MASS_SR_1, stats.T_MASS_SR_0, stats.T_MASS_MR_0 ]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = [ stats.HARVESTER ]
        stats.PlayableShips = {}
        
        steps = [
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.asteroid, 300 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
             #   onBegin=lambda self, game: self.player.flagship.ore = 500,
                texts = [ (0, "We need some materials."),
                            (4*config.fps, "There is an asteroid close to the Moon."),
                            (8*config.fps, "Get close to it.") ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.ai.launching[ self.player.race.defaultHarvester.img ],
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Begin collecting raw ore."),
     (4*config.fps, "To do so, launch your harvester by pressing the blue arrow button at the bottom of the screen.") ] ),
            Step(
                goal=lambda self, game: self.player.flagship.oreProcess,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Now wait for them to bring back the ore."),
                (6*config.fps, "Don't worry about the ships following you around."),
                (10*config.fps, "They are civilian and while they are under your protection they speed up building processes.") ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.ore >= 100,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "They have now added the raw ore to the processing queue."),
                (4*config.fps, "Wait a little while and it will be transformed into usable materials."),
                (8*config.fps, "Keep harvesting and processing the ore until you reach 100 material."),
                (12*config.fps, "Notice the moving bars at the bottom right corner of the screen..."),
                (14*config.fps, "they represents the ore being processed."),
                (18*config.fps, "once they reach the right, they are usable!"),
                (22*config.fps, "They will then be added to the ore stock indicated by the blue gage in the bottom right corner."), ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.shipyards[ self.player.race.defaultHarvester.img ].getCount() >= 4,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "You now have enough material to build a new harvester and speed it up!"),
    (2*config.fps, "To do so, click on the icon of the harvester at the bottom of the screen, under the launch button.") ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.ore >= 300,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Keep harvesting and processing ore util you reach 300 material."),
                (4*config.fps, "It will follow the orders the others already received."),
                (8*config.fps, "Notice the blue bar in the upper right corner and the green one in the bottm right..."),
                (12*config.fps, "the blue one represents your shield and the green one your hull.") ] ),
            Step( 
                goal=lambda self, game: len( filter( lambda turret: turret.install, self.player.flagship.turrets ) ) >= 3,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "There are rumors of pirates in the area."),
                (4*config.fps, "Build one more mass cannon turret on your ship."),
                (8*config.fps, "To do so, click on an empty slot on the right of the screen and select an affordable turret."), ] ),
            Step( 
                goal=lambda self, game: not self.ennemyShip.alive,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                onBegin=lambda self, game: (self.addAttackingEnnemy( game, (self.moon.xp-1500,self.moon.yp-800), self.player.flagship, "Pirate lambda" ), game.setRelationBetween( self.player, self.ennemy, 1 )),
                texts = [ (0, "Defend yourself from the incoming pirate ship."),
                (4*config.fps, "To attack it, simply left-click on it once."),
                (8*config.fps, "Your crew will aim and fire the turrets."),
                (12*config.fps, "You can still help them by manoeuvering the ship so that the ennemy is in range of the turrets.") ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.orbitalbase, 100 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Well done!"),
                (2*config.fps, "Recall your harvester and return to the orbital base.") ] ),
            ]
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
    
        ### redefining stats, dangerous
        
        
        self.sol = Sun( game.stats.S_SOL, 0, 0 )
        self.mercury = Planet( game.stats.P_MERCURY, -4100, 1400 )
        self.venus = Planet( game.stats.P_VENUS, 5000, 2300 )
        self.earth = Planet( game.stats.P_EARTH, -3100, 6700 )
        self.mars = Planet( game.stats.P_MARS_1, -7800, -2300 )
        self.moon = Planet( game.stats.P_MOON, -3900, 6400 )
        self.jupiter = Planet( game.stats.P_JUPITER, -13000, -4800 )
        self.saturn = Planet( game.stats.P_SATURN, 13000, 2500 )
        self.neptune = Planet( game.stats.P_NEPTUNE, 15000, 7000 )
        
        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth
        
        # asteroids over the moon, vital to scenario
        for i in xrange( 1 ):
            self.asteroid = Asteroid( game, self.moon.xp-200, self.moon.yp+150, 10 )
            game.harvestables.append( self.asteroid )
        
        for i in xrange( 3 ): # civilians around self.earth
            dist = randint( 100, 800 )
            angle = 2*pi*random()

            (x,y) = (self.earth.xp+dist*cos(angle), self.earth.yp+dist*sin(angle))
            s = Ship( game.stats.CIVILIAN_0, AiCivilian(), x, y, -20 )
            game.objects.append( s )

        for i in range( 50 ): # asteroids outer self.mars
            dist = 9000
            angle = (1-2*random())*pi/8+pi*9/8
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )

        game.astres = [self.sol, self.mercury, self.venus, self.earth, self.moon, self.mars, self.jupiter, self.saturn, self.neptune, self.moon ]
        
        dist = self.earth.stats.maxRadius*1.5
        angle = 5*pi/8
        self.orbitalbase = OrbitalBase( None, game.stats.HUMAN_BASE_MINING, None, self.earth.xp+dist*cos(angle),self.earth.yp+dist*sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append( self.orbitalbase )
        
        self.player = None
Пример #7
0
    def __init__(self, game):
        Scenario.__init__(self, game)

        self.harvestersAtSpawn = 4
        self.wantedBadGuys = 5

        sol = Sun(game.stats.S_SOL, 0, 0)
        mercury = Planet(game.stats.P_MERCURY, -4100, 1400)
        venus = Planet(game.stats.P_VENUS, 5000, 2200)
        self.earth = Planet(game.stats.P_EARTH, -3100, 6700)
        self.mars = Planet(game.stats.P_MARS, -7800, -2200)
        moon = Planet(game.stats.P_MOON, -3900, 6400)
        jupiter = Planet(game.stats.P_JUPITER, -12000, -4800)
        saturn = Planet(game.stats.P_SATURN, 13000, 2500)
        neptune = Planet(game.stats.P_NEPTUNE, 15000, 7000)

        moon.zp = -50
        moon.yi = 0.1
        moon.orbiting = self.earth

        for i in xrange(20):  # civilians around self.earth
            dist = randint(100, 800)
            angle = 2 * pi * random()

            (x, y) = (self.earth.xp + dist * cos(angle),
                      self.earth.yp + dist * sin(angle))
            s = Ship(game.stats.CIVILIAN_0, AiCivilian(), x, y, -20)
            game.objects.append(s)

        for i in range(60):  # asteroids between saturn and neptune
            dist = 15000
            angle = (1 - 2 * random()) * pi / 10 + pi / 7
            asteroid = Asteroid(game, sol.xp + dist * cos(angle),
                                sol.yp + dist * sin(angle), 300)
            game.harvestables.append(asteroid)

        for i in range(30):  # asteroids outer self.mars
            dist = 9000
            angle = (1 - 2 * random()) * pi / 8 + pi * 9 / 8
            asteroid = Asteroid(game, sol.xp + dist * cos(angle),
                                sol.yp + dist * sin(angle), 200)
            game.harvestables.append(asteroid)

        nebula = Nebula(game.stats.A_NEBULA, 4800, 500)
        for i in range(15):  # asteroids in nebula
            asteroid = Asteroid(game, 4800, 800, 800)
            game.harvestables.append(asteroid)

        self.alphaCentaury = [
            Sun(game.stats.S_SOL, -32000, 16000),
            Planet(game.stats.P_MARS_2, -28300, 12000),
            Planet(game.stats.P_SATURN_1, -39000, 8000)
        ]
        for i in range(40):  # asteroids around self.alphaCentaury
            dist = 4600
            #angle = 2*pi*i/50
            angle = (1 - 2 * random()) * pi / 4 - pi / 8
            asteroid = Asteroid(game,
                                self.alphaCentaury[0].xp + dist * cos(angle),
                                self.alphaCentaury[0].yp + dist * sin(angle),
                                200)
            game.harvestables.append(asteroid)

        self.beta = [
            Sun(game.stats.S_SOL, 8000, -24000),
            Planet(game.stats.P_MARS_1, 12000, -22000),
            Planet(game.stats.P_X, 500, -21000),
            Planet(game.stats.P_JUPITER_1, 17000, -24700)
        ]
        for i in range(20):  # asteroids around self.beta[1]
            dist = 600
            angle = 2 * pi * random()
            asteroid = Asteroid(game, self.beta[1].xp + dist * cos(angle),
                                self.beta[1].yp + dist * sin(angle), 80)
            game.harvestables.append(asteroid)

        self.gamma = [
            Sun(game.stats.S_SOL, 40000, 4000),
            Planet(game.stats.P_MERCURY_1, 39000, -2200),
            Planet(game.stats.P_X_1, 38000, 11500)
        ]
        for i in range(20):  # asteroids around self.gamma[1]
            dist = 750
            angle = 2 * pi * random()
            asteroid = Asteroid(game, self.gamma[1].xp + dist * cos(angle),
                                self.gamma[1].yp + dist * sin(angle), 80)
            game.harvestables.append(asteroid)
        for i in range(100):  # asteroids around self.gamma
            area = choice([(7000, 300, 5 * pi / 8, pi / 9),
                           (10000, 400, 6 * pi / 8, pi / 8),
                           (12000, 500, 5 * pi / 8, pi / 11)])  # , 3000
            dist = area[0]  #randint( area[0]-area[1], area[0]+area[1] )
            angle = area[2] + area[3] * (1 - 2 * random())
            asteroid = Asteroid(game, self.gamma[0].xp + dist * cos(angle),
                                self.gamma[0].yp + dist * sin(angle), area[1])
            game.harvestables.append(asteroid)

        nebula2 = Nebula(game.stats.A_NEBULA, 8000, -16000)

        blackHole0 = BlackHole(game.stats.BH_0, -30000, -20000)

        #        for i in range( 15 ):
        #           asteroid = Asteroid( game, -7000, -3200, 800 )
        #           game.objects.append( asteroid )

        #      for i in range( 15 ):
        #         asteroid = Asteroid( game, 8500, 6800, 800 )
        #       game.objects.append( asteroid )
        self.sol = [
            sol, mercury, venus, self.earth, moon, self.mars, jupiter, saturn,
            neptune, nebula, nebula2
        ]
        game.astres = [
            sol, mercury, venus, self.earth, moon, self.mars, jupiter, saturn,
            neptune, nebula, nebula2, blackHole0
        ] + self.alphaCentaury + self.beta + self.gamma
        #   game.objects = game.objects #  + [sol, mercury, venus, self.earth, moon, self.mars, jupiter, saturn, neptune, nebula, nebula2 ] + self.alphaCentaury + self.beta

        for i in range(5):
            self.addRandomNpc(game)

        spots = []
        for o in game.astres:
            if isinstance(o, Planet) and not isinstance(o, Sun):
                spots.append(o)

        for i in xrange(30):  # random civilians
            spot = choice(spots)
            dist = randint(100, 800)
            angle = 2 * pi * random()

            (x, y) = (spot.xp + dist * cos(angle), spot.yp + dist * sin(angle))
            s = Ship(game.stats.CIVILIAN_0, AiCivilian(), x, y, -20)
            game.objects.append(s)

        self.marsDefense = Faction(game.stats.R_HUMAN, "Mars Defenses")
        obase = OrbitalBase(self.marsDefense, game.stats.HUMAN_BASE,
                            AiGovernor(self.marsDefense),
                            self.mars.xp + self.mars.stats.maxRadius * 1.5,
                            self.mars.yp + self.mars.stats.maxRadius * 1.5, 0,
                            0, 0.0, 0.0, 0.0, 0)
        for t in obase.turrets:
            t.install = TurretInstall(game.stats.T_MASS_SR_0)
            t.weapon = MassWeaponTurret(game.stats.W_MASS_SR_0)
            t.ai = AiWeaponTurret()
        obase.orbiting = self.mars
        obase.yi = 1
        obase.ore = obase.stats.maxOre
        obase.ri = -0.008
        game.objects.append(obase)

        for i in xrange(20):
            radius = self.mars.stats.maxRadius * (2.5)
            dist = self.mars.stats.maxRadius * (1.5 + 1 * random())
            angle = 2 * pi * random()  # AiPilotDefense
            fighter = ShipSingleWeapon(self.marsDefense,
                                       game.stats.HUMAN_FIGHTER,
                                       AiPilotDefense(self.mars, radius),
                                       self.mars.xp + dist * cos(angle),
                                       self.mars.yp + dist * sin(angle), 0, 4,
                                       0.0, 0.0, 0.0, 0)
            game.objects.append(fighter)
            self.marsDefense.ships.append(fighter)

        self.marsDefense.bases.append(obase)
        game.addPlayer(self.marsDefense)

        self.earthDefense = Faction(game.stats.R_HUMAN, "Earth Defenses")
        nbrBases = 3
        for i in xrange(nbrBases):
            dist = self.earth.stats.maxRadius * 1.8  #(1.8+0.4*random())
            angle = pi * i * 2 / nbrBases
            obase = OrbitalBase(self.earthDefense, game.stats.HUMAN_BASE,
                                AiGovernor(self.earthDefense),
                                self.earth.xp + dist * cos(angle),
                                self.earth.yp + dist * sin(angle), 0, 0, 0.0,
                                0.0, 0.0, 0)
            for t in obase.turrets:
                t.install = TurretInstall(game.stats.T_MASS_MR_0)
                t.weapon = MassWeaponTurret(game.stats.W_MASS_MR)
                t.ai = AiWeaponTurret()
            obase.ori = angle + pi / 2
            obase.orbiting = self.earth
            obase.xi = cos(obase.ori)
            obase.yi = sin(obase.ori)
            obase.ore = obase.stats.maxOre
            obase.ri = -0.008
            game.objects.append(obase)
            self.earthDefense.bases.append(obase)

        for i in xrange(20):
            radius = self.earth.stats.maxRadius * (2.5)
            dist = self.earth.stats.maxRadius * (1.5 + 1 * random())
            angle = 2 * pi * random()  # AiPilotDefense
            fighter = ShipSingleWeapon(self.earthDefense,
                                       game.stats.HUMAN_FIGHTER,
                                       AiPilotPolice(self.earth, radius),
                                       self.earth.xp + dist * cos(angle),
                                       self.earth.yp + dist * sin(angle), 0, 4,
                                       0.0, 0.0, 0.0, 0)
            game.objects.append(fighter)
            self.earthDefense.ships.append(fighter)

    # self.earthDefense.bases.append( obase )
        game.addPlayer(self.earthDefense)

        ## ai forces
        self.addAiBase(game, "Neptune base", neptune)
        self.addAiBase(game, "Saturn base", saturn)
        self.addAiBase(game, "Jupiter base", jupiter, 2)

        ## Evolved
        self.evolvedSwarm0 = Faction(
            game.stats.R_EVOLVED,
            "First Swarm",
            territories=[
                Territory((self.alphaCentaury[1].xp, self.alphaCentaury[1].yp),
                          500),
                Territory((self.alphaCentaury[1].xp - 1000,
                           self.alphaCentaury[1].yp - 500), 500)
            ])

        (x, y) = self.alphaCentaury[1].xp - self.alphaCentaury[
            1].stats.maxRadius * 1.5, self.alphaCentaury[
                1].yp + self.alphaCentaury[1].stats.maxRadius * 1.5
        flagship = FlagShip(self.evolvedSwarm0, game.stats.EVOLVED_FS_1,
                            AiCaptain(self.evolvedSwarm0), x, y, 0, 0, 0.0,
                            0.0, 0.0, 0)
        flagship.ore = flagship.stats.maxOre
        for t in flagship.turrets[:-2]:
            t.install = TurretInstall(game.stats.T_MASS_MR_0)
            t.weapon = MassWeaponTurret(game.stats.W_MASS_MR)
            t.ai = AiWeaponTurret()
        for t in flagship.turrets[-2:]:
            t.install = TurretInstall(game.stats.T_LASER_SR_0)
            t.weapon = LaserWeaponTurret(game.stats.W_LASER_SR)
            t.ai = AiWeaponTurret()
        for i in range(4):
            harvester = HarvesterShip(self.evolvedSwarm0,
                                      self.evolvedSwarm0.race.defaultHarvester,
                                      AiPilotHarvester(flagship), 0, 0, 0, 4,
                                      0.0, 0.0, 0.0, 0)
            flagship.shipyards[harvester.stats.img].docked.append(harvester)

        for i in xrange(5):
            if i >= 3:
                fighter = ShipSingleWeapon(self.evolvedSwarm0,
                                           game.stats.EVOLVED_BOMBER,
                                           AiPilotFighter(flagship), 0, 0, 0,
                                           4, 0.0, 0.0, 0.0, 0)
            else:
                fighter = ShipSingleWeapon(self.evolvedSwarm0,
                                           game.stats.EVOLVED_FIGHTER,
                                           AiPilotFighter(flagship), 0, 0, 0,
                                           4, 0.0, 0.0, 0.0, 0)

        for i in xrange(10):
            fighter = ShipSingleWeapon(self.evolvedSwarm0,
                                       game.stats.EVOLVED_FIGHTER,
                                       AiPilotDefense(flagship, 500), 0, 0, 0,
                                       4, 0.0, 0.0, 0.0, 0)
            (fighter.xp, fighter.yp) = (flagship.xp, flagship.yp)
            game.objects.append(fighter)
            self.evolvedSwarm0.ships.append(fighter)
        #    flagship.shipyards[ fighter.stats.img ].docked.append( fighter )
        game.objects.append(flagship)
        self.evolvedSwarm0.flagships.append(flagship)
        game.addPlayer(self.evolvedSwarm0)

        ## Extra TODO remove section
        self.extraRock0 = Faction(game.stats.R_EXTRA, "Rocks")
        for i in xrange(0):  # 4 ):
            angle = 2 * pi * random()
            dist = 750  # self.gamma[ 1 ].stats.maxRadius*
            (x, y) = self.gamma[1].xp - dist * cos(
                angle), self.gamma[1].yp + dist * sin(angle)

            if i % 4 == 0:
                flagship = FlagShip(self.extraRock0, game.stats.EXTRA_BASE,
                                    AiCaptain(self.extraRock0), x, y, 0, 0,
                                    0.0, 0.0, 0.0, 0)
                for k, t in enumerate(flagship.turrets):
                    t.install = TurretInstall(game.stats.T_ROCK_THROWER_1)
                    t.weapon = MassWeaponTurret(game.stats.W_ROCK_THROWER_1)
                    t.ai = AiWeaponTurret()
            elif i % 4 == 1:
                flagship = FlagShip(self.extraRock0, game.stats.EXTRA_FS_1,
                                    AiCaptain(self.extraRock0), x, y, 0, 0,
                                    0.0, 0.0, 0.0, 0)
                for k, t in enumerate(flagship.turrets):
                    t.install = TurretInstall(game.stats.T_DRAGON_0)
                    t.weapon = MassWeaponTurret(game.stats.W_DRAGON_0)
                    t.ai = AiWeaponTurret()
            elif i % 4 == 2:
                flagship = FlagShip(self.extraRock0, game.stats.EXTRA_BASE,
                                    AiCaptain(self.extraRock0), x, y, 0, 0,
                                    0.0, 0.0, 0.0, 0)
                for k, t in enumerate(flagship.turrets):
                    t.install = TurretInstall(game.stats.T_LARVA_0)
                    t.weapon = MissileWeaponTurret(game.stats.W_LARVA_0)
                    t.ai = AiWeaponTurret()
            else:
                flagship = FlagShip(self.extraRock0, game.stats.EXTRA_FS_2,
                                    AiCaptain(self.extraRock0), x, y, 0, 0,
                                    0.0, 0.0, 0.0, 0)
                for i in xrange(8):
                    fighter = ShipSingleWeapon(self.extraRock0,
                                               game.stats.EXTRA_FIGHTER,
                                               AiPilotFighter(flagship), 0, 0,
                                               0, 4, 0.0, 0.0, 0.0, 0)
                    flagship.shipyards[fighter.stats.img].docked.append(
                        fighter)

            flagship.ore = flagship.stats.maxOre

            game.objects.append(flagship)
            self.extraRock0.flagships.append(flagship)
            flagship.missiles[ids.M_LARVA].amount = 100

        for i in xrange(16):
            self.addRandomExtra(game)
Пример #8
0
    def __init__( self, game ):
        self.player = None

        self.harvestersAtSpawn = 4
        self.wantedBadGuys = 9

        steps = [
            Step( 
                goal=lambda self, game: not filter( lambda ship: ship.alive, self.ennemyShips ),
                onBegin=lambda self, game: self.addExtrasInFields( game, count=self.wantedBadGuys ),
                failure=lambda self, game: False,
                texts = [ (config.fps*10,"You are at the Human outpost over Gamma 1."),
                          (config.fps*20,"There is hostile life forms in the system."),
                          (config.fps*30,"Clear the asteroids fields above the star Gamma.") ] ),
            Step( 
                goal=lambda self, game: not filter( lambda ship: ship.alive, self.ennemyShips ),
                onBegin=lambda self, game: self.addAttackingExtras( game, count=self.wantedBadGuys ),
                failure=lambda self, game: False,
                texts = [ (0,"The human outpost above Gamma 1 is under attack!"),
                          (config.fps*10,"Jump to their help in 10s..."),
                          (config.fps*17,"3s"),
                          (config.fps*18,"2s"),
                          (config.fps*19,"1s"),
                          (config.fps*20,"Jump!") ] ),
            Step( 
                goal=lambda self, game: game.tick - 20*config.fps >= self.lastStepAt,
                onBegin=lambda self, game: False,
                failure=lambda self, game: False,
                texts = [ (0,"The alien's attack has been succesfully repelled!"),
                          (config.fps*10,"Congratulations ;)") ] )
                 ]


        
        Scenario.__init__(self, game, steps=steps )

        self.ennemyShips = []

        self.gamma = [Sun( game.stats.S_SOL, 1000, 4000 ),
                 Planet( game.stats.P_MERCURY_1, 0, -2200 ),
                 Planet( game.stats.P_X_1, -1000, 11500 ) ]
        for i in range( 20 ): # asteroids around self.gamma[1]
            dist = 750
            angle = 2*pi*random()
            asteroid = Asteroid( game, self.gamma[1].xp+dist*cos(angle), self.gamma[1].yp+dist*sin(angle), 80 )
            game.harvestables.append( asteroid )
        for i in range( 100 ): # asteroids around self.gamma
            area = choice( [(7000, 300, 5*pi/8, pi/9), (10000, 400, 6*pi/8, pi/8), (12000, 500, 5*pi/8, pi/11) ] ) # , 3000
            dist = area[0] #randint( area[0]-area[1], area[0]+area[1] )
            angle = area[2]+area[3]*(1-2*random())
            asteroid = Asteroid( game, self.gamma[0].xp+dist*cos(angle), self.gamma[0].yp+dist*sin(angle), area[1] )
            game.harvestables.append( asteroid )

        for i in xrange( 10 ): # civilians around self.gamma[1]
            dist = randint( 100, 800 )
            angle = 2*pi*random()

            (x,y) = (self.gamma[1].xp+dist*cos(angle), self.gamma[1].yp+dist*sin(angle))
            s = Ship( game.stats.CIVILIAN_0, AiCivilian(), x, y, -20 )
            game.objects.append( s )



        game.astres = self.gamma




       # for i in range( 5 ):
       #     self.addExtrasInFields( game )

        spots = []
        for o in game.astres:
          if isinstance( o, Planet ) and not isinstance( o, Sun ):
            spots.append( o )

        for i in xrange( 30 ): # random civilians
            spot = choice( spots )
            dist = randint( 100, 800 )
            angle = 2*pi*random()

            (x,y) = (spot.xp+dist*cos(angle), spot.yp+dist*sin(angle))
            s = Ship( game.stats.CIVILIAN_0, AiCivilian(), x, y, -20 )
            game.objects.append( s )


        self.humanDefense = Faction( game.stats.R_HUMAN, "Human Defenses" )
        nbrBases = 3
        for i in xrange( nbrBases ):
          dist =  self.gamma[1].stats.maxRadius*1.8 #(1.8+0.4*random())
          angle = pi*i*2/nbrBases
          obase = OrbitalBase( self.humanDefense, game.stats.HUMAN_BASE, AiGovernor( self.humanDefense ),self.gamma[1].xp+dist*cos(angle),self.gamma[1].yp+dist*sin(angle),0, 0, 0.0,0.0,0.0, 0)
          for t in obase.turrets:
            if i%2==0:    
              t.install = TurretInstall( game.stats.T_MASS_SR_1 )
              t.weapon = MassWeaponTurret( game.stats.W_MASS_SR_1 )
            else:
              t.install = TurretInstall( game.stats.T_MASS_MR_1 )
              t.weapon = MassWeaponTurret( game.stats.W_MASS_MR )
            t.ai = AiWeaponTurret()
          obase.ori = angle+pi/2
          obase.orbiting = self.gamma[1]
          obase.xi = cos( obase.ori)
          obase.yi = sin( obase.ori)
          obase.ore = obase.stats.maxOre
          obase.ri = -0.008
          game.objects.append( obase )
          self.humanDefense.bases.append( obase )

        for i in xrange( 10 ):
            radius = self.gamma[1].stats.maxRadius*(2.5)
            dist = self.gamma[1].stats.maxRadius*(1.5+1*random())
            angle = 2*pi*random() # AiPilotDefense
            fighter = ShipSingleWeapon(self.humanDefense, game.stats.HUMAN_FIGHTER, AiPilotPolice(self.gamma[1],radius),self.gamma[1].xp+dist*cos(angle),self.gamma[1].yp+dist*sin(angle),0, 4, 0.0,0.0,0.0, 0)
            game.objects.append( fighter )
            self.humanDefense.ships.append( fighter )

       # self.humanDefense.bases.append( obase )
        game.addPlayer( self.humanDefense )


      ## Extra
        self.extraRock0 = Faction( game.stats.R_EXTRA, "Rocks" )
        game.addPlayer( self.extraRock0 )
Пример #9
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
    
        stats = Stats()
        stats.R_HUMAN.turrets = [ stats.T_SOLAR_0 ]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = []
        stats.PlayableShips = {}
        
        steps = [
            Step( 
                goal=lambda self, game: game.tick-9*config.fps>=self.lastStepAt and self.player.inputs.xc and not utils.distLowerThan( (self.player.inputs.xc+self.player.inputs.wc/2, self.player.inputs.yc+self.player.inputs.hc/2 ), self.player.flagship.pos, 200 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Look around your ship a bit.")),
    (config.fps*3, _("To move the camera, either use the arrow keys...")),
    (config.fps*6, _("or click on the radar in the upper left corner."))] ),
            Step( 
                goal=lambda self, game: game.tick-6*config.fps>=self.lastStepAt and utils.distLowerThan( (self.player.inputs.xc+self.player.inputs.wc/2, self.player.inputs.yc+self.player.inputs.hc/2 ), self.player.flagship.pos, 2 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Good, now stick the camera to your ship.")),
    (config.fps*3, _("To do so, click on the center of the radar.")),] ),
            Step( 
                goal=lambda self, game:  game.tick-9*config.fps>=self.lastStepAt and not utils.distLowerThan( self.startingPoint, self.player.flagship.pos, 100 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Now move away from the orbital station.")),
      (3*config.fps, _("To move the ship, left-click on the destination and your crew will manoeuver towards there.") ),
      (6*config.fps, _("To give the order to stop, left-click on the ship.") ) ] ),
            Step( 
                goal=lambda self, game: filter( lambda turret: turret.building==stats.T_SOLAR_0, self.player.flagship.turrets ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Let's prepare ourselves before going out to explore.")),
          (3*config.fps, _("Jumping uses a lot of energy, so first build 2 solar arrays on your ship.") ),
          (6*config.fps, _("To do so, left-click on one of the black circle at the right of the screen.") ),           
          (9*config.fps, _("Then select the solar array from the list.") ) ] ),
            Step( 
                goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_SOLAR_0, self.player.flagship.turrets ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Well done, it will take a little while for it to be completed.")),
                          (3*config.fps, _("Begin building the second one right away.") ),
                          (9*config.fps, _("Notice the green bar in the top right corner...") ),
                          (12*config.fps, _("it indicates the proportion of energy in your battery.") ),
                          (15*config.fps, _("The quantity is indicated in green text next to it..") ) ] ),
            Step( 
                goal=lambda self, game: len(filter( lambda turret: turret.install and turret.install.stats==stats.T_SOLAR_0, self.player.flagship.turrets ) ) >= 2 and game.tick-6*config.fps>=self.lastStepAt,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Every ship benefits from solar energy the closer they are to a sun.") ),
                    (3*config.fps,_("A solar array will capture even more solar energy but will consume a little when in deep space.") ) ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("We still need to fill the battery before jumping.")),
                          (3*config.fps, _("Use the long-range sensor in fullscreen mode to see our destination.") ),
                          (6*config.fps, _("Left-click on the Radar button in the upper-left corner.") ),
                          (12*config.fps, _("Notice your poition over Earth. It will be useful to come back.") ),
                          (15*config.fps, _("Mars is the 4th planet from the sun.") ),
                          (18*config.fps, _("You can see it on the right of the asteroid field down left from you.")),
                          (21*config.fps, _("To execute the jump, left-click on the blue button at the top of the screen") ),
                          (24*config.fps, _("the left-click on the destination, the planet Mars.") ), ] ),
            Step( 
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                onBegin=lambda self, game: self.addEnnemyShip( game, self.ennemyPosition ),
                texts = [ ( 0, _("Know that you can change the destination of the jump while it charges.") ),
                          (3*config.fps, _("Go back to normal view by clicking on the radar button again.") ), ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThan( self.ennemyPosition, self.player.flagship.pos, 500 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( config.fps, _("Now head for the asteroid field.") ),
                    ( 4*config.fps, _("Reports are that there is a anormal rotating asteroid towards the bottom of the field.") ),
                    ( 7*config.fps, _("Investigate it.") ) ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThan( self.ennemyPosition, self.player.flagship.pos, 200 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 0, _("It may be dangerous but get closer to gather data.") ) ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 0, _("What ever it is. It is hostile!") ),
                    ( 1*config.fps, _("Enough data collected.") ),
                    ( 2*config.fps, _("Jump away now!") ) ] ),
            Step( 
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 0, _("Don't worry, your shield and hull should be able to handle the hits for a little longer.") ) ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.orbitalbase, 2000 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 1, _("Head back to Earth.") ) ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.orbitalbase, 100 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, _("Return to the orbital station.")),
                    ( 3*config.fps, _("Collected data will be useful if they ever try to get closer to Earth.") ) ] ),
                ]
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
        
        ### redefining stats, dangerous
        
        self.sol = Sun( game.stats.S_SOL, 0, 0 )
        self.mercury = Planet( game.stats.P_MERCURY, -4100, 1400 )
        self.venus = Planet( game.stats.P_VENUS, 5000, 2300 )
        self.earth = Planet( game.stats.P_EARTH, -3100, 6700 )
        self.mars = Planet( game.stats.P_MARS_1, -7800, -2300 )
        self.moon = Planet( game.stats.P_MOON, -3900, 6400 )
        self.jupiter = Planet( game.stats.P_JUPITER, -13000, -4800 )
        self.saturn = Planet( game.stats.P_SATURN, 13000, 2500 )
        self.neptune = Planet( game.stats.P_NEPTUNE, 15000, 7000 )
        
        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth
        

        for i in range( 50 ): # asteroids outer self.mars
            dist = 9000
            angle = (1-2*random())*pi/8+pi*9/8
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )

        for i in range( 60 ): # asteroids between self.saturn and self.neptune
            dist = 15000
            angle = (1-2*random())*pi/10+pi/7
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )
            
        game.astres = [self.sol, self.mercury, self.venus, self.earth, self.moon, self.mars, self.jupiter, self.saturn, self.neptune, self.moon ]
        
        dist = self.earth.stats.maxRadius*1.5
        angle = 5*pi/8
        self.orbitalbase = OrbitalBase( None, game.stats.HUMAN_BASE_MINING, None, self.earth.xp+dist*cos(angle),self.earth.yp+dist*sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append( self.orbitalbase )
        
        self.player = None
        self.startingPoint = ( self.orbitalbase.xp+50, self.orbitalbase.yp+60 )
        
        dist = 9000
        angle = pi*9/8+pi/8*2/3
        self.ennemyPosition = ( self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle) )
Пример #10
0
    def __init__( self, game ):
        Scenario.__init__(self, game )

        self.harvestersAtSpawn = 4
        self.wantedBadGuys = 5

        sol = Sun( game.stats.S_SOL, 0, 0 )
        mercury = Planet( game.stats.P_MERCURY, -4100, 1400 )
        venus = Planet( game.stats.P_VENUS, 5000, 2200 )
        self.earth = Planet( game.stats.P_EARTH, -3100, 6700 )
        self.mars = Planet( game.stats.P_MARS, -7800, -2200 )
        moon = Planet( game.stats.P_MOON, -3900, 6400 )
        jupiter = Planet( game.stats.P_JUPITER, -12000, -4800 )
        saturn = Planet( game.stats.P_SATURN, 13000, 2500 )
        neptune = Planet( game.stats.P_NEPTUNE, 15000, 7000 )

        moon.zp = -50
        moon.yi = 0.1
        moon.orbiting = self.earth

        for i in xrange( 20 ): # civilians around self.earth
            dist = randint( 100, 800 )
            angle = 2*pi*random()

            (x,y) = (self.earth.xp+dist*cos(angle), self.earth.yp+dist*sin(angle))
            s = Ship( game.stats.CIVILIAN_0, AiCivilian(), x, y, -20 )
            game.objects.append( s )

        for i in range( 60 ): # asteroids between saturn and neptune
            dist = 15000
            angle = (1-2*random())*pi/10+pi/7
            asteroid = Asteroid( game, sol.xp+dist*cos(angle), sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )

        for i in range( 30 ): # asteroids outer self.mars
            dist = 9000
            angle = (1-2*random())*pi/8+pi*9/8
            asteroid = Asteroid( game, sol.xp+dist*cos(angle), sol.yp+dist*sin(angle), 200 )
            game.harvestables.append( asteroid )


        nebula = Nebula( game.stats.A_NEBULA, 4800, 500 )
        for i in range( 15 ): # asteroids in nebula
            asteroid = Asteroid( game, 4800, 800, 800 )
            game.harvestables.append( asteroid )


        self.alphaCentaury = [ Sun( game.stats.S_SOL, -32000, 16000 ),
                          Planet( game.stats.P_MARS_2, -28300, 12000 ),
                          Planet( game.stats.P_SATURN_1, -39000, 8000 ) ]
        for i in range( 40 ): # asteroids around self.alphaCentaury
            dist = 4600
            #angle = 2*pi*i/50
            angle = (1-2*random())*pi/4-pi/8
            asteroid = Asteroid( game, self.alphaCentaury[0].xp+dist*cos(angle), self.alphaCentaury[0].yp+dist*sin(angle), 200 )
            game.harvestables.append( asteroid )


        self.beta = [ Sun( game.stats.S_SOL, 8000, -24000 ),
                 Planet( game.stats.P_MARS_1, 12000, -22000 ),
                 Planet( game.stats.P_X, 500, -21000 ) ,
                 Planet( game.stats.P_JUPITER_1, 17000, -24700 )]
        for i in range( 20 ): # asteroids around self.beta[1]
            dist = 600
            angle = 2*pi*random()
            asteroid = Asteroid( game, self.beta[1].xp+dist*cos(angle), self.beta[1].yp+dist*sin(angle), 80 )
            game.harvestables.append( asteroid )

        self.gamma = [Sun( game.stats.S_SOL, 40000, 4000 ),
                 Planet( game.stats.P_MERCURY_1, 39000, -2200 ),
                 Planet( game.stats.P_X_1, 38000, 11500 ) ]
        for i in range( 20 ): # asteroids around self.gamma[1]
            dist = 750
            angle = 2*pi*random()
            asteroid = Asteroid( game, self.gamma[1].xp+dist*cos(angle), self.gamma[1].yp+dist*sin(angle), 80 )
            game.harvestables.append( asteroid )
        for i in range( 100 ): # asteroids around self.gamma
            area = choice( [(7000, 300, 5*pi/8, pi/9), (10000, 400, 6*pi/8, pi/8), (12000, 500, 5*pi/8, pi/11) ] ) # , 3000
            dist = area[0] #randint( area[0]-area[1], area[0]+area[1] )
            angle = area[2]+area[3]*(1-2*random())
            asteroid = Asteroid( game, self.gamma[0].xp+dist*cos(angle), self.gamma[0].yp+dist*sin(angle), area[1] )
            game.harvestables.append( asteroid )

        nebula2 = Nebula( game.stats.A_NEBULA, 8000, -16000 )

        blackHole0 = BlackHole( game.stats.BH_0, -30000, -20000 )


#        for i in range( 15 ):
 #           asteroid = Asteroid( game, -7000, -3200, 800 )
 #           game.objects.append( asteroid )

  #      for i in range( 15 ):
   #         asteroid = Asteroid( game, 8500, 6800, 800 )
     #       game.objects.append( asteroid )
        self.sol = [sol, mercury, venus, self.earth, moon, self.mars, jupiter, saturn, neptune, nebula, nebula2 ]
        game.astres = [sol, mercury, venus, self.earth, moon, self.mars, jupiter, saturn, neptune, nebula, nebula2, blackHole0 ] + self.alphaCentaury + self.beta + self.gamma
     #   game.objects = game.objects #  + [sol, mercury, venus, self.earth, moon, self.mars, jupiter, saturn, neptune, nebula, nebula2 ] + self.alphaCentaury + self.beta

        for i in range( 5 ):
            self.addRandomNpc( game )

        spots = []
        for o in game.astres:
          if isinstance( o, Planet ) and not isinstance( o, Sun ):
            spots.append( o )

        for i in xrange( 30 ): # random civilians
            spot = choice( spots )
            dist = randint( 100, 800 )
            angle = 2*pi*random()

            (x,y) = (spot.xp+dist*cos(angle), spot.yp+dist*sin(angle))
            s = Ship( game.stats.CIVILIAN_0, AiCivilian(), x, y, -20 )
            game.objects.append( s )



        self.marsDefense = Faction( game.stats.R_HUMAN, "Mars Defenses" )
        obase = OrbitalBase( self.marsDefense, game.stats.HUMAN_BASE, AiGovernor( self.marsDefense ),self.mars.xp+self.mars.stats.maxRadius*1.5,self.mars.yp+self.mars.stats.maxRadius*1.5,0, 0, 0.0,0.0,0.0, 0)
        for t in obase.turrets:
            t.install = TurretInstall( game.stats.T_MASS_SR_0 )
            t.weapon = MassWeaponTurret( game.stats.W_MASS_SR_0 )
            t.ai = AiWeaponTurret()
        obase.orbiting = self.mars
        obase.yi = 1
        obase.ore = obase.stats.maxOre
        obase.ri = -0.008
        game.objects.append( obase )

        for i in xrange( 20 ):
            radius = self.mars.stats.maxRadius*(2.5)
            dist = self.mars.stats.maxRadius*(1.5+1*random())
            angle = 2*pi*random() # AiPilotDefense
            fighter = ShipSingleWeapon(self.marsDefense, game.stats.HUMAN_FIGHTER, AiPilotDefense(self.mars,radius),self.mars.xp+dist*cos(angle),self.mars.yp+dist*sin(angle),0, 4, 0.0,0.0,0.0, 0)
            game.objects.append( fighter )
            self.marsDefense.ships.append( fighter )

        self.marsDefense.bases.append( obase )
        game.addPlayer( self.marsDefense )


        self.earthDefense = Faction( game.stats.R_HUMAN, "Earth Defenses" )
        nbrBases = 3
        for i in xrange( nbrBases ):
          dist = self.earth.stats.maxRadius*1.8 #(1.8+0.4*random())
          angle = pi*i*2/nbrBases
          obase = OrbitalBase( self.earthDefense, game.stats.HUMAN_BASE, AiGovernor( self.earthDefense ),self.earth.xp+dist*cos(angle),self.earth.yp+dist*sin(angle),0, 0, 0.0,0.0,0.0, 0)
          for t in obase.turrets:
            t.install = TurretInstall( game.stats.T_MASS_MR_0 )
            t.weapon = MassWeaponTurret( game.stats.W_MASS_MR )
            t.ai = AiWeaponTurret()
          obase.ori = angle+pi/2
          obase.orbiting = self.earth
          obase.xi = cos( obase.ori)
          obase.yi = sin( obase.ori)
          obase.ore = obase.stats.maxOre
          obase.ri = -0.008
          game.objects.append( obase )
          self.earthDefense.bases.append( obase )

        for i in xrange( 20 ):
            radius = self.earth.stats.maxRadius*(2.5)
            dist = self.earth.stats.maxRadius*(1.5+1*random())
            angle = 2*pi*random() # AiPilotDefense
            fighter = ShipSingleWeapon(self.earthDefense, game.stats.HUMAN_FIGHTER, AiPilotPolice(self.earth,radius),self.earth.xp+dist*cos(angle),self.earth.yp+dist*sin(angle),0, 4, 0.0,0.0,0.0, 0)
            game.objects.append( fighter )
            self.earthDefense.ships.append( fighter )

       # self.earthDefense.bases.append( obase )
        game.addPlayer( self.earthDefense )

       ## ai forces
        self.addAiBase( game, "Neptune base", neptune )
        self.addAiBase( game, "Saturn base", saturn )
        self.addAiBase( game, "Jupiter base", jupiter, 2 )


       ## Evolved
        self.evolvedSwarm0 = Faction( game.stats.R_EVOLVED, "First Swarm", territories=[Territory((self.alphaCentaury[ 1 ].xp, self.alphaCentaury[ 1 ].yp), 500), Territory((self.alphaCentaury[ 1 ].xp-1000, self.alphaCentaury[ 1 ].yp-500), 500)] )

        (x,y) = self.alphaCentaury[ 1 ].xp-self.alphaCentaury[ 1 ].stats.maxRadius*1.5,self.alphaCentaury[ 1 ].yp+self.alphaCentaury[ 1 ].stats.maxRadius*1.5
        flagship = FlagShip( self.evolvedSwarm0, game.stats.EVOLVED_FS_1, AiCaptain( self.evolvedSwarm0 ),x,y,0, 0, 0.0,0.0,0.0, 0)
        flagship.ore = flagship.stats.maxOre
        for t in flagship.turrets[:-2]:
            t.install = TurretInstall( game.stats.T_MASS_MR_0 )
            t.weapon = MassWeaponTurret( game.stats.W_MASS_MR )
            t.ai = AiWeaponTurret()
        for t in flagship.turrets[-2:]:
            t.install = TurretInstall( game.stats.T_LASER_SR_0 )
            t.weapon = LaserWeaponTurret( game.stats.W_LASER_SR )
            t.ai = AiWeaponTurret()
        for i in range(4):
           harvester = HarvesterShip(self.evolvedSwarm0, self.evolvedSwarm0.race.defaultHarvester, AiPilotHarvester(flagship), 0,0,0, 4, 0.0,0.0,0.0, 0)
           flagship.shipyards[ harvester.stats.img ].docked.append( harvester )

        for i in xrange( 5 ):
            if i>=3:
                fighter = ShipSingleWeapon(self.evolvedSwarm0, game.stats.EVOLVED_BOMBER, AiPilotFighter(flagship),0,0,0, 4, 0.0,0.0,0.0, 0)
            else:
                fighter = ShipSingleWeapon(self.evolvedSwarm0, game.stats.EVOLVED_FIGHTER, AiPilotFighter(flagship),0,0,0, 4, 0.0,0.0,0.0, 0)

        for i in xrange( 10 ):
            fighter = ShipSingleWeapon(self.evolvedSwarm0, game.stats.EVOLVED_FIGHTER, AiPilotDefense(flagship, 500),0,0,0, 4, 0.0,0.0,0.0, 0)
            (fighter.xp,fighter.yp) = (flagship.xp,flagship.yp)
            game.objects.append( fighter )
            self.evolvedSwarm0.ships.append( fighter )
        #    flagship.shipyards[ fighter.stats.img ].docked.append( fighter )
        game.objects.append( flagship )
        self.evolvedSwarm0.flagships.append( flagship )
        game.addPlayer( self.evolvedSwarm0 )


      ## Extra TODO remove section
        self.extraRock0 = Faction( game.stats.R_EXTRA, "Rocks" )
        for i in xrange( 0 ): # 4 ):
          angle = 2*pi*random()
          dist = 750 # self.gamma[ 1 ].stats.maxRadius*
          (x,y) = self.gamma[ 1 ].xp-dist*cos(angle),self.gamma[ 1 ].yp+dist*sin(angle)

          if i%4==0:
              flagship = FlagShip( self.extraRock0, game.stats.EXTRA_BASE, AiCaptain( self.extraRock0 ),x,y,0, 0, 0.0,0.0,0.0, 0)
              for k,t in enumerate(flagship.turrets):
                  t.install = TurretInstall( game.stats.T_ROCK_THROWER_1 )
                  t.weapon = MassWeaponTurret( game.stats.W_ROCK_THROWER_1 )
                  t.ai = AiWeaponTurret()
          elif i%4==1:
              flagship = FlagShip( self.extraRock0, game.stats.EXTRA_FS_1, AiCaptain( self.extraRock0 ),x,y,0, 0, 0.0,0.0,0.0, 0)
              for k,t in enumerate(flagship.turrets):
                  t.install = TurretInstall( game.stats.T_DRAGON_0 )
                  t.weapon = MassWeaponTurret( game.stats.W_DRAGON_0 )
                  t.ai = AiWeaponTurret()
          elif i%4==2:
              flagship = FlagShip( self.extraRock0, game.stats.EXTRA_BASE, AiCaptain( self.extraRock0 ),x,y,0, 0, 0.0,0.0,0.0, 0)
              for k,t in enumerate(flagship.turrets):
                  t.install = TurretInstall( game.stats.T_LARVA_0 )
                  t.weapon = MissileWeaponTurret( game.stats.W_LARVA_0 )
                  t.ai = AiWeaponTurret()
          else:
              flagship = FlagShip( self.extraRock0, game.stats.EXTRA_FS_2, AiCaptain( self.extraRock0 ),x,y,0, 0, 0.0,0.0,0.0, 0)
              for i in xrange( 8 ):
                  fighter = ShipSingleWeapon(self.extraRock0, game.stats.EXTRA_FIGHTER, AiPilotFighter(flagship),0,0,0, 4, 0.0,0.0,0.0, 0)
                  flagship.shipyards[ fighter.stats.img ].docked.append( fighter )

          flagship.ore = flagship.stats.maxOre

          game.objects.append( flagship )
          self.extraRock0.flagships.append( flagship )
          flagship.missiles[ ids.M_LARVA ].amount = 100

        for i in xrange( 16 ):
          self.addRandomExtra( game )
Пример #11
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):

        stats = Stats()
        stats.R_HUMAN.turrets = [
            stats.T_LASER_SR_1, stats.T_LASER_SR_0, stats.T_MASS_SR_1,
            stats.T_MASS_SR_0, stats.T_MASS_MR_0
        ]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = [stats.HARVESTER]
        stats.PlayableShips = {}

        steps = [
            Step(
                goal=lambda self, game: utils.distLowerThanObjects(
                    self.player.flagship, self.asteroid, 300),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                #   onBegin=lambda self, game: self.player.flagship.ore = 500,
                texts=[(0, "We need some materials."),
                       (4 * config.fps,
                        "There is an asteroid close to the Moon."),
                       (8 * config.fps, "Get close to it.")]),
            Step(
                goal=lambda self, game: self.player.flagship.ai.launching[
                    self.player.race.defaultHarvester.img],
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, "Begin collecting raw ore."),
                 (4 * config.fps,
                  "To do so, launch your harvester by pressing the blue arrow button at the bottom of the screen."
                  )]),
            Step(
                goal=lambda self, game: self.player.flagship.oreProcess,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, "Now wait for them to bring back the ore."),
                 (6 * config.fps,
                  "Don't worry about the ships following you around."),
                 (10 * config.fps,
                  "They are civilian and while they are under your protection they speed up building processes."
                  )]),
            Step(
                goal=lambda self, game: self.player.flagship.ore >= 100,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=[
                    (0,
                     "They have now added the raw ore to the processing queue."
                     ),
                    (4 * config.fps,
                     "Wait a little while and it will be transformed into usable materials."
                     ),
                    (8 * config.fps,
                     "Keep harvesting and processing the ore until you reach 100 material."
                     ),
                    (12 * config.fps,
                     "Notice the moving bars at the bottom right corner of the screen..."
                     ),
                    (14 * config.fps,
                     "they represents the ore being processed."),
                    (18 * config.fps,
                     "once they reach the right, they are usable!"),
                    (22 * config.fps,
                     "They will then be added to the ore stock indicated by the blue gage in the bottom right corner."
                     ),
                ]),
            Step(
                goal=lambda self, game: self.player.flagship.shipyards[
                    self.player.race.defaultHarvester.img].getCount() >= 4,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  "You now have enough material to build a new harvester and speed it up!"
                  ),
                 (2 * config.fps,
                  "To do so, click on the icon of the harvester at the bottom of the screen, under the launch button."
                  )]),
            Step(
                goal=lambda self, game: self.player.flagship.ore >= 300,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  "Keep harvesting and processing ore util you reach 300 material."
                  ),
                 (4 * config.fps,
                  "It will follow the orders the others already received."),
                 (8 * config.fps,
                  "Notice the blue bar in the upper right corner and the green one in the bottm right..."
                  ),
                 (12 * config.fps,
                  "the blue one represents your shield and the green one your hull."
                  )]),
            Step(
                goal=lambda self, game: len(
                    filter(lambda turret: turret.install, self.player.flagship.
                           turrets)) >= 3,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=[
                    (0, "There are rumors of pirates in the area."),
                    (4 * config.fps,
                     "Build one more mass cannon turret on your ship."),
                    (8 * config.fps,
                     "To do so, click on an empty slot on the right of the screen and select an affordable turret."
                     ),
                ]),
            Step(
                goal=lambda self, game: not self.ennemyShip.alive,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                onBegin=lambda self, game: (self.addAttackingEnnemy(
                    game, (self.moon.xp - 1500, self.moon.yp
                           - 800), self.player.flagship, "Pirate lambda"
                ), game.setRelationBetween(self.player, self.ennemy, 1)),
                texts=
                [(0, "Defend yourself from the incoming pirate ship."),
                 (4 * config.fps,
                  "To attack it, simply left-click on it once."),
                 (8 * config.fps,
                  "Your crew will aim and fire the turrets."),
                 (12 * config.fps,
                  "You can still help them by manoeuvering the ship so that the ennemy is in range of the turrets."
                  )]),
            Step(goal=lambda self, game: utils.distLowerThanObjects(
                self.player.flagship, self.orbitalbase, 100),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0, "Well done!"),
                     (2 * config.fps,
                      "Recall your harvester and return to the orbital base.")
                 ]),
        ]

        Scenario.__init__(self, game, steps=steps, stats=stats)

        ### redefining stats, dangerous

        self.sol = Sun(game.stats.S_SOL, 0, 0)
        self.mercury = Planet(game.stats.P_MERCURY, -4100, 1400)
        self.venus = Planet(game.stats.P_VENUS, 5000, 2300)
        self.earth = Planet(game.stats.P_EARTH, -3100, 6700)
        self.mars = Planet(game.stats.P_MARS_1, -7800, -2300)
        self.moon = Planet(game.stats.P_MOON, -3900, 6400)
        self.jupiter = Planet(game.stats.P_JUPITER, -13000, -4800)
        self.saturn = Planet(game.stats.P_SATURN, 13000, 2500)
        self.neptune = Planet(game.stats.P_NEPTUNE, 15000, 7000)

        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth

        # asteroids over the moon, vital to scenario
        for i in xrange(1):
            self.asteroid = Asteroid(game, self.moon.xp - 200,
                                     self.moon.yp + 150, 10)
            game.harvestables.append(self.asteroid)

        for i in xrange(3):  # civilians around self.earth
            dist = randint(100, 800)
            angle = 2 * pi * random()

            (x, y) = (self.earth.xp + dist * cos(angle),
                      self.earth.yp + dist * sin(angle))
            s = Ship(game.stats.CIVILIAN_0, AiCivilian(), x, y, -20)
            game.objects.append(s)

        for i in range(50):  # asteroids outer self.mars
            dist = 9000
            angle = (1 - 2 * random()) * pi / 8 + pi * 9 / 8
            asteroid = Asteroid(game, self.sol.xp + dist * cos(angle),
                                self.sol.yp + dist * sin(angle), 300)
            game.harvestables.append(asteroid)

        game.astres = [
            self.sol, self.mercury, self.venus, self.earth, self.moon,
            self.mars, self.jupiter, self.saturn, self.neptune, self.moon
        ]

        dist = self.earth.stats.maxRadius * 1.5
        angle = 5 * pi / 8
        self.orbitalbase = OrbitalBase(None, game.stats.HUMAN_BASE_MINING,
                                       None, self.earth.xp + dist * cos(angle),
                                       self.earth.yp + dist * sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append(self.orbitalbase)

        self.player = None
Пример #12
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):

        stats = Stats()
        stats.R_HUMAN.turrets = [stats.T_SOLAR_0]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = []
        stats.PlayableShips = {}

        steps = [
            Step(goal=lambda self, game: game.tick - 9 * config.fps >= self.
                 lastStepAt and self.player.inputs.xc and not utils.
                 distLowerThan((self.player.inputs.xc + self.player.inputs.wc /
                                2, self.player.inputs.yc + self.player.inputs.
                                hc / 2), self.player.flagship.pos, 200),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0, _("Look around your ship a bit.")),
                     (config.fps * 3,
                      _("To move the camera, either use the arrow keys...")),
                     (config.fps * 6,
                      _("or click on the radar in the upper left corner."))
                 ]),
            Step(goal=lambda self, game: game.tick - 6 * config.fps >= self.
                 lastStepAt and utils.distLowerThan(
                     (self.player.inputs.xc + self.player.inputs.wc / 2, self.
                      player.inputs.yc + self.player.inputs.hc / 2), self.
                     player.flagship.pos, 2),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0, _("Good, now stick the camera to your ship.")),
                     (config.fps * 3,
                      _("To do so, click on the center of the radar.")),
                 ]),
            Step(
                goal=lambda self, game: game.tick - 9 * config.fps >= self.
                lastStepAt and not utils.distLowerThan(
                    self.startingPoint, self.player.flagship.pos, 100),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, _("Now move away from the orbital station.")),
                 (3 * config.fps,
                  _("To move the ship, left-click on the destination and your crew will manoeuver towards there."
                    )),
                 (6 * config.fps,
                  _("To give the order to stop, left-click on the ship."))]),
            Step(
                goal=lambda self, game: filter(
                    lambda turret: turret.building == stats.T_SOLAR_0, self.
                    player.flagship.turrets),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Let's prepare ourselves before going out to explore.")),
                 (3 * config.fps,
                  _("Jumping uses a lot of energy, so first build 2 solar arrays on your ship."
                    )),
                 (6 * config.fps,
                  _("To do so, left-click on one of the black circle at the right of the screen."
                    )),
                 (9 * config.fps,
                  _("Then select the solar array from the list."))]),
            Step(
                goal=lambda self, game: filter(
                    lambda turret: turret.install and turret.install.stats ==
                    stats.T_SOLAR_0, self.player.flagship.turrets),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Well done, it will take a little while for it to be completed."
                    )),
                 (3 * config.fps,
                  _("Begin building the second one right away.")),
                 (9 * config.fps,
                  _("Notice the green bar in the top right corner...")),
                 (12 * config.fps,
                  _("it indicates the proportion of energy in your battery.")),
                 (15 * config.fps,
                  _("The quantity is indicated in green text next to it.."))]),
            Step(
                goal=lambda self, game: len(
                    filter(
                        lambda turret: turret.install and turret.install.stats
                        == stats.T_SOLAR_0, self.player.flagship.turrets)
                ) >= 2 and game.tick - 6 * config.fps >= self.lastStepAt,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Every ship benefits from solar energy the closer they are to a sun."
                    )),
                 (3 * config.fps,
                  _("A solar array will capture even more solar energy but will consume a little when in deep space."
                    ))]),
            Step(
                goal=lambda self, game: self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=[
                    (0,
                     _("We still need to fill the battery before jumping.")),
                    (3 * config.fps,
                     _("Use the long-range sensor in fullscreen mode to see our destination."
                       )),
                    (6 * config.fps,
                     _("Left-click on the Radar button in the upper-left corner."
                       )),
                    (12 * config.fps,
                     _("Notice your poition over Earth. It will be useful to come back."
                       )),
                    (15 * config.fps,
                     _("Mars is the 4th planet from the sun.")),
                    (18 * config.fps,
                     _("You can see it on the right of the asteroid field down left from you."
                       )),
                    (21 * config.fps,
                     _("To execute the jump, left-click on the blue button at the top of the screen"
                       )),
                    (24 * config.fps,
                     _("the left-click on the destination, the planet Mars.")),
                ]),
            Step(
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                onBegin=lambda self, game: self.addEnnemyShip(
                    game, self.ennemyPosition),
                texts=[
                    (0,
                     _("Know that you can change the destination of the jump while it charges."
                       )),
                    (3 * config.fps,
                     _("Go back to normal view by clicking on the radar button again."
                       )),
                ]),
            Step(
                goal=lambda self, game: utils.distLowerThan(
                    self.ennemyPosition, self.player.flagship.pos, 500),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(config.fps, _("Now head for the asteroid field.")),
                 (4 * config.fps,
                  _("Reports are that there is a anormal rotating asteroid towards the bottom of the field."
                    )), (7 * config.fps, _("Investigate it."))]),
            Step(goal=lambda self, game: utils.distLowerThan(
                self.ennemyPosition, self.player.flagship.pos, 200),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0,
                      _("It may be dangerous but get closer to gather data."))
                 ]),
            Step(goal=lambda self, game: self.player.flagship.jumping,
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[(0, _("What ever it is. It is hostile!")),
                        (1 * config.fps, _("Enough data collected.")),
                        (2 * config.fps, _("Jump away now!"))]),
            Step(
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Don't worry, your shield and hull should be able to handle the hits for a little longer."
                    ))]),
            Step(goal=lambda self, game: utils.distLowerThanObjects(
                self.player.flagship, self.orbitalbase, 2000),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[(1, _("Head back to Earth."))]),
            Step(
                goal=lambda self, game: utils.distLowerThanObjects(
                    self.player.flagship, self.orbitalbase, 100),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, _("Return to the orbital station.")),
                 (3 * config.fps,
                  _("Collected data will be useful if they ever try to get closer to Earth."
                    ))]),
        ]

        Scenario.__init__(self, game, steps=steps, stats=stats)

        ### redefining stats, dangerous

        self.sol = Sun(game.stats.S_SOL, 0, 0)
        self.mercury = Planet(game.stats.P_MERCURY, -4100, 1400)
        self.venus = Planet(game.stats.P_VENUS, 5000, 2300)
        self.earth = Planet(game.stats.P_EARTH, -3100, 6700)
        self.mars = Planet(game.stats.P_MARS_1, -7800, -2300)
        self.moon = Planet(game.stats.P_MOON, -3900, 6400)
        self.jupiter = Planet(game.stats.P_JUPITER, -13000, -4800)
        self.saturn = Planet(game.stats.P_SATURN, 13000, 2500)
        self.neptune = Planet(game.stats.P_NEPTUNE, 15000, 7000)

        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth

        for i in range(50):  # asteroids outer self.mars
            dist = 9000
            angle = (1 - 2 * random()) * pi / 8 + pi * 9 / 8
            asteroid = Asteroid(game, self.sol.xp + dist * cos(angle),
                                self.sol.yp + dist * sin(angle), 300)
            game.harvestables.append(asteroid)

        for i in range(60):  # asteroids between self.saturn and self.neptune
            dist = 15000
            angle = (1 - 2 * random()) * pi / 10 + pi / 7
            asteroid = Asteroid(game, self.sol.xp + dist * cos(angle),
                                self.sol.yp + dist * sin(angle), 300)
            game.harvestables.append(asteroid)

        game.astres = [
            self.sol, self.mercury, self.venus, self.earth, self.moon,
            self.mars, self.jupiter, self.saturn, self.neptune, self.moon
        ]

        dist = self.earth.stats.maxRadius * 1.5
        angle = 5 * pi / 8
        self.orbitalbase = OrbitalBase(None, game.stats.HUMAN_BASE_MINING,
                                       None, self.earth.xp + dist * cos(angle),
                                       self.earth.yp + dist * sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append(self.orbitalbase)

        self.player = None
        self.startingPoint = (self.orbitalbase.xp + 50,
                              self.orbitalbase.yp + 60)

        dist = 9000
        angle = pi * 9 / 8 + pi / 8 * 2 / 3
        self.ennemyPosition = (self.sol.xp + dist * cos(angle),
                               self.sol.yp + dist * sin(angle))
Пример #13
0
    def __init__(self, game):
        self.player = None

        self.harvestersAtSpawn = 4
        self.wantedBadGuys = 9

        steps = [
            Step(goal=lambda self, game: not filter(lambda ship: ship.alive,
                                                    self.ennemyShips),
                 onBegin=lambda self, game: self.addExtrasInFields(
                     game, count=self.wantedBadGuys),
                 failure=lambda self, game: False,
                 texts=[(config.fps * 10,
                         "You are at the Human outpost over Gamma 1."),
                        (config.fps * 20,
                         "There is hostile life forms in the system."),
                        (config.fps * 30,
                         "Clear the asteroids fields above the star Gamma.")]),
            Step(goal=lambda self, game: not filter(lambda ship: ship.alive,
                                                    self.ennemyShips),
                 onBegin=lambda self, game: self.addAttackingExtras(
                     game, count=self.wantedBadGuys),
                 failure=lambda self, game: False,
                 texts=[
                     (0, "The human outpost above Gamma 1 is under attack!"),
                     (config.fps * 10, "Jump to their help in 10s..."),
                     (config.fps * 17, "3s"), (config.fps * 18, "2s"),
                     (config.fps * 19, "1s"), (config.fps * 20, "Jump!")
                 ]),
            Step(goal=lambda self, game: game.tick - 20 * config.fps >= self.
                 lastStepAt,
                 onBegin=lambda self, game: False,
                 failure=lambda self, game: False,
                 texts=[
                     (0, "The alien's attack has been succesfully repelled!"),
                     (config.fps * 10, "Congratulations ;)")
                 ])
        ]

        Scenario.__init__(self, game, steps=steps)

        self.ennemyShips = []

        self.gamma = [
            Sun(game.stats.S_SOL, 1000, 4000),
            Planet(game.stats.P_MERCURY_1, 0, -2200),
            Planet(game.stats.P_X_1, -1000, 11500)
        ]
        for i in range(20):  # asteroids around self.gamma[1]
            dist = 750
            angle = 2 * pi * random()
            asteroid = Asteroid(game, self.gamma[1].xp + dist * cos(angle),
                                self.gamma[1].yp + dist * sin(angle), 80)
            game.harvestables.append(asteroid)
        for i in range(100):  # asteroids around self.gamma
            area = choice([(7000, 300, 5 * pi / 8, pi / 9),
                           (10000, 400, 6 * pi / 8, pi / 8),
                           (12000, 500, 5 * pi / 8, pi / 11)])  # , 3000
            dist = area[0]  #randint( area[0]-area[1], area[0]+area[1] )
            angle = area[2] + area[3] * (1 - 2 * random())
            asteroid = Asteroid(game, self.gamma[0].xp + dist * cos(angle),
                                self.gamma[0].yp + dist * sin(angle), area[1])
            game.harvestables.append(asteroid)

        for i in xrange(10):  # civilians around self.gamma[1]
            dist = randint(100, 800)
            angle = 2 * pi * random()

            (x, y) = (self.gamma[1].xp + dist * cos(angle),
                      self.gamma[1].yp + dist * sin(angle))
            s = Ship(game.stats.CIVILIAN_0, AiCivilian(), x, y, -20)
            game.objects.append(s)

        game.astres = self.gamma

        # for i in range( 5 ):
        #     self.addExtrasInFields( game )

        spots = []
        for o in game.astres:
            if isinstance(o, Planet) and not isinstance(o, Sun):
                spots.append(o)

        for i in xrange(30):  # random civilians
            spot = choice(spots)
            dist = randint(100, 800)
            angle = 2 * pi * random()

            (x, y) = (spot.xp + dist * cos(angle), spot.yp + dist * sin(angle))
            s = Ship(game.stats.CIVILIAN_0, AiCivilian(), x, y, -20)
            game.objects.append(s)

        self.humanDefense = Faction(game.stats.R_HUMAN, "Human Defenses")
        nbrBases = 3
        for i in xrange(nbrBases):
            dist = self.gamma[1].stats.maxRadius * 1.8  #(1.8+0.4*random())
            angle = pi * i * 2 / nbrBases
            obase = OrbitalBase(self.humanDefense, game.stats.HUMAN_BASE,
                                AiGovernor(self.humanDefense),
                                self.gamma[1].xp + dist * cos(angle),
                                self.gamma[1].yp + dist * sin(angle), 0, 0,
                                0.0, 0.0, 0.0, 0)
            for t in obase.turrets:
                if i % 2 == 0:
                    t.install = TurretInstall(game.stats.T_MASS_SR_1)
                    t.weapon = MassWeaponTurret(game.stats.W_MASS_SR_1)
                else:
                    t.install = TurretInstall(game.stats.T_MASS_MR_1)
                    t.weapon = MassWeaponTurret(game.stats.W_MASS_MR)
                t.ai = AiWeaponTurret()
            obase.ori = angle + pi / 2
            obase.orbiting = self.gamma[1]
            obase.xi = cos(obase.ori)
            obase.yi = sin(obase.ori)
            obase.ore = obase.stats.maxOre
            obase.ri = -0.008
            game.objects.append(obase)
            self.humanDefense.bases.append(obase)

        for i in xrange(10):
            radius = self.gamma[1].stats.maxRadius * (2.5)
            dist = self.gamma[1].stats.maxRadius * (1.5 + 1 * random())
            angle = 2 * pi * random()  # AiPilotDefense
            fighter = ShipSingleWeapon(self.humanDefense,
                                       game.stats.HUMAN_FIGHTER,
                                       AiPilotPolice(self.gamma[1], radius),
                                       self.gamma[1].xp + dist * cos(angle),
                                       self.gamma[1].yp + dist * sin(angle), 0,
                                       4, 0.0, 0.0, 0.0, 0)
            game.objects.append(fighter)
            self.humanDefense.ships.append(fighter)

    # self.humanDefense.bases.append( obase )
        game.addPlayer(self.humanDefense)

        ## Extra
        self.extraRock0 = Faction(game.stats.R_EXTRA, "Rocks")
        game.addPlayer(self.extraRock0)
Пример #14
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
    
        stats = Stats()
        stats.R_HUMAN.turrets = [ stats.T_LASER_SR_1, stats.T_LASER_SR_0, stats.T_LASER_MR_0,
    stats.T_MASS_SR_1, stats.T_MASS_SR_0, stats.T_MASS_LR, stats.T_MASS_MR_0,
    stats.T_MISSILE_1, stats.T_MISSILE_0,
    stats.T_PULSE, stats.T_MINER, 
    stats.T_SOLAR_0,  ]
        stats.R_HUMAN.missiles = [ids.M_NORMAL, ids.M_PULSE, ids.M_MINER]
        stats.R_HUMAN.ships = [ stats.HARVESTER, stats.HUMAN_FIGHTER ]
        stats.PlayableShips = {}
        
        
        steps = []
        
        ### missiles
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_MISSILE_0, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: self.addEnnemyShip( game, (self.player.flagship.xp+stats.T_MASS_MR_0.weapon.maxRange+100, self.player.flagship.yp), None ),
            texts = [(0,"There's an ennemy ship on the other side of Earth, directly to your right."),
                (config.fps*4, "It is too far away to reach with your current weapons."),
                (config.fps*8, "Select an empty turret, on the right of the screen, and build a missile launcher."),
                (config.fps*16, "It would also be a good idea to begin harvesting the asteroid close by."),
                (config.fps*20, "Build more harvester if you feel that it's necessary." )] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.missiles[ids.M_NORMAL].amount >= 10,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0,"Now that the launcher is ready you will need some missiles!"),
                (config.fps*4, "Click on the missile icon at the botom of the screen to start building them."),
                (config.fps*8, "10 should be enough to initiate the combat.") ] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemyShip.alive,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            texts = [(0,"Now attack it!"),
                (config.fps*4, "It is the blue dot on the radar screen, left-click on it to begin the attack." ) ] ) )
            
        ### mass turret / upgrading
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_MASS_LR, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: self.addEnnemyShip( game, (self.player.flagship.xp+stats.T_MASS_LR.weapon.maxRange-400, self.player.flagship.yp), None ),
            texts = [(0,"One appeared even further away!"),
                (config.fps*4, "Upgrade at least one of your mass cannon to a mass driver turret." ) ] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemyShip.alive,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            text = "Now that you can reach it, attack it!" ) )
            
        ### fighters
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.shipyards[ ids.S_HUMAN_FIGHTER ].getCount() >= 5,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: self.addEnnemyShips( game, (self.player.flagship.xp+stats.T_MASS_LR.weapon.maxRange+1000, self.player.flagship.yp), 200, count=2 ),
            texts = [(0,"There's another one too far away for your turrets."),
            (config.fps*4, "You need to build at leats 5 fighters."),
            (config.fps*8, "To do so, click on the fighter icon, at the bottom of the screen next to the harvester." )] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.ai.launching[ ids.S_HUMAN_FIGHTER ],
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0,"Launch your fighters."),
            (config.fps*4, "To do so, press the blue arrow button at the bottom of the screen." )] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemy.flagships,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            text = "Now order your fighters to attack it by left-clicking on it." ) )
         
         ### mines
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_MINER, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0, "The pirates always come from the same direction."),
                (config.fps*4, "Let's think ahead and build a mine field."),
                (config.fps*8, "First, build a mine layer turret."),
                (config.fps*12, "It would be a good idea to recall your fighters before laying the mine field."),
                (config.fps*16, "To do so, press  onthe green arrow over the fighter icon." )] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.missiles[ids.M_MINER].amount >= 1,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "Build 8 or more miner missiles.\nThe button appeared next to the missile button." ) )
        steps.append( Step( 
            goal=lambda self, game: filter( lambda obj: isinstance( obj, MinerMissile ), game.objects.objects ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "A missile is ready.\nShoot it by clicking on the red targetting button over its icon.",
            texts= [
    (config.fps*4,"Then click on the target, in this case target at a little distance to the right of the station."),
    (config.fps*8,"You can always cancel the launch of a missile by right clicking on the screen when targetting.")
                    ] ) )
        steps.append( Step( 
            goal=lambda self, game: len( filter( lambda obj: isinstance( obj, Mine ), game.objects.objects ) ) >= stats.T_MINER.specialValue[1]*8,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "Build and deploy a total of at least 8 missiles." ) )
            
         ### pulse
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_PULSE, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
           onBegin=lambda self, game: self.addEnnemyShips( game, (self.player.flagship.xp+stats.T_MASS_LR.weapon.maxRange+200, self.player.flagship.yp), 200, count=4 ),
            texts = [(0, "A group of pirates can now be seen far away."),
            (config.fps*4, "To trap them and give us a head start let's hit them with an EMP weapon first!"),
            (config.fps*8, "Build a pulse launcher.") ] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.missiles[ids.M_PULSE].amount >= 1,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "Build at least one pulse missile." ) )
        steps.append( Step( 
            goal=lambda self, game: filter( lambda obj: isinstance( obj, PulseMissile ), game.objects.objects ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "A missile is ready.\nShoot it in the middle of the pirates." ) )
        steps.append( Step( 
            goal=lambda self, game: not filter( lambda obj: isinstance( obj, PulseMissile ), game.objects.objects ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            texts = [(0,"Wait for them to get hit."),
            (config.fps*4, "Every ship caught in the explosion will have its engines disabled for a few seconds..."),
            (config.fps*8, "its shield will also be badly hit.")] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemy.flagships,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0,"Wait for them to recover from the EMP and to get caught in the mine field!"),
                (config.fps*4, "Then finish them.")] ) )
            
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
        
        
        self.sol = Sun( game.stats.S_SOL, 0, 0 )
        self.mercury = Planet( game.stats.P_MERCURY, -4100, 1400 )
        self.venus = Planet( game.stats.P_VENUS, 5000, 2300 )
        self.earth = Planet( game.stats.P_EARTH, -3100, 6700 )
        self.mars = Planet( game.stats.P_MARS_1, -7800, -2300 )
        self.moon = Planet( game.stats.P_MOON, -3900, 6400 )
        self.jupiter = Planet( game.stats.P_JUPITER, -13000, -4800 )
        self.saturn = Planet( game.stats.P_SATURN, 13000, 2500 )
        self.neptune = Planet( game.stats.P_NEPTUNE, 15000, 7000 )
        
        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth
        
        # asteroids near the station
        for i in xrange( 1 ):
            asteroid = Asteroid( game, self.moon.xp+200, self.moon.yp+430, 0 )
            game.harvestables.append( asteroid )
        
        for i in xrange( 10 ): # civilians around self.earth
            dist = randint( 100, 800 )
            angle = 2*pi*random()

            (x,y) = (self.earth.xp+dist*cos(angle), self.earth.yp+dist*sin(angle))
            s = Ship( game.stats.CIVILIAN_0, AiCivilian(), x, y, -20 )
            game.objects.append( s )

        for i in range( 50 ): # asteroids outer self.mars
            dist = 9000
            angle = (1-2*random())*pi/8+pi*9/8
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )

        game.astres = [self.sol, self.mercury, self.venus, self.earth, self.moon, self.mars, self.jupiter, self.saturn, self.neptune, self.moon ]
        
      #  dist = self.earth.stats.maxRadius*1.2
      #  angle = 7/8*pi
     #   self.orbitalbase = OrbitalBase( None, game.stats.HUMAN_BASE, None, self.earth.xp+dist*cos(angle),self.earth.yp+dist*sin(angle))
      #  self.orbitalbase.ri = -0.013
      #  game.objects.append( self.orbitalbase )
        
        self.player = None