function move_ai($account) { global $player_data; global $map_data; if (player_ready($account) == False) { irciv_privmsg("player {$account} not ready"); return; } unset($player_data[$account]["path"]); if (isset($player_data[$account]["active"]) == False) { irciv_privmsg("player {$account} has no active unit"); return; } $active = $player_data[$account]["active"]; $start = array(); $start["x"] = $player_data[$account]["units"][$active]["x"]; $start["y"] = $player_data[$account]["units"][$active]["y"]; $paths = array(); foreach ($player_data as $enemy_account => $enemy_data) { if ($enemy_account == $account) { continue; } $path = array(); $finish = array(); $finish["x"] = $player_data[$enemy_account]["units"][0]["x"]; $finish["y"] = $player_data[$enemy_account]["units"][0]["y"]; if (find_path($path, $start, $finish) == False) { $player_data[$account]["status_messages"][] = "no path exists between {$account} and {$enemy_account}"; status($account); continue; } if (count($path) <= 1) { $player_data[$account]["status_messages"][] = "no path exists between {$account} and {$enemy_account}"; status($account); continue; } $paths[] = $path; } $min_path_length = $map_data["cols"] * $map_data["rows"]; $min_path = -1; for ($i = 0; $i < count($paths); $i++) { if (count($paths[$i]) < $min_path_length) { $min_path = $i; $min_path_length = count($paths[$i]); } } if ($min_path >= 0) { $player_data[$account]["path"] = $paths[$min_path]; $dir = $paths[$min_path][1]["dir"]; move_active_unit($account, $dir); } }
irciv_privmsg("syntax: [~civ] (right|r)"); } break; case "d": case "down": if ($trailing == "") { move_active_unit($account, 2); $irciv_data_changed = True; } else { irciv_privmsg("syntax: [~civ] (down|d)"); } break; case "l": case "left": if ($trailing == "") { move_active_unit($account, 3); $irciv_data_changed = True; } else { irciv_privmsg("syntax: [~civ] (left|l)"); } break; case "b": case "build": if ($trailing != "") { build_city($account, $trailing); $irciv_data_changed = True; } else { irciv_privmsg("syntax: [~civ] (build|b) City Name"); } break; case "status":