Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CS2Fixes.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
<ClInclude Include="src\cs2_sdk\entity\cenventitymaker.h" />
<ClInclude Include="src\cs2_sdk\entity\cgameplayerequip.h" />
<ClInclude Include="src\cs2_sdk\entity\cgamerules.h" />
<ClInclude Include="src\cs2_sdk\entity\clogiccase.h" />
<ClInclude Include="src\cs2_sdk\entity\cparticlesystem.h" />
<ClInclude Include="src\cs2_sdk\entity\cphysthruster.h" />
<ClInclude Include="src\cs2_sdk\entity\ctakedamageinfo.h" />
Expand Down
3 changes: 3 additions & 0 deletions CS2Fixes.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,8 @@
<ClInclude Include="src\cs2_sdk\entity\cgameplayerequip.h">
<Filter>Header Files\cs2_sdk\entity</Filter>
</ClInclude>
<ClInclude Include="src\cs2_sdk\entity\clogiccase.h">
<Filter>Header Files\cs2_sdk\entity</Filter>
</ClInclude>
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions src/cs2_sdk/entity/cbaseentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

extern CGameConfig *g_GameConfig;

class CGameUI;

class CGameSceneNode
{
public:
Expand Down Expand Up @@ -134,6 +136,7 @@ class Z_CBaseEntity : public CBaseEntity
SCHEMA_FIELD(float, m_flSpeed)
SCHEMA_FIELD(CUtlString, m_sUniqueHammerID);
SCHEMA_FIELD(CUtlSymbolLarge, m_target);
SCHEMA_FIELD(CUtlSymbolLarge, m_iGlobalname);

int entindex() { return m_pEntity->m_EHandle.GetEntryIndex(); }

Expand Down Expand Up @@ -239,6 +242,23 @@ class Z_CBaseEntity : public CBaseEntity
}

const char* GetName() const { return m_pEntity->m_name.String(); }

/* Begin Custom Entities Cast */

[[nodiscard]] CGameUI *AsGameUI()
{
if (V_strcasecmp(GetClassname(), "logic_case") != 0)
return nullptr;

const auto tag = m_iszPrivateVScripts.IsValid() ? m_iszPrivateVScripts.String() : nullptr;

if (tag && V_strcasecmp(tag, "game_ui") == 0)
return reinterpret_cast<CGameUI *>(this);

return nullptr;
}

/* End Custom Entities Cast */
};

class SpawnPoint : public Z_CBaseEntity
Expand Down
42 changes: 42 additions & 0 deletions src/cs2_sdk/entity/clogiccase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* =============================================================================
* CS2Fixes
* Copyright (C) 2023-2024 Source2ZE
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "../schema.h"
#include "cbaseentity.h"

class CLogicCase : public Z_CBaseEntity
{
public:
DECLARE_SCHEMA_CLASS(CLogicCase)
};

class CGameUI : public CLogicCase
{
public:
static constexpr int SF_GAMEUI_FREEZE_PLAYER = 32;
static constexpr int SF_GAMEUI_JUMP_DEACTIVATE = 256;

// TODO Hide Weapon requires more RE
static constexpr int SF_GAMEUI_HIDE_WEAPON = 64;

// TODO subtick problem
static constexpr int SF_GAMEUI_USE_DEACTIVATE = 128;
};
8 changes: 5 additions & 3 deletions src/cs2fixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool

Message( "Starting plugin.\n" );

SH_ADD_HOOK(IServerGameDLL, GameFrame, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameFrame), true);
SH_ADD_HOOK(IServerGameDLL, GameFrame, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameFramePost), true);
SH_ADD_HOOK(IServerGameDLL, GameServerSteamAPIActivated, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameServerSteamAPIActivated), false);
SH_ADD_HOOK(IServerGameDLL, GameServerSteamAPIDeactivated, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameServerSteamAPIDeactivated), false);
SH_ADD_HOOK(IServerGameClients, ClientActive, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientActive), true);
Expand Down Expand Up @@ -288,7 +288,7 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool

