Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DMW = DMW
- local Initialized = false
- local Active = false
- local LibDraw = LibStub("LibDraw-1.0")
- local AceGUI = LibStub("AceGUI-3.0", true)
- local Player = DMW.Player
- local Target = Player.Target
- local timerHP, timerMP
- local anyReturn = false
- local timerWAIT
- local function locals()
- Player = DMW.Player
- Target = Player.Target
- Spell = Player.Spells
- anyReturn = false
- end
- -- local function locals()
- -- local anyReturn = false
- -- end
- GrindBotOptionsTable = {
- name = "GrindBot",
- handler = GrindBot,
- type = "group",
- childGroups = "tab",
- args = {
- StatsTab = {
- name = "Stats",
- type = "group",
- order = 2,
- args = {}
- },
- GeneralTab = {
- name = "Settings",
- type = "group",
- order = 1,
- args = {
- GeneralHeader = {
- type = "header",
- order = 1,
- name = "General"
- },
- Enabled = {
- type = "toggle",
- order = 2,
- name = "Enable Bot",
- desc = "Toggle to enable/disable bot",
- width = "full",
- get = function()
- return GrindBot.Settings.Enabled
- end,
- set = function(info, value)
- GrindBot.Settings.Enabled = value
- if value then
- GrindBot.Settings.Enabled = true
- else
- if IsHackEnabled("follow") then
- RunMacroText(".follow")
- end
- GrindBot.Settings.Enabled = false
- end
- end
- },
- Looting = {
- type = "toggle",
- order = 3,
- name = "Loot the mobs",
- desc = "Toggle to get the loot",
- width = "full",
- get = function()
- return GrindBot.Settings.Looting
- end,
- set = function(info, value)
- GrindBot.Settings.Looting = value
- if value then
- GrindBot.Settings.Looting = true
- else
- GrindBot.Settings.Looting = false
- end
- end
- },
- Skinning = {
- type = "toggle",
- order = 4,
- name = "Skin the mobs",
- desc = "Toggle to get the loot",
- width = "full",
- get = function()
- return GrindBot.Settings.Skinning
- end,
- set = function(info, value)
- GrindBot.Settings.Skinning = value
- if value then
- GrindBot.Settings.Skinning = true
- else
- GrindBot.Settings.Skinning = false
- end
- end
- },
- Delay = {
- type = "range",
- order = 5,
- name = "Delay",
- desc = "Set seconds to look for next target",
- width = "full",
- min = 0,
- max = 10,
- step = 1,
- get = function()
- return GrindBot.Settings.Delay
- end,
- set = function(info, value)
- GrindBot.Settings.Delay = value
- end
- },
- PlayerHP = {
- type = "range",
- order = 6,
- name = "Health",
- desc = "Set seconds to look for next target",
- width = "full",
- min = 0,
- max = 100,
- step = 10,
- get = function()
- return GrindBot.Settings.PlayerHP
- end,
- set = function(info, value)
- GrindBot.Settings.PlayerHP = value
- end
- },
- PlayerMP = {
- type = "range",
- order = 7,
- name = "Mana",
- desc = "Set seconds to look for next target",
- width = "full",
- min = 0,
- max = 100,
- step = 10,
- get = function()
- return GrindBot.Settings.PlayerMP
- end,
- set = function(info, value)
- GrindBot.Settings.PlayerMP = value
- end
- },
- PullRange = {
- type = "range",
- order = 8,
- name = "Range",
- desc = "When to shoot",
- width = "full",
- min = 0,
- max = 30,
- step = 1,
- get = function()
- return GrindBot.Settings.PullRange
- end,
- set = function(info, value)
- GrindBot.Settings.PullRange = value
- end
- },
- TargetNames = {
- type = "input",
- order = 9,
- name = "Attack units by name",
- desc = "Attack units by name or part of name, seperated by comma",
- width = "full",
- get = function()
- return GrindBot.Settings.TargetNames
- end,
- set = function(info, value)
- GrindBot.Settings.TargetNames = value
- end
- }
- -- asdd = {
- -- type = "toggle",
- -- order = 7,
- -- name = "Loot the mobs",
- -- desc = "Toggle to get the loot",
- -- width = "full",
- -- -- get = function()
- -- -- return GrindBot.Settings.Looting
- -- -- end,
- -- -- set = function(info, value)
- -- -- GrindBot.Settings.Looting = value
- -- -- if value then
- -- -- GrindBot.Settings.Looting = true
- -- -- else
- -- -- GrindBot.Settings.Looting = false
- -- -- end
- -- -- end
- -- }
- }
- },
- WaypointsTab = {
- name = "Waypoints",
- type = "group",
- order = 3,
- args = {
- GeneralHeader = {
- type = "header",
- order = 1,
- name = "Waypoints"
- },
- Enabled = {
- type = "toggle",
- order = 2,
- name = "Enable Bot",
- desc = "Toggle to enable/disable bot",
- width = "full",
- get = function()
- return GrindBot.Settings.Enabled
- end,
- set = function(info, value)
- GrindBot.Settings.Enabled = value
- if value then
- GrindBot.Settings.Enabled = true
- else
- GrindBot.Settings.Enabled = false
- end
- end
- }
- }
- }
- }
- }
- local function Initialize()
- GrindBot = {}
- GrindBot.Waypoints = {}
- GrindBot.WaypointsGY = {}
- GrindBot.WaypointsVend = {}
- GrindBot.Units = {}
- GrindBot.Settings = {}
- LibStub("AceConfig-3.0"):RegisterOptionsTable("GrindBotConfig", GrindBotOptionsTable)
- LibStub("AceConfigDialog-3.0"):SetDefaultSize("GrindBotConfig", 400, 350)
- Initialized = true
- end
- local function startHPCheck()
- if timerHP == nil then timerHP = DMW.Time end
- if DMW.Player.HP < GrindBot.Settings.PlayerHP and not Player.Combat then
- if not Player:AuraByID(11196) and Player.DOTed == nil and not Player.Moving and (DMW.Time - timerHP >= 1) then
- RunMacroText("/use Heavy Runecloth Bandage")
- timerHP = DMW.Time
- end
- anyReturn = true
- end
- end
- local function startMPCheck()
- if timerMP == nil then timerMP = DMW.Time end
- if DMW.Player.HP < GrindBot.Settings.PlayerMP and not Player.Combat then
- if not Player.Moving and (DMW.Time - timerMP >= 1) then
- ---mana
- RunMacroText("/use Heavy Runecloth Bandage")
- timerMP = DMW.Time
- end
- anyReturn = true
- end
- end
- local function unitTable()
- table.sort(
- -- GrindBot.Units,
- DMW.Attackable,
- function(x, y)
- return x.Distance < y.Distance
- end
- )
- end
- local function recheckEnemies()
- if (not Target or Target.Dead) and #DMW.Enemies > 0 then
- for i = 1, #DMW.Enemies do
- local thisUnit = DMW.Enemies[i]
- if thisUnit.CreatureType ~= "Critter" and not thisUnit.Player then
- TargetUnit(DMW.Enemies[i])
- return true
- end
- end
- end
- end
- local function findTarget()
- if not Player.CombatLeft or Player.CombatLeftTime > GrindBot.Settings.Delay then
- for i = 1, #DMW.Attackable do
- local thisUnit = DMW.Attackable[i]
- if not thisUnit.Dead and thisUnit.CreatureType ~= "Critter" and not thisUnit.Player and not UnitIsTapDenied(thisUnit.Pointer) then
- if GrindBot.Settings.TargetNames and GrindBot.Settings.TargetNames ~= "" then
- for k in string.gmatch(GrindBot.Settings.TargetNames, "([^,]+)") do
- if strmatch(string.lower(thisUnit.Name), string.lower(string.trim(k))) then
- TargetUnit(thisUnit.Pointer)
- return true
- end
- end
- else
- TargetUnit(thisUnit.Pointer)
- return true
- end
- end
- end
- end
- end
- local function followTarget()
- if Target and not Target.Dead then
- if not Target.Facing then
- FaceDirection(Target.Pointer, true)
- end
- if Target.Distance > 2 and not IsHackEnabled("follow") then
- RunMacroText(".follow 2")
- end
- else
- if IsHackEnabled("follow") then
- RunMacroText(".follow")
- end
- end
- end
- local Looting
- local function lootingFunc()
- if GrindBot.Settings.Looting then
- for _, Unit in pairs(DMW.Units) do
- if Unit.Dead and Unit.Distance < 5 and UnitCanBeLooted(Unit.Pointer) then
- anyReturn = true
- if (Looting == nil or DMW.Time > Looting) and not DMW.Player.Casting and not IsMounted() and not UnitIsDeadOrGhost("player") then
- InteractUnit(Unit.Pointer)
- Looting = DMW.Time + 1
- end
- return true
- end
- end
- end
- end
- local Skinning
- local function skinningFunc()
- if GrindBot.Settings.Skinning then
- for _, Unit in pairs(DMW.Units) do
- if Unit.Dead and Unit.Distance < 5 and UnitCanBeSkinned(Unit.Pointer) then
- anyReturn = true
- if (Skinning == nil or DMW.Time > Skinning) and not DMW.Player.Casting and not IsMounted() and not UnitIsDeadOrGhost("player") then
- InteractUnit(Unit.Pointer)
- Skinning = DMW.Time + 1
- end
- return true
- end
- end
- end
- end
- -- local function jumpCheck()
- -- local oldX,oldY,oldZ, X,Y,Z, timer
- -- if oldX,oldY,oldZ == nil then --or DMW.Time - timer >= 1 then
- -- oldX,oldY,oldZ = DMW.Player.PosX, DMW.Player.PosY, DMW.Player.PosZ
- -- timer = DMW.Time
- -- end
- -- if DMW.Time - timer >= 1 then
- -- if DMW.Player.Posx == oldX and DMW.Player.PosY == oldY then
- -- JumpOrAscendStart(); print("jump")
- -- end
- -- end
- -- end
- local function addWaypoint(x,y,z,value)
- local value = value or "main"
- local waypoint = {}
- waypoint.posX = x
- waypoint.posY = y
- waypoint.posZ = z
- if value == "main" then
- if GrindBot.Waypoints["main"] == nil then
- GrindBot.Waypoints["main"] = {}
- end
- tinsert(GrindBot.Waypoints["main"], waypoint)
- else
- if GrindBot.Waypoints["Backup"] == nil then
- GrindBot.Waypoints["Backup"] = {}
- end
- tinsert(GrindBot.Waypoints["Backup"], waypoint)
- end
- end
- local function GrindEngine()
- if not Initialized then
- Initialize()
- end
- if GrindBot.Settings.Enabled then
- locals()
- if not Player.Combat then
- skinningFunc()
- lootingFunc()
- startHPCheck()
- startMPCheck()
- end
- if anyReturn or Player.Casting then timerWAIT = (DMW.Time + 1); return true end
- if timerWAIT and DMW.Time <= timerWAIT then return true end
- timerWAIT = nil
- followTarget()
- if not Player.Combat then
- unitTable()
- findTarget()
- -- jumpCheck()
- -- readyCheck()
- -- movingCheck()
- -- lootingCheck()
- else
- recheckEnemies()
- end
- followTarget()
- end
- end
- local function showUI()
- if not GrindBot.ConfigFrame then
- GrindBot.ConfigFrame = AceGUI:Create("Frame")
- GrindBot.ConfigFrame:Hide()
- _G["GrindBotConfigFrame"] = GrindBot.ConfigFrame.frame
- table.insert(UISpecialFrames, "GrindBotConfigFrame")
- end
- if not GrindBot.ConfigFrame:IsShown() then
- LibStub("AceConfigDialog-3.0"):Open("GrindBotConfig", GrindBot.ConfigFrame)
- else
- GrindBot.ConfigFrame:Hide()
- end
- end
- SLASH_grindbot1 = "/grindbot"
- SlashCmdList["grindbot"] = function(msg)
- showUI()
- end
- SLASH_addwp1 = "/addwp"
- SlashCmdList["addwp"] = function(msg)
- local getX, getY = GetMousePosition()
- local x,y,z = ScreenToWorld(getX, getY)
- addWaypoint(x,y,z,msg)
- end
- DMW.Plugins.GrindBot = GrindEngine
- -- if MyPlugin() then return true end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement