Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Game/Core.hpp>
- #include <Game/Tools/RandomHandler.hpp>
- #include <iostream>
- static std::uint32_t WillowLogs = 0;
- void Setup()
- {
- ScriptInfo Info;
- Info.Name = "DraynorWillows";
- Info.Description = "Cuts and banks willow logs at Draynor Village.";
- Info.Version = "0.01";
- Info.Category = "gdfdfgdfggfd";
- Info.Author = "fdggdfdfgdfg";
- Info.UID = "";
- Info.ForumPage = "gdfgdfdgfdgfgdf";
- SetScriptInfo(Info);
- }
- bool OnStart()
- {
- SetLoopDelay(50);
- return true;
- }
- bool IsMoving()
- {
- Player P = GetLocalPlayer();
- if (P)
- return (P.GetPoseAnimationID() != P.GetSubPoseAnimationID());
- return false;
- }
- bool IsAnimating(std::int32_t AnimationID)
- {
- Player P = GetLocalPlayer();
- if (P)
- return (P.GetAnimationID() == AnimationID);
- return false;
- }
- Tile GetTileInFront(const Character& C)
- {
- Tile Result(-1, -1, 0);
- if (!C)
- return Result;
- Result.X = (GetClientX() + (C.GetX() >> 7));
- Result.Y = (GetClientY() + (C.GetY() >> 7));
- Result.Plane = GetClientPlane();
- std::int32_t Angle = (((((std::int32_t)std::abs(C.GetAngle() - 2048)) & 0x7FF) / 2048.0f) * 360.0f);
- if ((Angle > 315) || (Angle < 45))
- {
- Result.Y--;
- } else if((Angle > 225) && (Angle < 315))
- {
- Result.X--;
- } else if ((Angle > 135) && (Angle < 225))
- {
- Result.Y++;
- } else if ((Angle > 45) && (Angle < 135))
- {
- Result.X++;
- }
- return Result;
- }
- bool TreeCutDown()
- {
- Tile TreeTile = GetTileInFront(GetLocalPlayer());
- if (TreeTile.IsPositive())
- {
- auto Objs = SceneObjects::GetAll(TreeTile, SceneObjects::GAME_OBJECT);
- for (const auto& O : Objs)
- {
- if (!O)
- continue;
- ObjectInfo Tree = SceneObjects::GetInfoOf(O);
- if (Tree)
- if (Tree.GetName() == "Willow")
- return false;
- }
- }
- return true;
- }
- bool ValidWillow(const GameObject& Obj)
- {
- if (!Obj)
- return false;
- Player P = GetLocalPlayer();
- if (!P)
- return false;
- Point Local(P.GetX() >> 7, P.GetY() >> 7);
- if (!(Local.DistanceFrom(Point((Obj.GetX() >> 7), (Obj.GetY() >> 7))) <= 3))
- return false;
- ObjectInfo Info = SceneObjects::GetInfoOf(Obj);
- if (!Info)
- return false;
- return (Info.GetName() == "Willow");
- }
- void ChopTree()
- {
- auto Willow = SceneObjects::Get(ValidWillow);
- if (Willow)
- Interact::Click(Willow, "Chop down");
- }
- bool ValidBank(const GameObject& Obj)
- {
- if (!Obj)
- return false;
- ObjectInfo Info = SceneObjects::GetInfoOf(Obj);
- if (!Info)
- return false;
- if (Info.GetName() == "Bank booth")
- {
- auto Actions = Info.GetActions();
- for (auto A : Actions)
- if (A == "Bank")
- return true;
- }
- return false;
- }
- void WalkBank()
- {
- if (!IsMoving())
- Interact::Click(TileToMinimap(Area(Tile(3092, 3245, 0), Tile(3094, 3241, 0)).GetHybridRandomTile(0.5, 0.5, 0.5, 0.5)));
- }
- void OpenBank()
- {
- auto BankBooth = SceneObjects::Get(ValidBank);
- if (BankBooth)
- Interact::Click(BankBooth, "Bank");
- }
- void DepositExceptAxe()
- {
- if (Bank::IsOpen())
- if (Bank::DepositAllOf("Willow logs"))
- {
- WillowLogs+=27;
- std::uint64_t MS = GetScriptTimer().GetTimeElapsed();
- std::cout << std::endl;
- std::cout << "DraynorWillows by Kasi" << std::endl;
- std::cout << " Ran for ";
- std::cout << (std::int32_t)((MS / (1000 * 60 * 60)) % 24) << "h";
- std::cout << (std::int32_t)((MS / (1000 * 60)) % 60) << "m";
- std::cout << (std::int32_t)((MS / (1000)) % 60) << "s";
- std::cout << std::endl;
- std::cout << " Cut " << WillowLogs << " Logs" << std::endl;
- std::cout << " Gained " << (double)((double)WillowLogs * 67.5f) << " XP" << std::endl << std::endl;
- }
- }
- void WalkWillows()
- {
- if (!IsMoving())
- Interact::Click(TileToMinimap(Area(Tile(3084, 3237, 0), Tile(3089, 3230, 0)).GetHybridRandomTile(0.5, 0.5, 0.5, 0.5)));
- }
- bool AtWillows()
- {
- if (!(Area(Tile(3082, 3239, 0), Tile(3091, 3225, 0)).Contains(Minimap::GetPosition())))
- {
- Point LocalDes(GetLocalDestinationX(), GetLocalDestinationY());
- if ((LocalDes.X != 0) && (LocalDes.Y != 0))
- {
- Player P = GetLocalPlayer();
- if (P)
- {
- Point LocalPos((P.GetX() >> 7), (P.GetY() >> 7));
- if (LocalPos.DistanceFrom(LocalDes) < 3)
- return true;
- }
- }
- } else
- return true;
- return false;
- }
- bool AtBank()
- {
- if (!(Area(Tile(3092, 3246, 0), Tile(3095, 3241, 0)).Contains(Minimap::GetPosition())))
- {
- Point LocalDes(GetLocalDestinationX(), GetLocalDestinationY());
- if ((LocalDes.X) && (LocalDes.Y))
- {
- Player P = GetLocalPlayer();
- if (P)
- {
- Point LocalPos((P.GetX() >> 7), (P.GetY() >> 7));
- if (LocalPos.DistanceFrom(LocalDes) <= 3)
- return true;
- }
- }
- } else
- return true;
- return false;
- }
- bool Cutting()
- {
- return (IsAnimating(867) && (!TreeCutDown()));
- }
- bool Loop()
- {
- if (!Login::IsLoggedIn())
- {
- if (Login::LoginPlayer() != Login::LOGGED_IN)
- return false;
- else
- Mainscreen::SetCameraPitch(1000);
- }
- if (Inventory::IsFull())
- {
- if (!AtBank())
- {
- WalkBank();
- } else if (!Bank::IsOpen())
- {
- OpenBank();
- } else
- {
- DepositExceptAxe();
- }
- } else
- {
- if (!AtWillows())
- {
- WalkWillows();
- } else
- {
- if (!Cutting())
- ChopTree();
- else
- {
- RandomHandler::Check();
- if (UniformRandom(0, 9999) < 25)
- {
- std::int32_t Angle = Minimap::GetCompassAngle() + UniformRandom(-45, 45);
- if ((Angle > 270) || (Angle < 90))
- Minimap::RotateCompass(Angle);
- }
- if (UniformRandom(0, 9999) < 150)
- {
- LoseFocus();
- Wait(UniformRandom(4000, 15000));
- }
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement