Ejemplo n.º 1
0
def handle_player_end_of_turn(entity, squad_id):
	_squad = ai_squads.get_assigned_squad(entity)
	
	if not _squad:
		return
	
	if _squad['_id'] == squad_id:
		settings.set_tick_mode('normal')
		
		return False
Ejemplo n.º 2
0
def handle_player_end_of_turn(entity, squad_id):
    _squad = ai_squads.get_assigned_squad(entity)

    if not _squad:
        return

    if _squad['_id'] == squad_id:
        settings.set_tick_mode('normal')

        return False
Ejemplo n.º 3
0
def handle_start_of_turn(entity, squad_id):
	update_combat_risk(entity)
	update_group_status(entity)
	entities.trigger_event(entity, 'update_position_map')
	
	if entity['faction'] == 'Rogues':
		settings.set_tick_mode('strategy')
	
	else:
		settings.set_tick_mode('normal')
Ejemplo n.º 4
0
def handle_start_of_turn(entity, squad_id):
    update_combat_risk(entity)
    update_group_status(entity)
    entities.trigger_event(entity, 'update_position_map')

    if entity['faction'] == 'Rogues':
        settings.set_tick_mode('strategy')

    else:
        settings.set_tick_mode('normal')
Ejemplo n.º 5
0
def handle_movement_order(x, y):
	global WALK_PATH, WALK_DEST
	
	if not is_squad_member_selected() or (x, y) in zones.get_active_solids({}, ignore_calling_entity=True):
		return False
	
	_entity = get_selected_squad_member()
	
	movement.walk_to_position(_entity, x, y, zones.get_active_astar_map(), zones.get_active_weight_map())
	
	WALK_PATH = _entity['movement']['path']['positions']
	WALK_DEST = _entity['movement']['path']['destination']
	
	settings.set_tick_mode('normal')
	
	return True
Ejemplo n.º 6
0
def handle_movement_order(x, y):
    global WALK_PATH, WALK_DEST

    if not is_squad_member_selected() or (x, y) in zones.get_active_solids(
        {}, ignore_calling_entity=True):
        return False

    _entity = get_selected_squad_member()

    movement.walk_to_position(_entity, x, y, zones.get_active_astar_map(),
                              zones.get_active_weight_map())

    WALK_PATH = _entity['movement']['path']['positions']
    WALK_DEST = _entity['movement']['path']['destination']

    settings.set_tick_mode('normal')

    return True
Ejemplo n.º 7
0
def handle_player_start_of_turn(entity, squad_id):
	if ai_squads.get_assigned_squad(entity)['_id'] == squad_id:
		settings.set_tick_mode('strategy')
	
		_squad = entities.get_entity(squad_id)
		
		if not ai_factions.is_enemy(entity, _squad['leader']) and entity['_id'] == _squad['leader']:
			if _squad['meta']['is_squad_combat_ready']:
				_message = random.choice(['Locked and loaded.',
					                      'Nuke \'em!',
					                      'No mercy, boys...'])
			
			elif _squad['meta']['is_squad_overwhelmed']:
				_message = random.choice(['We\'re outnumbered!',
					                      'Fall back!'])
				
			else:
				return
			
			effects.message(_message, time=120, center=True)
Ejemplo n.º 8
0
def handle_player_start_of_turn(entity, squad_id):
    if ai_squads.get_assigned_squad(entity)['_id'] == squad_id:
        settings.set_tick_mode('strategy')

        _squad = entities.get_entity(squad_id)

        if not ai_factions.is_enemy(
                entity,
                _squad['leader']) and entity['_id'] == _squad['leader']:
            if _squad['meta']['is_squad_combat_ready']:
                _message = random.choice(
                    ['Locked and loaded.', 'Nuke \'em!', 'No mercy, boys...'])

            elif _squad['meta']['is_squad_overwhelmed']:
                _message = random.choice(['We\'re outnumbered!', 'Fall back!'])

            else:
                return

            effects.message(_message, time=120, center=True)
