Пример #1
0
def setup_failure_freeplay(setup_manager: SetupManager,
                           message: str,
                           color_key="red"):
    setup_manager.shut_down()
    match_config = MatchConfig()
    match_config.game_mode = game_mode_types[0]
    match_config.game_map = "BeckwithPark"
    match_config.enable_rendering = True

    mutators = MutatorConfig()
    mutators.match_length = match_length_types[3]
    match_config.mutators = mutators

    match_config.player_configs = []

    setup_manager.load_match_config(match_config)
    setup_manager.start_match()

    # wait till num players is 0
    wait_till_cars_spawned(setup_manager, 0)

    color = getattr(setup_manager.game_interface.renderer, color_key)()
    setup_manager.game_interface.renderer.begin_rendering(RENDERING_GROUP)
    # setup_manager.game_interface.renderer.draw_rect_2d(20, 20, 800, 800, True, setup_manager.game_interface.renderer.black())
    setup_manager.game_interface.renderer.draw_string_2d(
        20, 200, 4, 4, message, color)
    setup_manager.game_interface.renderer.end_rendering()
Пример #2
0
def make_match_config(challenge: dict, upgrades: dict,
                      player_configs: List[PlayerConfig],
                      script_configs: List[ScriptConfig]):
    """Setup the match, following the challenge rules and user's upgrades
    """
    match_config = MatchConfig()
    match_config.mutators = MutatorConfig()

    match_config.game_mode = game_mode_types[0]  # Soccar
    match_config.game_map = challenge.get("map")
    match_config.enable_state_setting = True

    for script_config in script_configs:
        script_config_bundle = get_script_config_bundle(
            script_config.config_path)
        script_class_wrapper = import_class_with_base(
            script_config_bundle.script_file, BaseStoryScript)
        script_class = script_class_wrapper.get_loaded_class()
        if "edit_match_config" in dir(script_class):
            enabled_upgrades = list(
                filter(lambda upgrade: upgrades[upgrade], upgrades.keys()))
            script_class.edit_match_config(match_config, challenge,
                                           enabled_upgrades)

    if DEBUG_MODE_SHORT_GAMES:
        match_config.mutators.max_score = "3 Goals"

    match_config.player_configs = player_configs
    match_config.script_configs = script_configs
    return match_config
Пример #3
0
def make_match_config(challenge: dict, upgrades: dict,
                      player_configs: List[PlayerConfig],
                      script_configs: List[ScriptConfig]):
    """Setup the match, following the challenge rules and user's upgrades
    """
    match_config = MatchConfig()

    match_config.game_mode = game_mode_types[0]  # Soccar
    if challenge.get("limitations", []).count("half-field"):
        match_config.game_mode = game_mode_types[5]  # Heatseeker
    match_config.game_map = challenge.get("map")
    match_config.enable_state_setting = True

    match_config.mutators = MutatorConfig()
    match_config.mutators.max_score = challenge.get("max_score")
    if DEBUG_MODE_SHORT_GAMES:
        match_config.mutators.max_score = "3 Goals"

    if challenge.get("disabledBoost"):
        match_config.mutators.boost_amount = boost_amount_mutator_types[
            4]  # No boost

    if "rumble" in upgrades:
        match_config.mutators.rumble = rumble_mutator_types[1]  # All rumble

    match_config.player_configs = player_configs
    match_config.script_configs = script_configs
    return match_config
Пример #4
0
 def set_pending_relaunch_config(self, active_bots: List[ActiveBot]):
     match_config = MatchConfig()
     match_config.player_configs = [player_config_from_active_bot(ab) for ab in active_bots]
     match_config.game_mode = 'Soccer'
     match_config.game_map = 'DFHStadium'
     match_config.existing_match_behavior = 'Continue And Spawn'
     match_config.mutators = MutatorConfig()
     self.requested_relaunch = match_config
