diff --git a/hook_lib/Main.cpp b/hook_lib/Main.cpp index e692cf8..b7bfd87 100644 --- a/hook_lib/Main.cpp +++ b/hook_lib/Main.cpp @@ -41,6 +41,7 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD Reason, LPVOID lpVoid) FILE* Dummy; freopen_s(&Dummy, "CONOUT$", "w", stdout); freopen_s(&Dummy, "CONIN$", "r", stdin); + SetConsoleTitleA("Donetsk Client Console"); utils::nt::library game{}; utils::nt::library user32("user32.dll"); diff --git a/hook_lib/Main.hpp b/hook_lib/Main.hpp index 57a33c8..2277c7d 100644 --- a/hook_lib/Main.hpp +++ b/hook_lib/Main.hpp @@ -21,7 +21,6 @@ #include "ini.h" #include "json.hpp" -#include "splashscreen.hpp" #define base g_Addrs.ModuleBase diff --git a/hook_lib/assets.h b/hook_lib/assets.h index 1aee26e..7fbcaaf 100644 --- a/hook_lib/assets.h +++ b/hook_lib/assets.h @@ -4077,7 +4077,7 @@ struct __declspec(align(8)) WeaponDef struct WeaponCompleteDef { const char* szInternalName; - WeaponDef weapDef; + WeaponDef* weapDef; const char* szDisplayName; const char* szLootTable; scr_string_t* hideTags; diff --git a/hook_lib/functions.cpp b/hook_lib/functions.cpp index 06163fa..560d59b 100644 --- a/hook_lib/functions.cpp +++ b/hook_lib/functions.cpp @@ -538,6 +538,8 @@ cmd_function_s MapRestart_f_VAR; cmd_function_s omnvar_set_f_VAR; cmd_function_s omnvar_dump_f_VAR; cmd_function_s unlockall_f_VAR; +cmd_function_s dump_weapdefs_f_VAR; +cmd_function_s load_weapdef_f_VAR; CmdArgs* cmd_args; diff --git a/hook_lib/functions.hpp b/hook_lib/functions.hpp index f31ffc0..23c9242 100644 --- a/hook_lib/functions.hpp +++ b/hook_lib/functions.hpp @@ -132,6 +132,8 @@ extern cmd_function_s MapRestart_f_VAR; extern cmd_function_s omnvar_set_f_VAR; extern cmd_function_s omnvar_dump_f_VAR; extern cmd_function_s unlockall_f_VAR; +extern cmd_function_s dump_weapdefs_f_VAR; +extern cmd_function_s load_weapdef_f_VAR; extern CmdArgs* cmd_args; void* RtlAddVectoredExceptionHandler(LONG First, PVECTORED_EXCEPTION_HANDLER Handler); diff --git a/hook_lib/g_cmds.cpp b/hook_lib/g_cmds.cpp index acfa030..1e760c3 100644 --- a/hook_lib/g_cmds.cpp +++ b/hook_lib/g_cmds.cpp @@ -13,7 +13,7 @@ void addCustomCmds() Cmd_AddCommandInternal("addbot", Cmd_AddBot_f, &addbot_f_VAR); Cmd_AddCommandInternal("addtestclient", Cmd_AddTestClient_f, &addTestClient_f_VAR); Cmd_AddCommandInternal("ddldump", Cmd_DDLDump_f, &ddldump_f_VAR); - Cmd_AddCommandInternal("weapondefdump", Cmd_WeaponDefDump_f, &weapondefdump_f_VAR); + // Cmd_AddCommandInternal("weapondefdump", Cmd_WeaponDefDump_f, &weapondefdump_f_VAR); //Cmd_AddCommandInternal("view_vehicle_ents", Cmd_ViewVehicleEnts_f, &view_vehicle_ents_f_VAR); // Cmd_AddCommandInternal("save_inventory", Cmd_LoadoutSave_f, &loadout_save_f_VAR); Cmd_AddCommandInternal("map_restart", SV_CmdsMP_MapRestart_f, &MapRestart_f_VAR); @@ -21,6 +21,8 @@ void addCustomCmds() Cmd_AddCommandInternal("setOmnvar", Cmd_Omnvar_Set_f, &omnvar_set_f_VAR); // Cmd_AddCommandInternal("dumpomnvars", Cmd_Omnvars_Dump_f, &omnvar_dump_f_VAR); Cmd_AddCommandInternal("unlockAll", Cmd_UnlockAll_f, &unlockall_f_VAR); + Cmd_AddCommandInternal("dumpweapondef", Cmd_WeaponDefDump_f, &dump_weapdefs_f_VAR); + Cmd_AddCommandInternal("loadweapondef", Cmd_WeaponDef_Load_f, &load_weapdef_f_VAR); } void G_CmdsMP_ClientCommand_Detour(int clientNum) @@ -429,20 +431,10 @@ void Cmd_DDLDump_f() void Cmd_WeaponDefDump_f() { - //Globals - uintptr_t* bg_weaponCompleteDefs = reinterpret_cast(0x14C6EC870_g); - - printf("DUMPING WEAPON DEFINITIONS!!! --- \n"); - - for (int i = 0; i < 550; i++) { - WeaponCompleteDef* weap = reinterpret_cast(bg_weaponCompleteDefs[i]); - - if (!weap) continue; - printf("szInternalName: %s\n", weap->szInternalName); - printf("szDisplayName: %s\n", weap->szDisplayName); + if (CheatsOk(0)) + { + Dump_WeaponDef(); } - - printf("FINISHED WEAPON DEFINITION DUMP YAY!!! --- \n"); } void Cmd_ViewVehicleEnts_f() @@ -467,4 +459,12 @@ void Cmd_LoadoutSave_f() void Cmd_UnlockAll_f() { Cbuf_AddText("seta unlockAllItems 1"); +} + +void Cmd_WeaponDef_Load_f() +{ + if (CheatsOk(0)) + { + Load_WeaponDef(); + } } \ No newline at end of file diff --git a/hook_lib/g_cmds.h b/hook_lib/g_cmds.h index 44a5e99..e064c6c 100644 --- a/hook_lib/g_cmds.h +++ b/hook_lib/g_cmds.h @@ -36,4 +36,6 @@ void Cmd_ViewVehicleEnts_f(); void Cmd_LoadoutSave_f(); -void Cmd_UnlockAll_f(); \ No newline at end of file +void Cmd_UnlockAll_f(); + +void Cmd_WeaponDef_Load_f(); \ No newline at end of file diff --git a/hook_lib/game_inc.h b/hook_lib/game_inc.h index 3b87b85..ff3566d 100644 --- a/hook_lib/game_inc.h +++ b/hook_lib/game_inc.h @@ -13,6 +13,7 @@ #include "stringed.h" #include "fastfile.h" #include "mp_init.h" +#include "party.h" #include "ddl.h" #include "gamemode.h" #include "sv_main.h" diff --git a/hook_lib/gamemode.cpp b/hook_lib/gamemode.cpp index 26dca01..ced4e87 100644 --- a/hook_lib/gamemode.cpp +++ b/hook_lib/gamemode.cpp @@ -2,7 +2,17 @@ bool Com_GameMode_SupportsFeature_Detour(unsigned int featureID) { - if (featureID == 70) // TIMESCALE_TWEAKING + static dvar_t* com_timescale; + static dvar_t* timescale; + + if (com_timescale == nullptr && featureID == 70) + { + com_timescale = (dvar_t*)Dvar_FindVarByName("LNOTRKNRPS"); + timescale = (dvar_t*)Dvar_FindVarByName("MSNTNLNQNM"); + // fixes slowmotion final killcam, but not in an ideal way + } + + if (featureID == 70 && timescale->current.value != 1.0) // TIMESCALE_TWEAKING { return true; } diff --git a/hook_lib/hook_lib.vcxproj b/hook_lib/hook_lib.vcxproj index 893fe31..d528ef9 100644 --- a/hook_lib/hook_lib.vcxproj +++ b/hook_lib/hook_lib.vcxproj @@ -177,10 +177,10 @@ + - @@ -223,6 +223,7 @@ + diff --git a/hook_lib/hook_lib.vcxproj.filters b/hook_lib/hook_lib.vcxproj.filters index c6f5994..30aaeb0 100644 --- a/hook_lib/hook_lib.vcxproj.filters +++ b/hook_lib/hook_lib.vcxproj.filters @@ -70,9 +70,6 @@ hook_lib\game - - hook_lib\game - hook_lib\game @@ -136,6 +133,9 @@ hook_lib\game + + hook_lib\game + @@ -267,5 +267,8 @@ hook_lib\game + + hook_lib\game + \ No newline at end of file diff --git a/hook_lib/mp_init.cpp b/hook_lib/mp_init.cpp index d2f7b48..17ec249 100644 --- a/hook_lib/mp_init.cpp +++ b/hook_lib/mp_init.cpp @@ -5,9 +5,5 @@ void CG_MainMP_Init_Detour(int localClientNum, int serverMessageNum, int serverC { cg_mainmp_init.stub(localClientNum, serverMessageNum, serverCommandSequence, clientNum, hunkUser); - Cbuf_AddText("exec autoexec.cfg"); - - LoadInventory(); - Cbuf_AddText("set cl_textChatEnabled 1"); } \ No newline at end of file diff --git a/hook_lib/party.cpp b/hook_lib/party.cpp new file mode 100644 index 0000000..090911d --- /dev/null +++ b/hook_lib/party.cpp @@ -0,0 +1,14 @@ +#include "party.h" +#include "game_inc.h" + +void PartyHost_StartPrivateParty_Detour(int localClientNum, int localControllerIndex, bool currentlyActive, int hostType) +{ + partyhost_startprivateparty.stub(localClientNum, localControllerIndex, currentlyActive, hostType); + + static bool autoexec = false; + if (!autoexec) + { + Cbuf_AddText("exec autoexec.cfg"); + LoadInventory(); + } +} \ No newline at end of file diff --git a/hook_lib/party.h b/hook_lib/party.h new file mode 100644 index 0000000..49e4c9c --- /dev/null +++ b/hook_lib/party.h @@ -0,0 +1,5 @@ +#pragma once +#include "Main.hpp" + +inline utils::hook::detour partyhost_startprivateparty; +void PartyHost_StartPrivateParty_Detour(int localClientNum, int localControllerIndex, bool currentlyActive, int hostType); \ No newline at end of file diff --git a/hook_lib/patch.cpp b/hook_lib/patch.cpp index 3201d06..ea6cc96 100644 --- a/hook_lib/patch.cpp +++ b/hook_lib/patch.cpp @@ -6,7 +6,6 @@ bool bFinished; bool btoggle; dvar_t* cl_textChatEnabled = reinterpret_cast(0x14EEB0738_g); -dvar_t* com_timescale = reinterpret_cast(0x14D3865E8_g); uintptr_t xuid_generated; int collision_ticker; @@ -143,6 +142,7 @@ void hooks() cl_createdevgui.create(0x1415B2080_g, CL_CreateDevGui_Detour); cg_mainmp_init.create(0x141792E60_g, CG_MainMP_Init_Detour); + partyhost_startprivateparty.create(0x14119F0D0_g, PartyHost_StartPrivateParty_Detour); PM_WeaponUseAmmo.create(0x141155AF0_g, PM_WeaponUseAmmo_Detour); @@ -196,9 +196,6 @@ void patchGame() utils::hook::nop(0x141665289_g, 5); utils::hook::nop(0x14166567D_g, 5); - // set com_timescale dvar to read only - utils::hook::set(0x1412B26CF_g, 8192); - // remove FF Header version check // utils::hook::set(0x1411A776B_g, 0xEB); } \ No newline at end of file diff --git a/hook_lib/splashscreen.cpp b/hook_lib/splashscreen.cpp deleted file mode 100644 index a14dbb8..0000000 --- a/hook_lib/splashscreen.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "splashscreen.hpp" - -byte data_buf[1] = { 0x0 }; - -void set_splashscreen() { - // memcpy((void*)(0x1530AD525_g), (const void*)(data_buf), 0x128BB8); -} diff --git a/hook_lib/splashscreen.hpp b/hook_lib/splashscreen.hpp deleted file mode 100644 index 3601e15..0000000 --- a/hook_lib/splashscreen.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "Main.hpp" -typedef unsigned char byte; - -size_t operator"" _b(size_t val); -size_t reverse_b(size_t val); -size_t reverse_b(const void* val); - -size_t operator"" _g(size_t val); -size_t reverse_g(size_t val); -size_t reverse_g(const void* val); - -extern byte data_buf[1]; - -void set_splashscreen(); diff --git a/hook_lib/stringed.cpp b/hook_lib/stringed.cpp index a1c89a7..a7f90c7 100644 --- a/hook_lib/stringed.cpp +++ b/hook_lib/stringed.cpp @@ -16,9 +16,12 @@ const char* SEH_StringEd_GetString_Detour(const char* pszReference) GamerProfile_SetDataByName(0, "hasEverPlayed_MainMenu", 1); // LUA_MENU/MAPNAME_ANIYAH // Aniyah Palace - if (std::string(pszReference) == "LUA_MENU/MAPNAME_ANIYAH") + if (strstr(pszReference, "LUA_MENU/MAPNAME_ANIYAH")) { - return "^1no work"; + if (pszReference[23] == '\0') + { + return "^1no work"; + } } if (strstr(pszReference, "LUA_MENU/MAPNAME_DEADZONE") || diff --git a/hook_lib/weapons.cpp b/hook_lib/weapons.cpp index 3014945..eaec60b 100644 --- a/hook_lib/weapons.cpp +++ b/hook_lib/weapons.cpp @@ -17,3 +17,81 @@ void CG_OverrideImpactEffectType(uintptr_t localClientNum, unsigned int sourceEn fxImpactType[2] = 34; cg_overrideimpacteffecttype.stub<__int64>(localClientNum, sourceEntityNum, fxImpactType); } + +TracerDef* GetTracerDef(const char* asset) { + TracerDef* tracerDef = DB_FindXAssetHeader(ASSET_TYPE_TRACER, asset, 0).tracerDef; + if (tracerDef) return tracerDef; + return 0; +} + +void Dump_WeaponDef() { + char path[MAX_PATH + 1]; + strcpy(path, Dvar_GetStringSafe("LOOQOTRNTN")); + strcat(path, "\\players\\weapondef.json"); + bool inFrontend = *(bool*)(0x1459D1750_g); + if (!inFrontend) { + nlohmann::json weaponDefJson; + WeaponCompleteDef** bg_weaponCompleteDefs = (WeaponCompleteDef**)(0x14C6EC870_g); + for (int i = 0; i < 550; i++) { + WeaponCompleteDef* weap = bg_weaponCompleteDefs[i]; + if (!weap) continue; + if (strstr(weap->szInternalName, "iw8") && !strstr(weap->szInternalName, "watch") && !strstr(weap->szInternalName, "execution") && !strstr(weap->szInternalName, "plyr")) { + weaponDefJson[weap->szInternalName]["vfxImpactType"] = weap->vfxImpactType; + weaponDefJson[weap->szInternalName]["ladderWeapon"] = weap->weapDef->ladderWeapon; + weaponDefJson[weap->szInternalName]["canHoldBreath"] = weap->weapDef->canHoldBreath; + weaponDefJson[weap->szInternalName]["iFireTime"] = weap->weapDef->iFireTime; + weaponDefJson[weap->szInternalName]["bBoltAction"] = weap->weapDef->bBoltAction; + weaponDefJson[weap->szInternalName]["fireType"] = weap->weapDef->fireType; + weaponDefJson[weap->szInternalName]["iStartAmmo"] = weap->weapDef->iStartAmmo; + weaponDefJson[weap->szInternalName]["iMaxAmmo"] = weap->weapDef->iMaxAmmo; + if (weap->weapDef->tracerType) + weaponDefJson[weap->szInternalName]["tracerType"] = weap->weapDef->tracerType->name; + } + } + std::ofstream JsonOut(path); + JsonOut << weaponDefJson; + } + else { + Com_SetErrorMessage("[DLL ERROR] Must be in-game to dump WeaponDef."); + } + + +} + +void Load_WeaponDef() { + char path[MAX_PATH + 1]; + strcpy(path, Dvar_GetStringSafe("LOOQOTRNTN")); + strcat(path, "\\players\\weapondef.json"); + bool inFrontend = *(bool*)(0x1459D1750_g); + if (!inFrontend) { + if (file_exists(path)) { + std::ifstream jsonPath(path); + nlohmann::json weaponDefJson = nlohmann::json::parse(jsonPath); + WeaponCompleteDef** bg_weaponCompleteDefs = (WeaponCompleteDef**)(0x14C6EC870_g); + for (int i = 0; i < 550; i++) { + WeaponCompleteDef* weap = bg_weaponCompleteDefs[i]; + if (!weap) continue; + if (weaponDefJson.contains(weap->szInternalName)) { + weap->vfxImpactType = weaponDefJson[weap->szInternalName]["vfxImpactType"]; + weap->weapDef->ladderWeapon = weaponDefJson[weap->szInternalName]["ladderWeapon"]; + weap->weapDef->canHoldBreath = weaponDefJson[weap->szInternalName]["canHoldBreath"]; + weap->weapDef->iFireTime = weaponDefJson[weap->szInternalName]["iFireTime"]; + weap->weapDef->bBoltAction = weaponDefJson[weap->szInternalName]["bBoltAction"]; + weap->weapDef->fireType = weaponDefJson[weap->szInternalName]["fireType"]; + weap->weapDef->iStartAmmo = weaponDefJson[weap->szInternalName]["iStartAmmo"]; + weap->weapDef->iMaxAmmo = weaponDefJson[weap->szInternalName]["iMaxAmmo"]; + + if (weaponDefJson[weap->szInternalName].contains("tracerType")) { + weap->weapDef->tracerType = GetTracerDef(weaponDefJson[weap->szInternalName]["tracerType"].get().c_str()); + } + } + } + } + else { + Com_SetErrorMessage("[DLL ERROR] weapondef JSON is not present in players directory."); + } + } + else { + Com_SetErrorMessage("[DLL ERROR] Must be in-game to load custom WeaponDef."); + } +} \ No newline at end of file diff --git a/hook_lib/weapons.h b/hook_lib/weapons.h index 00cf525..86134b3 100644 --- a/hook_lib/weapons.h +++ b/hook_lib/weapons.h @@ -5,4 +5,10 @@ inline utils::hook::detour PM_WeaponUseAmmo; void PM_WeaponUseAmmo_Detour(__int64 playerstate, Weapon* weapon, char a3, int a4, int hand); inline utils::hook::detour cg_overrideimpacteffecttype; -void CG_OverrideImpactEffectType(uintptr_t localClientNum, unsigned int sourceEntityNum, int* fxImpactType); \ No newline at end of file +void CG_OverrideImpactEffectType(uintptr_t localClientNum, unsigned int sourceEntityNum, int* fxImpactType); + +TracerDef* GetTracerDef(const char* asset); + +void Dump_WeaponDef(); + +void Load_WeaponDef(); \ No newline at end of file