Ejemplo n.º 9
0
def handle_keyboard_input():
	global SELECTED_SQUAD_MEMBER, WALK_PATH, WALK_DEST
	
	#TODO: Check for multiple movement changes at this location
	if not is_squad_member_selected():
		return
	
	_entity = get_selected_squad_member()
	_x, _y = movement.get_position(_entity)
	
	if timers.has_timer_with_name(_entity, 'passout'):
		return
	
	if controls.get_input_char_pressed('z'):
		entities.trigger_event(_entity, 'set_motion', motion='crawl')
		settings.set_tick_mode('normal')
	
	elif controls.get_input_char_pressed('x'):
		entities.trigger_event(_entity, 'set_motion', motion='crouch')
		settings.set_tick_mode('normal')
	
	elif controls.get_input_char_pressed('c'):
		entities.trigger_event(_entity, 'set_motion', motion='stand')
		settings.set_tick_mode('normal')
	
	elif controls.get_input_char_pressed(' '):
		_entity['stats']['action_points'] = 0
		SELECTED_SQUAD_MEMBER = None
		WALK_DEST = None
		WALK_PATH = []
		_broken = False
		
		for squad_id in entities.get_entity_group('squads'):
			_squad = entities.get_entity(squad_id)
			
			if not _squad['faction'] == 'Rogues':
				continue
		
			for entity_id in _squad['members']:
				_entity = entities.get_entity(entity_id)
				
				if _entity['stats']['action_points'] > 0:
					_broken = True
					break
			
			if _broken:
				break
		
		else:
			settings.set_tick_mode('normal')
Ejemplo n.º 10
0
def handle_keyboard_input():
    global SELECTED_SQUAD_MEMBER, WALK_PATH, WALK_DEST

    #TODO: Check for multiple movement changes at this location
    if not is_squad_member_selected():
        return

    _entity = get_selected_squad_member()
    _x, _y = movement.get_position(_entity)

    if timers.has_timer_with_name(_entity, 'passout'):
        return

    if controls.get_input_char_pressed('z'):
        entities.trigger_event(_entity, 'set_motion', motion='crawl')
        settings.set_tick_mode('normal')

    elif controls.get_input_char_pressed('x'):
        entities.trigger_event(_entity, 'set_motion', motion='crouch')
        settings.set_tick_mode('normal')

    elif controls.get_input_char_pressed('c'):
        entities.trigger_event(_entity, 'set_motion', motion='stand')
        settings.set_tick_mode('normal')

    elif controls.get_input_char_pressed(' '):
        _entity['stats']['action_points'] = 0
        SELECTED_SQUAD_MEMBER = None
        WALK_DEST = None
        WALK_PATH = []
        _broken = False

        for squad_id in entities.get_entity_group('squads'):
            _squad = entities.get_entity(squad_id)

            if not _squad['faction'] == 'Rogues':
                continue

            for entity_id in _squad['members']:
                _entity = entities.get_entity(entity_id)

                if _entity['stats']['action_points'] > 0:
                    _broken = True
                    break

            if _broken:
                break

        else:
            settings.set_tick_mode('normal')
Ejemplo n.º 11
0
def create_shoot_menu(entity, target_id):
    _tx, _ty = movement.get_position_via_id(target_id)
    _weapon = entities.get_entity(
        items.get_items_in_holder(entity, 'weapon')[0])
    _menu = ui_menu.create(_tx - camera.X + 2,
                           _ty - camera.Y - 4,
                           title='Shoot')
    _accuracy = stats.get_accuracy(entity, _weapon['_id'])
    _x, _y = movement.get_position(entity)
    _direction = numbers.direction_to((_x, _y), (_tx, _ty))
    _final_direction = _direction + (_accuracy * numbers.distance((_x, _y),
                                                                  (_tx, _ty)))
    _spray_accuracy = (100 * (_direction / float(_final_direction)))

    entities.trigger_event(_weapon, 'get_actions', menu=_menu)
    ui_menu.add_selectable(
        _menu, 'Spray (Acc: %.2d)' % _spray_accuracy,
        lambda: entities.trigger_event(entity, 'shoot', target_id=target_id
                                       ) and settings.set_tick_mode('normal'))
    ui_menu.add_selectable(_menu, 'Snipe (Acc: %s)' % _accuracy, lambda: _)
