Advertisement
Guest User

Untitled

a guest
Sep 18th, 2012
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.92 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 = "gold coin", VALUE = 1},
  30. {NAME = "platinum coin", VALUE = 100},
  31. {NAME = "Zaoan Armor", VALUE = 14000},
  32. {NAME = "zaoan legs", VALUE = 14000},
  33. {NAME = "Zaoan Shoes", VALUE = 5000},
  34. {NAME = "Zaoan Robe", VALUE = 10000},
  35. {NAME = "Zaoan Helmet", VALUE = 45000},
  36. {NAME = "Tower Shield", VALUE = 8000},
  37. {NAME = "Great Health Potion", VALUE = 150},
  38. {NAME = "Corrupted Flag", VALUE = 700},
  39. {NAME = "Small Diamond", VALUE = 250},
  40. {NAME = "Scale of Corruption", VALUE = 550},
  41. {NAME = "demonic essence", VALUE = 1000},
  42. {NAME = "guardian boots", VALUE = 35000},
  43. {NAME = "jade hat", VALUE = 9000},
  44. {NAME = "great mana potion", VALUE = 0},
  45. {NAME = "spellweaver's robe", VALUE = 12000},
  46. {NAME = "small emerald", VALUE = 250},
  47. {NAME = "terra boots", VALUE = 2500},
  48. {NAME = "terra legs", VALUE = 12000},
  49. {NAME = "ghastly dragon head", VALUE = 700},
  50. {NAME = "crown armor", VALUE = 13000},
  51. {NAME = "knight armor", VALUE = 5000},
  52. {NAME = "drakinata", VALUE = 10000},
  53. {NAME = "spiked iron ball", VALUE = 100},
  54. {NAME = "Cursed Shoulder Spikes", VALUE = 320},
  55.  
  56. }
  57.  
  58. MONITOR_MY_HUNTING.SHOW_ALL_SUPPLIES = false
  59. MONITOR_MY_HUNTING.SUPPLIES_LIST = {
  60. {NAME = "strong mana potion", PRICE = 80},
  61. {NAME = "prismatic bolt", PRICE = 20},
  62. }
  63.  
  64. -- [[ DO NOT CHANGE ANYTHING BELOW THIS LINE. ]] --
  65.  
  66. MONITOR_MY_HUNTING.TEMP_ITEMS_LIST = MONITOR_MY_HUNTING.TEMP_ITEMS_LIST or {}
  67. MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST = MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST or {}
  68. MONITOR_MY_HUNTING.COLORS = MONITOR_MY_HUNTING.COLORS or {
  69. BLACK = rgbcolor(1, 1, 1),
  70. ORANGE = rgbcolor(255, 165, 0),
  71. BLUE = rgbcolor(30, 144, 255),
  72. CORNSILK = rgbcolor(205, 200, 177),
  73. WHITE = rgbcolor(255, 255, 255),
  74. GREEN = rgbcolor(107, 142, 35),
  75. RED = rgbcolor(178, 34, 34),
  76. }
  77.  
  78. local function CreateMessageObject(MESSAGE_DATA)
  79. if (type(MESSAGE_DATA) ~= "userdata") then
  80. return setmetatable({__data = {TYPE = -1, TIME_STAMP = -1, SENDER_NAME = "", SENDER_LEVEL = -1, CONTENT = ""}}, MessageMetaTable)
  81. else
  82. 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)
  83. end
  84. end
  85.  
  86. local function addtextshadow(DISPLAY_TEXT, X_OFFSET, Y_OFFSET, FONT_COLOR)
  87. setfontcolor(MONITOR_MY_HUNTING.COLORS.BLACK)
  88. addtext(DISPLAY_TEXT, X_OFFSET + 1, Y_OFFSET + 1)
  89. setfontcolor(FONT_COLOR)
  90. addtext(DISPLAY_TEXT, X_OFFSET, Y_OFFSET)
  91. end
  92. -- [[ INIT END ]] --
  93.  
  94. if (not Stats.Update()) then
  95. local SERVER_LOG_MESSAGES = getnewmessages("Server Log")
  96. local SERVER_LOG_MESSAGES_COUNT = SERVER_LOG_MESSAGES.count - 1
  97.  
  98. for INDEX = 0, SERVER_LOG_MESSAGES_COUNT do
  99. local MESSAGE_OBJECT = CreateMessageObject(SERVER_LOG_MESSAGES[SERVER_LOG_MESSAGES_COUNT - INDEX])
  100.  
  101. if (MESSAGE_OBJECT:Type() == 19 and MESSAGE_OBJECT:Content():lower():match("^loot of")) then
  102. local LOOT_INFO = Message.ParseLootMessage(MESSAGE_OBJECT, true)
  103.  
  104. if (#LOOT_INFO.NAME > 0) then
  105. Stats.__data.MONSTERS_KILLED[LOOT_INFO.NAME] = (Stats.__data.MONSTERS_KILLED[LOOT_INFO.NAME] or 0) + 1
  106.  
  107. for _, LOOT_ITEM in ipairs(LOOT_INFO.ITEMS) do
  108. if (Stats.__data.ITEMS_LOOTED[LOOT_ITEM.ID]) then
  109. Stats.__data.ITEMS_LOOTED[LOOT_ITEM.ID].QUANTITY = Stats.__data.ITEMS_LOOTED[LOOT_ITEM.ID].QUANTITY + LOOT_ITEM.QUANTITY
  110. else
  111. 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)}
  112. end
  113. end
  114. end
  115. end
  116. end
  117. end
  118.  
  119. 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
  120.  
  121. if (not RESET_ITEMS_AND_SUPPLIES) then
  122. for INDEX, LOOT_ITEM in ipairs(MONITOR_MY_HUNTING.ITEMS_LIST) do
  123. 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
  124. RESET_ITEMS_AND_SUPPLIES = true
  125. break
  126. end
  127. end
  128. end
  129.  
  130. if (not RESET_ITEMS_AND_SUPPLIES) then
  131. for INDEX, SUPPLY_ITEM in ipairs(MONITOR_MY_HUNTING.SUPPLIES_LIST) do
  132. 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
  133. RESET_ITEMS_AND_SUPPLIES = true
  134. break
  135. end
  136. end
  137. end
  138.  
  139. if (not MONITOR_MY_HUNTING.INITIALIZED or RESET_ITEMS_AND_SUPPLIES) then
  140. if (not MONITOR_MY_HUNTING.CLEARED_STATS) then
  141. Stats.Clear(CLEAR_STATS_ALL)
  142. Stats.Update()
  143.  
  144. MONITOR_MY_HUNTING.CLEARED_STATS = true
  145. end
  146.  
  147. MONITOR_MY_HUNTING.TEMP_ITEMS_LIST, MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST = {}, {}
  148.  
  149. for _, LOOT_ITEM in ipairs(MONITOR_MY_HUNTING.ITEMS_LIST) do
  150. local LOOT_ITEM_ID = Item.GetID(type(LOOT_ITEM.NAME) ~= "table" and LOOT_ITEM.NAME or unpack(LOOT_ITEM.NAME))
  151.  
  152. Stats.AddItemsLooted(LOOT_ITEM_ID, 0, LOOT_ITEM.VALUE)
  153. table.insert(MONITOR_MY_HUNTING.TEMP_ITEMS_LIST, {ID = LOOT_ITEM_ID, NAME = LOOT_ITEM.NAME, VALUE = LOOT_ITEM.VALUE})
  154. end
  155.  
  156. for _, SUPPLY_ITEM in ipairs(MONITOR_MY_HUNTING.SUPPLIES_LIST) do
  157. local SUPPLY_ITEM_ID = Item.GetID(type(SUPPLY_ITEM.NAME) ~= "table" and SUPPLY_ITEM.NAME or unpack(SUPPLY_ITEM.NAME))
  158.  
  159. Stats.AddSuppliesUsed(SUPPLY_ITEM_ID, 0, SUPPLY_ITEM.PRICE)
  160. table.insert(MONITOR_MY_HUNTING.TEMP_SUPPLIES_LIST, {ID = SUPPLY_ITEM_ID, NAME = SUPPLY_ITEM.NAME, PRICE = SUPPLY_ITEM.PRICE})
  161. end
  162.  
  163. MONITOR_MY_HUNTING.INITIALIZED = true
  164. end
  165.  
  166. setposition(Client.ClientWindow().right - 434, Client.WorldWindow().top + 5)
  167.  
  168. local Y_POSITION, INDEX, ITEMS_LOOTED_WORTH, SUPPLIES_USED_WORTH = 30, 0, 0, 0
  169.  
  170. 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)
  171.  
  172. Y_POSITION = Y_POSITION + 20
  173.  
  174. addtextshadow("ITEMS LOOTED", 10, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.BLUE)
  175.  
  176. Y_POSITION = Y_POSITION + 20
  177.  
  178. for _, LOOT_ITEM in pairs(Stats.GetItemsLooted()) do
  179. 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
  180. 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)
  181. 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)
  182.  
  183. INDEX, ITEMS_LOOTED_WORTH = INDEX + 1, ITEMS_LOOTED_WORTH + (LOOT_ITEM.VALUE * LOOT_ITEM.QUANTITY)
  184. end
  185. end
  186.  
  187. addtextshadow("Total:", 10, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.WHITE)
  188. addtextshadow(sprintf("%s GPs", Misc.FormatNumber(ITEMS_LOOTED_WORTH)), 10 + 35, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.ORANGE)
  189.  
  190. Y_POSITION = Y_POSITION + 20
  191.  
  192. addtextshadow("SUPPLIES USED", 10, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.BLUE)
  193.  
  194. Y_POSITION = Y_POSITION + 20
  195.  
  196. for _, SUPPLY_ITEM in pairs(Stats.GetSuppliesUsed()) do
  197. 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
  198. 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)
  199. 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)
  200.  
  201. INDEX, SUPPLIES_USED_WORTH = INDEX + 1, SUPPLIES_USED_WORTH + (SUPPLY_ITEM.PRICE * SUPPLY_ITEM.QUANTITY)
  202. end
  203. end
  204.  
  205. addtextshadow("Total:", 10, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.WHITE)
  206. addtextshadow(sprintf("%s GPs", Misc.FormatNumber(SUPPLIES_USED_WORTH)), 10 + 35, Y_POSITION + (INDEX * 16), MONITOR_MY_HUNTING.COLORS.ORANGE)
  207.  
  208. Y_POSITION = Y_POSITION + 20
  209.  
  210. 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