Пример #5
0
def start_match_helper(bot_list: List[dict], match_settings: dict,
                       launcher_prefs: RocketLeagueLauncherPreference):
    print(bot_list)
    print(match_settings)

    match_config = MatchConfig()
    match_config.game_mode = match_settings['game_mode']
    match_config.game_map = match_settings['map']
    match_config.skip_replays = match_settings['skip_replays']
    match_config.instant_start = match_settings['instant_start']
    match_config.enable_lockstep = match_settings['enable_lockstep']
    match_config.enable_rendering = match_settings['enable_rendering']
    match_config.enable_state_setting = match_settings['enable_state_setting']
    match_config.auto_save_replay = match_settings['auto_save_replay']
    match_config.existing_match_behavior = match_settings['match_behavior']
    match_config.mutators = MutatorConfig()

    mutators = match_settings['mutators']
    match_config.mutators.match_length = mutators['match_length']
    match_config.mutators.max_score = mutators['max_score']
    match_config.mutators.overtime = mutators['overtime']
    match_config.mutators.series_length = mutators['series_length']
    match_config.mutators.game_speed = mutators['game_speed']
    match_config.mutators.ball_max_speed = mutators['ball_max_speed']
    match_config.mutators.ball_type = mutators['ball_type']
    match_config.mutators.ball_weight = mutators['ball_weight']
    match_config.mutators.ball_size = mutators['ball_size']
    match_config.mutators.ball_bounciness = mutators['ball_bounciness']
    match_config.mutators.boost_amount = mutators['boost_amount']
    match_config.mutators.rumble = mutators['rumble']
    match_config.mutators.boost_strength = mutators['boost_strength']
    match_config.mutators.gravity = mutators['gravity']
    match_config.mutators.demolish = mutators['demolish']
    match_config.mutators.respawn_time = mutators['respawn_time']

    human_index_tracker = IncrementingInteger(0)
    match_config.player_configs = [
        create_player_config(bot, human_index_tracker) for bot in bot_list
    ]
    match_config.script_configs = [
        create_script_config(script) for script in match_settings['scripts']
    ]

    sm = get_fresh_setup_manager()
    try:
        setup_match(sm, match_config, launcher_prefs)
    except Exception as e:
        print(e)
        eel.matchStartFailed(str(e))
        return

    # Note that we are not calling infinite_loop because that is not compatible with the way eel works!
    # Instead we will reproduce the important behavior from infinite_loop inside this file.
    eel.matchStarted()
Пример #6
0
def parse_match_config(config_parser: ConfigObject, config_location,
                       config_bundle_overrides,
                       looks_config_overrides) -> MatchConfig:

    match_config = MatchConfig()
    match_config.mutators = MutatorConfig()

    # Determine number of participants
    num_players = get_num_players(config_parser)

    parse_match_settings(match_config, config_parser)

    # Retrieve bot config files
    config_bundles = get_bot_config_bundles(num_players, config_parser,
                                            config_location,
                                            config_bundle_overrides)

    match_config.player_configs = []

    human_index_tracker = IncrementingInteger(0)

    # Set configuration values for bots and store name and team
    for i in range(num_players):

        config_bundle = config_bundles[i]

        looks_config_object = None
        if i in looks_config_overrides:
            looks_config_object = looks_config_overrides[i]

        player_config = _load_bot_config(i, config_bundle, looks_config_object,
                                         config_parser, human_index_tracker)

        match_config.player_configs.append(player_config)

    extension_path = config_parser.get(RLBOT_CONFIGURATION_HEADER,
                                       EXTENSION_PATH_KEY)
    if extension_path and extension_path != 'None':  # The string 'None' ends up in people's config a lot.
        match_config.extension_config = ExtensionConfig()
        match_config.extension_config.python_file_path = extension_path

    match_config.networking_role = config_parser.get(
        RLBOT_CONFIGURATION_HEADER, NETWORKING_ROLE_KEY)
    match_config.network_address = config_parser.get(
        RLBOT_CONFIGURATION_HEADER, NETWORK_ADDRESS_KEY)

    match_config.script_configs = [
        ScriptConfig(bundle.config_path)
        for bundle in get_script_config_bundles(config_parser, config_location)
    ]

    return match_config
