ereinion

manaburn.ash

Nov 3rd, 2016
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import <clanhop.ash>;
  2.  
  3. int get_price(item item_to_check, float acceptable_age) {
  4.     return ((historical_age(item_to_check) <= acceptable_age)? historical_price(item_to_check) : mall_price(item_to_check));
  5. }
  6.  
  7. int clanLeaderID() {
  8.     buffer clanInfo;
  9.     matcher m;
  10.     int leaderID;
  11.    
  12.     leaderID = -1;
  13.     clanInfo = visit_url("showclan.php?recruiter=1&whichclan=" + get_clan_id());
  14.     m = create_matcher("Leader:</td><td valign=top><b><a href=\"showplayer\\.php\\?who=(\\d+?)\">", clanInfo);
  15.    
  16.     if (find(m)) {
  17.         leaderID = to_int(group(m,1));
  18.     }
  19.     return leaderID;
  20. }
  21.  
  22. float average_price(int first_item_id, int last_item_id) {
  23.     float[item] weightOfRares; item it;
  24.     float total;
  25.    
  26.     weightOfRares[$item[divine champagne popper]] = 0.1;
  27.     weightOfRares[$item[divine champagne flute]] = 0.1;
  28.     weightOfRares[$item[divine cracker]] = 0.1;
  29.     weightOfRares[$item[resolution: be kinder]] = 0.1;
  30.     weightOfRares[$item[resolution: be luckier]] = 0.1;
  31.     weightOfRares[$item[resolution: be more adventurous]] = 0.1;
  32.     weightOfRares[$item[pulled indigo taffy]] = 0.1;
  33.     weightOfRares[$item[pulled green taffy]] = 0.1;
  34.     weightOfRares[$item[pulled yellow taffy]] = 0.1;
  35.    
  36.     for i from first_item_id to last_item_id {
  37.         it = to_item(i);
  38.         if (weightOfRares contains it) {
  39.             total = total + (get_price(to_item(i), 1) * weightOfRares[it]);
  40.         } else {
  41.             total = total + get_price(to_item(i), 1);
  42.         }
  43.     }
  44.    
  45.     return (total / (1 + last_item_id - first_item_id));
  46. }
  47.  
  48. skill most_valuable_libram_skill() {
  49.     float[skill] averageSummonValue;
  50.     skill bestSkill;
  51.     string s;
  52.    
  53.     averageSummonValue[$skill[Summon Candy Heart]] = (have_skill($skill[Summon Candy Heart]))? average_price(2304, 2309) : 0;
  54.     averageSummonValue[$skill[Summon Party Favor]] = (have_skill($skill[Summon Party Favor]))? average_price(3118, 3123) : 0;
  55.     averageSummonValue[$skill[Summon Love Song]] = (have_skill($skill[Summon Love Song]))? average_price(3754, 3759) : 0;
  56.     averageSummonValue[$skill[Summon BRICKOs]] = (have_skill($skill[Summon BRICKOs]))? average_price(4469, 4470) : 0;
  57.     averageSummonValue[$skill[Summon Dice]] = (have_skill($skill[Summon Dice]))? average_price(5285, 5290) : 0;
  58.     averageSummonValue[$skill[Summon Resolutions]] = (have_skill($skill[Summon Resolutions]))? average_price(5464, 5472) : 0;
  59.     averageSummonValue[$skill[Summon Taffy]] = (have_skill($skill[Summon Taffy]))? average_price(6361, 6367) : 0;
  60.    
  61.     #sort averageSummonValue by -value;
  62.    
  63.     foreach sk in averageSummonValue {
  64.         if (averageSummonValue[sk] > averageSummonValue[bestSkill]) {
  65.             bestSkill = sk;
  66.         }
  67.         if (averageSummonValue[sk] != 0) {
  68.             s = substring(to_string(averageSummonValue[sk]), 0, last_index_of(to_string(averageSummonValue[sk]),".") + 2);
  69.             print("Average mallprice for the items from " + to_string(sk) + " is: " + s + ".", "green");
  70.         }
  71.     }
  72.     if (averageSummonValue[bestSkill] != 0) {
  73.         s = substring(to_string(averageSummonValue[bestSkill]), 0, last_index_of(to_string(averageSummonValue[bestSkill]),".") + 2);
  74.         print("The largest return on tome-summons is from " + to_string(bestSkill) + " which gives " + s + " meat on average.", "blue");
  75.         return bestSkill;
  76.     }
  77.     return $skill[none];
  78. }
  79.  
  80. void buff_mp() {
  81.     string current_clan;
  82.     // Ballpit
  83.     if (item_amount($item[Clan VIP Lounge key]) > 0 && !to_boolean(get_property("_ballpit")) && clanLeaderID() != to_int(my_id())) {
  84.         if (to_int(get_property("ballpitBonus")) < 100) {
  85.             clanhop("Bonus Adventures From Hell");
  86.             cli_execute("ballpit");
  87.         } else {
  88.             cli_execute("ballpit");
  89.         }
  90.     }
  91.    
  92.     // Telescope
  93.     if (to_int(get_property("telescopeUpgrades")) > 0 && !to_boolean(get_property("telescopeLookedHigh"))) {
  94.         cli_execute("telescope high");
  95.     }
  96.    
  97.     // Maximize
  98.     if (have_familiar($familiar[Disembodied Hand])) {
  99.         maximize("mp, -tie, -current, -equip staff of ed, switch Disembodied Hand", false);
  100.     } else {
  101.         maximize("mp, -tie, -current, -equip staff of ed", false);
  102.     }
  103. }
  104.  
  105. boolean restore_without_overshooting() {
  106.     int free_rests_available; int rest_mp;
  107.     boolean return_value;
  108.     return_value = false;
  109.     buffer vip_lounge;
  110.    
  111.     // Nuns
  112.     if (get_property("sidequestNunsCompleted") == "fratboy") {
  113.         while (my_maxmp() - my_mp() >= 1000 && to_int(get_property("nunsVisits")) < 3) {
  114.             cli_execute("nuns");
  115.             return_value = true;
  116.         }
  117.     }
  118.     // Shower mp
  119.     if (!to_boolean(get_property("_aprilShower"))) {
  120.         vip_lounge = visit_url("clan_viplounge.php?whichfloor=2");
  121.         if (my_maxmp() - my_mp() >= 1000) {
  122.             vip_lounge.append(visit_url("clan_viplounge.php"));
  123.             if (!vip_lounge.contains_text("vip_trendy.gif")) {
  124.                 if (!vip_lounge.contains_text("aprilshower.gif") && clanLeaderID() != to_int(my_id())) {
  125.                     clanhop("Bonus Adventures from Hell");
  126.                 }
  127.                 if (vip_lounge.contains_text("aprilshower.gif")) {
  128.                     cli_execute("shower mp");
  129.                     return_value = true;
  130.                 }
  131.             }
  132.         }
  133.     }
  134.     // Oscus's neverending soda
  135.     if (!to_boolean(get_property("oscusSodaUsed")) && item_amount($item[Oscus's neverending soda]) > 0) {
  136.         if (my_maxmp() - my_mp() >= 300) {
  137.             use(1, $item[Oscus's neverending soda]);
  138.             return_value = true;
  139.         }
  140.     }
  141.     // Campground
  142.     free_rests_available = total_free_rests();
  143.     free_rests_available -= to_int(get_property("timesRested"));
  144.    
  145.     if (free_rests_available > 0) {
  146.         if (item_amount($item[Pantsgiving]) > 0) {
  147.             equip($slot[pants], $item[Pantsgiving]);
  148.         }
  149.         rest_mp = numeric_modifier("Base Resting MP") * (numeric_modifier("Resting MP Percent")+100) / 100 + numeric_modifier("Bonus Resting MP");
  150.         #if (to_boolean(get_property("chateauAvailable"))) {
  151.         #   if (rest_mp < 125) {
  152.         #       set_property("restUsingChateau", "true");
  153.         #       rest_mp = 150;
  154.         #   } else {
  155.         #       set_property("restUsingChateau", "false");
  156.         #   }  
  157.         #}
  158.         while (my_maxmp() - my_mp() >= rest_mp && free_rests_available > 0) {
  159.             cli_execute("rest");
  160.             free_rests_available -= 1;
  161.             return_value = true;
  162.         }
  163.     }
  164.     return return_value;
  165. }
  166.  
  167. boolean restore_with_overshooting() {
  168.     int free_rests_available;
  169.     buffer vip_lounge;
  170.    
  171.     // Nuns
  172.     if (get_property("sidequestNunsCompleted") == "fratboy") {
  173.         if (my_maxmp() > my_mp() && to_int(get_property("nunsVisits")) < 3) {
  174.             cli_execute("nuns");
  175.             return true;
  176.         }
  177.     }
  178.     // Shower mp
  179.     if (!to_boolean(get_property("_aprilShower"))) {
  180.         vip_lounge = visit_url("clan_viplounge.php?whichfloor=2");
  181.         if (my_maxmp() > my_mp()) {
  182.             vip_lounge.append(visit_url("clan_viplounge.php"));
  183.             if (!vip_lounge.contains_text("vip_trendy.gif")) {
  184.                 if (!vip_lounge.contains_text("aprilshower.gif") && clanLeaderID() != to_int(my_id())) {
  185.                     clanhop("Bonus Adventures from Hell");
  186.                 }
  187.                 if (vip_lounge.contains_text("aprilshower.gif")) {
  188.                     cli_execute("shower mp");
  189.                     return true;
  190.                 }
  191.             }
  192.         }
  193.     }
  194.    
  195.     // Oscus's neverending soda
  196.     if (!to_boolean(get_property("oscusSodaUsed")) && item_amount($item[Oscus's neverending soda]) > 0) {
  197.         if (my_maxmp() > my_mp()) {
  198.             use(1, $item[Oscus's neverending soda]);
  199.             return true;
  200.         }
  201.     }
  202.     // Campground
  203.     free_rests_available = total_free_rests();
  204.     free_rests_available -= to_int(get_property("timesRested"));
  205.    
  206.     if (free_rests_available > 0) {
  207.         if (item_amount($item[Pantsgiving]) > 0) {
  208.             equip($slot[pants], $item[Pantsgiving]);
  209.         }
  210.         if (my_maxmp() > my_mp() && free_rests_available > 0) {
  211.             cli_execute("rest");
  212.             return true;
  213.         }
  214.     }
  215.     return false;
  216. }
  217.  
  218. void cast_while_affordable(skill skill_to_use) {
  219.     while (mp_cost(skill_to_use) < my_mp()) {
  220.         use_skill(1, skill_to_use);
  221.     }
  222. }
  223.  
  224. boolean use_pyec() {
  225.     string pyec_taken_from; string property_value;
  226.    
  227.     // Check if PYEC is available
  228.     if (!(item_amount($item[Platinum Yendorian Express Card]) > 0) && can_interact()) {
  229.         if(display_amount($item[Platinum Yendorian Express Card]) > 0) {
  230.             take_display(1, $item[Platinum Yendorian Express Card]);
  231.             pyec_taken_from = "display";
  232.         } else if (closet_amount($item[Platinum Yendorian Express Card]) > 0) {
  233.             take_closet(1, $item[Platinum Yendorian Express Card]);
  234.             pyec_taken_from = "closet";
  235.         } else if (shop_amount($item[Platinum Yendorian Express Card]) > 0) {
  236.             take_shop(1, $item[Platinum Yendorian Express Card]);
  237.             pyec_taken_from = "shop";
  238.         } else if (storage_amount($item[Platinum Yendorian Express Card]) > 0) {
  239.             take_storage(1, $item[Platinum Yendorian Express Card]);
  240.             pyec_taken_from = "storage";
  241.         } else if (stash_amount($item[Platinum Yendorian Express Card]) > 0) {
  242.             if (take_stash(1, $item[Platinum Yendorian Express Card])) {
  243.                 pyec_taken_from = "stash";
  244.             }
  245.         } else if (clanhop("Hardcore Oxygenation")) {
  246.             if (stash_amount($item[Platinum Yendorian Express Card]) > 0) {
  247.                 if (take_stash(1, $item[Platinum Yendorian Express Card])) {
  248.                     pyec_taken_from = "stash";
  249.                 }
  250.             }
  251.         } else {
  252.             return false;
  253.         }
  254.     }
  255.    
  256.     if (item_amount($item[Platinum Yendorian Express Card]) >= 1) {
  257.         // Burn as much mp as possible, before using the card.
  258.         // First mood.
  259.         cli_execute("burn * mp");
  260.         // Then leash.
  261.         if (mp_cost($skill[Leash of Linguini]) < my_mp() && have_skill($skill[Leash of Linguini])) {
  262.             use_skill(to_int(my_mp() / mp_cost($skill[Leash of Linguini])), $skill[Leash of Linguini]);
  263.         }
  264.         // Then extend buffs.
  265.         property_value = get_property("allowNonMoodBurning");
  266.         set_property("allowNonMoodBurning", "true");
  267.         cli_execute("burn * mp");
  268.         set_property("allowNonMoodBurning", property_value);
  269.        
  270.         use(1, $item[Platinum Yendorian Express Card]);
  271.        
  272.         switch (pyec_taken_from) {
  273.             case "display":
  274.                 put_display(1, $item[Platinum Yendorian Express Card]);
  275.                 break;
  276.             case "closet":
  277.                 put_closet(1, $item[Platinum Yendorian Express Card]);
  278.                 break;
  279.             case "shop":
  280.                 put_shop(0, 0, 1, $item[Platinum Yendorian Express Card]);
  281.                 break;
  282.             case "stash":
  283.                 put_stash(1, $item[Platinum Yendorian Express Card]);
  284.                 break;
  285.         }
  286.     }
  287.    
  288.     return true;
  289. }
  290.  
  291. void manaburn() {
  292.     string current_clan;
  293.  
  294.     skill skill_to_use = most_valuable_libram_skill();
  295.    
  296.     if (skill_to_use != $skill[none]) {
  297.         current_clan = get_clan_name();
  298.        
  299.         buff_mp();
  300.        
  301.         // Run down current mp before using PYEC.
  302.         // First libram skill
  303.         cast_while_affordable(skill_to_use);
  304.        
  305.         // First try to restore mp without going over max mp
  306.         while (restore_without_overshooting() && mp_cost(skill_to_use) <= my_maxmp()) {
  307.             cast_while_affordable(skill_to_use);
  308.         }
  309.        
  310.         // Then allow going over maz mp
  311.         while (restore_with_overshooting() && mp_cost(skill_to_use) <= my_maxmp()) {
  312.             cast_while_affordable(skill_to_use);
  313.         }
  314.        
  315.         // Then use PYEC, if available
  316.         if (!to_boolean(get_property("expressCardUsed"))) {
  317.             use_pyec();
  318.             cast_while_affordable(skill_to_use);
  319.         }
  320.         if (get_clan_name() != current_clan) {
  321.             clanhop (current_clan);
  322.         }
  323.         print("Done! The next libram summon will cost " + mp_cost(skill_to_use) + " mp.", "blue");
  324.     } else {
  325.         print("You don't have any libram skills.", "red");
  326.     }
  327. }
  328.  
  329. void main() {
  330.     manaburn();
  331. }
Advertisement
Add Comment
Please, Sign In to add comment