Ejemplo n.º 12
0
def create_shoot_menu(entity, target_id):
	_tx, _ty = movement.get_position_via_id(target_id)
	_weapon = entities.get_entity(items.get_items_in_holder(entity, 'weapon')[0])
	_menu = ui_menu.create(_tx-camera.X+2, _ty-camera.Y-4, title='Shoot')
	_accuracy = stats.get_accuracy(entity, _weapon['_id'])
	_x, _y = movement.get_position(entity)
	_direction = numbers.direction_to((_x, _y), (_tx, _ty))
	_final_direction = _direction + (_accuracy * numbers.distance((_x, _y), (_tx, _ty)))
	_spray_accuracy = (100 * (_direction / float(_final_direction)))
	
	entities.trigger_event(_weapon, 'get_actions', menu=_menu)
	ui_menu.add_selectable(_menu, 'Spray (Acc: %.2d)' % _spray_accuracy, lambda: entities.trigger_event(entity, 'shoot', target_id=target_id) and settings.set_tick_mode('normal'))
	ui_menu.add_selectable(_menu, 'Snipe (Acc: %s)' % _accuracy, lambda: _)
Ejemplo n.º 13
0
def tick():
    if settings.TURN_QUEUE:
        _squads = [settings.TURN_QUEUE[0]]

    else:
        _squads = entities.get_entity_group('squads')
        _found_able_player = False

        for squad_id in entities.get_entity_group('squads'):
            _squad = entities.get_entity(squad_id)
            _break = False

            if not _squad['faction'] == 'Rogues':
                continue

            for member_id in _squad['members']:
                _entity = entities.get_entity(member_id)

                if _entity['ai']['is_npc']:
                    continue

                if timers.has_timer_with_name(
                        _entity, 'shoot') or _entity['movement']['path'][
                            'positions'] or timers.has_timer_with_name(
                                _entity, 'move'):
                    _break = True

                    break

                _found_able_player = True

            if _break:
                break

        else:
            if _found_able_player:
                settings.set_tick_mode('strategy')

    for squad_id in _squads:
        _squad = entities.get_entity(squad_id)
        _waiting = False

        #if not _squad['faction'] == 'Rogues':
        #	settings.set_tick_mode('normal')

        for entity_id in _squad['members']:
            _entity = entities.get_entity(entity_id)

            if not settings.TURN_QUEUE:
                _entity['stats']['action_points'] = _entity['stats'][
                    'action_points_max']

                if _entity['ai']['is_npc']:
                    continue

            if _entity['stats']['action_points'] <= 0:
                continue

            _had_action = False

            if timers.has_timer_with_name(
                    _entity, 'shoot') or _entity['movement']['path'][
                        'positions'] or timers.has_timer_with_name(
                            _entity, 'move'):
                _had_action = True

            elif _entity['ai']['is_player']:
                _waiting = True

                continue

            entities.trigger_event(_entity, 'tick')

            if _had_action and not timers.has_timer_with_name(
                    _entity, 'shoot') and not _entity['movement']['path'][
                        'positions'] and not timers.has_timer_with_name(
                            _entity,
                            'move') and _entity['stats']['action_points'] > 0:
                if _entity['ai']['is_player'] and (
                        ui_squad_control.is_squad_member_selected() and _entity
                        == ui_squad_control.get_selected_squad_member()):
                    settings.set_tick_mode('strategy')

                    break

            if _entity['ai'][
                    'is_player'] and _entity['stats']['action_points'] <= 0:
                ui_squad_control.reset_selected_squad_member()
                settings.set_tick_mode('strategy')

            if not _entity['movement']['path'][
                    'positions'] and not timers.has_timer_with_name(
                        _entity, 'shoot') and not timers.has_timer_with_name(
                            _entity, 'move'):
                _entity['stats']['action_points'] -= constants.IDLE_COST

            if _entity['stats'][
                    'action_points'] <= 0:  # and list(_squad['members']).index(entity_id)+1 == len(_squad['members']):
                entities.trigger_event(_squad, 'update_position_map')

            #print _entity['stats']['name'], _entity['stats']['action_points']

            break

        else:
            if _entity['ai']['is_player'] and not _waiting:
                settings.set_tick_mode('normal')
                print 'Normal...'
