//defensive scenario runtime- barbarian assault from all sidesthe matrix{ labels { DEFENDER, //PLAYER ATTACKER, //COMPUTER } //VARIABLES //the x and y coordinates of the center of the map static int center_x = get_map_size() / 2; static int center_y = center_x; //counter of how many attack waves the barbarians have sent static int attack_count = 0; //variables that store your capital name and capital id static String my_capital_name = find_capital(DEFENDER); static int my_capital_id = find_city_id(my_capital_name); //find out what the time limit is static int time_limit = get_time_limit(); //variable that keeps track of the current time static int cur_time = time(); //used to keep track of where units should be placed static int x; static int y; //variable used to keep track of which side the computer comes from static int side; //do this stuff once at start-up of scenario run_once { //allow the computer to transport over water even if it doesn't have a dock and the right technology force_transport_ability(ATTACKER); //don't allow the computer to be defeated if it has no units on the map disable_city_defeat(ATTACKER); //sets the timer that spawns barbarian troops set_timer("units", 15); } //keeps track of current time cur_time = time(); //spawns the barbarian troops if (timer_expired("units")) { //find a spot to place troops near edge of map, side 0 = top left, side 1 = bottom right, side 2 = top right, side 3 = bottom left side = rand_int(0, 3); switch (side) { case 0 : x = 0; y = rand_int(0, get_map_size() - 1); break; case 1 : x = get_map_size() - 1; y = rand_int(0, get_map_size() - 1); break; case 2 : x = rand_int(0, get_map_size() - 1); y = 0; break; case 3 : x = rand_int(0, get_map_size() - 1); y = get_map_size() - 1; break; } //add the units if (attack_count >= 0 && attack_count <= 5) { //this is attack waves 1 through 6 create_unit_upgrade(ATTACKER, x, y, "light horse", 1); //creates the upgrade of light horse create_unit_in_group(ATTACKER, x, y, "slingers", 1); //works the same as create_unit_upgrade, but makes these units be in the same group as the last ones set_timer("units", 30); //re-initializes the countdown timer for the next set of troops } else if (attack_count == 6) { create_unit_upgrade(ATTACKER, x, y, "bowmen", 2); create_unit_in_group(ATTACKER, x, y, "catapult", 1); set_timer("units", 35); } else if (attack_count > 6 && attack_count <= 9) { create_unit_upgrade(ATTACKER, x, y, "hoplites", 2); set_timer("units", 35); } else if (attack_count > 9 && attack_count <= 15) { create_unit_upgrade(ATTACKER, x, y, "bowmen", 2); set_timer("units", 35); } else if (attack_count > 15 && attack_count <= 17) { create_unit_upgrade(ATTACKER, x, y, "slingers", 1); create_unit_in_group(ATTACKER, x, y, "catapult", 1); set_timer("units", 30); } else if (attack_count > 17 && attack_count <= 20) { create_unit_upgrade(ATTACKER, x, y, "bowmen", 1); create_unit_in_group(ATTACKER, x, y, "slingers", 1); set_timer("units", 30); } else if (attack_count > 20 && attack_count <= 24) { //ancient age create_unit_upgrade(ATTACKER, x, y, "bowmen", 1); create_unit_in_group(ATTACKER, x, y, "catapult", 1); create_unit_in_group(ATTACKER, x, y, "cataphract", 1); set_timer("units", 30); } attack_count++; //increase the attack counter group_attack_to_order(ATTACKER, center_x, center_y); //give the group an attack order } //if the current time equals the time limit, the defender wins if (cur_time >= time_limit) { victory(DEFENDER); } //if the attacker captures the defender's capital, the attacker wins if (city_id_captured(DEFENDER, my_capital_id)) { victory(ATTACKER); } }
2006年03月18日 15点03分
21