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/hook_lib.vcxproj b/hook_lib/hook_lib.vcxproj index dcacf2e..d528ef9 100644 --- a/hook_lib/hook_lib.vcxproj +++ b/hook_lib/hook_lib.vcxproj @@ -177,6 +177,7 @@ + @@ -222,6 +223,7 @@ + diff --git a/hook_lib/hook_lib.vcxproj.filters b/hook_lib/hook_lib.vcxproj.filters index 487e418..30aaeb0 100644 --- a/hook_lib/hook_lib.vcxproj.filters +++ b/hook_lib/hook_lib.vcxproj.filters @@ -133,6 +133,9 @@ hook_lib\game + + hook_lib\game + @@ -264,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 fbb02e2..ea6cc96 100644 --- a/hook_lib/patch.cpp +++ b/hook_lib/patch.cpp @@ -142,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); 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