Merge pull request #329 from diamante0018/feature/weapon-pickup
DisableWeaponPickup & EnableWeaponPickup
This commit is contained in:
commit
5aff32e328
@ -1,4 +1,4 @@
|
|||||||
#include <StdInclude.hpp>
|
#include <STDInclude.hpp>
|
||||||
|
|
||||||
#include "AssetInterfaces/IFont_s.hpp"
|
#include "AssetInterfaces/IFont_s.hpp"
|
||||||
#include "AssetInterfaces/IWeapon.hpp"
|
#include "AssetInterfaces/IWeapon.hpp"
|
||||||
@ -518,10 +518,10 @@ namespace Components
|
|||||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BAEA2, entryPool + 1);
|
Utils::Hook::Set<Game::XAssetEntry*>(0x5BAEA2, entryPool + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetHandler::ExposeTemporaryAssets(bool expose)
|
void AssetHandler::ExposeTemporaryAssets(bool expose)
|
||||||
{
|
{
|
||||||
AssetHandler::ShouldSearchTempAssets = expose;
|
AssetHandler::ShouldSearchTempAssets = expose;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetHandler::AssetHandler()
|
AssetHandler::AssetHandler()
|
||||||
{
|
{
|
||||||
|
@ -226,11 +226,11 @@ namespace Components
|
|||||||
// Ook, ook, eek
|
// Ook, ook, eek
|
||||||
Logger::Warning(Game::CON_CHANNEL_SERVER, "You are using deprecated {}", (*SVMapRotationCurrent)->name);
|
Logger::Warning(Game::CON_CHANNEL_SERVER, "You are using deprecated {}", (*SVMapRotationCurrent)->name);
|
||||||
|
|
||||||
RotationData currentRotation;
|
RotationData rotationCurrent;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logger::Debug("Parsing {}", (*SVMapRotationCurrent)->name);
|
Logger::Debug("Parsing {}", (*SVMapRotationCurrent)->name);
|
||||||
currentRotation.parse(data);
|
rotationCurrent.parse(data);
|
||||||
}
|
}
|
||||||
catch (const std::exception& ex)
|
catch (const std::exception& ex)
|
||||||
{
|
{
|
||||||
@ -239,14 +239,14 @@ namespace Components
|
|||||||
|
|
||||||
Game::Dvar_SetString(*SVMapRotationCurrent, "");
|
Game::Dvar_SetString(*SVMapRotationCurrent, "");
|
||||||
|
|
||||||
if (currentRotation.getEntriesSize() == 0)
|
if (rotationCurrent.getEntriesSize() == 0)
|
||||||
{
|
{
|
||||||
Logger::Print(Game::CON_CHANNEL_SERVER, "{} is empty or contains invalid data. Restarting map\n", (*SVMapRotationCurrent)->name);
|
Logger::Print(Game::CON_CHANNEL_SERVER, "{} is empty or contains invalid data. Restarting map\n", (*SVMapRotationCurrent)->name);
|
||||||
RestartCurrentMap();
|
RestartCurrentMap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyRotation(currentRotation);
|
ApplyRotation(rotationCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapRotation::RandomizeMapRotation()
|
void MapRotation::RandomizeMapRotation()
|
||||||
|
@ -448,10 +448,57 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) Weapon::WeaponEntCanBeGrabbed_Stub()
|
||||||
|
{
|
||||||
|
using namespace Game;
|
||||||
|
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
cmp dword ptr [esp + 0x8], 0x0
|
||||||
|
jz touched
|
||||||
|
|
||||||
|
push 0x56E82C
|
||||||
|
retn
|
||||||
|
|
||||||
|
touched:
|
||||||
|
test dword ptr [edi + 0x2BC], PWF_DISABLE_WEAPON_PICKUP
|
||||||
|
jnz exit_func
|
||||||
|
|
||||||
|
// Game code
|
||||||
|
test eax, eax
|
||||||
|
jz continue_func
|
||||||
|
|
||||||
|
exit_func:
|
||||||
|
xor eax, eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
continue_func:
|
||||||
|
push 0x56E84C
|
||||||
|
retn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Weapon::AddScriptMethods()
|
||||||
|
{
|
||||||
|
Script::AddMethod("DisableWeaponPickup", [](Game::scr_entref_t entref)
|
||||||
|
{
|
||||||
|
const auto* ent = Game::GetPlayerEntity(entref);
|
||||||
|
|
||||||
|
ent->client->ps.weapCommon.weapFlags |= Game::PWF_DISABLE_WEAPON_PICKUP;
|
||||||
|
});
|
||||||
|
|
||||||
|
Script::AddMethod("EnableWeaponPickup", [](Game::scr_entref_t entref)
|
||||||
|
{
|
||||||
|
const auto* ent = Game::GetPlayerEntity(entref);
|
||||||
|
|
||||||
|
ent->client->ps.weapCommon.weapFlags &= ~Game::PWF_DISABLE_WEAPON_PICKUP;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Weapon::Weapon()
|
Weapon::Weapon()
|
||||||
{
|
{
|
||||||
Weapon::PatchLimit();
|
PatchLimit();
|
||||||
Weapon::PatchConfigStrings();
|
PatchConfigStrings();
|
||||||
|
|
||||||
// Intercept weapon loading
|
// Intercept weapon loading
|
||||||
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_WEAPON, Weapon::WeaponFileLoad);
|
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_WEAPON, Weapon::WeaponFileLoad);
|
||||||
@ -466,7 +513,7 @@ namespace Components
|
|||||||
|
|
||||||
// Weapon swap fix
|
// Weapon swap fix
|
||||||
Utils::Hook::Nop(0x4B3670, 5);
|
Utils::Hook::Nop(0x4B3670, 5);
|
||||||
Utils::Hook(0x57B4F0, LoadNoneWeaponHookStub).install()->quick();
|
Utils::Hook(0x57B4F0, LoadNoneWeaponHookStub, HOOK_JUMP).install()->quick();
|
||||||
|
|
||||||
// Don't load bounce sounds for now, it causes crashes
|
// Don't load bounce sounds for now, it causes crashes
|
||||||
// TODO: Actually check the weaponfiles and/or reset the soundtable correctly!
|
// TODO: Actually check the weaponfiles and/or reset the soundtable correctly!
|
||||||
@ -477,5 +524,10 @@ namespace Components
|
|||||||
// Clear weapons independently from fs_game
|
// Clear weapons independently from fs_game
|
||||||
//Utils::Hook::Nop(0x452C1D, 2);
|
//Utils::Hook::Nop(0x452C1D, 2);
|
||||||
//Utils::Hook::Nop(0x452C24, 5);
|
//Utils::Hook::Nop(0x452C24, 5);
|
||||||
|
|
||||||
|
AddScriptMethods();
|
||||||
|
|
||||||
|
AssertOffset(Game::playerState_s, Game::playerState_s::weapCommon.weapFlags, 0x2BC);
|
||||||
|
Utils::Hook(0x56E825, WeaponEntCanBeGrabbed_Stub, HOOK_JUMP).install()->quick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,5 +25,8 @@ namespace Components
|
|||||||
static void ParseConfigStrings();
|
static void ParseConfigStrings();
|
||||||
static int ParseWeaponConfigStrings();
|
static int ParseWeaponConfigStrings();
|
||||||
static int ClearConfigStrings(void* dest, int value, int size);
|
static int ClearConfigStrings(void* dest, int value, int size);
|
||||||
|
|
||||||
|
static void WeaponEntCanBeGrabbed_Stub();
|
||||||
|
static void AddScriptMethods();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1367,6 +1367,8 @@ namespace Game
|
|||||||
PWF_DISABLE_WEAPON_SWAPPING = 1 << 11,
|
PWF_DISABLE_WEAPON_SWAPPING = 1 << 11,
|
||||||
PWF_DISABLE_OFFHAND_WEAPONS = 1 << 12,
|
PWF_DISABLE_OFFHAND_WEAPONS = 1 << 12,
|
||||||
PWF_SWITCHING_TO_RIOTSHIELD = 1 << 13,
|
PWF_SWITCHING_TO_RIOTSHIELD = 1 << 13,
|
||||||
|
// IW5 flags backported
|
||||||
|
PWF_DISABLE_WEAPON_PICKUP = 1 << 16
|
||||||
};
|
};
|
||||||
|
|
||||||
struct playerState_s
|
struct playerState_s
|
||||||
@ -1491,6 +1493,8 @@ namespace Game
|
|||||||
int stunTime;
|
int stunTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(Game::playerState_s) == 0x311C);
|
||||||
|
|
||||||
enum LocSelInputState
|
enum LocSelInputState
|
||||||
{
|
{
|
||||||
LOC_SEL_INPUT_NONE = 0x0,
|
LOC_SEL_INPUT_NONE = 0x0,
|
||||||
|
Loading…
Reference in New Issue
Block a user