Merge pull request #1026 from diamante0018/develop
[Weapon]: Add very realistic FreezeControlsAllowLook
This commit is contained in:
commit
aad6096ccd
@ -488,12 +488,12 @@ namespace Components
|
|||||||
if (!CheatsOk(ent))
|
if (!CheatsOk(ent))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ent->client->flags ^= Game::PF_NOCLIP;
|
ent->client->flags ^= Game::CF_BIT_NOCLIP;
|
||||||
|
|
||||||
const auto entNum = ent->s.number;
|
const auto entNum = ent->s.number;
|
||||||
Logger::Debug("Noclip toggled for entity {}", entNum);
|
Logger::Debug("Noclip toggled for entity {}", entNum);
|
||||||
|
|
||||||
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::PF_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF"));
|
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::CF_BIT_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientCommand::Cmd_UFO_f(Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params)
|
void ClientCommand::Cmd_UFO_f(Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params)
|
||||||
@ -501,12 +501,12 @@ namespace Components
|
|||||||
if (!CheatsOk(ent))
|
if (!CheatsOk(ent))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ent->client->flags ^= Game::PF_UFO;
|
ent->client->flags ^= Game::CF_BIT_UFO;
|
||||||
|
|
||||||
const auto entNum = ent->s.number;
|
const auto entNum = ent->s.number;
|
||||||
Logger::Debug("UFO toggled for entity {}", entNum);
|
Logger::Debug("UFO toggled for entity {}", entNum);
|
||||||
|
|
||||||
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::PF_UFO) ? "GAME_UFOON" : "GAME_UFOOFF"));
|
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::CF_BIT_UFO) ? "GAME_UFOON" : "GAME_UFOOFF"));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientCommand::ClientCommand()
|
ClientCommand::ClientCommand()
|
||||||
|
@ -262,7 +262,7 @@ namespace Components::GSC
|
|||||||
auto* ent = &Game::g_entities[entref.entnum];
|
auto* ent = &Game::g_entities[entref.entnum];
|
||||||
if (!ent->client)
|
if (!ent->client)
|
||||||
{
|
{
|
||||||
Game::Scr_ObjectError(Utils::String::VA("entity %i is not a player", entref.entnum));
|
Game::Scr_ObjectError(Utils::String::VA("entity %hu is not a player", entref.entnum));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,20 +169,9 @@ namespace Components::GSC
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptExtension::AddMethods()
|
|
||||||
{
|
|
||||||
// PlayerCmd_AreControlsFrozen GSC function from Black Ops 2
|
|
||||||
Script::AddMethod("AreControlsFrozen", [](Game::scr_entref_t entref) // Usage: self AreControlsFrozen();
|
|
||||||
{
|
|
||||||
const auto* ent = Script::Scr_GetPlayerEntity(entref);
|
|
||||||
Game::Scr_AddBool((ent->client->flags & Game::PF_FROZEN) != 0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptExtension::ScriptExtension()
|
ScriptExtension::ScriptExtension()
|
||||||
{
|
{
|
||||||
AddFunctions();
|
AddFunctions();
|
||||||
AddMethods();
|
|
||||||
|
|
||||||
Utils::Hook(0x61E92E, VMExecuteInternalStub, HOOK_JUMP).install()->quick();
|
Utils::Hook(0x61E92E, VMExecuteInternalStub, HOOK_JUMP).install()->quick();
|
||||||
Utils::Hook::Nop(0x61E933, 1);
|
Utils::Hook::Nop(0x61E933, 1);
|
||||||
|
@ -18,6 +18,5 @@ namespace Components::GSC
|
|||||||
static void VMExecuteInternalStub();
|
static void VMExecuteInternalStub();
|
||||||
|
|
||||||
static void AddFunctions();
|
static void AddFunctions();
|
||||||
static void AddMethods();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ namespace Components
|
|||||||
|
|
||||||
Events::OnSteamDisconnect(CL_ClearMutedList);
|
Events::OnSteamDisconnect(CL_ClearMutedList);
|
||||||
Events::OnClientDisconnect(SV_UnmuteClient);
|
Events::OnClientDisconnect(SV_UnmuteClient);
|
||||||
Events::OnClientConnect([](Game::client_s* cl) -> void
|
Events::OnClientConnect([](const Game::client_s* cl) -> void
|
||||||
{
|
{
|
||||||
if (Chat::IsMuted(cl))
|
if (Chat::IsMuted(cl))
|
||||||
{
|
{
|
||||||
|
@ -548,7 +548,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Weapon::PlayerCmd_InitialWeaponRaise(Game::scr_entref_t entref)
|
void Weapon::PlayerCmd_InitialWeaponRaise(const Game::scr_entref_t entref)
|
||||||
{
|
{
|
||||||
auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||||
const auto* weapon = Game::Scr_GetString(0);
|
const auto* weapon = Game::Scr_GetString(0);
|
||||||
@ -578,23 +578,47 @@ namespace Components
|
|||||||
Game::Player_SwitchToWeapon(ent);
|
Game::Player_SwitchToWeapon(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Weapon::PlayerCmd_FreezeControlsAllowLook(const Game::scr_entref_t entref)
|
||||||
|
{
|
||||||
|
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||||
|
|
||||||
|
if (Game::Scr_GetInt(0))
|
||||||
|
{
|
||||||
|
ent->client->ps.weapCommon.weapFlags |= Game::PWF_DISABLE_WEAPONS;
|
||||||
|
ent->client->flags |= Game::CF_BIT_DISABLE_USABILITY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ent->client->ps.weapCommon.weapFlags &= ~Game::PWF_DISABLE_WEAPONS;
|
||||||
|
ent->client->flags &= ~Game::CF_BIT_DISABLE_USABILITY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Weapon::AddScriptMethods()
|
void Weapon::AddScriptMethods()
|
||||||
{
|
{
|
||||||
GSC::Script::AddMethod("DisableWeaponPickup", [](Game::scr_entref_t entref)
|
GSC::Script::AddMethod("DisableWeaponPickup", [](const Game::scr_entref_t entref)
|
||||||
{
|
{
|
||||||
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||||
|
|
||||||
ent->client->ps.weapCommon.weapFlags |= Game::PWF_DISABLE_WEAPON_PICKUP;
|
ent->client->ps.weapCommon.weapFlags |= Game::PWF_DISABLE_WEAPON_PICKUP;
|
||||||
});
|
});
|
||||||
|
|
||||||
GSC::Script::AddMethod("EnableWeaponPickup", [](Game::scr_entref_t entref)
|
GSC::Script::AddMethod("EnableWeaponPickup", [](const Game::scr_entref_t entref)
|
||||||
{
|
{
|
||||||
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||||
|
|
||||||
ent->client->ps.weapCommon.weapFlags &= ~Game::PWF_DISABLE_WEAPON_PICKUP;
|
ent->client->ps.weapCommon.weapFlags &= ~Game::PWF_DISABLE_WEAPON_PICKUP;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// PlayerCmd_AreControlsFrozen GSC function from Black Ops 2
|
||||||
|
GSC::Script::AddMethod("AreControlsFrozen", [](Game::scr_entref_t entref) // Usage: self AreControlsFrozen();
|
||||||
|
{
|
||||||
|
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||||
|
Game::Scr_AddBool((ent->client->flags & Game::CF_BIT_FROZEN) != 0);
|
||||||
|
});
|
||||||
|
|
||||||
GSC::Script::AddMethod("InitialWeaponRaise", PlayerCmd_InitialWeaponRaise);
|
GSC::Script::AddMethod("InitialWeaponRaise", PlayerCmd_InitialWeaponRaise);
|
||||||
|
GSC::Script::AddMethod("FreezeControlsAllowLook", PlayerCmd_FreezeControlsAllowLook);
|
||||||
}
|
}
|
||||||
|
|
||||||
Weapon::Weapon()
|
Weapon::Weapon()
|
||||||
|
@ -36,6 +36,7 @@ namespace Components
|
|||||||
static void WeaponEntCanBeGrabbed_Stub();
|
static void WeaponEntCanBeGrabbed_Stub();
|
||||||
|
|
||||||
static void PlayerCmd_InitialWeaponRaise(Game::scr_entref_t entref);
|
static void PlayerCmd_InitialWeaponRaise(Game::scr_entref_t entref);
|
||||||
|
static void PlayerCmd_FreezeControlsAllowLook(Game::scr_entref_t entref);
|
||||||
|
|
||||||
static void AddScriptMethods();
|
static void AddScriptMethods();
|
||||||
};
|
};
|
||||||
|
@ -1156,7 +1156,7 @@ namespace Game
|
|||||||
int SEH_GetLocalizedTokenReference(char* token, const char* reference, const char* messageType, msgLocErrType_t errType)
|
int SEH_GetLocalizedTokenReference(char* token, const char* reference, const char* messageType, msgLocErrType_t errType)
|
||||||
{
|
{
|
||||||
static DWORD SEH_GetLocalizedTokenReference_t = 0x629BB0;
|
static DWORD SEH_GetLocalizedTokenReference_t = 0x629BB0;
|
||||||
auto answer = 0;
|
auto result = 0;
|
||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
@ -1167,11 +1167,11 @@ namespace Game
|
|||||||
push token
|
push token
|
||||||
call SEH_GetLocalizedTokenReference_t
|
call SEH_GetLocalizedTokenReference_t
|
||||||
add esp, 0x4
|
add esp, 0x4
|
||||||
mov answer, eax
|
mov result, eax
|
||||||
popad
|
popad
|
||||||
}
|
}
|
||||||
|
|
||||||
return answer;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player_SwitchToWeapon(gentity_s* player)
|
void Player_SwitchToWeapon(gentity_s* player)
|
||||||
|
@ -7140,9 +7140,11 @@ namespace Game
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PF_NOCLIP = 1 << 0,
|
CF_BIT_NOCLIP = (1 << 0),
|
||||||
PF_UFO = 1 << 1,
|
CF_BIT_UFO = (1 << 1),
|
||||||
PF_FROZEN = 1 << 2,
|
CF_BIT_FROZEN = (1 << 2),
|
||||||
|
CF_BIT_DISABLE_USABILITY = (1 << 3),
|
||||||
|
CF_BIT_NO_KNOCKBACK = (1 << 4),
|
||||||
};
|
};
|
||||||
|
|
||||||
enum sessionState_t
|
enum sessionState_t
|
||||||
|
Loading…
Reference in New Issue
Block a user