def boss_explode(entity): for i in range(random.randint(3, 6)): _effect = effects.create_particle(entity['position'][0]+random.randint(-20, 20), entity['position'][1]+random.randint(-20, 20), 'explosion.png', background=False, scale=random.uniform(.5, 1.3), flashes=random.randint(10, 15), flash_chance=0.85, direction=entity['direction']+random.randint(-90, 90), speed=entity['current_speed']*.9) for i in range(random.randint(6, 8)): _effect = effects.create_particle(entity['position'][0]+random.randint(-20, 20), entity['position'][1]+random.randint(-20, 20), 'explosion.png', background=True, scale=random.uniform(1.0, 1.3), scale_min=0.05, scale_rate=.91, friction=0, speed=80, direction=random.randint(0, 359), streamer=True, streamer_chance=.8, swerve_rate=15)
def boss_dying(entity): if random.randint(0, 3): _effect = effects.create_particle(entity['position'][0]+random.randint(-190, 190), entity['position'][1]+random.randint(-190, 190), 'explosion.png', background=False, scale=random.uniform(.5, 1.3), flashes=random.randint(10, 15), flash_chance=0.85, direction=entity['direction']+random.randint(-90, 90), speed=entity['current_speed']*.9) if not random.randint(0, 5): _effect = effects.create_particle(entity['position'][0]+random.randint(-50, 50), entity['position'][1]+random.randint(-50, 50), 'explosion.png', background=True, scale=random.uniform(1.0, 1.3), scale_min=0.05, scale_rate=.91, friction=0, speed=80, direction=random.randint(0, 359), streamer=True, streamer_chance=.8, swerve_rate=15)
def destroy(entity): entity['hp'] = 0 if entity['death_timer'] == -1: entity['death_timer'] = entity['death_timer_max'] if entity['death_timer']: entity['death_timer'] -= 1 else: entities.trigger_event(entity, 'explode') _effect = effects.create_particle(entity['position'][0]+random.randint(-20, 20), entity['position'][1]+random.randint(-20, 20), 'shockwave.png', background=True, scale=0, scale_min=-.1, scale_max=8, scale_rate=1.1) entities.delete_entity(entity) if random.randint(0, 3): _effect = effects.create_particle(entity['position'][0]+random.randint(-20, 20), entity['position'][1]+random.randint(-20, 20), 'explosion.png', background=False, scale=random.uniform(.5, 1.3), flashes=random.randint(10, 15), flash_chance=0.85, direction=entity['direction']+random.randint(-90, 90), speed=entity['current_speed']*.9)
def tick_missile(bullet): if not random.randint(0, 3): _displace = (random.randint(-2, 2), random.randint(-2, 2)) effects.create_particle(bullet['position'][0]+_displace[0], bullet['position'][1]+_displace[1], 'explosion.png', scale=0.2, scale_rate=.95, fade_rate=.7) bullet['engine_power'] -= 1 if not bullet['engine_power']: entities.trigger_event(bullet, 'destroy') entities.trigger_event(bullet, 'set_rotation', degrees=bullet['direction'])
def tick_energy_ship(entity): entity['shoot_direction'] = numbers.direction_to(entity['last_position'], entity['position']) if random.randint(0, 1): _displace = (random.uniform(-entity['velocity'][0], entity['velocity'][0]), random.uniform(-entity['velocity'][1], entity['velocity'][1])) _effect_direction = numbers.direction_to(entity['position'], (entity['position'][0]+(entity['velocity'][0]*6), entity['position'][1]+(entity['velocity'][1]*6))) _effect_direction += (abs(entity['shoot_direction']-_effect_direction)*numbers.clip(_effect_direction, -1, 1))*5 effects.create_particle(entity['position'][0]+_displace[0], entity['position'][1]+_displace[1], 'streamer.png', scale_rate=.75, speed=-entity['current_speed'], friction=0.1, direction=_effect_direction+random.randint(-5, 5), rotation=_effect_direction)
def create_missile(x, y, direction, speed, sprite_name, owner_id, life=3000, scale=.2, turn_rate=.15, tracking=True, drunk=True, radius=50): _bullet = create(x, y, direction, speed, sprite_name, owner_id, life=life, turn_rate=turn_rate, radius=radius) _owner = entities.get_entity(_bullet['owner_id']) _bullet['sprite'].anchor_x = 0 _bullet['sprite'].anchor_y = sprites.get_size(_bullet['sprite'])[1]/2 entities.trigger_event(_bullet, 'set_scale', scale=scale) entities.register_event(_bullet, 'tick', tick_missile) entities.register_event(_bullet, 'hit', hit_missile) if drunk: entities.register_event(_bullet, 'tick', tick_drunk) if tracking: _bullet['target_id'] = ai.find_target(_owner, max_distance=1600) if _bullet['target_id']: _target = entities.get_entity(_bullet['target_id']) entities.register_event(_bullet, 'tick', tick_track) entities.register_event(_target, 'delete', lambda target: _bullet['_id'] in entities.ENTITIES and entities.unregister_event(_bullet, 'tick', tick_track)) if 'player' in _owner and _owner['player']: effects.create_particle(_target['position'][0], _target['position'][1], 'crosshair.png', background=False, scale_rate=.95, fade_rate=.98, spin=random.choice([-3, -6, 3, 6])) else: _bullet['target_id'] = None _bullet['engine_power'] = 100 return _bullet
def destroy(bullet): for i in range(random.randint(2, 3)): _effect = effects.create_particle(bullet['position'][0]+random.randint(-2, 2), bullet['position'][1]+random.randint(-2, 2), 'explosion.png', background=False, scale=random.uniform(.4, .8), flashes=random.randint(5, 7), flash_chance=0.7, direction=bullet['direction']+random.randint(-45, 45), speed=bullet['current_speed']*.5) return entities.delete_entity(bullet)
def tick(bullet): for soldier_id in entities.get_sprite_groups(bullet['enemy_sprite_groups']): if bullet['owner_id'] == soldier_id: continue _entity = entities.get_entity(soldier_id) if numbers.distance(bullet['position'], _entity['position'], old=True)-_entity['collision_radius']>bullet['damage_radius']: continue if bullet['owner_id'] in entities.ENTITIES and 'player' in entities.get_entity(bullet['owner_id']): effects.create_particle(bullet['position'][0], bullet['position'][1], 'hitmarker.png', direction=random.randint(0, 359), speed=random.randint(25, 30), background=False, fade_rate=0.8, scale_rate=1.02) entities.trigger_event(bullet, 'hit', target_id=soldier_id) entities.trigger_event(_entity, 'hit', damage=bullet['damage'], target_id=bullet['owner_id']) entities.delete_entity(bullet)
def hit_laser(bullet, target_id): for i in range(random.randint(2, 3)): _effect = effects.create_particle(bullet['position'][0]+random.randint(-6, 6), bullet['position'][1]+random.randint(-6, 6), 'explosion.png', background=False, scale=random.uniform(.4, .8), flashes=random.randint(15, 25), flash_chance=0.7) _effect['velocity'] = numbers.interp_velocity(bullet['velocity'], entities.get_entity(target_id)['velocity'], .1) _effect['velocity'][0] = numbers.clip(_effect['velocity'][0], -6, 6) _effect['velocity'][1] = numbers.clip(_effect['velocity'][1], -6, 6) entities.trigger_event(entities.get_entity(target_id), 'accelerate', velocity=numbers.interp_velocity(entities.get_entity(target_id)['velocity'], bullet['velocity'], .4))
def explode(entity): for i in range(random.randint(0, 3)+('player' in entity)*2): _effect = effects.create_particle(entity['position'][0]+random.randint(-20, 20), entity['position'][1]+random.randint(-20, 20), 'explosion.png', background=True, scale=random.uniform(1.0, 1.3), scale_min=0.05, scale_rate=.91, friction=0, speed=40, direction=random.randint(0, 359), streamer=True, streamer_chance=.8, swerve_rate=15)