Advertisement
Guest User

Untitled

a guest
Apr 4th, 2016
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 59.54 KB | None | 0 0
  1. #include "stdafx.h"
  2. unsigned long GObjects = NULL;
  3. unsigned long GNames = NULL;
  4. #include "C:\TFL_SDK_GEN\MH\SDKheaders.h"
  5. #include "d3d.h"
  6. #pragma region SDK DEFINES
  7.  
  8. // We include this now because DefFunc sets things needed within here
  9. unsigned long TheWorld = NULL;
  10. unsigned long ThePE = NULL;
  11. // A1 ? ? ? ? 8b ? ? 8b ? ? 25 ? 02 ? ?                                
  12. #define GObjects_Pattern        "\xA1\x00\x00\x00\x00\x8B\x00\x00\x8B\x00\x00\x25\x00\x02\x00\x00"
  13. #define GObjects_Mask           "x????x??x??xxxxx"
  14. #define GObjects_Offset         0x1
  15. // 8b 0d ? ? ? ? 83 3c 81 00 74
  16. // 8b 0d ? ? ? ? 53 55 8b 0c b1    text:008DFB2C                 mov     ecx, dword_201C428
  17. #define GNames_Pattern          "\x8b\x0d\x00\x00\x00\x00\x53\x55\x8b\x0c\xb1"
  18. #define GNames_Mask             "xx????xxxxx"
  19. #define GNames_Offset           0x2
  20. // 8B 0D ? ? ? ? 89 74 24 2C 89 74 24 30 F3 0F 11 44 24 34
  21. // CaptureMemoryChartInfo
  22. // 8B 0D ? ? ? ? 85 C9 74 30 E8 54 24 56 00 85 C0 74 27 8B
  23. // 8B 0D ? ? ? ? 85 C9 74 30 E8
  24. #define TheWorld_Pattern        "\x8B\x0D\x00\x00\x00\x00\x85\xC9\x74\x30\xE8"
  25. #define TheWorld_Mask           "xx????xxxxx"
  26. #define TheWorld_Offset         0x2 // cuz 2* xx be4 ????  
  27. // 55 8B EC 6A FF 68 ?  ?  ?   ? 64 A1 ?   ?  ?  ? 50 83
  28. // 55 8B EC 6A FF 68 AE  ?  ?   ? 64 A1 ?   ?  ?  ? 50 83
  29. //55 8B EC 6A FF 68 9E 4E 90 01 64 A1 00 00 00 00 50 83
  30. //55 8B EC 6A FF 68 9E  ?  ? ?  64 A1 ? ? ? ? 50 83
  31. //
  32. //55 8B EC 6A FF 68 AE 51 90 01 64 A1 00 00 00 00 50 83 EC 7C  A1 00 31 FA  01 33 C5 89 45 F0 53 56
  33. //55 8B EC 6A FF 68 ? ? ? ? 64 A1 ? ? ? ? 50 83 EC 7C A1 00 31 FA    GOOD
  34. //\x55\x8B\xEC\x6A\xFF\x68\x00\x00\x00\x00\x64\xA1\x00\x00\x00\x00\x50\x83\xEC\x7C\xA1 xxxxxx????xx????xxxxx
  35. #define ProcessEvent_Pattern    "\x55\x8B\xEC\x6A\xFF\x68\x00\x00\x00\x00\x64\xA1\x00\x00\x00\x00\x50\x83\xEC\x40"
  36. #define ProcessEvent_Mask       "xxxxxx????xx????xxxx"
  37. #define ProcessEvent_Offset     0x6
  38. #define PI 3.14159265
  39. DWORD dwProcessEvent = NULL;
  40. DWORD dwOldProcessEvent = NULL;
  41. DWORD dwOldEndScene = NULL;
  42. HANDLE PingThread = NULL;
  43.  
  44. void DefFunc()
  45. {
  46.     MODULEINFO miGame = TFLHACKT00LS::GetModuleInfo(NULL);
  47.     GObjects = *(unsigned long*)(TFLHACKT00LS::FindPattern((unsigned long)miGame.lpBaseOfDll, miGame.SizeOfImage, (unsigned char*)GObjects_Pattern, (char*)GObjects_Mask) + GObjects_Offset);
  48.     GNames = *(unsigned long*)(TFLHACKT00LS::FindPattern((unsigned long)miGame.lpBaseOfDll, miGame.SizeOfImage, (unsigned char*)GNames_Pattern, (char*)GNames_Mask) + GNames_Offset);
  49.     TheWorld = *(unsigned long*)(TFLHACKT00LS::FindPattern((unsigned long)miGame.lpBaseOfDll, miGame.SizeOfImage, (unsigned char*)TheWorld_Pattern, (char*)TheWorld_Mask) + TheWorld_Offset);
  50. }
  51.  
  52. // Using this to find DLL path
  53. EXTERN_C IMAGE_DOS_HEADER __ImageBase;
  54. using namespace std;
  55. using boost::format;
  56.  
  57. #pragma endregion
  58.  
  59.  
  60. /*
  61. //LOS tag for abilitiy
  62. //fixed waypointing, doesn't require mouse anymore (only things left that ever use virtual mouse is looting and mousetarget)
  63.  
  64.  
  65. Power Number |0| PowerSlot = 0  Usable = 1  Cooldown = 0  Slot 1
  66. Power Number |1| PowerSlot = 1  Usable = 1  Cooldown = 0  Slot 8
  67. Power Number |2| PowerSlot = 2  Usable = 1  Cooldown = 0  Slot 2
  68. Power Number |3| PowerSlot = 3  Usable = 1  Cooldown = 0  Slot 3
  69. Power Number |4| PowerSlot = 4  Usable = 1  Cooldown = 0  Slot 4
  70. Power Number |5| PowerSlot = 5  Usable = 1  Cooldown = 0  Slot 5
  71. Power Number |6| PowerSlot = 6  Usable = 1  Cooldown = 0  Slot 6
  72. Power Number |7| PowerSlot = 7  Usable = 1  Cooldown = 0  Slot 7
  73. Power Number |8| PowerSlot = 15  Usable = 1  Cooldown = 0 MedKit
  74. Power Number |9| PowerSlot = 16  Usable = 0  Cooldown = 0 Ultimate
  75. Power Number |10| PowerSlot = 17  Usable = 0  Cooldown = 0 Teamup Summon?  Is usable as long as it's off cd though teamup may already be out
  76.  
  77. TODO
  78. //check usable test while doing my is function for things like the pet ability and the teamup
  79. //allocate every function so they can be moved anywhere I want? possibly other files?
  80. //redo entire pick ability logic with a isabilityusable function and a useabilityfunction
  81. //seperate the bigger guitriggers and prepcharacter stuff and whatnot into functions
  82. //switch at certain level for onescript
  83. //stash itemgrid?
  84. //moveing in a different function check all that again....?
  85. //Rewrite midtown completely and allow for more options
  86. //Shiftclick? maybe through engine sigh or different thread?
  87. //There's gotta be a way to split a stack without all the mouse moving and whatnot...I really hate doing this
  88. //I can't get the damn POI's... really fuckin gay...
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. dialogtarget stuff to determine if crafter is broken?
  96.  
  97. damage meter mode (have to use mouseclicks or its gay)
  98. rewrite everything so we can just set a destination and thats where we wanna go, than use a single movement to go there
  99.  
  100.  
  101. might be useful at one point //GameViewPort->SetMouse(1, 1);
  102. even moves the OS point if it's there... it moves it all man
  103.  
  104. MHBUDDY UI
  105. IF SERVICE GOES DOWN THEY STILL NEED TO BE ABLE TO USE LOCAL UI
  106. ultimates need the ultimate tag
  107. download rared debug file and attempt to place in correct location
  108. notify me when (add a list of words) (seen in any chat)
  109. force sync button / timered notification that you need to sync?
  110. crash restarter? auto-starter?
  111. community ratings for templates?
  112. Comments for templates?
  113. Change Ability template icons to names (much better, we don't need to show icons)
  114. Onescript System is automatically always copied first (than will be overwritten if needed from clones)
  115. Child Templates arnt Published??
  116. Forgot Password for people to email them their password
  117. New Ability Basic Stuff / TeamUp for basics
  118. Omega linker to ability file
  119.  
  120. slot
  121. 0 = Costume
  122. 1 = Slot 1
  123. 2 = Slot 2
  124. 3 = Slot 3
  125. 4 = Slot 4
  126. 5 = Slot 5
  127. 7 = Medallion
  128. 8 = Artifact
  129. 9 = Relic
  130. 10 = Insignia
  131. 11 = Artifact
  132. 12 = Ring
  133. 13 = Legendary
  134. 14 = Artifact
  135. 15 = Uruforged
  136. */
  137.  
  138.  
  139.  
  140. #pragma region Loggers
  141. // Logger Variables
  142. bool gDebug = false; // DEBUGGING
  143. bool gDebugLastSet = false;
  144. bool gDebug2 = false; // SUPER DEBUGGING
  145. bool gDebugRadius = false;
  146. bool gTerminalDebug = true;
  147. bool gGridDebug = false;
  148. bool gDynamicGridDebug = false;
  149. bool gPathDebug = false;
  150. bool gAvoidanceDebug = false;
  151. bool gLOSDEBUG = false;
  152. bool gDebugSpam = false;
  153. bool gRender = true;
  154. bool gExportChat = true;
  155. bool gCoolRoster = false;
  156. errno_t err;
  157. FILE *pFile;
  158. string pFileName = "logFile.txt";
  159. vector<string> PendingLogFile;
  160. vector<string> PendingDLogFile;
  161. vector<int> PendingSendText;
  162.  
  163. long long microseconds_now() {
  164.     static LARGE_INTEGER s_frequency;
  165.     static BOOL s_use_qpc = QueryPerformanceFrequency(&s_frequency);
  166.     if (s_use_qpc) {
  167.         LARGE_INTEGER now;
  168.         QueryPerformanceCounter(&now);
  169.         return (1000LL * now.QuadPart) / s_frequency.QuadPart;
  170.     }
  171.     else {
  172.         return GetTickCount();
  173.     }
  174. }
  175. string to_string(wchar_t* text)
  176. {
  177.     if (text == NULL)
  178.         return "NULL";
  179.     wstring blah = text;
  180.     string retval(blah.begin(), blah.end());
  181.     return retval;
  182. }
  183. string to_string(wstring text)
  184. {
  185.     wstring blah = text;
  186.     string retval(blah.begin(), blah.end());
  187.     return retval;
  188. }
  189. string to_string(bool text)
  190. {
  191.     if (text)
  192.         return "TRUE";
  193.     else
  194.         return "FALSE";
  195. }
  196. string to_string(float value)
  197. {
  198.     std::stringstream ss;
  199.     ss << std::setprecision(std::numeric_limits<float>::digits10 + 2);
  200.     ss << value;
  201.     return ss.str();
  202. }
  203. string to_hex(int num)
  204. {
  205.     stringstream ss;
  206.     ss << hex << num; // int decimal_value
  207.     string res(ss.str());
  208.     res = "0x" + res;
  209.     return res;
  210. }
  211. wstring to_wstring(string text)
  212. {
  213.     wchar_t buf[5000];
  214.     swprintf_s(buf, L"%S", text.c_str());
  215.     return buf;
  216. }
  217.  
  218. void TimeStamp()
  219. {
  220.     time_t rawtime;
  221.     struct tm timeinfo;
  222.     char buffer[128];
  223.     time(&rawtime);
  224.     localtime_s(&timeinfo, &rawtime);
  225.     strftime(buffer, 80, "\n[%x %I:%M:%S %p]", &timeinfo);
  226.     while (!pFile)
  227.     {
  228.         pFile = _fsopen(pFileName.c_str(), "a", _SH_DENYNO);
  229.     }
  230.     fprintf(pFile, "%s", buffer);
  231.     fclose(pFile);
  232.  
  233. }
  234. string TimeStampStr()
  235. {
  236.     time_t rawtime;
  237.     struct tm timeinfo;
  238.     char buffer[128];
  239.     time(&rawtime);
  240.     localtime_s(&timeinfo, &rawtime);
  241.     strftime(buffer, 80, "[%x %I:%M:%S %p]", &timeinfo);
  242.     return buffer;
  243. }
  244. string TimeStampC(long long mytime)
  245. {
  246.     struct tm timeinfo;
  247.     char buffer[128];
  248.     time_t rawtime = static_cast<time_t>(mytime / 1000);
  249.     localtime_s(&timeinfo, &rawtime);
  250.     strftime(buffer, 80, "[%I:%M:%S%p]", &timeinfo);
  251.     return buffer;
  252. }
  253.  
  254. template <typename T>
  255. T WriteLogFile(T t)
  256. {
  257.     PendingLogFile.push_back(str(format("%1%") % t));
  258.     PendingDLogFile.push_back(str(format("%1%") % t));
  259.     return t;
  260. }
  261. template <typename T>
  262. T WriteLogFileD(T t)
  263. {
  264.     if (gDebug)
  265.     {
  266.         PendingDLogFile.push_back(str(format("%1%") % t));
  267.     }
  268.     return t;
  269. }
  270. void WriteLogFile(wchar_t* szString)
  271. {
  272.     char buffer[5000];
  273.     sprintf_s(buffer, "%ls", szString);
  274.     PendingLogFile.push_back(buffer);
  275.     PendingDLogFile.push_back(buffer);
  276. }
  277. void WriteLogFile(wstring* szString)
  278. {
  279.     char buffer[5000];
  280.     sprintf_s(buffer, "%ls", szString);
  281.     PendingLogFile.push_back(buffer);
  282.     PendingDLogFile.push_back(buffer);
  283. }
  284. void WriteLogFileD(wchar_t* szString)
  285. {
  286.     if (gDebug)
  287.     {
  288.         char buffer[5000];
  289.         sprintf_s(buffer, "%ls", szString);
  290.         PendingDLogFile.push_back(buffer);
  291.     }
  292. }
  293. void WriteLogFileD(wstring* szString)
  294. {
  295.     if (gDebug)
  296.     {
  297.         char buffer[5000];
  298.         sprintf_s(buffer, "%ls", szString);
  299.         PendingDLogFile.push_back(buffer);
  300.     }
  301. }
  302. #pragma endregion
  303.  
  304. #pragma region General Helper Functions
  305. void killProcessByName(string filename)
  306. {
  307.     HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, NULL);
  308.     PROCESSENTRY32 pEntry;
  309.     pEntry.dwSize = sizeof(pEntry);
  310.     BOOL hRes = Process32First(hSnapShot, &pEntry);
  311.     while (hRes)
  312.     {
  313.         if (boost::iequals(pEntry.szExeFile, filename))
  314.         {
  315.             HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0, (DWORD)pEntry.th32ProcessID);
  316.             if (hProcess != NULL)
  317.             {
  318.                 TerminateProcess(hProcess, 9);
  319.                 CloseHandle(hProcess);
  320.             }
  321.         }
  322.         hRes = Process32Next(hSnapShot, &pEntry);
  323.     }
  324.     CloseHandle(hSnapShot);
  325. }
  326. wstring replaceAll(wstring s, wstring f, wstring r) {
  327.     unsigned int found = 0;
  328.     while ((found = s.find(f, found)) != string::npos) {
  329.         s.replace(found, f.length(), r);
  330.         found += r.size();
  331.     }
  332.     return s;
  333. }
  334. string rev(string x)
  335. {
  336.     auto a = x.begin();
  337.     auto b = x.rbegin();
  338.  
  339.     while (a < b.base())
  340.         swap(*a++, *b++);
  341.  
  342.     return x;
  343. }
  344. struct InvalidChar
  345. {
  346.     bool operator()(char c) const {
  347.         return !isprint((unsigned)c);
  348.     }
  349. };
  350. string stripHTMLTags(string s) {
  351.     s.erase(std::remove_if(s.begin(), s.end(), InvalidChar()), s.end());
  352.     while (true) {
  353.         unsigned int left = s.find("<");
  354.         unsigned int right = s.find(">");
  355.         if (left == string::npos || right == string::npos)
  356.             break;
  357.         s = s.erase(left, right - left + 1);
  358.     }
  359.     return s;
  360. }
  361. wstring stripHTMLTags(wstring s) {
  362.     s.erase(std::remove_if(s.begin(), s.end(), InvalidChar()), s.end());
  363.     while (true) {
  364.         unsigned int left = s.find(L"<");
  365.         unsigned int right = s.find(L">");
  366.         if (left == string::npos || right == string::npos)
  367.             break;
  368.         s = s.erase(left, right - left + 1);
  369.     }
  370.     // Etc...
  371.     return s;
  372. }
  373.  
  374.  
  375. bool CompareFloats(float A, float B)
  376. {
  377.     return abs(A - B) < 0.001;
  378. }
  379.  
  380. template<typename charT>
  381. struct my_equal {
  382.     my_equal(const locale& loc) : loc_(loc) {}
  383.     bool operator()(charT ch1, charT ch2) {
  384.         return std::toupper(ch1, loc_) == std::toupper(ch2, loc_);
  385.     }
  386. private:
  387.     const locale& loc_;
  388. };
  389.  
  390. // find substring (case insensitive)
  391. template<typename T>
  392. int ci_find_substr(const T& str1, const T& str2, const locale& loc = locale())
  393. {
  394.     typename T::const_iterator it = std::search(str1.begin(), str1.end(),
  395.         str2.begin(), str2.end(), my_equal<typename T::value_type>(loc));
  396.     if (it != str1.end()) return it - str1.begin();
  397.     else return -1; // not found
  398. }
  399.  
  400. bool is_float(string line)
  401. {
  402.     char* p;
  403.     strtod(line.c_str(), &p);
  404.     return *p == 0;
  405. }
  406. bool is_number2(string line)
  407. {
  408.     char* p;
  409.     strtol(line.c_str(), &p, 10);
  410.     return *p == 0;
  411. }
  412.  
  413.  
  414. bool is_number(string line)
  415. {
  416.     bool test = false;
  417.     if (is_number2(line))
  418.         test = true;
  419.     if (is_float(line))
  420.         test = true;
  421.     return test;
  422. }
  423.  
  424. vector<string> splitstring(const string &s, char delim) {
  425.     stringstream ss(s);
  426.     string item;
  427.     vector<string> tokens;
  428.     while (getline(ss, item, delim)) {
  429.         tokens.push_back(item);
  430.     }
  431.     return tokens;
  432. }
  433.  
  434.  
  435.  
  436. #pragma endregion
  437.  
  438. string website = "mhbuddy.com";
  439. string websiteh = "http://";
  440. LPCWSTR website2 = L"MyBrowser";
  441.  
  442. #pragma region Global Defines
  443. // GLOBAL DEFINES
  444. HWND MHhwnd;
  445. toolkit::VMTHook* hook[10]; //Pointer to the VMTHook class
  446. typedef void(__stdcall *tProcessEvent) (UFunction*, void*, void*);
  447. tProcessEvent pProcessEvent;
  448. UFunction *pUFunc = NULL; //pointers to proce+ssevent arguements
  449. void      *pParms = NULL;
  450. void      *pResult = NULL;
  451. UObject*  *pCallObject = NULL;
  452.  
  453. AMarvelPlayerController  *pPlayerController = NULL;
  454. AMarvelPlayerCamera *pCamera = NULL;
  455. AMarvelEntity  *pEntity = NULL;
  456. AMarvelHUD  *mHUD = NULL;
  457. UWorld *World = NULL;
  458. UMarvelGameEngine *mEngine = NULL;
  459. UMarvelGFxUIManager *mManager = NULL;
  460. char FunctionName[256]; // Used for inside PE to compare events
  461. char DllPath[512]; // prev 260
  462. string BasePath;
  463. string LogFile;
  464.  
  465. int gHookNumber = 0;
  466. bool gRunThreads = true;
  467.  
  468.  
  469.  
  470. bool gCombatEnabled = true;
  471. enum gBotState
  472. {
  473.     BS_LOGGING_IN = 0,
  474.     BS_LOGGING_OUT = 1,
  475.     BS_READY = 2,
  476. };
  477.  
  478. int gBotState = 0;
  479. int gBotStateOld = 0;
  480.  
  481. #pragma endregion
  482.  
  483.  
  484. #pragma region BOT SPECIFIC DEFINES
  485. // BOT SPECIFIC DEFINES
  486.  
  487.  
  488.  
  489. string website3 = "/t.txt";
  490.  
  491. string website4 = "ghostly";
  492.  
  493.  
  494. vector<FPowerDescriptor> AbilityDetails;
  495.  
  496. string gVersion = "1.485";
  497. bool gVersionMatch = false;
  498. string gGUITrigger = "";
  499. float gPlayerSecondaryCurrent = 0.0f;
  500. float gPlayerSecondaryMax = 0.0f;
  501. bool gRunning = false;
  502. string gInGameName = "";
  503. string gDisplayedErrorMessage = "";
  504. bool gShouldCheckSettings = true;
  505. bool gRunningLast = false;
  506. bool gfuckingmouse = false;
  507. bool gUsingHoldAbility = false;
  508. bool gHasTeamUpOut = false;
  509. __int64 gUsingHoldAbilityTime;
  510. bool gUsingActivateAbility = false;
  511. __int64 gUsingActivateAbilityTime;
  512. bool gDebugUI = false;
  513. int gLastNotification = 99999;
  514. int gCurrentAbilityPage = 0;
  515. int gActivateAbilityNum = 0;
  516. int gGameStep = 0;
  517. int gSubGameStep = 0;
  518. int gSubSubGameStep = 0;
  519. int gOldGameStep = 99999;
  520. int gOldGameStep2 = 99999;
  521. int gTimerCheckpoint = 0;
  522. int gTimerGoto = 0;
  523. bool gPossessed = false;
  524. bool gNeedReconnecting = false;
  525. int gPrepCharacterStep = 0;
  526. int gPrepCharacterVar = 0;
  527. bool gPreppingCharacter = false;
  528. bool gPreppingGear = false;
  529. int gLastSlotMarkedasTrash = -1;
  530. int gCallGoto = 0;
  531. string gCallFile = "gamesteps.txt";
  532. bool gInventoryCountFirstRun = true;
  533. bool gGearCountFirstRun = true;
  534. int gInventoryCount = -1;
  535. int gInventoryCountOld = -1;
  536. bool gInsideaTimer = false;
  537. wchar_t gWBuffer[5000];
  538. string gLICENSE = "";
  539. string gLICENSE2 = "";
  540. string gUniqueKey = "";
  541. string gGAMESTEPFILE = "gamesteps.txt";
  542. string gPassword = "";
  543. string gUserName = "";
  544. string gABILITYFILE = "abilities.txt";
  545. string gLOOTRULEFILE = "lootrules.txt";
  546. bool gShouldRelog = true;
  547. bool gfuckhackers = false;
  548. bool gfuckhackers2 = true; // change this to false to enable md5 checking SECURITYCHECK
  549. bool gSessionValid = true;
  550. bool gSessionIp = true;
  551. bool gEnabledPing = false;
  552. bool gtesting = false;
  553. string gv1 = "";
  554. string gv2 = "";
  555. string gv3 = "";
  556. string gv4 = "";
  557. __int64 gWaitTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
  558. __int64 gWaitMedKitTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
  559. __int64 gLicenseCheckTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
  560. __int64 gLoginTimer = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
  561. int gLoginCount = 0;
  562. __int64 gTimerTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
  563. __int64 gCurTime = NULL;
  564. __int64 gCurTimeS = NULL;
  565. __int64 gAfkStartCheck = NULL;
  566. __int64 gDonateTimeOut = NULL;
  567. __int64 gCraftTimeOut = NULL;
  568. __int64 gStashTimeOut = NULL;
  569. __int64 gTrashTimeOut = NULL;
  570. __int64 gStepResetCheck = NULL;
  571. __int64 gStepResetCheck2 = NULL;
  572. __int64 gCombatDisabledUntil = NULL;
  573. __int64 gAvoidanceDisabledUntil = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
  574. __int64 gLastCombatDisable = NULL;
  575. __int64 gStatRunStart = NULL;
  576. __int64 gStatRunTotal = NULL;
  577. unsigned gStatBiggestNode = 0;
  578. float gStatBiggestDistance = 0.0f;
  579. int gTickCounter = 0;
  580. int gStatDeathRun = 0;
  581. int gStatDeathTotal = 0;
  582. bool gNeedInventoryUpdate = true;
  583. bool gCharacterSheetOpen = false;
  584. time_t gStatStartTime = NULL;
  585. int gStatRunCount = 0;
  586. float gMouseX, gMouseY;
  587. FVector gChaseStartLoc;
  588. FVector gAfkStartLoc;
  589. FVector gCellCenterPos;
  590. FVector gCellCenterNPos;
  591. FVector gCellCenterSPos;
  592. FVector gCellCenterEPos;
  593. FVector gCellCenterWPos;
  594.  
  595. int gTermBossId = 9999;
  596.  
  597. string gChatFile_Inc = "chat_inc.txt";
  598. string gChatFile_Out = "chat_out.txt";
  599. vector<string> gChat_Out;
  600. int gChat_ShouldFocus = 0;
  601. vector<string> gChat_Old;
  602. vector<string> gChat_New;
  603. __int64 gChat_Time = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
  604.  
  605. #pragma endregion
  606.  
  607. // UE3 HELPER FUNCTIONS
  608. #pragma region General UE3 Helper Functions
  609. bool IsPointOnLine(FVector a, FVector b, FVector c)
  610. {
  611.     float crossproduct = (c.Y - a.Y) * (b.X - a.X) - (c.X - a.X) * (b.Y - a.Y);
  612.     if (abs(crossproduct) > 0.1f)
  613.         return false;
  614.     float dotproduct = (c.X - a.X) * (b.X - a.X) + (c.Y - a.Y)*(b.Y - a.Y);
  615.     if (dotproduct < 0.0f)
  616.         return false;
  617.     float squaredlengthba = (b.X - a.X)*(b.X - a.X) + (b.Y - a.Y)*(b.Y - a.Y);
  618.     if (dotproduct > squaredlengthba)
  619.         return false;
  620.     return true;
  621. }
  622. FVector getNewPointOnLine(FVector start, FVector end, float distance)
  623. {
  624.     float vx = end.X - start.X;
  625.     float vy = end.Y - start.Y;
  626.     float mag = sqrt(vx*vx + vy*vy);
  627.     vx /= mag;
  628.     vy /= mag;
  629.     int px2 = (int)(start.X + vx * distance);
  630.     int py2 = (int)(start.Y + vy * distance);
  631.     return{ (float)px2, (float)py2, 0.0f };
  632. }
  633. FVector2D getNewPoint(FVector2D center, FVector2D edge, double degrees, float distance)
  634. {
  635.     FVector2D result;
  636.     double theta = degrees;
  637.     float dx = edge.X - center.X;
  638.     float dy = edge.Y - center.Y;
  639.     float dist = sqrt(dx*dx + dy*dy);
  640.     result.X = round((float)(cos(theta / 180.0*PI)*dx + sin(theta / 180.0*PI)*dy)*distance / dist + center.X);
  641.     result.Y = round((float)(cos(theta / 180.0*PI)*dy - sin(theta / 180.0*PI)*dx)*distance / dist + center.Y);
  642.     return result;
  643. }
  644.  
  645. int roundUp(int numToRound, int multiple)
  646. {
  647.     if (multiple == 0)
  648.         return numToRound;
  649.  
  650.     int remainder = abs(numToRound) % multiple;
  651.     if (remainder == 0)
  652.         return numToRound;
  653.     if (numToRound < 0)
  654.         return -(abs(numToRound) - remainder);
  655.     return numToRound + multiple - remainder;
  656. }
  657.  
  658. float VectorDiff(FVector vec1, FVector vec2)
  659. {
  660.     float distance = sqrt(pow(vec1.X - vec2.X, 2) + pow(vec1.Y - vec2.Y, 2));
  661.     return distance;
  662. };
  663. template <class T> T* Cast(UObject* pObj)
  664. {
  665.     return pObj && pObj->IsA(T::StaticClass()) ? (T*)pObj : NULL;
  666. }
  667.  
  668. UObject* GetInstanceOf(UClass* Class)
  669. {
  670.     static UObject* ObjectInstance;
  671.  
  672.     ObjectInstance = NULL;
  673.  
  674.     for (int i = 0; i < UObject::GObjObjects()->Count; ++i)
  675.     {
  676.         UObject* CheckObject = (*UObject::GObjObjects())(i);
  677.  
  678.         if (CheckObject && CheckObject->IsA(Class))
  679.         {
  680.             if (!strstr(CheckObject->GetFullName(), "Default"))
  681.                 ObjectInstance = CheckObject;
  682.         }
  683.     }
  684.  
  685.     return ObjectInstance;
  686. };
  687.  
  688. FColor MakeColor(int R, int G, int B, int A)
  689. {
  690.     FColor ReturnedColor;
  691.     ReturnedColor.R = R;
  692.     ReturnedColor.G = G;
  693.     ReturnedColor.B = B;
  694.     ReturnedColor.A = A;
  695.     return ReturnedColor;
  696. }
  697.  
  698. FColor Green = MakeColor(0, 255, 0, 255);
  699. FColor Yellow = MakeColor(255, 255, 0, 255);
  700. FColor Red = MakeColor(255, 0, 0, 255);
  701. FColor Blue = MakeColor(0, 0, 255, 255);
  702. FColor LightGreen = MakeColor(100, 255, 150, 120);
  703. FColor DarkGreen = MakeColor(100, 190, 60, 120);
  704. FColor White = MakeColor(255, 255, 255, 255);
  705. FColor Black = MakeColor(0, 0, 0, 0);
  706. FColor Pink = MakeColor(200, 0, 200, 255);
  707. FColor MenuBlack = MakeColor(0, 0, 0, 200);
  708. FColor MenuBlue = MakeColor(59, 209, 237, 150);
  709. FColor Orange = MakeColor(255, 128, 0, 255);
  710.  
  711. #pragma endregion
  712.  
  713. #pragma region Bot Related Helper Functions
  714.  
  715. string MD5HASH = "";
  716. char DataReceived[256];
  717.  
  718.  
  719. std::string GetWebsiteData2(const std::string& server, const std::string& file)
  720. {
  721.     if (boost::icontains(DllPath, website4))
  722.     {
  723.         WriteLogFile("\nData = ");
  724.     }
  725.     try
  726.     {
  727.         boost::asio::ip::tcp::iostream s(server, "http");
  728.         s.expires_from_now(boost::posix_time::seconds(15));
  729.  
  730.         if (!s)
  731.         {
  732.             return "ERROR : " + s.error().message();
  733.         }
  734.  
  735.         // ask for the file
  736.         s << "GET " << file << " HTTP/1.0\r\n";
  737.         s << "Host: " << server << "\r\n";
  738.         s << "Accept: */*\r\n";
  739.         s << "Cache-Control: no-cache, no-store, must-revalidate\r\n";
  740.         s << "Pragma: no-cache\r\n";
  741.         s << "Expires: Mon, 1 Jun 1995 01:00:00 GMT\r\n";
  742.         s << "Connection: close\r\n\r\n";
  743.  
  744.         // Check that response is OK.
  745.         std::string http_version;
  746.         s >> http_version;
  747.         unsigned int status_code;
  748.         s >> status_code;
  749.         std::string status_message;
  750.         std::getline(s, status_message);
  751.         if (!s && http_version.substr(0, 5) != "HTTP/")
  752.         {
  753.             return "ERROR";
  754.         }
  755.         if (status_code != 200)
  756.         {
  757.             return "ERROR WITH CODE - " + to_string(status_code);
  758.         }
  759.  
  760.         // Process the response headers, which are terminated by a blank line.
  761.         std::string header;
  762.         while (std::getline(s, header) && header != "\r"){}
  763.  
  764.         // Write the remaining data to output.
  765.         std::stringstream ss;
  766.         ss << s.rdbuf();
  767.         if (boost::icontains(DllPath, website4))
  768.         {
  769.             WriteLogFile(ss.str());
  770.         }
  771.         return ss.str();
  772.     }
  773.     catch (std::exception& e)
  774.     {
  775.         return e.what();
  776.     }
  777. }
  778.  
  779. bool SessionPing(string uniquekey)
  780. {
  781.     // PING%OS_MorB%_Method
  782.     //string morb = GetVariableValue("OS_MorB");
  783.     //string meth = morb + "_Method";
  784.     //string meth = GetVariableValue(meth);
  785.     string v = "/instancecheck.php?uk=" + uniquekey + "&license=" + gLICENSE + "&em=" + gInGameName;
  786.     v = GetWebsiteData2(website, v);
  787.     if (boost::icontains(v, "EMERGENCY-SHUTDOWN"))
  788.         gRunThreads = false;
  789.     if (boost::icontains(v, "false"))
  790.     {
  791.         gSessionIp = true;
  792.         if (boost::icontains(v, "IP MISMATCH"))
  793.             gSessionIp = false;
  794.         gSessionValid = false;
  795.         return false;
  796.     }
  797.     gSessionValid = true;
  798.     return true;
  799. }
  800.  
  801. bool Validate()
  802. {
  803.     for (int aa = 0; aa < 5; aa++)
  804.     {
  805.         char cbuffer[512] = "";
  806.         string v = "/version.txt";
  807.         v = GetWebsiteData2(website, v);
  808.         gVersionMatch = false;
  809.         if (boost::icontains(v, gVersion) || boost::icontains(v, "ERROR"))
  810.             gVersionMatch = true;
  811.  
  812.         sprintf_s(cbuffer, "/openeshop/api/license/%s?domain=%s", gLICENSE.c_str(), website.c_str()); // original
  813.         string test = GetWebsiteData2(website, cbuffer);
  814.         sprintf_s(DataReceived, "%s", test.c_str());
  815.         test = test.substr(0, 4);
  816.         if (boost::iequals(test, "true"))
  817.         {
  818.             gfuckhackers = true;
  819.             return true;
  820.         }
  821.         Sleep(500);
  822.     }
  823.     gfuckhackers = false;
  824.     return false;
  825. }
  826. FString FSTRING(string text)
  827. {
  828.     wchar_t buf[5000];
  829.     swprintf_s(buf, L"%S", text.c_str());
  830.     return{ buf, wcslen(buf) + 1, wcslen(buf) + 1 };
  831. }
  832. void myDrawBox(UCanvas *pCanvas, FColor Color, float CurX, float CurY, float width, float height, string label = "")
  833. {
  834.  
  835.     float OldCurX = pCanvas->CurX;
  836.     float OldCurY = pCanvas->CurY;
  837.     float OldCurZ = pCanvas->CurZ;
  838.     FColor OldColor = pCanvas->DrawColor;
  839.     float xrat, yrat;
  840.     xrat = mHUD->viewportResolution.X / 1280.0f;
  841.     yrat = mHUD->viewportResolution.Y / 720.0f;
  842.     CurX = CurX * xrat;
  843.     CurY = CurY * yrat;
  844.     pCanvas->DrawColor = Color;
  845.     pCanvas->SetPos(CurX - 15.0f, CurY - 22.0f, 0.0f);
  846.     pCanvas->DrawText(FSTRING(label), false, 1.0f, 1.0f, NULL);
  847.     pCanvas->SetPos(CurX, CurY, 0.0f);
  848.     pCanvas->DrawBox(width * xrat, height * yrat);
  849.     pCanvas->SetPos(OldCurX, OldCurY, OldCurZ);
  850.     pCanvas->DrawColor = OldColor;
  851. }
  852. void myDrawLine(UCanvas *pCanvas, FColor Color, float CurX, float CurY, float CurX2, float CurY2)
  853. {
  854.     float OldCurX = pCanvas->CurX;
  855.     float OldCurY = pCanvas->CurY;
  856.     float OldCurZ = pCanvas->CurZ;
  857.     FColor OldColor = pCanvas->DrawColor;
  858.     float xrat, yrat;
  859.     xrat = mHUD->viewportResolution.X / 1280.0f;
  860.     yrat = mHUD->viewportResolution.Y / 720.0f;
  861.     CurX = CurX * xrat;
  862.     CurY = CurY * yrat;
  863.     CurX2 = CurX2 * xrat;
  864.     CurY2 = CurY2 * yrat;
  865.     pCanvas->DrawColor = Color;
  866.     pCanvas->Draw2DLine(CurX, CurY, CurX2, CurY2, Color);
  867.     pCanvas->SetPos(OldCurX, OldCurY, OldCurZ);
  868.     pCanvas->DrawColor = OldColor;
  869. }
  870. void ShadowedText(UCanvas *pCanvas, WCHAR *text, FColor Color, float CurX, float CurY, float ScaleX = 1.0f, float ScaleY = 1.0f)
  871. {
  872.     float OldCurX = pCanvas->CurX;
  873.     float OldCurY = pCanvas->CurY;
  874.     FColor OldColor = pCanvas->DrawColor;
  875.     pCanvas->DrawColor = Black;
  876.     FString text2;
  877.     text2.Data = text;
  878.     text2.Count = wcslen(text) + 1;
  879.     text2.Max = text2.Count;
  880.     pCanvas->DrawColor = Color;
  881.     pCanvas->SetPos(CurX, CurY, 1.0f);
  882.     pCanvas->DrawText(text2, false, ScaleX, ScaleY, NULL);
  883.     pCanvas->SetPos(OldCurX, OldCurY, 1.0f);
  884.     pCanvas->DrawColor = OldColor;
  885.  
  886. }
  887. void LeftClickH()
  888. {
  889.     HWND h = MHhwnd;
  890.     DWORD mouseX = 0;// x coord of mouse
  891.     DWORD mouseY = 0;// y coord of mouse
  892.     PostMessage(h, WM_LBUTTONDOWN, 0, MAKELPARAM(mouseX, mouseY));
  893.     PostMessage(h, WM_LBUTTONUP, 0, MAKELPARAM(mouseX, mouseY));
  894. }
  895. void LeftClickG()
  896. {
  897.     mHUD->m_gameUI->HandleMouseEventInUnreal({ L"LeftMouseButton", 16, 16 }, { L"onPress", 8, 8 }); // doesn't get filtered to UI
  898.     mHUD->m_gameUI->HandleMouseEventInUnreal({ L"LeftMouseButton", 16, 16 }, { L"onRelease", 10, 10 }); // doesn't get filtered to UI
  899. }
  900. void LeftClickU()
  901. {
  902.     mHUD->m_gameUI->ForceGFxHandleMouseEvent({ L"LeftMouseButton", 16, 16 }, { L"onPress", 8, 8 });
  903.     mHUD->m_gameUI->ForceGFxHandleMouseEvent({ L"LeftMouseButton", 16, 16 }, { L"onRelease", 10, 10 });
  904. }
  905. void RightClickG()
  906. {
  907.     mHUD->m_gameUI->HandleMouseEventInUnreal({ L"RightMouseButton", 17, 17 }, { L"onPressAux", 11, 11 }); // doesn't get filtered to UI
  908.     mHUD->m_gameUI->HandleMouseEventInUnreal({ L"RightMouseButton", 17, 17 }, { L"onRelease", 10, 10 }); // doesn't get filtered to UI
  909. }
  910. void RightClickU()
  911. {
  912.     mHUD->m_gameUI->ForceGFxHandleMouseEvent({ L"RightMouseButton", 17, 17 }, { L"onPressAux", 11, 11 });
  913.     mHUD->m_gameUI->ForceGFxHandleMouseEvent({ L"RightMouseButton", 17, 17 }, { L"onRelease", 10, 10 });
  914. }
  915. void MoveMouse(float x, float y)
  916. {
  917.     if (mHUD)
  918.     {
  919.         float x1, x2, y1, y2, nx, ny;
  920.         float xrat, yrat;
  921.         xrat = mHUD->viewportResolution.X / mHUD->uiResolution.X;
  922.         yrat = mHUD->viewportResolution.Y / mHUD->uiResolution.Y;
  923.         x = x * xrat;
  924.         y = y * yrat;
  925.         x1 = mHUD->viewportResolution.X;
  926.         x2 = mHUD->uiResolution.X;
  927.         y1 = mHUD->viewportResolution.Y;
  928.         y2 = mHUD->uiResolution.Y;
  929.         nx = (x1 - x2) / 2;
  930.         ny = (y1 - y2) / 2;
  931.         mHUD->m_gameUI->MouseMC->SetPosition(x - nx, y - ny);
  932.     }
  933. }
  934.  
  935.  
  936. void SendText(string str, bool iskey)
  937. {
  938.     HWND h = MHhwnd;
  939.     if (!iskey)
  940.     {
  941.         for (string::iterator it = str.begin(); it != str.end(); ++it)
  942.         {
  943.             PendingSendText.push_back(*it);
  944.         }
  945.     }
  946.     else
  947.     {
  948.         PostMessage(h, WM_KEYDOWN, strtoul(str.c_str(), NULL, 16), 0);
  949.     }
  950.  
  951.  
  952.     return;
  953. }
  954. void PreventAFK()
  955. {
  956.     HWND h = MHhwnd;
  957.     PostMessage(h, WM_KEYDOWN, VK_LSHIFT, 0);
  958.     SendMessage(h, WM_KEYDOWN, VK_LSHIFT, 0);
  959. }
  960.  
  961.  
  962. void Wait(int time)
  963. {
  964.     gWaitTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count() + time;
  965. }
  966. void Wait(double time)
  967. {
  968.     gWaitTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count() + (long long)time;
  969. }
  970.  
  971.  
  972. float calculateDistance(float x1, float y1, float x2, float y2)
  973. {
  974.     float dist = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
  975.     return dist;
  976. }
  977. bool isWithPerpDistance(float x1, float y1, float x2, float y2, float c1, float c2, float dist)
  978. {
  979.     bool flagInside = false;
  980.  
  981.     float dist1, dist2;
  982.     long long fucktimeout = microseconds_now() + 150;
  983.     while (1)
  984.     {
  985.         if (microseconds_now() > fucktimeout)
  986.         {
  987.             WriteLogFileD("\nAvoidance Error Timeout");
  988.             gAvoidanceDisabledUntil = gCurTime + 1000;
  989.             break;
  990.         }
  991.         dist1 = calculateDistance(x1, y1, c1, c2);
  992.         dist2 = calculateDistance(x2, y2, c1, c2);
  993.         if ((dist1 <= dist) || (dist2 <= dist))
  994.         {
  995.             flagInside = true;
  996.             break;
  997.         }
  998.         if (calculateDistance(x1, y1, x2, y2) < dist / 16)
  999.         {
  1000.             break;
  1001.         }
  1002.         if (dist1 < dist2)
  1003.         {
  1004.             x2 = (x2 + x1) / 2;
  1005.             y2 = (y2 + y1) / 2;
  1006.         }
  1007.         else
  1008.         {
  1009.             x1 = (x2 + x1) / 2;
  1010.             y1 = (y2 + y1) / 2;
  1011.         }
  1012.     }
  1013.     return flagInside;
  1014. }
  1015.  
  1016.  
  1017. string regex_escape(const string& string_to_escape) {
  1018.     static const boost::regex re_boostRegexEscape(string("[.^$|()\\[\\]{}*+?\\\\]"));
  1019.     const string rep(string("\\\\&"));
  1020.     string result = regex_replace(string_to_escape, re_boostRegexEscape, rep, boost::match_default | boost::format_sed);
  1021.     return result;
  1022. }
  1023.  
  1024.  
  1025. UMarvelGFxPanel* GetPanelByName(string panelname)
  1026. {
  1027.     for (int wp = 0; wp < mHUD->m_gameUI->ManagerMC->m_panels.Count; wp++)
  1028.     {
  1029.         if (boost::iequals(panelname, mHUD->m_gameUI->ManagerMC->m_panels(wp)->PanelName.GetName()))
  1030.         {
  1031.             return mHUD->m_gameUI->ManagerMC->m_panels(wp);
  1032.         }
  1033.     }
  1034.     return NULL;
  1035. }
  1036.  
  1037.  
  1038. FVector2D w2s(FVector worldloc)
  1039. {
  1040.     FMatrix view = mHUD->ViewProjectionMatrix;
  1041.     float mX = 1280.0f * 0.5f;
  1042.     float mY = 720.0f * 0.5f;
  1043.     float x = worldloc.X;
  1044.     float y = worldloc.Y;
  1045.     float z = worldloc.Z;
  1046.     float w =
  1047.         view.XPlane.Z * x +
  1048.         view.YPlane.Z * y +
  1049.         view.ZPlane.Z * z +
  1050.         view.WPlane.Z;
  1051.     float vx =
  1052.         view.XPlane.X * x +
  1053.         view.YPlane.X * y +
  1054.         view.ZPlane.X * z +
  1055.         view.WPlane.X;
  1056.  
  1057.     float vy =
  1058.         view.XPlane.Y * x +
  1059.         view.YPlane.Y * y +
  1060.         view.ZPlane.Y * z +
  1061.         view.WPlane.Y;
  1062.     float nx = mX + mX * vx / w;
  1063.     float ny = mY - mY * vy / w;
  1064.  
  1065.     return{ nx, ny };
  1066. }
  1067.  
  1068.  
  1069.  
  1070. void SpitInfo(UGFxObject* obj, string name)
  1071. {
  1072.     if (!obj)
  1073.         return;
  1074.     WriteLogFile("\n---------------\n");
  1075.     WriteLogFile(name);
  1076.     WriteLogFile("\nName = ");
  1077.     WriteLogFile(to_string(obj->ActionScriptString(FSTRING("toString")).Data));
  1078.     WriteLogFile(" ----- ");
  1079.     WriteLogFile(obj->GetString(FSTRING("_name")).Data);
  1080.     WriteLogFile("\nLength = ");
  1081.     WriteLogFile(obj->GetInt(FSTRING("length")));
  1082.     WriteLogFile("\nHeight = ");
  1083.     WriteLogFile(obj->GetInt(FSTRING("_height")));
  1084.     WriteLogFile("\nWidth = ");
  1085.     WriteLogFile(obj->GetInt(FSTRING("_width")));  
  1086.     float x, y;
  1087.     obj->GetPosition(&x, &y);
  1088.     WriteLogFile("\nX = ");
  1089.     WriteLogFile(x);
  1090.     WriteLogFile("\nY = ");
  1091.     WriteLogFile(y);
  1092.     WriteLogFile("\n---------------");
  1093. }
  1094. void SpitString(UGFxObject* obj, string name)
  1095. {
  1096.     if (!obj)
  1097.         return;
  1098.     WriteLogFile("\nStringInfo -- ");
  1099.     WriteLogFile(name);
  1100.     WriteLogFile(" ---- ");
  1101.     WriteLogFile(obj->GetString(FSTRING(name)).Data);
  1102. }
  1103. void SpitInt(UGFxObject* obj, string name)
  1104. {
  1105.     if (!obj)
  1106.         return;
  1107.     WriteLogFile("\nIntInfo -- ");
  1108.     WriteLogFile(name);
  1109.     WriteLogFile(" ---- ");
  1110.     WriteLogFile(obj->GetInt(FSTRING(name)));
  1111. }
  1112.  
  1113.  
  1114. void SetIntInvoke(UGFxObject* object, string iname, int number)
  1115. {
  1116.     FString TempMember = FSTRING(iname);
  1117.     TArray<FASValue> TempArgs;
  1118.     FASValue TempV;
  1119.     TempV.Type = AS_Null;
  1120.     TempArgs.Add(TempV);
  1121.     TempArgs.Data[0].Type = AS_Int;
  1122.     TempArgs.Data[0].N = 0;
  1123.     TempArgs.Data[0].I = number;
  1124.     TempArgs.Data[0].B = true;
  1125.     TempArgs.Data[0].S = { L"", 0, 0 };
  1126.     object->Invoke(TempMember, TempArgs);
  1127. }
  1128.  
  1129. void LClickObject(UGFxObject* object)
  1130. {
  1131.     FString TempMember = { L"handleClick", wcslen(L"handleClick") + 1, wcslen(L"handleClick") + 1 };
  1132.     TArray<FASValue> TempArgs;
  1133.     FASValue TempV;
  1134.     TempV.Type = AS_Null;
  1135.     TempArgs.Add(TempV);
  1136.     TempArgs.Add(TempV);
  1137.     TempArgs.Data[0].S = { L"LeftMouseButton", wcslen(L"LeftMouseButton") + 1, wcslen(L"LeftMouseButton") + 1 };
  1138.     TempArgs.Data[0].Type = AS_String;
  1139.     TempArgs.Data[0].N = 0;
  1140.     TempArgs.Data[0].I = 0;
  1141.     TempArgs.Data[0].B = true;
  1142.     TempArgs.Data[1].Type = AS_Int;
  1143.     TempArgs.Data[1].N = 0;
  1144.     TempArgs.Data[1].I = 0;
  1145.     TempArgs.Data[1].B = true;
  1146.     TempArgs.Data[1].S = { L"", 0, 0 };
  1147.     object->Invoke(TempMember, TempArgs);
  1148. }
  1149.  
  1150.  
  1151. struct ABILITYDATA
  1152. {
  1153.     string icon = "";
  1154.     int slot = -1;
  1155.     string cooldowntext = "";
  1156.     float cooldownscale = 1.0f;
  1157.     double cooldown = 0;
  1158.     __int64 offcooldown = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
  1159.     float x = 1.0f;
  1160.     float y = 1.0f;
  1161.     float h = 1.0f;
  1162.     float w = 1.0f;
  1163.     bool visible = false;
  1164.     bool textureloaded = false;
  1165.     LPD3DXFONT font = NULL;
  1166.     LPDIRECT3DTEXTURE9 texture = NULL;
  1167. };
  1168. struct PAGEDATA
  1169. {
  1170.     vector<ABILITYDATA> AbilityData;
  1171. };
  1172. vector<PAGEDATA> PageData;
  1173.  
  1174. void LoadConfig()
  1175. {
  1176.     // Gets the full path of our dll without the dll name
  1177.     string path(DllPath);
  1178.     path = path.substr(0, (path.find_last_of("\\")) + 1);
  1179.     path.append("config.txt");
  1180.     // CUSTOM KEYBINDS
  1181.  
  1182.  
  1183.     ifstream infile;
  1184.     string line;
  1185.     infile.open(path);
  1186.     if (infile.is_open())
  1187.     {
  1188.         while (getline(infile, line))
  1189.         {
  1190.  
  1191.             //SETTING VALUE SUBSETTING VALUE2
  1192.             boost::trim_left(line);
  1193.             boost::trim_right(line);
  1194.             vector<string> lines = splitstring(line, ',');
  1195.             if (boost::iequals(lines[0], "Page"))
  1196.             {
  1197.                 //Page,#,Slot,#,PX,PY,H,W
  1198.                 WriteLogFile("\nPage ");
  1199.                 WriteLogFile(lines[1]);
  1200.                 WriteLogFile(" Slot ");
  1201.                 WriteLogFile(lines[2]);
  1202.                 PageData[stoi(lines[1])].AbilityData[stoi(lines[2])].visible = true;
  1203.                 PageData[stoi(lines[1])].AbilityData[stoi(lines[2])].x = stof(lines[3]);
  1204.                 PageData[stoi(lines[1])].AbilityData[stoi(lines[2])].y = stof(lines[4]);
  1205.                 PageData[stoi(lines[1])].AbilityData[stoi(lines[2])].h = stof(lines[5]) - 1.0f;
  1206.                 PageData[stoi(lines[1])].AbilityData[stoi(lines[2])].w = stof(lines[6]) - 1.0f;
  1207.             }
  1208.         }
  1209.         infile.close();
  1210.     }  
  1211. }
  1212.  
  1213. bool gTestBool = false;
  1214. int gTestNumber = 0;
  1215. int gTestNumber2 = 0;
  1216.  
  1217. int testnumber = 0;
  1218.  
  1219. string RandomString(int len)
  1220. {
  1221.     string str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  1222.     int pos;
  1223.     while (str.size() != len) {
  1224.         pos = ((rand() % (str.size() - 1)));
  1225.         str.erase(pos, 1);
  1226.     }
  1227.     return str;
  1228. }
  1229.  
  1230. int currentpage = 0;
  1231.  
  1232. FVector2D t_mousepos, r_mousepos;
  1233. void MyRender2(UCanvas *pCanvas)
  1234. {
  1235.     if (pCanvas)
  1236.     {
  1237.         wchar_t Blah[5000];
  1238.         float line = 15.0f;
  1239.         if (pPlayerController && pPlayerController->Agent)
  1240.         {
  1241.             swprintf_s(Blah, L"Current Page = %d", currentpage);
  1242.             ShadowedText(pCanvas, Blah, Yellow, 1.0f, 1 * line + 1.0f);
  1243.             swprintf_s(Blah, L"TMouse Pos = x %.1f y %.1f", t_mousepos.X, t_mousepos.Y);
  1244.             ShadowedText(pCanvas, Blah, Yellow, 1.0f, 2 * line + 1.0f);
  1245.             swprintf_s(Blah, L"Mouse Pos = x %.1f y %.1f", r_mousepos.X, r_mousepos.Y);
  1246.             ShadowedText(pCanvas, Blah, Yellow, 1.0f, 3 * line + 1.0f);
  1247.             //for (unsigned x = 0; x < PageData.size(); x++)
  1248.                 //for (unsigned y = 0; y < PageData[x].AbilityData.size(); y++)
  1249.                 //{
  1250.                     //swprintf_s(Blah, L"Page = %d | Slot %d | Cooldown %.1f | Icon %S", x, PageData[x].AbilityData[y].slot, PageData[x].AbilityData[y].cooldown, PageData[x].AbilityData[y].icon.c_str());
  1251.                     //ShadowedText(pCanvas, Blah, Yellow, 1.0f, 1 + ((x*8) + y) * line + 1.0f);
  1252.                 //}
  1253.  
  1254.         }
  1255.     }
  1256. }
  1257.  
  1258. typedef HRESULT(__stdcall* EndScene_t)(LPDIRECT3DDEVICE9);
  1259. EndScene_t pEndScene;
  1260.  
  1261.  
  1262. bool is_file_exist(const char *fileName)
  1263. {
  1264.     std::ifstream infile(fileName);
  1265.     return infile.good();
  1266. }
  1267.  
  1268. void DrawLine(int X, int Y, int XX, int YY, float LineWidth, D3DCOLOR LineColor, bool Outlined, float OutlineWidth, D3DCOLOR OutlineColor)
  1269. {
  1270.     D3DXVECTOR2 Points[2];
  1271.     Points[0] = D3DXVECTOR2(X, Y);
  1272.     Points[1] = D3DXVECTOR2(XX, YY);
  1273.     if (Outlined)
  1274.     {
  1275.         g_pLine->SetWidth(OutlineWidth * 2 + LineWidth);
  1276.         g_pLine->Draw(Points, 2, OutlineColor);
  1277.     }
  1278.     g_pLine->SetWidth(LineWidth);
  1279.     g_pLine->Draw(Points, 2, LineColor);
  1280. }
  1281.  
  1282. void DrawRect(int X, int Y, int Width, int Height, float LineWidth, D3DCOLOR LineColor, bool Outlined, bool Filled, float OutlineWidth, D3DCOLOR OutlineColor)
  1283. {
  1284.  
  1285.     if (Filled)
  1286.     {
  1287.         if (Outlined)
  1288.         {
  1289.             DrawLine(X - OutlineWidth, Y + Height / 2, X + Width + OutlineWidth, Y + Height / 2, Height, OutlineColor, true, OutlineWidth, OutlineColor);
  1290.         }
  1291.         DrawLine(X, Y + Height / 2, X + Width, Y + Height / 2, Height, LineColor, false, 0, 0);
  1292.     }
  1293.     else
  1294.     {
  1295.  
  1296.         if (Outlined)
  1297.         {
  1298.             DrawLine(X, Y, X, Y + Height, LineWidth, LineColor, true, OutlineWidth, OutlineColor);
  1299.             DrawLine(X, Y + Height, X + Width, Y + Height, LineWidth, LineColor, true, OutlineWidth, OutlineColor);
  1300.             DrawLine(X + Width, Y + Height, X + Width, Y, LineWidth, LineColor, true, OutlineWidth, OutlineColor);
  1301.             DrawLine(X + Width, Y, X, Y, LineWidth, LineColor, true, OutlineWidth, OutlineColor);
  1302.         }
  1303.         else
  1304.         {
  1305.             DrawLine(X, Y, X, Y + Height, LineWidth, LineColor, false, 0, 0);
  1306.             DrawLine(X, Y + Height, X + Width, Y + Height, LineWidth, LineColor, false, 0, 0);
  1307.             DrawLine(X + Width, Y + Height, X + Width, Y, LineWidth, LineColor, false, 0, 0);
  1308.             DrawLine(X + Width, Y, X, Y, LineWidth, LineColor, false, 0, 0);
  1309.         }
  1310.     }
  1311. }
  1312.  
  1313.  
  1314. float px, py;
  1315. float ex, ey, ew, eh;
  1316. HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice)
  1317. {      
  1318.     if (!gRunThreads)
  1319.         return pEndScene(pDevice);
  1320.  
  1321.     pDevice->GetViewport(&g_ViewPort);
  1322.     if (g_ViewPort.Width != 1094.0f || g_ViewPort.Height != 821.0f)
  1323.         return pEndScene(pDevice);
  1324.    
  1325.     if (!sprite)
  1326.     {       //D3DX_DEFAULT_NONPOW2     
  1327.         D3DXCreateSprite(pDevice, &sprite);
  1328.         D3DXCreateLine(pDevice, &g_pLine); //Create lines
  1329.     }  
  1330.     sprite->Begin(D3DXSPRITE_ALPHABLEND);
  1331.  
  1332.     for (int p = 0; p < 3; p++)
  1333.         for (int s = 0; s < 8; s++)
  1334.         {
  1335.             if (!PageData[p].AbilityData[s].visible)
  1336.                 continue;
  1337.             if (!PageData[p].AbilityData[s].textureloaded)
  1338.             {
  1339.                 PageData[p].AbilityData[s].textureloaded = true;
  1340.                 string temp = BasePath + PageData[p].AbilityData[s].icon + ".tga";
  1341.                 if (!is_file_exist(temp.c_str()))
  1342.                     temp = BasePath + "40x40_placeholder.tga";
  1343.                 WriteLogFile("\nLoading Texture = ");
  1344.                 WriteLogFile(temp);
  1345.                 if (PageData[p].AbilityData[s].texture)
  1346.                     PageData[p].AbilityData[s].texture->Release();
  1347.                 if (PageData[p].AbilityData[s].font)
  1348.                     PageData[p].AbilityData[s].font->Release();
  1349.                 D3DXCreateTextureFromFileExA(pDevice, temp.c_str(), PageData[p].AbilityData[s].h, PageData[p].AbilityData[s].w, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &PageData[p].AbilityData[s].texture);
  1350.                 D3DXCreateFontA(pDevice, PageData[p].AbilityData[s].h, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana", &PageData[p].AbilityData[s].font);
  1351.             }          
  1352.             float px = PageData[p].AbilityData[s].x + ((mHUD->viewportResolution.X - mHUD->uiResolution.X) / 2.0f);
  1353.             float py = PageData[p].AbilityData[s].y + ((mHUD->viewportResolution.Y - mHUD->uiResolution.Y) / 2.0f);
  1354.            
  1355.             D3DXVECTOR3 pos = D3DXVECTOR3(px, py, 0.0f);
  1356.             D3DCOLOR color;
  1357.             color = D3DCOLOR_ARGB(255, 255, 255, 255);
  1358.             D3DCOLOR color2;
  1359.             color2 = D3DCOLOR_ARGB(255, 255, 1, 1);
  1360.  
  1361.             D3DXMATRIX S, P;
  1362.             sprite->GetTransform(&P);
  1363.             sprite->Draw(PageData[p].AbilityData[s].texture, NULL, NULL, &pos, 0xFFFFFFFF);        
  1364.  
  1365.             DrawRect(px - 1, py - 1, PageData[p].AbilityData[s].h + 1, PageData[p].AbilityData[s].w + 1, 1.0f, color, false, false, 0.0f, color);
  1366.            
  1367.  
  1368.             string text = PageData[p].AbilityData[s].cooldowntext;
  1369.             RECT rect;
  1370.             SetRect(&rect, px, py, px + PageData[p].AbilityData[s].h, py + PageData[p].AbilityData[s].w);
  1371.            
  1372.             float sfx = PageData[p].AbilityData[s].cooldownscale;
  1373.             float sfy = PageData[p].AbilityData[s].cooldownscale;
  1374.             RECT rect2, shad1, shad2;
  1375.             SetRect(&rect2, rect.left * sfx, rect.top * sfy, rect.right * sfx, rect.bottom * sfy);         
  1376.             SetRect(&shad1, rect.left * sfx - 1, rect.top * sfy - 1, rect.right * sfx - 1, rect.bottom * sfy - 1);
  1377.             SetRect(&shad2, rect.left * sfx + 1, rect.top * sfy + 1, rect.right * sfx + 1, rect.bottom * sfy + 1);
  1378.             D3DXMatrixScaling(&S, 1.0f / sfx, 1.0f / sfy, 0.0f);           
  1379.             sprite->SetTransform(&S);          
  1380.             PageData[p].AbilityData[s].font->DrawTextA(sprite, text.c_str(), -1, &shad1, DT_NOCLIP | DT_CENTER | DT_VCENTER, color2);
  1381.             PageData[p].AbilityData[s].font->DrawTextA(sprite, text.c_str(), -1, &shad2, DT_NOCLIP | DT_CENTER | DT_VCENTER, color2);
  1382.             PageData[p].AbilityData[s].font->DrawTextA(sprite, text.c_str(), -1, &rect2, DT_NOCLIP | DT_CENTER | DT_VCENTER, color);
  1383.             sprite->SetTransform(&P);
  1384.  
  1385.         }
  1386.  
  1387.     //DrawRect(ex, ey, ew, eh, 2.0f, D3DCOLOR_ARGB(255, 255, 255, 255), false, false, 0.0f, D3DCOLOR_ARGB(255, 255, 255, 255));
  1388.  
  1389.     sprite->End();
  1390.  
  1391.     return pEndScene(pDevice);
  1392. }
  1393.  
  1394.  
  1395. bool runonce = true;
  1396.  
  1397.  
  1398. void MyTick2()
  1399. {
  1400.     if (!gRunThreads)
  1401.         return;
  1402.     __int64 gCurTime = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
  1403.     if (!pPlayerController)
  1404.         return;
  1405.     if (!pPlayerController->Agent)
  1406.         return;
  1407.     if (!World)
  1408.     {
  1409.         MODULEINFO miGame = TFLHACKT00LS::GetModuleInfo(NULL);
  1410.         TheWorld = *(unsigned long*)(TFLHACKT00LS::FindPattern((unsigned long)miGame.lpBaseOfDll, miGame.SizeOfImage, (unsigned char*)TheWorld_Pattern, (char*)TheWorld_Mask) + TheWorld_Offset);
  1411.         World = *(UWorld**)TheWorld;
  1412.         mEngine = (UMarvelGameEngine*)GetInstanceOf(UMarvelGameEngine::StaticClass());
  1413.     }
  1414.     mHUD = pPlayerController->Agent->getMarvelHUD();
  1415.     gMouseX = (mHUD->eventGetMouseCoordinates(true).X) / (mHUD->viewportResolution.X / mHUD->uiResolution.X);
  1416.     gMouseY = (mHUD->eventGetMouseCoordinates(true).Y) / (mHUD->viewportResolution.Y / mHUD->uiResolution.Y);
  1417.     string ownerid = to_hex(pPlayerController->GetCurrentAvatarId().A);
  1418.     wchar_t favaid[5000];
  1419.     swprintf_s(favaid, L"%S", ownerid.c_str());
  1420.  
  1421.     r_mousepos = mHUD->m_gameUI->GetGFxMousePos();
  1422.     FVector2D mousepos;
  1423.     mousepos.X = r_mousepos.X - ((mHUD->viewportResolution.X - mHUD->uiResolution.X) / 2.0f);
  1424.     mousepos.Y = r_mousepos.Y - ((mHUD->viewportResolution.Y - mHUD->uiResolution.Y) / 2.0f);
  1425.     t_mousepos = mousepos;
  1426.  
  1427.     if (runonce)
  1428.     {              
  1429.         pPlayerController->SetCurrentAvatarAbilitySet(0);
  1430.         currentpage = 0;
  1431.         runonce = false;       
  1432.     }
  1433.     UGFxObject* activePowers = mHUD->m_gameUI->PowerPanel->GetObjectW(FSTRING("activePowers"), UGFxObject::StaticClass());
  1434.  
  1435.  
  1436.     for (int i = 0; i < 8; i++)
  1437.     {
  1438.         UGFxObject* power = activePowers->GetElementObject(i, UGFxObject::StaticClass());
  1439.         UGFxObject* icon_mc = power->GetObjectW(FSTRING("icon_mc"), UGFxObject::StaticClass());
  1440.        
  1441.         string iconname = to_string(icon_mc->GetString(FSTRING("_source")).Data);
  1442.         boost::replace_all(iconname, "img://MarvelUIIcons.", "");
  1443.         if (iconname != PageData[currentpage].AbilityData[i].icon)
  1444.             PageData[currentpage].AbilityData[i].textureloaded = false;
  1445.         PageData[currentpage].AbilityData[i].icon = iconname;
  1446.         PageData[currentpage].AbilityData[i].slot = i;     
  1447.         PageData[currentpage].AbilityData[i].offcooldown = gCurTime + pPlayerController->GetAbilityCooldownTime(i).timeRemainingMS;    
  1448.     }
  1449.     for (int p = 0; p < 3; p++)
  1450.         for (int i = 0; i < 8; i++)
  1451.         {
  1452.             double cooldowntime = PageData[p].AbilityData[i].offcooldown - gCurTime;
  1453.             if (cooldowntime < 0) cooldowntime = 0;
  1454.             PageData[p].AbilityData[i].cooldown = cooldowntime / 1000; 
  1455.             if (cooldowntime >= 60000)
  1456.             {
  1457.                 int cd = PageData[p].AbilityData[i].offcooldown - gCurTime;
  1458.                 int m = (cd % (1000 * 60 * 60)) / (1000 * 60);
  1459.                 int s = ((cd % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
  1460.                 char buffer[5000];
  1461.                 if (s < 10)
  1462.                 sprintf_s(buffer, "%d:0%d", m,s);
  1463.                 else
  1464.                 sprintf_s(buffer, "%d:%d", m, s);
  1465.                 PageData[p].AbilityData[i].cooldowntext = buffer;
  1466.                 PageData[p].AbilityData[i].cooldownscale = 3.0f;
  1467.             }
  1468.             else if (cooldowntime > 0)
  1469.             {
  1470.                 char buffer[5000];
  1471.                 sprintf_s(buffer, "%.1f", PageData[p].AbilityData[i].cooldown);
  1472.                 PageData[p].AbilityData[i].cooldowntext = buffer;              
  1473.                 PageData[p].AbilityData[i].cooldownscale = 2.5f;
  1474.             }
  1475.             else
  1476.                 PageData[p].AbilityData[i].cooldowntext = "";
  1477.         }
  1478.  
  1479.  
  1480.     for (int wp = 0; wp < mHUD->m_gameUI->ManagerMC->m_panels.Count; wp++)
  1481.     {
  1482.         string PanelName = mHUD->m_gameUI->ManagerMC->m_panels(wp)->PanelName.GetName();
  1483.         if (boost::iequals(PanelName, "PowerPanel"))
  1484.             if (mHUD->m_gameUI->ManagerMC->m_panels(wp)->GetDisplayInfo().Visible)
  1485.             {
  1486.                 //FASDisplayInfo test = mHUD->m_gameUI->ManagerMC->m_panels(wp)->GetDisplayInfo();
  1487.                 //test.Visible = false;
  1488.                 //mHUD->m_gameUI->ManagerMC->m_panels(wp)->SetDisplayInfo(test);               
  1489.             }
  1490.        
  1491.     }      
  1492.    
  1493.  
  1494.     if (GetAsyncKeyState(VK_CONTROL))
  1495.         if (World)
  1496.             if (World->Levels.Data)
  1497.                 if (World->Levels.Data[0]->Actors.Data)
  1498.                     for (int i = 0; i < World->Levels.Data[0]->Actors.Count; i++)
  1499.                     { // start for loop                    
  1500.                         AMarvelItem* Item = Cast<AMarvelItem>(World->Levels.Data[0]->Actors(i));
  1501.                         if (Item)
  1502.                         {
  1503.                             UMarvelCommonTypes_FEntityId id;
  1504.                             Item->GetEntityId(&id);
  1505.                             FTooltipData test = mHUD->m_gameUI->GetTooltipForEntity(id, 1, id);
  1506.                             test.bTopMost = true;
  1507.                             if (Item->eventIsMousedOver())
  1508.                             {
  1509.                                 Item->eventShowTooltip(test, true);
  1510.                                 break;
  1511.                             }
  1512.                             else
  1513.                                 Item->eventHideTooltip(true);
  1514.                         }
  1515.                     }
  1516.  
  1517.     mHUD->m_gameUI->PlayerHUDPanel->ActionScriptVoid(FSTRING("clearPanelPositioningMembers"));
  1518.  
  1519.     FString TempMember = { L"PlaceMouseCenter", wcslen(L"PlaceMouseCenter") + 1, wcslen(L"PlaceMouseCenter") + 1 };
  1520.     TArray<FASValue> TempArgs;
  1521.     FASValue TempV;
  1522.     TempV.Type = AS_Null;
  1523.     TempArgs.Add(TempV);   
  1524.     TempArgs.Data[0].S = { L"", 0 ,0 };
  1525.     TempArgs.Data[0].Type = AS_Boolean;
  1526.     TempArgs.Data[0].N = 0;
  1527.     TempArgs.Data[0].I = 0;
  1528.     TempArgs.Data[0].B = false;
  1529.     UGFxObject* expbar = mHUD->m_gameUI->PlayerHUDPanel->GetObjectW(FSTRING("alternateExperienceBarFilled_mc"), UGFxObject::StaticClass());
  1530.     expbar->Invoke(TempMember, TempArgs);
  1531.     expbar->ActionScriptVoid(FSTRING("clearPanelPositioningMembers"));
  1532.    
  1533.  
  1534.     mHUD->m_gameUI->TooltipInWorldPanel->CallSwapDepths(99499);
  1535.     FASDisplayInfo test = mHUD->m_gameUI->TooltipInWorldPanel->GetDisplayInfo();
  1536.     test.Alpha = 200.0f;
  1537.     mHUD->m_gameUI->TooltipInWorldPanel->SetDisplayInfo(test);
  1538.  
  1539.     if (GetAsyncKeyState(VK_NUMPAD1))
  1540.     {
  1541.         float hp, hpmax;
  1542.         pPlayerController->Agent->GetEntityHealthAndMax(&hp, &hpmax);
  1543.         //WriteLogFile(str(format("\nCurrent HP = %1%/%2%") % hp % hpmax));
  1544.         float mana1, mana1max, mana2, mana2max;
  1545.         pPlayerController->Agent->GetEntityEnduranceAndMax(1, &mana1, &mana1max);
  1546.         pPlayerController->Agent->GetEntityEnduranceAndMax(0, &mana2, &mana2max);
  1547.         //WriteLogFile(str(format("\nCurrent Mana = %1%/%2% %3%/%4%") % mana1 % mana1max % mana2 % mana2max));
  1548.         Sleep(100);
  1549.            
  1550.         UGFxObject* expbar2 = mHUD->m_gameUI->PlayerHUDPanel->GetObjectW(FSTRING("alternateExperienceBarFilled_mc"), UGFxObject::StaticClass());
  1551.         //SpitInt(expbar2, "maxValue");
  1552.         //SpitInt(expbar2, "currentValue");            
  1553.        
  1554.         for (int x = 0; x < mHUD->m_gameUI->PanelConfigData.Count; x++)
  1555.         {
  1556.             string panelname = to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_PanelName.Data);
  1557.             WriteLogFile("\nPanel = ");
  1558.             WriteLogFile(panelname);
  1559.             if (boost::icontains(panelname, "PlayerHudPanel"))
  1560.             {
  1561.  
  1562.                 WriteLogFile(str(format("\n Panel Name = %1%") % to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_PanelName.Data)));
  1563.                 WriteLogFile(str(format("\n Target Name = %1%") % to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_TargetName.Data)));
  1564.                 WriteLogFile(str(format("\n Scale Mode = %1%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_ScaleMode));
  1565.                 WriteLogFile(str(format("\n Stretched = %1%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_Stretched));
  1566.                 WriteLogFile(str(format("\n Source Pins  = %1%,%2%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_SourceAttachmentPin.X % mHUD->m_gameUI->PanelConfigData.Data[x].PC_SourceAttachmentPin.Y));
  1567.                 WriteLogFile(str(format("\n Target Pins  = %1%,%2%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_TargetAttachmentPin.X % mHUD->m_gameUI->PanelConfigData.Data[x].PC_TargetAttachmentPin.Y));
  1568.                 WriteLogFile(str(format("\n PC_VirtualPixelOffset  = %1%,%2%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_VirtualPixelOffset.X % mHUD->m_gameUI->PanelConfigData.Data[x].PC_VirtualPixelOffset.Y));
  1569.                 WriteLogFile(str(format("\n PC_TopLeftStretchPin  = %1%,%2%") % mHUD->m_gameUI->PanelConfigData.Data[x].PC_TopLeftStretchPin.PA_XVal % mHUD->m_gameUI->PanelConfigData.Data[x].PC_TopLeftStretchPin.PA_YVal));
  1570.                 WriteLogFile(str(format("\n PC_PreferredLane Name = %1%") % to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_PreferredLane.Data)));
  1571.                 WriteLogFile(str(format("\n Widget Name = %1%") % to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_WidgetClass.Data)));
  1572.                 WriteLogFile(str(format("\n SWF Name = %1%") % to_string(mHUD->m_gameUI->PanelConfigData.Data[x].PC_SWFName.Data)));
  1573.                 //struct FPanelAnchor                                PC_BottomRightStretchPin;                              // 0x0058 (0x0020) [0x0000000000500000]              ( CPF_NeedCtorLink )
  1574.                 //TArray< struct FPanelConfig >                      PC_ChildPanelConfigs;                                  // 0x0078 (0x000C) [0x0000000000500000]              ( CPF_NeedCtorLink )
  1575.                 //unsigned long                                      PC_OpenOnStart : 1;                                    // 0x009C (0x0004) [0x0000000000000000] [0x00000001]
  1576.                 //unsigned long                                      PC_VisibilityToggleable : 1;                           // 0x009C (0x0004) [0x0000000000000000] [0x00000002]
  1577.                 //unsigned long                                      PC_CanClickThrough : 1;                                // 0x009C (0x0004) [0x0000000000000000] [0x00000004]
  1578.                 //unsigned long                                      PC_EntityInteractPanel : 1;                            // 0x009C (0x0004) [0x0000000000000000] [0x00000008]
  1579.                 //unsigned long                                      PC_UseNewPlacementSystem : 1;                          // 0x009C (0x0004) [0x0000000000000000] [0x00000010]               
  1580.                 //struct FVector2D                                   PC_OuterEdgePin;                                       // 0x00AC (0x0008) [0x0000000000000000]              
  1581.                 //struct FVector2D                                   PC_NewSourceAttachmentPin;                             // 0x00B4 (0x0008) [0x0000000000000000]              
  1582.                 //int                                                PC_SortDepth;                                          // 0x00BC (0x0004) [0x0000000000000000]              
  1583.                 //struct FPanelOpenData                              initOpenData;
  1584.  
  1585.                 WriteLogFile("\nChild Count = ");
  1586.                 WriteLogFile(mHUD->m_gameUI->PanelConfigData.Data[x].PC_ChildPanelConfigs.Count);                              
  1587.             }
  1588.         }
  1589.     }  
  1590.  
  1591.     return;
  1592. }
  1593.  
  1594.  
  1595.  
  1596. void MyDebug(char *name)
  1597. {
  1598.     WriteLogFile(name);
  1599.     WriteLogFile("\n");
  1600. }
  1601.  
  1602. void UpdatePowers(AMarvelHUD_eventSlottedPower_Parms* pParms)
  1603. {  
  1604.     int x = pParms->powerData.powerSlot;   
  1605.     //if (x == 1) x = 8;
  1606.     //if (x == 0) x = 1;   
  1607.     AbilityDetails[x] = pParms->powerData; 
  1608. }
  1609.  
  1610. void SetSecondaryResource(AMarvelHUD_eventSetAvatarSecondaryResourceGauge_Parms* pParms)
  1611. {
  1612.     gPlayerSecondaryCurrent = pParms->val;
  1613.     gPlayerSecondaryMax = pParms->MaxVal;
  1614. }
  1615.  
  1616. void PrintingSpecPower(UMarvelGFxGameUI_execToggleSpecializationPower_Parms* pParms)
  1617. {
  1618.     WriteLogFile("\n-=--=- Activated Specialization --- ");
  1619.     WriteLogFile(pParms->PowerPrototypeId.Data);
  1620. }
  1621. void ChangeCurrentPage(AMarvelPlayerController_execSetCurrentAvatarAbilitySet_Parms* pParms)
  1622. {
  1623.     currentpage = pParms->abilitySetIndex;
  1624. }
  1625.  
  1626. void TestFunction(UMarvelGFxGameUI_execOnContextMenuButtonClick_Parms* pParms)
  1627. {
  1628.     WriteLogFile("\nClick");
  1629.     WriteLogFile(pParms->interactionMethods.A);
  1630.     WriteLogFile(" , ");
  1631.     WriteLogFile(pParms->interactionMethods.B);
  1632.     WriteLogFile("\nButton = ");
  1633.     WriteLogFile(pParms->buttonIndex);
  1634. }
  1635. void TestFunction2(AMarvelHUD_eventDrawMiniMapPOIs_Parms* pParms)
  1636. {
  1637.     WriteLogFile("\nDrawing - ");
  1638.     WriteLogFile(pParms->miniMapPOIs.Count);
  1639. }
  1640. void TestFunction3(AMarvelHUD_eventSetAvatarExperience_Parms* pParms)
  1641. {
  1642.     WriteLogFile("\n-------------------------------");
  1643.     WriteLogFile(str(format("\nAvatar ID = %1%") % pParms->avatarId.A));
  1644.     WriteLogFile(str(format("\nMax Level = %1%") % pParms->bMaxLevel));
  1645.     WriteLogFile(str(format("\nExperience = %1%") % to_string(pParms->experience.Data)));
  1646.     WriteLogFile(str(format("\nMax Exp = %1%") % to_string(pParms->maxExp.Data)));
  1647.     WriteLogFile(str(format("\nMin Exp = %1%\n\n") % to_string(pParms->minExp.Data))); 
  1648. }
  1649.  
  1650.  
  1651.  
  1652. VOID WINAPI DispatchFunction()
  1653. {
  1654.     if (pUFunc == NULL)
  1655.         return;
  1656.  
  1657.     strcpy_s(FunctionName, pUFunc->GetFullName());
  1658.  
  1659.     if (!strcmp(FunctionName, "Function MarvelGame.MarvelGameViewportClient.GameSessionEnded") && gBotState == BS_READY)
  1660.     {
  1661.         gBotState = BS_LOGGING_OUT;
  1662.         gEnabledPing = false;
  1663.         pPlayerController = nullptr;
  1664.         mHUD = nullptr;
  1665.         World = nullptr;
  1666.         gDebugUI = false;
  1667.         Wait(10000);
  1668.         if (gRunning)
  1669.         {
  1670.             Wait(60000);
  1671.             gLoginTimer = gCurTime + 60000;
  1672.             gLoginCount = 0;
  1673.             WriteLogFile(str(format("\n%1%MHBuddy was running and I'm dced, I'll try to relog.") % TimeStampStr()));
  1674.             gNeedReconnecting = true;
  1675.             gShouldRelog = true;
  1676.             gRunning = false;
  1677.         }
  1678.         else
  1679.         {
  1680.             WriteLogFile(str(format("\n%1%MHBuddy was NOT running and I'm dced, I will not try to relog.") % TimeStampStr()));
  1681.             gShouldRelog = false;
  1682.         }
  1683.         return;
  1684.     }
  1685.     if (gRunThreads) // Stops everything safely if we attempt to uninject the dll
  1686.     {
  1687.            
  1688.        
  1689.         if (!strcmp(FunctionName, "Function MarvelGame.MarvelGFxGameUI.IncrementAvatarAbilitySet") || !strcmp(FunctionName, "Function MarvelGame.MarvelPlayerController.IncrementAvatarAbilitySet"))
  1690.         {
  1691.             currentpage++;
  1692.             if (currentpage == 3)
  1693.                 currentpage = 0;
  1694.         }  
  1695.         if (!strcmp(FunctionName, "Function MarvelGame.MarvelGFxGameUI.DecrementAvatarAbilitySet") || !strcmp(FunctionName, "Function MarvelGame.MarvelPlayerController.DecrementAvatarAbilitySet"))
  1696.         {
  1697.             currentpage--;
  1698.             if (currentpage == -1)
  1699.                 currentpage = 2;
  1700.         }      
  1701.         if (!strcmp(FunctionName, "Function MarvelGame.MarvelPlayerController.SetCurrentAvatarAbilitySet"))
  1702.         {          
  1703.             ChangeCurrentPage((AMarvelPlayerController_execSetCurrentAvatarAbilitySet_Parms*)pParms);
  1704.         }
  1705.         if (!strcmp(FunctionName, "Function MarvelGame.MarvelPlayerController.PossessAgent"))
  1706.         {
  1707.             World = nullptr;           
  1708.         }      
  1709.         if (!strcmp(FunctionName, "Function MarvelGame.MarvelHUD.SetAvatarSecondaryResourceGauge"))
  1710.         {
  1711.             SetSecondaryResource((AMarvelHUD_eventSetAvatarSecondaryResourceGauge_Parms*)pParms);
  1712.         }
  1713.         if (!strcmp(FunctionName, "Function MarvelGame.MarvelHUD.SlottedPower"))
  1714.         {
  1715.             UpdatePowers((AMarvelHUD_eventSlottedPower_Parms*)pParms);
  1716.         }
  1717.         if (!strcmp(FunctionName, "Function MarvelGame.MarvelGameViewportClient.PostRender"))
  1718.         {
  1719.        
  1720.  
  1721.             if (gRender)
  1722.                 MyRender2(((UMarvelGameViewportClient_eventPostRender_Parms*)pParms)->Canvas);
  1723.  
  1724.         }
  1725.  
  1726.        
  1727.  
  1728.         if (!strcmp(FunctionName, "Function MarvelGame.MarvelPlayerController.PlayerTick"))
  1729.         {
  1730.             pPlayerController = (AMarvelPlayerController*)pCallObject;
  1731.             if (pPlayerController)
  1732.             {                                                          
  1733.                 MyTick2();
  1734.             }
  1735.         }
  1736.  
  1737.     }
  1738.  
  1739. }
  1740. VOID __declspec(naked) ProxyFunction()
  1741. {
  1742.     __asm
  1743.     {
  1744.         mov pCallObject, ecx
  1745.  
  1746.             push edx
  1747.             mov edx, dword ptr[esp + 0x8]
  1748.             mov pUFunc, edx
  1749.             mov edx, dword ptr[esp + 0xC]
  1750.             mov pParms, edx
  1751.             pop edx
  1752.             pushfd
  1753.             pushad
  1754.  
  1755.     }
  1756.     DispatchFunction();
  1757.     __asm
  1758.     {
  1759.         popad
  1760.             popfd
  1761.             jmp[dwOldProcessEvent]
  1762.     }
  1763. }
  1764.  
  1765. #pragma region All Hooking DLL Functions
  1766.  
  1767.  
  1768. void GameHook()
  1769. {
  1770.     AbilityDetails.clear();
  1771.     AbilityDetails.resize(9);
  1772.     PageData.clear();
  1773.     PageData.resize(3);
  1774.     for (unsigned i = 0; i < PageData.size(); i++)
  1775.     {
  1776.         PageData[i].AbilityData.clear();
  1777.         PageData[i].AbilityData.resize(8);
  1778.     }
  1779.  
  1780.     LoadConfig();
  1781.    
  1782.     dwProcessEvent = TFLHACKT00LS::FindPattern((DWORD)GetModuleHandle(nullptr), 0xbac000, reinterpret_cast<PBYTE>(ProcessEvent_Pattern), ProcessEvent_Mask);
  1783.     dwOldProcessEvent = (DWORD)DetourFunction((BYTE *)dwProcessEvent, (BYTE *)ProxyFunction);
  1784.     Wait(10000);
  1785.     DWORD VTable[3] = { 0 };   
  1786.     DX_Init(VTable);       
  1787.     DWORD EndSceneaddy = VTable[ES];
  1788.     //dwOldEndScene = (DWORD)DetourFunction((BYTE *)EndSceneaddy, (BYTE *)hkEndScene);
  1789.     //pEndScene = (EndScene_t)dwOldEndScene;
  1790.  
  1791.    
  1792. }
  1793.  
  1794. void OnUnload(HMODULE hModule)
  1795. {
  1796.     while (true)
  1797.     {
  1798.         if ((GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_PAUSE)) || !gRunThreads)
  1799.         {
  1800.             WriteLogFile("\nUAW\n");
  1801.             Sleep(500);
  1802.             gRunThreads = false;
  1803.             Sleep(250);
  1804.             /*for (int p = 0; p < 3; p++)
  1805.                 for (int s = 0; s < 8; s++)
  1806.                 {
  1807.                 if (PageData[p].AbilityData[s].texture) PageData[p].AbilityData[s].texture->Release();
  1808.                 if (PageData[p].AbilityData[s].font) PageData[p].AbilityData[s].font->Release();
  1809.                 }
  1810.                 sprite->Release();  */
  1811.             Sleep(500);        
  1812.             if (dwOldEndScene)
  1813.             DetourRemove(reinterpret_cast<PBYTE>(dwOldEndScene), reinterpret_cast<PBYTE>(hkEndScene));                                         
  1814.             Sleep(2000);
  1815.             DetourRemove(reinterpret_cast<PBYTE>(dwOldProcessEvent), reinterpret_cast<PBYTE>(ProxyFunction));
  1816.             Sleep(100);
  1817.             // unload
  1818.             FreeLibraryAndExitThread(hModule, 0);
  1819.             // exit this thread    
  1820.             ExitThread(0);
  1821.         }
  1822.  
  1823.         Sleep(100); // check it every second
  1824.     }
  1825. }
  1826.  
  1827. void LogFileExport(HMODULE hModule)
  1828. {
  1829.  
  1830.     char DllPath2[512]; // prev 260
  1831.     GetModuleFileNameA((HINSTANCE)&__ImageBase, DllPath2, _countof(DllPath2));
  1832.     string path(DllPath2);
  1833.     path = path.substr(0, (path.find_last_of("\\")) + 1);
  1834.     path.append("logfile.txt");
  1835.     ofstream ofs;
  1836.     ofs.open(path, ofstream::out | ofstream::trunc);
  1837.     ofs.close();
  1838.     while (gRunThreads)
  1839.     {
  1840.         if (!PendingLogFile.empty())
  1841.         {
  1842.             int logsize = (int)PendingLogFile.size();
  1843.             ofs.open(path, ofstream::out | ofstream::app);
  1844.             if (ofs.is_open())
  1845.             {
  1846.                 for (int i = 0; i < logsize; i++)
  1847.                 {
  1848.                     ofs << PendingLogFile[i];
  1849.                 }
  1850.                 PendingLogFile.erase(PendingLogFile.begin(), PendingLogFile.begin() + logsize);
  1851.                 ofs.close();
  1852.             }
  1853.         }
  1854.         Sleep(25);
  1855.     }
  1856.     // exit this thread
  1857. }
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867. BOOL CALLBACK EnumWindowsProcMy(HWND hwnd, LPARAM lParam)
  1868. {
  1869.     DWORD lpdwProcessId;
  1870.     GetWindowThreadProcessId(hwnd, &lpdwProcessId);
  1871.     if (lpdwProcessId == lParam)
  1872.     {
  1873.         char NewName[256];
  1874.         GetWindowTextA(hwnd, NewName, 256);
  1875.         MHhwnd = hwnd;
  1876.         if (boost::icontains(NewName, "Marvel Heroes 2015") || boost::icontains(NewName, "Marvel Heroes 2016"))
  1877.             return FALSE;
  1878.         else
  1879.             return TRUE;
  1880.     }
  1881.     return TRUE;
  1882. }
  1883.  
  1884. void OnAttach(HMODULE hModule)
  1885. {
  1886.     DisableThreadLibraryCalls(hModule);
  1887.     srand((unsigned)time(0));
  1888.     CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)OnUnload, hModule, 0, NULL); 
  1889.     CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LogFileExport, hModule, 0, NULL);    
  1890.     GetModuleFileNameA((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath));
  1891.     string path(DllPath);
  1892.     path = path.substr(0, (path.find_last_of("\\")) + 1);
  1893.     BasePath = path + "Icons\\";
  1894.     WriteLogFile("\nBase Path = ");
  1895.     WriteLogFile(BasePath);
  1896.     path.append("LogFile.txt");
  1897.     pFileName = path;
  1898.     remove(pFileName.c_str()); 
  1899.     EnumWindows(EnumWindowsProcMy, GetCurrentProcessId());     
  1900.  
  1901.  
  1902.  
  1903.  
  1904.     GameHook();
  1905.  
  1906. }
  1907.  
  1908. void DX_Init(DWORD* table)
  1909. {  
  1910.     WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"DX", NULL };
  1911.     RegisterClassEx(&wc);
  1912.     HWND hWnd = CreateWindowA("DX", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, GetDesktopWindow(), NULL, wc.hInstance, NULL);
  1913.     LPDIRECT3D9 pD3D = Direct3DCreate9(D3D_SDK_VERSION);
  1914.     D3DPRESENT_PARAMETERS d3dpp;
  1915.     ZeroMemory(&d3dpp, sizeof(d3dpp));
  1916.     d3dpp.Windowed = TRUE;
  1917.     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
  1918.     d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
  1919.     LPDIRECT3DDEVICE9 pd3dDevice;
  1920.     pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice);
  1921.     DWORD* pVTable = (DWORD*)pd3dDevice;
  1922.     pVTable = (DWORD*)pVTable[0];
  1923.     table[ES] = pVTable[42];                    //EndScene address
  1924.     table[DIP] = pVTable[82];                    //DrawIndexedPrimitive address
  1925.     table[RES] = pVTable[16];                    //Reset address   
  1926.     DestroyWindow(hWnd);
  1927.     UnregisterClassA("DX", wc.hInstance);
  1928.     pD3D->Release();
  1929. }
  1930.  
  1931.  
  1932. // DLL ATTACH
  1933. BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
  1934. {
  1935.     switch (dwReason)
  1936.     {
  1937.     case DLL_PROCESS_ATTACH:
  1938.         DefFunc();     
  1939.         //CreateThread(0, 0, LoopFunction, 0, 0, 0);
  1940.         //CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LoopFunction, hModule, 0, NULL);
  1941.         CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)OnAttach, hModule, 0, NULL);
  1942.         return true;
  1943.     }
  1944. }
  1945.  
  1946. #pragma endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement