Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.06 KB | None | 0 0
  1. local DMW = DMW
  2. local Initialized = false
  3. local Active = false
  4. local LibDraw = LibStub("LibDraw-1.0")
  5. local AceGUI = LibStub("AceGUI-3.0", true)
  6. local Player = DMW.Player
  7. local Target = Player.Target
  8. local timerHP, timerMP
  9. local anyReturn = false
  10. local timerWAIT
  11. local function locals()
  12. Player = DMW.Player
  13. Target = Player.Target
  14. Spell = Player.Spells
  15. anyReturn = false
  16.  
  17. end
  18. -- local function locals()
  19. -- local anyReturn = false
  20.  
  21. -- end
  22.  
  23.  
  24.  
  25. GrindBotOptionsTable = {
  26. name = "GrindBot",
  27. handler = GrindBot,
  28. type = "group",
  29. childGroups = "tab",
  30. args = {
  31. StatsTab = {
  32. name = "Stats",
  33. type = "group",
  34. order = 2,
  35. args = {}
  36. },
  37. GeneralTab = {
  38. name = "Settings",
  39. type = "group",
  40. order = 1,
  41. args = {
  42. GeneralHeader = {
  43. type = "header",
  44. order = 1,
  45. name = "General"
  46. },
  47. Enabled = {
  48. type = "toggle",
  49. order = 2,
  50. name = "Enable Bot",
  51. desc = "Toggle to enable/disable bot",
  52. width = "full",
  53. get = function()
  54. return GrindBot.Settings.Enabled
  55. end,
  56. set = function(info, value)
  57. GrindBot.Settings.Enabled = value
  58. if value then
  59. GrindBot.Settings.Enabled = true
  60. else
  61. if IsHackEnabled("follow") then
  62. RunMacroText(".follow")
  63. end
  64. GrindBot.Settings.Enabled = false
  65. end
  66. end
  67. },
  68. Looting = {
  69. type = "toggle",
  70. order = 3,
  71. name = "Loot the mobs",
  72. desc = "Toggle to get the loot",
  73. width = "full",
  74. get = function()
  75. return GrindBot.Settings.Looting
  76. end,
  77. set = function(info, value)
  78. GrindBot.Settings.Looting = value
  79. if value then
  80. GrindBot.Settings.Looting = true
  81. else
  82. GrindBot.Settings.Looting = false
  83. end
  84. end
  85. },
  86. Skinning = {
  87. type = "toggle",
  88. order = 4,
  89. name = "Skin the mobs",
  90. desc = "Toggle to get the loot",
  91. width = "full",
  92. get = function()
  93. return GrindBot.Settings.Skinning
  94. end,
  95. set = function(info, value)
  96. GrindBot.Settings.Skinning = value
  97. if value then
  98. GrindBot.Settings.Skinning = true
  99. else
  100. GrindBot.Settings.Skinning = false
  101. end
  102. end
  103. },
  104. Delay = {
  105. type = "range",
  106. order = 5,
  107. name = "Delay",
  108. desc = "Set seconds to look for next target",
  109. width = "full",
  110. min = 0,
  111. max = 10,
  112. step = 1,
  113. get = function()
  114. return GrindBot.Settings.Delay
  115. end,
  116. set = function(info, value)
  117. GrindBot.Settings.Delay = value
  118. end
  119. },
  120. PlayerHP = {
  121. type = "range",
  122. order = 6,
  123. name = "Health",
  124. desc = "Set seconds to look for next target",
  125. width = "full",
  126. min = 0,
  127. max = 100,
  128. step = 10,
  129. get = function()
  130. return GrindBot.Settings.PlayerHP
  131. end,
  132. set = function(info, value)
  133. GrindBot.Settings.PlayerHP = value
  134. end
  135. },
  136. PlayerMP = {
  137. type = "range",
  138. order = 7,
  139. name = "Mana",
  140. desc = "Set seconds to look for next target",
  141. width = "full",
  142. min = 0,
  143. max = 100,
  144. step = 10,
  145. get = function()
  146. return GrindBot.Settings.PlayerMP
  147. end,
  148. set = function(info, value)
  149. GrindBot.Settings.PlayerMP = value
  150. end
  151. },
  152. PullRange = {
  153. type = "range",
  154. order = 8,
  155. name = "Range",
  156. desc = "When to shoot",
  157. width = "full",
  158. min = 0,
  159. max = 30,
  160. step = 1,
  161. get = function()
  162. return GrindBot.Settings.PullRange
  163. end,
  164. set = function(info, value)
  165. GrindBot.Settings.PullRange = value
  166. end
  167. },
  168. TargetNames = {
  169. type = "input",
  170. order = 9,
  171. name = "Attack units by name",
  172. desc = "Attack units by name or part of name, seperated by comma",
  173. width = "full",
  174. get = function()
  175. return GrindBot.Settings.TargetNames
  176. end,
  177. set = function(info, value)
  178. GrindBot.Settings.TargetNames = value
  179. end
  180. }
  181. -- asdd = {
  182. -- type = "toggle",
  183. -- order = 7,
  184. -- name = "Loot the mobs",
  185. -- desc = "Toggle to get the loot",
  186. -- width = "full",
  187. -- -- get = function()
  188. -- -- return GrindBot.Settings.Looting
  189. -- -- end,
  190. -- -- set = function(info, value)
  191. -- -- GrindBot.Settings.Looting = value
  192. -- -- if value then
  193. -- -- GrindBot.Settings.Looting = true
  194. -- -- else
  195. -- -- GrindBot.Settings.Looting = false
  196. -- -- end
  197. -- -- end
  198. -- }
  199. }
  200. },
  201. WaypointsTab = {
  202. name = "Waypoints",
  203. type = "group",
  204. order = 3,
  205. args = {
  206. GeneralHeader = {
  207. type = "header",
  208. order = 1,
  209. name = "Waypoints"
  210. },
  211. Enabled = {
  212. type = "toggle",
  213. order = 2,
  214. name = "Enable Bot",
  215. desc = "Toggle to enable/disable bot",
  216. width = "full",
  217. get = function()
  218. return GrindBot.Settings.Enabled
  219. end,
  220. set = function(info, value)
  221. GrindBot.Settings.Enabled = value
  222. if value then
  223. GrindBot.Settings.Enabled = true
  224. else
  225. GrindBot.Settings.Enabled = false
  226. end
  227. end
  228. }
  229. }
  230. }
  231.  
  232. }
  233. }
  234.  
  235. local function Initialize()
  236. GrindBot = {}
  237. GrindBot.Waypoints = {}
  238. GrindBot.WaypointsGY = {}
  239. GrindBot.WaypointsVend = {}
  240. GrindBot.Units = {}
  241. GrindBot.Settings = {}
  242.  
  243. LibStub("AceConfig-3.0"):RegisterOptionsTable("GrindBotConfig", GrindBotOptionsTable)
  244. LibStub("AceConfigDialog-3.0"):SetDefaultSize("GrindBotConfig", 400, 350)
  245. Initialized = true
  246. end
  247.  
  248.  
  249.  
  250. local function startHPCheck()
  251. if timerHP == nil then timerHP = DMW.Time end
  252. if DMW.Player.HP < GrindBot.Settings.PlayerHP and not Player.Combat then
  253. if not Player:AuraByID(11196) and Player.DOTed == nil and not Player.Moving and (DMW.Time - timerHP >= 1) then
  254. RunMacroText("/use Heavy Runecloth Bandage")
  255. timerHP = DMW.Time
  256. end
  257. anyReturn = true
  258. end
  259. end
  260.  
  261. local function startMPCheck()
  262. if timerMP == nil then timerMP = DMW.Time end
  263. if DMW.Player.HP < GrindBot.Settings.PlayerMP and not Player.Combat then
  264. if not Player.Moving and (DMW.Time - timerMP >= 1) then
  265. ---mana
  266. RunMacroText("/use Heavy Runecloth Bandage")
  267. timerMP = DMW.Time
  268. end
  269. anyReturn = true
  270. end
  271. end
  272.  
  273. local function unitTable()
  274. table.sort(
  275. -- GrindBot.Units,
  276. DMW.Attackable,
  277. function(x, y)
  278. return x.Distance < y.Distance
  279. end
  280. )
  281. end
  282.  
  283. local function recheckEnemies()
  284. if (not Target or Target.Dead) and #DMW.Enemies > 0 then
  285. for i = 1, #DMW.Enemies do
  286. local thisUnit = DMW.Enemies[i]
  287. if thisUnit.CreatureType ~= "Critter" and not thisUnit.Player then
  288. TargetUnit(DMW.Enemies[i])
  289. return true
  290. end
  291. end
  292. end
  293. end
  294.  
  295. local function findTarget()
  296. if not Player.CombatLeft or Player.CombatLeftTime > GrindBot.Settings.Delay then
  297. for i = 1, #DMW.Attackable do
  298. local thisUnit = DMW.Attackable[i]
  299. if not thisUnit.Dead and thisUnit.CreatureType ~= "Critter" and not thisUnit.Player and not UnitIsTapDenied(thisUnit.Pointer) then
  300. if GrindBot.Settings.TargetNames and GrindBot.Settings.TargetNames ~= "" then
  301. for k in string.gmatch(GrindBot.Settings.TargetNames, "([^,]+)") do
  302. if strmatch(string.lower(thisUnit.Name), string.lower(string.trim(k))) then
  303. TargetUnit(thisUnit.Pointer)
  304. return true
  305. end
  306. end
  307. else
  308. TargetUnit(thisUnit.Pointer)
  309. return true
  310. end
  311. end
  312. end
  313. end
  314. end
  315.  
  316. local function followTarget()
  317. if Target and not Target.Dead then
  318. if not Target.Facing then
  319. FaceDirection(Target.Pointer, true)
  320. end
  321. if Target.Distance > 2 and not IsHackEnabled("follow") then
  322. RunMacroText(".follow 2")
  323. end
  324. else
  325. if IsHackEnabled("follow") then
  326. RunMacroText(".follow")
  327. end
  328. end
  329. end
  330.  
  331. local Looting
  332.  
  333. local function lootingFunc()
  334. if GrindBot.Settings.Looting then
  335. for _, Unit in pairs(DMW.Units) do
  336. if Unit.Dead and Unit.Distance < 5 and UnitCanBeLooted(Unit.Pointer) then
  337. anyReturn = true
  338. if (Looting == nil or DMW.Time > Looting) and not DMW.Player.Casting and not IsMounted() and not UnitIsDeadOrGhost("player") then
  339. InteractUnit(Unit.Pointer)
  340. Looting = DMW.Time + 1
  341. end
  342. return true
  343. end
  344. end
  345. end
  346. end
  347.  
  348. local Skinning
  349. local function skinningFunc()
  350. if GrindBot.Settings.Skinning then
  351. for _, Unit in pairs(DMW.Units) do
  352. if Unit.Dead and Unit.Distance < 5 and UnitCanBeSkinned(Unit.Pointer) then
  353. anyReturn = true
  354. if (Skinning == nil or DMW.Time > Skinning) and not DMW.Player.Casting and not IsMounted() and not UnitIsDeadOrGhost("player") then
  355. InteractUnit(Unit.Pointer)
  356. Skinning = DMW.Time + 1
  357. end
  358. return true
  359. end
  360. end
  361. end
  362. end
  363.  
  364. -- local function jumpCheck()
  365. -- local oldX,oldY,oldZ, X,Y,Z, timer
  366. -- if oldX,oldY,oldZ == nil then --or DMW.Time - timer >= 1 then
  367. -- oldX,oldY,oldZ = DMW.Player.PosX, DMW.Player.PosY, DMW.Player.PosZ
  368. -- timer = DMW.Time
  369. -- end
  370.  
  371. -- if DMW.Time - timer >= 1 then
  372. -- if DMW.Player.Posx == oldX and DMW.Player.PosY == oldY then
  373. -- JumpOrAscendStart(); print("jump")
  374. -- end
  375. -- end
  376. -- end
  377.  
  378. local function addWaypoint(x,y,z,value)
  379. local value = value or "main"
  380. local waypoint = {}
  381. waypoint.posX = x
  382. waypoint.posY = y
  383. waypoint.posZ = z
  384. if value == "main" then
  385. if GrindBot.Waypoints["main"] == nil then
  386. GrindBot.Waypoints["main"] = {}
  387. end
  388. tinsert(GrindBot.Waypoints["main"], waypoint)
  389. else
  390. if GrindBot.Waypoints["Backup"] == nil then
  391. GrindBot.Waypoints["Backup"] = {}
  392. end
  393. tinsert(GrindBot.Waypoints["Backup"], waypoint)
  394. end
  395. end
  396.  
  397.  
  398. local function GrindEngine()
  399. if not Initialized then
  400. Initialize()
  401. end
  402.  
  403. if GrindBot.Settings.Enabled then
  404. locals()
  405.  
  406.  
  407.  
  408. if not Player.Combat then
  409. skinningFunc()
  410. lootingFunc()
  411. startHPCheck()
  412. startMPCheck()
  413. end
  414.  
  415. if anyReturn or Player.Casting then timerWAIT = (DMW.Time + 1); return true end
  416. if timerWAIT and DMW.Time <= timerWAIT then return true end
  417. timerWAIT = nil
  418.  
  419.  
  420. followTarget()
  421.  
  422.  
  423. if not Player.Combat then
  424. unitTable()
  425. findTarget()
  426. -- jumpCheck()
  427. -- readyCheck()
  428. -- movingCheck()
  429. -- lootingCheck()
  430. else
  431. recheckEnemies()
  432. end
  433. followTarget()
  434. end
  435. end
  436.  
  437. local function showUI()
  438. if not GrindBot.ConfigFrame then
  439. GrindBot.ConfigFrame = AceGUI:Create("Frame")
  440. GrindBot.ConfigFrame:Hide()
  441. _G["GrindBotConfigFrame"] = GrindBot.ConfigFrame.frame
  442. table.insert(UISpecialFrames, "GrindBotConfigFrame")
  443. end
  444. if not GrindBot.ConfigFrame:IsShown() then
  445. LibStub("AceConfigDialog-3.0"):Open("GrindBotConfig", GrindBot.ConfigFrame)
  446. else
  447. GrindBot.ConfigFrame:Hide()
  448. end
  449. end
  450.  
  451. SLASH_grindbot1 = "/grindbot"
  452. SlashCmdList["grindbot"] = function(msg)
  453. showUI()
  454. end
  455.  
  456. SLASH_addwp1 = "/addwp"
  457. SlashCmdList["addwp"] = function(msg)
  458. local getX, getY = GetMousePosition()
  459. local x,y,z = ScreenToWorld(getX, getY)
  460. addWaypoint(x,y,z,msg)
  461. end
  462.  
  463. DMW.Plugins.GrindBot = GrindEngine
  464.  
  465. -- if MyPlugin() then return true end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement