def explode(self, game): (ao, ro, ag) = ([], [], []) for obj in game.objects.objects: if obj.alive and obj.player and utils.distLowerThanObjects( self, obj, self.explosionRange + obj.stats.maxRadius): if self.launcher: sender = self.launcher.player else: sender = None (ao0, ro0, ag0) = obj.hit(game, utils.angleBetweenObjects(obj, self), sender, self.weapon.stats.energyDamage, self.weapon.stats.massDamage, pulse=10 * 30) # self.weapon.stats.pulseLength (ao, ro, ag) = (ao + ao0, ro + ro0, ag + ag0) self.alive = False ro0 = [self] ag0 = [ GfxExplosion((self.xp, self.yp), self.explosionRange, sound=ids.S_EX_PULSE) ] return (ao, ro + ro0, ag + ag0)
def doTurn( self, game ): for ship in self.flagships: if not ship.alive: self.flagships.remove( ship) else: self.manageFagship( ship, game ) if ship.ai.idle and self.territories: territory = choice( self.territories ) dist = randint( 0, territory.radius ) angle = 2*pi*random() dest = (territory.x+cos(angle)*dist, territory.y+sin(angle)*dist) ship.ai.goTo( ship, dest ) for ship in self.bases: if not ship.alive: self.bases.remove( ship) else: ship.energy = ship.stats.maxEnergy # cheating ship.ore = ship.stats.maxOre # cheating self.manageFagship( ship, game ) for ship in self.ships: if not ship.alive: self.ships.remove( ship) # else: for ship in utils.mY( self.bases, self.flagships, self.ships ): if ship.ai.attacking: #needsHelp( game ): for s1 in utils.mY( self.bases, self.flagships, self.ships ): # self.ships: if ship != s1 and not s1.ai.attacking and utils.distLowerThanObjects( ship, s1, 300 ): s1.ai.attack( s1, ship.ai.attacking )
def explode(self, game): (ao, ro, ag) = ([], [], []) for obj in game.objects.objects: if obj.alive and obj.player and utils.distLowerThanObjects( self, obj, self.explosionRange + obj.stats.maxRadius): if self.launcher: sender = self.launcher.player else: sender = None waveEffect = 5 angle = utils.angleBetweenObjects(self, obj) dist = utils.distBetweenObjects(self, obj) modif = max( (self.explosionRange - dist - obj.stats.maxRadius) / self.explosionRange, 1) obj.xi += cos(angle) * modif * waveEffect obj.yi += sin(angle) * modif * waveEffect (ao0, ro0, ag0) = obj.hit(game, utils.angleBetweenObjects(obj, self), sender, modif * self.weapon.stats.energyDamage, self.weapon.stats.massDamage * modif) (ao, ro, ag) = (ao + ao0, ro + ro0, ag + ag0) self.alive = False ro0 = [self] ag0 = [ GfxExplosion((self.xp, self.yp), self.explosionRange, sound=ids.S_EX_NUKE) ] return (ao, ro + ro0, ag + ag0)
def doTurn(self, game): for ship in self.flagships: if not ship.alive: self.flagships.remove(ship) else: self.manageFagship(ship, game) if ship.ai.idle and self.territories: territory = choice(self.territories) dist = randint(0, territory.radius) angle = 2 * pi * random() dest = (territory.x + cos(angle) * dist, territory.y + sin(angle) * dist) ship.ai.goTo(ship, dest) for ship in self.bases: if not ship.alive: self.bases.remove(ship) else: ship.energy = ship.stats.maxEnergy # cheating ship.ore = ship.stats.maxOre # cheating self.manageFagship(ship, game) for ship in self.ships: if not ship.alive: self.ships.remove(ship) # else: for ship in utils.mY(self.bases, self.flagships, self.ships): if ship.ai.attacking: #needsHelp( game ): for s1 in utils.mY(self.bases, self.flagships, self.ships): # self.ships: if ship != s1 and not s1.ai.attacking and utils.distLowerThanObjects( ship, s1, 300): s1.ai.attack(s1, ship.ai.attacking)
def fire( self, ship, game, target ): (ao,ro,ag) = ([],[],[]) for obj in game.objects.objects: if obj.alive and obj.player and utils.distLowerThanObjects( self, obj, self.stats.explosionRange + obj.stats.maxRadius ): if ship.ai.player: sender = ship.ai.player else: sender = None (ao0, ro0, ag0) = obj.hit( game, utils.angleBetweenObjects( obj, ship ), sender, self.stats.energyDamage, self.stats.massDamage, pulse=self.stats.pulseLength ) # self.weapon.stats.pulseLength (ao, ro, ag) = (ao+ao0, ro+ro0, ag+ag0) ag0 = [ GfxExplosion( (ship.xp,ship.yp), self.stats.explosionRange, sound=ids.S_EX_PULSE ) ] return (ao, ro+ro0, ag+ag0)
def manageFagship(self, ship, game): if not game.tick % 50: ## activated turrets for turret in ship.turrets: turret.activated = True ## launch harvesters for k in ship.ai.launching: if isinstance(game.stats[k], game.stats.HarvesterShipStats): ship.ai.launching[k] = True if ship.ai.attacking: # in combat ## launch fighters for k in ship.ai.launching: if not isinstance(game.stats[k], game.stats.HarvesterShipStats): ship.ai.launching[k] = True ## maneuver dist = (ship.stats.maxRadius + ship.ai.attacking.stats.maxRadius) * 1.5 angle = utils.angleBetweenObjects(ship.ai.attacking, ship) + pi / 8 ship.ai.goTo(ship, (ship.ai.attacking.xp + cos(angle) * dist, ship.ai.attacking.yp + sin(angle) * dist)) else: # not in combat if not game.tick % (config.fps * 10): needToFindOre = False needToFindEnergy = False ## recall fighters when not in combat for k in ship.ai.launching: if not isinstance(game.stats[k], game.stats.HarvesterShipStats): ship.ai.recallShips(ship, game, k) #ship.ai.launching[ k ] = False ## move closer to resources if sum( [ len(ship.shipyards[ shipyard ].docked)+len(ship.shipyards[ shipyard ].away) for shipyard in \ filter( lambda ship: isinstance( game.stats[ k ], game.stats.HarvesterShipStats ), ship.shipyards ) ] ): # if has any harvesters closestAsteroid = game.harvestables.getClosestAccording( ship.pos, ship.getRadarRange()) if closestAsteroid and not utils.distLowerThanObjects( ship, closestAsteroid, ship.stats.maxRadius * 2): dist = ship.stats.maxRadius * 1.5 angle = random() * 2 * pi ship.ai.goTo(ship, (closestAsteroid.xp + dist * cos(angle), closestAsteroid.yp + dist * sin(angle))) else: # nothing in range if ship.ore < ship.stats.maxOre / 10: # low on ore needToFindOre = True
def explode( self, game ): (ao,ro,ag) = ([],[],[]) for obj in game.objects.objects: if obj.alive and obj.player and utils.distLowerThanObjects( self, obj, self.explosionRange + obj.stats.maxRadius ): if self.launcher: sender = self.launcher.player else: sender = None (ao0, ro0, ag0) = obj.hit( game, utils.angleBetweenObjects( obj, self ), sender, self.weapon.stats.energyDamage, self.weapon.stats.massDamage, pulse=10*30 ) # self.weapon.stats.pulseLength (ao, ro, ag) = (ao+ao0, ro+ro0, ag+ag0) self.alive = False ro0 = [ self ] ag0 = [ GfxExplosion( (self.xp,self.yp), self.explosionRange, sound=ids.S_EX_PULSE ) ] return (ao, ro+ro0, ag+ag0)
def manageFagship( self, ship, game ): if not game.tick%50: ## activated turrets for turret in ship.turrets: turret.activated = True ## launch harvesters for k in ship.ai.launching: if isinstance( game.stats[ k ], game.stats.HarvesterShipStats ): ship.ai.launching[ k ] = True if ship.ai.attacking: # in combat ## launch fighters for k in ship.ai.launching: if not isinstance( game.stats[ k ], game.stats.HarvesterShipStats ): ship.ai.launching[ k ] = True ## maneuver dist = (ship.stats.maxRadius + ship.ai.attacking.stats.maxRadius)*1.5 angle = utils.angleBetweenObjects( ship.ai.attacking, ship )+pi/8 ship.ai.goTo( ship, (ship.ai.attacking.xp+cos(angle)*dist, ship.ai.attacking.yp+sin(angle)*dist) ) else: # not in combat if not game.tick%(config.fps*10): needToFindOre = False needToFindEnergy = False ## recall fighters when not in combat for k in ship.ai.launching: if not isinstance( game.stats[ k ], game.stats.HarvesterShipStats ): ship.ai.recallShips( ship, game, k ) #ship.ai.launching[ k ] = False ## move closer to resources if sum( [ len(ship.shipyards[ shipyard ].docked)+len(ship.shipyards[ shipyard ].away) for shipyard in \ filter( lambda ship: isinstance( game.stats[ k ], game.stats.HarvesterShipStats ), ship.shipyards ) ] ): # if has any harvesters closestAsteroid = game.harvestables.getClosestAccording( ship.pos, ship.getRadarRange() ) if closestAsteroid and not utils.distLowerThanObjects( ship, closestAsteroid, ship.stats.maxRadius*2 ): dist=ship.stats.maxRadius*1.5 angle=random()*2*pi ship.ai.goTo( ship, (closestAsteroid.xp+dist*cos(angle),closestAsteroid.yp+dist*sin(angle)) ) else: # nothing in range if ship.ore < ship.stats.maxOre/10: # low on ore needToFindOre = True
def explode( self, game ): (ao,ro,ag) = ([],[],[]) for obj in game.objects.objects: if obj.alive and obj.player and utils.distLowerThanObjects( self, obj, self.explosionRange + obj.stats.maxRadius ): if self.launcher: sender = self.launcher.player else: sender = None waveEffect = 5 angle = utils.angleBetweenObjects( self, obj ) dist = utils.distBetweenObjects( self, obj ) modif = max((self.explosionRange-dist-obj.stats.maxRadius)/self.explosionRange, 1) obj.xi += cos(angle)*modif*waveEffect obj.yi += sin(angle)*modif*waveEffect (ao0, ro0, ag0) = obj.hit( game, utils.angleBetweenObjects( obj, self ), sender, modif*self.weapon.stats.energyDamage, self.weapon.stats.massDamage*modif ) (ao, ro, ag) = (ao+ao0, ro+ro0, ag+ag0) self.alive = False ro0 = [ self ] ag0 = [ GfxExplosion( (self.xp,self.yp), self.explosionRange, sound=ids.S_EX_NUKE ) ] return (ao, ro+ro0, ag+ag0)
def fire(self, ship, game, target): (ao, ro, ag) = ([], [], []) for obj in game.objects.objects: if obj.alive and obj.player and utils.distLowerThanObjects( self, obj, self.stats.explosionRange + obj.stats.maxRadius): if ship.ai.player: sender = ship.ai.player else: sender = None (ao0, ro0, ag0) = obj.hit(game, utils.angleBetweenObjects(obj, ship), sender, self.stats.energyDamage, self.stats.massDamage, pulse=self.stats.pulseLength ) # self.weapon.stats.pulseLength (ao, ro, ag) = (ao + ao0, ro + ro0, ag + ag0) ag0 = [ GfxExplosion((ship.xp, ship.yp), self.stats.explosionRange, sound=ids.S_EX_PULSE) ] return (ao, ro + ro0, ag + ag0)
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
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) )
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
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))