Пример #7
0
def start_match_helper(bot_list, match_settings):
    print(bot_list)
    print(match_settings)

    match_config = MatchConfig()
    match_config.game_mode = match_settings['game_mode']
    match_config.game_map = match_settings['map']
    match_config.skip_replays = match_settings['skip_replays']
    match_config.instant_start = match_settings['instant_start']
    match_config.enable_lockstep = match_settings['enable_lockstep']
    match_config.enable_rendering = match_settings['enable_rendering']
    match_config.enable_state_setting = match_settings['enable_state_setting']
    match_config.auto_save_replay = match_settings['auto_save_replay']
    match_config.existing_match_behavior = match_settings['match_behavior']
    match_config.mutators = MutatorConfig()

    mutators = match_settings['mutators']
    match_config.mutators.match_length = mutators['match_length']
    match_config.mutators.max_score = mutators['max_score']
    match_config.mutators.overtime = mutators['overtime']
    match_config.mutators.series_length = mutators['series_length']
    match_config.mutators.game_speed = mutators['game_speed']
    match_config.mutators.ball_max_speed = mutators['ball_max_speed']
    match_config.mutators.ball_type = mutators['ball_type']
    match_config.mutators.ball_weight = mutators['ball_weight']
    match_config.mutators.ball_size = mutators['ball_size']
    match_config.mutators.ball_bounciness = mutators['ball_bounciness']
    match_config.mutators.boost_amount = mutators['boost_amount']
    match_config.mutators.rumble = mutators['rumble']
    match_config.mutators.boost_strength = mutators['boost_strength']
    match_config.mutators.gravity = mutators['gravity']
    match_config.mutators.demolish = mutators['demolish']
    match_config.mutators.respawn_time = mutators['respawn_time']

    human_index_tracker = IncrementingInteger(0)
    match_config.player_configs = [create_player_config(bot, human_index_tracker) for bot in bot_list]
    match_config.script_configs = [create_script_config(script) for script in match_settings['scripts']]

    global sm
    if sm is not None:
        try:
            sm.shut_down()
        except Exception as e:
            print(e)

    sm = SetupManager()
    sm.early_start_seconds = 5
    sm.connect_to_game()
    sm.load_match_config(match_config)
    sm.launch_early_start_bot_processes()
    sm.start_match()
    sm.launch_bot_processes()
Пример #8
0
    def build_match_config(self, player_config_path: str):
        if self.player_config is None:
            self.player_config = self.create_player_config(player_config_path)

        match_config = MatchConfig()
        match_config.player_configs = [self.player_config]
        match_config.game_mode = 'Soccer'
        match_config.game_map = 'DFHStadium'
        match_config.existing_match_behavior = 'Continue And Spawn'
        match_config.mutators = MutatorConfig()
        match_config.enable_state_setting = True
        match_config.enable_rendering = True
        return match_config
Пример #9
0
def parse_match_config(config_parser: ConfigObject, config_location,
                       config_bundle_overrides,
                       looks_config_overrides) -> MatchConfig:

    match_config = MatchConfig()
    match_config.mutators = MutatorConfig()

    # Determine number of participants
    num_players = get_num_players(config_parser)

    parse_match_settings(match_config, config_parser)

    # Retrieve bot config files
    config_bundles = get_bot_config_bundles(num_players, config_parser,
                                            config_location,
                                            config_bundle_overrides)

    match_config.player_configs = []

    human_index_tracker = IncrementingInteger(0)

    # Set configuration values for bots and store name and team
    for i in range(num_players):

        config_bundle = config_bundles[i]

        if i not in looks_config_overrides:
            looks_config_object = config_bundle.get_looks_config()
        else:
            looks_config_object = looks_config_overrides[i]

        player_config = _load_bot_config(i, config_bundle, looks_config_object,
                                         config_parser, human_index_tracker)

        match_config.player_configs.append(player_config)

    for path in config_parser.get(BOTLESS_AGENT_CONFIGURATION_HEADER,
                                  BOTLESS_AGENT_PATH_KEY):
        if path != 'None':
            match_config.botless_agents.append(path)

    extension_path = config_parser.get(RLBOT_CONFIGURATION_HEADER,
                                       EXTENSION_PATH_KEY)
    if extension_path and extension_path != 'None':  # The string 'None' ends up in people's config a lot.
        match_config.extension_config = ExtensionConfig()
        match_config.extension_config.python_file_path = extension_path

    return match_config
