Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[string] currencies;
- currencies["Guns"] = 0;
- currencies["Grub"] = 0;
- currencies["Grog"] = 0;
- currencies["Glue"] = 0;
- currencies["Gold"] = 0;
- currencies["Fun"] = 0;
- string chosen_crew;
- void update_currencies() {
- string s = visit_url("charpane.php");
- matcher m = create_matcher(">([GF]\\w+)[<>\\/:= \\w]+?(\\d+)", s);
- while (find(m)) {
- if (currencies contains group(m, 1)) {
- currencies[group(m, 1)] = to_int(group(m, 2));
- }
- }
- }
- boolean handle_sea_advs() {
- string s = visit_url("adventure.php?snarfblat=530");
- string[int] choices = available_choice_options();
- int best_choice = 0;
- string preferred_currency;
- int i = 0;
- boolean return_value = true;
- switch (last_choice()) {
- case 1352: # Island #1, Who Are You?
- print_html("</br><font color=008000>Choosing island #1...</font>");
- best_choice = 1; # Crab Island
- foreach key in choices {
- if (choices[key] == "Skull Island") {
- best_choice = key;
- break;
- }
- }
- break;
- case 1353: # What's Behind Island #2?
- print_html("</br><font color=008000>Choosing island #2...</font>");
- if (item_amount($item[tomb-opener]) > 0) {
- best_choice = 3; # Cemetery Island
- } else {
- best_choice = 2; # Isla Gublar
- }
- break;
- case 1354: # Third Island's the Charm
- print_html("</br><font color=008000>Choosing island #3...</font>");
- foreach key in choices {
- best_choice = 3; # Storm Island
- if (choices[key].contains_text("Red Roger")) { # Red Roger's Fortress
- best_choice = key;
- break;
- } else if (choices[key].contains_text("Glass Jack")) { # Glass Jack's Hideout
- best_choice = key;
- }
- }
- break;
- case 1355: # Land Ho!
- print_html("</br><font color=008000>Found an island.</font>");
- best_choice = 1; # Head Inland
- return_value = false;
- break;
- case 1356: # Smooth Sailing
- print_html("</br><font color=008000>Smooth sailing.</font>");
- if (chosen_crew.contains_text("Cuisinier") && currencies["Grub"] > 0) {
- best_choice = 1;
- } else if (chosen_crew.contains_text("Mixologist") && currencies["Grog"] > 0) {
- best_choice = 2;
- } else if (chosen_crew.contains_text("Wide-Eyed")) {
- best_choice = 3;
- } else if (currencies["Grub"] > 0 && currencies["Grub"] > currencies["Grog"]) {
- best_choice = 1;
- } else if (currencies["Grog"] > 0) {
- best_choice = 2;
- } else {
- best_choice = 3;
- }
- break;
- case 1357: # High Tide, Low Morale
- print_html("</br><font color=008000>High Tide, Low Morale.</font>");
- if (currencies["Grub"] >= 10 && currencies["Grub"] > currencies["Grog"]) {
- best_choice = 1;
- } else if (currencies["Grog"] > 10) {
- best_choice = 2;
- } else if (currencies["Gold"] > 30) {
- best_choice = 3;
- } else {
- best_choice = 4;
- }
- break;
- case 1358: # The Starboard is Bare
- print_html("</br><font color=FF0000>Out of food, collecting...</font>");
- if (chosen_crew.contains_text("Gluttonous")) {
- best_choice = 2;
- } else {
- best_choice = 1;
- }
- break;
- case 1359: # Grog for the Grogless
- print_html("</br><font color=FF0000>Out of booze, collecting...</font>");
- if (chosen_crew.contains_text("Cryptobotanist")) {
- best_choice = 2;
- } else {
- best_choice = 1;
- }
- break;
- case 1360: # Like Shops in the Night
- print_html("</br><font color=0000FF>Shopping...</font>");
- if (item_amount($item[cursed compass]) > 0) {
- # sell compass
- }
- while(currencies["Gold"] > 10 && i < 100) {
- if (currencies["Grub"] < 5) {
- print_html("</br><font color=008000>Getting some grub...</font>");
- run_choice(1);
- currencies["Grub"] = currencies["Grub"] + 5;
- currencies["Gold"] = currencies["Gold"] - 10;
- } else if (currencies["Grog"] < 5) {
- print_html("</br><font color=008000>Getting some grog...</font>");
- run_choice(2);
- currencies["Grog"] = currencies["Grog"] + 5;
- currencies["Gold"] = currencies["Gold"] - 10;
- } else if (currencies["Grub"] < 10) {
- print_html("</br><font color=008000>Getting some grub...</font>");
- run_choice(1);
- currencies["Grub"] = currencies["Grub"] + 5;
- currencies["Gold"] = currencies["Gold"] - 10;
- } else if (currencies["Grog"] < 10) {
- print_html("</br><font color=008000>Getting some grog...</font>");
- run_choice(2);
- currencies["Grog"] = currencies["Grog"] + 5;
- currencies["Gold"] = currencies["Gold"] - 10;
- } else if (currencies["Glue"] < 2) {
- print_html("</br><font color=008000>Getting some glue...</font>");
- run_choice(3);
- currencies["Glue"] = currencies["Glue"] + 1;
- currencies["Gold"] = currencies["Gold"] - 10;
- } else if (currencies["Grub"] < 15) {
- print_html("</br><font color=008000>Getting some grub...</font>");
- run_choice(1);
- currencies["Grub"] = currencies["Grub"] + 5;
- currencies["Gold"] = currencies["Gold"] - 10;
- } else if (currencies["Grog"] < 15) {
- print_html("</br><font color=008000>Getting some grog...</font>");
- run_choice(2);
- currencies["Grog"] = currencies["Grog"] + 5;
- currencies["Gold"] = currencies["Gold"] - 10;
- } else if (currencies["Gold"] >= 200) {
- print_html("</br><font color=008000>Purchasing a cannon!</font>");
- run_choice(4);
- currencies["Gold"] = currencies["Gold"] - 200;
- } else if (currencies["Glue"] < 3) {
- print_html("</br><font color=008000>Getting some glue...</font>");
- run_choice(3);
- currencies["Glue"] = currencies["Glue"] + 1;
- currencies["Gold"] = currencies["Gold"] - 10;
- } else if (currencies["Grub"] < 20) {
- print_html("</br><font color=008000>Getting some grub...</font>");
- run_choice(1);
- currencies["Grub"] = currencies["Grub"] + 5;
- currencies["Gold"] = currencies["Gold"] - 10;
- } else if (currencies["Grog"] < 20) {
- print_html("</br><font color=008000>Getting some grog...</font>");
- run_choice(2);
- currencies["Grog"] = currencies["Grog"] + 5;
- currencies["Gold"] = currencies["Gold"] - 10;
- } else {
- break;
- }
- i = i + 1;
- }
- i = 0;
- # Sail away
- choices = available_choice_options();
- foreach key in choices {
- if (choices[key].contains_text("Sail away")) {
- print_html("</br><font color=0000FF>Done shopping, continuing journey...</font>");
- best_choice = key;
- }
- }
- break;
- case 1361: # Avast, a Mast!
- print_html("</br><font color=008000>Diving for bounty!</font>");
- best_choice = 1;
- break;
- case 1362: # Stormy Weather
- if (currencies["Glue"] > 0) {
- print_html("</br><font color=008000>Stormy weather, let's outrun it!</font>");
- best_choice = 2;
- } else {
- print_html("</br><font color=008000>Stormy weather, let's hunker down since we don't have <b>glue</b>.</font>");
- best_choice = 1;
- }
- break;
- case 1363: # Who Pirates the Pirates?
- case 1364: # An Opportunity for Dastardly Do
- case 1365: # A Sea Monster!
- print_html("</br><font color=008000>Let's do some fighting!</font>");
- best_choice = 1; # Attack
- break;
- case 1367: # The Ship is Wrecked
- if (currencies["Glue"] > 0) {
- print_html("</br><font color=008000>Shipwreck! Let's fix it with glue.</font>");
- best_choice = 1;
- } else {
- print_html("</br><font color=FF0000>Shipwreck! We'll have to wait for help...</font>");
- best_choice = 2;
- }
- break;
- default:
- print_html("</br><font color=FF0000>Unhandled choiceadventure #" + last_choice() + " on the PirateRealm seas!</font>");
- }
- run_choice(best_choice);
- return return_value;
- }
- void prep_ship() {
- string s;
- string[int] pirates;
- item eyepatch = $item[PirateRealm eyepatch];
- int i;
- int pirateChoice;
- matcher m;
- if (item_amount(eyepatch) <= 0 && !have_equipped(eyepatch)) {
- print_html("</br><font color=008000>Acquiring eyepatch...</font>");
- visit_url("place.php?whichplace=realm_pirate&action=pr_port");
- }
- if (item_amount($item[PirateRealm eyepatch]) > 0 || have_equipped(eyepatch)) {
- if (outfit("PirateRealm")) {
- s = visit_url("place.php?whichplace=realm_pirate&action=pr_port");
- if (s.contains_text("Head to Groggy's")) {
- // Head to Groggy's
- s = run_choice(1);
- // Crew
- print_html("</br><font color=008000>Choosing crew...</font>");
- m = create_matcher("submit value=\"the ([-\\w]+)\\s+(\\w+)\\s*\"><\\/form>", s);
- while (find(m)) {
- i = i + 1;
- // Group 1 = adjective, group 2 = noun
- pirates[i] = group(m, 1) + " " + group(m, 2);
- print_html(pirates[i]);
- if (group(m, 2) == "Harquebusier") {
- pirateChoice = i;
- break;
- }
- if (group(m, 1) == "Wide-Eyed") {
- pirateChoice = i;
- }
- }
- if (pirateChoice == 0) {
- pirateChoice = 1+random(3);
- }
- chosen_crew = pirates[pirateChoice];
- print_html("</br><font color=008000>Choosing the <b>" + chosen_crew + "</b> as crew.</font>");
- s = run_choice(pirateChoice);
- // Curio
- print_html("</br><font color=008000>Selecting curio...</font>");
- if (!pirates[pirateChoice].contains_text("Wide-Eyed") && !pirates[pirateChoice].contains_text("Harquebusier")) {
- // Compass
- print_html("</br><font color=008000>Choosing the compass.</font>");
- s = run_choice(2);
- } else {
- // Red Roger's Flag
- m = create_matcher("option value=(\\d{1,2})[\\-\"=><\\w\\s\\d]+?Red Roger's flag", s);
- if (find(m)) {
- print_html("</br><font color=008000>Choosing Red Roger's flag.</font>");
- s = run_choice(to_int(group(m,1)));
- // Harpoon
- } else {
- print_html("</br><font color=008000>Choosing harpoon.</font>");
- s = run_choice(1);
- }
- }
- // Ship
- print_html("</br><font color=008000>Choosing ship...</font>");
- m = create_matcher("option value=(\\d{1,2})[\\-\"=><\\w\\s\\d]+?The Menacing Man", s);
- // The Menacing Man o' War
- if (find(m)) {
- print_html("</br><font color=008000>Getting the Menacing Man o' War.</font>");
- s = run_choice(to_int(group(m,1)));
- // The Intimidating Galleon
- } else {
- print_html("</br><font color=008000>Getting the Intimidating Galleon.</font>");
- s = run_choice(2);
- }
- // Head for the sea
- run_choice(1);
- }
- }
- }
- }
- boolean handle_island_advs() {
- while (adventure(1, $location[PirateRealm Island])) {}
- return false;
- }
- void main() {
- int starting_fun;
- boolean island_complete = false;
- int i;
- int j;
- int[string] previous_choices;
- print_html("</br><font color=0000FF>Preparing for adventure...</font>");
- foreach key in $ints[1368, 1370, 1375, 1377, 1381, 1382, 1384] { # Possible choices at the end of islands
- if (get_property("choiceAdventure" + to_string(key)) != 1) {
- previous_choices["choiceAdventure" + to_string(key)] = to_int(get_property("choiceAdventure" + to_string(key)));
- set_property("choiceAdventure" + to_string(key), 1);
- }
- }
- update_currencies();
- starting_fun = currencies["Fun"];
- print_html("</br><font color=0000FF>Preparing our ship...</font>");
- prep_ship();
- while (!island_complete && i < 50 && my_adventures() > 0) {
- while (handle_sea_advs() && j < 100) {
- print_html("</br><font color=0000FF>Exploring the PirateRealm seas...</font>");
- update_currencies();
- j = j + 1;
- }
- j = 0;
- while (adventure(1, $location[PirateRealm Island]) && j < 100) {
- print_html("</br><font color=0000FF>Adventuring on the islands...</font>");
- j = j + 1;
- }
- update_currencies();
- if (last_choice() >= 1381 && last_choice() <= 1384) {
- island_complete = true;
- }
- j = 0;
- i = i + 1;
- }
- print_html("</br><font color=0000FF>Cleaning up our settings...</font>");
- foreach key in previous_choices {
- set_property(key, previous_choices[key]);
- }
- if (island_complete) {
- print_html("</br><font color=0000FF>Our island adventure is complete!</font>");
- print_html("</br><font color=0000FF>Gained <b>" + to_string(currencies["Fun"] - starting_fun) + "</b> funpoints.</font>");
- } else {
- print_html("</br><font color=FF0000>Couldn't finish our island adventure!</font>");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement