added custom weapdef loading
added custom weapdef loading/dumping moved LoadInventory & autoexec back to PartyHost_StartPrivateParty_Detour
This commit is contained in:
parent
24f04a940a
commit
1f9319f845
@ -4077,7 +4077,7 @@ struct __declspec(align(8)) WeaponDef
|
|||||||
struct WeaponCompleteDef
|
struct WeaponCompleteDef
|
||||||
{
|
{
|
||||||
const char* szInternalName;
|
const char* szInternalName;
|
||||||
WeaponDef weapDef;
|
WeaponDef* weapDef;
|
||||||
const char* szDisplayName;
|
const char* szDisplayName;
|
||||||
const char* szLootTable;
|
const char* szLootTable;
|
||||||
scr_string_t* hideTags;
|
scr_string_t* hideTags;
|
||||||
|
@ -538,6 +538,8 @@ cmd_function_s MapRestart_f_VAR;
|
|||||||
cmd_function_s omnvar_set_f_VAR;
|
cmd_function_s omnvar_set_f_VAR;
|
||||||
cmd_function_s omnvar_dump_f_VAR;
|
cmd_function_s omnvar_dump_f_VAR;
|
||||||
cmd_function_s unlockall_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;
|
CmdArgs* cmd_args;
|
||||||
|
|
||||||
|
@ -132,6 +132,8 @@ extern cmd_function_s MapRestart_f_VAR;
|
|||||||
extern cmd_function_s omnvar_set_f_VAR;
|
extern cmd_function_s omnvar_set_f_VAR;
|
||||||
extern cmd_function_s omnvar_dump_f_VAR;
|
extern cmd_function_s omnvar_dump_f_VAR;
|
||||||
extern cmd_function_s unlockall_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;
|
extern CmdArgs* cmd_args;
|
||||||
|
|
||||||
void* RtlAddVectoredExceptionHandler(LONG First, PVECTORED_EXCEPTION_HANDLER Handler);
|
void* RtlAddVectoredExceptionHandler(LONG First, PVECTORED_EXCEPTION_HANDLER Handler);
|
||||||
|
@ -13,7 +13,7 @@ void addCustomCmds()
|
|||||||
Cmd_AddCommandInternal("addbot", Cmd_AddBot_f, &addbot_f_VAR);
|
Cmd_AddCommandInternal("addbot", Cmd_AddBot_f, &addbot_f_VAR);
|
||||||
Cmd_AddCommandInternal("addtestclient", Cmd_AddTestClient_f, &addTestClient_f_VAR);
|
Cmd_AddCommandInternal("addtestclient", Cmd_AddTestClient_f, &addTestClient_f_VAR);
|
||||||
Cmd_AddCommandInternal("ddldump", Cmd_DDLDump_f, &ddldump_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("view_vehicle_ents", Cmd_ViewVehicleEnts_f, &view_vehicle_ents_f_VAR);
|
||||||
// Cmd_AddCommandInternal("save_inventory", Cmd_LoadoutSave_f, &loadout_save_f_VAR);
|
// Cmd_AddCommandInternal("save_inventory", Cmd_LoadoutSave_f, &loadout_save_f_VAR);
|
||||||
Cmd_AddCommandInternal("map_restart", SV_CmdsMP_MapRestart_f, &MapRestart_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("setOmnvar", Cmd_Omnvar_Set_f, &omnvar_set_f_VAR);
|
||||||
// Cmd_AddCommandInternal("dumpomnvars", Cmd_Omnvars_Dump_f, &omnvar_dump_f_VAR);
|
// Cmd_AddCommandInternal("dumpomnvars", Cmd_Omnvars_Dump_f, &omnvar_dump_f_VAR);
|
||||||
Cmd_AddCommandInternal("unlockAll", Cmd_UnlockAll_f, &unlockall_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)
|
void G_CmdsMP_ClientCommand_Detour(int clientNum)
|
||||||
@ -429,20 +431,10 @@ void Cmd_DDLDump_f()
|
|||||||
|
|
||||||
void Cmd_WeaponDefDump_f()
|
void Cmd_WeaponDefDump_f()
|
||||||
{
|
{
|
||||||
//Globals
|
if (CheatsOk(0))
|
||||||
uintptr_t* bg_weaponCompleteDefs = reinterpret_cast<uintptr_t*>(0x14C6EC870_g);
|
{
|
||||||
|
Dump_WeaponDef();
|
||||||
printf("DUMPING WEAPON DEFINITIONS!!! --- \n");
|
|
||||||
|
|
||||||
for (int i = 0; i < 550; i++) {
|
|
||||||
WeaponCompleteDef* weap = reinterpret_cast<WeaponCompleteDef*>(bg_weaponCompleteDefs[i]);
|
|
||||||
|
|
||||||
if (!weap) continue;
|
|
||||||
printf("szInternalName: %s\n", weap->szInternalName);
|
|
||||||
printf("szDisplayName: %s\n", weap->szDisplayName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("FINISHED WEAPON DEFINITION DUMP YAY!!! --- \n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cmd_ViewVehicleEnts_f()
|
void Cmd_ViewVehicleEnts_f()
|
||||||
@ -468,3 +460,11 @@ void Cmd_UnlockAll_f()
|
|||||||
{
|
{
|
||||||
Cbuf_AddText("seta unlockAllItems 1");
|
Cbuf_AddText("seta unlockAllItems 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cmd_WeaponDef_Load_f()
|
||||||
|
{
|
||||||
|
if (CheatsOk(0))
|
||||||
|
{
|
||||||
|
Load_WeaponDef();
|
||||||
|
}
|
||||||
|
}
|
@ -37,3 +37,5 @@ void Cmd_ViewVehicleEnts_f();
|
|||||||
void Cmd_LoadoutSave_f();
|
void Cmd_LoadoutSave_f();
|
||||||
|
|
||||||
void Cmd_UnlockAll_f();
|
void Cmd_UnlockAll_f();
|
||||||
|
|
||||||
|
void Cmd_WeaponDef_Load_f();
|
@ -13,6 +13,7 @@
|
|||||||
#include "stringed.h"
|
#include "stringed.h"
|
||||||
#include "fastfile.h"
|
#include "fastfile.h"
|
||||||
#include "mp_init.h"
|
#include "mp_init.h"
|
||||||
|
#include "party.h"
|
||||||
#include "ddl.h"
|
#include "ddl.h"
|
||||||
#include "gamemode.h"
|
#include "gamemode.h"
|
||||||
#include "sv_main.h"
|
#include "sv_main.h"
|
||||||
|
@ -177,6 +177,7 @@
|
|||||||
<ClCompile Include="net_chan.cpp" />
|
<ClCompile Include="net_chan.cpp" />
|
||||||
<ClCompile Include="omnvars.cpp" />
|
<ClCompile Include="omnvars.cpp" />
|
||||||
<ClCompile Include="mp_init.cpp" />
|
<ClCompile Include="mp_init.cpp" />
|
||||||
|
<ClCompile Include="party.cpp" />
|
||||||
<ClCompile Include="patch.cpp" />
|
<ClCompile Include="patch.cpp" />
|
||||||
<ClCompile Include="screen.cpp" />
|
<ClCompile Include="screen.cpp" />
|
||||||
<ClCompile Include="script.cpp" />
|
<ClCompile Include="script.cpp" />
|
||||||
@ -222,6 +223,7 @@
|
|||||||
<ClInclude Include="net_chan.h" />
|
<ClInclude Include="net_chan.h" />
|
||||||
<ClInclude Include="omnvars.h" />
|
<ClInclude Include="omnvars.h" />
|
||||||
<ClInclude Include="mp_init.h" />
|
<ClInclude Include="mp_init.h" />
|
||||||
|
<ClInclude Include="party.h" />
|
||||||
<ClInclude Include="patch.h" />
|
<ClInclude Include="patch.h" />
|
||||||
<ClInclude Include="screen.h" />
|
<ClInclude Include="screen.h" />
|
||||||
<ClInclude Include="script.h" />
|
<ClInclude Include="script.h" />
|
||||||
|
@ -133,6 +133,9 @@
|
|||||||
<ClCompile Include="zones.cpp">
|
<ClCompile Include="zones.cpp">
|
||||||
<Filter>hook_lib\game</Filter>
|
<Filter>hook_lib\game</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="party.cpp">
|
||||||
|
<Filter>hook_lib\game</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="common\utils\binary_resource.hpp">
|
<ClInclude Include="common\utils\binary_resource.hpp">
|
||||||
@ -264,5 +267,8 @@
|
|||||||
<ClInclude Include="zones.h">
|
<ClInclude Include="zones.h">
|
||||||
<Filter>hook_lib\game</Filter>
|
<Filter>hook_lib\game</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="party.h">
|
||||||
|
<Filter>hook_lib\game</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -5,9 +5,5 @@ void CG_MainMP_Init_Detour(int localClientNum, int serverMessageNum, int serverC
|
|||||||
{
|
{
|
||||||
cg_mainmp_init.stub<void>(localClientNum, serverMessageNum, serverCommandSequence, clientNum, hunkUser);
|
cg_mainmp_init.stub<void>(localClientNum, serverMessageNum, serverCommandSequence, clientNum, hunkUser);
|
||||||
|
|
||||||
Cbuf_AddText("exec autoexec.cfg");
|
|
||||||
|
|
||||||
LoadInventory();
|
|
||||||
|
|
||||||
Cbuf_AddText("set cl_textChatEnabled 1");
|
Cbuf_AddText("set cl_textChatEnabled 1");
|
||||||
}
|
}
|
14
hook_lib/party.cpp
Normal file
14
hook_lib/party.cpp
Normal file
@ -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<void>(localClientNum, localControllerIndex, currentlyActive, hostType);
|
||||||
|
|
||||||
|
static bool autoexec = false;
|
||||||
|
if (!autoexec)
|
||||||
|
{
|
||||||
|
Cbuf_AddText("exec autoexec.cfg");
|
||||||
|
LoadInventory();
|
||||||
|
}
|
||||||
|
}
|
5
hook_lib/party.h
Normal file
5
hook_lib/party.h
Normal file
@ -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);
|
@ -142,6 +142,7 @@ void hooks()
|
|||||||
|
|
||||||
cl_createdevgui.create(0x1415B2080_g, CL_CreateDevGui_Detour);
|
cl_createdevgui.create(0x1415B2080_g, CL_CreateDevGui_Detour);
|
||||||
cg_mainmp_init.create(0x141792E60_g, CG_MainMP_Init_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);
|
PM_WeaponUseAmmo.create(0x141155AF0_g, PM_WeaponUseAmmo_Detour);
|
||||||
|
|
||||||
|
@ -17,3 +17,81 @@ void CG_OverrideImpactEffectType(uintptr_t localClientNum, unsigned int sourceEn
|
|||||||
fxImpactType[2] = 34;
|
fxImpactType[2] = 34;
|
||||||
cg_overrideimpacteffecttype.stub<__int64>(localClientNum, sourceEntityNum, fxImpactType);
|
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<std::string>().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.");
|
||||||
|
}
|
||||||
|
}
|
@ -6,3 +6,9 @@ void PM_WeaponUseAmmo_Detour(__int64 playerstate, Weapon* weapon, char a3, int a
|
|||||||
|
|
||||||
inline utils::hook::detour cg_overrideimpacteffecttype;
|
inline utils::hook::detour cg_overrideimpacteffecttype;
|
||||||
void CG_OverrideImpactEffectType(uintptr_t localClientNum, unsigned int sourceEntityNum, int* fxImpactType);
|
void CG_OverrideImpactEffectType(uintptr_t localClientNum, unsigned int sourceEntityNum, int* fxImpactType);
|
||||||
|
|
||||||
|
TracerDef* GetTracerDef(const char* asset);
|
||||||
|
|
||||||
|
void Dump_WeaponDef();
|
||||||
|
|
||||||
|
void Load_WeaponDef();
|
Loading…
Reference in New Issue
Block a user