Advertisement
Guest User

Untitled

a guest
Oct 30th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.89 KB | None | 0 0
  1. -- [[ INIT START ]] --
  2. --
  3. -- 88
  4. -- "" ,d
  5. -- 88
  6. -- ,adPPYba, 88 8b,dPPYba, 88,dPYba,,adPYba, ,adPPYYba, MM88MMM ,adPPYba,
  7. -- I8[ "" 88 88P' "Y8 88P' "88" "8a "" `Y8 88 a8P_____88
  8. -- `"Y8ba, 88 88 88 88 88 ,adPPPPP88 88 8PP"""""""
  9. -- aa ]8I 88 88 88 88 88 88, ,88 88, "8b, ,aa
  10. -- Author: `"YbbdP"' 88 88 88 88 88 `"8bbdP"Y8 "Y888 `"Ybbd8"'
  11. --
  12. -- Monitor My Hunting!
  13. --
  14. -- Version: 1.0
  15. -- Created: 7.09.2012
  16. -- Last update: 18.09.2012
  17. --
  18.  
  19. MONITOR_MY_HUNTING = MONITOR_MY_HUNTING or {
  20. SCRIPT_NAME = "Monitor My Hunting",
  21. SCRIPT_VERSION = "1.0",
  22.  
  23. CLEARED_STATS = false,
  24. INITIALIZED = false,
  25. }
  26.  
  27. MONITOR_MY_HUNTING.SHOW_ALL_ITEMS = false
  28. MONITOR_MY_HUNTING.ITEMS_LIST = {
  29. {NAME = 8895, VALUE = 0},
  30. {NAME = "foxtail", VALUE = 0},
  31. {NAME = "ornate crossbow", VALUE = 12000},
  32. {NAME = "warriors axe", VALUE = 11000},
  33. {NAME = "deepling backpack", VALUE = 10000},
  34. {NAME = "guardian axe", VALUE = 9000},
  35. {NAME = "warriors shield", VALUE = 9000},
  36. {NAME = "deepling squelcher", VALUE = 7000},
  37. {NAME = "fish fin", VALUE = 3000},
  38. {NAME = "deepling staff", VALUE = 4000},
  39. {NAME = "necklace of the deep", VALUE = 3000},
  40. {NAME = "heavy trident", VALUE = 2000},
  41. {NAME = "deepling claw", VALUE = 430},
  42. {NAME = "deepling ridge", VALUE = 360},
  43. {NAME = "key to the drowned library", VALUE = 330},
  44. {NAME = "deeptags", VALUE = 290},
  45. {NAME = "spellsingers seal", VALUE = 280},
  46. {NAME = "small emerald", VALUE = 250},
  47. {NAME = "small sapphire", VALUE = 250},
  48. {NAME = "deepling guard belt buckle", VALUE = 230},
  49. {NAME = "great health potion", VALUE = 190},
  50. {NAME = "deepling warts", VALUE = 180},
  51. {NAME = "eye of a deepling", VALUE = 150},
  52. {NAME = "great mana potion", VALUE = 120},
  53. {NAME = "platinum coin", VALUE = 100},
  54. {NAME = "deepling breaktime snack", VALUE = 90},
  55. {NAME = "deepling scales", VALUE = 80},
  56. {NAME = "life ring", VALUE = 50},
  57. {NAME = "gold coin", VALUE = 1},
  58. {NAME = "rust remover", VALUE = 0},
  59. }
  60.  
  61. MONITOR_MY_HUNTING.SHOW_ALL_SUPPLIES = false
  62. MONITOR_MY_HUNTING.SUPPLIES_LIST = {
  63. {NAME = "mana potion", PRICE = 50},
  64. {NAME = "great health potion", PRICE = 190},
  65. {NAME = "ultimate health potion", PRICE = 310},
  66. }
  67.  
  68. -- [[ DO NOT CHANGE ANYTHING BELOW THIS LINE. ]] --
  69.  
  70. MONITOR_MY_HUNTING.TEMP_ITEMS_LIST = MONITOR_MY_HUNTING.TEMP_ITEMS_LIST or {}
  71. MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST = MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST or {}
  72. MONITOR_MY_HUNTING.COLORS = MONITOR_MY_HUNTING.COLORS or {
  73. BLACK = rgbcolor(1, 1, 1),
  74. ORANGE = rgbcolor(255, 165, 0),
  75. BLUE = rgbcolor(30, 144, 255),
  76. CORNSILK = rgbcolor(205, 200, 177),
  77. WHITE = rgbcolor(255, 255, 255),
  78. GREEN = rgbcolor(107, 142, 35),
  79. RED = rgbcolor(178, 34, 34),
  80. }
  81.  
  82. local function CreateMessageObject(MESSAGE_DATA)
  83. if (type(MESSAGE_DATA) ~= "userdata") then
  84. return setmetatable({__data = {TYPE = -1, TIME_STAMP = -1, SENDER_NAME = "", SENDER_LEVEL = -1, CONTENT = ""}}, MessageMetaTable)
  85. else
  86. return setmetatable({__data = {TYPE = MESSAGE_DATA.type, TIME_STAMP = Misc.ConvertToSeconds(string.sub(MESSAGE_DATA.text, 1, 5)), SENDER_NAME = MESSAGE_DATA.sender, SENDER_LEVEL = tonumber((tostring(string.match(MESSAGE_DATA.text, ".+ (%b[]): .+")):gsub("[^%d]", ""))) or 0, CONTENT = string.sub(MESSAGE_DATA.text, 7)}}, MessageMetaTable)
  87. end
  88. end
  89.  
  90. local function addtextshadow(DISPLAY_TEXT, X_OFFSET, Y_OFFSET, FONT_COLOR)
  91. setfontcolor(MONITOR_MY_HUNTING.COLORS.BLACK)
  92. addtext(DISPLAY_TEXT, X_OFFSET + 1, Y_OFFSET + 1)
  93. setfontcolor(FONT_COLOR)
  94. addtext(DISPLAY_TEXT, X_OFFSET, Y_OFFSET)
  95. end
  96. -- [[ INIT END ]] --
  97.  
  98. if (not Stats.Update()) then
  99. local SERVER_LOG_MESSAGES = getnewmessages("Server Log")
  100. local SERVER_LOG_MESSAGES_COUNT = SERVER_LOG_MESSAGES.count - 1
  101.  
  102. for INDEX = 0, SERVER_LOG_MESSAGES_COUNT do
  103. local MESSAGE_OBJECT = CreateMessageObject(SERVER_LOG_MESSAGES[SERVER_LOG_MESSAGES_COUNT - INDEX])
  104.  
  105. if (MESSAGE_OBJECT:Type() == 19 and MESSAGE_OBJECT:Content():lower():match("^loot of")) then
  106. local LOOT_INFO = Message.ParseLootMessage(MESSAGE_OBJECT, true)
  107.  
  108. if (#LOOT_INFO.NAME > 0) then
  109. Stats.__data.MONSTERS_KILLED[LOOT_INFO.NAME] = (Stats.__data.MONSTERS_KILLED[LOOT_INFO.NAME] or 0) + 1
  110.  
  111. for _, LOOT_ITEM in ipairs(LOOT_INFO.ITEMS) do
  112. if (Stats.__data.ITEMS_LOOTED[LOOT_ITEM.ID]) then
  113. Stats.__data.ITEMS_LOOTED[LOOT_ITEM.ID].QUANTITY = Stats.__data.ITEMS_LOOTED[LOOT_ITEM.ID].QUANTITY + LOOT_ITEM.QUANTITY
  114. else
  115. Stats.__data.ITEMS_LOOTED[LOOT_ITEM.ID] = {ID = LOOT_ITEM.ID, NAME = LOOT_ITEM.NAME, QUANTITY = LOOT_ITEM.QUANTITY, VALUE = Item.GetValue(LOOT_ITEM.ID)}
  116. end
  117. end
  118. end
  119. end
  120. end
  121. end
  122.  
  123. local RESET_ITEMS_AND_SUPPLIES = #MONITOR_MY_HUNTING.ITEMS_LIST ~= MONITOR_MY_HUNTING.TEMP_ITEMS_LIST or #MONITOR_MY_HUNTING.SUPPLIES_LIST ~= MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST
  124.  
  125. if (not RESET_ITEMS_AND_SUPPLIES) then
  126. for INDEX, LOOT_ITEM in ipairs(MONITOR_MY_HUNTING.ITEMS_LIST) do
  127. if (LOOT_ITEM.NAME ~= MONITOR_MY_HUNTING.TEMP_ITEMS_LIST[INDEX].NAME or LOOT_ITEM.VALUE ~= MONITOR_MY_HUNTING.TEMP_ITEMS_LIST[INDEX].VALUE) then
  128. RESET_ITEMS_AND_SUPPLIES = true
  129. break
  130. end
  131. end
  132. end
  133.  
  134. if (not RESET_ITEMS_AND_SUPPLIES) then
  135. for INDEX, SUPPLY_ITEM in ipairs(MONITOR_MY_HUNTING.SUPPLIES_LIST) do
  136. if (SUPPLY_ITEM.NAME ~= MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST[INDEX].NAME or SUPPLY_ITEM.PRICE ~= MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST[INDEX].PRICE) then
  137. RESET_ITEMS_AND_SUPPLIES = true
  138. break
  139. end
  140. end
  141. end
  142.  
  143. if (not MONITOR_MY_HUNTING.INITIALIZED or RESET_ITEMS_AND_SUPPLIES) then
  144. if (not MONITOR_MY_HUNTING.CLEARED_STATS) then
  145. Stats.Clear(CLEAR_STATS_ALL)
  146. Stats.Update()
  147.  
  148. MONITOR_MY_HUNTING.CLEARED_STATS = true
  149. end
  150.  
  151. MONITOR_MY_HUNTING.TEMP_ITEMS_LIST, MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST = {}, {}
  152.  
  153. for _, LOOT_ITEM in ipairs(MONITOR_MY_HUNTING.ITEMS_LIST) do
  154. local LOOT_ITEM_ID = Item.GetID(type(LOOT_ITEM.NAME) ~= "table" and LOOT_ITEM.NAME or unpack(LOOT_ITEM.NAME))
  155.  
  156. Stats.AddItemsLooted(LOOT_ITEM_ID, 0, LOOT_ITEM.VALUE)
  157. table.insert(MONITOR_MY_HUNTING.TEMP_ITEMS_LIST, {ID = LOOT_ITEM_ID, NAME = LOOT_ITEM.NAME, VALUE = LOOT_ITEM.VALUE})
  158. end
  159.  
  160. for _, SUPPLY_ITEM in ipairs(MONITOR_MY_HUNTING.SUPPLIES_LIST) do
  161. local SUPPLY_ITEM_ID = Item.GetID(type(SUPPLY_ITEM.NAME) ~= "table" and SUPPLY_ITEM.NAME or unpack(SUPPLY_ITEM.NAME))
  162.  
  163. Stats.AddSuppliesUsed(SUPPLY_ITEM_ID, 0, SUPPLY_ITEM.PRICE)
  164. table.insert(MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST, {ID = SUPPLY_ITEM_ID, NAME = SUPPLY_ITEM.NAME, PRICE = SUPPLY_ITEM.PRICE})
  165. end
  166.  
  167. MONITOR_MY_HUNTING.INITIALIZED = true
  168. end
  169.  
  170. setposition(Client.ClientWindow().right - 434, Client.WorldWindow().top + 5)
  171.  
  172. local Y_POSITION, INDEX, ITEMS_LOOTED_WORTH, SUPPLIES_USED_WORTH = 30, 0, 0, 0
  173.  
  174. addtextshadow(sprintf("%s v%s", MONITOR_MY_HUNTING.SCRIPT_NAME:upper(), MONITOR_MY_HUNTING.SCRIPT_VERSION), 10, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.ORANGE)
  175.  
  176. Y_POSITION = Y_POSITION + 20
  177.  
  178. addtextshadow("ITEMS LOOTED", 10, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.BLUE)
  179.  
  180. Y_POSITION = Y_POSITION + 20
  181.  
  182. for _, LOOT_ITEM in pairs(Stats.GetItemsLooted()) do
  183. if ((MONITOR_MY_HUNTING.SHOW_ALL_ITEMS or table.find(MONITOR_MY_HUNTING.TEMP_ITEMS_LIST, LOOT_ITEM.ID, "ID")) and LOOT_ITEM.QUANTITY > 0) then
  184. addtextshadow(((#LOOT_ITEM.NAME > 17 and sprintf("%s...", string.match(string.sub(LOOT_ITEM.NAME, 1, 17), "(.-)%s?$"))) or LOOT_ITEM.NAME):ucwords(), 10, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.CORNSILK)
  185. addtextshadow(sprintf("%s (%sK)", Misc.FormatNumber(LOOT_ITEM.QUANTITY), tostring(math.floor(LOOT_ITEM.VALUE * LOOT_ITEM.QUANTITY / 100) / 10)), 140, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.WHITE)
  186.  
  187. INDEX, ITEMS_LOOTED_WORTH = INDEX + 1, ITEMS_LOOTED_WORTH + (LOOT_ITEM.VALUE * LOOT_ITEM.QUANTITY)
  188. end
  189. end
  190.  
  191. addtextshadow("Total:", 10, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.WHITE)
  192. addtextshadow(sprintf("%s GPs", Misc.FormatNumber(ITEMS_LOOTED_WORTH)), 10 + 35, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.ORANGE)
  193.  
  194. Y_POSITION = Y_POSITION + 20
  195.  
  196. addtextshadow("SUPPLIES USED", 10, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.BLUE)
  197.  
  198. Y_POSITION = Y_POSITION + 20
  199.  
  200. for _, SUPPLY_ITEM in pairs(Stats.GetSuppliesUsed()) do
  201. if ((MONITOR_MY_HUNTING.SHOW_ALL_SUPPLIES or table.find(MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST, SUPPLY_ITEM.ID, "ID")) and SUPPLY_ITEM.QUANTITY > 0) then
  202. addtextshadow(((#SUPPLY_ITEM.NAME > 17 and sprintf("%s...", string.match(string.sub(SUPPLY_ITEM.NAME, 1, 17), "(.-)%s?$"))) or SUPPLY_ITEM.NAME):ucwords(), 10, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.CORNSILK)
  203. addtextshadow(sprintf("%s (%sK)", Misc.FormatNumber(SUPPLY_ITEM.QUANTITY), tostring(math.floor(SUPPLY_ITEM.PRICE * SUPPLY_ITEM.QUANTITY / 100) / 10)), 140, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.WHITE)
  204.  
  205. INDEX, SUPPLIES_USED_WORTH = INDEX + 1, SUPPLIES_USED_WORTH + (SUPPLY_ITEM.PRICE * SUPPLY_ITEM.QUANTITY)
  206. end
  207. end
  208.  
  209. addtextshadow("Total:", 10, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.WHITE)
  210. addtextshadow(sprintf("%s GPs", Misc.FormatNumber(SUPPLIES_USED_WORTH)), 10 + 35, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.ORANGE)
  211.  
  212. Y_POSITION = Y_POSITION + 20
  213.  
  214. addtextshadow(sprintf("%s: %s GPs (%s K/H)", ((ITEMS_LOOTED_WORTH >= SUPPLIES_USED_WORTH and ("PROFIT")) or ("WASTE")), Misc.FormatNumber(ITEMS_LOOTED_WORTH - SUPPLIES_USED_WORTH), tostring(math.floor(((ITEMS_LOOTED_WORTH - SUPPLIES_USED_WORTH) * 3600) / (System.HuntingTime() / 1000) / 100) / 10)), 10, Y_POSITION + (INDEX * 16), ITEMS_LOOTED_WORTH >= SUPPLIES_USED_WORTH and MONITOR_MY_HUNTING.COLORS.GREEN or MONITOR_MY_HUNTING.COLORS.RED)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement