def _create(x, y, name, char, weight, item_type, equip_to=None, fore_color=(255, 255, 255), kind=None): _entity = entities.create_entity(group='items') _entity['stats'] = {'name': name, 'display_name': name, 'type': item_type, 'weight': weight, 'owner': None, 'kind': kind, 'equip_to': equip_to, 'in_container': None} movement.register(_entity) flags.register(_entity) tile.register(_entity, surface='items', char=char, fore_color=fore_color) entities.create_event(_entity, 'collision_with_solid') entities.create_event(_entity, 'collision_with_entity') entities.create_event(_entity, 'get_interactions') entities.create_event(_entity, 'get_actions') entities.create_event(_entity, 'get_display_name') entities.create_event(_entity, 'seen') entities.register_event(_entity, 'get_display_name', get_display_name) entities.trigger_event(_entity, 'set_position', x=x, y=y) return _entity
def _create_animal(x, y, health, speed, name, vision=65, faction='Mutants', has_ai=False, char='m', fore_color=(255, 255, 255)): _entity = entities.create_entity(group='life') entities.create_event(_entity, 'damage') entities.create_event(_entity, 'did_damage') entities.create_event(_entity, 'receive_memory') entities.create_event(_entity, 'handle_corpse') entities.create_event(_entity, 'finish_turn') tile.register(_entity, surface='life', char=char, fore_color=fore_color) movement.register(_entity, collisions=True) timers.register(_entity) stats.register(_entity, health, speed, vision, name=name, kind='animal') nodes.register(_entity) items.register(_entity) flags.register(_entity) noise.register(_entity) skeleton.register(_entity) ai_factions.register(_entity, faction) if has_ai: ai.register_animal(_entity) _entity['ai']['is_npc'] = True entities.register_event(_entity, 'finish_turn', finish_turn) entities.create_event(_entity, 'get_and_store_item') entities.create_event(_entity, 'get_and_hold_item') entities.create_event(_entity, 'reload') entities.create_event(_entity, 'shoot') entities.create_event(_entity, 'damage') entities.register_event(_entity, 'post_tick', ai_visuals.cleanup) entities.register_event(_entity, 'get_and_store_item', get_and_store_item) entities.register_event(_entity, 'get_and_hold_item', get_and_hold_item) entities.register_event(_entity, 'reload', reload_weapon) entities.register_event(_entity, 'shoot', shoot_weapon) entities.register_event(_entity, 'heard_noise', handle_heard_noise) entities.register_event(_entity, 'position_changed', lambda e, **kwargs: entities.trigger_event(e, 'create_noise', volume=25, text='?', owner_can_hear=False, callback=lambda t, x, y: entities.trigger_event(t, 'update_target_memory', target_id=_entity['_id'], key='last_seen_at', value=[x, y]))) #entities.register_event(_entity, 'position_changed', lambda e, **kwargs: ai_visuals.add_to_moved_life(e)) entities.register_event(_entity, 'push', lambda e, **kwargs: movement.sub_move_cost(e)) entities.trigger_event(_entity, 'set_position', x=x, y=y) entities.trigger_event(_entity, 'create_holder', name='weapon', max_weight=10) entities.trigger_event(_entity, 'create_holder', name='backpack', max_weight=10) return _entity
def _create_node(node_grid, x, y): _entity = entities.create_entity() flags.register(_entity) tile.register(_entity, surface='node_grid', fore_color=(255, 0, 255)) entities.trigger_event(_entity, 'set_position', x=x, y=y) entities.trigger_event(_entity, 'set_flag', flag='owner', value=None) entities.register_event(_entity, 'flag_changed', handle_node_flag_change) node_grid[(x, y)] = _entity['_id'] UNCLAIMED_NODES.add((x, y))
def _create(x, y, surface='effects', group='effects'): _entity = entities.create_entity() movement.register(_entity) tile.register(_entity, surface=surface) timers.register(_entity) entities.add_entity_to_group(_entity, group) entities.trigger_event(_entity, 'set_position', x=x, y=y) return _entity
def boot(): global CURSOR CURSOR = entities.create_entity(group='systems') tile.register(CURSOR, surface='ui') events.register_event('camera', logic) events.register_event('mouse_moved', handle_mouse_movement) events.register_event('mouse_pressed', handle_mouse_pressed) events.register_event('input', handle_keyboard_input) events.register_event('draw', lambda *args: entities.trigger_event(CURSOR, 'draw')) entities.trigger_event(CURSOR, 'set_position', x=constants.MAP_VIEW_WIDTH/2, y=constants.MAP_VIEW_HEIGHT/2)
def create_context(x, y, text, callback): _entity = entities.create_entity(group='contexts') _entity['text'] = text _entity['callback'] = callback tile.register(_entity, surface='effects', char='!', fore_color=(0, 200, 0)) timers.register(_entity, use_system_event='logic') entities.trigger_event(_entity, 'set_position', x=x, y=y) entities.trigger_event(_entity, 'animate', animation=['!', ' '], repeat=-1) entities.trigger_event(_entity, 'create_timer', time=120, exit_callback=entities.delete_entity) return _entity
def _create_node(entity, x, y, draw_path=False, passive=True, action_time=0, name='Node', callback_on_touch=True): global LAST_CLICKED_POS _path_index = -1 if LAST_CLICKED_POS: _node_positions = [(p['node']['x'], p['node']['y']) for p in entity['node_grid']['nodes'].values() if not p['node']['name'] == chr(31)] for node_id in entity['node_grid']['path'][:]: _last_node = entity['node_grid']['nodes'][node_id] if LAST_CLICKED_POS in _last_node['node']['path']: _move_cost = 0 for pos in _last_node['node']['path'][_last_node['node']['path'].index(LAST_CLICKED_POS):]: _move_cost += movement.get_move_cost(entity) if _move_cost < action_time and pos in _node_positions: return _path_index = entity['node_grid']['path'].index(node_id) entity['node_grid']['nodes'][entity['node_grid']['path'][_path_index]]['node']['action_time'] = action_time break LAST_CLICKED_POS = None _node = entities.create_entity(group='nodes') _node['x'] = x _node['y'] = y _node['name'] = name _node['draw_path'] = draw_path _node['path'] = [] _node['owner_id'] = entity['_id'] _node['action_time'] = action_time _node['busy_pos'] = [] tile.register(_node, surface='nodes') entities.trigger_event(_node, 'set_position', x=x, y=y) if _path_index == -1: _path_index = len(entity['node_grid']['path']) entity['node_grid']['nodes'][_node['_id']] = {'node': _node, 'passive': passive, 'callback': None, 'call_on_touch': callback_on_touch} entity['node_grid']['path'].insert(_path_index, _node['_id']) return _node
def boot(): global CURSOR CURSOR = entities.create_entity(group='systems') tile.register(CURSOR, surface='ui') events.register_event('camera', logic) events.register_event('mouse_moved', handle_mouse_movement) events.register_event('mouse_pressed', handle_mouse_pressed) events.register_event('input', handle_keyboard_input) events.register_event('draw', lambda *args: entities.trigger_event(CURSOR, 'draw')) entities.trigger_event(CURSOR, 'set_position', x=constants.MAP_VIEW_WIDTH / 2, y=constants.MAP_VIEW_HEIGHT / 2)
def _create(x, y, name, char, weight, item_type, equip_to=None, fore_color=(255, 255, 255), kind=None): _entity = entities.create_entity(group='items') _entity['stats'] = { 'name': name, 'display_name': name, 'type': item_type, 'weight': weight, 'owner': None, 'kind': kind, 'equip_to': equip_to, 'in_container': None } movement.register(_entity) flags.register(_entity) tile.register(_entity, surface='items', char=char, fore_color=fore_color) entities.create_event(_entity, 'collision_with_solid') entities.create_event(_entity, 'collision_with_entity') entities.create_event(_entity, 'get_interactions') entities.create_event(_entity, 'get_actions') entities.create_event(_entity, 'get_display_name') entities.create_event(_entity, 'seen') entities.register_event(_entity, 'get_display_name', get_display_name) entities.trigger_event(_entity, 'set_position', x=x, y=y) return _entity
def _create_human(x, y, health, speed, name, vision=50, faction='Rogues', is_player=False, has_ai=False, fore_color=(255, 255, 255)): _entity = entities.create_entity(group='life') entities.create_event(_entity, 'get_and_store_item') entities.create_event(_entity, 'get_and_hold_item') entities.create_event(_entity, 'reload') entities.create_event(_entity, 'shoot') entities.create_event(_entity, 'damage') entities.create_event(_entity, 'did_damage') entities.create_event(_entity, 'receive_memory') entities.create_event(_entity, 'handle_corpse') entities.create_event(_entity, 'finish_turn') tile.register(_entity, surface='life', char='@', fore_color=fore_color) movement.register(_entity, collisions=True) timers.register(_entity) stats.register(_entity, health, speed, vision, name=name, kind='human') nodes.register(_entity) items.register(_entity) flags.register(_entity) noise.register(_entity) missions.register(_entity) skeleton.register(_entity) skeleton.create_motion(_entity, 'stand') skeleton.create_motion(_entity, 'crouch', stat_mod={'mobility': 1.55}) skeleton.create_motion(_entity, 'crawl', stat_mod={'mobility': 2.3}) skeleton.create_limb(_entity, 'head', [], True, 0.1, stat_mod={'vision': .75}) skeleton.create_limb(_entity, 'chest', ['head'], True, 0.88, stat_mod={'mobility': .1}) skeleton.create_limb(_entity, 'torso', ['chest'], True, 0.75, stat_mod={'mobility': .6}) skeleton.create_limb(_entity, 'left arm', ['chest'], False, 0.3, can_sever=True, stat_mod={'accuracy': .22}) skeleton.create_limb(_entity, 'right arm', ['chest'], False, 0.3, can_sever=True, stat_mod={'accuracy': .22}) skeleton.create_limb(_entity, 'left leg', ['torso'], False, 0.45, can_sever=True, stat_mod={'mobility': .4}) skeleton.create_limb(_entity, 'right leg', ['torso'], False, 0.45, can_sever=True, stat_mod={'mobility': .4}) if has_ai: ai.register_human(_entity) ai_factions.register(_entity, faction) _entity['ai']['is_player'] = is_player _entity['ai']['is_npc'] = not is_player if faction == 'Rogues': entities.register_event(_entity, 'did_damage', lambda e, target_id, damage: effects.printer(entities.get_entity(target_id)['tile']['x'], entities.get_entity(target_id)['tile']['y']-1, '%s' % damage, fore_color=(200, 0, 0), speed_mod=0.3, show_mod=1.0, moving=True, center=True)) entities.register_event(_entity, 'log_kill', lambda e, target_id: effects.printer(entities.get_entity(target_id)['tile']['x'], entities.get_entity(target_id)['tile']['y']-1, 'KILL', fore_color=(255, 0, 0), speed_mod=0.3, show_mod=1.0, moving=True, center=True)) entities.register_event(_entity, 'finish_turn', finish_turn) entities.register_event(_entity, 'post_tick', ai_visuals.cleanup) entities.register_event(_entity, 'get_and_store_item', get_and_store_item) entities.register_event(_entity, 'get_and_hold_item', get_and_hold_item) entities.register_event(_entity, 'reload', reload_weapon) entities.register_event(_entity, 'shoot', shoot_weapon) entities.register_event(_entity, 'heard_noise', handle_heard_noise) entities.register_event(_entity, 'position_changed', lambda e, **kwargs: entities.trigger_event(e, 'create_noise', volume=25, text='?', callback=lambda t, x, y: entities.trigger_event(t, 'update_target_memory', target_id=_entity['_id'], key='last_seen_at', value=[x, y]))) #entities.register_event(_entity, 'damage', # lambda e, **kwargs: entities.trigger_event(e, # 'create_noise', # volume=12, # text='Ow!', # owner_can_hear=True, # show_on_sight=True, # callback=lambda t, x, y: entities.trigger_event(t, # 'update_target_memory', # target_id=_entity['_id'], # key='last_seen_at', # value=[x, y]))) #entities.register_event(_entity, 'position_changed', lambda e, **kwargs: ai_visuals.add_to_moved_life(e)) entities.register_event(_entity, 'push', lambda e, **kwargs: movement.sub_move_cost(e)) entities.trigger_event(_entity, 'set_position', x=x, y=y) entities.trigger_event(_entity, 'create_holder', name='weapon', max_weight=10) entities.trigger_event(_entity, 'create_holder', name='backpack', max_weight=10) _get_and_hold_item(_entity, items.leather_backpack(20, 20)['_id']) return _entity
def _create_robot(x, y, health, speed, name, vision=30, faction='Rogues', is_player=False, has_ai=True, fore_color=(200, 200, 200)): _entity = entities.create_entity(group='life') entities.create_event(_entity, 'get_and_store_item') entities.create_event(_entity, 'get_and_hold_item') entities.create_event(_entity, 'reload') entities.create_event(_entity, 'shoot') entities.create_event(_entity, 'damage') entities.create_event(_entity, 'did_damage') entities.create_event(_entity, 'receive_memory') entities.create_event(_entity, 'handle_corpse') entities.create_event(_entity, 'finish_turn') tile.register(_entity, surface='life', char='@', fore_color=fore_color) movement.register(_entity, collisions=True) timers.register(_entity) stats.register(_entity, health, speed, vision, name=name, kind='human') nodes.register(_entity) items.register(_entity) flags.register(_entity) noise.register(_entity) missions.register(_entity) skeleton.register(_entity) if has_ai: ai.register_robot(_entity) ai_factions.register(_entity, faction) _entity['ai']['is_player'] = is_player _entity['ai']['is_npc'] = not is_player if is_player: entities.register_event(_entity, 'did_damage', lambda e, target_id, damage: effects.printer(entities.get_entity(target_id)['tile']['x'], entities.get_entity(target_id)['tile']['y']-1, '%s' % damage, fore_color=(200, 0, 0), speed_mod=0.3, show_mod=1.0, moving=True, center=True)) entities.register_event(_entity, 'log_kill', lambda e, target_id: effects.printer(entities.get_entity(target_id)['tile']['x'], entities.get_entity(target_id)['tile']['y']-1, 'KILL', fore_color=(255, 0, 0), speed_mod=0.3, show_mod=1.0, moving=True, center=True)) entities.register_event(_entity, 'delete', _handle_robot_death) entities.register_event(_entity, 'finish_turn', finish_turn) entities.register_event(_entity, 'post_tick', ai_visuals.cleanup) entities.register_event(_entity, 'get_and_store_item', get_and_store_item) entities.register_event(_entity, 'get_and_hold_item', get_and_hold_item) entities.register_event(_entity, 'reload', reload_weapon) entities.register_event(_entity, 'shoot', shoot_weapon) entities.register_event(_entity, 'heard_noise', handle_heard_noise) entities.register_event(_entity, 'position_changed', lambda e, **kwargs: entities.trigger_event(e, 'create_noise', volume=25, text='?', callback=lambda t, x, y: entities.trigger_event(t, 'update_target_memory', target_id=_entity['_id'], key='last_seen_at', value=[x, y]))) entities.register_event(_entity, 'push', lambda e, **kwargs: movement.sub_move_cost(e)) entities.trigger_event(_entity, 'set_position', x=x, y=y) entities.trigger_event(_entity, 'create_holder', name='weapon', max_weight=10) entities.trigger_event(_entity, 'create_holder', name='backpack', max_weight=10) _get_and_hold_item(_entity, items.leather_backpack(20, 20)['_id']) return _entity
def _create_animal(x, y, health, speed, name, vision=65, faction='Mutants', has_ai=False, char='m', fore_color=(255, 255, 255)): _entity = entities.create_entity(group='life') entities.create_event(_entity, 'damage') entities.create_event(_entity, 'did_damage') entities.create_event(_entity, 'receive_memory') entities.create_event(_entity, 'handle_corpse') entities.create_event(_entity, 'finish_turn') tile.register(_entity, surface='life', char=char, fore_color=fore_color) movement.register(_entity, collisions=True) timers.register(_entity) stats.register(_entity, health, speed, vision, name=name, kind='animal') nodes.register(_entity) items.register(_entity) flags.register(_entity) noise.register(_entity) skeleton.register(_entity) ai_factions.register(_entity, faction) if has_ai: ai.register_animal(_entity) _entity['ai']['is_npc'] = True entities.register_event(_entity, 'finish_turn', finish_turn) entities.create_event(_entity, 'get_and_store_item') entities.create_event(_entity, 'get_and_hold_item') entities.create_event(_entity, 'reload') entities.create_event(_entity, 'shoot') entities.create_event(_entity, 'damage') entities.register_event(_entity, 'post_tick', ai_visuals.cleanup) entities.register_event(_entity, 'get_and_store_item', get_and_store_item) entities.register_event(_entity, 'get_and_hold_item', get_and_hold_item) entities.register_event(_entity, 'reload', reload_weapon) entities.register_event(_entity, 'shoot', shoot_weapon) entities.register_event(_entity, 'heard_noise', handle_heard_noise) entities.register_event( _entity, 'position_changed', lambda e, **kwargs: entities. trigger_event(e, 'create_noise', volume=25, text='?', owner_can_hear=False, callback=lambda t, x, y: entities.trigger_event( t, 'update_target_memory', target_id=_entity['_id'], key='last_seen_at', value=[x, y]))) #entities.register_event(_entity, 'position_changed', lambda e, **kwargs: ai_visuals.add_to_moved_life(e)) entities.register_event(_entity, 'push', lambda e, **kwargs: movement.sub_move_cost(e)) entities.trigger_event(_entity, 'set_position', x=x, y=y) entities.trigger_event(_entity, 'create_holder', name='weapon', max_weight=10) entities.trigger_event(_entity, 'create_holder', name='backpack', max_weight=10) return _entity
def _create_node(entity, x, y, draw_path=False, passive=True, action_time=0, name='Node', callback_on_touch=True): global LAST_CLICKED_POS _path_index = -1 if LAST_CLICKED_POS: _node_positions = [(p['node']['x'], p['node']['y']) for p in entity['node_grid']['nodes'].values() if not p['node']['name'] == chr(31)] for node_id in entity['node_grid']['path'][:]: _last_node = entity['node_grid']['nodes'][node_id] if LAST_CLICKED_POS in _last_node['node']['path']: _move_cost = 0 for pos in _last_node['node']['path'][ _last_node['node']['path'].index(LAST_CLICKED_POS):]: _move_cost += movement.get_move_cost(entity) if _move_cost < action_time and pos in _node_positions: return _path_index = entity['node_grid']['path'].index(node_id) entity['node_grid']['nodes'][entity['node_grid']['path'][ _path_index]]['node']['action_time'] = action_time break LAST_CLICKED_POS = None _node = entities.create_entity(group='nodes') _node['x'] = x _node['y'] = y _node['name'] = name _node['draw_path'] = draw_path _node['path'] = [] _node['owner_id'] = entity['_id'] _node['action_time'] = action_time _node['busy_pos'] = [] tile.register(_node, surface='nodes') entities.trigger_event(_node, 'set_position', x=x, y=y) if _path_index == -1: _path_index = len(entity['node_grid']['path']) entity['node_grid']['nodes'][_node['_id']] = { 'node': _node, 'passive': passive, 'callback': None, 'call_on_touch': callback_on_touch } entity['node_grid']['path'].insert(_path_index, _node['_id']) return _node
def _create_human(x, y, health, speed, name, vision=50, faction='Rogues', is_player=False, has_ai=False, fore_color=(255, 255, 255)): _entity = entities.create_entity(group='life') entities.create_event(_entity, 'get_and_store_item') entities.create_event(_entity, 'get_and_hold_item') entities.create_event(_entity, 'reload') entities.create_event(_entity, 'shoot') entities.create_event(_entity, 'damage') entities.create_event(_entity, 'did_damage') entities.create_event(_entity, 'receive_memory') entities.create_event(_entity, 'handle_corpse') entities.create_event(_entity, 'finish_turn') tile.register(_entity, surface='life', char='@', fore_color=fore_color) movement.register(_entity, collisions=True) timers.register(_entity) stats.register(_entity, health, speed, vision, name=name, kind='human') nodes.register(_entity) items.register(_entity) flags.register(_entity) noise.register(_entity) missions.register(_entity) skeleton.register(_entity) skeleton.create_motion(_entity, 'stand') skeleton.create_motion(_entity, 'crouch', stat_mod={'mobility': 1.55}) skeleton.create_motion(_entity, 'crawl', stat_mod={'mobility': 2.3}) skeleton.create_limb(_entity, 'head', [], True, 0.1, stat_mod={'vision': .75}) skeleton.create_limb(_entity, 'chest', ['head'], True, 0.88, stat_mod={'mobility': .1}) skeleton.create_limb(_entity, 'torso', ['chest'], True, 0.75, stat_mod={'mobility': .6}) skeleton.create_limb(_entity, 'left arm', ['chest'], False, 0.3, can_sever=True, stat_mod={'accuracy': .22}) skeleton.create_limb(_entity, 'right arm', ['chest'], False, 0.3, can_sever=True, stat_mod={'accuracy': .22}) skeleton.create_limb(_entity, 'left leg', ['torso'], False, 0.45, can_sever=True, stat_mod={'mobility': .4}) skeleton.create_limb(_entity, 'right leg', ['torso'], False, 0.45, can_sever=True, stat_mod={'mobility': .4}) if has_ai: ai.register_human(_entity) ai_factions.register(_entity, faction) _entity['ai']['is_player'] = is_player _entity['ai']['is_npc'] = not is_player if faction == 'Rogues': entities.register_event( _entity, 'did_damage', lambda e, target_id, damage: effects. printer(entities.get_entity(target_id)['tile']['x'], entities.get_entity(target_id)['tile']['y'] - 1, '%s' % damage, fore_color=(200, 0, 0), speed_mod=0.3, show_mod=1.0, moving=True, center=True)) entities.register_event( _entity, 'log_kill', lambda e, target_id: effects.printer( entities.get_entity(target_id)['tile']['x'], entities.get_entity(target_id)['tile']['y'] - 1, 'KILL', fore_color=(255, 0, 0), speed_mod=0.3, show_mod=1.0, moving=True, center=True)) entities.register_event(_entity, 'finish_turn', finish_turn) entities.register_event(_entity, 'post_tick', ai_visuals.cleanup) entities.register_event(_entity, 'get_and_store_item', get_and_store_item) entities.register_event(_entity, 'get_and_hold_item', get_and_hold_item) entities.register_event(_entity, 'reload', reload_weapon) entities.register_event(_entity, 'shoot', shoot_weapon) entities.register_event(_entity, 'heard_noise', handle_heard_noise) entities.register_event( _entity, 'position_changed', lambda e, **kwargs: entities. trigger_event(e, 'create_noise', volume=25, text='?', callback=lambda t, x, y: entities.trigger_event( t, 'update_target_memory', target_id=_entity['_id'], key='last_seen_at', value=[x, y]))) #entities.register_event(_entity, 'damage', # lambda e, **kwargs: entities.trigger_event(e, # 'create_noise', # volume=12, # text='Ow!', # owner_can_hear=True, # show_on_sight=True, # callback=lambda t, x, y: entities.trigger_event(t, # 'update_target_memory', # target_id=_entity['_id'], # key='last_seen_at', # value=[x, y]))) #entities.register_event(_entity, 'position_changed', lambda e, **kwargs: ai_visuals.add_to_moved_life(e)) entities.register_event(_entity, 'push', lambda e, **kwargs: movement.sub_move_cost(e)) entities.trigger_event(_entity, 'set_position', x=x, y=y) entities.trigger_event(_entity, 'create_holder', name='weapon', max_weight=10) entities.trigger_event(_entity, 'create_holder', name='backpack', max_weight=10) _get_and_hold_item(_entity, items.leather_backpack(20, 20)['_id']) return _entity
def _create_robot(x, y, health, speed, name, vision=30, faction='Rogues', is_player=False, has_ai=True, fore_color=(200, 200, 200)): _entity = entities.create_entity(group='life') entities.create_event(_entity, 'get_and_store_item') entities.create_event(_entity, 'get_and_hold_item') entities.create_event(_entity, 'reload') entities.create_event(_entity, 'shoot') entities.create_event(_entity, 'damage') entities.create_event(_entity, 'did_damage') entities.create_event(_entity, 'receive_memory') entities.create_event(_entity, 'handle_corpse') entities.create_event(_entity, 'finish_turn') tile.register(_entity, surface='life', char='@', fore_color=fore_color) movement.register(_entity, collisions=True) timers.register(_entity) stats.register(_entity, health, speed, vision, name=name, kind='human') nodes.register(_entity) items.register(_entity) flags.register(_entity) noise.register(_entity) missions.register(_entity) skeleton.register(_entity) if has_ai: ai.register_robot(_entity) ai_factions.register(_entity, faction) _entity['ai']['is_player'] = is_player _entity['ai']['is_npc'] = not is_player if is_player: entities.register_event( _entity, 'did_damage', lambda e, target_id, damage: effects. printer(entities.get_entity(target_id)['tile']['x'], entities.get_entity(target_id)['tile']['y'] - 1, '%s' % damage, fore_color=(200, 0, 0), speed_mod=0.3, show_mod=1.0, moving=True, center=True)) entities.register_event( _entity, 'log_kill', lambda e, target_id: effects.printer( entities.get_entity(target_id)['tile']['x'], entities.get_entity(target_id)['tile']['y'] - 1, 'KILL', fore_color=(255, 0, 0), speed_mod=0.3, show_mod=1.0, moving=True, center=True)) entities.register_event(_entity, 'delete', _handle_robot_death) entities.register_event(_entity, 'finish_turn', finish_turn) entities.register_event(_entity, 'post_tick', ai_visuals.cleanup) entities.register_event(_entity, 'get_and_store_item', get_and_store_item) entities.register_event(_entity, 'get_and_hold_item', get_and_hold_item) entities.register_event(_entity, 'reload', reload_weapon) entities.register_event(_entity, 'shoot', shoot_weapon) entities.register_event(_entity, 'heard_noise', handle_heard_noise) entities.register_event( _entity, 'position_changed', lambda e, **kwargs: entities. trigger_event(e, 'create_noise', volume=25, text='?', callback=lambda t, x, y: entities.trigger_event( t, 'update_target_memory', target_id=_entity['_id'], key='last_seen_at', value=[x, y]))) entities.register_event(_entity, 'push', lambda e, **kwargs: movement.sub_move_cost(e)) entities.trigger_event(_entity, 'set_position', x=x, y=y) entities.trigger_event(_entity, 'create_holder', name='weapon', max_weight=10) entities.trigger_event(_entity, 'create_holder', name='backpack', max_weight=10) _get_and_hold_item(_entity, items.leather_backpack(20, 20)['_id']) return _entity