Advertisement
Guest User

fdgfdgfdgfdgrty432451

a guest
Mar 17th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.61 KB | None | 0 0
  1. #include <Game/Core.hpp>
  2. #include <Game/Tools/RandomHandler.hpp>
  3. #include <iostream>
  4.  
  5. static std::uint32_t WillowLogs = 0;
  6.  
  7. void Setup()
  8. {
  9. ScriptInfo Info;
  10. Info.Name = "DraynorWillows";
  11. Info.Description = "Cuts and banks willow logs at Draynor Village.";
  12. Info.Version = "0.01";
  13. Info.Category = "gdfdfgdfggfd";
  14. Info.Author = "fdggdfdfgdfg";
  15. Info.UID = "";
  16. Info.ForumPage = "gdfgdfdgfdgfgdf";
  17. SetScriptInfo(Info);
  18. }
  19.  
  20. bool OnStart()
  21. {
  22. SetLoopDelay(50);
  23. return true;
  24. }
  25.  
  26. bool IsMoving()
  27. {
  28. Player P = GetLocalPlayer();
  29. if (P)
  30. return (P.GetPoseAnimationID() != P.GetSubPoseAnimationID());
  31. return false;
  32. }
  33.  
  34. bool IsAnimating(std::int32_t AnimationID)
  35. {
  36. Player P = GetLocalPlayer();
  37. if (P)
  38. return (P.GetAnimationID() == AnimationID);
  39. return false;
  40. }
  41.  
  42. Tile GetTileInFront(const Character& C)
  43. {
  44. Tile Result(-1, -1, 0);
  45. if (!C)
  46. return Result;
  47. Result.X = (GetClientX() + (C.GetX() >> 7));
  48. Result.Y = (GetClientY() + (C.GetY() >> 7));
  49. Result.Plane = GetClientPlane();
  50. std::int32_t Angle = (((((std::int32_t)std::abs(C.GetAngle() - 2048)) & 0x7FF) / 2048.0f) * 360.0f);
  51. if ((Angle > 315) || (Angle < 45))
  52. {
  53. Result.Y--;
  54. } else if((Angle > 225) && (Angle < 315))
  55. {
  56. Result.X--;
  57. } else if ((Angle > 135) && (Angle < 225))
  58. {
  59. Result.Y++;
  60. } else if ((Angle > 45) && (Angle < 135))
  61. {
  62. Result.X++;
  63. }
  64. return Result;
  65. }
  66.  
  67. bool TreeCutDown()
  68. {
  69. Tile TreeTile = GetTileInFront(GetLocalPlayer());
  70. if (TreeTile.IsPositive())
  71. {
  72. auto Objs = SceneObjects::GetAll(TreeTile, SceneObjects::GAME_OBJECT);
  73. for (const auto& O : Objs)
  74. {
  75. if (!O)
  76. continue;
  77. ObjectInfo Tree = SceneObjects::GetInfoOf(O);
  78. if (Tree)
  79. if (Tree.GetName() == "Willow")
  80. return false;
  81. }
  82. }
  83. return true;
  84. }
  85.  
  86. bool ValidWillow(const GameObject& Obj)
  87. {
  88. if (!Obj)
  89. return false;
  90. Player P = GetLocalPlayer();
  91. if (!P)
  92. return false;
  93. Point Local(P.GetX() >> 7, P.GetY() >> 7);
  94. if (!(Local.DistanceFrom(Point((Obj.GetX() >> 7), (Obj.GetY() >> 7))) <= 3))
  95. return false;
  96. ObjectInfo Info = SceneObjects::GetInfoOf(Obj);
  97. if (!Info)
  98. return false;
  99. return (Info.GetName() == "Willow");
  100. }
  101.  
  102. void ChopTree()
  103. {
  104. auto Willow = SceneObjects::Get(ValidWillow);
  105. if (Willow)
  106. Interact::Click(Willow, "Chop down");
  107. }
  108.  
  109. bool ValidBank(const GameObject& Obj)
  110. {
  111. if (!Obj)
  112. return false;
  113. ObjectInfo Info = SceneObjects::GetInfoOf(Obj);
  114. if (!Info)
  115. return false;
  116. if (Info.GetName() == "Bank booth")
  117. {
  118. auto Actions = Info.GetActions();
  119. for (auto A : Actions)
  120. if (A == "Bank")
  121. return true;
  122. }
  123. return false;
  124. }
  125.  
  126. void WalkBank()
  127. {
  128. if (!IsMoving())
  129. Interact::Click(TileToMinimap(Area(Tile(3092, 3245, 0), Tile(3094, 3241, 0)).GetHybridRandomTile(0.5, 0.5, 0.5, 0.5)));
  130. }
  131.  
  132. void OpenBank()
  133. {
  134. auto BankBooth = SceneObjects::Get(ValidBank);
  135. if (BankBooth)
  136. Interact::Click(BankBooth, "Bank");
  137. }
  138.  
  139. void DepositExceptAxe()
  140. {
  141. if (Bank::IsOpen())
  142. if (Bank::DepositAllOf("Willow logs"))
  143. {
  144. WillowLogs+=27;
  145. std::uint64_t MS = GetScriptTimer().GetTimeElapsed();
  146. std::cout << std::endl;
  147. std::cout << "DraynorWillows by Kasi" << std::endl;
  148. std::cout << " Ran for ";
  149. std::cout << (std::int32_t)((MS / (1000 * 60 * 60)) % 24) << "h";
  150. std::cout << (std::int32_t)((MS / (1000 * 60)) % 60) << "m";
  151. std::cout << (std::int32_t)((MS / (1000)) % 60) << "s";
  152. std::cout << std::endl;
  153. std::cout << " Cut " << WillowLogs << " Logs" << std::endl;
  154. std::cout << " Gained " << (double)((double)WillowLogs * 67.5f) << " XP" << std::endl << std::endl;
  155. }
  156. }
  157.  
  158. void WalkWillows()
  159. {
  160. if (!IsMoving())
  161. Interact::Click(TileToMinimap(Area(Tile(3084, 3237, 0), Tile(3089, 3230, 0)).GetHybridRandomTile(0.5, 0.5, 0.5, 0.5)));
  162. }
  163.  
  164. bool AtWillows()
  165. {
  166. if (!(Area(Tile(3082, 3239, 0), Tile(3091, 3225, 0)).Contains(Minimap::GetPosition())))
  167. {
  168. Point LocalDes(GetLocalDestinationX(), GetLocalDestinationY());
  169. if ((LocalDes.X != 0) && (LocalDes.Y != 0))
  170. {
  171. Player P = GetLocalPlayer();
  172. if (P)
  173. {
  174. Point LocalPos((P.GetX() >> 7), (P.GetY() >> 7));
  175. if (LocalPos.DistanceFrom(LocalDes) < 3)
  176. return true;
  177. }
  178. }
  179. } else
  180. return true;
  181. return false;
  182. }
  183.  
  184. bool AtBank()
  185. {
  186. if (!(Area(Tile(3092, 3246, 0), Tile(3095, 3241, 0)).Contains(Minimap::GetPosition())))
  187. {
  188. Point LocalDes(GetLocalDestinationX(), GetLocalDestinationY());
  189. if ((LocalDes.X) && (LocalDes.Y))
  190. {
  191. Player P = GetLocalPlayer();
  192. if (P)
  193. {
  194. Point LocalPos((P.GetX() >> 7), (P.GetY() >> 7));
  195. if (LocalPos.DistanceFrom(LocalDes) <= 3)
  196. return true;
  197. }
  198. }
  199. } else
  200. return true;
  201. return false;
  202. }
  203.  
  204. bool Cutting()
  205. {
  206. return (IsAnimating(867) && (!TreeCutDown()));
  207. }
  208.  
  209. bool Loop()
  210. {
  211. if (!Login::IsLoggedIn())
  212. {
  213. if (Login::LoginPlayer() != Login::LOGGED_IN)
  214. return false;
  215. else
  216. Mainscreen::SetCameraPitch(1000);
  217. }
  218.  
  219. if (Inventory::IsFull())
  220. {
  221. if (!AtBank())
  222. {
  223. WalkBank();
  224. } else if (!Bank::IsOpen())
  225. {
  226. OpenBank();
  227. } else
  228. {
  229. DepositExceptAxe();
  230. }
  231. } else
  232. {
  233. if (!AtWillows())
  234. {
  235. WalkWillows();
  236. } else
  237. {
  238. if (!Cutting())
  239. ChopTree();
  240. else
  241. {
  242. RandomHandler::Check();
  243. if (UniformRandom(0, 9999) < 25)
  244. {
  245. std::int32_t Angle = Minimap::GetCompassAngle() + UniformRandom(-45, 45);
  246. if ((Angle > 270) || (Angle < 90))
  247. Minimap::RotateCompass(Angle);
  248. }
  249. if (UniformRandom(0, 9999) < 150)
  250. {
  251. LoseFocus();
  252. Wait(UniformRandom(4000, 15000));
  253. }
  254. }
  255. }
  256. }
  257. return true;
  258. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement