Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
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
Exemple #4
0
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