bool CS2Fixes::Unload(char *error, size_t maxlen)
{
SH_REMOVE_HOOK(IServerGameDLL, GameFrame, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameFrame), true);
SH_REMOVE_HOOK(IServerGameDLL, GameFrame, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameFramePost), true);
SH_REMOVE_HOOK(IServerGameDLL, GameServerSteamAPIActivated, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameServerSteamAPIActivated), false);
SH_REMOVE_HOOK(IServerGameDLL, GameServerSteamAPIDeactivated, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameServerSteamAPIDeactivated), false);
SH_REMOVE_HOOK(IServerGameClients, ClientActive, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientActive), true);
Expand Down Expand Up @@ -620,7 +620,7 @@ void CS2Fixes::Hook_ClientDisconnect( CPlayerSlot slot, ENetworkDisconnectionRea
g_playerManager->OnClientDisconnect(slot);
}

void CS2Fixes::Hook_GameFrame( bool simulating, bool bFirstTick, bool bLastTick )
void CS2Fixes::Hook_GameFramePost(bool simulating, bool bFirstTick, bool bLastTick)
{
VPROF_ENTER_SCOPE(__FUNCTION__);
/**
Expand Down Expand Up @@ -666,6 +666,8 @@ void CS2Fixes::Hook_GameFrame( bool simulating, bool bFirstTick, bool bLastTick
if (g_bEnableZR)
CZRRegenTimer::Tick();

EntityHandler_OnGameFramePost(simulating, gpGlobals->tickcount);

VPROF_EXIT_SCOPE();
}

Expand Down
2 changes: 1 addition & 1 deletion src/cs2fixes.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CS2Fixes : public ISmmPlugin, public IMetamodListener
bool loadGame,
bool background );
void OnLevelShutdown();
void Hook_GameFrame( bool simulating, bool bFirstTick, bool bLastTick );
void Hook_GameFramePost(bool simulating, bool bFirstTick, bool bLastTick);
void Hook_ClientActive( CPlayerSlot slot, bool bLoadGame, const char *pszName, uint64 xuid );
void Hook_ClientDisconnect( CPlayerSlot slot, ENetworkDisconnectionReason reason, const char *pszName, uint64 xuid, const char *pszNetworkID );
void Hook_ClientPutInServer( CPlayerSlot slot, char const *pszName, int type, uint64 xuid );
Expand Down
94 changes: 46 additions & 48 deletions src/customio.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* =============================================================================
* CS2Fixes
* Copyright (C) 2023 Source2ZE
* Copyright (C) 2023-2024 Source2ZE
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
Expand Down Expand Up @@ -31,7 +31,7 @@
#include <string>
#include <vector>

extern CGlobalVars *gpGlobals;
extern CGlobalVars* gpGlobals;

struct AddOutputKey_t
{
Expand Down Expand Up @@ -140,8 +140,8 @@ static void AddOutputCustom_MoveType(Z_CBaseEntity* pInstance,
const std::vector<std::string>& vecArgs)
{
static Vector stopVelocity(0, 0, 0);
const auto value = clamp(Q_atoi(vecArgs[1].c_str()), MOVETYPE_NONE, MOVETYPE_LAST);
const auto type = static_cast<MoveType_t>(value);
const auto value = clamp(Q_atoi(vecArgs[1].c_str()), MOVETYPE_NONE, MOVETYPE_LAST);
const auto type = static_cast<MoveType_t>(value);

pInstance->SetMoveType(type);

Expand Down Expand Up @@ -185,14 +185,14 @@ static void AddOutputCustom_BaseVelocity(Z_CBaseEntity* pInstan
#endif
}

static void AddOutputCustom_AbsVelocity(Z_CBaseEntity *pInstance,
CEntityInstance *pActivator,
CEntityInstance *pCaller,
const std::vector<std::string> &vecArgs)
static void AddOutputCustom_AbsVelocity(Z_CBaseEntity* pInstance,
CEntityInstance* pActivator,
CEntityInstance* pCaller,
const std::vector<std::string>& vecArgs)
{
Vector velocity(clamp(Q_atof(vecArgs[1].c_str()), -4096.f, 4096.f),
clamp(Q_atof(vecArgs[2].c_str()), -4096.f, 4096.f),
clamp(Q_atof(vecArgs[3].c_str()), -4096.f, 4096.f));
clamp(Q_atof(vecArgs[2].c_str()), -4096.f, 4096.f),
clamp(Q_atof(vecArgs[3].c_str()), -4096.f, 4096.f));

pInstance->Teleport(nullptr, nullptr, &velocity);

Expand All @@ -201,7 +201,7 @@ static void AddOutputCustom_AbsVelocity(Z_CBaseEntity *pInstance,
#endif
}

static void AddOutputCustom_Target(Z_CBaseEntity* pInstance,
static void AddOutputCustom_Target(Z_CBaseEntity* pInstance,
CEntityInstance* pActivator,
CEntityInstance* pCaller,
const std::vector<std::string>& vecArgs)
Expand Down Expand Up @@ -242,7 +242,7 @@ static void AddOutputCustom_Force(Z_CBaseEntity* pInstance,
CEntityInstance* pCaller,
const std::vector<std::string>& vecArgs)
{
const auto value = Q_atof(vecArgs[1].c_str());
const auto value = Q_atof(vecArgs[1].c_str());
const auto pEntity = reinterpret_cast<CPhysThruster*>(pInstance);
if (V_strcasecmp(pEntity->GetClassname(), "phys_thruster") == 0)
{
Expand All @@ -254,24 +254,24 @@ static void AddOutputCustom_Force(Z_CBaseEntity* pInstance,
}
}

static void AddOutputCustom_Gravity(Z_CBaseEntity *pInstance,
CEntityInstance *pActivator,
CEntityInstance *pCaller,
const std::vector<std::string> &vecArgs)
static void AddOutputCustom_Gravity(Z_CBaseEntity* pInstance,
CEntityInstance* pActivator,
CEntityInstance* pCaller,
const std::vector<std::string>& vecArgs)
{
const auto value = Q_atof(vecArgs[1].c_str());

pInstance->m_flGravityScale = value;

#ifdef _DEBUG
Message("Set gravity to %f for %s\n", value, pInstance->GetName());
Message("Set gravity to %f for %s\n", value, pInstance->GetName());
#endif
}

static void AddOutputCustom_Timescale(Z_CBaseEntity *pInstance,
CEntityInstance *pActivator,
CEntityInstance *pCaller,
const std::vector<std::string> &vecArgs)
static void AddOutputCustom_Timescale(Z_CBaseEntity* pInstance,
CEntityInstance* pActivator,
CEntityInstance* pCaller,
const std::vector<std::string>& vecArgs)
{
const auto value = Q_atof(vecArgs[1].c_str());

Expand All @@ -282,10 +282,10 @@ static void AddOutputCustom_Timescale(Z_CBaseEntity *pInstance,
#endif
}

static void AddOutputCustom_Friction(Z_CBaseEntity *pInstance,
CEntityInstance *pActivator,
CEntityInstance *pCaller,
const std::vector<std::string> &vecArgs)
static void AddOutputCustom_Friction(Z_CBaseEntity* pInstance,
CEntityInstance* pActivator,
CEntityInstance* pCaller,
const std::vector<std::string>& vecArgs)
{
const auto value = Q_atof(vecArgs[1].c_str());

Expand All @@ -296,16 +296,16 @@ static void AddOutputCustom_Friction(Z_CBaseEntity *pInstance,
#endif
}

static void AddOutputCustom_Speed(Z_CBaseEntity *pInstance,
CEntityInstance *pActivator,
CEntityInstance *pCaller,
const std::vector<std::string> &vecArgs)
static void AddOutputCustom_Speed(Z_CBaseEntity* pInstance,
CEntityInstance* pActivator,
CEntityInstance* pCaller,
const std::vector<std::string>& vecArgs)
{
if (!pInstance->IsPawn())
return;

CCSPlayerPawn *pPawn = (CCSPlayerPawn*)pInstance;
CCSPlayerController *pController = (CCSPlayerController*)pPawn->GetOriginalController();
const auto pPawn = reinterpret_cast<CCSPlayerPawn*>(pInstance);
const auto pController = pPawn->GetOriginalController();

if (!pController || !pController->IsConnected())
return;
Expand All @@ -319,15 +319,15 @@ static void AddOutputCustom_Speed(Z_CBaseEntity *pInstance,
#endif
}

static void AddOutputCustom_RunSpeed(Z_CBaseEntity *pInstance,
CEntityInstance *pActivator,
CEntityInstance *pCaller,
const std::vector<std::string> &vecArgs)
static void AddOutputCustom_RunSpeed(Z_CBaseEntity* pInstance,
CEntityInstance* pActivator,
CEntityInstance* pCaller,
const std::vector<std::string>& vecArgs)
{
if (!pInstance->IsPawn())
return;

CCSPlayerPawn *pPawn = reinterpret_cast<CCSPlayerPawn*>(pInstance);
const auto pPawn = reinterpret_cast<CCSPlayerPawn*>(pInstance);

const auto value = Q_atof(vecArgs[1].c_str());

Expand Down Expand Up @@ -397,7 +397,6 @@ bool CustomIO_HandleInput(CEntityInstance* pInstance,
return false;
}


std::string g_sBurnParticle = "particles/burning_fx/burning_character_b.vpcf";
FAKE_STRING_CVAR(cs2f_burn_particle, "The particle to use for burning entities", g_sBurnParticle, false);

Expand All @@ -410,26 +409,26 @@ FAKE_FLOAT_CVAR(cs2f_burn_slowdown, "The slowdown of each burn damage tick as a
float g_flBurnInterval = 0.3f;
FAKE_FLOAT_CVAR(cs2f_burn_interval, "The interval between burn damage ticks", g_flBurnInterval, 0.3f, false);

bool IgnitePawn(CCSPlayerPawn *pPawn, float flDuration, Z_CBaseEntity *pInflictor, Z_CBaseEntity *pAttacker, Z_CBaseEntity *pAbility, DamageTypes_t nDamageType)
bool IgnitePawn(CCSPlayerPawn* pPawn, float flDuration, Z_CBaseEntity* pInflictor, Z_CBaseEntity* pAttacker, Z_CBaseEntity* pAbility, DamageTypes_t nDamageType)
{
CParticleSystem *pParticleEnt = (CParticleSystem*)pPawn->m_hEffectEntity().Get();
auto pParticleEnt = reinterpret_cast<CParticleSystem*>(pPawn->m_hEffectEntity().Get());

// This guy is already burning, don't ignite again
if (pParticleEnt)
{
{
// Override the end time instead of just adding to it so players who get a ton of ignite inputs don't burn forever
pParticleEnt->m_flDissolveStartTime = gpGlobals->curtime + flDuration;
return true;
}

Vector vecOrigin = pPawn->GetAbsOrigin();
const auto vecOrigin = pPawn->GetAbsOrigin();

pParticleEnt = (CParticleSystem *)CreateEntityByName("info_particle_system");
pParticleEnt = reinterpret_cast<CParticleSystem*>(CreateEntityByName("info_particle_system"));

pParticleEnt->m_bStartActive(true);
pParticleEnt->m_iszEffectName(g_sBurnParticle.c_str());
pParticleEnt->m_hControlPointEnts[0] = pPawn;
pParticleEnt->m_flDissolveStartTime = gpGlobals->curtime + flDuration; // Store the end time in the particle itself so we can increment if needed
pParticleEnt->m_flDissolveStartTime = gpGlobals->curtime + flDuration; // Store the end time in the particle itself so we can increment if needed
pParticleEnt->Teleport(&vecOrigin, nullptr, nullptr);

pParticleEnt->DispatchSpawn();
Expand All @@ -443,14 +442,13 @@ bool IgnitePawn(CCSPlayerPawn *pPawn, float flDuration, Z_CBaseEntity *pInflicto
CHandle<Z_CBaseEntity> hAttacker(pAttacker);
CHandle<Z_CBaseEntity> hAbility(pAbility);

new CTimer(0.f, false, [hPawn, hInflictor, hAttacker, hAbility, nDamageType]()
{
CCSPlayerPawn *pPawn = hPawn.Get();
new CTimer(0.f, false, [hPawn, hInflictor, hAttacker, hAbility, nDamageType]() {
CCSPlayerPawn* pPawn = hPawn.Get();

if (!pPawn)
return -1.f;

CParticleSystem *pParticleEnt = (CParticleSystem*)pPawn->m_hEffectEntity().Get();
const auto pParticleEnt = reinterpret_cast<CParticleSystem*>(pPawn->m_hEffectEntity().Get());

if (!pParticleEnt)
return -1.f;
Expand All @@ -475,7 +473,7 @@ bool IgnitePawn(CCSPlayerPawn *pPawn, float flDuration, Z_CBaseEntity *pInflicto
// Damage doesn't apply if the inflictor is null
if (!hInflictor.Get())
info.m_hInflictor.Set(hAttacker);

pPawn->TakeDamage(info);

pPawn->m_flVelocityModifier = g_flBurnSlowdown;
Expand Down
Loading