Пример #10
0
def start_match_helper(bot_list, match_settings):
    print(bot_list)
    print(match_settings)
    num_participants = len(bot_list)

    match_config = MatchConfig()
    match_config.num_players = num_participants
    match_config.game_mode = match_settings['game_mode']
    match_config.game_map = match_settings['map']
    match_config.mutators = MutatorConfig()

    mutators = match_settings['mutators']
    match_config.mutators.match_length = mutators['match_length']
    match_config.mutators.max_score = mutators['max_score']
    match_config.mutators.overtime = mutators['overtime']
    match_config.mutators.series_length = mutators['series_length']
    match_config.mutators.game_speed = mutators['game_speed']
    match_config.mutators.ball_max_speed = mutators['ball_max_speed']
    match_config.mutators.ball_type = mutators['ball_type']
    match_config.mutators.ball_weight = mutators['ball_weight']
    match_config.mutators.ball_size = mutators['ball_size']
    match_config.mutators.ball_bounciness = mutators['ball_bounciness']
    match_config.mutators.boost_amount = mutators['boost_amount']
    match_config.mutators.rumble = mutators['rumble']
    match_config.mutators.boost_strength = mutators['boost_strength']
    match_config.mutators.gravity = mutators['gravity']
    match_config.mutators.demolish = mutators['demolish']
    match_config.mutators.respawn_time = mutators['respawn_time']

    human_index_tracker = IncrementingInteger(0)
    match_config.player_configs = [
        create_player_config(bot, human_index_tracker) for bot in bot_list
    ]

    global sm
    if sm is not None:
        try:
            sm.shut_down()
        except Exception as e:
            print(e)

    sm = SetupManager()
    sm.connect_to_game()
    sm.load_match_config(match_config)
    sm.launch_ball_prediction()
    sm.launch_quick_chat_manager()
    sm.launch_bot_processes()
    sm.start_match()
Пример #11
0
def start_match_helper(bot_list: List[dict], match_settings: dict,
                       launcher_prefs: RocketLeagueLauncherPreference):
    print(bot_list)
    print(match_settings)

    match_config = MatchConfig()
    match_config.game_mode = match_settings['game_mode']
    match_config.game_map = match_settings['map']
    match_config.skip_replays = match_settings['skip_replays']
    match_config.instant_start = match_settings['instant_start']
    match_config.enable_lockstep = match_settings['enable_lockstep']
    match_config.enable_rendering = match_settings['enable_rendering']
    match_config.enable_state_setting = match_settings['enable_state_setting']
    match_config.auto_save_replay = match_settings['auto_save_replay']
    match_config.existing_match_behavior = match_settings['match_behavior']
    match_config.mutators = MutatorConfig()

    mutators = match_settings['mutators']
    match_config.mutators.match_length = mutators['match_length']
    match_config.mutators.max_score = mutators['max_score']
    match_config.mutators.overtime = mutators['overtime']
    match_config.mutators.series_length = mutators['series_length']
    match_config.mutators.game_speed = mutators['game_speed']
    match_config.mutators.ball_max_speed = mutators['ball_max_speed']
    match_config.mutators.ball_type = mutators['ball_type']
    match_config.mutators.ball_weight = mutators['ball_weight']
    match_config.mutators.ball_size = mutators['ball_size']
    match_config.mutators.ball_bounciness = mutators['ball_bounciness']
    match_config.mutators.boost_amount = mutators['boost_amount']
    match_config.mutators.rumble = mutators['rumble']
    match_config.mutators.boost_strength = mutators['boost_strength']
    match_config.mutators.gravity = mutators['gravity']
    match_config.mutators.demolish = mutators['demolish']
    match_config.mutators.respawn_time = mutators['respawn_time']

    human_index_tracker = IncrementingInteger(0)
    match_config.player_configs = [
        create_player_config(bot, human_index_tracker) for bot in bot_list
    ]
    match_config.script_configs = [
        create_script_config(script) for script in match_settings['scripts']
    ]

    sm = get_fresh_setup_manager()
    setup_match(sm, match_config, launcher_prefs)
