Advertisement
kolpastebin

Mirror, mirror.ash

Dec 13th, 2014
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. //Mirror, Mirror.ash - shows a list of items you can duplicate with the Full-Length Mirror semi-rare.
  2.  
  3. //Settings:
  4. boolean setting_show_pastebin_output = true;
  5. boolean setting_show_all_pvpable_items = false; //by default, only shows equipment; when set to true, shows everything you can steal
  6.  
  7.  
  8. int __backoffice_script_requests_made = 0;
  9. int [item] __minimum_price_cache;
  10. int minimumMallPrice(item it)
  11. {
  12. if (__minimum_price_cache contains it)
  13. return __minimum_price_cache[it];
  14. //Safety:
  15. __backoffice_script_requests_made += 1;
  16. if (__backoffice_script_requests_made >= 10000) //there are about that many items in the game
  17. {
  18. abort("Script made too many server requests; aborting as a safety feature.");
  19. return -1;
  20. }
  21. print_html("Looking up price for " + it + "...");
  22. buffer page_text = visit_url("backoffice.php?iid=" + it.to_int() + "&action=prices&ajax=1");
  23.  
  24. string unlimited = page_text.group_string("<tr><td>unlimited:</td><td><b>([^<]*)</b>")[0][1];
  25. string limited = page_text.group_string("<tr><td>limited:</td><td><b>([^<]*)</b>")[0][1];
  26.  
  27. int price = -1;
  28. if (unlimited != "")
  29. price = unlimited.to_int();
  30. if (limited != "")
  31. {
  32. int value = limited.to_int();
  33. if (price == -1 || price > value)
  34. price = value;
  35. }
  36. __minimum_price_cache[it] = price;
  37. return price;
  38. }
  39.  
  40.  
  41. int item_price(item it)
  42. {
  43. int value = 0;
  44. if (!it.is_tradeable())
  45. value = 0;
  46. else if (it.historical_age() > 30.0 || (setting_show_pastebin_output && it.historical_price() > 10000))
  47. value = it.minimumMallPrice(); //it.mall_price();
  48. else
  49. value = it.historical_price();
  50. if (value == -1)
  51. value = 999999999;
  52. return value;
  53. }
  54.  
  55. boolean item_is_pvp_stealable(item it)
  56. {
  57. if ($items[candy dress shoes,chocolate pocketwatch,candy necktie] contains it) //no
  58. return false;
  59. if (!it.tradeable)
  60. return false;
  61. if (!it.discardable)
  62. return false;
  63. if (it.quest)
  64. return false;
  65. if (it.gift)
  66. return false;
  67. return true;
  68. }
  69.  
  70. void main()
  71. {
  72. item [int] stealables;
  73. foreach i in $items[]
  74. {
  75. if (!setting_show_all_pvpable_items && (i.to_slot() == $slot[none] || I.to_slot() == $slot[familiar]))
  76. continue;
  77.  
  78. if (!i.item_is_pvp_stealable())
  79. continue;
  80. stealables[stealables.count()] = i;
  81. }
  82.  
  83. sort stealables by -item_price(value);
  84.  
  85. print("Stealable items:");
  86. foreach key in stealables
  87. {
  88. item it = stealables[key];
  89. int total_price = it.item_price();
  90. if (total_price < 10000 && setting_show_all_pvpable_items)
  91. continue;
  92. if (total_price == 0.0)
  93. print(it);
  94. else
  95. {
  96. if (setting_show_pastebin_output)
  97. print(it + " (" + total_price + " meat)");
  98. else
  99. print(it.available_amount() + " " + it + " (" + total_price + " meat)");
  100. }
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement