From c8d24d5bcb2db86663a525cef2cb286e8b4470eb Mon Sep 17 00:00:00 2001 From: ermaccer <40604575+ermaccer@users.noreply.github.com> Date: Sat, 20 Mar 2021 21:46:41 +0100 Subject: [PATCH] update --- README.md | 104 ++- source/IniReader.cpp | 2 +- source/PluginMH.aps | Bin 0 -> 2496 bytes source/PluginMH.rc | Bin 0 -> 4320 bytes source/PluginMH.vcxproj | 196 +++-- source/PluginMH.vcxproj.filters | 345 +++++++- source/PluginMH.vcxproj.user | 11 + source/code/CAnimLimit.cpp | 75 -- source/code/CAnimLimit.h | 11 - source/code/CDebugMenuLimit.cpp | 25 - source/code/CDebugMenuLimit.h | 6 - source/code/CHalosFix.cpp | 113 --- source/code/CHalosFix.h | 11 - source/code/CNewMenu.cpp | 118 --- source/code/CNewMenu.h | 7 - source/code/CPlayerModelLoader.h | 19 - source/code/CSettingsManager.cpp | 39 - source/code/CSettingsManager.h | 38 - source/code/CStuff.cpp | 118 --- source/code/CStuff.h | 11 - source/code/CTOC.h | 9 - source/code/CWeaponAdjuster.cpp | 399 --------- source/code/CWeaponAdjuster.h | 39 - source/code/CWeaponSpawner.cpp | 335 -------- source/code/CWeaponSpawner.h | 42 - source/code/ManhuntRW.cpp | 12 - source/code/ManhuntSDK.cpp | 150 ---- source/code/ManhuntSDK.h | 409 ---------- source/code/MemoryMgr.h | 443 ---------- source/code/core/FileFunctions.cpp | 171 ++++ source/code/core/FileFunctions.h | 17 + source/code/core/eMain.cpp | 79 ++ source/code/core/eMain.h | 10 + source/code/core/eSettingsManager.cpp | 71 ++ source/code/core/eSettingsManager.h | 44 + source/code/manhunt/AI.cpp | 10 + source/code/manhunt/AI.h | 12 + source/code/manhunt/AmmoWeapon.cpp | 11 + source/code/manhunt/AmmoWeapon.h | 266 ++++++ source/code/manhunt/Anim.cpp | 45 ++ source/code/manhunt/Anim.h | 92 +++ source/code/manhunt/App.cpp | 26 + source/code/manhunt/App.h | 43 + source/code/manhunt/Character.cpp | 7 + source/code/manhunt/Character.h | 8 + source/code/manhunt/Cheats.cpp | 54 ++ source/code/manhunt/Cheats.h | 61 ++ source/code/manhunt/Clump.h | 5 + source/code/manhunt/ClumpDict.cpp | 27 + source/code/manhunt/ClumpDict.h | 16 + source/code/manhunt/Collectable.cpp | 20 + source/code/manhunt/Collectable.h | 124 +++ source/code/manhunt/CreationManager.cpp | 7 + source/code/manhunt/CreationManager.h | 7 + source/code/manhunt/DevMenu.h | 8 + source/code/manhunt/Entity.cpp | 38 + source/code/manhunt/Entity.h | 176 ++++ source/code/manhunt/EntityManager.cpp | 25 + source/code/manhunt/EntityManager.h | 11 + source/code/manhunt/Filenames.cpp | 20 + source/code/manhunt/Filenames.h | 16 + source/code/manhunt/Frontend.cpp | 106 +++ source/code/manhunt/Frontend.h | 113 +++ source/code/manhunt/Input.cpp | 34 + source/code/manhunt/Input.h | 15 + source/code/manhunt/Inventory.cpp | 32 + source/code/manhunt/Inventory.h | 28 + source/code/manhunt/MaterialMananger.h | 69 ++ source/code/manhunt/Misc.cpp | 12 + source/code/manhunt/Misc.h | 18 + source/code/manhunt/Player.cpp | 17 + source/code/manhunt/Player.h | 9 + source/code/manhunt/Renderer.cpp | 38 + .../code/{ManhuntRW.h => manhunt/Renderer.h} | 22 +- source/code/manhunt/Scene.cpp | 31 + source/code/manhunt/Scene.h | 15 + source/code/manhunt/Script.cpp | 17 + source/code/manhunt/Script.h | 21 + source/code/manhunt/Shot.h | 84 ++ source/code/manhunt/SpecialFX.cpp | 23 + source/code/manhunt/SpecialFX.h | 189 +++++ source/code/manhunt/String.cpp | 14 + source/code/manhunt/String.h | 11 + source/code/manhunt/Text.cpp | 7 + source/code/manhunt/Text.h | 6 + source/code/manhunt/Time.cpp | 14 + source/code/manhunt/Time.h | 12 + source/code/manhunt/TypeData.h | 142 ++++ source/code/manhunt/Vector.h | 9 + source/code/manhunt/Weapon.h | 77 ++ source/code/manhunt/core.h | 43 + source/code/plugin/MHcommon.cpp | 59 ++ source/code/plugin/MHcommon.h | 7 + source/code/plugin/console/eConsole.cpp | 333 ++++++++ source/code/plugin/console/eConsole.h | 56 ++ source/code/plugin/eCommonHooks.cpp | 209 +++++ source/code/plugin/eCommonHooks.h | 27 + source/code/plugin/eCustomAnimManager.cpp | 58 ++ source/code/plugin/eCustomAnimManager.h | 11 + .../eCustomTableOfContents.cpp} | 45 +- source/code/plugin/eCustomTableOfContents.h | 9 + source/code/plugin/eLog.cpp | 53 ++ source/code/plugin/eLog.h | 10 + source/code/plugin/eModSettings.cpp | 9 + source/code/plugin/eModSettings.h | 9 + source/code/plugin/eNewFrontend.cpp | 515 ++++++++++++ source/code/plugin/eNewFrontend.h | 55 ++ source/code/plugin/eQoLChanges.cpp | 13 + source/code/plugin/eQoLChanges.h | 7 + .../eSkinLoader.cpp} | 258 +++--- source/code/plugin/eSkinLoader.h | 25 + source/code/plugin/eStatsManager.cpp | 230 ++++++ source/code/plugin/eStatsManager.h | 75 ++ source/code/plugin/menu/eMenu.cpp | 760 ++++++++++++++++++ source/code/plugin/menu/eMenu.h | 134 +++ .../plugin/modloader/eCustomClumpDict.cpp | 87 ++ .../code/plugin/modloader/eCustomClumpDict.h | 22 + source/code/plugin/modloader/eModLoader.cpp | 233 ++++++ source/code/plugin/modloader/eModLoader.h | 32 + source/code/plugin/script/eScriptExtender.cpp | 60 ++ source/code/plugin/script/eScriptExtender.h | 22 + source/dllmain.cpp | 217 ++--- source/framework.h | 5 + source/pch.cpp | 5 + source/pch.h | 13 + source/resource.h | 14 + source/stdafx.cpp | 8 - source/stdafx.h | 16 - source/targetver.h | 8 - 129 files changed, 6672 insertions(+), 2879 deletions(-) create mode 100644 source/PluginMH.aps create mode 100644 source/PluginMH.rc create mode 100644 source/PluginMH.vcxproj.user delete mode 100644 source/code/CAnimLimit.cpp delete mode 100644 source/code/CAnimLimit.h delete mode 100644 source/code/CDebugMenuLimit.cpp delete mode 100644 source/code/CDebugMenuLimit.h delete mode 100644 source/code/CHalosFix.cpp delete mode 100644 source/code/CHalosFix.h delete mode 100644 source/code/CNewMenu.cpp delete mode 100644 source/code/CNewMenu.h delete mode 100644 source/code/CPlayerModelLoader.h delete mode 100644 source/code/CSettingsManager.cpp delete mode 100644 source/code/CSettingsManager.h delete mode 100644 source/code/CStuff.cpp delete mode 100644 source/code/CStuff.h delete mode 100644 source/code/CTOC.h delete mode 100644 source/code/CWeaponAdjuster.cpp delete mode 100644 source/code/CWeaponAdjuster.h delete mode 100644 source/code/CWeaponSpawner.cpp delete mode 100644 source/code/CWeaponSpawner.h delete mode 100644 source/code/ManhuntRW.cpp delete mode 100644 source/code/ManhuntSDK.cpp delete mode 100644 source/code/ManhuntSDK.h delete mode 100644 source/code/MemoryMgr.h create mode 100644 source/code/core/FileFunctions.cpp create mode 100644 source/code/core/FileFunctions.h create mode 100644 source/code/core/eMain.cpp create mode 100644 source/code/core/eMain.h create mode 100644 source/code/core/eSettingsManager.cpp create mode 100644 source/code/core/eSettingsManager.h create mode 100644 source/code/manhunt/AI.cpp create mode 100644 source/code/manhunt/AI.h create mode 100644 source/code/manhunt/AmmoWeapon.cpp create mode 100644 source/code/manhunt/AmmoWeapon.h create mode 100644 source/code/manhunt/Anim.cpp create mode 100644 source/code/manhunt/Anim.h create mode 100644 source/code/manhunt/App.cpp create mode 100644 source/code/manhunt/App.h create mode 100644 source/code/manhunt/Character.cpp create mode 100644 source/code/manhunt/Character.h create mode 100644 source/code/manhunt/Cheats.cpp create mode 100644 source/code/manhunt/Cheats.h create mode 100644 source/code/manhunt/Clump.h create mode 100644 source/code/manhunt/ClumpDict.cpp create mode 100644 source/code/manhunt/ClumpDict.h create mode 100644 source/code/manhunt/Collectable.cpp create mode 100644 source/code/manhunt/Collectable.h create mode 100644 source/code/manhunt/CreationManager.cpp create mode 100644 source/code/manhunt/CreationManager.h create mode 100644 source/code/manhunt/DevMenu.h create mode 100644 source/code/manhunt/Entity.cpp create mode 100644 source/code/manhunt/Entity.h create mode 100644 source/code/manhunt/EntityManager.cpp create mode 100644 source/code/manhunt/EntityManager.h create mode 100644 source/code/manhunt/Filenames.cpp create mode 100644 source/code/manhunt/Filenames.h create mode 100644 source/code/manhunt/Frontend.cpp create mode 100644 source/code/manhunt/Frontend.h create mode 100644 source/code/manhunt/Input.cpp create mode 100644 source/code/manhunt/Input.h create mode 100644 source/code/manhunt/Inventory.cpp create mode 100644 source/code/manhunt/Inventory.h create mode 100644 source/code/manhunt/MaterialMananger.h create mode 100644 source/code/manhunt/Misc.cpp create mode 100644 source/code/manhunt/Misc.h create mode 100644 source/code/manhunt/Player.cpp create mode 100644 source/code/manhunt/Player.h create mode 100644 source/code/manhunt/Renderer.cpp rename source/code/{ManhuntRW.h => manhunt/Renderer.h} (83%) create mode 100644 source/code/manhunt/Scene.cpp create mode 100644 source/code/manhunt/Scene.h create mode 100644 source/code/manhunt/Script.cpp create mode 100644 source/code/manhunt/Script.h create mode 100644 source/code/manhunt/Shot.h create mode 100644 source/code/manhunt/SpecialFX.cpp create mode 100644 source/code/manhunt/SpecialFX.h create mode 100644 source/code/manhunt/String.cpp create mode 100644 source/code/manhunt/String.h create mode 100644 source/code/manhunt/Text.cpp create mode 100644 source/code/manhunt/Text.h create mode 100644 source/code/manhunt/Time.cpp create mode 100644 source/code/manhunt/Time.h create mode 100644 source/code/manhunt/TypeData.h create mode 100644 source/code/manhunt/Vector.h create mode 100644 source/code/manhunt/Weapon.h create mode 100644 source/code/manhunt/core.h create mode 100644 source/code/plugin/MHcommon.cpp create mode 100644 source/code/plugin/MHcommon.h create mode 100644 source/code/plugin/console/eConsole.cpp create mode 100644 source/code/plugin/console/eConsole.h create mode 100644 source/code/plugin/eCommonHooks.cpp create mode 100644 source/code/plugin/eCommonHooks.h create mode 100644 source/code/plugin/eCustomAnimManager.cpp create mode 100644 source/code/plugin/eCustomAnimManager.h rename source/code/{CTOC.cpp => plugin/eCustomTableOfContents.cpp} (53%) create mode 100644 source/code/plugin/eCustomTableOfContents.h create mode 100644 source/code/plugin/eLog.cpp create mode 100644 source/code/plugin/eLog.h create mode 100644 source/code/plugin/eModSettings.cpp create mode 100644 source/code/plugin/eModSettings.h create mode 100644 source/code/plugin/eNewFrontend.cpp create mode 100644 source/code/plugin/eNewFrontend.h create mode 100644 source/code/plugin/eQoLChanges.cpp create mode 100644 source/code/plugin/eQoLChanges.h rename source/code/{CPlayerModelLoader.cpp => plugin/eSkinLoader.cpp} (57%) create mode 100644 source/code/plugin/eSkinLoader.h create mode 100644 source/code/plugin/eStatsManager.cpp create mode 100644 source/code/plugin/eStatsManager.h create mode 100644 source/code/plugin/menu/eMenu.cpp create mode 100644 source/code/plugin/menu/eMenu.h create mode 100644 source/code/plugin/modloader/eCustomClumpDict.cpp create mode 100644 source/code/plugin/modloader/eCustomClumpDict.h create mode 100644 source/code/plugin/modloader/eModLoader.cpp create mode 100644 source/code/plugin/modloader/eModLoader.h create mode 100644 source/code/plugin/script/eScriptExtender.cpp create mode 100644 source/code/plugin/script/eScriptExtender.h create mode 100644 source/framework.h create mode 100644 source/pch.cpp create mode 100644 source/pch.h create mode 100644 source/resource.h delete mode 100644 source/stdafx.cpp delete mode 100644 source/stdafx.h delete mode 100644 source/targetver.h diff --git a/README.md b/README.md index cf2f3b2..1bcb08d 100644 --- a/README.md +++ b/README.md @@ -9,45 +9,111 @@ PluginMH requires https://github.com/ThirteenAG/Ultimate-ASI-Loader or https://g Check PluginMH.ini for available features. -# Controls (default) -**CTRL + V** - Enable/Disable Camera Control -**F1** - Enable/Disable Debug Menu +# Features -# Features +## First Person Mode -## TOC Disabler ## +Allows to freely move in first person perspective + +## TOC Disabler Removes the need to constantly update toc.txt -## Legal Screen Skip ## +## Player Model Loader -Skips 3 seconds long legal screen. +Allows you to load more player models and set them with one ini option, no need to replace existing files. +## Custom Menu -## Player Model Loader ## +Menu based on Manhunt 2 menu, it allows you to quickly spawn available weapons and more! -Allows you to load more player models and set them with one ini option, no need to replace existing files. +## Console + +Custom console recreated using leftover and custom code. + +## Screenshot Mode + +Press one key to instantly freeze the game, hide hud and move camera! + +## Modloader + +Load mods easily (read below)! + +## Custom Animations Manager + +Replaces animations loader with a custom one, allows to load more than 1000 animations + +## Stats + +Track your game data! + +## Tweaks + +Disable autoaim, BSP warnings and more! + +```NOTE: modloader and data folder must be in the root folder of the game!``` + + +# How to use Modloader +Modloader is a feature inspired by GTA Modloader by Link, +it is not as powerful as the GTA version but it is still pretty useful. + +What isn't supported? + +Currently, MH Modloader doesn't support swapping: + +- INI +- PAK +- Any audio file + +How to load mods? + +It depends on type, but every mod needs a folder. +Create a folder with any name inside modloader folder. + +MH Modloader comes with a custom DFF loader which allows +to load multiple .dff files and append them to the model list. + +Some files are ignored from beign loaded, they are specified +in modloader.ini file. + +By default, your .dff filename cannot be gmodelspc.dff or modelscpc.dff. +Model require txds to be loaded too, how to load texture for custom models? +You'll need a filename with .txd extension which is the same as the model name. +eg. +Katana.dff requires Katana.txd. +So, how to load model mods? -## Weapon Limit Adjuster/Customizer ## +Example folder tree: -Allows you to edit certain hardcoded values for weapons, and also add new ones with unique stuff like scopes or head explosion. -Experimental. +``` +---- My Custom Katana +-------Katana.dff +-------Katana.txd +``` -## Weapon Spawner ## +The .dff file will be loaded and any model that it replaces will +be replaced. -Fully working weapon spawner designed to replace broken Cheat functions with 3 slots for custom weapons. -## Screenshot Mode ## +Swapping normal files -Quickly freeze game and gain control of camera. +To swap normal files, you'll need to recreate the original path. -## FPS Mode ## +Example folder tree +``` +---- My Custom Loading +-------pictures +--------TITLE +---------title_pc.txd +``` -Allows to freely move in first person perspective. +The file will be loaded in place of the original. -and some other ones, likes forcing player skin to desired one or enabling cheats on bonus levels. +You can view list of loaded mods in the "Modifications" menu. +## Check the readme in releases and .ini file for more info! \ No newline at end of file diff --git a/source/IniReader.cpp b/source/IniReader.cpp index 218cf10..8422d61 100644 --- a/source/IniReader.cpp +++ b/source/IniReader.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "framework.h" #include "IniReader.h" #include #include diff --git a/source/PluginMH.aps b/source/PluginMH.aps new file mode 100644 index 0000000000000000000000000000000000000000..9c47293d6b5bb03efb202d27113901d91c7aa93e GIT binary patch literal 2496 zcmb7G-Hy{n6#h(8X=y=4Eg&w#mJ6tq)PZGzy+K*W+jU9o$o2+Sie#l(lMTvdSJ^}h zQXhhgUi6Yj;01b*s=fsD0oo^M`kk>8kK?kaj%?4F^PQhLGv{*vpv-$dPi_u#SB26o z-n)2;ZNBGoBh_Ckr30+30oGQxJvn|6_ot`bR&RVb8&A9K(QGgrw|19<>ZC6=?|J8a zzEiGDWIk`InVXozr^mBNKdv5vfunjmh+O+w82NVK?fI4+b?VJM8#S|ri@M(OTCKX< zNYxvrNx&C*fE)T=b7@cgm%2XKZ`liT@qP(do(FvlC?FWwMMvlAVp@y$v zI1MWb!g}afxLv8;K?R1gmFJ%Kj^f1ODW_(T+V#M(PL&`0lj4mx= zB9A#cp;e43(L58HzX3Hp9HERI+Km*xjN5pLhuFj&`gp4R9ni}eeU_e`Jm4=OHd^&J>mYUc@gEJWi>3yQ{1g?M5KG|vA{@dZWKbjrH<@H5( zuU{r#;ImKq5(N85<1R6L%@AeI&*xW`oT>NP>kG2N4gy4c+VDAY;BlpqTJH|Wa{X5N z>mP8BK35W!@5iZJ;t^S#+jI(lb4v~So3iJmM+eKElOB4`4g>yB7?X9b@x;jcCqBVb zc9FIgF-JI2egBF%N$1AOeN3N6l>4gBCu;6HS{Tb14b|Iy75jua4C!mEaPly*reQn8 zPT1`kM*8`F+SiiL7A_Mnc~2E~%-AC>qqbs%jEkydhY^2r{fKX9+oatbp&56Du&uX=4I&W5T_ z!ods7YL!-N)S#WgQ`BR2i;S|J79J`Q5mGBWe#*RixqZ1-dRzL1=ONEm*{NELZOAMT0ir=ekVy?3NGE9-ng@=F6VTwE~eDjVa j`agUl9J9uz{J2e0HJulPDZ+DYid-T*@{%?mqI{BF literal 0 HcmV?d00001 diff --git a/source/PluginMH.rc b/source/PluginMH.rc new file mode 100644 index 0000000000000000000000000000000000000000..ef0b1faf4cd35ed1ec5f2d1428f1354d4a168977 GIT binary patch literal 4320 zcmd6r+iu!G5QgWvQs2QPH?0~aki!FnLnsOfC=k?2kx&{AK}sOvpte$~C%?3p>=hY3bSJYR?4ISe(#nW9(k`f zThv<@koObnMpgNMukV-7ch3J0DN&zAYG~x}c^9jt9y-qKoGc1!s71ZpP)#NBs7p50 zxuo|eSFlyGjgD(_wu?P=yFfw~*Wq5ly@6I;UV4t^sV-|&<|o@nbBkHUm4sHVVAUDi zI{7Va8tNQ_7b2}X=%D!m>9Ui^Rve?&_?UXSt(yINQH=sTA|@&Ik6qSC>+Cs8_LZF7(w}b0+OWs3t=wkO@s1X~cAY)fcY7|+yj6-? zT3<MSblWeP!ysMCQe{rb~G3=dNp1vF?(7(W3S>|GOR2De6vp zylaHLrN~Ov<=RP2p@zarzE97cfm7VC^~&M=d}O}%BlW7dL<9T6xhL4D>trdjMyt)a zr3q@`yrabXuv5lo`IXaaUwyR!u0ke<1#{x96WEXljqt2boW|HX*{H^JZN4hvTIETB zsEU5&H(u9knY7;I-+J01jylT-gB*72%=64yb8J7zyE~rx@U?5?T<$)>yLYF~>6UfV zHGA*l72q}JIklcLM7Q~qu2*R4Ts(#9M7gzsohS9+1jO|*2vrF2)p@9=l$fq9MzYtdwC{{JpI=%Kb@0a{_^u!W($X?HL`Gf Sevj!3`fnonotKQeH2ncmL-=(7 literal 0 HcmV?d00001 diff --git a/source/PluginMH.vcxproj b/source/PluginMH.vcxproj index 04e5a4c..4d6d4e5 100644 --- a/source/PluginMH.vcxproj +++ b/source/PluginMH.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,35 +19,36 @@ - {7C6D04C2-EE52-4BAC-AC69-4E53F97A931A} + 15.0 + {DF58B4F9-5FA8-4A06-95A5-8ED91DD1A4AC} Win32Proj PluginMH - 8.1 + 10.0.17763.0 DynamicLibrary true - v140_xp - Unicode + v141 + MultiByte DynamicLibrary false - v140 + v141 true MultiByte DynamicLibrary true - v140 + v141 Unicode DynamicLibrary false - v140 + v141 true Unicode @@ -85,101 +86,188 @@ - - + NotUsing Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGINMH_EXPORTS;%(PreprocessorDefinitions) + true + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;PLUGINMH_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + pch.h + stdcpplatest Windows true + false - - + Use Level3 Disabled - _DEBUG;_WINDOWS;_USRDLL;PLUGINMH_EXPORTS;%(PreprocessorDefinitions) + true + _DEBUG;PLUGINMH_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + pch.h Windows true + false + NotUsing Level3 - - MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGINMH_EXPORTS;%(PreprocessorDefinitions) + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;PLUGINMH_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + pch.h + stdcpp17 Windows - true true true + true + false + Use Level3 - - MaxSpeed true true - NDEBUG;_WINDOWS;_USRDLL;PLUGINMH_EXPORTS;%(PreprocessorDefinitions) + true + NDEBUG;PLUGINMH_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + pch.h Windows - true true true + true + false - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - false - - - false - - - false - - - false - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + Create + Create + Create + Create + + + + diff --git a/source/PluginMH.vcxproj.filters b/source/PluginMH.vcxproj.filters index d3dca41..1def32e 100644 --- a/source/PluginMH.vcxproj.filters +++ b/source/PluginMH.vcxproj.filters @@ -7,75 +7,350 @@ {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - {1e0b90be-1809-436e-b6d8-ed692b196577} + + {5e262293-7f67-4d16-9551-c0a7cd0c27d6} + + + {11c10a44-9318-4a31-9988-71d623c09ae5} + + + {f31e2f5a-e48b-4eca-aca1-951e105f7147} + + + {dc3f41e9-0aa7-419b-8923-877bcf7b6965} + + + {95e3e37a-16d9-49a0-8706-b44ed7622c3e} + + + {4e18220d-8de3-4601-abbd-055bcf65d2ed} + + + {7b3deaf2-12bf-438e-a720-e2d7cdabfee7} + + + {d1b03838-d8ee-4f91-8960-143feb31be91} + + + {5b75541c-e1ad-4a0e-b291-b347449bc2ac} + + + {743bb4db-ffb9-40ad-8acf-87777ea3eb4b} + + + {16845170-a99b-49b9-bb35-12e48f94822c} - - - - + + Header Files + + Header Files - + + Header Files + + + Header Files\core + + + Header Files\core + + Header Files Header Files - - Header Files\code + + Header Files\plugin + + + Header Files\plugin + + + Header Files\plugin + + + Header Files\plugin + + + Header Files\plugin + + + Header Files\manhunt\main + + + Header Files\manhunt\main + + + Header Files\manhunt\main + + + Header Files\manhunt\main + + + Header Files\manhunt\main + + + Header Files\manhunt\game + + + Header Files\manhunt\game + + + Header Files\manhunt\main + + + Header Files\manhunt\main + + + Header Files\manhunt\game + + + Header Files\manhunt\game + + + Header Files\manhunt\main + + + Header Files\plugin\menu + + + Header Files\manhunt\game + + + Header Files\manhunt\game\weapons + + + Header Files\manhunt\game\weapons + + + Header Files\manhunt\game + + + Header Files\plugin + + + Header Files\plugin\modloader + + + Header Files\plugin\modloader + + + Header Files\manhunt\game + + + Header Files\plugin\script + + + Header Files\plugin\console + + + Header Files\plugin + + + Header Files\core + + + Header Files\manhunt\main + + + Header Files\plugin + + + Header Files\plugin + + + Header Files\manhunt\game - - Header Files\code + + Header Files\manhunt\game\core - - Header Files\code + + Header Files\manhunt\game\core - - Header Files\code + + Header Files\manhunt\game\core - - Header Files\code + + Header Files\manhunt\game\core - - Header Files\code + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\weapons + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\plugin - - Source Files - Source Files + + Header Files\core + + + Header Files\core + Header Files - - Header Files\code + + Header Files\plugin + + + Header Files\plugin + + + Header Files\plugin + + + Header Files\plugin + + + Header Files\plugin + + + Header Files\manhunt\main + + + Header Files\manhunt\main + + + Header Files\manhunt\main + + + Header Files\manhunt\game + + + Header Files\manhunt\game + + + Header Files\manhunt\game + + + Header Files\manhunt\main + + + Header Files\manhunt\game + + + Header Files\plugin\menu - - Header Files\code + + Header Files\manhunt\main - - Header Files\code + + Header Files\manhunt\game - - Header Files\code + + Header Files\manhunt\main - - Header Files\code + + Header Files\manhunt\game\weapons - - Header Files\code + + Header Files\manhunt\game + + Header Files\plugin + + + Header Files\plugin\modloader + + + Source Files + + + Header Files\plugin\modloader + + + Header Files\manhunt\game + + + Header Files\plugin\script + + + Header Files\plugin\console + + + Header Files\plugin + + + Header Files\core + + + Header Files\plugin + + + Header Files\plugin + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game\core + + + Header Files\manhunt\game + + + Header Files\plugin + + + + + Resource Files + \ No newline at end of file diff --git a/source/PluginMH.vcxproj.user b/source/PluginMH.vcxproj.user new file mode 100644 index 0000000..42fc4a7 --- /dev/null +++ b/source/PluginMH.vcxproj.user @@ -0,0 +1,11 @@ + + + + Z:\Steam\steamapps\common\Manhunt\manhunt.exe + WindowsLocalDebugger + + + Z:\Steam\steamapps\common\Manhunt\manhunt.exe + WindowsLocalDebugger + + \ No newline at end of file diff --git a/source/code/CAnimLimit.cpp b/source/code/CAnimLimit.cpp deleted file mode 100644 index 467a678..0000000 --- a/source/code/CAnimLimit.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "CAnimLimit.h" -#include "..\MemoryMgr.h" -#include -#include -#include -using namespace Memory::VP; - -std::vector AnimationNames; - -void CAnimLimit::Init() -{ - char messageBuffer[256]; - FILE* pFile = fopen("data\\animations.dat","rb"); - - if (!pFile) - MessageBoxA(0, "Failed to open animations.dat!", 0, 0); - - if (pFile) - { - char szLine[1024]; - int i = 0; - while (fgets(szLine, sizeof(szLine), pFile)) - { - if (szLine[0] == ';' || szLine[0] == '\n') - continue; - - char tempStr[256]; - if (sscanf(szLine, "%s", &tempStr) == 1) - { - if (strlen(tempStr) > 48) - MessageBoxA(0, "ERROR: String too large!\n 48 characters max!", tempStr, 0); - else - { - anim_entry name; - sprintf(name.name, "%s", tempStr); - - AnimationNames.push_back(name); - } - - } - } - MessageBoxA(0, messageBuffer, 0, 0); - } -} - -void CAnimLimit::MakePatches() -{ - std::unique_ptr animations = std::make_unique(1000); - - Patch(0x496416 + 1, 999); - Patch(0x496420 + 3, (int)&animations[0]); - Patch(0x4965B1 + 3, (int)&animations[0]); - Patch(0x496768 + 3, (int)&animations[0]); - Patch(0x496B17 + 3, (int)&animations[0]); - /* - Patch(0x41D92B + 2, (int)&AnimationNames[0]); - Patch(0x41E92A + 1, (int)&AnimationNames[0]); - Patch(0x41EBC7 + 2, (int)&AnimationNames[0]); - Patch(0x41EBD3 + 1, (int)&AnimationNames[0]); - Patch(0x421137 + 2, (int)&AnimationNames[0]); - Patch(0x421144 + 1, (int)&AnimationNames[0]); - Patch(0x4211B5 + 2, (int)&AnimationNames[0]); - Patch(0x4211C2 + 1, (int)&AnimationNames[0]); - Patch(0x421BF5 + 2, (int)&AnimationNames[0]); - Patch(0x421C02 + 1, (int)&AnimationNames[0]); - Patch(0x422614 + 2, (int)&AnimationNames[0]); - Patch(0x422621 + 1, (int)&AnimationNames[0]); - Patch(0x422925 + 2, (int)&AnimationNames[0]); - Patch(0x422932 + 1, (int)&AnimationNames[0]); - Patch(0x422D54 + 2, (int)&AnimationNames[0]); - Patch(0x422D61 + 1, (int)&AnimationNames[0]); - Patch(0x422FC4 + 2, (int)&AnimationNames[0]); - Patch(0x422FD1 + 1, (int)&AnimationNames[0]); - */ -} diff --git a/source/code/CAnimLimit.h b/source/code/CAnimLimit.h deleted file mode 100644 index 21309e5..0000000 --- a/source/code/CAnimLimit.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -struct anim_entry { - char name[48] = {}; -}; - -namespace CAnimLimit { - // TODO - void Init(); - void MakePatches(); -} \ No newline at end of file diff --git a/source/code/CDebugMenuLimit.cpp b/source/code/CDebugMenuLimit.cpp deleted file mode 100644 index 7b94db3..0000000 --- a/source/code/CDebugMenuLimit.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "CDebugMenuLimit.h" -#include "..\MemoryMgr.h" -#include -using namespace Memory::VP; - -#define FE_DEV_MENU_ITEMS_MAX 170 - -char szDevMenuNames[FE_DEV_MENU_ITEMS_MAX * 32]; - -int jmpHookOne = 0x5F1EC9; - -void CDebugMenuLimit::Init() -{ - Patch(0x5E9AAB + 2, (int)szDevMenuNames); - Patch(0x5F22C9 + 2, 0); -} - -void __declspec(naked) CDebugMenuLimit::HookOne() -{ - _asm { - lea eax, szDevMenuNames - mov ebx, eax - jmp jmpHookOne - } -} diff --git a/source/code/CDebugMenuLimit.h b/source/code/CDebugMenuLimit.h deleted file mode 100644 index d3b9484..0000000 --- a/source/code/CDebugMenuLimit.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -namespace CDebugMenuLimit { - void Init(); - void HookOne(); -} \ No newline at end of file diff --git a/source/code/CHalosFix.cpp b/source/code/CHalosFix.cpp deleted file mode 100644 index f1c7424..0000000 --- a/source/code/CHalosFix.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "CHalosFix.h" -#include "ManhuntRW.h" -#include "ManhuntSDK.h" - -int*& tempRenderStates = *(int**)0x7D2ADC; -int*& dword_7D2B2C = *(int**)0x7D2B2C; -int& dword_7D2AD8 = *(int*)0x7D2AD8; -int& m_nHaloAmount = *(int*)0x7D5E30; -int& dword_7D2A98 = *(int*)0x7D2A98; - -int*& dword_7D5A30 = *(int**)0x7D5A30; -int*& dword_7D5A34 = *(int**)0x7D5A34; -int*& dword_7D5A38 = *(int**)0x7D5A38; -int*& dword_7D5A4C = *(int**)0x7D5A4C; - - - -/* -void CHalosFix::HookRenderPickups() -{ - int nHaloCounter = 0; - int nHaloOffset = 0; - - if (m_nHaloAmount) - { - ++dword_7D2A98; - // prepare rendering flags - - /*RwRenderStateSetA(rwRENDERSTATESRCBLEND, rwBLENDNABLEND); - RwRenderStateSetA(rwRENDERSTATESRCBLEND, rwBLENDNABLEND); - RwRenderStateSetA(rwRENDERSTATEVERTEXALPHAENABLE, 0); - - RwRenderStateSet(rwRENDERSTATESRCBLEND, rwBLENDONE); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, rwBLENDONE); - - tempRenderStates[dword_7D2AD8] = rwRENDERSTATEVERTEXALPHAENABLE; - RwRenderStateSetA(rwRENDERSTATEVERTEXALPHAENABLE, dword_7D2B2C[dword_7D2AD8]); - - ++dword_7D2AD8; - - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, 1); - tempRenderStates[dword_7D2AD8] = 14; - - RwRenderStateSetA(rwRENDERSTATEFOGENABLE, dword_7D2B2C[dword_7D2AD8]); - ++dword_7D2AD8; - - RwRenderStateSet(rwRENDERSTATEFOGENABLE, 0); - tempRenderStates[dword_7D2AD8] = rwRENDERSTATECULLMODE; - - RwRenderStateSetA(rwRENDERSTATECULLMODE, 4 * dword_7D2AD8 + 0x7D2B2C); - ++dword_7D2AD8; - RwRenderStateSet(rwRENDERSTATECULLMODE, rwCULLMODECULLNONE); - tempRenderStates[dword_7D2AD8] = rwRENDERSTATEZWRITEENABLE; - RwRenderStateSetA(rwRENDERSTATEZWRITEENABLE, dword_7D2B2C[dword_7D2AD8]); - - - ++dword_7D2AD8; - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, 0); - - tempRenderStates[dword_7D2AD8] = 6; - - RwRenderStateSetA(rwRENDERSTATEZTESTENABLE, dword_7D2B2C[dword_7D2AD8]); - - ++dword_7D2AD8; - - RwRenderStateSet(rwRENDERSTATEZTESTENABLE, 1); - - tempRenderStates[dword_7D2AD8] = 2; - - RwRenderStateSetA(rwRENDERSTATETEXTUREADDRESS, dword_7D2B2C[dword_7D2AD8]); - ++dword_7D2AD8; - RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, rwTEXTUREADDRESSWRAP); - tempRenderStates[dword_7D2AD8] = 9; - RwRenderStateSetA(rwRENDERSTATETEXTUREFILTER, dword_7D2B2C[dword_7D2AD8]); - ++dword_7D2AD8; - //RwRenderStateSetA(rwRENDERSTATETEXTUREFILTER, dword_7D2B2C[dword_7D2AD8]); - RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, rwFILTERLINEAR); - RwRenderStateSet(rwRENDERSTATESRCBLEND, rwBLENDSRCALPHA); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, rwBLENDONE); - - nHaloCounter = 0; - - if (m_nHaloAmount > 0) - { - nHaloOffset = 0; - do - { - int v5 = dword_7D5A30[nHaloOffset]; - int v6 = dword_7D5A34[nHaloOffset]; - int v7 = dword_7D5A38[nHaloOffset]; - Render3DHalo((int)&v5, 1.0f,120,120,120, dword_7D5A4C[nHaloOffset]); - nHaloCounter++; - nHaloOffset += 8; - } while (nHaloCounter < m_nHaloAmount); - } - --dword_7D2A98; - RwRenderStateSet(rwRENDERSTATESRCBLEND,*(int*)0x7D2AA4); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, 0); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, 0); - } - -} - -void CHalosFix::Render2DHalo(int ptr, float scale, int r, int g, int b, float range) -{ - Call<0x5FB6D0, int, float, int, int, int, float>(ptr, scale, r,g,b,range); -} - -void CHalosFix::Render3DHalo(int ptr, float scale, int r, int g, int b, float range) -{ - Call<0x5FBBD0, int, float, int, int, int, float>(ptr, scale, r, g, b, range); -} -*/ \ No newline at end of file diff --git a/source/code/CHalosFix.h b/source/code/CHalosFix.h deleted file mode 100644 index 0bdb21a..0000000 --- a/source/code/CHalosFix.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - - -namespace CHalosFix { - //TODO - //void HookRenderPickups(); - - // functions - //void Render2DHalo(int ptr, float scale, int r, int g, int b, float range); - //void Render3DHalo(int ptr, float scale, int r, int g, int b, float range); -} \ No newline at end of file diff --git a/source/code/CNewMenu.cpp b/source/code/CNewMenu.cpp deleted file mode 100644 index 59f6e06..0000000 --- a/source/code/CNewMenu.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include "CNewMenu.h" -#include -#include -#include "ManhuntSDK.h" -using namespace ManhuntFunctions; - -float& fMenuPositionX = *(float*)0x7D6410; -float& fMenuPositionY = *(float*)0x7D640C; -float& fButtonY = *(float*)0x7C8728; -float& fTextScaleX = *(float*)0x7C8720; -float& fTextScaleY = *(float*)0x7C8724; -float& fHudStretch = *(float*)0x7D3458; - -int& iMenuButton = *(int*)0x7C89D4; -int& iActiveCheat = *(int*)0x7C84A8; -int& iCheatsON = *(int*)0x7C84AC; - -void CNewMenu::ProcessMainMenuHook() -{ - wchar_t* menuText, *cheatText; - float pos = fButtonY, pos_temp; - int button = iMenuButton; - int iLastCheat = 0; - - - // draw menu thing - Call<0x5D5740, wchar_t*>(FastGetText("MAINM")); - - // draw manhunt logo - - int mhLogo = CallAndReturn(*(int*)0x7C8704, "logo"); - DrawTexture(*(float*)0x7D6408, *(float*)0x7D6404, fHudStretch * *(float*)0x7D63FC, *(float*)0x7D6400, 180, 180, 180, 255, mhLogo); - - // play game - menuText = GetText(0x725A38,"PLAY"); - AddMenuEntry(menuText, fMenuPositionX, fMenuPositionY, fTextScaleX, fTextScaleY,button == 0); - - // select scene - pos += 0.40000001; - menuText = GetText(0x725A38,"SELSCE"); - AddMenuEntry(menuText, fMenuPositionX, pos, fTextScaleX, fTextScaleY, button == 1); - // load game - pos += fButtonY; - menuText = GetText(0x725A38,"LOADG"); - AddMenuEntry(menuText, fMenuPositionX, pos, fTextScaleX, fTextScaleY, button == 2); - // settings - pos += fButtonY; - menuText = GetText(0x725A38,"SETT"); - AddMenuEntry(menuText, fMenuPositionX, pos, fTextScaleX, fTextScaleY, button == 3); - // bonus - pos += fButtonY; - menuText = GetText(0x725A38,"BONFEA"); - AddMenuEntry(menuText, fMenuPositionX, pos, fTextScaleX, fTextScaleY, button == 4); - - // mods - pos += fButtonY; - menuText = L"MODIFICATIONS"; - AddMenuEntry(menuText, fMenuPositionX, pos, fTextScaleX, fTextScaleY, button == 5); - - // quit - pos += fButtonY; - menuText = GetText(0x725A38,"QUITPRG"); - AddMenuEntry(menuText, fMenuPositionX, pos, fTextScaleX, fTextScaleY, button == 6); - - if (iActiveCheat) - { - switch (iActiveCheat) - { - case CHEAT_RUNNER: - cheatText = FastGetText("C_RUN"); - break; - case CHEAT_SILENCE: - cheatText = FastGetText("C_SILEN"); - break; - case CHEAT_REGENERATION: - cheatText = FastGetText("C_REGEN"); - break; - case CHEAT_EXPLODE: - cheatText = FastGetText("C_HELI"); - break; - case CHEAT_EQUIPPED: - cheatText = FastGetText("C_FULEQ"); - break; - case CHEAT_SUPERPUNCH: - cheatText = FastGetText("C_SUPUN"); - break; - case CHEAT_RABBIT: - cheatText = FastGetText("C_RABBI"); - break; - case CHEAT_MONKEY: - cheatText = FastGetText("C_MONKE"); - break; - case CHEAT_INVIS: - cheatText = FastGetText("C_INVIS"); - break; - case CHEAT_PIGGSY: - cheatText = FastGetText("C_PIGGS"); - break; - case CHEAT_GODMODE: - cheatText = FastGetText("C_GOD"); - break; - default: - break; - } - } - - if (iCheatsON) - Call<0x5D5BB0, const wchar_t*, int*,int*,int*>(cheatText, &*(int*)0x7D6360, &*(int*)0x7D6360, &*(int*)0x7D6360); -} - -void CNewMenu::HookExtraButton(wchar_t* text, float posx, float posy, float tsx, float tsy, int button) -{ - int but = iMenuButton; - //AddMenuEntry(text, fMenuPositionX, posy, fTextScaleX, fTextScaleY, but == 5); - - //float pos = posy + fButtonY; - AddMenuEntry(text, fMenuPositionX, posy, fTextScaleX, fTextScaleY, but == 5); -} diff --git a/source/code/CNewMenu.h b/source/code/CNewMenu.h deleted file mode 100644 index dd24ce6..0000000 --- a/source/code/CNewMenu.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - - -namespace CNewMenu { - void ProcessMainMenuHook(); - void HookExtraButton(wchar_t* text, float posx, float posy, float tsx, float tsy, int button); -} \ No newline at end of file diff --git a/source/code/CPlayerModelLoader.h b/source/code/CPlayerModelLoader.h deleted file mode 100644 index 3a98220..0000000 --- a/source/code/CPlayerModelLoader.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include - -struct CCustomPlayer -{ - int iID; - std::string sModelFile; - std::string sTxdFile; - std::string sRootName; - int iShowWeapons; - int iFlag; -}; - -namespace CPlayerModelLoader { - int ReadFile(const char* name); - int Hook(int skinID); - int FindSkin(int skinID); - void HookWeapon(); -} \ No newline at end of file diff --git a/source/code/CSettingsManager.cpp b/source/code/CSettingsManager.cpp deleted file mode 100644 index 0b49d29..0000000 --- a/source/code/CSettingsManager.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "CSettingsManager.h" -#include "ManhuntSDK.h" - -CSettingsManager* SettingsMgr = new CSettingsManager(); - -void CSettingsManager::Init() -{ - CIniReader reader(""); - bEnableCheatsOnBonusLevels = reader.ReadBoolean("Settings", "bEnableCheatsOnBonusLevels", false); - bEnableScreenshotMode = reader.ReadBoolean("Settings", "bEnableScreenshotMode", false); - bEnableWeaponSpawner = reader.ReadBoolean("Settings", "bEnableWeaponSpawner", false); - bHookWeaponAdjuster = reader.ReadBoolean("Settings", "bHookWeaponAdjuster", false); - bEnableFirearmsExecutions = reader.ReadBoolean("Settings", "bEnableFirearmsExecutions", false); - bEnableConsoleOutput = reader.ReadBoolean("Settings", "bEnableConsoleOutput", false); - bEnableFPSMode = reader.ReadBoolean("Settings", "bEnableFPSMode", false); - bEnableFXMode = reader.ReadBoolean("Settings","bEnableFXMode", false); - bEnableConfirmationIcon = reader.ReadBoolean("Patches", "bEnableConfirmationIcon", false); - bEnableExperimentalRIBLoopFix = reader.ReadBoolean("Patches", "bEnableExperimentalRIBLoopFix", false); - bHookPlayerModelLoader = reader.ReadBoolean("Settings", "bHookPlayerModelLoader", false); - bDisableLegalScreen = reader.ReadBoolean("Patches", "bDisableLegalScreen", true); - bDisableTOC = reader.ReadBoolean("Settings", "bDisableTOC", true); - iForcePlayerSkin = reader.ReadInteger("Settings", "iForcePlayerSkin", 0); - iRestrictedHeliumCheatWeaponType = reader.ReadInteger("Settings", "iRestrictedHeliumCheatWeaponType", 0); - iDebugMenuKey = reader.ReadInteger("Settings", "iDebugMenuKey", 0); - iQuickScreenshotKeyMain = reader.ReadInteger("Settings", "iQuickScreenshotKeyMain", 0); - iQuickScreenshotKeySub = reader.ReadInteger("Settings", "iQuickScreenshotKeySub", 0); - iQuickHideHUDKey = reader.ReadInteger("Settings", "iQuickHideHUDKey", 0); - // custom weaps - szCustomWeapon[0] = reader.ReadString("Spawner", "szCustomWeapon1Record",0); - szCustomWeapon[1] = reader.ReadString("Spawner", "szCustomWeapon2Record",0); - szCustomWeapon[2] = reader.ReadString("Spawner", "szCustomWeapon3Record",0); - - iCustomWeapon[0] = reader.ReadInteger("Spawner", "iCustomWeapon1Record", -1); - iCustomWeapon[1] = reader.ReadInteger("Spawner", "iCustomWeapon2Record", -1); - iCustomWeapon[2] = reader.ReadInteger("Spawner", "iCustomWeapon3Record", -1); - - - szSkinsLine = reader.ReadString("Settings", "szDisplayWeaponsOn", "0 1"); -} diff --git a/source/code/CSettingsManager.h b/source/code/CSettingsManager.h deleted file mode 100644 index d2b482e..0000000 --- a/source/code/CSettingsManager.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include "..\IniReader.h" - - -class CSettingsManager { -public: - void Init(); - - // vars - bool bEnableCheatsOnBonusLevels; - bool bEnableWeaponSpawner; - bool bEnableScreenshotMode; - bool bHookWeaponAdjuster; - bool bEnableFirearmsExecutions; - bool bEnableConsoleOutput; - bool bEnableFXMode; - bool bEnableFPSMode; - bool bEnableConfirmationIcon; - bool bEnableExperimentalRIBLoopFix; - bool bHookPlayerModelLoader; - bool bDisableLegalScreen; - bool bDisableTOC; - - - int iForcePlayerSkin; - char iRestrictedHeliumCheatWeaponType; - int iDebugMenuKey; - int iQuickScreenshotKeyMain; - int iQuickScreenshotKeySub; - int iQuickHideHUDKey; - - char* szCustomWeapon[3]; - int iCustomWeapon[3]; - - char* szSkinsLine; -}; - -extern CSettingsManager* SettingsMgr; \ No newline at end of file diff --git a/source/code/CStuff.cpp b/source/code/CStuff.cpp deleted file mode 100644 index af3a602..0000000 --- a/source/code/CStuff.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include "CStuff.h" -#include "ManhuntSDK.h" -#include -#include "..\MemoryMgr.h" -#include "CSettingsManager.h" -#include "CWeaponSpawner.h" - -using namespace Memory::VP; -using namespace ManhuntDebugMenu; -using namespace ManhuntFunctions; - -void CStuff::EnableCheatsOnBonusLevels() -{ - -} - -bool CStuff::KeyHit(unsigned int keyCode) -{ - return (GetKeyState(keyCode) & 0x8000) != 0; -} - -int CStuff::HookDebugEntires() -{ - int result; - if (!*(char*)0x7A13D0) - { - EditVariableInt("Cheat: Helium Hunters", (int*)0x7C84BC); - EditVariableInt("Freeze World", (int*)0x715BA0); - if (SettingsMgr->bEnableWeaponSpawner) - { - CallFunction("Spawn: Can", CWeaponSpawner::Can); - CallFunction("Spawn: Bottle", CWeaponSpawner::Bottle); - CallFunction("Spawn: Brick", CWeaponSpawner::Brick); - CallFunction("Spawn: Knife", CWeaponSpawner::Knife); - CallFunction("Spawn: Shard", CWeaponSpawner::Shard); - CallFunction("Spawn: Shard (Piggsy)", CWeaponSpawner::ShardP); - CallFunction("Spawn: Bag", CWeaponSpawner::Bag); - CallFunction("Spawn: Wire", CWeaponSpawner::Wire); - CallFunction("Spawn: Wire (Piggsy)", CWeaponSpawner::WireP); - CallFunction("Spawn: Spike (Piggsy)", CWeaponSpawner::Wood); - CallFunction("Spawn: Cleaver", CWeaponSpawner::Cleaver); - CallFunction("Spawn: Crowbar", CWeaponSpawner::Crowbar); - CallFunction("Spawn: Machete", CWeaponSpawner::Machete); - CallFunction("Spawn: Axe", CWeaponSpawner::Axe); - CallFunction("Spawn: IcePick", CWeaponSpawner::IcePick); - CallFunction("Spawn: Sickle", CWeaponSpawner::Sickle); - CallFunction("Spawn: Nightstick", CWeaponSpawner::NightStick); - CallFunction("Spawn: Small Bat", CWeaponSpawner::SmallBat); - CallFunction("Spawn: Hammer", CWeaponSpawner::Hammer); - CallFunction("Spawn: Baseball Bat", CWeaponSpawner::WBat); - CallFunction("Spawn: Metal Bat", CWeaponSpawner::Bat); - CallFunction("Spawn: Spiked Bat", CWeaponSpawner::SpikedBat); - CallFunction("Spawn: Glock", CWeaponSpawner::Glock); - CallFunction("Spawn: Nailgun", CWeaponSpawner::NailGun); - CallFunction("Spawn: Desert Eagle", CWeaponSpawner::Deagle); - CallFunction("Spawn: Uzi", CWeaponSpawner::Uzi); - CallFunction("Spawn: 6Shooter", CWeaponSpawner::Revolver); - CallFunction("Spawn: Shotgun", CWeaponSpawner::Shotgun); - CallFunction("Spawn: Shotgun + Torch", CWeaponSpawner::ShotgunT); - CallFunction("Spawn: Sawnoff", CWeaponSpawner::SawnOff); - CallFunction("Spawn: Sniper Rifle", CWeaponSpawner::Sniper); - CallFunction("Spawn: C. Commando", CWeaponSpawner::Colt); - CallFunction("Spawn: Tranq. Rifle", CWeaponSpawner::Tranq); - CallFunction("Spawn: Chainsaw", CWeaponSpawner::Chainsaw); - CallFunction("Spawn: Custom #1", CWeaponSpawner::Custom1); - CallFunction("Spawn: Custom #2", CWeaponSpawner::Custom2); - CallFunction("Spawn: Custom #3", CWeaponSpawner::Custom3); - } - result = CallFunction("Dump player coords", CStuff::DumpPlayerCoords); - } - Patch(0x7A0FAC + 0x424, 1); - return result; -} - - -void CStuff::DumpPlayerCoords() -{ - std::ofstream oFile("data\\out.txt", std::ofstream::binary); - - oFile << "Text output: " << *(float*)0x821430 << " " << *(float*)0x821434 << " " << *(float*)0x821438 << std::endl; - - oFile << "Raw output (use hex editor to see):\n"; - - for (int i = 0; i < 3; i++) - { - float pos = *(float*)(0x821430 + i * 4); - oFile.write((char*)&pos, sizeof(float)); - } - - WriteDebug(12, "Saved coords to data\\out.txt!"); -} - - - - -void CStuff::HookManTriIcon(float x, float y, float scaleX, float scaleY, int red, int green, int blue, int alpha, int pTexture) -{ - Call<0x5F96F0, float, float, float, float, int, int, int, int, int>(x, y, scaleX, scaleY, red, green, blue, alpha, pTexture); - if (*(int*)0x7D343C) - Call<0x5F96F0, float, float, float, float, int, int, int, int, int>(0.81300002,0.88100001, 0.04, 0.05, 255, 255, 255, 255, *(int*)0x7D343C); -} - - -void __declspec(naked) CStuff::HookSkipIntroSeq() -{ - static int jmpPoint = 0x5E276E; - _asm jmp jmpPoint - -} - -void __declspec(naked) CStuff::DisableExecutionCamera() -{ - static int jmpPoint = 0x589D10; - _asm jmp jmpPoint -} - - - diff --git a/source/code/CStuff.h b/source/code/CStuff.h deleted file mode 100644 index 4e8d87a..0000000 --- a/source/code/CStuff.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include -namespace CStuff { - void EnableCheatsOnBonusLevels(); - bool KeyHit(unsigned int keyCode); - int HookDebugEntires(); - void DumpPlayerCoords(); - void HookManTriIcon(float x, float y, float scaleX, float scaleY, int red, int green, int blue, int alpha, int pTexture); - void HookSkipIntroSeq(); - void DisableExecutionCamera(); -} \ No newline at end of file diff --git a/source/code/CTOC.h b/source/code/CTOC.h deleted file mode 100644 index ee3a383..0000000 --- a/source/code/CTOC.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "ManhuntSDK.h" - -namespace eTOC { - CFile* __cdecl HookLoadFile(char *name, int *fileBuffer, int *a3, CFile **file, int *fileSize); - bool HookLoadTOC(bool isGlobal); - void HookSkipLevelToc(); -} \ No newline at end of file diff --git a/source/code/CWeaponAdjuster.cpp b/source/code/CWeaponAdjuster.cpp deleted file mode 100644 index dbc837c..0000000 --- a/source/code/CWeaponAdjuster.cpp +++ /dev/null @@ -1,399 +0,0 @@ -#include "CWeaponAdjuster.h" -#include "ManhuntSDK.h" -#include "..\MemoryMgr.h" -#include - -using namespace ManhuntFunctions; -std::vector vWeapons; - -int iExplodeWeapon_esp; -int iExplodeWeapon_id; -int iExplodeWeapon_true = 0x49D79A; -int iExplodeWeapon_false = 0x49D940; -int iExplodeWeapon_iFind; - -int iAutoHeadL_esp; -int iAutoHeadL_id; -int iAutoHeadL_true = 0x49D976; -int iAutoHeadL_false = 0x49DE35; -int iAutoHeadL_iFind; - -float ignoreDist = 100000.0f; - -int CWeaponAdjuster::ReadFile(const char * file) -{ - FILE* pFile = fopen(file, "rb"); - if (!pFile) - { - printf("CWeaponAdjuster::ReadFile() | ERROR: Could not open %s!\n", file); - return 0; - } - if (pFile) - { - printf("CWeaponAdjuster::ReadFile() | Reading %s\n", file); - char line[1536]; - while (fgets(line, sizeof(line), pFile)) - { - // check if comment - if (line[0] == ';' || line[0] == '#' || line[0] == '\n') - continue; - - int id = 0; - if (sscanf(line, "%d", &id) == 1) - { - char t_recordname[128]; - char t_collectablename[128]; - char t_gxtname[128]; - char t_iconname[128]; - char t_executionName[128]; - int flags; - - sscanf(line, "%d %s %s %s %s %d %s", &id, &t_recordname, &t_collectablename, &t_gxtname, &t_iconname, &flags, &t_executionName); - - // convert to strings - std::string strRecordName(t_recordname, strlen(t_recordname)); - std::string strCollectableName(t_collectablename, strlen(t_collectablename)); - std::string strGXTName(t_gxtname, strlen(t_gxtname)); - std::string strIconName(t_iconname, strlen(t_iconname)); - std::string strExecName(t_executionName, strlen(t_executionName)); - // create weapon - CCustomWeapon weap; - - weap.weaponID = id; - weap.weaponFlag = flags; - weap.sGxtEntryName = strGXTName; - weap.sRecordName = strRecordName; - weap.sWeaponCollectableName = strCollectableName; - weap.sFeIconName = strIconName; - weap.sExecutionName = strExecName; - - vWeapons.push_back(weap); - } - - } - printf("CWeaponAdjuster::ReadFile() | Found %d entities!\n", vWeapons.size()); - fclose(pFile); - } - return 1; -} - -void CWeaponAdjuster::GetRecordName(int id, char * dest) -{ - int iFind = 0; - for (int i = 0; i < vWeapons.size(); i++) - { - if (vWeapons[i].weaponID == id) - { - iFind = i; - break; - } - } - if (iFind == 0) - { - printf("CWeaponAdjuster::GetRecordName() | %d does not exist! Using fist instead!\n", id); - sprintf(dest, "fists"); - } - else - sprintf(dest, vWeapons[iFind].sRecordName.c_str()); -} - -int CWeaponAdjuster::GetWeaponIDFromString(std::string input) -{ - int iFind = 0; - for (int i = 0; i < vWeapons.size(); i++) - { - if (vWeapons[i].sWeaponCollectableName == input) - { - iFind = i; - break; - } - } - return vWeapons[iFind].weaponID; -} - -int CWeaponAdjuster::GetExecutionIDFromString(std::string input) -{ - int result = 15; - - if (input == "BAG") result = EXEC_BAG; - else if (input == "KNIFE") result = EXEC_KNIFE; - else if (input == "CROWBAR") result = EXEC_CROWBAR; - else if (input == "BAT") result = EXEC_BAT; - else if (input == "SICKLE") result = EXEC_SICKLE; - else if (input == "WIRE") result = EXEC_WIRE; - else if (input == "CLEAVER") result = EXEC_CLEAVER; - else if (input == "AXE") result = EXEC_AXE; - else if (input == "NIGHTSTICK") result = EXEC_NIGHTSTICK; - else if (input == "HAMMER") result = EXEC_HAMMER; - else if (input == "CHAINSAW") result = EXEC_CHAINSAW; - else if (input == "PIGSHARD") result = EXEC_PIGSHARD; - else if (input == "PIGWIRE") result = EXEC_PIGWIRE; - else if (input == "PIGSPIK") result = EXEC_PIGSPIK; - else if (input == "RAMIREZ") result = EXEC_RAMIREZ; - else if (input == "DEFAULT") result = EXEC_DEFAULT; - else { - result = 15; - } - return result; -} - -int CWeaponAdjuster::GetWeaponID(int * line) -{ - std::string temp = (char*)*line; - - return GetWeaponIDFromString(temp); -} - -wchar_t * CWeaponAdjuster::GetWeaponText(int id) -{ - int iFind = 0; - for (int i = 0; i < vWeapons.size(); i++) - { - if (vWeapons[i].weaponID == id) - { - iFind = i; - break; - } - } - wchar_t* result; - - - if (vWeapons[iFind].sGxtEntryName.length() > 7) - { - printf("CWeaponAdjuster::GetWeaponText() | %s gxt entry name is too long!\n", vWeapons[iFind].sRecordName.c_str()); - result = L"(this item uses too long text entry)"; - } - else - //result = ((wchar_t*(__thiscall*)(int, const char*))0x4937E0)(0x725A38, vWeapons[iFind].sGxtEntryName.c_str()); - result = GetText(0x725A38, vWeapons[iFind].sGxtEntryName.c_str()); - return result; -} - -int CWeaponAdjuster::GetWeaponIcon(int id, int a2) -{ - wchar_t *text; - if (a2) - { - // display weapon text - *(int*)0x7C9B78 = 1; - *(int*)0x7C9C80 = 0; - // fill the buffer - text = GetWeaponText(id); - ((void(__cdecl*)(int, wchar_t*))0x5FC150)(0x7C9B7C, text); - } - int iFind = 0; - for (int i = 0; i < vWeapons.size(); i++) - { - if (vWeapons[i].weaponID == id) - { - iFind = i; - break; - } - } - int weaponIcon = LoadTexture(*(int*)0x7D366C, vWeapons[iFind].sFeIconName.c_str()); - if (!weaponIcon) - { - printf("CWeaponAdjuster::GetWeaponIcon() | Icon for %s does not exist! (%s)\n", vWeapons[iFind].sRecordName.c_str(), vWeapons[iFind].sFeIconName.c_str()); - weaponIcon = LoadTexture(*(int*)0x7D366C, "na"); - } - return weaponIcon; -} - -int __fastcall CWeaponAdjuster::Executions(int * ptr) -{ - int execution; - - if (*(int*)(ptr + 80) && (*(int*)(*(int*)(ptr + 80) + 2228)) != 0 && ((int(__thiscall*)(int*))0x4B2F40)(ptr)) - { - execution = 14; - } - else - { - int weaponID = (*(int*)(*(int*)(ptr + 31) + 356)); - int iFind = 0; - for (int i = 0; i < vWeapons.size(); i++) - { - if (vWeapons[i].weaponID == weaponID) - { - iFind = i; - break; - } - } - - execution = GetExecutionIDFromString(vWeapons[iFind].sExecutionName); - } - - return execution; -} - -int __fastcall CWeaponAdjuster::CheckExecutionWeaponType(int ptr) -{ - int v1; - int v2; - int v3; - - int result = 0; - - v1 = *(int*)(ptr + 340); - - if (v1 == -1) v2 = 0; - else - v2 = (*(int*)(*(int *)(*(int *)(ptr + 336) + 8) + 4 * v1)); - result = 0; - if (v2) - { - - if ((*(int*)(*(int*)(v2 + 124) + 4) & 0x3001) == 12289) - { - - v3 = *(int*)(v2 + 428); - - // added 3 - if firearm check - if ((*(int*)(*(int*)(v3 + 4) + 4)) == 0 || (*(int*)(*(int*)(v3 + 4) + 4)) == 1 || (*(int*)(*(int*)(v3 + 4) + 4)) == 3) - result = 1; - } - - - - } - return result; -} - - -signed int __fastcall CWeaponAdjuster::HookSniperRifle(int ptr) -{ - signed int result; - - int weaponID = (*(int*)(*(int*)(ptr + 124) + 356)); - - int iFind = 0; - for (int i = 0; i < vWeapons.size(); i++) - { - if (vWeapons[i].weaponID == weaponID) - { - iFind = i; - break; - } - } - - if (vWeapons[iFind].weaponFlag & IS_SNIPER_RIFLE) - result = 1; - else - result = 0; - - return result; -} - -int __fastcall CWeaponAdjuster::HookShotgun(int ptr) -{ - int result; - - int weaponID = *(int*)(*(int*)(ptr + 124) + 356); - int iFind = 0; - for (int i = 0; i < vWeapons.size(); i++) - { - if (vWeapons[i].weaponID == weaponID) - { - iFind = i; - break; - } - } - - if (vWeapons[iFind].weaponFlag & IS_SHOTGUN) - result = 1; - else - result = 0; - - return result; -} - -signed int __fastcall CWeaponAdjuster::HookHealthItem(int ptr) -{ - signed int result = 0; - if (*(int*)0x755E50) result = 0; - - - int weaponID = *(int*)(*(int*)(ptr + 124) + 356); - int iFind = 0; - for (int i = 0; i < vWeapons.size(); i++) - { - if (vWeapons[i].weaponID == weaponID) - { - iFind = i; - break; - } - } - - if (vWeapons[iFind].weaponFlag & IS_HEALTH_ITEM) - result = 1; - - return result; -} - -void __declspec(naked) CWeaponAdjuster::HookExplodeHeadF() -{ - _asm { - mov iExplodeWeapon_esp, esp - pushad - } - iExplodeWeapon_id = (*(int*)(iExplodeWeapon_esp + 216)); - - - for (int i = 0; i < vWeapons.size(); i++) - { - if (vWeapons[i].weaponID == iExplodeWeapon_id) - { - iExplodeWeapon_iFind = i; - break; - } - } - - - if (vWeapons[iExplodeWeapon_iFind].weaponFlag & AB_EXPLODE_HEAD_F) - { - if (vWeapons[iExplodeWeapon_iFind].weaponFlag & ST_IGNORE_EXP_DIST) - Memory::VP::Patch(0x49F9C9, ignoreDist); - _asm - { - popad - jmp iExplodeWeapon_true - } - } - _asm { - popad - jmp iExplodeWeapon_false - } -} - -void __declspec(naked) CWeaponAdjuster::HookAutoHeadshot() -{ - _asm { - mov iAutoHeadL_esp, esp - pushad - } - iAutoHeadL_id = (*(int*)(iAutoHeadL_esp + 216)); - - - for (int i = 0; i < vWeapons.size(); i++) - { - if (vWeapons[i].weaponID == iAutoHeadL_id) - { - iAutoHeadL_iFind = i; - break; - } - } - - - if (vWeapons[iAutoHeadL_iFind].weaponFlag & AB_AUTO_HEADSHOT) - { - _asm - { - popad - jmp iAutoHeadL_true - } - } - _asm { - popad - jmp iAutoHeadL_false - } -} diff --git a/source/code/CWeaponAdjuster.h b/source/code/CWeaponAdjuster.h deleted file mode 100644 index 33f0a82..0000000 --- a/source/code/CWeaponAdjuster.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include - -#define IS_SNIPER_RIFLE 1 -#define IS_SHOTGUN 2 -#define IS_HEALTH_ITEM 4 -#define IS_AMMUNITION 8 -#define AB_EXPLODE_HEAD_F 16 -#define AB_AUTO_HEADSHOT 32 -#define ST_IGNORE_EXP_DIST 64 - -struct CCustomWeapon { - std::string sRecordName; - std::string sWeaponCollectableName; - std::string sGxtEntryName; - std::string sFeIconName; - std::string sExecutionName; - int weaponID; - int weaponFlag; - -}; - - -namespace CWeaponAdjuster { - int ReadFile(const char* file); - void GetRecordName(int id, char* dest); - int GetWeaponIDFromString(std::string input); - int GetExecutionIDFromString(std::string input); - int GetWeaponID(int* line); - wchar_t* GetWeaponText(int id); - int GetWeaponIcon(int id, int a2); - int __fastcall Executions(int* ptr); - int __fastcall CheckExecutionWeaponType(int ptr); - signed int __fastcall HookSniperRifle(int ptr); - int __fastcall HookShotgun(int ptr); - signed int __fastcall HookHealthItem(int ptr); - void HookExplodeHeadF(); - void HookAutoHeadshot(); -} \ No newline at end of file diff --git a/source/code/CWeaponSpawner.cpp b/source/code/CWeaponSpawner.cpp deleted file mode 100644 index 35b1a6c..0000000 --- a/source/code/CWeaponSpawner.cpp +++ /dev/null @@ -1,335 +0,0 @@ -#pragma once -#include "ManhuntSDK.h" -#include "CWeaponSpawner.h" -#include "CSettingsManager.h" -using namespace ManhuntFunctions; - - -namespace CWeaponSpawner { - void Knife() { - CEntity* plr = FindPlayer(); - if (GetEntity("Hunt_Knife_(CT)")) - CreateInventoryItem(plr, CT_KNIFE, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void Shard() { - CEntity* plr = FindPlayer(); - if (GetEntity("Shard_(CT)")) - CreateInventoryItem(plr, CT_SHARD, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - - void Bag() { - CEntity* plr = FindPlayer(); - if (GetEntity("Bag_(CT)")) - CreateInventoryItem(plr, CT_BAG, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void Wire() { - CEntity* plr = FindPlayer(); - if (GetEntity("Wire_(CT)")) - CreateInventoryItem(plr, CT_WIRE, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void WireP() { - CEntity* plr = FindPlayer(); - if (GetEntity("Wire_Piggsy_(CT)")) - CreateInventoryItem(plr, CT_PIGSY_WIRE, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - - void Wood() { - CEntity* plr = FindPlayer(); - if (GetEntity("Wooden_Spike_(CT)")) - CreateInventoryItem(plr, CT_WOODEN_SPIKE, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void ShardP() { - CEntity* plr = FindPlayer(); - if (GetEntity("Shard_Piggsy_(CT)")) - CreateInventoryItem(plr, CT_PIGSY_SHARD, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - - - void Cleaver() { - CEntity* plr = FindPlayer(); - if (GetEntity("Cleaver_(CT)")) - CreateInventoryItem(plr, CT_CLEAVER, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void Crowbar() { - CEntity* plr = FindPlayer(); - if (GetEntity("Crowbar_(CT)")) - CreateInventoryItem(plr, CT_CROWBAR, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void Machete() { - CEntity* plr = FindPlayer(); - if (GetEntity("Machete_(CT)")) - CreateInventoryItem(plr, CT_MACHETE, true); - else SetHelpMessage(L"Item does not exist here!"); - } - void Glock() { - CEntity* plr = FindPlayer(); - if (GetEntity("Glock_(CT)")) - { - CreateInventoryItem(plr, CT_GLOCK, true); - GiveAmmo(150, CT_GLOCK); - } - - - else SetHelpMessage(L"Item does not exist here!"); - } - - void Deagle() { - CEntity* plr = FindPlayer(); - if (GetEntity("Desert_Eagle_(CT)")) - { - CreateInventoryItem(plr, CT_DESERT_EAGLE, true); - GiveAmmo(150, CT_DESERT_EAGLE); - } - - - else SetHelpMessage(L"Item does not exist here!"); - } - - void Uzi() { - CEntity* plr = FindPlayer(); - if (GetEntity("Uzi_(CT)")) - { - CreateInventoryItem(plr, CT_UZI, true); - GiveAmmo(150, CT_UZI); - } - - - else SetHelpMessage(L"Item does not exist here!"); - } - - - void SawnOff() { - CEntity* plr = FindPlayer(); - if (GetEntity("SawnOff_Shotgun_(CT)")) - { - CreateInventoryItem(plr, CT_SAWNOFF, true); - GiveAmmo(150, CT_SAWNOFF); - } - - - else SetHelpMessage(L"Item does not exist here!"); - } - - - void Colt() { - CEntity* plr = FindPlayer(); - if (GetEntity("C_Commando_(CT)")) - { - CreateInventoryItem(plr, CT_COLT_COMMANDO, true); - GiveAmmo(150, CT_COLT_COMMANDO); - - } - - - else SetHelpMessage(L"Item does not exist here!"); - } - - void Sniper() { - CEntity* plr = FindPlayer(); - if (GetEntity("Sniper_Rifle_(CT)")) - { - CreateInventoryItem(plr, CT_SNIPER_RIFLE, true); - GiveAmmo(150, CT_SNIPER_RIFLE); - } - - - else SetHelpMessage(L"Item does not exist here!"); - } - void Tranq() { - CEntity* plr = FindPlayer(); - if (GetEntity("Tranq_Rifle_(CT)")) - { - CreateInventoryItem(plr, CT_TRANQ_RIFLE, true); - GiveAmmo(150, CT_TRANQ_RIFLE); - } - - - else SetHelpMessage(L"Item does not exist here!"); - } - - - void Revolver() { - CEntity* plr = FindPlayer(); - if (GetEntity("6Shooter_(CT)")) - { - CreateInventoryItem(plr, CT_6SHOOTER, true); - GiveAmmo(150, CT_6SHOOTER); - } - - else SetHelpMessage(L"Item does not exist here!"); - } - - void Shotgun() { - CEntity* plr = FindPlayer(); - if (GetEntity("Shotgun_(CT)")) - { - CreateInventoryItem(plr, CT_SHOTGUN, true); - GiveAmmo(150, CT_SHOTGUN); - - } - - else SetHelpMessage(L"Item does not exist here!"); - } - - void ShotgunT() { - CEntity* plr = FindPlayer(); - if (GetEntity("Shotgun_Torch_(CT)")) - { - CreateInventoryItem(plr, CT_SHOTGUN_TORCH, true); - GiveAmmo(150, CT_SHOTGUN_TORCH); - } - - else SetHelpMessage(L"Item does not exist here!"); - } - - void NailGun() { - CEntity* plr = FindPlayer(); - if (GetEntity("Nail_Gun_(CT)")) - { - CreateInventoryItem(plr, 89, true); - GiveAmmo(150, CT_NAILGUN); - } - - else SetHelpMessage(L"Item does not exist here!"); - } - - void SpikedBat() { - CEntity* plr = FindPlayer(); - if (GetEntity("W_B_Bat_Nails_(CT)")) - CreateInventoryItem(plr, CT_BASEBALL_BAT_BLADES, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void WBat() { - CEntity* plr = FindPlayer(); - if (GetEntity("W_B_Bat_(CT)")) - CreateInventoryItem(plr, CT_W_BASEBALL_BAT, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void Bat() { - CEntity* plr = FindPlayer(); - if (GetEntity("M_B_Bat_(CT)")) - CreateInventoryItem(plr, CT_BASEBALL_BAT, true); - else SetHelpMessage(L"Item does not exist here!"); - } - void SmallBat() { - CEntity* plr = FindPlayer(); - if (GetEntity("Small_Bat_(CT)")) - CreateInventoryItem(plr, CT_SMALL_BAT, true); - else SetHelpMessage(L"Item does not exist here!"); - } - void Sickle() { - CEntity* plr = FindPlayer(); - if (GetEntity("Sickle_(CT)")) - CreateInventoryItem(plr, CT_SICKLE, true); - else SetHelpMessage(L"Item does not exist here!"); - } - void NightStick() { - CEntity* plr = FindPlayer(); - if (GetEntity("NightStick_(CT)")) - CreateInventoryItem(plr, CT_NIGHTSTICK, true); - else SetHelpMessage(L"Item does not exist here!"); - } - void Axe() { - CEntity* plr = FindPlayer(); - if (GetEntity("Axe_(CT)")) - CreateInventoryItem(plr, CT_AXE, true); - else SetHelpMessage(L"Item does not exist here!"); - } - void IcePick() { - CEntity* plr = FindPlayer(); - if (GetEntity("IcePick_(CT)")) - CreateInventoryItem(plr, CT_ICEPICK, true); - else SetHelpMessage(L"Item does not exist here!"); - } - void Hammer() { - CEntity* plr = FindPlayer(); - if (GetEntity("Hammer_(CT)")) - CreateInventoryItem(plr, 97, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void Chainsaw() { - CEntity* plr = FindPlayer(); - if (GetEntity("Chainsaw_Player_(CT)")) - CreateInventoryItem(plr, 108, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void Brick() { - CEntity* plr = FindPlayer(); - if (GetEntity("Half_Brick_(CT)")) - CreateInventoryItem(plr, CT_BRICK_HALF, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void Bottle() { - CEntity* plr = FindPlayer(); - if (GetEntity("Bottle_(CT)")) - CreateInventoryItem(plr, CT_BOTTLE, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void Can() { - CEntity* plr = FindPlayer(); - if (GetEntity("Can_(CT)")) - CreateInventoryItem(plr, CT_CAN, true); - else SetHelpMessage(L"Item does not exist here!"); - } - - void Custom1() - { - CEntity* plr = FindPlayer(); - if (GetEntity(SettingsMgr->szCustomWeapon[0])) - { - CreateInventoryItem(plr, SettingsMgr->iCustomWeapon[0], true); - GiveAmmo(150, SettingsMgr->iCustomWeapon[0]); - } - - else SetHelpMessage(L"Item does not exist here!"); - } - - void Custom2() - { - CEntity* plr = FindPlayer(); - if (GetEntity(SettingsMgr->szCustomWeapon[1])) - { - CreateInventoryItem(plr, SettingsMgr->iCustomWeapon[1], true); - GiveAmmo(150, SettingsMgr->iCustomWeapon[1]); - } - - else SetHelpMessage(L"Item does not exist here!"); - } - - void Custom3() - { - CEntity* plr = FindPlayer(); - if (GetEntity(SettingsMgr->szCustomWeapon[2])) - { - CreateInventoryItem(plr, SettingsMgr->iCustomWeapon[2], true); - GiveAmmo(150, SettingsMgr->iCustomWeapon[2]); - } - - else SetHelpMessage(L"Item does not exist here!"); - } - -} diff --git a/source/code/CWeaponSpawner.h b/source/code/CWeaponSpawner.h deleted file mode 100644 index f69ed25..0000000 --- a/source/code/CWeaponSpawner.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - - -namespace CWeaponSpawner { - void Knife(); - void Shard(); - void Bag(); - void Wire(); - void WireP(); - void Wood(); - void ShardP(); - void Cleaver(); - void Machete(); - void Glock(); - void Deagle(); - void Uzi(); - void SawnOff(); - void Colt(); - void Sniper(); - void Tranq(); - void Revolver(); - void Shotgun(); - void ShotgunT(); - void NailGun(); - void SpikedBat(); - void WBat(); - void Bat(); - void SmallBat(); - void Sickle(); - void Crowbar(); - void NightStick(); - void Axe(); - void IcePick(); - void Hammer(); - void Chainsaw(); - void Brick(); - void Bottle(); - void Can(); - void Custom1(); - void Custom2(); - void Custom3(); -} \ No newline at end of file diff --git a/source/code/ManhuntRW.cpp b/source/code/ManhuntRW.cpp deleted file mode 100644 index 803eddb..0000000 --- a/source/code/ManhuntRW.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "ManhuntRW.h" - -void RwRenderStateSet(RwRenderState state, int value) -{ - - (*(void(__cdecl **)(RwRenderState, int))((*(int*)0x82279C + 32)))(state, value); -} - -void RwRenderStateSetA(RwRenderState state, int value) -{ - (*(void(__cdecl **)(RwRenderState, int))((*(int*)0x82279C + 36)))(state, value); -} diff --git a/source/code/ManhuntSDK.cpp b/source/code/ManhuntSDK.cpp deleted file mode 100644 index dd42193..0000000 --- a/source/code/ManhuntSDK.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "ManhuntSDK.h" - -void ManhuntFunctions::FlashScreen(int red, int green, int blue) -{ - Call<0x5EF890, int, int, int>(red, green, blue); -} - -CEntity * ManhuntFunctions::FindPlayer() -{ - return *(CEntity**)0x715B9C; -} - -void ManhuntFunctions::SetHelpMessage(wchar_t * msg) -{ - Call<0x489F40, wchar_t*>(msg); -} - -void ManhuntFunctions::CreateInventoryItem(CEntity * ent, int item, bool b1) -{ - CallMethod<0x49A5C0, CEntity*, int, bool>(ent, item, b1); -} - -void ManhuntFunctions::AddAmmoToInventoryWeapon(CEntity * ent, int amount, int item) -{ - int weapon_ptr = *(int*)(ent + 336); - int v1 = ((int(__thiscall*)(int, int))0x4929E0)(weapon_ptr, item); - - ((void(__thiscall*)(int, int))0x4F8B40)(*(int*)(v1 + 428), amount); -} - - -CVector* ManhuntFunctions::GetEntityPosition(CEntity * ent) -{ - return CallMethodAndReturn(ent); -} - -void ManhuntFunctions::SetHealth(CEntity * ent, float health) -{ -} - -void ManhuntFunctions::UnlockBonusLevels() -{ - Call<0x5E4D00>(); -} - -void ManhuntFunctions::UnlockBonusFeatures() -{ - Call<0x5E4D10>(); -} - -void ManhuntFunctions::HUDToggleFlashFlags(int elem, bool state) -{ - Call<0x5EA490, int, bool>(elem, state); -} - -int ManhuntFunctions::GetLevelStars(int level) -{ - return CallAndReturn(level); -} - -void ManhuntFunctions::CompleteLevel() -{ - Call<0x5D1F00>(); -} - -int ManhuntFunctions::LoadTexture(int txd, const char * name) -{ - return CallAndReturn(txd,name); -} - -wchar_t * ManhuntFunctions::GetText(int buffer, const char * entry) -{ - return CallMethodAndReturn(buffer,entry); -} - -wchar_t * ManhuntFunctions::FastGetText(const char * entry) -{ - return CallMethodAndReturn(0x725A38, entry); -} - -void ManhuntFunctions::GiveAmmo(int amount, int item) -{ - int v0 = *(int*)(*(int*)0x715B9C + 336); - int v1 = ((int(__thiscall*)(int, int))0x4929E0)(v0, item); - - ((void(__thiscall*)(int, int))0x4F8B40)(*(int*)(v1 + 428), amount); -} - -CEntity * ManhuntFunctions::GetEntity(const char * name) -{ - return CallAndReturn(name); -} - -void ManhuntFunctions::AddMenuEntry(wchar_t * name, float posX, float posY, float textScaleX, float textScaleY, int buttonID) -{ - - Call<0x5D55C0, wchar_t*, float, float, float, int>(name, posX, posY, textScaleX, textScaleY, buttonID); - Call<0x5D5B30, wchar_t*, float, float, float, float>(name, posX, posY, textScaleX, textScaleY); -} - -void ManhuntFunctions::DrawTexture(float posx, float posy, float scaleX, float scaleY, int r, int g, int b, int a, int pTexture) -{ - Call<0x5F96F0, float, float, float, float, int, int, int, int, int>(posx, posy, scaleX, scaleY, r, g, b, a, pTexture); -} - -void ManhuntFunctions::SetDrawRGBA(int r, int g, int b, int a) -{ - int col = b | (g << 8) | (a << 24) | (r << 16); - *(int*)(0x7D35C0 + 16) = col; -} - -void ManhuntFunctions::PrintText(const char * text, float x, float y, float sizex, float sizey, float unk, EFontType font) -{ - Call<0x5E55E0, const char*, float, float, float, float, float, EFontType>(text, x, y, sizex, sizey, unk, font); -} - -void ManhuntDebugMenu::EditVariableInt(const char * name, int * variable) -{ - Call<0x5E9840, const char*, int*>(name, variable); -} - -void ManhuntDebugMenu::EnableItemIfTrue(int * variable) -{ - Call<0x5E9960, int*>(variable); -} - -int ManhuntDebugMenu::CallFunction(const char * name, void * function) -{ - return CallAndReturn(name, function); -} - -int MLSOperators::GetParam(int mls) -{ - return CallMethodAndReturn(mls); -} - -int MLSOperators::GetStringParam(int mls) -{ - return CallMethodAndReturn(mls); -} - -CFile * ManhuntFileFunctions::Rockstar_fopen(int mode, int fMode, char* extraParam) -{ - return CallAndReturn(mode, fMode, extraParam); -} - -int ManhuntFileFunctions::ReadFileBytes(CFile * src, int dst, int size) -{ - return CallAndReturn(src, dst, size); -} diff --git a/source/code/ManhuntSDK.h b/source/code/ManhuntSDK.h deleted file mode 100644 index 34b6d3a..0000000 --- a/source/code/ManhuntSDK.h +++ /dev/null @@ -1,409 +0,0 @@ -#pragma once -// calling -template -static void Call(Args... args) { - reinterpret_cast(address)(args...); -} - -template -static Ret CallAndReturn(Args... args) { - return reinterpret_cast(address)(args...); -} - -template -static void CallMethod(C _this, Args... args) { - reinterpret_cast(address)(_this, args...); -} - -template -static Ret CallMethodAndReturn(C _this, Args... args) { - return reinterpret_cast(address)(_this, args...); -} - - - -// enums - -enum eLevels { - jury_turf, // Born Again - derelict, // Doorway Into Hell - der2, // Road To Ruin - scrap, // White Trash - scrap2, // Fuelled By Hate - zoo, // Grounds For Assault - zoo2, // Strapped for Cash - mall, // View of Innocence - church2, // Drunk Driving - pharm_wks, // Graveyard Shift - asylum, // Mouth of Madness - cellblock, // Doing Time - prison, // Kill The Rabbit - ramirez, // Divided They Fall - journo_streets, // Press Coverage - subway, // Wrong Side of the Tracks - trainyard, // Trained To Kill - estate_ext, // Border Patrol - mansion_int, // Key Personnel - attic, // Deliverance - bonus1, // Hard as Nails - bonus2, // Monkey See, Monkey Die - bonus3, // Brawl Game - weasel, // Time 2 Die -}; - - -enum eWeaponSlots { - BACK, - BELT_RIGHT, - BELT_LEFT, -}; - -enum eItemTypes { - CT_TRIPWIRE = 1, - CT_GASOLINE, - CT_WATER, - CT_LIGHTER, - CT_CASH, - CT_TORCH, - CT_N_VISION, - CT_PAINKILLERS, - CT_G_FIRST_AID, - CT_Y_FIRST_AID, - CT_SPEED_BOOST, - CT_STRENGTH_BOOST, - CT_SHOOTING_BOOST, - CT_REFLEXES_BOOST, - CT_HEALTH_BOOST, - CT_FISTS, - CT_K_DUST, - CT_KNIFE, - CT_SHARD, - CT_BROKEN_BOTTLE, - CT_JURYBLADES, - CT_BOTTLE, - CT_PIPE, - CT_CLEAVER, - CT_WOODEN_BAR, - CT_CROWBAR, - CT_SICKLE, - CT_NIGHTSTICK, - CT_CANE, - CT_AXE, - CT_ICEPICK, - CT_MACHETE, - CT_SMALL_BAT, - CT_BASEBALL_BAT, - CT_W_BASEBALL_BAT, - CT_FIRE_AXE, - CT_HOCKEY_STICK, - CT_BASEBALL_BAT_BLADES, - CT_6SHOOTER, - CT_GLOCK, - CT_GLOCK_SILENCED, - CT_GLOCK_TORCH, - CT_UZI, - CT_SHOTGUN, - CT_SHOTGUN_TORCH, - CT_DESERT_EAGLE, - CT_COLT_COMMANDO, - CT_SNIPER_RIFLE, - CT_TRANQ_RIFLE, - CT_SAWNOFF, - CT_GRENADE, - CT_MOLOTOV, - CT_EXPMOLOTOV, - CT_TEAR_GAS, - CT_F_GRENADE, - CT_BRICK_HALF, - CT_FIREWORK, - CT_BAG, - CT_RAG, - CT_CHLORINE, - CT_METHS, - CT_HCC, - CT_D_BEER_GUY, - CT_D_MERC_LEADER, - CT_D_SMILEY, - CT_D_HUNTLORD, - CT_E_L_SIGHT, - CT_S_SILENCER, - CT_RADIO, - CT_BAR_KEY, - CT_SYARD_COMB, - CT_CAMERA, - CT_BODY_P1, - CT_BODY_P2, - CT_PREC_KEY, - CT_PREC_CARD, - CT_PREC_DOCS, - CT_PHARM_HAND, - CT_EST_G_KEY, - CT_EST_A_KEY, - CT_DOLL, - CT_ANTIDOTE, - CT_KEY, - CT_SWIPE_CARD, // did not have ct_ entry - dummy = 87, - CT_CHAINSAW, - CT_NAILGUN, - CT_WIRE, - CT_CAN, - CT_WOODEN_SPIKE, - dummy2, - CT_PIGSY_SHARD, - CT_PIGSY_WIRE, - CT_PIGSY_SPIKE, - CT_HAMMER, - CT_DOLL_1, - CT_DOLL_2, - CT_DOLL_3, - CT_HEAD, - CT_AMMO_NAILS, - CT_AMMO_SHOTGUN, - CT_AMMO_PISTOL, - CT_AMMO_MGUN, - CT_AMMO_TRANQ, - CT_AMMO_SNIPER, - CT_CHAINSAW_PLAYER, - CT_DVTAPE, - CT_HANDYCAM - -}; - - -enum eWeatherTypes { - CLOUDY, - WINDY, - RAINY, - THUNDER, - FOGGY, - CLEAR, - FREE = -1 -}; - - - -enum eMenuTypes { - MENU_EMPTY, - MENU_CHANGE_LANGUAGE, - MENU_EMPTY_2, - MENU_DIFFICULTY_SELECT, - MENU_START_LOAD_GAME, - MENU_LOAD_GAME, - MENU_SAVE_GAME, - MENU_FRONTEND, - MENU_PAUSE, - MENU_LEVEL_SELECT, - MENU_SETTINGS, - MENU_AUDIO_SETTINGS, - MENU_HEADSET_SETTINGS, // most likely - MENU_VIDEO_SETTINGS, - MENU_BONUS_FEATURES, - MENU_BONUS_PREVIEW, - MENU_GAME_COMPLETED, - MENU_GAMMA_SETTINGS, - MENU_CONTROL_SETTINGS, - MENU_RESTORE_DEFAULTS, - MENU_19, - MENU_CREDITS, - // pc exclusive - MENU_REMAP_CONTROLS, - MENU_QUIT, - MENU_MODS -}; - -enum eCheats { - CHEAT_RUNNER = 1, - CHEAT_SILENCE = 2, - CHEAT_REGENERATION = 4, - CHEAT_EXPLODE = 8, - CHEAT_EQUIPPED = 16, - CHEAT_SUPERPUNCH = 32, - CHEAT_RABBIT = 64, - CHEAT_MONKEY = 128, - CHEAT_INVIS = 256, - CHEAT_PIGGSY = 512, - CHEAT_GODMODE = 1024 -}; - - -enum eExecutions { - EXEC_BAG, - EXEC_KNIFE, - EXEC_CROWBAR, - EXEC_BAT, - EXEC_SICKLE, - EXEC_WIRE, - EXEC_CLEAVER, - EXEC_AXE, - EXEC_NIGHTSTICK, - EXEC_HAMMER, - EXEC_CHAINSAW, - EXEC_PIGSHARD, - EXEC_PIGWIRE, - EXEC_PIGSPIK, - EXEC_RAMIREZ, - EXEC_DEFAULT -}; - -enum eShotClass { - SC_BASIC, - SC_INSTANT, - SC_INSTANT_MACHINEGUN, - SC_MELEE, - SC_MELEE_KICK, - SC_MELEE_OBSTRUCT, - SC_PROJECTICLE, - SC_PROJECTILE_WEAPON, - SC_AREA -}; - -enum eShotPrimitive { - SP_LINE, - SP_SHERE -}; - -enum eWeaponMeleeClass { - FISTS, - BEATER1, - BEATER2, - BLADE1, - BLADE2 -}; - - - -// structs - -struct CVector { - float x, y, z; -}; - - -struct CFile { - int m_nLastMode; - int m_nLastFileMode; - int field8; - int field12; // unused? in most cases set to 0 - int m_nBufferSize; - int m_pFilePointer; - int field24; - int field28; - int field32; // always 1? -}; - -struct CConsole { - int field0; - int field4; - int m_nCharacterCounter; - int m_nAvailableLines; - int m_nMaxChars; - int m_nTotalLines; - int field24; - int field28; - int field32; - int m_pCharacterData; // buffer - int field40; - int field44; - int field48; - int field52; - int m_pConsoleFunctionList; - int field60; - int field64; - // buffer is automatically generated, i've just put this here - // to make it nicer - //char Buffer[m_nTotalLines - 1][m_nMaxChars]; -}; - - -struct CEntity { - int field_0; - int field_4; - int field_8; - int field_C; - int field_10; - float fHealth; - int field_18; - CVector pos; - float field_28; - int field_2C; - int field_30; - double field_34; - int field_3C; - int field_40; - int field_44; - int field_48; - int field_4C; - int field_50; - int field_54; - int field_58; - int field_5C; - int field_60; - int field_64; - int field_68; - int field_6C; - int* model; - -}; - -enum EFontType { - FONT_TYPE_DEBUG, - FONT_TYPE_DEFAULT, - FONT_FRONTEND, - FONT_TYPE_LOADING -}; - - -// functions - -namespace ManhuntFunctions { - void FlashScreen(int red, int green, int blue); - CEntity* FindPlayer(); - void SetHelpMessage(wchar_t* msg); - void CreateInventoryItem(CEntity* ent, int item, bool b1); - void AddAmmoToInventoryWeapon(CEntity* ent, int amount, int item); - CVector* GetEntityPosition(CEntity* ent); - void SetHealth(CEntity* ent, float health); - void UnlockBonusLevels(); - void UnlockBonusFeatures(); - void HUDToggleFlashFlags(int elem, bool state); - int GetLevelStars(int level); - void CompleteLevel(); - int LoadTexture(int txd, const char* name); - wchar_t* GetText(int gxt, const char* entry); - wchar_t* FastGetText(const char* entry); - void GiveAmmo(int amount, int item); - CEntity* GetEntity(const char* name); - void AddMenuEntry(wchar_t* name, float posX, float posY, float textScaleX, float textScaleY, int buttonID); - void DrawTexture(float posx, float posy, float scaleX, float scaleY, int r, int g, int b, int a, int pTexture); - void SetDrawRGBA(int r, int g, int b, int a); - void PrintText(const char* text, float x, float y, float sizex, float sizey, float unk, EFontType font); - - - template - void WriteDebug(int line, const char * msg, Args ...args) - { - Call<0x5E5480, int, const char*, Args...>(line, msg, args...); - } -}; - - -namespace ManhuntDebugMenu { - void EditVariableInt(const char* name, int* variable); - void EnableItemIfTrue(int* variable); - int CallFunction(const char* name, void* function); -}; - -namespace ManhuntFileFunctions -{ - CFile* Rockstar_fopen(int mode, int fMode, char* extraParam); - int ReadFileBytes(CFile* src, int dst, int size); -} - - -namespace MLSOperators { - int GetParam(int mls); - int GetStringParam(int mls); -}; - - diff --git a/source/code/MemoryMgr.h b/source/code/MemoryMgr.h deleted file mode 100644 index 1758c0d..0000000 --- a/source/code/MemoryMgr.h +++ /dev/null @@ -1,443 +0,0 @@ -#ifndef __MEMORYMGR -#define __MEMORYMGR - -// Switches: -// _MEMORY_NO_CRT - don't include anything "complex" like ScopedUnprotect or memset -// _MEMORY_DECLS_ONLY - don't include anything but macroes - -#define WRAPPER __declspec(naked) -#define DEPRECATED __declspec(deprecated) -#define EAXJMP(a) { _asm mov eax, a _asm jmp eax } -#define VARJMP(a) { _asm jmp a } -#define WRAPARG(a) ((int)a) - -#define NOVMT __declspec(novtable) -#define SETVMT(a) *((uintptr_t*)this) = (uintptr_t)a - -#ifndef _MEMORY_DECLS_ONLY - -#define WIN32_LEAN_AND_MEAN -#include - -#include -#include - -#ifndef _MEMORY_NO_CRT -#include -#include -#endif - -enum -{ - PATCH_CALL, - PATCH_JUMP -}; - -template -inline AT DynBaseAddress(AT address) -{ - return (ptrdiff_t)GetModuleHandle(nullptr) - 0x400000 + address; -} - -namespace Memory -{ - template - inline void Patch(AT address, T value) - {*(T*)address = value; } - -#ifndef _MEMORY_NO_CRT - template - inline void Patch(AT address, std::initializer_list list ) - { - uint8_t* const addr = (uint8_t*)address; - std::copy( list.begin(), list.end(), stdext::make_checked_array_iterator(addr, list.size()) ); - } -#endif - - template - inline void Nop(AT address, size_t count) -#ifndef _MEMORY_NO_CRT - { memset((void*)address, 0x90, count); } -#else - { do { - *(uint8_t*)address++ = 0x90; - } while ( --count != 0 ); } -#endif - - template - inline void WriteOffsetValue(AT address, Var var) - { - union member_cast - { - intptr_t addr; - Var varPtr; - } cast; - static_assert( sizeof(cast.addr) == sizeof(cast.varPtr), "member_cast failure!" ); - cast.varPtr = var; - - intptr_t dstAddr = (intptr_t)address; - *(int32_t*)dstAddr = static_cast(cast.addr - dstAddr - 4); - } - - template - inline void ReadOffsetValue(AT address, Var& var) - { - union member_cast - { - intptr_t addr; - Var varPtr; - } cast; - static_assert( sizeof(cast.addr) == sizeof(cast.varPtr), "member_cast failure!" ); - - intptr_t srcAddr = (intptr_t)address; - cast.addr = srcAddr + 4 + *(int32_t*)srcAddr; - var = cast.varPtr; - } - - template - inline void InjectHook(AT address, Func hook) - { - WriteOffsetValue( (intptr_t)address + 1, hook ); - } - - template - inline void InjectHook(AT address, Func hook, unsigned int nType) - { - *(uint8_t*)address = nType == PATCH_JUMP ? 0xE9 : 0xE8; - InjectHook(address, hook); - } - - template - inline void ReadCall(AT address, Func& func) - { - ReadOffsetValue( (intptr_t)address+1, func ); - } - - template - inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0) - { - uintptr_t addr; - ReadCall( address, addr ); - return reinterpret_cast( addr + offset ); - } - -#ifndef _MEMORY_NO_CRT - inline bool MemEquals(uintptr_t address, std::initializer_list val) - { - const uint8_t* mem = reinterpret_cast(address); - return std::equal( val.begin(), val.end(), stdext::make_checked_array_iterator(mem, val.size()) ); - } -#endif - - template - inline AT Verify(AT address, uintptr_t expected) - { - assert( uintptr_t(address) == expected ); - return address; - } - - namespace DynBase - { - template - inline void Patch(AT address, T value) - { - Memory::Patch(DynBaseAddress(address), value); - } - -#ifndef _MEMORY_NO_CRT - template - inline void Patch(AT address, std::initializer_list list ) - { - Memory::Patch(DynBaseAddress(address), std::move(list)); - } -#endif - - template - inline void Nop(AT address, size_t count) - { - Memory::Nop(DynBaseAddress(address), count); - } - - template - inline void InjectHook(AT address, HT hook) - { - Memory::InjectHook(DynBaseAddress(address), hook); - } - - template - inline void InjectHook(AT address, HT hook, unsigned int nType) - { - Memory::InjectHook(DynBaseAddress(address), hook, nType); - } - - template - inline void ReadCall(AT address, Func& func) - { - Memory::ReadCall(DynBaseAddress(address), func); - } - - template - inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0) - { - return Memory::ReadCallFrom(DynBaseAddress(address), offset); - } - -#ifndef _MEMORY_NO_CRT - inline bool MemEquals(uintptr_t address, std::initializer_list val) - { - return Memory::MemEquals(DynBaseAddress(address), std::move(val)); - } - - template - inline AT Verify(AT address, uintptr_t expected) - { - return Memory::Verify(address, DynBaseAddress(expected)); - } -#endif - }; - - namespace VP - { - template - inline void Patch(AT address, T value) - { - DWORD dwProtect[2]; - VirtualProtect((void*)address, sizeof(T), PAGE_EXECUTE_READWRITE, &dwProtect[0]); - Memory::Patch( address, value ); - VirtualProtect((void*)address, sizeof(T), dwProtect[0], &dwProtect[1]); - } - -#ifndef _MEMORY_NO_CRT - template - inline void Patch(AT address, std::initializer_list list ) - { - DWORD dwProtect[2]; - VirtualProtect((void*)address, list.size(), PAGE_EXECUTE_READWRITE, &dwProtect[0]); - Memory::Patch(address, std::move(list)); - VirtualProtect((void*)address, list.size(), dwProtect[0], &dwProtect[1]); - } -#endif - - template - inline void Nop(AT address, size_t count) - { - DWORD dwProtect[2]; - VirtualProtect((void*)address, count, PAGE_EXECUTE_READWRITE, &dwProtect[0]); - Memory::Nop( address, count ); - VirtualProtect((void*)address, count, dwProtect[0], &dwProtect[1]); - } - - template - inline void InjectHook(AT address, HT hook) - { - DWORD dwProtect[2]; - - VirtualProtect((void*)((DWORD_PTR)address + 1), 4, PAGE_EXECUTE_READWRITE, &dwProtect[0]); - Memory::InjectHook( address, hook ); - VirtualProtect((void*)((DWORD_PTR)address + 1), 4, dwProtect[0], &dwProtect[1]); - } - - template - inline void InjectHook(AT address, HT hook, unsigned int nType) - { - DWORD dwProtect[2]; - - VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &dwProtect[0]); - Memory::InjectHook( address, hook, nType ); - VirtualProtect((void*)address, 5, dwProtect[0], &dwProtect[1]); - } - - template - inline void ReadCall(AT address, Func& func) - { - Memory::ReadCall(address, func); - } - - template - inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0) - { - return Memory::ReadCallFrom(address, offset); - } - -#ifndef _MEMORY_NO_CRT - inline bool MemEquals(uintptr_t address, std::initializer_list val) - { - return Memory::MemEquals(address, std::move(val)); - } -#endif - - template - inline AT Verify(AT address, uintptr_t expected) - { - return Memory::Verify(address, expected); - } - - namespace DynBase - { - template - inline void Patch(AT address, T value) - { - VP::Patch(DynBaseAddress(address), value); - } - -#ifndef _MEMORY_NO_CRT - template - inline void Patch(AT address, std::initializer_list list ) - { - VP::Patch(DynBaseAddress(address), std::move(list)); - } -#endif - - template - inline void Nop(AT address, size_t count) - { - VP::Nop(DynBaseAddress(address), count); - } - - template - inline void InjectHook(AT address, HT hook) - { - VP::InjectHook(DynBaseAddress(address), hook); - } - - template - inline void InjectHook(AT address, HT hook, unsigned int nType) - { - VP::InjectHook(DynBaseAddress(address), hook, nType); - } - - template - inline void ReadCall(AT address, Func& func) - { - Memory::ReadCall(DynBaseAddress(address), func); - } - - template - inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0) - { - Memory::ReadCallFrom(DynBaseAddress(address), offset); - } - -#ifndef _MEMORY_NO_CRT - inline bool MemEquals(uintptr_t address, std::initializer_list val) - { - return Memory::MemEquals(DynBaseAddress(address), std::move(val)); - } -#endif - - template - inline AT Verify(AT address, uintptr_t expected) - { - return Memory::Verify(address, DynBaseAddress(expected)); - } - - }; - }; -}; - -#ifndef _MEMORY_NO_CRT - -#include -#include -#include - -namespace ScopedUnprotect -{ - class Unprotect - { - public: - ~Unprotect() - { - for ( auto& it : m_queriedProtects ) - { - DWORD dwOldProtect; - VirtualProtect( std::get<0>(it), std::get<1>(it), std::get<2>(it), &dwOldProtect ); - } - } - - protected: - Unprotect() = default; - - void UnprotectRange( DWORD_PTR BaseAddress, SIZE_T Size ) - { - SIZE_T QueriedSize = 0; - while ( QueriedSize < Size ) - { - MEMORY_BASIC_INFORMATION MemoryInf; - DWORD dwOldProtect; - - VirtualQuery( (LPCVOID)(BaseAddress + QueriedSize), &MemoryInf, sizeof(MemoryInf) ); - if ( MemoryInf.State == MEM_COMMIT && (MemoryInf.Type & MEM_IMAGE) != 0 && - (MemoryInf.Protect & (PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY|PAGE_READWRITE|PAGE_WRITECOPY)) == 0 ) - { - const bool wasExecutable = (MemoryInf.Protect & (PAGE_EXECUTE|PAGE_EXECUTE_READ)) != 0; - VirtualProtect( MemoryInf.BaseAddress, MemoryInf.RegionSize, wasExecutable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, &dwOldProtect ); - m_queriedProtects.emplace_front( MemoryInf.BaseAddress, MemoryInf.RegionSize, MemoryInf.Protect ); - } - QueriedSize += MemoryInf.RegionSize; - } - } - - private: - std::forward_list< std::tuple< LPVOID, SIZE_T, DWORD > > m_queriedProtects; - }; - - class Section : public Unprotect - { - public: - Section( HINSTANCE hInstance, const char* name ) - { - PIMAGE_NT_HEADERS ntHeader = (PIMAGE_NT_HEADERS)((DWORD_PTR)hInstance + ((PIMAGE_DOS_HEADER)hInstance)->e_lfanew); - PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(ntHeader); - - DWORD_PTR VirtualAddress = DWORD_PTR(-1); - SIZE_T VirtualSize = SIZE_T(-1); - for ( SIZE_T i = 0, j = ntHeader->FileHeader.NumberOfSections; i < j; ++i, ++pSection ) - { - if ( strncmp( (const char*)pSection->Name, name, IMAGE_SIZEOF_SHORT_NAME ) == 0 ) - { - VirtualAddress = (DWORD_PTR)hInstance + pSection->VirtualAddress; - VirtualSize = pSection->Misc.VirtualSize; - m_locatedSection = true; - break; - } - } - - if ( VirtualAddress == DWORD_PTR(-1) ) - return; - - UnprotectRange( VirtualAddress, VirtualSize ); - }; - - bool SectionLocated() const { return m_locatedSection; } - - private: - bool m_locatedSection = false; - }; - - class FullModule : public Unprotect - { - public: - FullModule( HINSTANCE hInstance ) - { - PIMAGE_NT_HEADERS ntHeader = (PIMAGE_NT_HEADERS)((DWORD_PTR)hInstance + ((PIMAGE_DOS_HEADER)hInstance)->e_lfanew); - UnprotectRange( (DWORD_PTR)hInstance, ntHeader->OptionalHeader.SizeOfImage ); - } - }; - - inline std::unique_ptr UnprotectSectionOrFullModule( HINSTANCE hInstance, const char* name ) - { - std::unique_ptr
section = std::make_unique
( hInstance, name ); - if ( !section->SectionLocated() ) - { - return std::make_unique( hInstance ); - } - return section; - } -}; - -#endif - -#endif - -#endif \ No newline at end of file diff --git a/source/code/core/FileFunctions.cpp b/source/code/core/FileFunctions.cpp new file mode 100644 index 0000000..51e2639 --- /dev/null +++ b/source/code/core/FileFunctions.cpp @@ -0,0 +1,171 @@ +#include "FileFunctions.h" +#include +#include +#include +#include + +std::streampos getSizeToEnd(std::ifstream& is) +{ + auto currentPosition = is.tellg(); + is.seekg(0, is.end); + auto length = is.tellg() - currentPosition; + is.seekg(currentPosition, is.beg); + return length; +} + +bool checkSlash(std::string& str, bool first) +{ + int fnd = str.find_last_of("/\\"); + if (first == true) + fnd = str.find_first_of("/\\"); + + if (fnd == std::string::npos) + return false; + else + return true; +} + +bool wcheckSlash(std::wstring& str, bool first) +{ + int fnd = str.find_last_of(L"/\\"); + if (first == true) + fnd = str.find_first_of(L"/\\"); + + if (fnd == std::wstring::npos) + return false; + else + return true; +} + +std::string getWideStr(std::ifstream &file, bool f) +{ + auto buff = std::make_unique(_MAX_PATH); + int strlen = 0; + for (int i = 0; i < _MAX_PATH; i++) + { + char temp[2]; + file.read((char*)&temp, sizeof(temp)); + buff[i] = temp[0]; + if (!(temp[0] == 0 && temp[1] == 0)) + strlen++; + else + break; + + } + if (f == true) strlen -= 2; + return std::string(buff.get(), strlen); +} + +std::wstring getWideString(std::ifstream & file) +{ + auto buff = std::make_unique(_MAX_PATH); + int strlen = 0; + for (int i = 0; i < _MAX_PATH; i++) + { + wchar_t temp; + file.read((char*)&temp, sizeof(temp)); + buff[i] = temp; + if (!(temp == 0)) + strlen++; + else + break; + + } + + return std::wstring(buff.get(), strlen); +} + +std::string convertWide(std::string& str) +{ + int strlen = str.length(); + std::string temp; + for (int i = 0; i < strlen; i++) + { + temp += str[i]; + i++; + } + return temp; +} + +std::string convertWideToChar(std::wstring & str) +{ + int wcslen = str.length(); + + std::string temp; + + for (int i = 0; i < wcslen; i++) + { + temp += *(char*)(&str + i); + i++; + } + + return temp; +} + +std::string splitString(std::string& str, bool file) { + + std::string str_ret; + int fnd = str.find_last_of("/\\"); + + if (file == true) str_ret = str.substr(fnd + 1); + if (file == false) str_ret = str.substr(0, fnd); + return str_ret; + +} + +std::wstring wsplitString(std::wstring& str, bool file) { + + std::wstring str_ret; + int fnd = str.find_last_of(L"/\\"); + + if (file == true) str_ret = str.substr(fnd + 1); + if (file == false) str_ret = str.substr(0, fnd); + return str_ret; + +} + +int calcOffsetFromPad(int val, int padsize) +{ + int retval = val; + if (!(retval % padsize == 0)) + { + do + { + retval++; + } while (retval % padsize != 0); + + } + return retval; +} + +std::wstring getExecutablePath() +{ + wchar_t path[260]; + GetModuleFileNameW(NULL, path, sizeof(path)); + + wchar_t* end = wcsrchr(path, L'\\'); + if (end) + end[1] = 0x00; + std::wstring wpath(path, wcslen(path)); + return wpath; +} + +std::string getExecutablePath_str() +{ + char path[260]; + GetModuleFileNameA(NULL, path, sizeof(path)); + + char* end = strrchr(path, '\\'); + if (end) + end[1] = 0x00; + std::string spath(path,strlen(path)); + return spath; +} + +std::string getExtension(std::string & str) +{ + if (str.find_last_of(".") != std::string::npos) + return str.substr(str.find_last_of(".") + 1); + else + return " "; +} diff --git a/source/code/core/FileFunctions.h b/source/code/core/FileFunctions.h new file mode 100644 index 0000000..4ac2b11 --- /dev/null +++ b/source/code/core/FileFunctions.h @@ -0,0 +1,17 @@ +#pragma once +#include +#include + +std::streampos getSizeToEnd(std::ifstream& is); +bool checkSlash(std::string& str, bool first = false); +bool wcheckSlash(std::wstring& str, bool first = false); +std::string getWideStr(std::ifstream &file, bool f = false); +std::wstring getWideString(std::ifstream &file); +std::string convertWide(std::string& str); +std::string convertWideToChar(std::wstring& str); +std::string splitString(std::string& str, bool file); +std::wstring wsplitString(std::wstring& str, bool file); +int calcOffsetFromPad(int val, int padsize); +std::wstring getExecutablePath(); +std::string getExecutablePath_str(); +std::string getExtension(std::string& str); \ No newline at end of file diff --git a/source/code/core/eMain.cpp b/source/code/core/eMain.cpp new file mode 100644 index 0000000..8445afa --- /dev/null +++ b/source/code/core/eMain.cpp @@ -0,0 +1,79 @@ +#include "eMain.h" +#include "..\manhunt\core.h" +#include "..\manhunt\App.h" +#include "..\manhunt\Frontend.h" +#include "..\manhunt\Scene.h" +#include "..\manhunt\Filenames.h" +#include "..\manhunt\Input.h" +#include "..\plugin\eStatsManager.h" +#include "..\plugin\menu\eMenu.h" +#include "..\plugin\console\eConsole.h" +#include "..\plugin\modloader\eModLoader.h" +#include "eSettingsManager.h" + +WNDPROC wOriginalWndProc = nullptr; +static bool bWindowInFocus = true; + +LRESULT CALLBACK MainHooks::HookedWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_KEYDOWN: + if (wParam == eSettingsManager::keyToggleDebugMenu) + CFrontend::ms_devMenu ^= 1; + if (CFrontend::m_gameIsRunning) + { + if (wParam == VK_OEM_3) + TheConsole.m_consoleActive ^= 1; + + if (wParam == eSettingsManager::keyToggleScreenshotMode) + { + CFrontend::ms_draw2d ^= 1; + CScene::ms_stepMode ^= 1; + CScene::ms_bFreeCam ^= 1; + } + + if (wParam == eSettingsManager::keyToggleHUD) + CFrontend::ms_draw2d ^= 1; + + } + break; + case WM_CHAR: + if (CFrontend::m_gameIsRunning) + { + if (TheConsole.m_consoleActive) + { + if (wParam == VK_BACK) + TheConsole.RemoveLastCharacter(); + else if (wParam == VK_RETURN) + TheConsole.Execute(); + else + { + TheConsole.PushCharacter(wParam); + } + + } + } + break; + case WM_KILLFOCUS: + bWindowInFocus = false; + break; + case WM_SETFOCUS: + bWindowInFocus = true; + break; + default: + break; + } + + return CallWindowProc(wOriginalWndProc, hWnd, uMsg, wParam, lParam); +} + +void MainHooks::HookWndProc() +{ + wOriginalWndProc = (WNDPROC)SetWindowLongPtr(CApp::ms_window, GWLP_WNDPROC, (LONG_PTR)HookedWndProc); +} + +bool IsWindowFocused() +{ + return bWindowInFocus; +} diff --git a/source/code/core/eMain.h b/source/code/core/eMain.h new file mode 100644 index 0000000..0a6c2ce --- /dev/null +++ b/source/code/core/eMain.h @@ -0,0 +1,10 @@ +#pragma once +#include + + +namespace MainHooks { + LRESULT CALLBACK HookedWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + void HookWndProc(); +} + +bool IsWindowFocused(); \ No newline at end of file diff --git a/source/code/core/eSettingsManager.cpp b/source/code/core/eSettingsManager.cpp new file mode 100644 index 0000000..8121b03 --- /dev/null +++ b/source/code/core/eSettingsManager.cpp @@ -0,0 +1,71 @@ +#include "eSettingsManager.h" +#include "..\..\IniReader.h" +#include "..\manhunt\core.h" + +bool eSettingsManager::bEnableLog; +bool eSettingsManager::bUseEmptyPAKFile; +bool eSettingsManager::bHookSkinLoader; + +bool eSettingsManager::bEnableStatsManager; + +bool eSettingsManager::bDisableHeartBeat; +bool eSettingsManager::bDisableBreathing; +bool eSettingsManager::bHookCustomAnimManager; +int eSettingsManager::iCustomAnimManagerSize; + +bool eSettingsManager::bCustomAnimManagerUseGlobalFile; +bool eSettingsManager::bHookCustomTableOfContents; +int eSettingsManager::iCustomTableOfContentsBufferSize; +char* eSettingsManager::szCustomUserFilesDirectory; + + +bool eSettingsManager::bSkipIntroSequence; +bool eSettingsManager::bEnableCheatsInBonusLevels; +bool eSettingsManager::bDisableAutoAim; +bool eSettingsManager::bRestoreConfirmationIcon; +bool eSettingsManager::bAllowAllWeaponsExplodeCheat; +bool eSettingsManager::bHideBSPWarnings; +bool eSettingsManager::bForceFXMode; +bool eSettingsManager::bEnableFirstPersonMode; +int eSettingsManager::iForcePlayerSkin; + +int eSettingsManager::keyToggleDebugMenu; +int eSettingsManager::keyToggleConsole; +int eSettingsManager::keyToggleHUD; +int eSettingsManager::keyToggleScreenshotMode; +void eSettingsManager::Init() +{ + CIniReader reader(""); + bEnableLog = reader.ReadBoolean("Settings", "bEnableLog", false); + + bEnableStatsManager = reader.ReadBoolean("Settings.Features", "bEnableStatsManager", false); + bHookSkinLoader = reader.ReadBoolean("Settings.Features", "bHookSkinLoader", false); + + bHookCustomAnimManager = reader.ReadBoolean("Settings", "bHookCustomAnimManager", false); + bCustomAnimManagerUseGlobalFile = reader.ReadBoolean("Settings", "bCustomAnimMangerUseGlobalFile", false); + iCustomAnimManagerSize = reader.ReadInteger("Limits", "Animations", 1000); + + + bHookCustomTableOfContents = reader.ReadBoolean("Settings", "bHookCustomTableOfContents", false); + iCustomTableOfContentsBufferSize = reader.ReadInteger("Settings", "iCustomTableOfContentsBufferSize", 25); + + szCustomUserFilesDirectory = reader.ReadString("Settings", "szCustomUserFilesDirectory", 0); + + + bDisableBreathing = reader.ReadBoolean("Settings.Game", "bDisableBreathingSound", false); + bDisableHeartBeat = reader.ReadBoolean("Settings.Game", "bDisableHeartBeatSound", false); + bSkipIntroSequence = reader.ReadBoolean("Settings.Game", "bSkipIntroSequence", false); + bEnableCheatsInBonusLevels = reader.ReadBoolean("Settings.Game", "bEnableCheatsInBonusLevels", false); + bDisableAutoAim = reader.ReadBoolean("Settings.Game", "bDisableAutoAim", false); + bAllowAllWeaponsExplodeCheat = reader.ReadBoolean("Settings.Game", "bAllowAllWeaponsExplodeCheat", false); + bRestoreConfirmationIcon = reader.ReadBoolean("Settings.Game", "bRestoreConfirmationIcon", false); + bHideBSPWarnings = reader.ReadBoolean("Settings.Game", "bHideBSPWarnings", false); + bForceFXMode = reader.ReadBoolean("Settings.Game", "bForceFXMode", false); + bEnableFirstPersonMode = reader.ReadBoolean("Settings.Game", "bEnableFirstPersonMode", false); + iForcePlayerSkin = reader.ReadInteger("Settings.Game", "iForcePlayerSkin", 0); + + keyToggleDebugMenu = reader.ReadInteger("Keys", "keyToggleDevMenu", VK_F1); + keyToggleConsole = reader.ReadInteger("Keys", "keyToggleConsole", VK_OEM_3); + keyToggleScreenshotMode = reader.ReadInteger("Keys", "keyToggleScreenshotMode", VK_F3); + keyToggleHUD = reader.ReadInteger("Keys", "keyToggleHUD", VK_F4); +} diff --git a/source/code/core/eSettingsManager.h b/source/code/core/eSettingsManager.h new file mode 100644 index 0000000..07595d3 --- /dev/null +++ b/source/code/core/eSettingsManager.h @@ -0,0 +1,44 @@ +#pragma once + +class eSettingsManager { +public: + static bool bEnableLog; + + + static bool bEnableStatsManager; + static bool bHookSkinLoader; + static bool bUseEmptyPAKFile; + + // anims + static bool bHookCustomAnimManager; + static bool bCustomAnimManagerUseGlobalFile; + static int iCustomAnimManagerSize; + + // toc + static bool bHookCustomTableOfContents; + static int iCustomTableOfContentsBufferSize; + + // common + static char* szCustomUserFilesDirectory; + + // adjustements + static bool bDisableHeartBeat; + static bool bDisableBreathing; + static bool bEnableCheatsInBonusLevels; + static bool bSkipIntroSequence; + static bool bDisableAutoAim; + static bool bAllowAllWeaponsExplodeCheat; + static bool bRestoreConfirmationIcon; + static bool bHideBSPWarnings; + static int iForcePlayerSkin; + static bool bForceFXMode; + static bool bEnableFirstPersonMode; + + + // keys + static int keyToggleDebugMenu; + static int keyToggleConsole; + static int keyToggleScreenshotMode; + static int keyToggleHUD; + static void Init(); +}; \ No newline at end of file diff --git a/source/code/manhunt/AI.cpp b/source/code/manhunt/AI.cpp new file mode 100644 index 0000000..c44100f --- /dev/null +++ b/source/code/manhunt/AI.cpp @@ -0,0 +1,10 @@ +#include "AI.h" +#include "core.h" + + + + +void modAI_Interface::AISCRIPT_EntityAlwaysEnabled(char * instance) +{ + CallMethod<0x53BCF0, int, char*>(0x799B50, instance); +} diff --git a/source/code/manhunt/AI.h b/source/code/manhunt/AI.h new file mode 100644 index 0000000..2bbe37d --- /dev/null +++ b/source/code/manhunt/AI.h @@ -0,0 +1,12 @@ +#pragma once + +class cAI { +public: + + +}; + +namespace modAI_Interface { + void AISCRIPT_EntityAlwaysEnabled(char* instance); +}; + diff --git a/source/code/manhunt/AmmoWeapon.cpp b/source/code/manhunt/AmmoWeapon.cpp new file mode 100644 index 0000000..37d5a1b --- /dev/null +++ b/source/code/manhunt/AmmoWeapon.cpp @@ -0,0 +1,11 @@ +#include "AmmoWeapon.h" +#include "core.h" +bool& CAmmoWeapon::ms_bHeadShot = *(bool*)0x7920C8; +void CAmmoWeapon::Reload(int flag) +{ + CallMethod<0x4F9B20, CAmmoWeapon*, int>(this, flag); +} +void CAmmoWeapon::SetAmmo(unsigned int amount) +{ + CallMethod<0x4F8B40, CAmmoWeapon* , unsigned int>(this, amount); +} diff --git a/source/code/manhunt/AmmoWeapon.h b/source/code/manhunt/AmmoWeapon.h new file mode 100644 index 0000000..da65fb2 --- /dev/null +++ b/source/code/manhunt/AmmoWeapon.h @@ -0,0 +1,266 @@ +#pragma once +#include "Weapon.h" +#include "Vector.h" + +class CAmmoWeaponTypeData : public CWeaponTypeData { + int field36; + int field40; + char* sz_ModelReloadAnim; + int field48; + char* sz_ModelReloadCockAnim; + int field56; + char* sz_ModelReloadZoomCockAnim; + int field64; + char* sz_ModelReloadEmptyAnim; + int field72; + char* sz_ModelFireEmptyAnim; + int field80; + float m_fMinRange; + float m_fMaxRange; + float m_fMaxRangeHitProbability; + int field96; + float m_fLockOnTargetRanges; + int m_nMaxClips; + int m_nClipAmmo; + int m_nMaxShots; + float m_fShellReloadTime; + float m_fShellReloadTime2; + CVector2D m_vecRecoilDist; + float m_fRecoilTime; + float m_fRecoilVertAccumulator; + float m_fMaxRecoilVertDistance; + float m_fRecoilReturnAccuracy; + float m_fShotSpread; + int m_nDroppedAmmo; + float m_fFireCycleTime; + char* m_szSmokeShellFX; + int field164; + int m_bHasReloadLoop; + CVector2D m_vecReloadLoop; + int m_nNumHeadShots; + float m_fTorsoDamageMultipiler; + float m_fArmDamageMultipiler; + float m_fLegDamageMultipiler; + float m_fMaxPlayerShotgunDamage; + int field196; + int m_fxSmokeShell; + +}; + +class CAmmoWeapon { +public: + void* vTable; + CAmmoWeaponTypeData* AmmoTypeData; + int field_8; + char field_C; + char field_D; + char field_E; + char field_F; + char field_10; + char field_11; + char field_12; + char field_13; + char field_14; + char field_15; + char field_16; + char field_17; + char field_18; + char field_19; + char field_1A; + char field_1B; + char field_1C; + char field_1D; + char field_1E; + char field_1F; + char field_20; + char field_21; + char field_22; + char field_23; + char field_24; + char field_25; + char field_26; + char field_27; + char field_28; + char field_29; + char field_2A; + char field_2B; + char field_2C; + char field_2D; + char field_2E; + char field_2F; + char field_30; + char field_31; + char field_32; + char field_33; + char field_34; + char field_35; + char field_36; + char field_37; + char field_38; + char field_39; + char field_3A; + char field_3B; + char field_3C; + char field_3D; + char field_3E; + char field_3F; + char field_40; + char field_41; + char field_42; + char field_43; + char field_44; + char field_45; + char field_46; + char field_47; + char field_48; + char field_49; + char field_4A; + char field_4B; + char field_4C; + char field_4D; + char field_4E; + char field_4F; + char field_50; + char field_51; + char field_52; + char field_53; + char field_54; + char field_55; + char field_56; + char field_57; + char field_58; + char field_59; + char field_5A; + char field_5B; + char field_5C; + char field_5D; + char field_5E; + char field_5F; + char field_60; + char field_61; + char field_62; + char field_63; + char field_64; + char field_65; + char field_66; + char field_67; + char field_68; + char field_69; + char field_6A; + char field_6B; + char field_6C; + char field_6D; + char field_6E; + char field_6F; + char field_70; + char field_71; + char field_72; + char field_73; + char field_74; + char field_75; + char field_76; + char field_77; + char field_78; + char field_79; + char field_7A; + char field_7B; + char field_7C; + char field_7D; + char field_7E; + char field_7F; + char field_80; + char field_81; + char field_82; + char field_83; + char field_84; + char field_85; + char field_86; + char field_87; + char field_88; + char field_89; + char field_8A; + char field_8B; + char field_8C; + char field_8D; + char field_8E; + char field_8F; + char field_90; + char field_91; + char field_92; + char field_93; + int field_94; + int field_98; + char field_9C; + char field_9D; + char field_9E; + char field_9F; + int m_curammo; + char field_A4; + char field_A5; + char field_A6; + char field_A7; + char field_A8; + char field_A9; + char field_AA; + char field_AB; + int field_AC; + char field_B0; + char field_B1; + char field_B2; + char field_B3; + char field_B4; + char field_B5; + char field_B6; + char field_B7; + char field_B8; + char field_B9; + char field_BA; + char field_BB; + char field_BC; + char field_BD; + char field_BE; + char field_BF; + char field_C0; + char field_C1; + char field_C2; + char field_C3; + char field_C4; + char field_C5; + char field_C6; + char field_C7; + char field_C8; + char field_C9; + char field_CA; + char field_CB; + char field_CC; + char field_CD; + char field_CE; + char field_CF; + char field_D0; + char field_D1; + char field_D2; + char field_D3; + char field_D4; + char field_D5; + char field_D6; + char field_D7; + char field_D8; + char field_D9; + char field_DA; + char field_DB; + char field_DC; + char field_DD; + char field_DE; + char field_DF; + char field_E0; + char field_E1; + char field_E2; + char field_E3; + + void Reload(int flag); + void SetAmmo(unsigned int amount); + + static bool& ms_bHeadShot; + + +}; \ No newline at end of file diff --git a/source/code/manhunt/Anim.cpp b/source/code/manhunt/Anim.cpp new file mode 100644 index 0000000..f9dcf2b --- /dev/null +++ b/source/code/manhunt/Anim.cpp @@ -0,0 +1,45 @@ +#include "Anim.h" +#include "core.h" + +int& CAnimManager::ms_nAvailableAnims = *(int*)0x727D40; + +bool CAnimManager::LoadAnimations(char * file) +{ + return CallAndReturn(file); +} + +void CPedBodyAnimFSM::SetRequested(int body, int bodyType, int anim) +{ + CallMethod<0x41D970, int, int, int>(body, bodyType, anim); +} + +void CPedBodyAnimFSM::Update(int body, int arg) +{ + CallMethod<0x41F700, int, int>(body, arg); +} + +void CPedBodyAnimFSM::SetStand(int body, int anim) +{ + CallMethod<0x41DA10, int, int>(body, anim); +} + +int CPedBodyAnimFSM::GetIdleAnimIdFromName(int body, const char * name) +{ + return CallMethodAndReturn(body, name); +} + +void CPedTorsoAnimFSM::SetRequested(int body, int bodyType, int anim) +{ + CallMethod<0x41D970, int, int, int>(body, bodyType, anim); +} + +void CPedTorsoAnimFSM::Update(int body, int arg) +{ + CallMethod<0x426BD0, int, int>(body, arg); +} + + +int CPedTorsoAnimFSM::GetIdleAnimIdFromName(int body, const char * name) +{ + return CallMethodAndReturn(body, name); +} \ No newline at end of file diff --git a/source/code/manhunt/Anim.h b/source/code/manhunt/Anim.h new file mode 100644 index 0000000..bf18bc3 --- /dev/null +++ b/source/code/manhunt/Anim.h @@ -0,0 +1,92 @@ +#pragma once + +enum eBodyTypes { + BT_STAND1, + BT_STAND2, + BT_TURN1, + BT_TURN2, + BT_TURN_BIG, + BT_MOVE_START, + BT_MOVE1, + BT_MOVE2, + BT_SKID, + BT_IDLE1, + BT_IDLE2, + BT_IDLELOOP1, + BT_IDLELOOP2, + BT_DAMAGE, + BT_DIE, + BT_PEEK, + BT_PICKUP, + BT_REACT, + BT_KICK, + BT_JUMP_LAUNCH, + BT_JUMP_GLIDE, + BT_JUMP_LAND, + BT_CLIMABLE_BASE_MOUNT, + BT_CLIMABLE_BASE_DISMOUNT, + BT_CLIMABLE_MOVE, + BT_CLIMABLE_TOP_MOUNT, + BT_CLIMABLE_TOP_DISMOUNT, + BT_COMBAT_STANCE_TRANSITION, + BT_COMBAT_STANCE, + BT_COMBAT_STANCE_FIRE1, + BT_COMBAT_STANCE_FIRE2, + BT_COMBAT_STANCE_FIRE_CHARGE, + BT_COMBAT_STANCE_TURN, + BT_WEAPON_SPECIAL, + BT_GRAB, + BT_GRAPPLE_ATTACK1, + BT_GRAPPLE_ATTACK2, + BT_GRAPPLE_ATTACK3, + BT_GRAPPLE_BREAK, + BT_FALL_LAUNCH, + BT_FALL_FLAIL, + BT_FALL_FLAIL_DEATH, + BT_FALL_LAND, + BT_FALL_STUN, + BT_FALL_DAMAGE, + BT_FALL_DIE, + BT_FALL_DIE_DAMAGE, + BT_FALL_GETUP, + BT_USE, + BT_WALL_TRANSITION, + BT_WALL_STAND1, + BT_WALL_STAND2, + BT_WALL_MOVE1, + BT_WALL_MOVE2, + BT_WALL_PEEK, + BT_WALL_FIRE, + BT_DEADCARRY_PICKUP, + BT_DEADCARRY_STAND, + BT_DEADCARRY_TURN, + BT_DEADCARRY_MOVE, + BT_DEADCARRY_DROP, + BT_PUSH, + + +}; + + + +class CAnimManager { +public: + static int& ms_nAvailableAnims; + + static bool LoadAnimations(char* file); +}; + +class CPedBodyAnimFSM { +public: + static void SetRequested(int body, int bodyType, int anim); + static void Update(int body, int arg); + static void SetStand(int body, int anim); + static int GetIdleAnimIdFromName(int body, const char* name); +}; + +class CPedTorsoAnimFSM { +public: + static void SetRequested(int body, int bodyType, int anim); + static void Update(int body, int arg); + static int GetIdleAnimIdFromName(int body, const char* name); +}; \ No newline at end of file diff --git a/source/code/manhunt/App.cpp b/source/code/manhunt/App.cpp new file mode 100644 index 0000000..cd0e23b --- /dev/null +++ b/source/code/manhunt/App.cpp @@ -0,0 +1,26 @@ + +#include "App.h" + +int& CApp::ms_currLevelNum = *(int*)0x75622C; +int& CApp::ms_mode = *(int*)0x755E4C; +HWND& CApp::ms_window = *(HWND*)0x824444; + +void CApp::ShutdownLevel() +{ + Call<0x4D83D0>(); +} + +void CApp::StartupLevel() +{ + Call<0x4D8500>(); +} + +void CApp::SetLevel(int level) +{ + Call<0x4D8390, int>(level); +} + +void CApp::SetLevel(char * folder) +{ + strcpy((char*)0x756214, folder); +} diff --git a/source/code/manhunt/App.h b/source/code/manhunt/App.h new file mode 100644 index 0000000..881addf --- /dev/null +++ b/source/code/manhunt/App.h @@ -0,0 +1,43 @@ +#pragma once +#include "core.h" + +enum eLevels { + jury_turf, // Born Again + derelict, // Doorway Into Hell + der2, // Road To Ruin + scrap, // White Trash + scrap2, // Fuelled By Hate + zoo, // Grounds For Assault + zoo2, // Strapped for Cash + mall, // View of Innocence + church2, // Drunk Driving + pharm_wks, // Graveyard Shift + asylum, // Mouth of Madness + cellblock, // Doing Time + prison, // Kill The Rabbit + ramirez, // Divided They Fall + journo_streets, // Press Coverage + subway, // Wrong Side of the Tracks + trainyard, // Trained To Kill + estate_ext, // Border Patrol + mansion_int, // Key Personnel + attic, // Deliverance + bonus1, // Hard as Nails + bonus2, // Monkey See, Monkey Die + bonus3, // Brawl Game + weasel, // Time 2 Die +}; + + + +class CApp { +public: + static HWND& ms_window; + static int& ms_currLevelNum; + static int& ms_mode; + + static void ShutdownLevel(); + static void StartupLevel(); + static void SetLevel(int level); + static void SetLevel(char* folder); +}; \ No newline at end of file diff --git a/source/code/manhunt/Character.cpp b/source/code/manhunt/Character.cpp new file mode 100644 index 0000000..270c2fe --- /dev/null +++ b/source/code/manhunt/Character.cpp @@ -0,0 +1,7 @@ +#include "Character.h" +#include "core.h" + +void CCharacter::CreateInventoryItem(CEntity * entity, int collectable, bool settoactive) +{ + CallMethod<0x49A5C0, CEntity*, int, bool>(entity, collectable, settoactive); +} diff --git a/source/code/manhunt/Character.h b/source/code/manhunt/Character.h new file mode 100644 index 0000000..5e959d0 --- /dev/null +++ b/source/code/manhunt/Character.h @@ -0,0 +1,8 @@ +#pragma once +#include "Entity.h" +#include "Collectable.h" + +class CCharacter { +public: + static void CreateInventoryItem(CEntity* entity, int collectable, bool settoactive); +}; \ No newline at end of file diff --git a/source/code/manhunt/Cheats.cpp b/source/code/manhunt/Cheats.cpp new file mode 100644 index 0000000..4168aeb --- /dev/null +++ b/source/code/manhunt/Cheats.cpp @@ -0,0 +1,54 @@ +#include "Cheats.h" + +bool& CCheatHandler::m_bCheatsActive = *(bool*)0x7C84AC; +int& CCheatHandler::m_lastCheat = *(int*)0x7C84A8; +int& CCheatHandler::m_fullyarmed = *(int*)0x7C84C0; +int& CCheatHandler::m_godMode = *(int*)0x7C84CC; +int& CCheatHandler::m_heliumHunters = *(int*)0x7C84BC; +int& CCheatHandler::m_invisibility = *(int*)0x7C84C8; +int& CCheatHandler::m_regenerate = *(int*)0x7C84B8; +int& CCheatHandler::m_runner = *(int*)0x7C84B0; +int& CCheatHandler::m_silence = *(int*)0x7C84B4; +int& CCheatHandler::m_superPunch = *(int*)0x7C84C4; + +int CCheatHandler::aCheatButtons[8][TOTAL_8_CHEATS] = { + 'U','R','U','N','F','A','S','T', // runner + 'A','L','L','R','D','E','A','F', // silence + 'H','E','A','L','B','A','C','K', // regenerate + 'T','H','E','Y','B','O','O','M', // helium hunters + 'U','G','O','T','A','R','M','S', // fully armed + 'U','H','I','T','H','A','R','D', // super punch + 'B','U','N','Y','S','U','I','T', // white rabbit skin + 'H','E','L','L','S','U','I','T', // monkey skin + 'E','V','I','L','E','Y','E','S', // invisibility + 'P','I','G','G','S','U','I','T', // piggsy skin + 'C','H','E','A','T','O','F','F', // disable cheats +}; + +int CCheatHandler::aCheatButtons12[12][TOTAL_12_CHEATS] = { + 'I','M','I','N','V','I','N','C','I','B','L','E', // god mode +}; + +int CCheatHandler::aCheatButtonsConfirms[8][TOTAL_8_CHEATS] = {}; +int CCheatHandler::aCheatButtons12Confirms[12][TOTAL_12_CHEATS] = {}; + + +void CCheatHandler::Update() +{ + _DUMMY +} + +void CCheatHandler::Reset() +{ + _DUMMY +} + +void CCheatHandler::DisableCheatsOnBonusLevels() +{ + _DUMMY +} + +void CCheatHandler::SetupForLevel() +{ + Call<0x5D4AF0>(); +} diff --git a/source/code/manhunt/Cheats.h b/source/code/manhunt/Cheats.h new file mode 100644 index 0000000..7e0fb1e --- /dev/null +++ b/source/code/manhunt/Cheats.h @@ -0,0 +1,61 @@ +#pragma once +#include "core.h" + +enum eCheatMasks { + CHEAT_RUNNER = 0x1, + CHEAT_SILENCE = 0x2, + CHEAT_REGENERATION = 0x4, + CHEAT_EXPLODE = 0x8, + CHEAT_EQUIPPED = 0x10, + CHEAT_SUPERPUNCH = 0x20, + CHEAT_RABBIT = 0x40, + CHEAT_MONKEY = 0x80, + CHEAT_INVIS = 0x100, + CHEAT_PIGGSY = 0x200, + CHEAT_GODMODE = 0x400, +}; + +enum eCheats8 { + runner, + silence, + regenerate, + heliumHunters, + fullyarmed, + superPunch, + rabbit, + monkey, + invisiblity, + piggsy, + cheatoff, + TOTAL_8_CHEATS +}; + +enum eCheats12 { + godmode, + TOTAL_12_CHEATS +}; + +class CCheatHandler { +public: + static int& m_lastCheat; + static bool& m_bCheatsActive; + // cheats + static int& m_runner; + static int& m_silence; + static int& m_regenerate; + static int& m_heliumHunters; + static int& m_fullyarmed; + static int& m_superPunch; + static int& m_invisibility; + static int& m_godMode; + + // data + static int aCheatButtons[8][TOTAL_8_CHEATS]; + static int aCheatButtons12[12][TOTAL_12_CHEATS]; + static int aCheatButtonsConfirms[8][TOTAL_8_CHEATS]; + static int aCheatButtons12Confirms[12][TOTAL_12_CHEATS]; + static void Update(); + static void Reset(); + static void DisableCheatsOnBonusLevels(); + static void SetupForLevel(); +}; \ No newline at end of file diff --git a/source/code/manhunt/Clump.h b/source/code/manhunt/Clump.h new file mode 100644 index 0000000..b72e3cc --- /dev/null +++ b/source/code/manhunt/Clump.h @@ -0,0 +1,5 @@ +#pragma once + +class CClump { +public: +}; \ No newline at end of file diff --git a/source/code/manhunt/ClumpDict.cpp b/source/code/manhunt/ClumpDict.cpp new file mode 100644 index 0000000..1c812be --- /dev/null +++ b/source/code/manhunt/ClumpDict.cpp @@ -0,0 +1,27 @@ +#include "ClumpDict.h" +#include "core.h" + +CClump * CClumpDict::FindClump(const char * name) +{ + return CallMethodAndReturn(this, name); +} + +void CClumpDict::Initialise(const char * texture, const char * name) +{ + CallMethod<0x59B3F0, CClumpDict*, const char*, const char*>(this, texture, name); +} + +int CClumpDict::CheckDict() +{ + return CallMethodAndReturn(this); +} + +CClump * CClumpDict::FindClumpDescription(const char * name) +{ + return CallMethodAndReturn(this, name); +} + +void CClumpDict::Destroy() +{ + CallMethod<0x59B680, CClumpDict*>(this); +} diff --git a/source/code/manhunt/ClumpDict.h b/source/code/manhunt/ClumpDict.h new file mode 100644 index 0000000..a252b11 --- /dev/null +++ b/source/code/manhunt/ClumpDict.h @@ -0,0 +1,16 @@ +#pragma once +#include "Clump.h" + +class CClumpDict { +private: + char data[0x288]; +public: + void Initialise(const char* texture, const char* name); + + CClump* FindClump(const char* name); + CClump* FindClumpDescription(const char* name); + void Destroy(); + + int CheckDict(); + +}; \ No newline at end of file diff --git a/source/code/manhunt/Collectable.cpp b/source/code/manhunt/Collectable.cpp new file mode 100644 index 0000000..bea8ce9 --- /dev/null +++ b/source/code/manhunt/Collectable.cpp @@ -0,0 +1,20 @@ +#include "Collectable.h" +#include "core.h" + +char tempBuffer[256]; + +wchar_t * CCollectable::GetNameKey16(int id) +{ + return CallAndReturn(id); +} + +void CCollectable::GetNameStringFromType(int weaponID, char * dest) +{ + Call<0x4C67F0, int, char*>(weaponID, dest); +} + +char * CCollectable::FastGetNameStringFromType(int weaponID) +{ + Call<0x4C67F0, int, int>(weaponID, (int)&tempBuffer); + return tempBuffer; +} diff --git a/source/code/manhunt/Collectable.h b/source/code/manhunt/Collectable.h new file mode 100644 index 0000000..dae3c95 --- /dev/null +++ b/source/code/manhunt/Collectable.h @@ -0,0 +1,124 @@ +#pragma once + +enum eCollectableTypes { + CT_TRIPWIRE = 1, + CT_GASOLINE, + CT_WATER, + CT_LIGHTER, + CT_CASH, + CT_TORCH, + CT_N_VISION, + CT_PAINKILLERS, + CT_G_FIRST_AID, + CT_Y_FIRST_AID, + CT_SPEED_BOOST, + CT_STRENGTH_BOOST, + CT_SHOOTING_BOOST, + CT_REFLEXES_BOOST, + CT_HEALTH_BOOST, + CT_FISTS, + CT_K_DUST, + CT_KNIFE, + CT_SHARD, + CT_BROKEN_BOTTLE, + CT_JURYBLADES, + CT_BOTTLE, + CT_PIPE, + CT_CLEAVER, + CT_WOODEN_BAR, + CT_CROWBAR, + CT_SICKLE, + CT_NIGHTSTICK, + CT_CANE, + CT_AXE, + CT_ICEPICK, + CT_MACHETE, + CT_SMALL_BAT, + CT_BASEBALL_BAT, + CT_W_BASEBALL_BAT, + CT_FIRE_AXE, + CT_HOCKEY_STICK, + CT_BASEBALL_BAT_BLADES, + CT_6SHOOTER, + CT_GLOCK, + CT_GLOCK_SILENCED, + CT_GLOCK_TORCH, + CT_UZI, + CT_SHOTGUN, + CT_SHOTGUN_TORCH, + CT_DESERT_EAGLE, + CT_COLT_COMMANDO, + CT_SNIPER_RIFLE, + CT_TRANQ_RIFLE, + CT_SAWNOFF, + CT_GRENADE, + CT_MOLOTOV, + CT_EXPMOLOTOV, + CT_TEAR_GAS, + CT_F_GRENADE, + CT_BRICK_HALF, + CT_FIREWORK, + CT_BAG, + CT_RAG, + CT_CHLORINE, + CT_METHS, + CT_HCC, + CT_D_BEER_GUY, + CT_D_MERC_LEADER, + CT_D_SMILEY, + CT_D_HUNTLORD, + CT_E_L_SIGHT, + CT_S_SILENCER, + CT_RADIO, + CT_BAR_KEY, + CT_SYARD_COMB, + CT_CAMERA, + CT_BODY_P1, + CT_BODY_P2, + CT_PREC_KEY, + CT_PREC_CARD, + CT_PREC_DOCS, + CT_PHARM_HAND, + CT_EST_G_KEY, + CT_EST_A_KEY, + CT_DOLL, + CT_ANTIDOTE, + CT_KEY, + CT_SWIPE_CARD, + CT_CHAINSAW = 88, + CT_NAILGUN, + CT_WIRE, + CT_CAN, + CT_WOODEN_SPIKE, + CT_PIGSY_SHARD = 94, + CT_PIGSY_WIRE, + CT_PIGSY_SPIKE, + CT_HAMMER, + CT_DOLL_1, + CT_DOLL_2, + CT_DOLL_3, + CT_HEAD, + CT_AMMO_NAILS, + CT_AMMO_SHOTGUN, + CT_AMMO_PISTOL, + CT_AMMO_MGUN, + CT_AMMO_TRANQ, + CT_AMMO_SNIPER, + CT_CHAINSAW_PLAYER, + CT_DVTAPE, + CT_HANDYCAM + +}; + +struct CCollectableTypeData { +public: + void* vTable; + +}; + +class CCollectable { +public: + static wchar_t* GetNameKey16(int id); + static void GetNameStringFromType(int weaponID, char *dest); + static char* FastGetNameStringFromType(int weaponID); +}; \ No newline at end of file diff --git a/source/code/manhunt/CreationManager.cpp b/source/code/manhunt/CreationManager.cpp new file mode 100644 index 0000000..6726681 --- /dev/null +++ b/source/code/manhunt/CreationManager.cpp @@ -0,0 +1,7 @@ +#include "CreationManager.h" +#include "core.h" + +CEntity * CCreationManager::CreateEntity(CTypeData * data) +{ + return CallAndReturn(data); +} diff --git a/source/code/manhunt/CreationManager.h b/source/code/manhunt/CreationManager.h new file mode 100644 index 0000000..e3f1ec6 --- /dev/null +++ b/source/code/manhunt/CreationManager.h @@ -0,0 +1,7 @@ +#pragma once +#include "Entity.h" + +class CCreationManager { +public: + static CEntity* CreateEntity(CTypeData* data); +}; \ No newline at end of file diff --git a/source/code/manhunt/DevMenu.h b/source/code/manhunt/DevMenu.h new file mode 100644 index 0000000..8fb38d9 --- /dev/null +++ b/source/code/manhunt/DevMenu.h @@ -0,0 +1,8 @@ +#pragma once + +#define FE_DEV_MENU_ITEMS_MAX 170 + + +class CDevMenu { +public: +}; \ No newline at end of file diff --git a/source/code/manhunt/Entity.cpp b/source/code/manhunt/Entity.cpp new file mode 100644 index 0000000..6e03e4c --- /dev/null +++ b/source/code/manhunt/Entity.cpp @@ -0,0 +1,38 @@ +#include "Entity.h" +#include "core.h" + + + +void CEntity::Spawn(CVector * pos, float arg) +{ + CallMethod<0x4342E0, int,CVector*, float>((int)this, pos, arg); +} + +void CEntity::SetFrozen(int state) +{ + CallMethod<0x436160, int,int>((int)this, state); +} + +void CEntity::SetName(char * name) +{ + CallMethod<0x4313D0, CEntity*, char*>(this, name); +} + +void CEntity::SetLocation(CVector * pos) +{ + (*((void(__thiscall **)(CEntity *, CVector *, int))this->vTable + 15))(this,pos,1); +} + +void CEntity::SetFlag(int flag, int status) +{ + if (status) + this->m_iEntityFlags |= flag; + else + this->m_iEntityFlags &= ~flag; + +} + +CVector * CEntity::GetLocation() +{ + return CallMethodAndReturn(this); +} diff --git a/source/code/manhunt/Entity.h b/source/code/manhunt/Entity.h new file mode 100644 index 0000000..2c1d221 --- /dev/null +++ b/source/code/manhunt/Entity.h @@ -0,0 +1,176 @@ +#pragma once +#include "Vector.h" +#include "TypeData.h" + + +struct CEntityAnim +{ + void *vTable; + char field_4; + char field_5; + char field_6; + char field_7; + char field_8; + char field_9; + char field_A; + char field_B; + int field_C; + int field_10; + int field_14; + int field_18; + int field_1C; + int field_20; + int field_24; + int field_28; +}; + + + +class CEntity { +public: + void *vTable; + int field_4; + int field_8; + int field_C; + int field_10; + float m_fHealth; + int field_18; + int field_1C; + int field_20; + int field_24; + int field_28; + int field_2C; + int field_30; + int field_34; + int field_38; + char field_3C; + char field_3D; + char field_3E; + char field_3F; + int field_40; + __int16 field_44; + char field_46; + char field_47; + char field_48; + char field_49; + char field_4A; + char field_4B; + char field_4C; + char field_4D; + char field_4E; + char field_4F; + int field_50; + int field_54; + int field_58; + int field_5C; + int field_60; + int field_64; + char field_68; + char field_69; + char field_6A; + char field_6B; + int field_6C; + char *m_szName; + char field_74; + char field_75; + char field_76; + char field_77; + int field_78; + CTypeData *m_TypeData; + int field_80; + int field_84; + int field_88; + int field_8C; + int field_90; + int field_94; + int field_98; + int field_9C; + int field_A0; + int field_A4; + int m_pPhysics; + CEntityAnim *m_pEntityAnim; + int field_B0; + char field_B4; + char field_B5; + char field_B6; + char field_B7; + char field_B8; + char field_B9; + char field_BA; + char field_BB; + int field_BC; + int field_C0; + float field_C4; + int m_iEntityFlags; + char field_CC; + char field_CD; + char field_CE; + char field_CF; + char field_D0; + char field_D1; + char field_D2; + char field_D3; + char field_D4; + char field_D5; + char field_D6; + char field_D7; + char field_D8; + char field_D9; + char field_DA; + char field_DB; + int field_DC; + int field_E0; + int field_E4; + char field_E8; + char field_E9; + char field_EA; + char field_EB; + int field_EC; + int field_F0; + int field_F4; + int field_F8; + int field_FC; + char field_100; + char field_101; + char field_102; + char field_103; + int field_104; + int field_108; + int field_10C; + char field_110; + char field_111; + short field_112; + int field_114; + int field_118; + int field_11C; + int field_120; + int field_124; + char field_128; + char field_129; + char field_12A; + char field_12B; + char field_12C; + char field_12D; + char field_12E; + char field_12F; + char field_130; + char field_131; + char field_132; + char field_133; + char field_134; + char field_135; + char field_136; + char field_137; + char field_138; + char field_139; + char field_13A; + char field_13B; + + + void Spawn(CVector* pos, float arg); + void SetFrozen(int state); + void SetName(char* name); + void SetLocation(CVector* pos); + void SetFlag(int flag, int status); + CVector* GetLocation(); +}; \ No newline at end of file diff --git a/source/code/manhunt/EntityManager.cpp b/source/code/manhunt/EntityManager.cpp new file mode 100644 index 0000000..9be032a --- /dev/null +++ b/source/code/manhunt/EntityManager.cpp @@ -0,0 +1,25 @@ +#include "EntityManager.h" +#include "core.h" + + +int& CEntityManager::ms_playerCharacterID = *(int*)0x6A94C0; + +CTypeData * CEntityManager::GetEntityTypeDataFromName(char * name) +{ + return CallAndReturn(name); +} + +CEntity * CEntityManager::GetEntity(char * name) +{ + return CallAndReturn(name); +} + +CEntity * CEntityManager::FindInstance(char * name) +{ + return CallAndReturn(name); +} + +void CEntityManager::CreateArchetypes() +{ + Call<0x4381C0>(); +} diff --git a/source/code/manhunt/EntityManager.h b/source/code/manhunt/EntityManager.h new file mode 100644 index 0000000..3eda5e3 --- /dev/null +++ b/source/code/manhunt/EntityManager.h @@ -0,0 +1,11 @@ +#pragma once +#include"Entity.h" + +class CEntityManager { +public: + static int& ms_playerCharacterID; + static CTypeData* GetEntityTypeDataFromName(char* name); + static CEntity* GetEntity(char* name); + static CEntity* FindInstance(char* name); + static void CreateArchetypes(); +}; \ No newline at end of file diff --git a/source/code/manhunt/Filenames.cpp b/source/code/manhunt/Filenames.cpp new file mode 100644 index 0000000..fe59479 --- /dev/null +++ b/source/code/manhunt/Filenames.cpp @@ -0,0 +1,20 @@ +#include "Filenames.h" +#include "core.h" + + +CString& CFileNames::ms_filenameAllAnims = *(CString*)0x73957C; +CString& CFileNames::ms_filenameAnimFileType = *(CString*)0x739574; +CString& CFileNames::ms_CurrentLevelPath = *(CString*)0x7394A4; +CString& CFileNames::ms_SceneEpPath = *(CString*)0x73975C; +CString& CFileNames::ms_BonusEpPath = *(CString*)0x73977C; +CString& CFileNames::ms_MainEpPath = *(CString*)0x739754; +char*& CFileNames::ms_pathLevels = *(char**)0x756034; +void CFileNames::init() +{ + _DUMMY +} + +char * CFileNames::GetMyDocumentsDirectory() +{ + return CallAndReturn(); +} diff --git a/source/code/manhunt/Filenames.h b/source/code/manhunt/Filenames.h new file mode 100644 index 0000000..f972209 --- /dev/null +++ b/source/code/manhunt/Filenames.h @@ -0,0 +1,16 @@ +#pragma once +#include "String.h" + +class CFileNames { +public: + static CString& ms_filenameAllAnims; + static CString& ms_filenameAnimFileType; + static CString& ms_CurrentLevelPath; + static CString& ms_SceneEpPath; + static CString& ms_BonusEpPath; + static CString& ms_MainEpPath; + static char*& ms_pathLevels; + static void init(); + + static char* GetMyDocumentsDirectory(); +}; \ No newline at end of file diff --git a/source/code/manhunt/Frontend.cpp b/source/code/manhunt/Frontend.cpp new file mode 100644 index 0000000..2d97d54 --- /dev/null +++ b/source/code/manhunt/Frontend.cpp @@ -0,0 +1,106 @@ +#include "Frontend.h" +#include "core.h" + +bool& CFrontend::m_bNewGame = *(bool*)0x7C86F0; +int& CFrontend::ms_devMenu = *(int*)0x7CF088; +int& CFrontend::m_gameIsRunning = *(int*)0x7D2E28; +int& CFrontend::ms_draw2d = *(int*)0x7CF0A0; +int& CFrontend::ms_misc = *(int*)0x7D34F8; +int& CFrontend::ms_menuButton = *(int*)0x7C89D4; +int& CFrontend::ms_currentMenu = *(int*)0x7C86F8; +int& CFrontend::ms_lastMenu = *(int*)0x7C8700; +float& CFrontend::ms_fTextXScale = *(float*)0x7C8720; +float& CFrontend::ms_fTextYScale = *(float*)0x7C8724; +float& CFrontend::ms_fTextAdjust = *(float*)0x7D6064; +float& CFrontend::ms_fMenuPositionY = *(float*)0x7C8728; +float& CFrontend::ms_fMenuPositionX = *(float*)0x7D6410; +int& CFrontend::ms_mouseHoverButton = *(int*)0x7C8FAC; +int& CFrontend::NumStoredHalos = *(int*)0x7D5E30; +int& CFrontend::ms_cnt = *(int*)0x7D5A1C; + +CRGBA& CFrontend::ColorSet1 = *(CRGBA*)0x7D4EC8; +CRGBA& CFrontend::ColorSet2 = *(CRGBA*)0x7D4EE8; +CRGBA& CFrontend::ColorSet3 = *(CRGBA*)0x7D4EF8; +CRGBA& CFrontend::ColorSet4 = *(CRGBA*)0x7D4ED8; + +CRGBA ColorSets[] = { + CFrontend::ColorSet1, + CFrontend::ColorSet2, + CFrontend::ColorSet3, + CFrontend::ColorSet4 +}; + + +void CFrontend::SetLevel(int level) +{ + Call<0x5EF7E0, int>(level); +} + +void CFrontend::ForceLevel(int level) +{ + Call<0x5EF800, int>(level); +} + +void CFrontend::SetCurrentMenu(int menu) +{ + Call<0x5D7A40, int>(menu); +} + +void CFrontend::DrawMenuCameraCounter(wchar_t * text) +{ + Call<0x5D5740, wchar_t*>(text); +} + +void CFrontend::AddOption(wchar_t * text, float x, float y, float textScaleX, float textScaleY, int menuID) +{ + Call<0x5D55C0, wchar_t*, float, float, float, float, int>(text, x, y, textScaleX, textScaleY, menuID); + Call<0x5D5B30, wchar_t*, float, float, float, float>(text, x, y, textScaleX, textScaleY); +} + +int CFrontend::GetHoveredItem() +{ + return CallAndReturn(); +} + +void CFrontend::SetDrawRGBA(int r, int g, int b, int a) +{ + ColorSet1 = { r,g,b,a }; + ColorSet2 = { r,g,b,a }; + ColorSet3 = { r,g,b,a }; + ColorSet4 = { r,g,b,a }; +} + +void CFrontend::Print8(const char * text, float x, float y, float sizex, float sizey, float unk, eFontType font) +{ + Call<0x5E55E0, const char*, float, float, float, float, float, eFontType>(text, x, y, sizex, sizey, unk, font); +} + +void CFrontend::SetMenuBackground(char * file) +{ + Call<0x5D7DD0, char*, int>(file, 0x7D38E0); +} + +void CFrontend::PrintInfo(wchar_t * button1, wchar_t * button2, wchar_t * button3, wchar_t * button4) +{ + Call<0x5D5BB0, wchar_t*, wchar_t*, wchar_t*, wchar_t*>(button1, button2, button3, button4); +} + +int CFrontend::GetTextureFromTXD(int txd, const char * texture) +{ + return CallAndReturn(txd, texture); +} + +float CFrontend::CalculateTextLen(wchar_t * text, float charScale, int byteLen) +{ + return CallAndReturn(text, charScale, byteLen); +} + +void CFrontend::DrawDisc2D(CVector* pos, float scale, int red, int green, int blue, float a6) +{ + Call<0x5FB6D0, CVector*, float, int, int, int, float>(pos, scale, red, green, blue, a6); +} + +void CFrontend::DrawDisc3D(CVector* pos, float scale, int red, int green, int blue, float a6) +{ + Call<0x5FBBD0, CVector*, float, int, int, int, float>(pos, scale, red, green, blue, a6); +} diff --git a/source/code/manhunt/Frontend.h b/source/code/manhunt/Frontend.h new file mode 100644 index 0000000..cb03eae --- /dev/null +++ b/source/code/manhunt/Frontend.h @@ -0,0 +1,113 @@ +#pragma once +#include "Vector.h" + +enum eFrontendMainMenuButtons { + MB_PLAY, + MB_SELSCE, + MB_LOADG, + MB_SETT, + MB_BONFEA, + // custom menus + MB_STATS, + MB_MODIFICATIONS, + // end custom menus + MB_QUITPRG, + MB_TOTAL_MENUS +}; + + + +enum eMenuTypes { + MENU_EMPTY, + MENU_CHANGE_LANGUAGE, + MENU_EMPTY_2, + MENU_DIFFICULTY_SELECT, + MENU_START_LOAD_GAME, + MENU_LOAD_GAME, + MENU_SAVE_GAME, + MENU_FRONTEND, + MENU_PAUSE, + MENU_LEVEL_SELECT, + MENU_SETTINGS, + MENU_AUDIO_SETTINGS, + MENU_HEADSET_SETTINGS, // most likely + MENU_VIDEO_SETTINGS, + MENU_BONUS_FEATURES, + MENU_BONUS_PREVIEW, + MENU_GAME_COMPLETED, + MENU_GAMMA_SETTINGS, + MENU_CONTROL_SETTINGS, + MENU_RESTORE_DEFAULTS, + MENU_19, + MENU_CREDITS, + // pc exclusive + MENU_REMAP_CONTROLS, + MENU_QUIT, +}; + +enum eFontType { + FONT_TYPE_DEBUG, + FONT_TYPE_DEFAULT, + FONT_FRONTEND, + FONT_TYPE_LOADING +}; + + +struct CRGBA { + int r, g, b, a; +}; + + + +struct CRGB3 { + int r, g, b; +}; + + +class CFrontend { +public: + static int& ms_devMenu; + static int& ms_draw2d; + static int& ms_misc; + static int& m_gameIsRunning; + static int& ms_cnt; + // menu stuff + static bool& m_bNewGame; + static int& ms_currentMenu; + static int& ms_lastMenu; + static int& ms_menuButton; + static float& ms_fTextXScale; + static float& ms_fTextYScale; + static float& ms_fMenuPositionX; + static float& ms_fMenuPositionY; + static float& ms_fTextAdjust; + static int& ms_mouseHoverButton; + static int& NumStoredHalos; + + static CRGBA& ColorSet1; + static CRGBA& ColorSet2; + static CRGBA& ColorSet3; + static CRGBA& ColorSet4; + + + static void SetLevel(int level); + static void ForceLevel(int level); + + + static void SetCurrentMenu(int menu); + static void DrawMenuCameraCounter(wchar_t* text); + static void AddOption(wchar_t* text, float x, float y, float textScaleX, float textScaleY, int menuID); + static int GetHoveredItem(); + static void SetDrawRGBA(int r, int g, int b, int a); + static void Print8(const char* text, float x, float y, float sizex, float sizey, float unk, eFontType font); + static void SetMenuBackground(char* file); + static void PrintInfo(wchar_t* button1, wchar_t* button2, wchar_t* button3, wchar_t* button4); + + static int GetTextureFromTXD(int txd, const char* texture); + + static float CalculateTextLen(wchar_t* text, float charScale, int byteLen); + + static void DrawDisc2D(CVector* pos, float scale, int red, int green, int blue, float a6); + static void DrawDisc3D(CVector* pos, float scale, int red, int green, int blue, float a6); + +}; \ No newline at end of file diff --git a/source/code/manhunt/Input.cpp b/source/code/manhunt/Input.cpp new file mode 100644 index 0000000..2f1cffc --- /dev/null +++ b/source/code/manhunt/Input.cpp @@ -0,0 +1,34 @@ +#include "Input.h" +#include "core.h" + +bool& CInputManager::m_bInputEnabled = *(bool*)0x725710; + +bool CInputManager::FrontendControlsAvailable() +{ + return CallAndReturn(); +} + +bool CInputManager::FrontendPressedUp() +{ + return CallAndReturn(); +} + +bool CInputManager::FrontendPressedDown() +{ + return CallAndReturn(); +} + +bool CInputManager::FrontedMouseHovered() +{ + return CallAndReturn(); +} + +bool CInputManager::FrontendPressedEscape() +{ + return CallAndReturn(); +} + +bool CInputManager::FrontendButtonEnter() +{ + return CallAndReturn(); +} diff --git a/source/code/manhunt/Input.h b/source/code/manhunt/Input.h new file mode 100644 index 0000000..f281837 --- /dev/null +++ b/source/code/manhunt/Input.h @@ -0,0 +1,15 @@ +#pragma once + +class CInputManager { +public: + static bool& m_bInputEnabled; + + + static bool FrontendControlsAvailable(); + static bool FrontendPressedUp(); + static bool FrontendPressedDown(); + static bool FrontendPressedEscape(); + static bool FrontendButtonEnter(); + + static bool FrontedMouseHovered(); +}; \ No newline at end of file diff --git a/source/code/manhunt/Inventory.cpp b/source/code/manhunt/Inventory.cpp new file mode 100644 index 0000000..835496d --- /dev/null +++ b/source/code/manhunt/Inventory.cpp @@ -0,0 +1,32 @@ +#include "Inventory.h" +#include "core.h" + + +int& CGameInventory::ms_inv = *(int*)0x7C9CD0; +int& CGameInventory::ms_curRedItem = *(int*)0x7C9CE8; +int& CGameInventory::ms_curBlueItem = *(int*)0x7C9CEC; +int& CGameInventory::ms_curGreenItem = *(int*)0x7C9CF0; +int& CGameInventory::ms_curThrowableItem = *(int*)0x7C9CF4; + +int CGameInventory::GetCurrentItem() +{ + switch (ms_inv) + { + case BACK: + return ms_curRedItem; break; + case BELT_RIGHT: + return ms_curBlueItem; break; + case BELT_LEFT: + return ms_curGreenItem; break; + case BELT_REAR: + return ms_curThrowableItem; break; + default: + return -1; + break; + } +} + +int CInventory::FindItemWithCollectableType(int ptr, int collectable) +{ + return CallMethodAndReturn(ptr, collectable); +} diff --git a/source/code/manhunt/Inventory.h b/source/code/manhunt/Inventory.h new file mode 100644 index 0000000..6812781 --- /dev/null +++ b/source/code/manhunt/Inventory.h @@ -0,0 +1,28 @@ +#pragma once + +enum eInventorySlots { + BACK = 1, + BELT_RIGHT, + BELT_LEFT, + BELT_REAR, + SPECIAL +}; + + +class CGameInventory { +public: + static int& ms_inv; + static int& ms_curRedItem; + static int& ms_curBlueItem; + static int& ms_curGreenItem; + static int& ms_curThrowableItem; + + static int GetCurrentItem(); +}; + +class CInventory { +private: + void* vTable; +public: + static int FindItemWithCollectableType(int ptr, int collectable); +}; \ No newline at end of file diff --git a/source/code/manhunt/MaterialMananger.h b/source/code/manhunt/MaterialMananger.h new file mode 100644 index 0000000..ee10d22 --- /dev/null +++ b/source/code/manhunt/MaterialMananger.h @@ -0,0 +1,69 @@ +#pragma once + +enum eMaterialClass : short +{ + MATERIAL_BAD = -1, + MATERIAL_NONE = 0x0, + MATERIAL_STONE = 0x1, + MATERIAL_WOOD = 0x2, + MATERIAL_METAL = 0x3, + MATERIAL_PAPER = 0x4, + MATERIAL_RUBBLE = 0x5, + MATERIAL_TILE = 0x6, + MATERIAL_CAR = 0x7, + MATERIAL_WIREMESH = 0x8, + MATERIAL_PLASTICBAG = 0x9, + MATERIAL_DUMPSTER = 0xA, + MATERIAL_STREETLIGHT = 0xB, + MATERIAL_OPANDTRWINDOW = 0xC, + MATERIAL_PEDBARRIER = 0xD, + MATERIAL_METALRAILING = 0xE, + MATERIAL_PUDDLE = 0xF, + MATERIAL_IGNORE = 0x10, + MATERIAL_GLASSHARD = 0x11, + MATERIAL_CERAMIC = 0x12, + MATERIAL_PLASTER = 0x13, + MATERIAL_WOODHARD = 0x14, + MATERIAL_METALHARD = 0x15, + MATERIAL_GRASS = 0x16, + MATERIAL_MUD = 0x17, + MATERIAL_BUSH = 0x18, + MATERIAL_WATER = 0x19, + MATERIAL_CARPET = 0x1A, + MATERIAL_PED = 0x1B, + MATERIAL_WEAPON = 0x1C, + MATERIAL_HALFOPENSHUTTER = 0x1D, + MATERIAL_BRICK = 0x1E, + MATERIAL_CAN = 0x1F, + MATERIAL_BOTTLE = 0x20, + MATERIAL_WOOD_PLANK = 0x21, + MATERIAL_WOOD_BOARD = 0x22, + MATERIAL_WOOD_DOOR = 0x23, + MATERIAL_WOOD_BIG_DOOR = 0x24, + MATERIAL_WOOD_THIN = 0x25, + MATERIAL_WOOD_TRUNK = 0x26, + MATERIAL_METAL_SMALL_SHUTTER = 0x27, + MATERIAL_METAL_LARGE_SHUTTER = 0x28, + MATERIAL_METAL_CAGE_SHUTTER = 0x29, + MATERIAL_METAL_THICK_METAL_PLATE = 0x2A, + MATERIAL_METAL_POLE = 0x2B, + MATERIAL_METAL_CONTAINER = 0x2C, + MATERIAL_SOFT = 0x2D, + MATERIAL_TYRE = 0x2E, + MATERIAL_PLASTIC = 0x2F, + MATERIAL_TARMAC = 0x30, + MATERIAL_TRASHCAN = 0x31, + MATERIAL_PEDBARRIER_WOOD = 0x32, + MATERIAL_PEDBARRIER_METAL = 0x33, + MATERIAL_PEDBARRIER_STONE = 0x34, + MATERIAL_GORE = 0x35, + MATERIAL_WET_MUD = 0x36, + MATERIAL_WHEELY_BIN = 0x37, + MATERIAL_SHOPPING_TROLLEY = 0x38, + MATERIAL_PIGSY_GRATING = 0x39, + MATERIAL_BUSH_SOLID = 0x3A, + MATERIAL_PEDBARRIER_CARPET = 0x3B, + MATERIAL_OPAQUEGLASS = 0x3C, + MATERIAL_PEDBARRIER_WIREMESH = 0x3D, + MATERIAL_IRON_BAR_DOOR = 0x3E, +}; diff --git a/source/code/manhunt/Misc.cpp b/source/code/manhunt/Misc.cpp new file mode 100644 index 0000000..410a7b3 --- /dev/null +++ b/source/code/manhunt/Misc.cpp @@ -0,0 +1,12 @@ +#include "Misc.h" +#include "core.h" + +CFile * Rockstar_fopen(int mode, int fMode, char * extraParam) +{ + return CallAndReturn(mode, fMode, extraParam); +} + +int ReadFileBytes(CFile * src, int dst, int size) +{ + return CallAndReturn(src, dst, size); +} diff --git a/source/code/manhunt/Misc.h b/source/code/manhunt/Misc.h new file mode 100644 index 0000000..0866a75 --- /dev/null +++ b/source/code/manhunt/Misc.h @@ -0,0 +1,18 @@ +#pragma once +// unknown file functions + +struct CFile { + int m_nLastMode; + int m_nLastFileMode; + int field8; + int field12; // unused? in most cases set to 0 + int m_nBufferSize; + int m_pFilePointer; + int field24; + int field28; + int field32; // always 1? +}; + + +CFile* Rockstar_fopen(int mode, int fMode, char* extraParam); +int ReadFileBytes(CFile* src, int dst, int size); \ No newline at end of file diff --git a/source/code/manhunt/Player.cpp b/source/code/manhunt/Player.cpp new file mode 100644 index 0000000..9e109f1 --- /dev/null +++ b/source/code/manhunt/Player.cpp @@ -0,0 +1,17 @@ +#include "Player.h" +#include "core.h" + +void CPlayer::StartLookAround() +{ + CallMethod<0x462060, CEntity*>(this); +} + +void CPlayer::ForcePlayAnim(const char * name) +{ + CallMethod<0x46E390, CEntity*, const char*>(this, name); +} + +void CPlayer::ForcePlayFullBodyAnim(const char * name) +{ + CallMethod<0x46E260, CEntity*, const char*>(this, name); +} diff --git a/source/code/manhunt/Player.h b/source/code/manhunt/Player.h new file mode 100644 index 0000000..9038d04 --- /dev/null +++ b/source/code/manhunt/Player.h @@ -0,0 +1,9 @@ +#pragma once +#include "Entity.h" + +class CPlayer: public CEntity { +public: + void StartLookAround(); + void ForcePlayAnim(const char* name); + void ForcePlayFullBodyAnim(const char* name); +}; \ No newline at end of file diff --git a/source/code/manhunt/Renderer.cpp b/source/code/manhunt/Renderer.cpp new file mode 100644 index 0000000..0abcd25 --- /dev/null +++ b/source/code/manhunt/Renderer.cpp @@ -0,0 +1,38 @@ +#include "Renderer.h" +#include "core.h" + +void CRenderer::PushRenderStateBlend() +{ + Call<0x5F5CF0>(); +} + + +void CRenderer::PushAndSetRenderState(RwRenderState state, void* value) +{ + Call<0x5F5E60, RwRenderState, void*>(state, value); +} + +void CRenderer::RenderStateSetBlend(RwBlendFunction state, RwBlendFunction value) +{ + Call<0x5F5C90, RwBlendFunction, RwBlendFunction>(state, value); +} + +void CRenderer::SetIngameInfoRenderStates(int value) +{ + Call<0x5F5A80, int>(value); +} + +void CRenderer::PopRenderStateAll() +{ + Call<0x5F5E10>(); +} + +void CRenderer::PopRenderStateBlend() +{ + Call<0x5F5D30>(); +} + +void CRenderer::DrawQuad2d(float posX, float posY, float scaleX, float scaleY, int red, int green, int blue, int alpha, int pTexture) +{ + Call<0x5F96F0, float, float, float, float, int, int, int, int, int>(posX, posY, scaleX, scaleY, red, green, blue, alpha, pTexture); +} diff --git a/source/code/ManhuntRW.h b/source/code/manhunt/Renderer.h similarity index 83% rename from source/code/ManhuntRW.h rename to source/code/manhunt/Renderer.h index 9476666..32c6456 100644 --- a/source/code/ManhuntRW.h +++ b/source/code/manhunt/Renderer.h @@ -1,8 +1,5 @@ #pragma once - -// rw stuff - enum RwRenderState { rwRENDERSTATENARENDERSTATE = 0x0, @@ -36,7 +33,6 @@ enum RwRenderState rwRENDERSTATESTENCILFUNCTIONWRITEMASK = 0x1C, }; - enum RwBlendFunction { rwBLENDNABLEND = 0x0, @@ -53,7 +49,6 @@ enum RwBlendFunction rwBLENDSRCALPHASAT = 0xB, }; - enum RwFogType { rwFOGTYPENAFOGTYPE = 0x0, @@ -62,7 +57,6 @@ enum RwFogType rwFOGTYPEEXPONENTIAL2 = 0x3, }; - enum RwTextureFilterMode { rwFILTERNAFILTERMODE = 0x0, @@ -74,7 +68,6 @@ enum RwTextureFilterMode rwFILTERLINEARMIPLINEAR = 0x6, }; - enum RwTextureAddressMode { rwTEXTUREADDRESSNATEXTUREADDRESS = 0x0, @@ -92,7 +85,6 @@ enum RwCullMode rwCULLMODECULLFRONT = 0x3, }; - enum RwPrimitiveType { rwPRIMTYPENAPRIMTYPE = 0x0, @@ -106,7 +98,13 @@ enum RwPrimitiveType - - -void RwRenderStateSet(RwRenderState state, int value); -void RwRenderStateSetA(RwRenderState state, int value); \ No newline at end of file +class CRenderer { +public: + static void PushRenderStateBlend(); + static void PushAndSetRenderState(RwRenderState state, void* value); + static void RenderStateSetBlend(RwBlendFunction state, RwBlendFunction value); + static void SetIngameInfoRenderStates(int value); + static void PopRenderStateAll(); + static void PopRenderStateBlend(); + static void DrawQuad2d(float posX, float posY, float scaleX, float scaleY, int red, int green, int blue, int alpha, int pTexture); +}; \ No newline at end of file diff --git a/source/code/manhunt/Scene.cpp b/source/code/manhunt/Scene.cpp new file mode 100644 index 0000000..8366d25 --- /dev/null +++ b/source/code/manhunt/Scene.cpp @@ -0,0 +1,31 @@ +#include "Scene.h" +#include "core.h" +#include "Anim.h" + +bool& CScene::ms_bFreeCam = *(bool*)0x715BB0; +int& CScene::ms_stepMode = *(int*)0x715BA0; +CEntity*& CScene::ms_pPlayer = *(CEntity**)0x715B9C; +CEntity*& CScene::ms_pCamera = *(CEntity**)0x715B94; +void CScene::OpenLevel(const char * level) +{ + Call<0x474330, const char*>(level); +} + +CEntity * CScene::FindPlayer() +{ + return *(CEntity**)0x715B9C; +} + +void CScene::PlayerFullBodyAnimDone() +{ + int* player = *(int**)0x715B9C; + if (!player[448] && player[439]) + { + player[439] = 0; + player[440] = 0; + } + if (!player[448]) + player[440] = 0; + player[441] = 0; + CPedBodyAnimFSM::SetStand(player[190], 854); +} diff --git a/source/code/manhunt/Scene.h b/source/code/manhunt/Scene.h new file mode 100644 index 0000000..d6ffed2 --- /dev/null +++ b/source/code/manhunt/Scene.h @@ -0,0 +1,15 @@ +#pragma once +#include "Entity.h" + + +class CScene { +public: + static bool& ms_bFreeCam; + // also known as freeze world + static int& ms_stepMode; + static CEntity*& ms_pPlayer; + static CEntity*& ms_pCamera; + static void OpenLevel(const char* level); + static CEntity* FindPlayer(); + static void PlayerFullBodyAnimDone(); +}; \ No newline at end of file diff --git a/source/code/manhunt/Script.cpp b/source/code/manhunt/Script.cpp new file mode 100644 index 0000000..3a7e1b3 --- /dev/null +++ b/source/code/manhunt/Script.cpp @@ -0,0 +1,17 @@ +#include "Script.h" +#include "core.h" + +int CScriptLoader::LoadScriptFile(const char * file) +{ + return CallAndReturn(file); +} + +int CScriptVM::PopInt() +{ + return CallMethodAndReturn(this); +} + +char* CScriptVM::PopCharStar() +{ + return CallMethodAndReturn(this); +} diff --git a/source/code/manhunt/Script.h b/source/code/manhunt/Script.h new file mode 100644 index 0000000..9e96306 --- /dev/null +++ b/source/code/manhunt/Script.h @@ -0,0 +1,21 @@ +#pragma once + +class CScriptLoader { +public: + + static int LoadScriptFile(const char* file); +}; + +class CScriptVM { +public: + int field0; + char pad[28]; + int m_returnValue; + char _pad[1092]; + int m_commandID; + char __pad[28]; + int m_hogProcessorValue; + + int PopInt(); + char* PopCharStar(); +}; \ No newline at end of file diff --git a/source/code/manhunt/Shot.h b/source/code/manhunt/Shot.h new file mode 100644 index 0000000..8fc3168 --- /dev/null +++ b/source/code/manhunt/Shot.h @@ -0,0 +1,84 @@ +#pragma once +#include "Weapon.h" +enum eShotClass { + SC_BASIC, + SC_INSTANT, + SC_INSTANT_MACHINEGUN, + SC_MELEE, + SC_MELEE_KICK, + SC_MELEE_OBSTRUCT, + SC_PROJECTILE, + SC_PROJECTILE_WEAPON, + SC_AREA +}; + +enum eShotPrimitive { + SP_LINE, + SP_SPHERE +}; + +enum eArmorType { + ARM_NONE, + ARM_LIGHT, + ARM_MEDIUM, + ARM_HEAVY, + ARM_INVULNERABLE +}; + + +class CShotTypeData { +public: + void* vTable; + eShotClass m_nShotClass; + eShotPrimitive m_nShotPrimitive; + int field12; + int field16; + float m_fSize; + float m_fDamage; + float m_fPlayerDamage; + float m_fSideDamage; + float m_fBackDamage; + eArmorType m_nArmorType; + float m_fAliveTime; + float m_fShotForce; + int m_nBodiesHit; + float m_fTranqTime; + char* m_szHardBSPHitFx; + int field64; + char* m_szSoftBSPHitFx; + int field72; + char* m_szCharacterHitFx; + int field80; + char* m_szSmokeBSPHitFx; + int field88; + int field92; + int field96; + char* m_szStreakFx; + int field104; + char* m_szFlashFx; + int field112; + int m_fxHardHit; + int m_fxSoftHit; + int m_fxSmokeHit; + int m_fxCharacterHit; + int m_fxStreak; + int m_fxFlash; +}; + +class CAreaShotTypeData : public CShotTypeData { +public: + float m_fInitRadius; + float m_fFinalRadius; + float m_fExpansionTime; +}; + + + + + +class CShot { + void* vTable; + CShotTypeData* m_TypeData; + CWeapon * m_pWeapon; +}; + diff --git a/source/code/manhunt/SpecialFX.cpp b/source/code/manhunt/SpecialFX.cpp new file mode 100644 index 0000000..bdc0fe0 --- /dev/null +++ b/source/code/manhunt/SpecialFX.cpp @@ -0,0 +1,23 @@ +#include "SpecialFX.h" +#include "core.h" + +int CSFXManager::GetArchetypeFromName(const char * name) +{ + return CallAndReturn(name); +} + +void CSFXManager::SetPosition(CParticleEffect * effect, CVector* position) +{ + float len = CallAndReturn(position); + float mult = 1.0f / len; + effect->m_nParticlePosition = *position; + effect->m_nParticlePosition.x *= mult; + effect->m_nParticlePosition.y *= mult; + effect->m_nParticlePosition.z *= mult; + (*((void(__thiscall **)(CParticleEffect *))effect->vTable + 4))(effect); +} + +CParticleEffect * CSFXManager::NewSFX(int archetype) +{ + return CallAndReturn(archetype); +} diff --git a/source/code/manhunt/SpecialFX.h b/source/code/manhunt/SpecialFX.h new file mode 100644 index 0000000..1358bc1 --- /dev/null +++ b/source/code/manhunt/SpecialFX.h @@ -0,0 +1,189 @@ +#pragma once +#include "Vector.h" + +struct CParticleEffect +{ + void *vTable; + int field_4; + char field_8; + char field_9; + char field_A; + char field_B; + char field_C; + char field_D; + char field_E; + char field_F; + int field_10; + int field_14; + char field_18; + char field_19; + char field_1A; + char field_1B; + char field_1C; + char field_1D; + char field_1E; + char field_1F; + char field_20; + char field_21; + char field_22; + char field_23; + char field_24; + char field_25; + char field_26; + char field_27; + char field_28; + char field_29; + char field_2A; + char field_2B; + int field_2C; + float field_30; + char field_34; + char field_35; + char field_36; + char field_37; + char field_38; + char field_39; + char field_3A; + char field_3B; + CVector m_nParticlePosition; + CVector field_48; + char field_54; + char field_55; + char field_56; + char field_57; + int field_58; + int field_5C; + int field_60; + char field_64; + char field_65; + char field_66; + char field_67; + int field_68; + int field_6C; + int field_70; + int field_74; + int field_78; + int field_7C; + char field_80; + char field_81; + char field_82; + char field_83; + char field_84; + char field_85; + char field_86; + char field_87; + char field_88; + char field_89; + char field_8A; + char field_8B; + int field_8C; + int field_90; + int field_94; + char field_98; + char field_99; + char field_9A; + char field_9B; + char field_9C; + char field_9D; + char field_9E; + char field_9F; + char field_A0; + char field_A1; + char field_A2; + char field_A3; + char field_A4; + char field_A5; + char field_A6; + char field_A7; + char field_A8; + char field_A9; + char field_AA; + char field_AB; + char field_AC; + char field_AD; + char field_AE; + char field_AF; + char field_B0; + char field_B1; + char field_B2; + char field_B3; + char field_B4; + char field_B5; + char field_B6; + char field_B7; + char field_B8; + char field_B9; + char field_BA; + char field_BB; + char field_BC; + char field_BD; + char field_BE; + char field_BF; + int field_C0; + char field_C4; + char field_C5; + char field_C6; + char field_C7; + char field_C8; + char field_C9; + char field_CA; + char field_CB; + char field_CC; + char field_CD; + char field_CE; + char field_CF; + char field_D0; + char field_D1; + char field_D2; + char field_D3; + char field_D4; + char field_D5; + char field_D6; + char field_D7; + int field_D8; + char field_DC; + char field_DD; + char field_DE; + char field_DF; + char field_E0; + char field_E1; + char field_E2; + char field_E3; + char field_E4; + char field_E5; + char field_E6; + char field_E7; + char field_E8; + char field_E9; + char field_EA; + char field_EB; + char field_EC; + char field_ED; + char field_EE; + char field_EF; + char field_F0; + char field_F1; + char field_F2; + char field_F3; + char field_F4; + char field_F5; + char field_F6; + char field_F7; + char field_F8; + char field_F9; + char field_FA; + char field_FB; + char field_FC; + char field_FD; + char field_FE; + char field_FF; +}; + + + +class CSFXManager { +public: + static int GetArchetypeFromName(const char* name); + static void SetPosition(CParticleEffect* effect, CVector* position); + static CParticleEffect* NewSFX(int archetype); +}; \ No newline at end of file diff --git a/source/code/manhunt/String.cpp b/source/code/manhunt/String.cpp new file mode 100644 index 0000000..57553a0 --- /dev/null +++ b/source/code/manhunt/String.cpp @@ -0,0 +1,14 @@ +#include "String.h" +#include "core.h" + +CString::CString() +{ + str = 0; + len = 0; + cap = 0; +} + +void CString::__as(CString * src, CString * dest) +{ + Call<0x4F2A90, CString*, CString*>(src, dest); +} diff --git a/source/code/manhunt/String.h b/source/code/manhunt/String.h new file mode 100644 index 0000000..30771f0 --- /dev/null +++ b/source/code/manhunt/String.h @@ -0,0 +1,11 @@ +#pragma once + +struct CString +{ + char *str; + short len; + short cap; + + CString(); + void __as(CString* src, CString* dest); +}; diff --git a/source/code/manhunt/Text.cpp b/source/code/manhunt/Text.cpp new file mode 100644 index 0000000..e1a63de --- /dev/null +++ b/source/code/manhunt/Text.cpp @@ -0,0 +1,7 @@ +#include "Text.h" +#include "..\manhunt\core.h" + +wchar_t * CText::GetFromKey16(const char * key) +{ + return CallMethodAndReturn(0x725A38, key); +} diff --git a/source/code/manhunt/Text.h b/source/code/manhunt/Text.h new file mode 100644 index 0000000..68befae --- /dev/null +++ b/source/code/manhunt/Text.h @@ -0,0 +1,6 @@ +#pragma once + +class CText { +public: + static wchar_t* GetFromKey16(const char* key); +}; \ No newline at end of file diff --git a/source/code/manhunt/Time.cpp b/source/code/manhunt/Time.cpp new file mode 100644 index 0000000..c3a3069 --- /dev/null +++ b/source/code/manhunt/Time.cpp @@ -0,0 +1,14 @@ +#include "Time.h" +#include "core.h" + +int& CGameTime::ms_startRealTime = *(int*)0x756268; +int& CGameTime::ms_realTimeOffset = *(int*)0x75626C; +int& CGameTime::ms_currGameTime = *(int*)0x756270; +int& CGameTime::ms_currGameTimePaused= *(int*)0x756274; +int& CGameTime::ms_timeStep = *(int*)0x756280; +int& CGameTime::ms_currFrame = *(int*)0x75628C; + +void CGameTime::Update() +{ + Call<0x4D87D0>(); +} diff --git a/source/code/manhunt/Time.h b/source/code/manhunt/Time.h new file mode 100644 index 0000000..92e6b16 --- /dev/null +++ b/source/code/manhunt/Time.h @@ -0,0 +1,12 @@ +#pragma once + +class CGameTime { +public: + static int& ms_startRealTime; + static int& ms_realTimeOffset; + static int& ms_currGameTime; + static int& ms_currGameTimePaused; + static int& ms_timeStep; + static int& ms_currFrame; + static void Update(); +}; \ No newline at end of file diff --git a/source/code/manhunt/TypeData.h b/source/code/manhunt/TypeData.h new file mode 100644 index 0000000..8d56ace --- /dev/null +++ b/source/code/manhunt/TypeData.h @@ -0,0 +1,142 @@ +#pragma once +#include "Entity.h" +#include "Vector.h" +#include "Shot.h" +#include "MaterialMananger.h" + +enum eEntityClass { + EC_BASIC = 0x1, + EC_3 = 0x3, + EC_PED = 0x7, + EC_F = 0xF, + EC_HUNTER = 0x1F, + EC_LEADER = 0x3F, + EC_7F = 0x7F, + EC_83 = 0x83, + EC_183 = 0x183, + EC_PLAYER = 0x20F, + EC_ENTITYLIGHT = 0x401, + EC_COLLECTABLE = 0x1001, + EC_WEAPON = 0x3001, + EC_RESPONDER = 0x7001, + EC_SHOT = 0x8001, + EC_LIFT = 0x10001, + EC_DOOR = 0x60001, + EC_SLIDEDOOR = 0x200001, + EC_SWITCH = 0xA0001, + EC_TRIGGER = 0x400001, + EC_CAMERADATA = 0x20000001, + EC_SENSOR = 0x800001, + EC_PEDHEAD = 0x1000001, + EC_CLIMABLE = 0x120001, + EC_USEABLE = 0x20001, + EC_CONVEYOR = 0x2000001, + EC_MOVER = 0x4000001, + +}; + +class CTypeData { +public: + void *vTable; + eEntityClass m_ecEntityClass; + int m_nEntityFlags; + int field_C; + __int16 field_10; + char field_12; + char field_13; + char field_14; + char field_15; + char field_16; + char field_17; + char *m_szModel; + char field_1C; + char field_1D; + char field_1E; + char field_1F; + char field_20; + char field_21; + char field_22; + char field_23; + char *m_szCollisionData; + char field_28; + char field_29; + char field_2A; + char field_2B; + char *m_szAnimationBlock; + char field_30; + char field_31; + char field_32; + char field_33; + int m_pPhysics; + int field_38; + int field_3C; + int field_40; + int m_pSounds; + eMaterialClass m_iMaterialID; + __declspec(align(4)) char field_4C; + char field_4D; + char field_4E; + char field_4F; + float m_fLODDistance; + int field_54; + int field_58; + int field_5C; + int field_60; + char field_64; + char field_65; + char field_66; + char field_67; + char field_68; + char field_69; + char field_6A; + char field_6B; + char field_6C; + char field_6D; + char field_6E; + char field_6F; + char *field_70; + char field_74; + char field_75; + char field_76; + char field_77; + char field_78; + char field_79; + char field_7A; + char field_7B; + CTypeData *field_7C; + int field_80; + char field_84; + char field_85; + char field_86; + char field_87; + int m_nHitPoints; + eArmorType m_nArmorType; + float m_fImpulseLimit; + int m_iEntityFlags; + CVector m_vLightAnchor; + char *m_szSpawnEntity; + char field_A8; + char field_A9; + char field_AA; + char field_AB; + char *m_szDamageSpawnEntity; + char field_B0; + char field_B1; + char field_B2; + char field_B3; + CVector m_vSpawnPosition; + CVector m_vSpawnVelocity; + float BND_SPH_BOOST; + int m_fxDamage; + int field_D4; + int field_D8; + int field_DC; + int field_E0; + int field_E4; + int field_E8; + int field_EC; + bool m_bCameraCollidable; + char field_F1; + char field_F2; + char field_F3; +}; \ No newline at end of file diff --git a/source/code/manhunt/Vector.h b/source/code/manhunt/Vector.h new file mode 100644 index 0000000..22e544e --- /dev/null +++ b/source/code/manhunt/Vector.h @@ -0,0 +1,9 @@ +#pragma once + +struct CVector2D { + float x, y; +}; + +struct CVector { + float x, y, z; +}; \ No newline at end of file diff --git a/source/code/manhunt/Weapon.h b/source/code/manhunt/Weapon.h new file mode 100644 index 0000000..7685caf --- /dev/null +++ b/source/code/manhunt/Weapon.h @@ -0,0 +1,77 @@ +#pragma once +#include "Vector.h" + +enum eWeaponClass { + WC_MELEE, + WC_MELEE_KICK, + WC_THROWING, + WC_AMMO, + WC_EXPLODER +}; + +class CWeaponTypeData { +public: + void* vTable; + eWeaponClass m_eWeaponClass; + int field8; + int field12; + char* m_szShotType; + int field20; + char* m_szShotType2; + int field28; + char* m_szSpecialWeaponAnim; +}; + +struct CWeapon +{ + void *vTable; + CWeaponTypeData *m_TypeData; + int field_8; + int field_C; + int field_10; + int field_14; + __declspec(align(16)) int field_20; + int field_24; + int field_28; + int field_2C; + int field_30; + int field_34; + int field_38; + int field_3C; + char field_40; + char field_41; + char field_42; + char field_43; + char field_44; + char field_45; + char field_46; + char field_47; + char field_48; + char field_49; + char field_4A; + char field_4B; + char field_4C; + char field_4D; + char field_4E; + char field_4F; + char field_50; + char field_51; + char field_52; + char field_53; + char field_54; + char field_55; + char field_56; + char field_57; + int field_58; + int field_5C; + int field_60; + int field_64; + int field_68; + int field_6C; + int field_70; + int field_74; + CVector m_vFireDirection; + int field_84; + int field_88; + int field_8C; +}; \ No newline at end of file diff --git a/source/code/manhunt/core.h b/source/code/manhunt/core.h new file mode 100644 index 0000000..d1b3794 --- /dev/null +++ b/source/code/manhunt/core.h @@ -0,0 +1,43 @@ +#pragma once +#include +#include +#include "..\..\MemoryMgr.h" + +typedef unsigned char uint8; +typedef unsigned int uint32; + +#define _DUMMY printf("Function not done: %s\n",__FUNCTION__); + +// calling +template +static void Call(Args... args) { + reinterpret_cast(address)(args...); +} + +template +static Ret CallAndReturn(Args... args) { + return reinterpret_cast(address)(args...); +} + +template +static void STDCall(Args... args) { + reinterpret_cast(address)(args...); +} + +template +static Ret STDCallAndReturn(Args... args) { + return reinterpret_cast(address)(args...); +} + + +template +static void CallMethod(C _this, Args... args) { + reinterpret_cast(address)(_this, args...); +} + +template +static Ret CallMethodAndReturn(C _this, Args... args) { + return reinterpret_cast(address)(_this, args...); +} + +using namespace Memory::VP; diff --git a/source/code/plugin/MHcommon.cpp b/source/code/plugin/MHcommon.cpp new file mode 100644 index 0000000..7ee6095 --- /dev/null +++ b/source/code/plugin/MHcommon.cpp @@ -0,0 +1,59 @@ +#include "MHcommon.h" +#include "..\manhunt\core.h" +#include "..\manhunt\Vector.h" +#include "..\manhunt\EntityManager.h" +#include "..\manhunt\CreationManager.h" +#include "..\plugin\console\eConsole.h" +#include "..\manhunt\Character.h" +#include "..\manhunt\AmmoWeapon.h" +#include "..\manhunt\Inventory.h" +#include "..\manhunt\Scene.h" +#include "..\manhunt\AI.h" + +void CreateEntity(char * name, CVector* pos) +{ + + CTypeData* typeData = CEntityManager::GetEntityTypeDataFromName(name); + + if (!typeData) + { + TheConsole.m_messages.push_back("Entity does not exist - " + (std::string)name); + } + if (typeData) + { + CEntity* entity = CCreationManager::CreateEntity(typeData); + if (entity) + { + char tmp[256]; + sprintf(tmp, "entity%d", TheConsole.m_entityID); + entity->SetName(tmp); + sprintf(tmp, "Created - %s [%x] [entity%d]", name, entity, TheConsole.m_entityID); + TheConsole.m_messages.push_back(tmp); + entity->SetFrozen(0); + entity->Spawn(pos, 0); + + TheConsole.m_entityID++; + } + } +} + +void GiveWeaponToEntity(CEntity * ent, int weaponID) +{ + if (ent) + { + CCharacter::CreateInventoryItem(ent, weaponID, true); + int inventory_handle = *(int*)((int)ent + 336); + int item = CInventory::FindItemWithCollectableType(inventory_handle, weaponID); + CAmmoWeapon* weapon = (CAmmoWeapon*)*(int*)(item + 428); + weapon->SetAmmo(1000); + + char tmp[256]; + sprintf(tmp, "[%x] - Weapon %d spawned", ent, weaponID); + TheConsole.m_messages.push_back(tmp); + } +} + +void GiveWeaponToPlayer(int weaponID) +{ + GiveWeaponToEntity(CScene::FindPlayer(), weaponID); +} diff --git a/source/code/plugin/MHcommon.h b/source/code/plugin/MHcommon.h new file mode 100644 index 0000000..df46d72 --- /dev/null +++ b/source/code/plugin/MHcommon.h @@ -0,0 +1,7 @@ +#pragma once +#include "..\manhunt\Vector.h" +#include "..\manhunt\Entity.h" +void CreateEntity(char* name, CVector* pos); +void GiveWeaponToEntity(CEntity* ent, int weaponID); + +void GiveWeaponToPlayer(int weaponID); \ No newline at end of file diff --git a/source/code/plugin/console/eConsole.cpp b/source/code/plugin/console/eConsole.cpp new file mode 100644 index 0000000..d29a9cf --- /dev/null +++ b/source/code/plugin/console/eConsole.cpp @@ -0,0 +1,333 @@ +#include "eConsole.h" +#include "..\..\manhunt\Frontend.h" +#include "..\..\manhunt\Input.h" +#include "..\..\manhunt\core.h" +#include "..\..\manhunt\EntityManager.h" +#include "..\..\manhunt\Scene.h" +#include "..\..\manhunt\SpecialFX.h" +#include "..\MHcommon.h" +#include "..\menu\eMenu.h" +eConsole TheConsole; + +using namespace ConsoleCommands; + +eConsole::eConsole() +{ + m_consoleActive = false; + m_currentCommand = 0; + m_entityID = 0; +} + +void eConsole::Process() +{ + + std::string message = "> "; + message += m_currentMessage; + + + for (int i = 0; i < m_messages.size(); i++) + { + CFrontend::SetDrawRGBA(255, 255, 255, 190); + CFrontend::Print8(m_messages[i].c_str(), 0.0, 0.85f - (0.025f * i), 0.85f, 0.85f, 0.0f, FONT_TYPE_DEBUG); + } + + CFrontend::SetDrawRGBA(255, 255, 255, 255); + CFrontend::Print8(message.c_str(), 0.0, 0.95f, 1.0f, 1.0f, 0.0f, FONT_TYPE_DEBUG); +} + +void eConsole::PushCharacter(char chr) +{ + if (chr == 0x60) + return; + + m_currentMessage += chr; +} + +void eConsole::ScrollMessage(int direction) +{ + if (m_commands.size() <= 0) + return; + + m_currentCommand--; + if (m_currentCommand < 0) + m_currentCommand = 0; + + m_currentMessage = m_commands[m_currentCommand]; +} + +void eConsole::RemoveLastCharacter() +{ + m_currentMessage = m_currentMessage.substr(0, m_currentMessage.size() - 1); +} + +void eConsole::Execute() +{ + if (m_currentMessage.size() == 0) + return; + + m_commands.push_back(m_currentMessage); + + char* function = ""; + char* args = ""; + char* szLine = ""; + + szLine = (char*)m_currentMessage.c_str(); + + function = strtok(szLine, " "); + args = (function + strlen(function) + 1); + + ExecuteCommand(function, args); + function[0]= 0; + args[0] = 0; + + m_currentMessage = ""; + m_currentMessage.clear(); + m_currentCommand++; + +} + +void eConsole::ExecuteCommand(char * command, char * args) +{ + char* tmp = command; + + for (int i = 0; i < strlen(tmp); i++) + tmp[i] = tolower(tmp[i]); + + std::string cmd = tmp; + + + if (cmd == "help") help(args); + else if (cmd == "pos") pos(args); + else if (cmd == "pvs") pvs(args); + else if (cmd == "repairpvs") repairPVS(args); + else if (cmd == "savebsp") saveBSP(args); + else if (cmd == "cls") cls(args); + else if (cmd == "farclip") farclip(args); + else if (cmd == "ambient") ambient(args); + else if (cmd == "fullbright") fullbright(args); + else if (cmd == "ini_reload") ini_reload(args); + else if (cmd == "create") create(args); + else if (cmd == "give") giveweapon(args); + else if (cmd == "gv") gv(args); + else if (cmd == "lp") lp(args); + else if (cmd == "sp") sp(args); + else if (cmd == "tp") tp(args); + command[0] = 0; + args[0] = 0; +} + + +void ConsoleCommands::fullbright(char * args) +{ + Call<0x4BBCF0, char*>(args); +} + +void ConsoleCommands::repairPVS(char * args) +{ + Call<0x4BBDA0>(); +} + +void ConsoleCommands::saveBSP(char * args) +{ + Call<0x4BBDD0>(); +} + +void ConsoleCommands::farclip(char * args) +{ + Call<0x4BC9B0, char*>(args); +} + +void ConsoleCommands::pos(char * args) +{ + Call<0x4BCAA0, char*>(args); +} + +void ConsoleCommands::cls(char * args) +{ + TheConsole.m_currentMessage.clear(); + TheConsole.m_messages.clear(); +} + +void ConsoleCommands::ambient(char * args) +{ + Call<0x4BCA10, char*>(args); +} + +void ConsoleCommands::level_load(char * args) +{ + Call<0x4BC070, char*>(args); +} + +void ConsoleCommands::fps(char * args) +{ + Call<0x4BCB60, char*>(args); +} + +void ConsoleCommands::pvs(char * args) +{ + Call<0x4BBE70, char*>(args); +} + +void ConsoleCommands::toggleslowmo(char * args) +{ + Call<0x4BCD80, char*>(args); +} + +void ConsoleCommands::ini_reload(char * args) +{ + Call<0x4BC127, char*>(args); +} + +void ConsoleCommands::create(char * args) +{ + float x, y, z; + char entityName[256]; + int arg = sscanf(args, "%s %f %f %f",&entityName, &x, &y, &z); + CEntity* plr = CScene::FindPlayer(); + CVector* pos = plr->GetLocation(); + pos->x += 1.0f; + if (arg == 4) + *pos = { x,y,z }; + + + CreateEntity(entityName, pos); +} + +void ConsoleCommands::giveweapon(char * args) +{ + int weaponID; + char entityName[256]; + int argc = sscanf(args, "%s %d", &entityName, &weaponID); + + if (argc < 2) + { + TheConsole.m_messages.push_back("Usage: give "); + return; + } + + CEntity* entity = CEntityManager::FindInstance(entityName); + + if (!entity) + { + TheConsole.m_messages.push_back("Entity instance does not exist - " + (std::string)entityName); + return; + } + + if (entity) + GiveWeaponToEntity(entity, weaponID); + +} + +void ConsoleCommands::gv(char * args) +{ + int weaponID; + + int argc = sscanf(args, "%d", &weaponID); + if (argc < 1) + { + TheConsole.m_messages.push_back("Usage: gv "); + return; + } + + GiveWeaponToPlayer(weaponID); + +} + + + +void ConsoleCommands::help(char * args) +{ + cls(args); + int pageID = 0; + int argc = sscanf(args, "%d", &pageID); + + if (strlen(args) <= 0) + TheConsole.m_messages.push_back("Usage: help <1-2>"); + + if (pageID == 1) + { + TheConsole.m_messages.push_back("cls - Clears console"); + TheConsole.m_messages.push_back("pos - Displays player position, teleports if params are specified"); + TheConsole.m_messages.push_back("ambient - Changes ambient light, values from 0.0 to 1.0, displays current if no params"); + TheConsole.m_messages.push_back("repairpvs - repairs PVS section of BSP"); + TheConsole.m_messages.push_back("savebsp - saves world bsp to a file"); + TheConsole.m_messages.push_back("fullbright - maximizes ambient light"); + TheConsole.m_messages.push_back("ini_reload - reloads ini files"); + TheConsole.m_messages.push_back("level_load - (broken)"); + } + if (pageID == 2) + { + TheConsole.m_messages.push_back("create - Creates an entity at specified location, if none - close to player"); + TheConsole.m_messages.push_back("give - Gives an entity instance specified item - item must exist"); + TheConsole.m_messages.push_back("gv - Gives an item to player - item must exist"); + TheConsole.m_messages.push_back("sp - Saves position"); + TheConsole.m_messages.push_back("lp - Loads position"); + TheConsole.m_messages.push_back("tp - Teleports entity instance to specified location, if none - close to player"); + } +} + +void ConsoleCommands::sp(char * args) +{ + TheMenu.savedPosition = *CScene::FindPlayer()->GetLocation(); + TheConsole.m_messages.push_back("Position saved!"); +} + +void ConsoleCommands::lp(char * args) +{ + CScene::FindPlayer()->SetLocation(&TheMenu.savedPosition); + TheConsole.m_messages.push_back("Teleported to saved position!"); +} + +void ConsoleCommands::tp(char * args) +{ + float x, y, z; + char entityName[256]; + int argc = sscanf(args, "%s %f %f %f", &entityName, &x, &y, &z); + CEntity* plr = CScene::FindPlayer(); + CVector* pos = plr->GetLocation(); + pos->x += 1.0f; + if (argc == 4) + *pos = { x,y,z }; + + + + CEntity* entity = CEntityManager::FindInstance(entityName); + + if (!entity) + { + TheConsole.m_messages.push_back("Entity instance does not exist - " + (std::string)entityName); + return; + } + + if (entity) + entity->SetLocation(pos); +} + +void __fastcall HookAddLine(int console, char * line) +{ + TheConsole.m_messages.push_back(line); +} + +void __fastcall HookAddAIError(int modai, char * line) +{ + TheConsole.m_messages.push_back(line); +} + +void __declspec(naked) HookConsoleInputPause() +{ + static int input_jump = 0x590E9F; + + if (TheConsole.m_consoleActive) + CInputManager::m_bInputEnabled = 0; + else + CInputManager::m_bInputEnabled = 1; + + _asm jmp input_jump; + +} + +void InitConsoleHooks() +{ + InjectHook(0x4BCEA3, HookAddLine, PATCH_CALL); + InjectHook(0x590E95, HookConsoleInputPause, PATCH_JUMP); +} diff --git a/source/code/plugin/console/eConsole.h b/source/code/plugin/console/eConsole.h new file mode 100644 index 0000000..2b22be1 --- /dev/null +++ b/source/code/plugin/console/eConsole.h @@ -0,0 +1,56 @@ +#pragma once +#include +#include + + +class eConsole { +public: + bool m_consoleActive; + int m_currentCommand; + int m_entityID; + std::vector m_messages; + std::vector m_commands; + std::string m_currentMessage; + + eConsole(); + + void Process(); + void PushCharacter(char chr); + void ScrollMessage(int direction); + void RemoveLastCharacter(); + void Execute(); + void ExecuteCommand(char* command, char* args); + + +}; + +extern eConsole TheConsole; + +void __fastcall HookAddLine(int console, char* line); +void __fastcall HookAddAIError(int modai, char* line); +void HookConsoleInputPause(); +void InitConsoleHooks(); + + +namespace ConsoleCommands { + void fullbright(char* args); + void repairPVS(char* args); + void saveBSP(char* args); + void farclip(char* args); + void pos(char* args); + void cls(char* args); + void ambient(char* args); + void level_load(char* args); + void fps(char* args); + void pvs(char* args); + void toggleslowmo(char* args); + void ini_reload(char* args); + // custom + void create(char* args); + void giveweapon(char* args); + void gv(char* args); + void help(char* args); + void sp(char* args); + void lp(char* args); + void tp(char* args); +}; \ No newline at end of file diff --git a/source/code/plugin/eCommonHooks.cpp b/source/code/plugin/eCommonHooks.cpp new file mode 100644 index 0000000..d654203 --- /dev/null +++ b/source/code/plugin/eCommonHooks.cpp @@ -0,0 +1,209 @@ +#include "eCommonHooks.h" +#include "..\manhunt\core.h" +#include "eStatsManager.h" +#include "..\core\eSettingsManager.h" +#include +#include "..\manhunt\Frontend.h" +#include "..\manhunt\Renderer.h" +#include "menu/eMenu.h" +#include "..\manhunt\Cheats.h" +#include "modloader/eModLoader.h"; +#include "console/eConsole.h" +#include "..\manhunt\EntityManager.h" +#include "..\core\FileFunctions.h" +#include "..\manhunt\Scene.h" +#include "..\manhunt\Player.h" + +void HookCommonShutdown() +{ + eStatsManager::SaveToFile(); + + Call<0x489D50>(); +} + +void InitCommonHooks() +{ + + InjectHook(0x4D7F70, HookCommonShutdown, PATCH_CALL); + + InjectHook(0x489B69, CommonHooks::CreateCamera, PATCH_CALL); + Patch(0x7113FC, (int)ClassHooks::CPlayer_Kill); + Patch(0x711538, (int)ClassHooks::CPlayer_Kick); + + InjectHook(0x49D5FD, ClassHooks::CPed_SetTranqed, PATCH_CALL); + InjectHook(0x49D6A4, ClassHooks::CPed_SetTranqed, PATCH_CALL); + InjectHook(0x49DE13, ClassHooks::CPed_SetTranqed, PATCH_CALL); + InjectHook(0x49DE68, ClassHooks::CPed_SetTranqed, PATCH_CALL); + + InjectHook(0x49CDC1, ClassHooks::CPedHead_Explode, PATCH_CALL); + if (strlen(eSettingsManager::szCustomUserFilesDirectory) > 0) + InjectHook(0x4BE990, CommonHooks::GetMyDocumentsDirectory, PATCH_JUMP); + + InjectHook(0x4D7A58, CommonHooks::HookLoadSFX, PATCH_CALL); + InjectHook(0x474A02, CommonHooks::CCheatHandler_SetupForLevel, PATCH_CALL); // open + InjectHook(0x473F53, CommonHooks::CCheatHandler_SetupForLevel, PATCH_CALL); // reset + InjectHook(0x5F189F, CommonHooks::HookRenderMenu, PATCH_CALL); + + InjectHook(0x4375D6, CommonHooks::CEntityManager_CreateArchetypes, PATCH_CALL); + InjectHook(0x47444D, CommonHooks::GameStartInit, PATCH_CALL); + +} + +void DoCommonPatches() +{ + // CPlayer::ProcessHeartBeat + if (eSettingsManager::bDisableHeartBeat) + Nop(0x45F407, 5); + // CPlayer::ProcessBreathing + if (eSettingsManager::bDisableBreathing) + Nop(0x45F40E, 5); + + if (eSettingsManager::bHideBSPWarnings) + { + Nop(0x474F24, 5); + Nop(0x474F43, 5); + } + + if (eSettingsManager::bDisableAutoAim) + Nop(0x46A300, 7); + +} + +void __fastcall ClassHooks::CPlayer_Kill(int ptr) +{ + eStatsManager::IncrementStat(STAT_PLR_DEAD); + CallMethod<0x45B8A0,int>(ptr); +} + +void __fastcall ClassHooks::CPlayer_Kick(int ptr) +{ + eStatsManager::IncrementStat(STAT_PLR_KICKS); + CallMethod<0x45B8E0, int>(ptr); +} + +void ClassHooks::CPedHead_Explode(int ptr, int a2, int a3, int a4) +{ + eStatsManager::IncrementStat(STAT_HEADS_BOOM); + Call<0x4F1AC0, int,int,int,int>(ptr,a2,a3,a4); +} + + +void __fastcall ClassHooks::CPed_SetTranqed(int ptr, float time) +{ + if (ptr == *(int*)0x715B9C) + eStatsManager::IncrementStat(STAT_PLR_TRQ); + CallMethod<0x4B2DD0, int, float>(ptr, time); +} + +void __declspec(naked) CommonHooks::HookSkipIntroSeq() +{ + static int jmpPoint = 0x5E276E; + _asm jmp jmpPoint +} + +void CommonHooks::HookLoadSFX() +{ + TheMenu.PreInitialize(); + Call<0x4D7BB0>(); +} + +void CommonHooks::CCheatHandler_SetupForLevel() +{ + TheMenu.Initialize(); + CCheatHandler::SetupForLevel(); + + + if (eSettingsManager::bEnableFirstPersonMode) + { + CPlayer* plr = (CPlayer*)CScene::FindPlayer(); + plr->StartLookAround(); + + } +} + +void CommonHooks::CreateCamera() +{ + Call<0x5E2410>(); + +// eStatsManager::Initialize(); + +} + +void CommonHooks::HookRenderMenu() +{ + if (CFrontend::m_gameIsRunning) + { + if (TheConsole.m_consoleActive) + TheConsole.Process(); + + } + TheMenu.ProcessMenu(); + + Call<0x5D7070>(); +} + +char * CommonHooks::GetMyDocumentsDirectory() +{ + std::string folder(eSettingsManager::szCustomUserFilesDirectory, strlen(eSettingsManager::szCustomUserFilesDirectory)); + if (folder.length() > 0) + { + std::filesystem::current_path(getExecutablePath_str()); + + if (!std::filesystem::exists(folder)) + std::filesystem::create_directory(folder); + + } + + std::string finalPath = getExecutablePath_str(); + finalPath += folder; + return (char*)finalPath.c_str(); +} + +void CommonHooks::CEntityManager_CreateArchetypes() +{ + eModLoader::InitClumpDicts(); + CEntityManager::CreateArchetypes(); +} + +void CommonHooks::GameStartInit() +{ + Call<0x5EF510 >(); + if (eSettingsManager::iForcePlayerSkin > 0) + CEntityManager::ms_playerCharacterID = eSettingsManager::iForcePlayerSkin; +} + + + +void CommonHooks::HookManTriIcon(float x, float y, float scaleX, float scaleY, int red, int green, int blue, int alpha, int pTexture) +{ + Call<0x5F96F0, float, float, float, float, int, int, int, int, int>(x, y, scaleX, scaleY, red, green, blue, alpha, pTexture); + // xbox values + if (*(int*)0x7D343C) + Call<0x5F96F0, float, float, float, float, int, int, int, int, int>(0.81300002, 0.88100001, 0.04, 0.05, 255, 255, 255, 255, *(int*)0x7D343C); +} + +void __declspec(naked) CommonHooks::ArmsPosition_PlayerFPS() +{ + static CEntity* entity_ptr = 0; + static float rotation_angle = 0.0f; + static int jmp_continue = 0x4AB555; + + _asm { + mov entity_ptr, ebx + mov eax, dword ptr[ebx + 880] + mov rotation_angle, eax + } + + //printf("Rotation angle - %f for %s\n", rotation_angle, entity_ptr->m_szName); + + if (!(entity_ptr == CScene::FindPlayer())) + _asm { + fsubr dword ptr[ebx + 880] + fst st(4) + jmp jmp_continue + } + else + _asm { + jmp jmp_continue + } +} diff --git a/source/code/plugin/eCommonHooks.h b/source/code/plugin/eCommonHooks.h new file mode 100644 index 0000000..49e020a --- /dev/null +++ b/source/code/plugin/eCommonHooks.h @@ -0,0 +1,27 @@ +#pragma once + +void HookCommonShutdown(); +void InitCommonHooks(); +namespace ClassHooks { + void __fastcall CPlayer_Kill(int ptr); + void __fastcall CPlayer_Kick(int ptr); + void CPedHead_Explode(int ptr, int a2, int a3, int a4); + void __fastcall CPed_SetTranqed(int ptr, float time); +} +namespace CommonHooks { + void HookSkipIntroSeq(); + void HookLoadSFX(); + void CCheatHandler_SetupForLevel(); + void CreateCamera(); + void HookRenderMenu(); + char* GetMyDocumentsDirectory(); + void CEntityManager_CreateArchetypes(); + void GameStartInit(); + void HookManTriIcon(float x, float y, float scaleX, float scaleY, int red, int green, int blue, int alpha, int pTexture); + + void ArmsPosition_PlayerFPS(); +} + +void DoCommonPatches(); + + diff --git a/source/code/plugin/eCustomAnimManager.cpp b/source/code/plugin/eCustomAnimManager.cpp new file mode 100644 index 0000000..e1befd1 --- /dev/null +++ b/source/code/plugin/eCustomAnimManager.cpp @@ -0,0 +1,58 @@ +#include "eCustomAnimManager.h" +#include "..\core\eSettingsManager.h" +#include "..\manhunt\Anim.h" +#include "..\manhunt\String.h" +#include "..\manhunt\Filenames.h" +#include "..\manhunt\App.h" +#include "eLog.h" +#include + +std::unique_ptr CCustomAnimManager::ptrNewAnimationsArray; + +void CCustomAnimManager::InitHooks() +{ + ptrNewAnimationsArray = std::make_unique(eSettingsManager::iCustomAnimManagerSize); + + InjectHook(0x496410, Initialise, PATCH_JUMP); + Patch(0x4965B1 + 3, (int)&ptrNewAnimationsArray[0]); + Patch(0x496768 + 3, (int)&ptrNewAnimationsArray[0]); + Patch(0x496B17 + 3, (int)&ptrNewAnimationsArray[0]); +} + +bool CCustomAnimManager::Initialise() +{ + char tmpPath[_MAX_PATH]; + int nAnims = eSettingsManager::iCustomAnimManagerSize; + bool result = false; + + do + { + ptrNewAnimationsArray[nAnims] = 0; + nAnims -= 8; + } while (nAnims >= 0); + + + CAnimManager::ms_nAvailableAnims = 0; + + // load global animation file if set + if (eSettingsManager::bCustomAnimManagerUseGlobalFile) + sprintf(tmpPath, "%s%s/", CFileNames::ms_CurrentLevelPath.str, "GLOBAL"); + else + sprintf(tmpPath, "%s%s/", CFileNames::ms_CurrentLevelPath.str, (char*)(0x756034 + 20 * CApp::ms_currLevelNum)); + + strcat(tmpPath, CFileNames::ms_filenameAllAnims.str); + strcat(tmpPath, CFileNames::ms_filenameAnimFileType.str); + + + + if (CAnimManager::LoadAnimations(tmpPath)) + result = true; + else + result = false; + + eLog::Message(__FUNCTION__, "Loaded file %s Animations - %d/%d", tmpPath, CAnimManager::ms_nAvailableAnims, eSettingsManager::iCustomAnimManagerSize); + + + return result; + +} diff --git a/source/code/plugin/eCustomAnimManager.h b/source/code/plugin/eCustomAnimManager.h new file mode 100644 index 0000000..556dd09 --- /dev/null +++ b/source/code/plugin/eCustomAnimManager.h @@ -0,0 +1,11 @@ +#pragma once +#include + +#define CUSTOM_ANIMMANAGER_TOTAL_ANIMS 2500 + +class CCustomAnimManager { +public: + static std::unique_ptr ptrNewAnimationsArray; + static void InitHooks(); + static bool Initialise(); +}; \ No newline at end of file diff --git a/source/code/CTOC.cpp b/source/code/plugin/eCustomTableOfContents.cpp similarity index 53% rename from source/code/CTOC.cpp rename to source/code/plugin/eCustomTableOfContents.cpp index da4d0da..0d55543 100644 --- a/source/code/CTOC.cpp +++ b/source/code/plugin/eCustomTableOfContents.cpp @@ -1,12 +1,21 @@ -#include "CTOC.h" +#include "eCustomTableOfContents.h" +#include "..\core\eSettingsManager.h" +#include "..\manhunt\Misc.h" +#include "..\manhunt\core.h" #include -using namespace ManhuntFileFunctions; int& iFileStreamSize = *(int*)0x7392C8; char& byte_7392CC = *(char*)0x7392CC; char& unk_67D000 = *(char*)0x67D000; -CFile *__cdecl eTOC::HookLoadFile(char * name, int * fileBuffer, int * a3, CFile ** file, int * fileSize) +void eCustomTableOfContents::InitHooks() +{ + //InjectHook(0x4D5090, LoadFile, PATCH_JUMP); + InjectHook(0x4D61B0, GetTOCFileSize, PATCH_JUMP); +} + + +CFile * eCustomTableOfContents::LoadFile(char * name, int * fileBuffer, int * a3, CFile ** file, int * fileSize) { int srcBuffer; int readBytes; @@ -21,12 +30,12 @@ CFile *__cdecl eTOC::HookLoadFile(char * name, int * fileBuffer, int * a3, CFile //iFileStreamSize = CallAndReturn(name); - iFileStreamSize = 25 * 1024 * 1024; + iFileStreamSize = std::filesystem::file_size(name); totalSize = iFileStreamSize; if (byte_7392CC) //always 0 anyway - srcBuffer = CallMethodAndReturn(unk_67D000, iFileStreamSize + 64); + srcBuffer = CallMethodAndReturn(unk_67D000, iFileStreamSize + 64); else srcBuffer = CallMethodAndReturn(0x67D000, totalSize + 64); @@ -41,28 +50,8 @@ CFile *__cdecl eTOC::HookLoadFile(char * name, int * fileBuffer, int * a3, CFile return Rockstar_fopen(3, 1, (char*)&buffer); } -bool eTOC::HookLoadTOC(bool isGlobal) -{ - - CFile* gToc; - int srcBuffer; - - gToc = Rockstar_fopen(2, 1, "levels//global//toc.txt"); - - if (!gToc) - return 0; - - //v16 = (char *)sub_401350(unk_67D000, 4160); - //a1 = (char *)((unsigned int)(v16 + 64) & 0xFFFFFFC0); - - srcBuffer = CallMethodAndReturn(0x67D000, 4160); - - CallMethod<0x401B00, int, int>(0x67D000, srcBuffer); - return true; -} - -void __declspec(naked) eTOC::HookSkipLevelToc() +int eCustomTableOfContents::GetTOCFileSize(char * name) { - static int jumpPoint = 0x474382; - _asm jmp jumpPoint + //printf("File %s\n", name); + return std::filesystem::file_size(name); } diff --git a/source/code/plugin/eCustomTableOfContents.h b/source/code/plugin/eCustomTableOfContents.h new file mode 100644 index 0000000..bed8c4e --- /dev/null +++ b/source/code/plugin/eCustomTableOfContents.h @@ -0,0 +1,9 @@ +#pragma once +#include "..\manhunt\Misc.h" + +namespace eCustomTableOfContents { + void InitHooks(); + CFile* __cdecl LoadFile(char* name, int* fileBuffer, int* a3, CFile** file, int* fileSize); + int GetTOCFileSize(char* name); +} + diff --git a/source/code/plugin/eLog.cpp b/source/code/plugin/eLog.cpp new file mode 100644 index 0000000..40dbe6d --- /dev/null +++ b/source/code/plugin/eLog.cpp @@ -0,0 +1,53 @@ +#include "eLog.h" +#include "..\core\eSettingsManager.h" +#include +#include +#include + +wchar_t eLog::path[260]; + +void eLog::Initialise() +{ + if (!eSettingsManager::bEnableLog) + return; + + + GetModuleFileNameW(NULL, path, sizeof(path)); + + wchar_t* end = wcsrchr(path, L'\\'); + if (end) + end[1] = 0x00; + wcscat(path, L"pluginmh_log.txt"); + + FILE* cls = _wfopen(path, L"w"); + fclose(cls); + FILE* log = _wfopen(path, L"a+"); + time_t ttime = time(0); + fprintf(log, "Logging Started - %s", ctime(&ttime)); + fclose(log); + +} + +void eLog::Message(char* function, char* format, ...) +{ + if (!eSettingsManager::bEnableLog) + return; + + + + char msg[2048]; + + va_list args; + va_start(args, format); + wvsprintf(msg, format, args); + va_end(args); + + FILE* log = _wfopen(path, L"a+"); + + if (log) + { + fprintf(log, "%s | %s\n",function, msg); + fclose(log); + } + +} diff --git a/source/code/plugin/eLog.h b/source/code/plugin/eLog.h new file mode 100644 index 0000000..dbc2c51 --- /dev/null +++ b/source/code/plugin/eLog.h @@ -0,0 +1,10 @@ +#pragma once + + +class eLog { +public: + static wchar_t path[260]; + + static void Initialise(); + static void Message(char* function, char* format, ...); +}; \ No newline at end of file diff --git a/source/code/plugin/eModSettings.cpp b/source/code/plugin/eModSettings.cpp new file mode 100644 index 0000000..c58a2e9 --- /dev/null +++ b/source/code/plugin/eModSettings.cpp @@ -0,0 +1,9 @@ +#include "eModSettings.h" + +void eModSettigns::SaveToFile() +{ +} + +void eModSettigns::LoadFromFile() +{ +} diff --git a/source/code/plugin/eModSettings.h b/source/code/plugin/eModSettings.h new file mode 100644 index 0000000..bc819ba --- /dev/null +++ b/source/code/plugin/eModSettings.h @@ -0,0 +1,9 @@ +#pragma once + +class eModSettigns { +public: + static bool m_bDisableAutoAim; + + static void SaveToFile(); + static void LoadFromFile(); +}; \ No newline at end of file diff --git a/source/code/plugin/eNewFrontend.cpp b/source/code/plugin/eNewFrontend.cpp new file mode 100644 index 0000000..c21420e --- /dev/null +++ b/source/code/plugin/eNewFrontend.cpp @@ -0,0 +1,515 @@ +#include "eNewFrontend.h" +#include "..\core\eMain.h" +#include "..\manhunt\Frontend.h" +#include "..\manhunt\Text.h" +#include "..\manhunt\Input.h" +#include "..\manhunt\core.h" +#include "..\manhunt\Filenames.h" +#include "..\manhunt\Renderer.h" +#include "..\manhunt\Scene.h" +#include "..\manhunt\App.h" +#include "..\manhunt\Cheats.h" +#include "..\manhunt\Time.h" +#include "..\plugin\modloader\eModLoader.h" +#include "eStatsManager.h" +#include + +int eNewFrontend::m_pStatsMenu[2] = { (int)eNewFrontend::ProcessStatsMenu, (int)eNewFrontend::StatsMenu }; +int eNewFrontend::ms_lastCustomMenu; +float eNewFrontend::m_fBoxPositionX; +float eNewFrontend::m_fBoxPositionY; +char eNewFrontend::statsBuffer[256]; +wchar_t eNewFrontend::m_szStatsBuffer[128]; +int eNewFrontend::m_allStatsPages; +int eNewFrontend::m_leftoverStatsPage; +int eNewFrontend::m_nCurrentStatsPage; +int eNewFrontend::m_nCurrentModsPage; +wchar_t* eNewFrontend::m_szCheatText = (wchar_t*)0x7D6360; + +void eNewFrontend::InitHooks() +{ + InjectHook(0x600C20, eNewFrontend::MainMenu, PATCH_JUMP); + InjectHook(0x600B34, eNewFrontend::ProcessMainMenu, PATCH_JUMP); + InjectHook(0x5D70F9, eNewFrontend::HookSelectMenuBackground, PATCH_JUMP); + InjectHook(0x5D75D7, eNewFrontend::HookExecuteMenuProcess, PATCH_JUMP); + + // lcd display + Nop(0x5D7504, 5); + +} + +void eNewFrontend::Init() +{ + m_fBoxPositionX = 0.155f; + m_fBoxPositionY = 0.277f; + m_nCurrentStatsPage = 0; + m_nCurrentModsPage = 0; + m_allStatsPages = 3; + +} + + +void eNewFrontend::MainMenu() +{ + CFrontend::ms_fMenuPositionX = 0.15f; + float y_pos = CFrontend::ms_fMenuPositionY; + float y_temp = 0.0f; + float y_adjust = 0.30000001f; + + CFrontend::DrawMenuCameraCounter(CText::GetFromKey16("MAINM")); + + + float m_fHudStretch = *(float*)0x7D3458; + float m_fLogoScale = *(float*)0x7D63FC; + + float logoX = m_fHudStretch * m_fLogoScale; + int logoTexture = CFrontend::GetTextureFromTXD(*(int*)0x7C8704, "logo"); + + + CRenderer::DrawQuad2d(*(float*)0x7D6408 + 0.45f,*(float*)0x7D6404,logoX,*(float*)0x7D6400, 180, 180, 180, 255, logoTexture); + + + y_temp = y_pos + y_adjust - CFrontend::ms_fMenuPositionY; + CFrontend::AddOption(CText::GetFromKey16("PLAY"), CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == MB_PLAY); + + y_temp = y_pos + y_adjust; + CFrontend::AddOption(CText::GetFromKey16("SELSCE"), CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == MB_SELSCE); + + y_temp += CFrontend::ms_fMenuPositionY; + CFrontend::AddOption(CText::GetFromKey16("LOADG"), CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == MB_LOADG); + + y_temp += CFrontend::ms_fMenuPositionY; + CFrontend::AddOption(CText::GetFromKey16("SETT"), CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == MB_SETT); + + y_temp += CFrontend::ms_fMenuPositionY; + CFrontend::AddOption(CText::GetFromKey16("BONFEA"), CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == MB_BONFEA); + + y_temp += CFrontend::ms_fMenuPositionY; + CFrontend::AddOption(L"STATS", CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == MB_STATS); + + y_temp += CFrontend::ms_fMenuPositionY; + CFrontend::AddOption(L"MODIFICATIONS", CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == MB_MODIFICATIONS); + + y_temp += CFrontend::ms_fMenuPositionY; + CFrontend::AddOption(CText::GetFromKey16("QUITPRG"), CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == MB_QUITPRG); +} + +bool __declspec(naked) eNewFrontend::ProcessMainMenu() +{ + static int arg = 0; + static int jmpPoint = 0x6025B6; + + if (CInputManager::FrontendPressedUp()) + { + if (--CFrontend::ms_menuButton < 0) + CFrontend::ms_menuButton = MB_QUITPRG; + } + + if (CInputManager::FrontendPressedDown()) + { + if (++CFrontend::ms_menuButton >= MB_TOTAL_MENUS) + CFrontend::ms_menuButton = 0; + } + + if (CInputManager::FrontedMouseHovered()) + CFrontend::ms_menuButton = CFrontend::GetHoveredItem(); + + if (CInputManager::FrontendPressedEscape()) + CFrontend::SetCurrentMenu(MENU_QUIT); + + + + if (CInputManager::FrontendButtonEnter()) + { + switch (CFrontend::ms_menuButton) + { + case MB_PLAY: + arg = CallAndReturn(); + if (arg == -1) + { + Call<0x5D6A60>(); + CFrontend::m_bNewGame = 0; + *(int*)0x7C86F4 = 0; + CFrontend::SetCurrentMenu(MENU_GAMMA_SETTINGS); + } + else + Call<0x5D6720, int, int>(arg, 1); + break; + case MB_SELSCE: + *(int*)0x7C89E4 = 7; + CFrontend::SetCurrentMenu(MENU_LEVEL_SELECT); + break; + case MB_LOADG: + CFrontend::SetCurrentMenu(MENU_START_LOAD_GAME); + break; + case MB_SETT: + CFrontend::SetCurrentMenu(MENU_SETTINGS); + break; + case MB_BONFEA: + CFrontend::SetCurrentMenu(MENU_BONUS_FEATURES); + break; + case MB_STATS: + CFrontend::SetCurrentMenu(MENU_STATS); + break; + case MB_MODIFICATIONS: + CFrontend::SetCurrentMenu(MENU_MODS); + break; + case MB_QUITPRG: + CFrontend::SetCurrentMenu(MENU_QUIT); + break; + } + } + + if (CCheatHandler::m_lastCheat) + { + switch (CCheatHandler::m_lastCheat) + { + case CHEAT_RUNNER: + m_szCheatText = CText::GetFromKey16("C_RUN"); + break; + case CHEAT_SILENCE: + m_szCheatText = CText::GetFromKey16("C_SILEN"); + break; + case CHEAT_REGENERATION: + m_szCheatText = CText::GetFromKey16("C_REGEN"); + break; + case CHEAT_EXPLODE: + m_szCheatText = CText::GetFromKey16("C_HELI"); + break; + case CHEAT_EQUIPPED: + m_szCheatText = CText::GetFromKey16("C_FULEQ"); + break; + case CHEAT_SUPERPUNCH: + m_szCheatText = CText::GetFromKey16("C_SUPUN"); + break; + case CHEAT_RABBIT: + m_szCheatText = CText::GetFromKey16("C_RABBI"); + break; + case CHEAT_MONKEY: + m_szCheatText = CText::GetFromKey16("C_MONKE"); + break; + case CHEAT_INVIS: + m_szCheatText = CText::GetFromKey16("C_INVIS"); + break; + case CHEAT_PIGGSY: + m_szCheatText = CText::GetFromKey16("C_PIGGS"); + break; + case CHEAT_GODMODE: + m_szCheatText = CText::GetFromKey16("C_GOD"); + break; + } + } + + if (CCheatHandler::m_bCheatsActive) + CFrontend::PrintInfo(m_szCheatText, (wchar_t*)0x7D6360, (wchar_t*)0x7D6360, (wchar_t*)0x7D6360); + + _asm jmp jmpPoint + +} + +bool eNewFrontend::IsCustomMenu(int menu) +{ + if (menu > MENU_QUIT && menu < MENU_MODS) + return true; + else + return false; +} + +void eNewFrontend::DrawEVisionMark() +{ + + CFrontend::SetDrawRGBA(255, 255, 255, 48); + CFrontend::Print8("PluginMH BETA by ermaccer", 0.0, 0.0, 0.28f, 0.28f, 0.0f, FONT_TYPE_DEFAULT); +} + +void eNewFrontend::StatsMenu() +{ + wsprintfW(m_szStatsBuffer, L"STATS %d/%d", m_nCurrentStatsPage + 1, m_allStatsPages); + CFrontend::DrawMenuCameraCounter(m_szStatsBuffer); + CRenderer::DrawQuad2d(m_fBoxPositionX, m_fBoxPositionY, 0.69f, 0.55f, 180, 180, 180, 128, 0); + for (int i = 0; i < STATS_PER_PAGE; i++) + { + if (m_nCurrentStatsPage > 0) + DrawStatText(i + (STATS_PER_PAGE * m_nCurrentStatsPage)); + else + DrawStatText(i); + } + + + CFrontend::PrintInfo(L"Press ESC to quit, ~up~ or ~down~ to navigate", (wchar_t*)0x7D6360, (wchar_t*)0x7D6360, (wchar_t*)0x7D6360); +} + +void eNewFrontend::ProcessStatsMenu() +{ + if (CInputManager::FrontendPressedEscape()) + CFrontend::SetCurrentMenu(MENU_19); + + if (CInputManager::FrontendPressedUp()) + m_nCurrentStatsPage--; + + if (CInputManager::FrontendPressedDown()) + m_nCurrentStatsPage++; + + if (m_nCurrentStatsPage < 0) + m_nCurrentStatsPage = 0; + + if (m_nCurrentStatsPage > m_allStatsPages - 1) + m_nCurrentStatsPage = m_allStatsPages - 1; + + + + +} + +void eNewFrontend::ModsMenu() +{ + int mods = eModLoader::modFolders.size(); + char tmp[128]; + + CFrontend::SetDrawRGBA(255,255,255, 255); + + sprintf(tmp, "LOADED MODIFICATIONS: %d", eModLoader::modFolders.size()); + CFrontend::Print8(tmp, m_fBoxPositionX, m_fBoxPositionY - 0.10f, 1.0, 1.0, 0.0, FONT_FRONTEND); + CFrontend::DrawMenuCameraCounter(L"MODIFICATIONS"); + + for (int i = 0; i < mods; i++) + { + CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(eModLoader::modFolders[i].c_str(), m_fBoxPositionX + 0.02 + 0.004, m_fBoxPositionY + 0.05 * i + 0.004, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + CFrontend::SetDrawRGBA(255, 255, 255, 255); + CFrontend::Print8(eModLoader::modFolders[i].c_str(), m_fBoxPositionX + 0.02, m_fBoxPositionY + 0.05 * i, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + } +} + +void eNewFrontend::ProcessModsMenu() +{ + if (CInputManager::FrontendPressedEscape()) + CFrontend::SetCurrentMenu(MENU_19); +} + +void eNewFrontend::NewLevelSelect() +{ + //CFrontend::ms_fMenuPositionX = 0.15f; + float y_pos = CFrontend::ms_fMenuPositionY; + float y_temp = 0.0f; + float y_adjust = 0.30000001f; + + CFrontend::DrawMenuCameraCounter(CText::GetFromKey16("MAINM")); + + + y_temp = y_pos + y_adjust - CFrontend::ms_fMenuPositionY; + CFrontend::AddOption(L"ORIGINAL", CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == LS_ORIGINAL); + y_temp = y_pos + y_adjust; + CFrontend::AddOption(L"CUSTOM", CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == LS_NEW); + y_temp += CFrontend::ms_fMenuPositionY; + CFrontend::AddOption(L"BACK", CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == LS_BACK); + +} + +void eNewFrontend::ProcessNewLevelSelect() +{ + if (CInputManager::FrontendPressedUp()) + { + if (CFrontend::ms_menuButton-- < 0) + CFrontend::ms_menuButton = LS_BACK; + } + + if (CInputManager::FrontendPressedDown()) + { + if (CFrontend::ms_menuButton++ >= LS_BACK) + CFrontend::ms_menuButton = LS_ORIGINAL; + } + + if (CInputManager::FrontedMouseHovered()) + CFrontend::ms_menuButton = CFrontend::GetHoveredItem(); + + if (CInputManager::FrontendPressedEscape()) + CFrontend::SetCurrentMenu(MENU_19); + + + + if (CInputManager::FrontendButtonEnter()) + { + switch (CFrontend::ms_menuButton) + { + case LS_ORIGINAL: + //*(int*)0x7C89E4 = 7; + CFrontend::ms_menuButton = -1; + *(int*)0x7C8FAC = -1; + Sleep(250); + CFrontend::SetCurrentMenu(MENU_LEVEL_SELECT); + + break; + case LS_NEW: + //*(int*)0x7C89E4 = 7; + CFrontend::SetCurrentMenu(MENU_19); + break; + case LS_BACK: + CFrontend::SetCurrentMenu(MENU_FRONTEND); + break; + } + } +} + +void eNewFrontend::NewSettingMenu() +{ + float y_pos = CFrontend::ms_fMenuPositionY; + float y_temp = 0.0f; + float y_adjust = 0.30000001f; + + CFrontend::DrawMenuCameraCounter(CText::GetFromKey16("MAINM")); + + + y_temp = y_pos + y_adjust - CFrontend::ms_fMenuPositionY; + CFrontend::AddOption(CText::GetFromKey16("SETT"), CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == LS_ORIGINAL); + y_temp = y_pos + y_adjust; + CFrontend::AddOption(L"MOD SETTINGS", CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == LS_NEW); + y_temp += CFrontend::ms_fMenuPositionY; + CFrontend::AddOption(L"BACK", CFrontend::ms_fMenuPositionX, y_temp + , CFrontend::ms_fTextXScale, CFrontend::ms_fTextYScale, CFrontend::ms_menuButton == LS_BACK); +} + +void eNewFrontend::ProcessNewSettingMenu() +{ + if (CInputManager::FrontendPressedUp()) + { + if (CFrontend::ms_menuButton-- < 0) + CFrontend::ms_menuButton = LS_BACK; + } + + if (CInputManager::FrontendPressedDown()) + { + if (CFrontend::ms_menuButton++ >= LS_BACK) + CFrontend::ms_menuButton = LS_ORIGINAL; + } + + if (CInputManager::FrontedMouseHovered()) + CFrontend::ms_menuButton = CFrontend::GetHoveredItem(); + + if (CInputManager::FrontendPressedEscape()) + CFrontend::SetCurrentMenu(MENU_19); + + + + if (CInputManager::FrontendButtonEnter()) + { + switch (CFrontend::ms_menuButton) + { + case LS_ORIGINAL: + //*(int*)0x7C89E4 = 7; + CFrontend::ms_menuButton = -1; + *(int*)0x7C8FAC = -1; + CFrontend::SetCurrentMenu(MENU_SETTINGS); + break; + case LS_NEW: + //*(int*)0x7C89E4 = 7; + CFrontend::SetCurrentMenu(MENU_MODS); + break; + case LS_BACK: + CFrontend::SetCurrentMenu(MENU_19); + break; + } + } +} + +void eNewFrontend::DrawStatText(int id) +{ + if (eStatsManager::GetStatName(id)) + { + int drawID = id - (STATS_PER_PAGE * m_nCurrentStatsPage); + + // stat names + CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(eStatsManager::GetStatName(id), m_fBoxPositionX + 0.02 + 0.004, m_fBoxPositionY + 0.05 * drawID + 0.004, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + CFrontend::SetDrawRGBA(255, 255, 255, 255); + CFrontend::Print8(eStatsManager::GetStatName(id), m_fBoxPositionX + 0.02, m_fBoxPositionY + 0.05 * drawID, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + // stat values + sprintf(statsBuffer, "%d", eStatsManager::GetStat(id)); + + + + CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(statsBuffer, m_fBoxPositionX + 0.02 + 0.55 + 0.004, m_fBoxPositionY + 0.05 * drawID + 0.004, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + CFrontend::SetDrawRGBA(255, 255, 255, 255); + CFrontend::Print8(statsBuffer, m_fBoxPositionX + 0.02 + 0.55, m_fBoxPositionY + 0.05 * drawID, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + } +} + +void eNewFrontend::DrawModText(int id) +{ + + +} + +void __declspec(naked) eNewFrontend::HookSelectMenuBackground() +{ + static int originalSwitch = 0x5D70FE; + + if (CFrontend::ms_currentMenu == MENU_STATS) + { + CFrontend::SetMenuBackground(CFileNames::ms_BonusEpPath.str); + } + else if (CFrontend::ms_currentMenu == MENU_MODS) + { + CFrontend::SetMenuBackground(CFileNames::ms_MainEpPath.str); + } + else if (CFrontend::ms_currentMenu == MENU_LEVEL_SELECT_DUO || (CFrontend::ms_currentMenu == MENU_NEW_SETTINGS)) + { + CFrontend::SetMenuBackground(CFileNames::ms_MainEpPath.str); + } + + + _asm + { + mov eax, ds:0x7C86F8 + jmp originalSwitch + } +} + +void __declspec(naked) eNewFrontend::HookExecuteMenuProcess() +{ + static int originalSwitchExec = 0x5D75DC; + + DrawEVisionMark(); + + if (CFrontend::ms_currentMenu == MENU_STATS) + { + ProcessStatsMenu(); + StatsMenu(); + } + else if (CFrontend::ms_currentMenu == MENU_MODS) + { + ProcessModsMenu(); + ModsMenu(); + } + else if (CFrontend::ms_currentMenu == MENU_LEVEL_SELECT_DUO) + { + ProcessNewLevelSelect(); + NewLevelSelect(); + } + else if (CFrontend::ms_currentMenu == MENU_NEW_SETTINGS) + { + ProcessNewSettingMenu(); + NewSettingMenu(); + + } + + _asm + { + mov eax, ds:0x7C86F8 + jmp originalSwitchExec + } +} diff --git a/source/code/plugin/eNewFrontend.h b/source/code/plugin/eNewFrontend.h new file mode 100644 index 0000000..22011b4 --- /dev/null +++ b/source/code/plugin/eNewFrontend.h @@ -0,0 +1,55 @@ +#pragma once + +enum eNewMenuTypes { + // new menus + MENU_STATS = 24, + MENU_LEVEL_SELECT_DUO, + MENU_NEW_SETTINGS, + MENU_MODS +}; + +enum eLevelSelectButtons { + LS_ORIGINAL, + LS_NEW, + LS_BACK +}; + +class eNewFrontend { +private: + static char statsBuffer[256]; + static char szMenuPath[128]; + static wchar_t* m_szCheatText; +public: + static void InitHooks(); + static int ms_lastCustomMenu; + static void Init(); + static void MainMenu(); + static bool ProcessMainMenu(); + static bool IsCustomMenu(int menu); + + static void DrawEVisionMark(); + + static float m_fBoxPositionX; + static float m_fBoxPositionY; + static int m_pStatsMenu[2]; + static int m_allStatsPages; + static int m_leftoverStatsPage; + static int m_nCurrentStatsPage; + static int m_nCurrentModsPage; + static wchar_t m_szStatsBuffer[128]; + static void StatsMenu(); + static void ProcessStatsMenu(); + static void ModsMenu(); + static void ProcessModsMenu(); + static void NewLevelSelect(); + static void ProcessNewLevelSelect(); + static void NewSettingMenu(); + static void ProcessNewSettingMenu(); + static void DrawStatText(int id); + static void DrawModText(int id); + + + // hooks + static void HookSelectMenuBackground(); + static void HookExecuteMenuProcess(); +}; \ No newline at end of file diff --git a/source/code/plugin/eQoLChanges.cpp b/source/code/plugin/eQoLChanges.cpp new file mode 100644 index 0000000..4cb44c5 --- /dev/null +++ b/source/code/plugin/eQoLChanges.cpp @@ -0,0 +1,13 @@ +#include "eQoLChanges.h" +#include "..\manhunt\core.h" + +void eQoLChanges::SkipIntro() +{ + // logo + Patch(0x5E275F + 2, 0); + Nop(0x5E2652, 5); + Nop(0x5E26DC, 5); + +} + + diff --git a/source/code/plugin/eQoLChanges.h b/source/code/plugin/eQoLChanges.h new file mode 100644 index 0000000..d6c59d4 --- /dev/null +++ b/source/code/plugin/eQoLChanges.h @@ -0,0 +1,7 @@ +#pragma once + +class eQoLChanges { +public: + static void SkipIntro(); + +}; \ No newline at end of file diff --git a/source/code/CPlayerModelLoader.cpp b/source/code/plugin/eSkinLoader.cpp similarity index 57% rename from source/code/CPlayerModelLoader.cpp rename to source/code/plugin/eSkinLoader.cpp index 9c43b46..af53cd1 100644 --- a/source/code/CPlayerModelLoader.cpp +++ b/source/code/plugin/eSkinLoader.cpp @@ -1,125 +1,133 @@ -#include "CPlayerModelLoader.h" -#include -#include -#include "ManhuntSDK.h" - -std::vector vSkins; - -int CPlayerModelLoader::ReadFile(const char * name) -{ - FILE* pFile = fopen(name, "rb"); - if (!pFile) - { - printf("CPlayerModelLoader::ReadFile() | ERROR: Could not open %s!\n", name); - return 0; - } - if (pFile) - { - printf("CPlayerModelLoader::ReadFile() | Reading %s\n", name); - char line[1536]; - while (fgets(line, sizeof(line), pFile)) - { - // check if comment - if (line[0] == ';' || line[0] == '#' || line[0] == '\n') - continue; - - int id = 0; - if (sscanf(line, "%d", &id) == 1) - { - char t_dffname[128]; - char t_txdename[128]; - char t_rootname[128]; - int bDisplayWeapons; - int flag; - - sscanf(line, "%d %s %s %s %d %d", &id, &t_txdename, &t_dffname, &t_rootname, &bDisplayWeapons, &flag); - - // convert to strings - std::string strDff(t_dffname, strlen(t_dffname)); - std::string strTxd(t_txdename, strlen(t_txdename)); - std::string strRoot(t_rootname, strlen(t_rootname)); - - if (strRoot.length() > 15) - { - printf("ERROR: Skin %d root name too long! (15 max)\n", id); - return 0; - } - - // create skin - CCustomPlayer skin; - skin.iID = id; - skin.iShowWeapons = bDisplayWeapons; - skin.sModelFile = strDff; - skin.sRootName = strRoot; - skin.sTxdFile = strTxd; - skin.iFlag = flag; - vSkins.push_back(skin); - } - - } - printf("CPlayerModelLoader::ReadFile() | Found %d entities!\n", vSkins.size()); - fclose(pFile); - } - return 1; -} -int CPlayerModelLoader::Hook(int skinID) -{ - char* result; - char fullDffPath[260]; - char fullTxdPath[260]; - char txdFile[260]; - char dffFile[260]; - - - sprintf(txdFile,"%s", vSkins[FindSkin(skinID)].sTxdFile.c_str()); - sprintf(dffFile,"%s", vSkins[FindSkin(skinID)].sModelFile.c_str()); - strcpy((char*)0x6A94A0, vSkins[FindSkin(skinID)].sRootName.c_str()); // root name - *(int*)0x7AE94C = vSkins[FindSkin(skinID)].iFlag; - - - sprintf(fullTxdPath, "%s%s", "./levels", txdFile); - sprintf(fullDffPath, "%s%s", "./levels", dffFile); - - //printf("CPlayerModelLoader::Hook() | Loading skin %d\n", skinID); - - result = CallMethodAndReturn(*(int*)0x736DB8, fullTxdPath); - CallMethod<0x59B3F0, int*, char*, char*>(&(*(int*)0x69BC90), result, fullDffPath); - return CallMethodAndReturn(*(int*)0x736DB8, result); - -} - -int CPlayerModelLoader::FindSkin(int skinID) -{ - int iFind = 0; - - for (int i = 0; i < vSkins.size(); i++) - { - if (vSkins[i].iID == skinID) - { - iFind = i; - break; - } - } - return iFind; -} - -void __declspec(naked) CPlayerModelLoader::HookWeapon() -{ - static int tecx; - static int jmpTrue = 0x45FD98; - static int jmpFalse = 0x45FDA0; - _asm { - mov ecx, ds:0x6A94C - mov tecx,ecx - } - if (vSkins[FindSkin(tecx)].iShowWeapons == 1) - { - _asm { - jmp jmpTrue - } - } - else - _asm { - jmp jmpFalse - } -} +#include "eSkinLoader.h" +#include "..\manhunt\core.h" +#include "..\core\eSettingsManager.h" +#include +#include "..\core\FileFunctions.h" +#include "..\manhunt\EntityManager.h" +#include + +#include "eLog.h" + +std::vector eSkinLoader::vSkins; + + +void eSkinLoader::InitHooks() +{ + if (eSettingsManager::bHookSkinLoader) + { + if (eSkinLoader::ReadFile("data\\skinLoader.dat")) + { + InjectHook(0x437FB0, eSkinLoader::Hook, PATCH_JUMP); + //InjectHook(0x45FD86, eSkinLoader::HookWeapon, PATCH_JUMP); + } + } +} + +int eSkinLoader::ReadFile(const char * name) +{ + std::filesystem::current_path(getExecutablePath()); + + FILE* pFile = fopen(name, "rb"); + if (!pFile) + { + eLog::Message(__FUNCTION__, "ERROR: Could not open %s!", name); + return 0; + } + if (pFile) + { + eLog::Message(__FUNCTION__, "Reading %s!", name); + char line[1536]; + while (fgets(line, sizeof(line), pFile)) + { + // check if comment + if (line[0] == ';' || line[0] == '#' || line[0] == '\n') + continue; + + int id = 0; + if (sscanf(line, "%d", &id) == 1) + { + char t_dffname[128]; + char t_txdename[128]; + char t_rootname[128]; + int bDisplayWeapons; + int flag; + + sscanf(line, "%d %s %s %s %d %d", &id, &t_txdename, &t_dffname, &t_rootname, &bDisplayWeapons, &flag); + + // convert to strings + std::string strDff(t_dffname, strlen(t_dffname)); + std::string strTxd(t_txdename, strlen(t_txdename)); + std::string strRoot(t_rootname, strlen(t_rootname)); + + + // create skin + eSkinEntry skin; + skin.iID = id; + skin.iShowWeapons = bDisplayWeapons; + skin.sModelFile = strDff; + skin.sRootName = strRoot; + skin.sTxdFile = strTxd; + skin.iFlag = flag; + vSkins.push_back(skin); + } + + } + eLog::Message(__FUNCTION__, "Read %d entries!", vSkins.size()); + fclose(pFile); + } + return 1; +} + +int eSkinLoader::Hook(int skinID) +{ + char* result; + char fullDffPath[260]; + char fullTxdPath[260]; + char txdFile[260]; + char dffFile[260]; + + + sprintf(txdFile, "%s", vSkins[FindSkin(skinID)].sTxdFile.c_str()); + sprintf(dffFile, "%s", vSkins[FindSkin(skinID)].sModelFile.c_str()); + strcpy((char*)0x6A94A0, vSkins[FindSkin(skinID)].sRootName.c_str()); + *(int*)0x7AE94C = vSkins[FindSkin(skinID)].iFlag; + + + sprintf(fullTxdPath, "%s%s", "./levels", txdFile); + sprintf(fullDffPath, "%s%s", "./levels", dffFile); + + // TODO: update with proper functions? + + printf("Loading %s\n", fullDffPath); + + result = CallMethodAndReturn(*(int*)0x736DB8, fullTxdPath); + CallMethod<0x59B3F0, int*, char*, char*>(&(*(int*)0x69BC90), result, fullDffPath); + return CallMethodAndReturn(*(int*)0x736DB8, result); +} + +int eSkinLoader::FindSkin(int skinID) +{ + int iFind = 0; + + for (int i = 0; i < vSkins.size(); i++) + { + if (vSkins[i].iID == skinID) + { + iFind = i; + break; + } + } + return iFind; +} + +void __declspec(naked) SkinLoader_HookWeapon() +{ + static int jmpTrue = 0x45FD98; + static int jmpFalse = 0x45FDA0; + + + if (eSkinLoader::vSkins[eSkinLoader::FindSkin(CEntityManager::ms_playerCharacterID)].iShowWeapons == 1) + _asm jmp jmpTrue + else + _asm jmp jmpFalse +} diff --git a/source/code/plugin/eSkinLoader.h b/source/code/plugin/eSkinLoader.h new file mode 100644 index 0000000..3421c04 --- /dev/null +++ b/source/code/plugin/eSkinLoader.h @@ -0,0 +1,25 @@ +#pragma once +#include +#include + +struct eSkinEntry +{ + int iID; + std::string sModelFile; + std::string sTxdFile; + std::string sRootName; + int iShowWeapons; + int iFlag; +}; + +class eSkinLoader { +public: + static std::vector vSkins; + + static void InitHooks(); + static int ReadFile(const char* name); + static int Hook(int skinID); + static int FindSkin(int skinID); +}; + +void SkinLoader_HookWeapon(); \ No newline at end of file diff --git a/source/code/plugin/eStatsManager.cpp b/source/code/plugin/eStatsManager.cpp new file mode 100644 index 0000000..17c77d2 --- /dev/null +++ b/source/code/plugin/eStatsManager.cpp @@ -0,0 +1,230 @@ +#include "eStatsManager.h" +#include "..\manhunt\core.h" +#include "..\manhunt\Frontend.h" +#include +#include +#include +#include "..\manhunt\Filenames.h" +#include "..\manhunt\Scene.h" +#include "..\manhunt\Inventory.h" +#include "..\manhunt\Collectable.h" +#include "eLog.h" +#include "..\core\eSettingsManager.h" +int eStatsManager::m_numberStats[TOTAL_NUM_STATS]; +float eStatsManager::m_floatStats[TOTAL_FLT_STATS]; +char* eStatsManager::m_numberStatsNames[TOTAL_NUM_STATS]; +bool eStatsManager::m_bDangerStatIncreased; + +void eStatsManager::InitHooks() +{ + InjectHook(0x4811F6, eStatsManager::HookExecutionsStat, PATCH_CALL); + InjectHook(0x4ECDE3, eStatsManager::HookKillsStat, PATCH_CALL); + InjectHook(0x45E688, eStatsManager::HookPainkillersStat, PATCH_CALL); + + +// CreateThread(nullptr, 0, reinterpret_cast(eStatsManager::StatsWatcher), nullptr, 0, nullptr); + +} + +void eStatsManager::Initialize() +{ + + SetDefaults(); + LoadFromFile(); + + m_numberStatsNames[STAT_PLR_DEAD] = "Times Died"; + m_numberStatsNames[STAT_PLR_TRQ] = "Times Stunned"; + m_numberStatsNames[STAT_PLR_KICKS] = "Kicks & Body Attacks"; + m_numberStatsNames[STAT_KILLS] = "Kills"; + m_numberStatsNames[STAT_EXECS] = "Executions"; + m_numberStatsNames[STAT_PAINKILLERS] = "Painkillers Taken"; + m_numberStatsNames[STAT_HEADS_BOOM] = "Heads Exploded"; + m_numberStatsNames[STAT_BAG_EXECS] = "Plastic Bag Executions"; + m_numberStatsNames[STAT_SHARD_EXECS] = "Glass Shard Executions"; + m_numberStatsNames[STAT_WIRE_EXECS] = "Wire Executions"; + m_numberStatsNames[STAT_SPIKE_EXECS] = "Wooden Spike Executions"; + m_numberStatsNames[STAT_AXE_EXECS] = "Axe Executions"; + m_numberStatsNames[STAT_BLACK_EXECS] = "Blackjack Executions"; + m_numberStatsNames[STAT_CROWBAR_EXECS] = "Crowbar Executions"; + m_numberStatsNames[STAT_HAMMER_EXECS] = "Hammer Executions"; + m_numberStatsNames[STAT_KNIFE_EXECS] = "Knife Executions"; + m_numberStatsNames[STAT_MACHETE_EXECS] = "Machete Executions"; + m_numberStatsNames[STAT_CLEAVER_EXECS] = "Cleaver Executions"; + m_numberStatsNames[STAT_ICEPICK_EXECS] = "Ice Pick Executions"; + m_numberStatsNames[STAT_SICKLE_EXECS] = "Sickle Executions"; + m_numberStatsNames[STAT_NIGHTSTICK_EXECS] = "Nightstick Executions"; + m_numberStatsNames[STAT_MBAT_EXECS] = "Metal Bat Executions"; + m_numberStatsNames[STAT_WBAT_EXECS] = "Wooden Bat Executions"; + m_numberStatsNames[STAT_BATBLADES_EXECS] = "Spiked Bat Executions"; + m_numberStatsNames[STAT_CHAINSAW_EXECS] = "Chainsaw Executions"; + +} + +void eStatsManager::IncrementStat(int id) +{ + m_numberStats[id]++; +} + +char * eStatsManager::GetStatName(int id) +{ + + if (m_numberStatsNames[id]) + return m_numberStatsNames[id]; + else + return nullptr; +} + +int eStatsManager::GetStat(int id) +{ + return m_numberStats[id]; +} + +void eStatsManager::SaveToFile() +{ + std::filesystem::current_path(CFileNames::GetMyDocumentsDirectory()); + std::ofstream StatsFile("stats.dat", std::ofstream::binary); + + int header = 'STAT'; + StatsFile.write((char*)&header, sizeof(int)); + + for (int i = 0; i < TOTAL_NUM_STATS; i++) + StatsFile.write((char*)&m_numberStats[i], sizeof(int)); + for (int i = 0; i < TOTAL_FLT_STATS; i++) + StatsFile.write((char*)&m_floatStats[i], sizeof(float)); + + StatsFile.close(); +;} + +void eStatsManager::LoadFromFile() +{ + + std::filesystem::current_path(CFileNames::GetMyDocumentsDirectory()); + std::ifstream pFile("stats.dat", std::ifstream::binary); + + if (!pFile) + { + SetDefaults(); + eLog::Message(__FUNCTION__, "Failed to load statistics from file"); + } + + eStatsFile file; + pFile.read((char*)&file, sizeof(eStatsFile)); + + if (file.header == 'STAT') + { + for (int i = 0; i < TOTAL_NUM_STATS; i++) + m_numberStats[i] = file.integerStats[i]; + for (int i = 0; i < TOTAL_FLT_STATS; i++) + m_floatStats[i] = file.m_floatStats[i]; + eLog::Message(__FUNCTION__, "Loaded statistics from file"); + } +} + +void eStatsManager::SetDefaults() +{ + if (!eSettingsManager::bEnableStatsManager) + return; + + for (int i = 0; i < TOTAL_NUM_STATS; i++) + m_numberStats[i] = 0; + for (int i = 0; i < TOTAL_FLT_STATS; i++) + m_floatStats[i] = 0.0f; +} + +void eStatsManager::StatsWatcher() +{ + while (true) + { + if (!CScene::ms_stepMode && CFrontend::m_gameIsRunning) + { + //if (*(int*)0x799F74) + // { + // eStatsManager::IncrementStat(STAT_PLR_DANG); + //} + } + + } + Sleep(1); + +} + +void eStatsManager::HookKillsStat() +{ + + IncrementStat(STAT_KILLS); + Call<0x5B63A0>(); +} + +void eStatsManager::HookExecutionsStat() +{ + IncrementStat(STAT_EXECS); + + switch (CGameInventory::GetCurrentItem()) + { + case CT_BAG: + IncrementStat(STAT_BAG_EXECS); + break; + case CT_SHARD: + case CT_PIGSY_SHARD: + IncrementStat(STAT_SHARD_EXECS); + break; + case CT_WIRE: + case CT_PIGSY_WIRE: + IncrementStat(STAT_WIRE_EXECS); + break; + case CT_WOODEN_SPIKE: + IncrementStat(STAT_SPIKE_EXECS); + break; + case CT_AXE: + IncrementStat(STAT_AXE_EXECS); + break; + case CT_SMALL_BAT: + IncrementStat(STAT_BLACK_EXECS); + break; + case CT_CROWBAR: + IncrementStat(STAT_CROWBAR_EXECS); + break; + case CT_HAMMER: + IncrementStat(STAT_HAMMER_EXECS); + break; + case CT_KNIFE: + IncrementStat(STAT_KNIFE_EXECS); + break; + case CT_MACHETE: + IncrementStat(STAT_MACHETE_EXECS); + break; + case CT_CLEAVER: + IncrementStat(STAT_CLEAVER_EXECS); + break; + case CT_ICEPICK: + IncrementStat(STAT_ICEPICK_EXECS); + break; + case CT_SICKLE: + IncrementStat(STAT_SICKLE_EXECS); + break; + case CT_NIGHTSTICK: + IncrementStat(STAT_NIGHTSTICK_EXECS); + break; + case CT_BASEBALL_BAT: + IncrementStat(STAT_MBAT_EXECS); + break; + case CT_W_BASEBALL_BAT: + IncrementStat(STAT_WBAT_EXECS); + break; + case CT_BASEBALL_BAT_BLADES: + IncrementStat(STAT_BATBLADES_EXECS); + break; + case CT_CHAINSAW: + IncrementStat(STAT_CHAINSAW_EXECS); + break; + } + + Call<0x5B62E0>(); +} + +void eStatsManager::HookPainkillersStat(int i) +{ + IncrementStat(STAT_PAINKILLERS); + Call<0x5DFB60, int>(i); +} + diff --git a/source/code/plugin/eStatsManager.h b/source/code/plugin/eStatsManager.h new file mode 100644 index 0000000..9543f97 --- /dev/null +++ b/source/code/plugin/eStatsManager.h @@ -0,0 +1,75 @@ +#pragma once + +#define STATS_PER_PAGE 10 + + +enum eStatsNumberIDs { + STAT_PLR_DEAD, // done + STAT_PLR_TRQ,// done + STAT_PLR_KICKS, + STAT_KILLS,// done + STAT_EXECS,// done + STAT_PAINKILLERS,// done + STAT_HEADS_BOOM, + STAT_BAG_EXECS, + STAT_SHARD_EXECS, + STAT_WIRE_EXECS, + STAT_SPIKE_EXECS, + STAT_AXE_EXECS, + STAT_BLACK_EXECS, + STAT_CROWBAR_EXECS, + STAT_HAMMER_EXECS, + STAT_KNIFE_EXECS, + STAT_MACHETE_EXECS, + STAT_CLEAVER_EXECS, + STAT_ICEPICK_EXECS, + STAT_SICKLE_EXECS, + STAT_NIGHTSTICK_EXECS, + STAT_MBAT_EXECS, + STAT_WBAT_EXECS, + STAT_BATBLADES_EXECS, + STAT_CHAINSAW_EXECS, + STAT_25, + STAT_26, + STAT_27, + STAT_28, + STAT_29, + STAT_30, + TOTAL_NUM_STATS +}; + + +enum eStatsFloatIDs { + STAT_RUN, + TOTAL_FLT_STATS +}; + +struct eStatsFile { + int header; + int integerStats[TOTAL_NUM_STATS]; + float m_floatStats[TOTAL_FLT_STATS]; +}; + + +class eStatsManager { +private: + static int m_numberStats[TOTAL_NUM_STATS]; + static float m_floatStats[TOTAL_FLT_STATS]; + static char* m_numberStatsNames[TOTAL_NUM_STATS]; + static bool m_bDangerStatIncreased; +public: + static void InitHooks(); + static void Initialize(); + static void IncrementStat(int id); + static char* GetStatName(int id); + static int GetStat(int id); + static void SaveToFile(); + static void LoadFromFile(); + static void SetDefaults(); + static void StatsWatcher(); + + // hooks + static void HookKillsStat(); + static void HookExecutionsStat(); + static void HookPainkillersStat(int i); +}; \ No newline at end of file diff --git a/source/code/plugin/menu/eMenu.cpp b/source/code/plugin/menu/eMenu.cpp new file mode 100644 index 0000000..e5b7b74 --- /dev/null +++ b/source/code/plugin/menu/eMenu.cpp @@ -0,0 +1,760 @@ +#include "eMenu.h" +#include +#include + +// manhunt includes + +#include "..\..\manhunt\Inventory.h" +#include "..\..\manhunt\Cheats.h" +#include "..\..\manhunt\Frontend.h" +#include "..\..\manhunt\Renderer.h" +#include "..\..\manhunt\EntityManager.h" +#include "..\..\manhunt\Collectable.h" +#include "..\..\manhunt\Anim.h" +#include "..\..\manhunt\Scene.h" +#include "..\..\manhunt\Inventory.h" +#include "..\..\manhunt\Character.h" +#include "..\..\manhunt\AmmoWeapon.h" +#include "..\..\manhunt\Player.h" + + +#include "..\..\core\eSettingsManager.h" +#include "..\..\core\eMain.h" +#include "..\..\plugin\eCustomAnimManager.h" +#include "..\..\manhunt\core.h" +#include "..\..\..\IniReader.h" + +#include "..\MHcommon.h" + + +// custom + +int bDisplayPlayerCoords = 0; +int bControllerDebug = 0; +int bDisplaySavedPositionMarker = 0; +int bGodMode = 0; +int bPlayerInfiniteHealth = 0; +int bFallDamage = 1; + +int bSilenceWeapons = 0; + +char& bTimer = *(char*)0x7D5A08; +char& bActivateTimer = *(char*)0x7D5A0C; +char& bBodyCount = *(char*)0x7D5A18; + +int bEnableKillCounter = 0; +int bInfiniteAmmo = 0; + + +static unsigned int iTimer = GetTickCount(); +char msgBuffer[256]; +char buffer[256]; +eMenu TheMenu; + + +void eMenu::PreInitialize() +{ + + CIniReader ini(""); + + KeyEnableMenu = ini.ReadInteger("Keys.Menu", "keyMenuEnable", VK_F2); + KeyMenuExecute = ini.ReadInteger("Keys.Menu", "keyMenuExecute", VK_RETURN); + KeyMenuGoBack = ini.ReadInteger("Keys.Menu", "keyMenuBack", VK_BACK); + KeyMenuItemDOWN = ini.ReadInteger("Keys.Menu", "keyMenuDown", VK_DOWN); + KeyMenuItemUP = ini.ReadInteger("Keys.Menu", "keyMenuUp", VK_UP); + KeyMenuItemLEFT = ini.ReadInteger("Keys.Menu", "keyMenuLeft", VK_LEFT); + KeyMenuItemRIGHT = ini.ReadInteger("Keys.Menu", "keyMenuRight", VK_RIGHT); +} + +void eMenu::Initialize() +{ + Clear(); + savedPosition = { 0,0,0 }; + + AddToggleIntEntry("Infinite Health", &bPlayerInfiniteHealth); + AddToggleIntEntry("God Mode", &bGodMode); + AddToggleIntEntry("Fall Damage", &bFallDamage); + AddFunctionEntry("Save Position", SavePosition); + AddFunctionEntry("Load Position", LoadPosition); + AddToggleIntEntry("Display Coordinates", &bDisplayPlayerCoords); + AddToggleIntEntry("Display Saved Position", &bDisplaySavedPositionMarker); + AddCategory("Player"); + + + // pistols + AddWeaponEntry(CT_6SHOOTER); + AddWeaponEntry(CT_GLOCK); + AddWeaponEntry(CT_DESERT_EAGLE); + AddWeaponEntry(CT_UZI); + AddWeaponEntry(CT_NAILGUN); + AddWeaponEntry(CT_TRANQ_RIFLE); + // rifles + AddWeaponEntry(CT_SHOTGUN); + AddWeaponEntry(CT_SHOTGUN_TORCH); + AddWeaponEntry(CT_COLT_COMMANDO); + AddWeaponEntry(CT_SNIPER_RIFLE); + AddWeaponEntry(CT_SAWNOFF); + // melee + AddWeaponEntry(CT_BASEBALL_BAT); + AddWeaponEntry(CT_BASEBALL_BAT_BLADES); + AddWeaponEntry(CT_W_BASEBALL_BAT); + AddWeaponEntry(CT_CROWBAR); + AddWeaponEntry(CT_SICKLE); + AddWeaponEntry(CT_NIGHTSTICK); + AddWeaponEntry(CT_CAN); + AddWeaponEntry(CT_BOTTLE); + AddWeaponEntry(CT_BRICK_HALF); + AddWeaponEntry(CT_WIRE); + AddWeaponEntry(CT_SHARD); + AddWeaponEntry(CT_HAMMER); + AddWeaponEntry(CT_CLEAVER); + AddWeaponEntry(CT_SMALL_BAT); + AddWeaponEntry(CT_ICEPICK); + AddWeaponEntry(CT_AXE); + AddWeaponEntry(CT_KNIFE); + AddWeaponEntry(CT_MACHETE); + AddWeaponEntry(CT_WOODEN_SPIKE); + AddWeaponEntry(CT_CHAINSAW); + AddWeaponEntry(CT_CHAINSAW_PLAYER); + AddWeaponEntry(CT_PIGSY_WIRE); + AddWeaponEntry(CT_PIGSY_SHARD); + AddCategory("Weapons", true); + + AddToggleCharEntry("Timer", &bTimer); + AddToggleCharEntry("Body Count", &bBodyCount); + AddToggleIntEntry("Enable Body Count", &bEnableKillCounter); + AddCategory("HUD"); + + + AddToggleCharEntry("Cheats Active", (char*)&CCheatHandler::m_bCheatsActive); + AddToggleIntEntry("Helium Hunters", &CCheatHandler::m_heliumHunters); + AddToggleIntEntry("Runner", &CCheatHandler::m_runner); + AddToggleIntEntry("Regenerate", &CCheatHandler::m_regenerate); + AddToggleIntEntry("Invisiblity", &CCheatHandler::m_invisibility); + AddToggleIntEntry("Super Punch", &CCheatHandler::m_superPunch); + + AddCategory("Cheats"); + + AddToggleIntEntry("Log Gamepad",&bControllerDebug); + AddToggleIntEntry("Silence Firearms", &bSilenceWeapons); + AddToggleIntEntry("Infinite Ammo", &bInfiniteAmmo); + AddCategory("Misc."); + + +} + +void eMenu::ProcessMenu() +{ + + if (bPlayerInfiniteHealth) + { + if (CScene::FindPlayer()) + { + CScene::FindPlayer()->m_fHealth = 100.0f; + } + } + + if (CScene::FindPlayer()) + CScene::FindPlayer()->SetFlag(0x100, bGodMode); + + + if (bEnableKillCounter) + CFrontend::ms_cnt = *(int*)0x7B7D84 + *(int*)0x7B7DA0; + + + if (!bFallDamage) + { + Patch(0x4313F7 + 3,100.0f); + Patch(0x43152B + 3,100.0f); + } + else + { + Patch(0x4313F7 + 3,-1.0f); + Patch(0x43152B + 3,-1.0f); + } + + if (bSilenceWeapons) + Patch(0x4C9C92 + 1, 8); + else + Patch(0x4C9C92 + 1, 7); + + + if (bInfiniteAmmo) + Patch(0x4F9073 + 6, 0); + else + Patch(0x4F9073 + 6, 1); + + + + if (bDisplayPlayerCoords) + { + sprintf(buffer, "X: %.3f Y: %.3f Z: %.3f", *(float *)0x821430, *(float *)0x821434, *(float *)0x821438); + CFrontend::CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(buffer, 0.552f, 0, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + CFrontend::CFrontend::SetDrawRGBA(255, 255, 255, 255); + CFrontend::Print8(buffer, 0.554f, 0, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + } + + if (bControllerDebug) + { + sprintf(buffer, "GAMEPAD BUTTON 0x%X", *(short*)0x725684); + CFrontend::CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(buffer, 0.152f, 0.5, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + CFrontend::CFrontend::SetDrawRGBA(180, 255, 180, 255); + CFrontend::Print8(buffer, 0.154f, 0.5f, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + + sprintf(buffer, "ANALOG STICK %d", *(short*)(0x725684 + 2)); + CFrontend::CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(buffer, 0.152f, 0.55, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + CFrontend::CFrontend::SetDrawRGBA(180, 255, 180, 255); + CFrontend::Print8(buffer, 0.154f, 0.55f, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + + + sprintf(buffer, "STICK STATES %f %f", *(float*)0x725674 ,*(float*)0x725678); + CFrontend::CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(buffer, 0.152f, 0.6, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + CFrontend::CFrontend::SetDrawRGBA(180, 255, 180, 255); + CFrontend::Print8(buffer, 0.154f, 0.6f, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + } + + + if (bDisplaySavedPositionMarker) + { + sprintf(buffer, "X: %.3f Y: %.3f Z: %.3f", savedPosition.x,savedPosition.y,savedPosition.z); + CFrontend::CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(buffer, 0.552f, 0.1f, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + CFrontend::CFrontend::SetDrawRGBA(255, 255, 255, 255); + CFrontend::Print8(buffer, 0.554f, 0.1f, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + } + if (IsWindowFocused()) + ProcessToggle(); + + if (bDisplayMenu) + { + DrawMenu(); + + if (IsWindowFocused()) + ProcessControls(); + } + + +} + +void eMenu::ProcessToggle() +{ + if (KeyHit(KeyEnableMenu)) + { + if (GetTickCount() - iTimer <= 240) return; + iTimer = GetTickCount(); + bDisplayMenu ^= 1; + iCurrentCategory = 0; + iCurrentItem = 0; + bCategoryOpen = false; + bNavigatingInCategory = false; + vCategories[iCurrentCategory].vPages.clear(); + vCategories[iCurrentCategory].vWeapons.clear(); + vTempPages.clear(); + vTempWeapons.clear(); + } +} + +void eMenu::ProcessControls() +{ + if (bPressedEnter) + ProcessEnter(); + + if (KeyHit(KeyMenuItemUP)) + { + + + if (GetTickCount() - iTimer <= 100) return; + iTimer = GetTickCount(); + if (bCategoryOpen && vCategories[iCurrentCategory].bHasItems) + { + + iCurrentItem--; + if (iCurrentItem < 0) + iCurrentItem = iTotalItems - 1; + } + + else + iCurrentCategory--; + } + + if (KeyHit(KeyMenuItemDOWN)) + { + + + if (GetTickCount() - iTimer <= 100) return; + iTimer = GetTickCount(); + if (bCategoryOpen && vCategories[iCurrentCategory].bHasItems) + { + iCurrentItem++; + if (iCurrentItem + 1 > iTotalItems) + iCurrentItem = 0; + + } + else + iCurrentCategory++; + + + } + + if (KeyHit(KeyMenuItemLEFT)) + { + if (GetTickCount() - iTimer <= 100) return; + iTimer = GetTickCount(); + iCurrentItem = 0; + iCurrentPage--; + } + if (KeyHit(KeyMenuItemRIGHT)) + { + if (GetTickCount() - iTimer <= 140) return; + iTimer = GetTickCount(); + iCurrentItem = 0; + iCurrentPage++; + } + + if (!bCategoryOpen && !bNavigatingInCategory) + { + if (vCategories[iCurrentCategory].bHasItems && vCategories[iCurrentCategory].vItems.size() > 0) + { + if (KeyHit(KeyMenuExecute)) + { + if (GetTickCount() - iTimer <= 140) return; + iTimer = GetTickCount(); + if (vCategories[iCurrentCategory].bIsWeapon) + { + vCategories[iCurrentCategory].vWeapons.clear(); + vCategories[iCurrentCategory].bHasBeenWeaponsPopulated = false; + + } + vTempPages.clear(); + vCategories[iCurrentCategory].vPages.clear(); + vCategories[iCurrentCategory].bHaveBeenPagesCalculated = false; + bCategoryOpen = true; + bPressedEnter = true; + bNavigatingInCategory = true; + } + } + + } + + if (bCategoryOpen) + { + if (KeyHit(KeyMenuGoBack)) + { + if (vCategories[iCurrentCategory].bIsWeapon) + { + vCategories[iCurrentCategory].vWeapons.clear(); + vTempWeapons.clear(); + vCategories[iCurrentCategory].bHasBeenWeaponsPopulated = false; + + } + + if (GetTickCount() - iTimer <= 140) return; + iTimer = GetTickCount(); + bCategoryOpen = false; + bNavigatingInCategory = false; + vTempPages.clear(); + vCategories[iCurrentCategory].vPages.clear(); + vCategories[iCurrentCategory].bHaveBeenPagesCalculated = false; + iCurrentItem = 0; + } + } + + if (bNavigatingInCategory && bCategoryOpen && !bPressedEnter) + { + if (KeyHit(KeyMenuExecute)) + { + if (vCategories[iCurrentCategory].bIsWeapon && vCategories[iCurrentCategory].bHasBeenWeaponsPopulated) + { + int weapon = iCurrentItem + vCategories[iCurrentCategory].vPages[iCurrentPage].iStart; + if (vCategories[iCurrentCategory].vWeapons[weapon].bIsWeapon) + GiveWeaponToPlayer(vCategories[iCurrentCategory].vWeapons[weapon].iWeaponID); + + } + if (vCategories[iCurrentCategory].vItems[iCurrentItem].bIsFunction) + { + int item = iCurrentItem + vCategories[iCurrentCategory].vPages[iCurrentPage].iStart; + vCategories[iCurrentCategory].vItems[item].fFunc(); + } + if (vCategories[iCurrentCategory].vItems[iCurrentItem].bIsCharToggle || vCategories[iCurrentCategory].vItems[iCurrentItem].bIsShortToggle + || vCategories[iCurrentCategory].vItems[iCurrentItem].bIsIntegerToggle) + { + int item = iCurrentItem + vCategories[iCurrentCategory].vPages[iCurrentPage].iStart; + + if (vCategories[iCurrentCategory].vItems[item].bIsCharToggle) + { + if (GetTickCount() - iTimer <= 140) return; + iTimer = GetTickCount(); + *vCategories[iCurrentCategory].vItems[item].ptrCharValue ^= 1; + } + if (vCategories[iCurrentCategory].vItems[item].bIsIntegerToggle) + { + if (GetTickCount() - iTimer <= 140) return; + iTimer = GetTickCount(); + *vCategories[iCurrentCategory].vItems[item].ptrIntValue ^= 1; + } + } + } + } + + + + if (iCurrentPage + 1 > vCategories[iCurrentCategory].vPages.size()) iCurrentPage = 0; + if (iCurrentPage < 0) iCurrentPage = vCategories[iCurrentCategory].vPages.size() - 1; + if (iCurrentCategory + 1 > vCategories.size()) iCurrentCategory = 0; + if (iCurrentCategory < 0) iCurrentCategory = vCategories.size() - 1; + +} + +void eMenu::DrawMenu() +{ + if (bDisplayMenu) + { + // control execution + + for (int i = 0; i < vCategories.size(); i++) + { + + // sprintf(msgBuffer, "ermaccer / dixmor-hospital.com", iCurrentPage + 1, vCategories[iCurrentCategory].vPages.size()); + // CFrontend::SetDrawRGBA(0, 0, 0, 255); + // CFrontend::Print8(msgBuffer, 0.048f, 0.012f, 0.5f, 0.5f, 0.0, FONT_TYPE_DEFAULT); + // CFrontend::SetDrawRGBA(255, 255, 255, 255); + // CFrontend::Print8(msgBuffer, 0.050f, 0.010f, 0.5f, 0.5f, 0.0, FONT_TYPE_DEFAULT); + + + CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(vCategories[i].strName.c_str(), 0.048f, 0.102f + 0.04 * i, 0.6f, 0.6f, 0.0, FONT_TYPE_DEFAULT); + if (i == iCurrentCategory) + CFrontend::SetDrawRGBA(51, 153, 255, 255); + else + CFrontend::SetDrawRGBA(255, 255, 255, 255); + CFrontend::Print8(vCategories[i].strName.c_str(), 0.050f, 0.10f + 0.04 * i, 0.6f, 0.6f, 0.0, FONT_TYPE_DEFAULT); + + // draw sub items + if (vCategories[i].bHasItems && bCategoryOpen) + { + if (i == iCurrentCategory) + { + if (vCategories[i].bIsWeapon) + { + if (!vCategories[i].bHasBeenWeaponsPopulated) + { + for (int j = 0; j < vCategories[i].vItems.size(); j++) + { + if (vCategories[i].vItems[j].bIsWeapon) + { + if (CEntityManager::GetEntityTypeDataFromName(CCollectable::FastGetNameStringFromType(vCategories[i].vItems[j].iWeaponID))) + vTempWeapons.push_back(vCategories[i].vItems[j]); + } + } + vCategories[i].vWeapons = vTempWeapons; + vCategories[i].bHasBeenWeaponsPopulated = true; + } + + if (!vCategories[iCurrentCategory].bHaveBeenPagesCalculated) + { + eMenuPage page; + int itemCounter = 0; + int fullPages = vCategories[iCurrentCategory].vWeapons.size() / 16; + int leftOver = vCategories[iCurrentCategory].vWeapons.size() % 16; + int lastEnd = 0; + page.iStart = 0; + for (int p = 0; p < vCategories[iCurrentCategory].vWeapons.size(); p++) + { + if (itemCounter >= 16) + { + page.iEnd = p; + page.iStart += lastEnd; + lastEnd = page.iEnd - page.iStart; + itemCounter = 0; + vTempPages.push_back(page); + } + itemCounter++; + } + page.iEnd = vCategories[iCurrentCategory].vWeapons.size(); + page.iStart = vCategories[iCurrentCategory].vWeapons.size() - leftOver; + vTempPages.push_back(page); + vCategories[iCurrentCategory].vPages = vTempPages; + vCategories[iCurrentCategory].bHaveBeenPagesCalculated = true; + } + iTotalItems = vCategories[iCurrentCategory].vPages[iCurrentPage].iEnd - vCategories[iCurrentCategory].vPages[iCurrentPage].iStart; + + for (int j = vCategories[iCurrentCategory].vPages[iCurrentPage].iStart; j < vCategories[iCurrentCategory].vPages[iCurrentPage].iEnd; j++) + { + iActualItemID = j; + std::string entry = vCategories[i].vWeapons[j].name.c_str(); + CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(entry.c_str(), 0.122f, 0.102f + 0.04 * (j - (vCategories[iCurrentCategory].vPages[iCurrentPage].iStart)), 0.6f, 0.6f, 0.0, FONT_TYPE_DEFAULT); + if ((j - (vCategories[iCurrentCategory].vPages[iCurrentPage].iStart)) == iCurrentItem) + CFrontend::SetDrawRGBA(51, 153, 255, 255); + else + CFrontend::SetDrawRGBA(255, 255, 255, 255); + CFrontend::Print8(entry.c_str(), 0.124f, 0.10f + 0.04 * (j - (vCategories[iCurrentCategory].vPages[iCurrentPage].iStart)), 0.6f, 0.6f, 0.0, FONT_TYPE_DEFAULT); + } + if (vCategories[iCurrentCategory].vPages.size() > 1) + { + sprintf(msgBuffer, "Page %d/%d", iCurrentPage + 1, vCategories[iCurrentCategory].vPages.size()); + CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(msgBuffer, 0.122f, 0.808f, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + CFrontend::SetDrawRGBA(255, 255, 255, 255); + CFrontend::Print8(msgBuffer, 0.124f, 0.810f, 0.7f, 0.7f, 0.0, FONT_TYPE_DEFAULT); + } + + } + else + { + iTotalItems = vCategories[i].vItems.size(); + + if (!vCategories[iCurrentCategory].bHaveBeenPagesCalculated) + { + eMenuPage page; + int itemCounter = 0; + int fullPages = vCategories[iCurrentCategory].vItems.size() / 16; + int leftOver = vCategories[iCurrentCategory].vItems.size() % 16; + int lastEnd = 0; + page.iStart = 0; + for (int p = 0; p < vCategories[iCurrentCategory].vItems.size(); p++) + { + if (itemCounter >= 16) + { + page.iEnd = p; + page.iStart += lastEnd; + lastEnd = page.iEnd - page.iStart; + itemCounter = 0; + vTempPages.push_back(page); + } + itemCounter++; + } + page.iEnd = vCategories[iCurrentCategory].vItems.size(); + page.iStart = vCategories[iCurrentCategory].vItems.size() - leftOver; + vTempPages.push_back(page); + vCategories[iCurrentCategory].vPages = vTempPages; + vCategories[iCurrentCategory].bHaveBeenPagesCalculated = true; + } + + for (int j = vCategories[iCurrentCategory].vPages[iCurrentPage].iStart; j < vCategories[iCurrentCategory].vPages[iCurrentPage].iEnd; j++) + { + iActualItemID = j; + std::string entry = vCategories[i].vItems[j].name.c_str(); + if (vCategories[i].vItems[j].bIsCharToggle || vCategories[i].vItems[j].bIsShortToggle || vCategories[i].vItems[j].bIsIntegerToggle) + { + entry.append(" = "); + if (vCategories[i].vItems[j].bIsCharToggle) + entry.append(GetStatusAsString(*vCategories[i].vItems[j].ptrCharValue)); + if (vCategories[i].vItems[j].bIsIntegerToggle) + entry.append(GetStatusAsString(*vCategories[i].vItems[j].ptrIntValue)); + } + + + + + + CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(entry.c_str(), 0.122f, 0.102f + 0.04 * j, 0.6f, 0.6f, 0.0, FONT_TYPE_DEFAULT); + if (j == iCurrentItem) + CFrontend::SetDrawRGBA(51, 153, 255, 255); + else + CFrontend::SetDrawRGBA(255, 255, 255, 255); + CFrontend::Print8(entry.c_str(), 0.124f, 0.10f + 0.04 * j, 0.6f, 0.6f, 0.0, FONT_TYPE_DEFAULT); + + + + if (vCategories[iCurrentCategory].vPages.size() > 1) + { + sprintf(msgBuffer, "Page %d/%d", iCurrentPage + 1, vCategories[iCurrentCategory].vPages.size()); + CFrontend::SetDrawRGBA(0, 0, 0, 255); + CFrontend::Print8(msgBuffer, 0.122f, 0.808f, 0.6f, 0.6f, 0.0, FONT_TYPE_DEFAULT); + CFrontend::SetDrawRGBA(255, 255, 255, 255); + CFrontend::Print8(msgBuffer, 0.124f, 0.810f, 0.6f, 0.6f, 0.0, FONT_TYPE_DEFAULT); + } + } + } + + } + } + + } + + } +} +void eMenu::ProcessEnter() +{ + if (GetTickCount() - iTimer <= 155) return; + iTimer = GetTickCount(); + bPressedEnter = false; +} + +void eMenu::Clear() +{ + vCategories.clear(); + vTempItems.clear(); + vTempPages.clear(); + vTempWeapons.clear(); + vTempAnims.clear(); + bDisplayMenu = false; + iCurrentItem = 0; + iActualItemID = 0; + iCurrentPage = 0; + iCurrentCategory = 0; + iBaseCategoryID = 0; + iTotalItems = 0; + bNavigatingInCategory = false; + bCategoryOpen = false; + bPressedEnter = false; + bIsHoldingMenu = false; + +} + + + +void eMenu::AddCategory(std::string name, bool isWeap) +{ + eMenuCategory newCat; + newCat.strName = name; + newCat.bIsWeapon = isWeap; + newCat.iID = iBaseCategoryID; + newCat.bHasBeenWeaponsPopulated = false; + newCat.bHasBeenAnimsPopulated = false; + newCat.bHaveBeenPagesCalculated = false; + newCat.iPages = 0; + if (vTempItems.size() > 0) + { + newCat.vItems = vTempItems; + newCat.bHasItems = true; + } + + vCategories.push_back(newCat); + iBaseCategoryID++; + vTempItems.clear(); +} + +void eMenu::AddAnimsCategory(std::string name) +{ + eMenuCategory newCat; + newCat.strName = name; + newCat.bIsWeapon = false; + newCat.bIsAnims = true; + newCat.iID = iBaseCategoryID; + newCat.bHasBeenWeaponsPopulated = false; + newCat.bHasBeenAnimsPopulated = false; + newCat.bHaveBeenPagesCalculated = false; + newCat.iPages = 0; + if (vTempItems.size() > 0) + { + newCat.vItems = vTempItems; + newCat.bHasItems = true; + } + + vCategories.push_back(newCat); + iBaseCategoryID++; + vTempItems.clear(); +} + +void eMenu::AddItem(std::string name, bool isChar, bool isShort, bool isInt, bool isFunc, bool isWeapon, int weapID, char* ptrChar, short* ptrShort, int* ptrInt, std::function func, + bool adjInt, int adjStep, int adjMin, int adjMax, bool adjFloat, float fAdjStep, float fAdjMin, float fAdjMax, bool isAnim, std::string strAnim) +{ + eMenuItem item; + item.ptrIntValue = ptrInt; + item.ptrShortValue = ptrShort; + item.ptrCharValue = ptrChar; + item.bIsCharToggle = isChar; + item.bIsShortToggle = isShort; + item.bIsIntegerToggle = isInt; + item.bIsFunction = isFunc; + item.bIsWeapon = isWeapon; + item.iWeaponID = weapID; + item.name = name; + item.fFunc = func; + item.bIsAdjustable = adjInt; + item.bIsAdjustableFloat = adjFloat; + item.iStep = adjStep; + item.iAdjustMin = adjMin; + item.iAdjustMax = adjMax; + item.fStep = fAdjStep; + item.fAdjustMax = fAdjMax; + item.fAdjustMin = fAdjMin; + item.bIsAnim = isAnim; + item.strAnim = strAnim; + + vTempItems.push_back(item); +} + +void eMenu::AddWeaponEntry(int weaponID) +{ + std::string str = CCollectable::FastGetNameStringFromType(weaponID);// GetRecordName(weaponID); + std::wstring wstr = CCollectable::GetNameKey16(weaponID); + if (!wstr.empty()) + str = std::string(wstr.begin(), wstr.end()); + + std::function dummy; + AddItem(str, false, false, false, false, true, weaponID, nullptr, nullptr, nullptr, dummy, 0, 0, 0, 0, 0, 0, 0, 0, 0, ""); +} + +void eMenu::AddAnimEntry(std::string str) +{ + std::function dummy; + AddItem(str, false, false, false, false, false, false, nullptr, nullptr, nullptr, dummy, 0, 0, 0, 0, 0, 0, 0, 0, true, str); +} + +void eMenu::AddToggleCharEntry(std::string name, char * ptr) +{ + std::function dummy; + AddItem(name, true, false, false, false, false, false, ptr, nullptr, nullptr, dummy, 0, 0, 0, 0, 0, 0, 0, 0, 0, ""); +} + +void eMenu::AddToggleIntEntry(std::string name, int * ptr) +{ + std::function dummy; + AddItem(name, false, false, true, false, false, false, nullptr, nullptr, ptr, dummy, 0, 0, 0, 0, 0, 0, 0, 0, 0, ""); +} + +void eMenu::AddFunctionEntry(std::string name, std::function func) +{ + AddItem(name, false, false, false, true, false, 0, nullptr, nullptr, nullptr, func, 0, 0, 0, 0, 0, 0, 0, 0, 0, ""); +} + +void eMenu::AddSliderIntEntry(std::string name, int * ptr, int min, int max, int step) +{ + std::function dummy; + AddItem(name, false, false, false, false, false, false, nullptr, nullptr, ptr, dummy, true, step, min, max, 0, 0, 0, 0, 0, ""); +} + + + +std::string GetStatusAsString(int value) +{ + if (value) return "true"; + else return "false"; +} + +std::string GetAnimationName(int id) +{ + char tmp[128] = {}; + sprintf(tmp, "%s", (char*)(0x6851C0 + (id * 48))); + return std::string(tmp, strlen(tmp)); +} + +void SavePosition() +{ + CEntity* plr = CScene::FindPlayer(); + CVector* pos = plr->GetLocation(); + TheMenu.savedPosition = *pos; +} + +void LoadPosition() +{ + CEntity* plr = CScene::FindPlayer(); + plr->SetLocation(&TheMenu.savedPosition); +} + +bool KeyHit(unsigned int keyCode) +{ + if (IsWindowFocused() && CFrontend::m_gameIsRunning) + return (GetKeyState(keyCode) & 0x8000) != 0; + else + return false; +} + diff --git a/source/code/plugin/menu/eMenu.h b/source/code/plugin/menu/eMenu.h new file mode 100644 index 0000000..1f36246 --- /dev/null +++ b/source/code/plugin/menu/eMenu.h @@ -0,0 +1,134 @@ +#pragma once +#include +#include +#include "..\..\manhunt\Vector.h" + +struct eMenuPage { + int iStart; + int iEnd; +}; + +struct eMenuItem { + std::string name; + std::string strAnim; + bool bIsWeapon; + bool bIsAnim; + bool bIsFunction; + bool bIsCharToggle; + bool bIsShortToggle; + bool bIsIntegerToggle; + bool bIsAdjustable; + bool bIsAdjustableFloat; + int iWeaponID; + char* ptrCharValue; + short* ptrShortValue; + int* ptrIntValue; + + + // GEN2: Adjustables + int iStep; + int iAdjustMax; + int iAdjustMin; + + float fStep; + float fAdjustMax; + float fAdjustMin; + + std::function fFunc; + // todo: add value items +}; + +struct eMenuCategory { + std::string strName; + int iID; + bool bHasItems; + bool bIsWeapon; + bool bIsAnims; + std::vector vItems; + std::vector vWeapons; + std::vector vAnims; + std::vector vPages; + bool bHasBeenWeaponsPopulated; + bool bHasBeenAnimsPopulated; + bool bHaveBeenPagesCalculated; + int iPages; +}; + +class eMenu { +private: + bool bDisplayMenu; + bool bCategoryOpen; + bool bNavigatingInCategory; + bool bPressedEnter; + bool bIsHoldingMenu; + + int iCurrentItem; + int iActualItemID; + int iCurrentPage; + int iCurrentCategory; + int iBaseCategoryID; + int iTotalItems; + + std::vector vTempItems; + std::vector vTempPages; + std::vector vTempWeapons; + std::vector vTempAnims; + std::vector vCategories; +public: + + CVector savedPosition; + + + // settings + int KeyEnableMenu; + int KeyQuickCameraMain; + int KeyQuickCameraSub; + int KeyQuickCameraTeleport; + int KeyMenuExecute; + int KeyMenuGoBack; + int KeyMenuItemUP; + int KeyMenuItemDOWN; + int KeyMenuItemLEFT; + int KeyMenuItemRIGHT; + + + + void PreInitialize(); + void Initialize(); + void ProcessMenu(); + void ProcessToggle(); + void ProcessControls(); + + void DrawMenu(); + void ProcessEnter(); + void Clear(); + // menu stuff + void AddCategory(std::string name, bool isWeapon = false); + void AddAnimsCategory(std::string name); + void AddItem(std::string name, bool isChar, bool isShort, bool isInt, bool isFunc, bool isWeapon, int weapID, char* ptrChar, short* ptrShort, int* ptrInt, std::function func, + bool adjInt, int adjStep, int adjMin, int adjMax, bool adjFloat, float fAdjStep, float fAdjMin, float fAdjMax, bool isAnim, std::string strAnim); // gen 2 menu + + void AddWeaponEntry(int weaponID); + void AddAnimEntry(std::string name); + void AddToggleCharEntry(std::string name, char* ptr); + void AddToggleIntEntry(std::string name, int* ptr); + void AddFunctionEntry(std::string name, std::function func); + + // GEN2 + + void AddSliderIntEntry(std::string name, int* ptr, int min, int max, int step = 1); + +}; + + + +std::string GetStatusAsString(int value); +std::string GetAnimationName(int id); +void SavePosition(); +void LoadPosition(); + + +extern eMenu TheMenu; + + +bool KeyHit(unsigned int keyCode); diff --git a/source/code/plugin/modloader/eCustomClumpDict.cpp b/source/code/plugin/modloader/eCustomClumpDict.cpp new file mode 100644 index 0000000..d93ca42 --- /dev/null +++ b/source/code/plugin/modloader/eCustomClumpDict.cpp @@ -0,0 +1,87 @@ +#include "eCustomClumpDict.h" +#include "..\..\manhunt\ClumpDict.h" +#include "..\..\manhunt\core.h" +#include "..\eLog.h" +#include + +std::vector eCustomClumpDictManager::m_vecClumps; + +CClump * eCustomClumpDict::FindClumpDescription(const char * name) +{ + CClump* clump = nullptr; + CClumpDict* dict = (CClumpDict*)this; + + // custom dffs first + for (int i = 0; i < eCustomClumpDictManager::m_vecClumps.size(); i++) + { + clump = eCustomClumpDictManager::m_vecClumps[i]->FindClumpDescription(name); + if (clump) + break; + } + + + + if (!clump) + clump = dict->FindClumpDescription(name); + eLog::Message(__FUNCTION__, "Loading model: %s",name); + + + return clump; +} + +void eCustomClumpDict::Destroy() +{ + CClumpDict* dict = (CClumpDict*)this; + dict->Destroy(); + + for (int i = 0; i < eCustomClumpDictManager::m_vecClumps.size(); i++) + eCustomClumpDictManager::m_vecClumps[i]->Destroy(); + +} + +void eCustomClumpDictManager::InitHooks() +{ + InjectHook(0x433A91, &eCustomClumpDict::FindClumpDescription, PATCH_CALL); + InjectHook(0x433BFF, &eCustomClumpDict::FindClumpDescription, PATCH_CALL); + InjectHook(0x433C10, &eCustomClumpDict::FindClumpDescription, PATCH_CALL); + InjectHook(0x43797B, &eCustomClumpDict::Destroy, PATCH_CALL); +} + +char * eCustomClumpDictManager::TranslateClumpPtr(int ptr) +{ + switch (ptr) + { + case 0x756250: + return "Global"; + break; + case 0x69BC84: + return "Local"; + break; + case 0x69BC90: + return "Character"; + break; + default: + return "Unknown"; + break; + } + return nullptr; +} + +void eCustomClumpDictManager::PushClumpDict(CClumpDict * dict) +{ + m_vecClumps.push_back(dict); +} + +int eCustomClumpDictManager::LoadTextureDict(const char * name) +{ + int txd = CallAndReturn(name); + printf("Loading TXD: %s [%x]\n", name,txd); + return txd; +} + +int eCustomClumpDictManager::LoadDffBank(const char * name, int arg) +{ + int dff = CallAndReturn(name, arg); + printf("Loading DFF: %s [%x]\n", name, dff); + return dff; +} diff --git a/source/code/plugin/modloader/eCustomClumpDict.h b/source/code/plugin/modloader/eCustomClumpDict.h new file mode 100644 index 0000000..922732f --- /dev/null +++ b/source/code/plugin/modloader/eCustomClumpDict.h @@ -0,0 +1,22 @@ +#pragma once +#include "..\..\manhunt\ClumpDict.h" +#include + + +class eCustomClumpDictManager { +public: + static std::vector m_vecClumps; + + static void InitHooks(); + static char* TranslateClumpPtr(int ptr); + static void PushClumpDict(CClumpDict* dict); + static int LoadTextureDict(const char* name); + static int LoadDffBank(const char* name, int arg); + +}; + +class eCustomClumpDict { +public: + CClump* FindClumpDescription(const char* name); + void Destroy(); +}; \ No newline at end of file diff --git a/source/code/plugin/modloader/eModLoader.cpp b/source/code/plugin/modloader/eModLoader.cpp new file mode 100644 index 0000000..8e9f144 --- /dev/null +++ b/source/code/plugin/modloader/eModLoader.cpp @@ -0,0 +1,233 @@ +#include "eModLoader.h" +#include "eCustomClumpDict.h" +#include "..\..\core\FileFunctions.h" +#include "..\..\core\eMain.h" +#include "..\..\manhunt\core.h" +#include +#include +#include "..\eLog.h" +#include "..\..\core\eSettingsManager.h" + +std::vector dffFiles; + +std::vector eModLoader::ignoredFiles; +std::vector eModLoader::files; +std::vector eModLoader::modFolders; +std::vector eModLoader::m_vMods; +void eModLoader::Init() +{ + InjectHook(0x4D4FE8, LoadFile, PATCH_CALL); + InjectHook(0x4D501E, LoadFile, PATCH_CALL); + InjectHook(0x4D507E, LoadFile, PATCH_CALL); + InjectHook(0x4D5326, LoadFile, PATCH_CALL); + InjectHook(0x5F6B2D, LoadFile, PATCH_CALL); + InjectHook(0x5FC88E, LoadFile, PATCH_CALL); + +} + +void eModLoader::InitClumpDicts() +{ + eCustomClumpDictManager::m_vecClumps.clear(); + for (unsigned int i = 0; i < m_vMods.size(); i++) + { + for (unsigned int a = 0; a < m_vMods[i].files.size(); a++) + { + + std::string file = splitString(m_vMods[i].files[a], true); + + if (getExtension(m_vMods[i].files[a]) == "dff") + { + if (!IsFileIgnored(file)) + { + CClumpDict* dict = new CClumpDict; + std::string possibleTXD = m_vMods[i].files[a]; + possibleTXD.replace(m_vMods[i].files[a].length() - 4, m_vMods[i].files[a].length(), ".txd"); + if (!std::filesystem::exists(possibleTXD)) + possibleTXD = "/levels/global/pak/GmodelsPC.txd"; + + dict->Initialise(possibleTXD.c_str(), m_vMods[i].files[a].c_str()); + eLog::Message(__FUNCTION__, "Initialising custom clump [%x] %s [%s]", dict, m_vMods[i].files[a].c_str(), possibleTXD.c_str()); + eCustomClumpDictManager::m_vecClumps.push_back(dict); + } + + } + } + + } +} + +void eModLoader::Refresh() +{ + m_vMods.clear(); + files.clear(); + modFolders.clear(); + dffFiles.clear(); + std::filesystem::current_path(getExecutablePath()); + ScanFolderForFiles("modloader"); +} + +void eModLoader::ScanFolderForFiles(const char* folder) +{ + std::filesystem::current_path(getExecutablePath()); + + + + + if (!std::filesystem::exists(folder)) + { + MessageBoxA(0, "Folder does not exist!", folder, MB_ICONERROR); + return; + } + + for (const auto & file : std::filesystem::directory_iterator(folder)) + { + std::string folder = splitString(file.path().string(), true); + + if (std::filesystem::is_directory(file.path().string())) + { + modFolders.push_back(folder); + eModEntry mod; + mod.name = folder; + m_vMods.push_back(mod); + } + + } + std::vector tmp_files; + std::vector tmp_gfiles; + std::vector tmp_sfiles; + for (int i = 0; i < m_vMods.size(); i++) + { + std::filesystem::current_path(getExecutablePath_str()); + std::filesystem::current_path(folder); + eLog::Message(__FUNCTION__, "Scanning %s for files...", modFolders[i].c_str()); + for (const auto & file : std::filesystem::recursive_directory_iterator(modFolders[i])) + { + if (file.path().has_extension()) + { + std::string tmp = file.path().string(); + tmp = tmp.substr(modFolders[i].length() + 1, file.path().string().length()); + + char buffer[MAX_PATH]; + sprintf(buffer, tmp.c_str()); + + for (int i = 0; i < strlen(buffer); i++) + { + buffer[i] = tolower(buffer[i]); + } + + std::string conv(buffer, strlen(buffer)); + tmp = conv; + + + tmp_gfiles.push_back(tmp); + + std::string str = folder; + str += "\\"; + str += file.path().string(); + + file_entry f; + sprintf(f.path, str.c_str()); + tmp_sfiles.push_back(f); + tmp_files.push_back(str); + } + } + m_vMods[i].files = tmp_files; + m_vMods[i].files_game = tmp_gfiles; + m_vMods[i].files_struct = tmp_sfiles; + tmp_files.clear(); + tmp_gfiles.clear(); + tmp_sfiles.clear(); + } + + // load ignored + + std::filesystem::current_path(getExecutablePath_str()); + std::filesystem::current_path(folder); + + FILE* pIgnoredList = fopen("modloader.ini","rb"); + if (pIgnoredList) + { + char szLine[512]; + + while (fgets(szLine, sizeof(szLine), pIgnoredList)) + { + if (szLine[0] == ';' || szLine[0] == '\n' || szLine[0] == '#') + continue; + + for (int i = 0; i < strlen(szLine); i++) + szLine[i] = tolower(szLine[i]); + + std::string name(szLine, strlen(szLine) - sizeof('\n') - 1); + ignoredFiles.push_back(name); + + } + } + else + eLog::Message(__FUNCTION__, "Ignore list is not present!"); + +} + +char * eModLoader::FindFile(char * input) +{ + char* result = input; + + if (input[0] == '.') + { + char tmpBuff[260] = {}; + strncpy(tmpBuff, input + 2, strlen(input) - 2); + input = tmpBuff; + } + + for (int i = 0; i < strlen(input); i++) + { + if (input[i] == '/') + input[i] = '\\'; + } + + for (int i = 0; i < strlen(input); i++) + input[i] = tolower(input[i]); + + // check file + std::string str(input, strlen(input)); + std::string file = splitString(str, true); + + if (IsFileIgnored(file)) + return result; + + for (int i = 0; i < m_vMods.size(); i++) + { + for (int a = 0; a < m_vMods[i].files.size(); a++) + { + + if (strcmp(m_vMods[i].files_game[a].c_str(), input) == 0) + { + result = (char*)m_vMods[i].files[a].c_str(); + } + } + } + return result; +} + +CFile* eModLoader::LoadFile(char * fileName, int * fileBuffer, int * arg3, CFile ** pFile, int * fileSize) +{ + fileName = FindFile(fileName); + CFile* result = CallAndReturn(fileName, fileBuffer, arg3, pFile, fileSize); + return result; +} + + +bool eModLoader::IsFileIgnored(std::string & name) +{ + bool result = false; + for (int i = 0; i < ignoredFiles.size(); i++) + { + if (strcmp(name.c_str(), ignoredFiles[i].c_str()) == 0) + { + result = true; + break; + } + } + return result; +} + + diff --git a/source/code/plugin/modloader/eModLoader.h b/source/code/plugin/modloader/eModLoader.h new file mode 100644 index 0000000..56cf9e4 --- /dev/null +++ b/source/code/plugin/modloader/eModLoader.h @@ -0,0 +1,32 @@ +#pragma once +#include +#include + +#include "..\..\manhunt\Misc.h" + +struct file_entry { + char path[MAX_PATH]; +}; + +struct eModEntry { + std::string name; + std::vector files; + std::vector files_struct; + std::vector files_game; +}; + +class eModLoader { +public: + static std::vector files; + static std::vector modFolders; + static std::vector m_vMods; + static std::vector ignoredFiles; + static void Init(); + + static void InitClumpDicts(); + static void Refresh(); + static void ScanFolderForFiles(const char* folder); + static char* FindFile(char* input); + static CFile* LoadFile(char* fileName, int* fileBuffer, int* arg3, CFile** pFile, int* fileSize); + static bool IsFileIgnored(std::string& name); +}; \ No newline at end of file diff --git a/source/code/plugin/script/eScriptExtender.cpp b/source/code/plugin/script/eScriptExtender.cpp new file mode 100644 index 0000000..734ae4e --- /dev/null +++ b/source/code/plugin/script/eScriptExtender.cpp @@ -0,0 +1,60 @@ +#include "eScriptExtender.h" +#include "..\..\manhunt\core.h" +#include + +void eScriptExtender::Init() +{ + InitHooks(); +} + +void eScriptExtender::InitHooks() +{ + InjectHook(0x482062, eScriptExtender::HookExtraCommands, PATCH_JUMP); +} + +void __declspec(naked) eScriptExtender::HookExtraCommands() +{ + static int jmpPoint_last = 0x482073; + static int jmpPoint_false = 0x482080; + static int no = TOTAL_NEW_SCRIPT_COMMANDS - 1; + _asm { + cmp edx, 773 + jg next + mov ecx, ebx + mov eax, 0x57AE60 + call eax + jmp jmpPoint_last + + next: + cmp edx, no + jg jump + mov ecx, ebx + call ProcessNewCommands + jmp jmpPoint_last + + jump: + jmp jmpPoint_false + } +} + +void eScriptExtender::ProcessNewCommands(CScriptVM * vm) +{ + printf("executing new\n"); + switch (vm->m_commandID) + { + case PushMessage: + MessageBoxA(0, "command test", 0, 0); + break; + case WriteMemory: + MessageBoxA(0, "command test", 0, 0); + break; + case ReadMemory: + MessageBoxA(0, "command test", 0, 0); + break; + case KeyHit: + MessageBoxA(0, "command test", 0, 0); + break; + default: + return; + } +} diff --git a/source/code/plugin/script/eScriptExtender.h b/source/code/plugin/script/eScriptExtender.h new file mode 100644 index 0000000..6b27f92 --- /dev/null +++ b/source/code/plugin/script/eScriptExtender.h @@ -0,0 +1,22 @@ +#pragma once +#include "..\..\manhunt\Script.h" +#include +#include + +enum eNewCommands { + PushMessage = 1001, + WriteMemory, + ReadMemory, + KeyHit, + TOTAL_NEW_SCRIPT_COMMANDS +}; + +class eScriptExtender { +public: + static void Init(); + static void InitHooks(); + + static void HookExtraCommands(); + + void ProcessNewCommands(CScriptVM* vm); +}; \ No newline at end of file diff --git a/source/dllmain.cpp b/source/dllmain.cpp index 1e37cbb..af6ec28 100644 --- a/source/dllmain.cpp +++ b/source/dllmain.cpp @@ -1,147 +1,96 @@ // dllmain.cpp : Defines the entry point for the DLL application. -#include "stdafx.h" -#include "code\CSettingsManager.h" -#include "code\CDebugMenuLimit.h" -#include "code\CWeaponAdjuster.h" -#include "code\CPlayerModelLoader.h" -#include "code\CStuff.h" -#include "code\CNewMenu.h" -#include "code\ManhuntSDK.h" -#include "code\CAnimLimit.h" -#include "code\CTOC.h" -#include "code\ManhuntRW.h" -#include "code\CHalosFix.h" +#include "pch.h" #include "MemoryMgr.h" -#include -#include -#include +#include "code/core/eMain.h" +#include "code/core/eSettingsManager.h" +#include "code/plugin/eCustomAnimManager.h" +#include "code/plugin/eCustomTableOfContents.h" +#include "code/plugin/eNewFrontend.h" +#include "code/plugin/eStatsManager.h" +#include "code/plugin/eNewFrontend.h" +#include "code/plugin/eCommonHooks.h" +#include "code/plugin/modloader/eCustomClumpDict.h" +#include "code/plugin/modloader/eModLoader.h" +#include "code/plugin/script/eScriptExtender.h" +#include "code/manhunt/Script.h" +#include "code/plugin/console/eConsole.h" +#include "code/manhunt/Filenames.h" +#include "code/manhunt/core.h" +#include "code/plugin/eQoLChanges.h" +#include "code/manhunt/Renderer.h" +#include "code/manhunt/Frontend.h" +#include "code/plugin/eSkinLoader.h" +#include "code/core/FileFunctions.h" +#include "code/plugin/eLog.h" -// TODO: -// big cleanup using namespace Memory::VP; -void printf_hook(int a1, const char* print) { - printf("%s\n", print); -} - - - -void NullFunc(){} - +int GenericTrueReturn() { return 1; } +int GenericFalseReturn() { return 0; } +void GenericDummy() { } void Init() -{ - - SettingsMgr->Init(); - if (SettingsMgr->bEnableConsoleOutput) - { - AllocConsole(); - freopen("CONIN$", "r", stdin); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); - } - - if (SettingsMgr->bDisableTOC) - InjectHook(0x4D5090, eTOC::HookLoadFile, PATCH_JUMP); - - if (SettingsMgr->bEnableCheatsOnBonusLevels) - InjectHook(0x5D4A50, CStuff::EnableCheatsOnBonusLevels, PATCH_JUMP); - - if (SettingsMgr->iRestrictedHeliumCheatWeaponType) - Patch(0x49D6DE + 2, SettingsMgr->iRestrictedHeliumCheatWeaponType); - - InjectHook(0x591E60, CStuff::HookDebugEntires, PATCH_JUMP); +{ + // AllocConsole(); + // freopen("CONIN$", "r", stdin); + // freopen("CONOUT$", "w", stdout); + // freopen("CONOUT$", "w", stderr); - + eSettingsManager::Init(); - if (SettingsMgr->bEnableFirearmsExecutions) - InjectHook(0x46C7F2, CWeaponAdjuster::CheckExecutionWeaponType, PATCH_CALL); + if (eSettingsManager::bEnableLog) + eLog::Initialise(); - if (SettingsMgr->bEnableConfirmationIcon) - InjectHook(0x5F085E, CStuff::HookManTriIcon, PATCH_CALL); + eModLoader::Init(); - if (SettingsMgr->bDisableLegalScreen) - InjectHook(0x5E25D2, CStuff::HookSkipIntroSeq, PATCH_JUMP); + if (eSettingsManager::bSkipIntroSequence) eQoLChanges::SkipIntro(); + if (eSettingsManager::bDisableAutoAim) Nop(0x46A300, 7); + if (eSettingsManager::bEnableCheatsInBonusLevels) InjectHook(0x5D4A50, GenericDummy, PATCH_JUMP); + if (eSettingsManager::bAllowAllWeaponsExplodeCheat) Patch(0x49D6DE + 2, -1); + if (eSettingsManager::bRestoreConfirmationIcon) InjectHook(0x5F085E, CommonHooks::HookManTriIcon, PATCH_CALL); - if (SettingsMgr->bEnableFXMode) Nop(0x5E9180, 10); + eModLoader::ScanFolderForFiles("modloader"); + eSkinLoader::InitHooks(); + InitCommonHooks(); + InitConsoleHooks(); - if (SettingsMgr->bHookPlayerModelLoader) - { - if (CPlayerModelLoader::ReadFile("data\\skinLoader.dat")) - { - InjectHook(0x437FB0, CPlayerModelLoader::Hook, PATCH_JUMP); - InjectHook(0x45FD86, CPlayerModelLoader::HookWeapon, PATCH_JUMP); - } - } + DoCommonPatches(); + eStatsManager::Initialize(); + eNewFrontend::Init(); + eCustomTableOfContents::InitHooks(); + if (eSettingsManager::bHookCustomAnimManager) + CCustomAnimManager::InitHooks(); + if (eSettingsManager::bForceFXMode) + Nop(0x5E9180, 10); - if (SettingsMgr->bHookWeaponAdjuster) + if (eSettingsManager::bEnableFirstPersonMode) { - if (CWeaponAdjuster::ReadFile("data\\weaponConfig.dat")) - { - InjectHook(0x4C67F0, CWeaponAdjuster::GetRecordName, PATCH_JUMP); - InjectHook(0x4C5A90, CWeaponAdjuster::GetWeaponID, PATCH_JUMP); - InjectHook(0x4C5870, CWeaponAdjuster::GetWeaponText, PATCH_JUMP); - InjectHook(0x5DF9A0, CWeaponAdjuster::GetWeaponIcon, PATCH_JUMP); - InjectHook(0x4C93B0, CWeaponAdjuster::Executions, PATCH_JUMP); - InjectHook(0x4C6FC0, CWeaponAdjuster::HookShotgun, PATCH_JUMP); - InjectHook(0x4C6F90, CWeaponAdjuster::HookSniperRifle, PATCH_JUMP); - InjectHook(0x4C7020, CWeaponAdjuster::HookHealthItem, PATCH_JUMP); - //TODO - // replace this - Patch(0x49D78C, 0xE9); - Patch(0x49D78C + 1, (int)CWeaponAdjuster::HookExplodeHeadF - ((int)0x49D78C + 5)); - Patch(0x49D782 + 7, 0); - Patch(0x49D778 + 7, 0); - Patch(0x49D94D, 0xE9); - Patch(0x49D94D + 1, (int)CWeaponAdjuster::HookAutoHeadshot - ((int)0x49D94D + 5)); - } + // disable reset + InjectHook(0x4622DC, GenericDummy, PATCH_CALL); + Patch(0x46053D, 0x00000000); + Patch(0x460545, 0x00000000); + + // lock arms for player only + // filtering only player fixes a bug where peds + // wouldn't move torso while aiming + InjectHook(0x4AB54D, CommonHooks::ArmsPosition_PlayerFPS, PATCH_JUMP); + + // disable resetting camera on x press + Nop(0x4628B2, 5); + } - // TODO: - // split this from main function or hook in-game - while (true) - { - Sleep(1); - - - if (CStuff::KeyHit(SettingsMgr->iDebugMenuKey)) - { - *(int*)0x7CF088 ^= 1; - Sleep(130); - } - - if (SettingsMgr->bEnableFPSMode) - { - Patch(0x4622DC + 1, (int)NullFunc- ((int)0x4622DC + 5)); - Patch(0x46053D, 0x00000000); - Patch(0x460545, 0x00000000); - Patch(0x46033F, 0x00000000); - } - - if (CStuff::KeyHit(SettingsMgr->iQuickHideHUDKey)) - { - *(int*)0x7CF0A0 ^= 1; // hud - Sleep(180); - } + eNewFrontend::InitHooks(); + eStatsManager::InitHooks(); + eCustomClumpDictManager::InitHooks(); - if (SettingsMgr->bEnableScreenshotMode) - { - if (CStuff::KeyHit(SettingsMgr->iQuickScreenshotKeyMain) && CStuff::KeyHit(SettingsMgr->iQuickScreenshotKeySub)) - { - *(int*)0x715BA0 ^= 1; // freeze - *(int*)0x715BB0 ^= 1; // free cam - *(int*)0x7CF0A0 ^= 1; // hud - Sleep(180); - } - } + InjectHook(0x5E279F, MainHooks::HookWndProc, PATCH_CALL); + eLog::Message(__FUNCTION__, "PluginMH initialized!"); - if (SettingsMgr->iForcePlayerSkin) - Patch(0x6A94C0, SettingsMgr->iForcePlayerSkin); - } } -#ifndef _XP_VER + extern "C" { __declspec(dllexport) void InitializeASI() @@ -150,26 +99,6 @@ extern "C" { MessageBoxA(0, "Invalid executable!", "PluginMH", 0); } - else CreateThread(nullptr, 0, reinterpret_cast(Init), nullptr, 0, nullptr); - } -} -#endif - -#ifdef _XP_VER -BOOL APIENTRY DllMain(HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - CreateThread(nullptr, 0, reinterpret_cast(Init), nullptr, 0, nullptr); - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; + else Init(); } - return TRUE; -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/source/framework.h b/source/framework.h new file mode 100644 index 0000000..54b83e9 --- /dev/null +++ b/source/framework.h @@ -0,0 +1,5 @@ +#pragma once + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files +#include diff --git a/source/pch.cpp b/source/pch.cpp new file mode 100644 index 0000000..64b7eef --- /dev/null +++ b/source/pch.cpp @@ -0,0 +1,5 @@ +// pch.cpp: source file corresponding to the pre-compiled header + +#include "pch.h" + +// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/source/pch.h b/source/pch.h new file mode 100644 index 0000000..885d5d6 --- /dev/null +++ b/source/pch.h @@ -0,0 +1,13 @@ +// pch.h: This is a precompiled header file. +// Files listed below are compiled only once, improving build performance for future builds. +// This also affects IntelliSense performance, including code completion and many code browsing features. +// However, files listed here are ALL re-compiled if any one of them is updated between builds. +// Do not add files here that you will be updating frequently as this negates the performance advantage. + +#ifndef PCH_H +#define PCH_H + +// add headers that you want to pre-compile here +#include "framework.h" + +#endif //PCH_H diff --git a/source/resource.h b/source/resource.h new file mode 100644 index 0000000..88a6f77 --- /dev/null +++ b/source/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by PluginMH.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/source/stdafx.cpp b/source/stdafx.cpp deleted file mode 100644 index 5a715b6..0000000 --- a/source/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// PluginMH.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/source/stdafx.h b/source/stdafx.h deleted file mode 100644 index 677e68a..0000000 --- a/source/stdafx.h +++ /dev/null @@ -1,16 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - - - -// TODO: reference additional headers your program requires here diff --git a/source/targetver.h b/source/targetver.h deleted file mode 100644 index 90e767b..0000000 --- a/source/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include