(
"training_ground_training", mtf_arena_fight, -1,
"Training.",
[
(0,mtef_visitor_source|mtef_team_0,af_override_everything,aif_start_alarmed,1,[itm_practice_staff]),
(1,mtef_visitor_source|mtef_team_1,af_override_everything,aif_start_alarmed,1,[itm_practice_staff]),
(2,mtef_visitor_source|mtef_team_1,af_override_everything,aif_start_alarmed,1,[itm_practice_staff]),
(3,mtef_visitor_source|mtef_team_1,af_override_everything,aif_start_alarmed,1,[itm_practice_staff]),
(4,mtef_visitor_source|mtef_team_1,af_override_everything,aif_start_alarmed,1,[itm_practice_staff]),
(8,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
(9,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
(10,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
(11,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
(12,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
(13,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
(14,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
(15,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
],
[
(ti_before_mission_start, 0, 0, [],
[
(assign, "$g_last_destroyed_gourds", 0),
(call_script, "script_change_banners_and_chest")]),
common_arena_fight_tab_press,
(ti_question_answered, 0, 0, [],
[
(store_trigger_param_1,":answer"),
(eq,":answer",0),
(assign, "$g_training_ground_training_success_ratio", 0),
(jump_to_menu, "mnu_training_ground_training_result"),
(finish_mission),
]),
common_inventory_not_available,
(0, 0, ti_once,
[
(try_begin),
(eq, "$g_mt_mode", ctm_ranged),
(set_fixed_point_multiplier, 100),
(entry_point_get_position, pos1, 0),
(init_position, pos2),
(position_set_y, pos2, "$g_training_ground_ranged_distance"),
(position_transform_position_to_parent, pos3, pos1, pos2),
(copy_position, pos1, pos3),
(assign, ":end_cond", 10),
(assign, ":shift_value", 0),
(try_for_range, ":cur_i", 0, ":end_cond"),
(store_sub, ":cur_instance", ":cur_i", ":shift_value"),
(scene_prop_get_instance, ":target_object", "spr_gourd", ":cur_instance"),
(copy_position, pos2, pos1),
(init_position, pos0),
(store_random_in_range, ":random_no", 0, 360),
(position_rotate_z, pos2, ":random_no"),
(store_random_in_range, ":random_no", 50, 600),
(position_move_x, pos2, ":random_no"),
(store_random_in_range, ":random_no", 0, 360),
(position_transform_position_to_local, pos3, pos1, pos2),
(position_rotate_z, pos0, ":random_no"),
(position_transform_position_to_parent, pos4, pos0, pos3),
(position_transform_position_to_parent, pos2, pos1, pos4),
(position_set_z_to_ground_level, pos2),
(position_move_z, pos2, 150),
(assign, ":valid", 1),
(try_for_range, ":cur_instance_2", 0, 10),
(eq, ":valid", 1),
(neq, ":cur_instance", ":cur_instance_2"),
(scene_prop_get_instance, ":target_object_2", "spr_gourd", ":cur_instance_2"),
(prop_instance_get_position, pos3, ":target_object_2"),
(get_distance_between_positions, ":dist", pos2, pos3),
(lt, ":dist", 100),
(assign, ":valid", 0),
(try_end),
(try_begin),
(eq, ":valid", 0),
(val_add, ":end_cond", 1),
(val_add, ":shift_value", 1),
(else_try),
(prop_instance_set_position, ":target_object", pos2),
(prop_instance_animate_to_position, ":target_object", pos2, 1),
(scene_prop_get_instance, ":target_object_2", "spr_gourd_spike", ":cur_instance"),
(position_move_z, pos2, -150), #moving back to ground level
(prop_instance_set_position, ":target_object_2", pos2),
(prop_instance_animate_to_position, ":target_object_2", pos2, 1),
(try_end),
(try_end),
(else_try),
(eq, "$g_mt_mode", ctm_mounted),
(assign, ":num_gourds", 0),
#First, placing gourds on the spikes
(try_for_range, ":cur_i", 0, 100),
(scene_prop_get_instance, ":target_object", "spr_gourd", ":cur_i"),
(scene_prop_get_instance, ":target_object_2", "spr_gourd_spike", ":cur_i"),
(ge, ":target_object", 0),
(ge, ":target_object_2", 0),
(val_add, ":num_gourds", 1),
(prop_instance_get_position, pos0, ":target_object_2"),
(position_move_z, pos0, 150),
(prop_instance_set_position, ":target_object", pos0),
(prop_instance_animate_to_position, ":target_object", pos0, 1),
(try_end),
(store_sub, ":end_cond", ":num_gourds", "$g_training_ground_training_num_gourds_to_destroy"),
#Second, removing gourds and their spikes randomly
(try_for_range, ":cur_i", 0, ":end_cond"),
(store_random_in_range, ":random_instance", 0, ":num_gourds"),
(scene_prop_get_instance, ":target_object", "spr_gourd", ":random_instance"),
(prop_instance_get_position, pos0, ":target_object"),
(position_get_z, ":pos_z", pos0),
(try_begin),
(lt, ":pos_z", -50000),
(val_add, ":end_cond", 1), #removed already, try again
(else_try),
(position_set_z, pos0, -100000),
(prop_instance_set_position, ":target_object", pos0),
(prop_instance_animate_to_position, ":target_object", pos0, 1),
(scene_prop_get_instance, ":target_object_2", "spr_gourd_spike", ":random_instance"),
(prop_instance_set_position, ":target_object_2", pos0),
(prop_instance_animate_to_position, ":target_object_2", pos0, 1),
(try_end),
(try_end),
(try_end),
],
[]),