Ejemplo n.º 14
0
def tick():
	if settings.TURN_QUEUE:
		_squads = [settings.TURN_QUEUE[0]]
	
	else:
		_squads = entities.get_entity_group('squads')
		_found_able_player = False
		
		for squad_id in entities.get_entity_group('squads'):
			_squad = entities.get_entity(squad_id)
			_break = False
			
			if not _squad['faction'] == 'Rogues':
				continue
			
			for member_id in _squad['members']:
				_entity = entities.get_entity(member_id)
				
				if _entity['ai']['is_npc']:
					continue
				
				if timers.has_timer_with_name(_entity, 'shoot') or _entity['movement']['path']['positions'] or timers.has_timer_with_name(_entity, 'move'):
					_break = True
					
					break
				
				_found_able_player = True
			
			if _break:
				break
		
		else:
			if _found_able_player:
				settings.set_tick_mode('strategy')
	
	for squad_id in _squads:
		_squad = entities.get_entity(squad_id)
		_waiting = False
		
		#if not _squad['faction'] == 'Rogues':
		#	settings.set_tick_mode('normal')
		
		for entity_id in _squad['members']:
			_entity = entities.get_entity(entity_id)
			
			if not settings.TURN_QUEUE:
				_entity['stats']['action_points'] = _entity['stats']['action_points_max']
				
				if _entity['ai']['is_npc']:
					continue
			
			if _entity['stats']['action_points'] <= 0:
				continue
			
			_had_action = False
			
			if timers.has_timer_with_name(_entity, 'shoot') or _entity['movement']['path']['positions'] or timers.has_timer_with_name(_entity, 'move'):
				_had_action = True
			
			elif _entity['ai']['is_player']:
				_waiting = True
				
				continue
			
			entities.trigger_event(_entity, 'tick')
			
			if _had_action and not timers.has_timer_with_name(_entity, 'shoot') and not _entity['movement']['path']['positions'] and not timers.has_timer_with_name(_entity, 'move') and _entity['stats']['action_points'] > 0:
				if _entity['ai']['is_player'] and (ui_squad_control.is_squad_member_selected() and _entity == ui_squad_control.get_selected_squad_member()):
					settings.set_tick_mode('strategy')
					
					break
			
			if _entity['ai']['is_player'] and _entity['stats']['action_points'] <= 0:
				ui_squad_control.reset_selected_squad_member()
				settings.set_tick_mode('strategy')
			
			if not _entity['movement']['path']['positions'] and not timers.has_timer_with_name(_entity, 'shoot') and not timers.has_timer_with_name(_entity, 'move'):
				_entity['stats']['action_points'] -= constants.IDLE_COST
			
			if _entity['stats']['action_points'] <= 0:# and list(_squad['members']).index(entity_id)+1 == len(_squad['members']):
				entities.trigger_event(_squad, 'update_position_map')
			
			#print _entity['stats']['name'], _entity['stats']['action_points']
			
			break
		
		else:
			if _entity['ai']['is_player'] and not _waiting:
				settings.set_tick_mode('normal')
				print 'Normal...'