daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- GrindBot v1.0 by l0l1dk
  2. -- Credit to Chaotic and cdmichaelb, for pieces of their scripts that I used in this
  3.  
  4. --- User Variables ---
  5. MountMacro = "Mount"; -- Change this to your mount macro name
  6. Color = 0xFFFFD700;
  7. HealSpell = "Rejuvenation"; -- Name of your healing spell
  8. HealPercent = 0.30; -- When to heal, 1.0 is full health, 0.5 is 50%.
  9. SpecificTarget = 0;-- The name of a specific mob to target. Set to 0 to target all
  10. AttackMacro = "Attack"; -- Name of your attack macro
  11. FoodName = ""; -- Name of the food to be eaten out of combat, can be a spell
  12. DrinkName = ""; -- Not currently working -- Name of the drink to be drank out of combat, can be a spell
  13. Speed = 1.0;  -- Speedhack speed (Ignore players should be set to false)
  14. NoCombatHealth = 0.40; -- What percent to not enter combat again until healed
  15. IgnorePlayers = true; -- Set to false if you want to stop grinding when a player is near
  16. CheckClass = true; -- Whether to determine if you're a melee by your class.
  17. -- If you're a Enh Shaman or a Balance Druid, this needs to be false, and the isMelee global to be changed
  18. RotationBot = false;
  19. -- Whether to do rotations the same way as RotationBot
  20. -- Use it if you have modules for your class/spec, it's smarter than AttackMacro
  21. ----------------------
  22. ------ Globals -------
  23. SHDisabled = false;
  24. Stopped = false;
  25. CurrentWaypoint = 0;
  26. Started = false;
  27. Pause = false;
  28. Wait = 0;
  29. One = false;
  30. Two = false;
  31. Three = false;
  32. Sleep = 0;
  33. Loot = Player.Pointer;
  34. PlayerLevel = game.getLevel(Player.Pointer);
  35. isMelee = false; -- isMelee Global
  36. MountPause = 0;
  37. Eating = 0;
  38. Time1 = 0;
  39. Time2 = 0;
  40. Time3 = 0;
  41. BadTarget = 0;
  42. isRezing = 0;
  43. ----------------------
  44. -- Waypoint list --
  45. Waypoint =
  46. {
  47.     --List must always end with {0,0,0},
  48.     {-1923.0455322266, 2313.78515625, 38.856819152832},
  49. {-1915.8654785156, 2321.4404296875, 38.778018951416},
  50. {-1909.8558349609, 2329.744140625, 39.068874359131},
  51. {-1910.5057373047, 2339.4353027344, 37.92626953125},
  52. {-1919.4293212891, 2344.2529296875, 35.357757568359},
  53. {-1929.2352294922, 2344.6599121094, 34.267276763916},
  54. {-1936.5455322266, 2337.9064941406, 34.148983001709},
  55. {-1941.9899902344, 2328.81640625, 34.593441009521},
  56. {-1946.6790771484, 2319.7907714844, 34.693256378174},
  57. {-1951.5794677734, 2310.3586425781, 34.809047698975},
  58. {-1951.3131103516, 2300.2585449219, 35.863285064697},
  59. {-1946.7491455078, 2291.0895996094, 37.703338623047},
  60. {-1938.0968017578, 2293.0661621094, 38.99295425415},
  61. {-1930.7525634766, 2300.9477539063, 38.848087310791},
  62. {0, 0, 0},
  63. }
  64.  
  65. function Load()
  66.     if MountID == 0 and PlayerLevel > 19 then
  67.         game.printChat("Please set the 'MountID' variable.",0xffff0000);
  68.         return 0;
  69.     end
  70.     game.printChat("GrindBot v1.0 loaded.",Color);
  71.     if CheckClass == true then
  72.         GetMelee();
  73.     end
  74.     system.setSpeedhack(Speed);
  75.     system.collisionlite(1);
  76.     system.collision(1);
  77.     system.setTimerCallback("Time",15);
  78.     system.setCommandCallback("Commands");
  79. end
  80.  
  81. function Commands(Cmd)
  82.     Cmd = string.lower(Cmd);
  83.     if Cmd == ".gb goto" then
  84.         GetNearestWaypoint();
  85.         teleport.addEvent(Waypoint[CurrentWaypoint][1],Waypoint[CurrentWaypoint][2],Waypoint[CurrentWaypoint][3]);
  86.         game.printChat("Teleporting to nearest waypoint.",Color);
  87.     end
  88.     if Cmd == ".gb start" and Pause == true then
  89.         Pause = false;
  90.     end
  91.     if Cmd == ".gb stop" and Pause == false then
  92.         Pause = true;
  93.     end
  94. end
  95.  
  96. function Time()
  97.     Time1 = Time1 + 1;
  98.     Time2 = Time2 + 1;
  99.     if Time1 > 2 then -- and game.isLootable(Loot) == 0
  100.         Bot();
  101.         Time1 = 0;
  102.     end
  103.     --[[if Time2 > 5 and game.isLootable(Loot) == 1 then
  104.         Timer();
  105.         Time2 = 0;
  106.     end]]
  107. end
  108.  
  109. function Bot()
  110. if Target.Pointer ~= 0 then
  111.     Time3 = Time3 + 1;
  112. end
  113. if Sleep > 0 then
  114.     Sleep = Sleep - 1;
  115.     return;
  116. end
  117. if Pause == true then
  118.     return;
  119. end
  120. if Player.Life < 2 then
  121.     Rez();
  122. end
  123. if Target.Pointer == BadTarget then
  124.     game.doString("RunMacroText('/cleartarget');");
  125. end
  126. if game.isInCombat(Player.Pointer) == 1 and Target.Pointer == 0 then
  127.     move.stop();
  128.     return;
  129. end
  130. X, Y, Z = game.getCoordinates(Loot);
  131. if GetDistance3D(X,Y,Z,Player.X,Player.Y,Player.Z) < 6 and Loot ~= Player.Pointer and game.isLootable(Loot) == 1 then
  132.     game.useObject(Loot);
  133.     Sleep = 25;
  134.     return;
  135. end
  136. if Target.Life / Target.MaxLife > 0.8 and Target.Pointer ~= 0 and game.isInCombat(Player.Pointer) == 0 then
  137.     if Time3 > 50 then
  138.         game.doString("RunMacroText('/cleartarget');");
  139.         BadTarget = Target.Pointer;
  140.         Time3 = 0;
  141.         GetNextWaypoint();
  142.         move.to(Waypoint[CurrentWaypoint][1],Waypoint[CurrentWaypoint][2],Waypoint[CurrentWaypoint][3]);
  143.     end
  144. end
  145. if IgnorePlayers == false then
  146.     CheckArea();
  147. end
  148. if Stopped == false or game.isInCombat(Player.Pointer) == 1 then
  149.     if Target.Pointer == 0 then
  150.         if game.getLife(Player.Pointer) / game.getMaxLife(Player.Pointer) < NoCombatHealth and game.isInCombat(Player.Pointer) == 0 then
  151.             Sleep = 200;
  152.             game.doString((string.format("RunMacroText('/cast %s');",FoodName)));
  153.             game.doString((string.format("RunMacroText('/cast %s');",DrinkName)));
  154.         else
  155.             GetTarget();
  156.             if game.isMounted(Player.Pointer) == 0 and PlayerLevel > 19 then
  157.                 Mount();
  158.                 Sleep = 20;
  159.             else
  160.                 if move.isMoving(Player.Pointer) == 0 then
  161.                     if Started == false then
  162.                         GetNearestWaypoint();
  163.                         Started = true;
  164.                     else
  165.                         GetNextWaypoint();
  166.                     end
  167.                     move.to(Waypoint[CurrentWaypoint][1],Waypoint[CurrentWaypoint][2],Waypoint[CurrentWaypoint][3]);
  168.                     -- Waypoint[CurrentWaypoint][3]
  169.                 end
  170.             end
  171.         end
  172.     end
  173.     if Target.Pointer ~= 0 and game.getLife(Target.Pointer) ~= 0 then
  174.         Combat();
  175.     end
  176.     if Target.Pointer ~= 0 and game.getLife(Target.Pointer) == 0 then
  177.         game.doString("RunMacroText('/cleartarget');");
  178.     end
  179. end
  180. end
  181.  
  182. function Mount()
  183.     if game.isMounted(Player.Pointer) == 0 then
  184.         game.doString("RunMacro('Mount');");
  185.     end
  186. end
  187.  
  188. function GetTarget()
  189.     if SpecificTarget == 0 and game.isInCombat(Player.Pointer) == 0 then
  190.         game.doString("RunMacroText('/targetenemy')");
  191.     end
  192.     if SpecificTarget ~= 0 and game.isInCombat(Player.Pointer) == 0 then
  193.         game.doString((string.format("RunMacroText('/target %s');",SpecificTarget)));
  194.     end
  195. end
  196.  
  197. function Heal()
  198.     game.doString("RunMacroText('/cast Healing Surge')"); -- Change "Healing Surge" to the name of your healing spell
  199. end
  200.  
  201. function Rez()
  202.     if One == false then
  203.         game.doString("RepopMe()");
  204.         Sleep = 100;
  205.         One = true;
  206.         return;
  207.     end
  208.     if Two == false then
  209.         X, Y, Z = game.getCorpseCoordinates();
  210.         teleport.addEvent(X,Y,Z);
  211.         Two = true;
  212.         Sleep = 50;
  213.         return;
  214.     end
  215.     if Three == false then
  216.         game.doString("RepopMe()");
  217.         Sleep = 50;
  218.         One = false;
  219.         Two = false;
  220.         Three = false;
  221.         return;
  222.     end
  223. end
  224.  
  225. function Combat()
  226.     Eating = 0;
  227.     Wait = 70;
  228.     if Target.Pointer ~= 0 then
  229.         Loot = Target.Pointer;
  230.     end
  231.     if game.getLife(Player.Pointer) / game.getMaxLife(Player.Pointer) < NoCombatHealth and game.isInCombat(Player.Pointer) == 0 then
  232.         Heal();
  233.         return 0;
  234.     end
  235.     if isMelee == true then
  236.         if GetDistance3D(Player.X,Player.Y,Player.Z,Target.X,Target.Y,Target.Z) > 3 then
  237.             move.to(Target.X,Target.Y,Target.Z);
  238.         end
  239.         if GetDistance3D(Player.X,Player.Y,Player.Z,Target.X,Target.Y,Target.Z) < 4 and move.isMoving(Player.Pointer) == 1 then
  240.             move.stop();
  241.         end
  242.     end
  243.     move.faceObject(Target.Pointer);
  244.     if move.isMoving(Player.Pointer) == 1 and isMelee == false then
  245.         move.stop();
  246.     end
  247.     if game.getLife(Player.Pointer) / game.getMaxLife(Player.Pointer) < HealPercent then
  248.         game.doString(string.format("RunMacroText('/cast %s')",HealSpell));
  249.     else
  250.         if RotationBot == true then
  251.             game.doString(string.format("RunMacroText('/fr pwn')"));
  252.         else
  253.             game.doString(string.format("RunMacro('%s');",AttackMacro));
  254.         end
  255.     end
  256.     Timer();
  257. end
  258.  
  259. function CheckArea() -- Credit to Chaotic and cdmichaelb for this function
  260.     local EntryCount,ThisObject, PlayerFound, isChanneling;
  261.     game.updateObjectList();
  262.     EntryCount = game.getObjectListEntryCount();
  263.     PlayerFound = false;
  264.     for i = 0, EntryCount, 1 do
  265.         ThisObject = game.getObjectListEntry(i);
  266.         if ThisObject ~= Player.Pointer and game.getType(ThisObject) == TYPE_PLAYER then
  267.             PlayerFound = true;
  268.             break;
  269.         end
  270.     end
  271.     isChanneling = game.getObjectAttribute(Player.Pointer,0x16);
  272.     if PlayerFound == true then
  273.         if SHDisabled == false and isChanneling == 0 then
  274.             SHDisabled = true;
  275.             Stopped = true;
  276.             system.setSpeedhack(1.0);
  277.         --  system.collisionlite(0);
  278.         --  system.climbhack(0);
  279.         end
  280.     else
  281.         if SHDisabled == true and isChanneling == 0 then
  282.             SHDisabled = false;
  283.             Stopped = false;
  284.             system.setSpeedhack(Speed);
  285.         --  system.collisionlite(1);
  286.         --  system.climbhack(1);
  287.         end
  288.     end
  289. end
  290.  
  291. function GetMelee()
  292.     Class = game.getClass(Player.Pointer);
  293.     if Class == "Warrior" then
  294.         isMelee = true;
  295.     elseif Class == "Paladin" then
  296.         isMelee = true;
  297.     elseif Class == "Warlock" then
  298.         isMelee =  false;
  299.     elseif Class == "Mage" then
  300.         isMelee = false;
  301.     elseif Class == "Druid" then
  302.         isMelee = true;
  303.     elseif Class == "Shaman" then
  304.         isMelee = false;
  305.     elseif Class == "Priest" then
  306.         isMelee = false;
  307.     elseif Class == "Death Knight" then
  308.         isMelee = true;
  309.     elseif Class == "Hunter" then
  310.         isMelee = false;
  311.     elseif Class == "Rogue" then
  312.         isMelee = true;
  313.     end
  314. end
  315.  
  316. -- Credit to Chaotic for everything below here
  317.  
  318. function GetNextWaypoint()
  319.     CurrentWaypoint = CurrentWaypoint + 1;
  320.     if Waypoint[CurrentWaypoint][1] == 0 then
  321.         CurrentWaypoint = 1;
  322.     end
  323. end
  324.  
  325. function GetNearestWaypoint()
  326.     --Get nearest waypoint to current position
  327.     local Distance,BestDistance,i;
  328.     i = 1;
  329.     while Waypoint[i][1] ~= 0 do
  330.         Distance = GetDistance2D(Player.X,Player.Y,Waypoint[i][1],Waypoint[i][2]);
  331.         if i == 1 or Distance < BestDistance and Distance > 5 then
  332.             BestDistance = Distance;
  333.             CurrentWaypoint = i;
  334.         end
  335.         i = i + 1;
  336.     end
  337. end
  338.  
  339. function GetDistance2D(x1,y1,x2,y2)
  340.     --c² = a² + b²
  341.     local d1,d2;
  342.     d1 = x2 - x1;
  343.     d1 = d1*d1;
  344.     d2 = y2 - y1;
  345.     d2 = d2*d2;
  346.     return math.sqrt(d1+d2);
  347. end
  348.  
  349. function GetDistance3D(x1,y1,z1,x2,y2,z2)
  350.     local d1,d2,d3;
  351.     d1 = x2 - x1;
  352.     d1 = d1*d1;
  353.     d2 = y2 - y1;
  354.     d2 = d2*d2;
  355.     d3 = z2 - z1;
  356.     d3 = d3*d3;
  357.     return math.sqrt(d1+d2+d3);
  358. end
  359.  
  360. function IsInRange( Object )
  361.     local ObjectX, ObjectY, ObjectZ;
  362.     ObjectX, ObjectY, ObjectZ = game.getCoordinates(Object);
  363.     if GetDistance3D( Player.X, Player.Y, Player.Z, ObjectX, ObjectY, ObjectZ ) < 5 then
  364.         return 1;
  365.     end
  366.     return 0;
  367. end
  368.  
  369. TickPause = 0;
  370. function Timer()
  371.     if TickPause > 0 then
  372.         TickPause = TickPause - 1;
  373.         return;
  374.     end
  375.     if move.isMoving(Player.Pointer) == 1 or game.isInCombat(Player.Pointer) == 1 and game.isMounted(Player.Pointer) == 1 then
  376.         TickPause = 1;
  377.         return;
  378.     end
  379.     local EntryCount,ThisObject;
  380.     game.updateObjectList();
  381.     EntryCount = game.getObjectListEntryCount();
  382.     for i = 0, EntryCount, 1 do
  383.         ThisObject = game.getObjectListEntry(i);
  384.         if ThisObject ~= Player.Pointer and game.getType(ThisObject) == TYPE_NPC
  385.                 and game.getLife(ThisObject) == 0 and IsInRange(ThisObject) == 1 and game.isLootable(ThisObject) == 1 and game.isInCombat(Player.Pointer) == 0 then
  386.             if Loot == true then
  387.                 game.useObject(ThisObject);
  388.             end
  389.             TickPause = 3;
  390.             return;
  391.         end
  392.         if ThisObject ~= Player.Pointer and game.getType(ThisObject) == TYPE_PLAYER
  393.                 and game.getLife(ThisObject) == 0 and IsInRange(ThisObject) == 1 and game.isLootable(ThisObject) == 1 and game.isInCombat(Player.Pointer) == 0 then
  394.             game.useObject(ThisObject);
  395.             TickPause = 3;
  396.             return;
  397.         end
  398.     end
  399. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top