def gen(position): x, y = position return Entity(str(uuid.uuid4()), components={ 'Stats': Stats(actual_stats).with_status('.TEMPORARY', strength=1, duration=10), 'Position': Position(x, y), 'Render': Render(character='t', colour=ThunderTotem.colours[tier-1]), 'Combat': Combat(), 'Ally': Combat(), 'NPC': NPC(ThunderTotem.names[tier-1]), 'AI': ai.AI()\ .add_skill('Shockwave', ThunderTotem.Shockwave(), delay=1)\ .with_state('IDLE', ai.AIState()\ .on_turn_otherwise(lambda e, ai, ev_d : ai.find_target(e), False)\ .when_target_within_distance(1.5, lambda e, ai, ev_d : ai.use_skill(e, 'Shockwave')))\ }, ttype='ThunderTotem_'+str(tier))
def gen(position): x, y = position return Entity(str(uuid.uuid4()), components={ 'Stats': Stats(actual_stats), 'Position': Position(x, y), 'Render': Render(character='s', colour=Allyslime.colours[tier-1]), 'Combat': Combat(), 'Ally': Combat(), 'NPC': NPC(Allyslime.names[tier-1]), 'AI': ai.AI()\ .add_skill('MonWave', Allyslime.MonWave(), delay=1)\ .with_state('IDLE', ai.AIState()\ .when_target_within_distance(1.5, lambda e, ai, ev_d : ai.use_skill(e, 'MonWave'))\ .when_target_within_distance(5, lambda e, ai, ev_d : ai.step_towards_target(e))\ .on_turn_otherwise(lambda e, ai, ev_d : ai.find_target(e), False)\ .on_turn_otherwise(lambda e, ai, ev_d : ai.step_towards_player(e)))\ }, ttype='Allyslime_'+str(tier))
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 tick_turret(entity): _target_id = ai.find_target(entity, max_distance=1600) if _target_id: entity['shoot_direction'] = numbers.direction_to(entity['position'], entities.get_entity(_target_id)['position']) entities.trigger_event(entity, 'shoot')
def tick_flea(entity): if not entity['current_target']: entity['current_target'] = ai.find_target(entity) if entity['current_target']: ai.track_target(entity, entity['current_target'])