Пример #12
0
    def __init__(self):
        match_config = MatchConfig()
        match_config.game_mode = 'Soccer'
        match_config.game_map = 'Mannfield_Night'
        match_config.existing_match_behavior = 'Continue And Spawn'
        match_config.mutators = MutatorConfig()
        match_config.mutators.match_length = 'Unlimited'

        # there needs to be at least one bot for the match to start
        bot_config = PlayerConfig()
        bot_config.name = "Dummy"
        bot_config.team = 0
        bot_config.bot = True
        bot_config.rlbot_controlled = True
        match_config.player_configs = [bot_config]

        sm = SetupManager()
        sm.connect_to_game()
        sm.load_match_config(match_config)
        sm.start_match()
        self.game_interface: GameInterface = sm.game_interface
Пример #13
0
def spawn_car_in_showroom(loadout_config: LoadoutConfig, team: int, showcase_type: str, map_name: str,
                          launcher_prefs: RocketLeagueLauncherPreference):
    match_config = MatchConfig()
    match_config.game_mode = 'Soccer'
    match_config.game_map = map_name
    match_config.instant_start = True
    match_config.existing_match_behavior = 'Continue And Spawn'
    match_config.networking_role = NetworkingRole.none
    match_config.enable_state_setting = True
    match_config.skip_replays = True

    bot_config = PlayerConfig()
    bot_config.bot = True
    bot_config.rlbot_controlled = True
    bot_config.team = team
    bot_config.name = "Showroom"
    bot_config.loadout_config = loadout_config

    match_config.player_configs = [bot_config]
    match_config.mutators = MutatorConfig()
    match_config.mutators.boost_amount = 'Unlimited'
    match_config.mutators.match_length = 'Unlimited'

    global sm
    if sm is None:
        sm = SetupManager()
    sm.connect_to_game(launcher_preference=launcher_prefs)
    sm.load_match_config(match_config)
    sm.start_match()

    game_state = GameState(
        cars={0: CarState(physics=Physics(
            location=Vector3(0, 0, 20),
            velocity=Vector3(0, 0, 0),
            angular_velocity=Vector3(0, 0, 0),
            rotation=Rotator(0, 0, 0)
        ))},
        ball=BallState(physics=Physics(
            location=Vector3(0, 0, -100),
            velocity=Vector3(0, 0, 0),
            angular_velocity=Vector3(0, 0, 0)
        ))
    )
    player_input = PlayerInput()
    team_sign = -1 if team == 0 else 1

    if showcase_type == "boost":
        player_input.boost = True
        player_input.steer = 1
        game_state.cars[0].physics.location.y = -1140
        game_state.cars[0].physics.velocity.x = 2300
        game_state.cars[0].physics.angular_velocity.z = 3.5

    elif showcase_type == "throttle":
        player_input.throttle = 1
        player_input.steer = 0.56
        game_state.cars[0].physics.location.y = -1140
        game_state.cars[0].physics.velocity.x = 1410
        game_state.cars[0].physics.angular_velocity.z = 1.5

    elif showcase_type == "back-center-kickoff":
        game_state.cars[0].physics.location.y = 4608 * team_sign
        game_state.cars[0].physics.rotation.yaw = -0.5 * pi * team_sign

    elif showcase_type == "goal-explosion":
        game_state.cars[0].physics.location.y = -2000 * team_sign
        game_state.cars[0].physics.rotation.yaw = -0.5 * pi * team_sign
        game_state.cars[0].physics.velocity.y = -2300 * team_sign
        game_state.ball.physics.location = Vector3(0, -3500 * team_sign, 93)

    sm.game_interface.update_player_input(player_input, 0)
    sm.game_interface.set_game_state(game_state)