def doTurn(self, game): (ao, ro, ag) = Object.doTurn(self, game) # detect hit for obj in game.objects.getWithinRadius( self, self.weapon.stats.projectile.explosionTriggerRange): if obj.alive and obj.player != None and obj.player != self.launcher.player: (ao0, ro0, ag0) = explode(self, game, self.weapon.stats.projectile.explosionRange, energyDamage=self.weapon.stats.energyDamage, massDamage=self.weapon.stats.massDamage, sender=self.launcher.player, sound=ids.S_EX_FIRE) (ao, ro, ag) = (ao + ao0, ro + ro0, ag + ag0) if self.alive and self.ttl == 0: (ao0, ro0, ag0) = explode(self, game, self.weapon.stats.projectile.explosionRange, energyDamage=self.weapon.stats.energyDamage, massDamage=self.weapon.stats.massDamage, sender=self.launcher.player, sound=ids.S_EX_FIRE) (ao, ro, ag) = (ao + ao0, ro + ro0, ag + ag0) else: self.ttl = self.ttl - 1 return (ao, ro, ag)
def doTurn(self, game): # ai if self.ai: ( addedObjects0, removedObjects0, addedGfxs0 ) = self.ai.doTurn( self, game ) else: ( addedObjects0, removedObjects0, addedGfxs0 ) = ([],[],[]) if not self.orbiting and self.pulsedUntil < game.tick: # engine thrust self.xi = self.xi + self.thrust * cos( self.ori ) self.yi = self.yi + self.thrust * sin( self.ori ) # gouvernailstats self.ri = self.ri + self.rg # inertia controls self.xi = self.xi * (0.9+0.01*self.stats.mass)*self.inertiaMod #0.9 self.yi = self.yi * (0.9+0.01*self.stats.mass)*self.inertiaMod #0.9 self.zi = self.zi * (0.9+0.01*self.stats.mass)*self.inertiaMod #0.9 if fabs(self.xi) < 0.05 and fabs(self.yi) < 0.05: self.xi = self.yi = 0 if self.inertiaControl: self.ri = self.ri * 0.9 # *self.inertiaMod if fabs(self.ri) < 0.0005: self.ri = 0 if (not self.ai or self.ai.dockingTo) and randint( 0, config.fps*10 ) == 0: # zDiff = -2 + 4*randint( 0, 1 ) nz = randint( -5, 5 ) can = True for obj in game.objects.getWithinArea( self, self.stats.maxRadius+500 ): # print "s ", obj.zp <= max( self.zp, nz ), obj.zp >= min( self.zp, nz ), areOver( self, obj ) if obj != self and obj.zp <= max( self.zp, nz ) and obj.zp >= min( self.zp, nz ) and areOver( self, obj ): can = False break # print "switch", can, nz, obj.zp <= max( self.zp, nz ), obj.zp >= min( self.zp, nz ), areOver( self, obj ) if can: self.zp = nz ( addedObjects1, removedObjects1, addedGfxs1 ) = Object.doTurn( self, game ) # if self.thrust > 0 and self.stats.engines: # if randint( 0, 4 ) == 0: # engine = choice( self.stats.engines ) # (x,y) = (self.xp+engine[0]*cos(self.ori+engine[1]), self.yp+engine[0]*sin(self.ori+engine[1]) ) # addedGfxs1.append( GfxExhaust( (x,y), self.zp, 0, -0.2*self.xi+(0.5-random())*0.4, -0.2*self.yi+(0.5-random())*0.4, random()*pi ) ) if game.tick%(config.fps)==11: self.inNebula = False for obj in game.astres: if isinstance( obj, Nebula ) and distLowerThanObjects( self, obj, self.stats.maxRadius+obj.stats.maxRadius): self.inNebula = True break return ( addedObjects0+addedObjects1, removedObjects0+removedObjects1, addedGfxs0+addedGfxs1 )
def doTurn( self, game ): (ao,ro,ag) = Object.doTurn(self, game) # detect hit for obj in game.objects.getWithinRadius( self, self.weapon.stats.projectile.explosionTriggerRange ): if obj.alive and obj.player != None and obj.player != self.launcher.player: (ao0, ro0, ag0) = explode( self, game, self.weapon.stats.projectile.explosionRange, energyDamage=self.weapon.stats.energyDamage, massDamage=self.weapon.stats.massDamage, sender=self.launcher.player, sound=ids.S_EX_FIRE ) (ao, ro, ag) = (ao+ao0, ro+ro0, ag+ag0) if self.alive and self.ttl == 0: (ao0, ro0, ag0) = explode( self, game, self.weapon.stats.projectile.explosionRange, energyDamage=self.weapon.stats.energyDamage, massDamage=self.weapon.stats.massDamage, sender=self.launcher.player, sound=ids.S_EX_FIRE ) (ao, ro, ag) = (ao+ao0, ro+ro0, ag+ag0) else: self.ttl = self.ttl - 1 return (ao,ro,ag)
def doTurn( self, game ): (ao,ro,ag) = Object.doTurn(self, game) ## detect hit if not game.tick%20: for obj in game.objects.getWithinRadius( self, self.detectionRange ): if obj.alive and obj.player and not isinstance( obj, Mine ): (ao0,ro0,ag0) = self.explode( game ) (ao,ro,ag) = (ao+ao0,ro+ro0,ag+ag0) break ## detect expiration if self.alive and self.ttl == 0: (ao0,ro0,ag0) = self.explode( game ) (ao,ro,ag) = (ao+ao0,ro+ro0,ag+ag0) else: self.ttl = self.ttl - 1 return (ao,ro,ag)
def doTurn( self, game ): (ao,ro,ag) = Object.doTurn(self, game) # detect hit for obj in game.objects.getWithinRadius( self, self.stats.maxRadius ): if obj.alive and obj.player != None and obj.player != self.launcher.player: # TODO better (ao0, ro0, ag0) = obj.hit( game, utils.angleBetweenObjects( obj, self), self.launcher.player, energy=self.weapon.stats.energyDamage, mass=self.weapon.stats.massDamage ) (ao, ro, ag) = (ao+ao0, ro+ro0, ag+ag0) self.alive = False ro.append( self ) break if self.alive and self.ttl == 0: self.alive = False ro.append( self ) else: self.ttl = self.ttl - 1 return (ao,ro,ag)
def doTurn(self, game): (ao, ro, ag) = Object.doTurn(self, game) ## detect hit if not game.tick % 20: for obj in game.objects.getWithinRadius(self, self.detectionRange): if obj.alive and obj.player and not isinstance(obj, Mine): (ao0, ro0, ag0) = self.explode(game) (ao, ro, ag) = (ao + ao0, ro + ro0, ag + ag0) break ## detect expiration if self.alive and self.ttl == 0: (ao0, ro0, ag0) = self.explode(game) (ao, ro, ag) = (ao + ao0, ro + ro0, ag + ag0) else: self.ttl = self.ttl - 1 return (ao, ro, ag)
def doTurn(self, game): (ao, ro, ag) = Object.doTurn(self, game) # detect hit for obj in game.objects.getWithinRadius(self, self.stats.maxRadius): if obj.alive and obj.player != None and obj.player != self.launcher.player: # TODO better (ao0, ro0, ag0) = obj.hit(game, utils.angleBetweenObjects(obj, self), self.launcher.player, energy=self.weapon.stats.energyDamage, mass=self.weapon.stats.massDamage) (ao, ro, ag) = (ao + ao0, ro + ro0, ag + ag0) self.alive = False ro.append(self) break if self.alive and self.ttl == 0: self.alive = False ro.append(self) else: self.ttl = self.ttl - 1 return (ao, ro, ag)
def doTurn(self, game): # ai if self.ai: (addedObjects0, removedObjects0, addedGfxs0) = self.ai.doTurn(self, game) else: (addedObjects0, removedObjects0, addedGfxs0) = ([], [], []) if not self.orbiting and self.pulsedUntil < game.tick: # engine thrust self.xi = self.xi + self.thrust * cos(self.ori) self.yi = self.yi + self.thrust * sin(self.ori) # gouvernailstats self.ri = self.ri + self.rg # inertia controls self.xi = self.xi * ( 0.9 + 0.01 * self.stats.mass) * self.inertiaMod #0.9 self.yi = self.yi * ( 0.9 + 0.01 * self.stats.mass) * self.inertiaMod #0.9 self.zi = self.zi * ( 0.9 + 0.01 * self.stats.mass) * self.inertiaMod #0.9 if fabs(self.xi) < 0.05 and fabs(self.yi) < 0.05: self.xi = self.yi = 0 if self.inertiaControl: self.ri = self.ri * 0.9 # *self.inertiaMod if fabs(self.ri) < 0.0005: self.ri = 0 if (not self.ai or self.ai.dockingTo) and randint( 0, config.fps * 10) == 0: # zDiff = -2 + 4*randint( 0, 1 ) nz = randint(-5, 5) can = True for obj in game.objects.getWithinArea(self, self.stats.maxRadius + 500): # print "s ", obj.zp <= max( self.zp, nz ), obj.zp >= min( self.zp, nz ), areOver( self, obj ) if obj != self and obj.zp <= max( self.zp, nz) and obj.zp >= min( self.zp, nz) and areOver(self, obj): can = False break # print "switch", can, nz, obj.zp <= max( self.zp, nz ), obj.zp >= min( self.zp, nz ), areOver( self, obj ) if can: self.zp = nz (addedObjects1, removedObjects1, addedGfxs1) = Object.doTurn(self, game) # if self.thrust > 0 and self.stats.engines: # if randint( 0, 4 ) == 0: # engine = choice( self.stats.engines ) # (x,y) = (self.xp+engine[0]*cos(self.ori+engine[1]), self.yp+engine[0]*sin(self.ori+engine[1]) ) # addedGfxs1.append( GfxExhaust( (x,y), self.zp, 0, -0.2*self.xi+(0.5-random())*0.4, -0.2*self.yi+(0.5-random())*0.4, random()*pi ) ) if game.tick % (config.fps) == 11: self.inNebula = False for obj in game.astres: if isinstance(obj, Nebula) and distLowerThanObjects( self, obj, self.stats.maxRadius + obj.stats.maxRadius): self.inNebula = True break return (addedObjects0 + addedObjects1, removedObjects0 + removedObjects1, addedGfxs0 + addedGfxs1)