#initialize my team at start of round (it will be assigned again at next round's first death)
(assign, "$my_team_at_start_of_round", -1),
#clear scene and end round
(multiplayer_clear_scene),
(call_script, "script_multiplayer_initialize_belfry_wheel_rotations"),
(try_begin),
(eq, "$g_battle_death_mode_started", 2),
(call_script, "script_move_death_mode_flags_down"),
(try_end),
(assign, "$g_battle_death_mode_started", 0),
(assign, "$g_reduced_waiting_seconds", 0),
#initialize moveable object positions
(call_script, "script_multiplayer_close_gate_if_it_is_open"),
(call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
(assign, "$g_round_ended", 0),
(assign, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1"),
(assign, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2"),
(store_mission_timer_a, "$g_round_start_time"),
(call_script, "script_initialize_all_scene_prop_slots"),
#initialize round start times for clients
(get_max_players, ":num_players"),
(try_for_range, ":player_no", 0, ":num_players"),
(player_is_active, ":player_no"),
(multiplayer_send_int_to_player, ":player_no", multiplayer_event_set_round_start_time, -9999), #this will also initialize moveable object slots.
(try_end),
]),
(0, 0, 0, [], #if there is nobody in any teams do not reduce round time.
[
#(multiplayer_is_server),
(assign, ":human_agents_spawned_at_team_1", "$g_multiplayer_num_bots_team_1"),
(assign, ":human_agents_spawned_at_team_2", "$g_multiplayer_num_bots_team_2"),
(get_max_players, ":num_players"),
(try_for_range, ":player_no", 0, ":num_players"),
(player_is_active, ":player_no"),
(player_get_team_no, ":player_team", ":player_no"),
(try_begin),
(eq, ":player_team", 0),
(val_add, ":human_agents_spawned_at_team_1", 1),
(else_try),
(eq, ":player_team", 1),
(val_add, ":human_agents_spawned_at_team_2", 1),
(try_end),
(try_end),
(try_begin),
(this_or_next|eq, ":human_agents_spawned_at_team_1", 0),
(eq, ":human_agents_spawned_at_team_2", 0),
(store_mission_timer_a, ":seconds_past_since_round_started"),
(val_sub, ":seconds_past_since_round_started", "$g_round_start_time"),
(le, ":seconds_past_since_round_started", 2),
(store_mission_timer_a, "$g_round_start_time"),
(try_end),
]),
(1, 0, 0, [],
[
(multiplayer_is_server),
(get_max_players, ":num_players"),
(try_for_range, ":player_no", 0, ":num_players"),
(player_is_active, ":player_no"),
(neg|player_is_busy_with_menus, ":player_no"),
(try_begin),
(player_slot_eq, ":player_no", slot_player_spawned_this_round, 0),
(player_get_team_no, ":player_team", ":player_no"), #if player is currently spectator do not spawn his agent
(lt, ":player_team", multi_team_spectator),
(player_get_troop_id, ":player_troop", ":player_no"), #if troop is not selected do not spawn his agent
(ge, ":player_troop", 0),
(assign, ":spawn_new", 0),
(assign, ":num_active_players_in_team_0", 0),
(assign, ":num_active_players_in_team_1", 0),
(try_begin),
(assign, ":num_active_players", 0),
(get_max_players, ":num_players"),
(try_for_range, ":player_no_2", 0, ":num_players"),
(player_is_active, ":player_no_2"),
(val_add, ":num_active_players", 1),
(player_get_team_no, ":player_team_2", ":player_no_2"),
(try_begin),
(eq, ":player_team_2", 0),
(val_add, ":num_active_players_in_team_0", 1),
(else_try),
(eq, ":player_team_2", 1),
(val_add, ":num_active_players_in_team_1", 1),
(try_end),
(try_end),
(store_mul, ":multipication_of_num_active_players_in_teams", ":num_active_players_in_team_0", ":num_active_players_in_team_1"),
(store_mission_timer_a, ":round_time"),
(val_sub, ":round_time", "$g_round_start_time"),
(this_or_next|lt, ":round_time", multiplayer_new_agents_finish_spawning_time),
(this_or_next|le, ":num_active_players", 2),
(eq, ":multipication_of_num_active_players_in_teams", 0),
(eq, "$g_round_ended", 0),
(assign, ":spawn_new", 1),
(try_end),
(eq, ":spawn_new", 1),
(try_begin),
(eq, ":player_team", 0),
(assign, ":entry_no", multi_initial_spawn_point_team_1),
(else_try),
(eq, ":player_team", 1),
(assign, ":entry_no", multi_initial_spawn_point_team_2),
(try_end),
(call_script, "script_multiplayer_buy_agent_equipment", ":player_no"),
(player_spawn_new_agent, ":player_no", ":entry_no"),
(player_set_slot, ":player_no", slot_player_spawned_this_round, 1),
(else_try), #spawning as a bot (if option ($g_multiplayer_player_respawn_as_bot) is 1)
(eq, "$g_multiplayer_player_respawn_as_bot", 1),
(player_get_agent_id, ":player_agent", ":player_no"),
(ge, ":player_agent", 0),
(neg|agent_is_alive, ":player_agent"),
(agent_get_time_elapsed_since_removed, ":elapsed_time", ":player_agent"),
(gt, ":elapsed_time", "$g_multiplayer_respawn_period"),
(player_get_team_no, ":player_team", ":player_no"),
(assign, ":is_found", 0),
(try_for_agents, ":cur_agent"),
(eq, ":is_found", 0),
(agent_is_alive, ":cur_agent"),
(agent_is_human, ":cur_agent"),
(agent_is_non_player, ":cur_agent"),
(agent_get_team ,":cur_team", ":cur_agent"),
(eq, ":cur_team", ":player_team"),
(assign, ":is_found", 1),
#(player_control_agent, ":player_no", ":cur_agent"),
(try_end),
(try_begin),
(eq, ":is_found", 1),
(call_script, "script_find_most_suitable_bot_to_control", ":player_no"),
(player_control_agent, ":player_no", reg0),
(player_get_slot, ":num_spawns", ":player_no", slot_player_spawned_this_round),
(val_add, ":num_spawns", 1),
(player_set_slot, ":player_no", slot_player_spawned_this_round, ":num_spawns"),
(try_end),
(try_end),
(try_end),
]),
multiplayer_server_spawn_bots,
multiplayer_server_manage_bots,
multiplayer_server_check_end_map,