Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/master' into experimenta…
Browse files Browse the repository at this point in the history
…l_penalty_jump
  • Loading branch information
s1lentq committed Nov 26, 2023
2 parents 6d31e33 + 5564060 commit 4126635
Show file tree
Hide file tree
Showing 25 changed files with 187 additions and 62 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_dying_time | 3.0 | 0.0 | - | Time for switch to free observing after death.<br/>`0` - disable spectating around death.<br/>`>0.00001` - time delay to start spectate.<br/>`NOTE`: The countdown starts when the player’s death animation is finished. |
| mp_deathmsg_flags | abc | 0 | - | Sets a flags for extra information in the player's death message.<br/>`0` disabled<br/>`a` position where the victim died<br/>`b` index of the assistant who helped the attacker kill the victim<br/>`c` rarity classification bits, e.g., `blinkill`, `noscope`, `penetrated`, etc. |
| mp_assist_damage_threshold | 40 | 0 | 100 | Sets the percentage of damage needed to score an assist. |
| mp_freezetime_duck | 1 | 0 | 1 | Allow players to duck during freezetime.<br/> `0` disabled<br/>`1` enabled |
| mp_freezetime_jump | 1 | 0 | 1 | Allow players to jump during freezetime.<br/> `0` disabled<br/>`1` enabled |
</details>

## How to install zBot for CS 1.6?
Expand Down
14 changes: 14 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -553,3 +553,17 @@ mp_deathmsg_flags "abc"
//
// Default value: "40"
mp_assist_damage_threshold "40"

// Allow players to duck during freezetime
// 0 - disabled
// 1 - enabled (default behaviour)
//
// Default value: "1"
mp_freezetime_duck "1"

// Allow players to jump during freezetime
// 0 - disabled
// 1 - enabled (default behaviour)
//
// Default value: "1"
mp_freezetime_jump "1"
1 change: 1 addition & 0 deletions regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ GAMEHOOK_REGISTRY(CBasePlayerWeapon_SendWeaponAnim);
GAMEHOOK_REGISTRY(CSGameRules_SendDeathMessage);

GAMEHOOK_REGISTRY(CBasePlayer_PlayerDeathThink);
GAMEHOOK_REGISTRY(CBasePlayer_Observer_Think);

int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR;
Expand Down
6 changes: 6 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,10 @@ typedef IHookChainRegistryClassImpl<void, CBasePlayerWeapon, int, int> CReGameHo
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_PlayerDeathThink;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_PlayerDeathThink;

// CBasePlayer::Observer_Think hook
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_Observer_Think;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_Observer_Think;

class CReGameHookchains: public IReGameHookchains {
public:
// CBasePlayer virtual
Expand Down Expand Up @@ -900,6 +904,7 @@ class CReGameHookchains: public IReGameHookchains {
CReGameHookRegistry_CSGameRules_SendDeathMessage m_CSGameRules_SendDeathMessage;

CReGameHookRegistry_CBasePlayer_PlayerDeathThink m_CBasePlayer_PlayerDeathThink;
CReGameHookRegistry_CBasePlayer_Observer_Think m_CBasePlayer_Observer_Think;

public:
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
Expand Down Expand Up @@ -1058,6 +1063,7 @@ class CReGameHookchains: public IReGameHookchains {
virtual IReGameHookRegistry_CSGameRules_SendDeathMessage *CSGameRules_SendDeathMessage();

virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink();
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think();
};

extern CReGameHookchains g_ReGameHookchains;
Expand Down
6 changes: 3 additions & 3 deletions regamedll/dlls/API/CSEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@

void CCSEntity::FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker)
{
m_pContainingEntity->FireBullets(iShots, vecSrc, vecDirShooting, vecSpread, flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker);
BaseEntity()->FireBullets(iShots, vecSrc, vecDirShooting, vecSpread, flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker);
}

void CCSEntity::FireBuckshots(ULONG cShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iTracerFreq, int iDamage, entvars_t *pevAttacker)
{
m_pContainingEntity->FireBuckshots(cShots, vecSrc, vecDirShooting, vecSpread, flDistance, iTracerFreq, iDamage, pevAttacker);
BaseEntity()->FireBuckshots(cShots, vecSrc, vecDirShooting, vecSpread, flDistance, iTracerFreq, iDamage, pevAttacker);
}

Vector CCSEntity::FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand)
{
return m_pContainingEntity->FireBullets3(vecSrc, vecDirShooting, vecSpread, flDistance, iPenetration, iBulletType, iDamage, flRangeModifier, pevAttacker, bPistol, shared_rand);
return BaseEntity()->FireBullets3(vecSrc, vecDirShooting, vecSpread, flDistance, iPenetration, iBulletType, iDamage, flRangeModifier, pevAttacker, bPistol, shared_rand);
}
6 changes: 4 additions & 2 deletions regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,13 @@ EXT_FUNC CBaseEntity *CCSPlayer::GiveNamedItemEx(const char *pszName)

if (FStrEq(pszName, "weapon_c4")) {
pPlayer->m_bHasC4 = true;
pPlayer->SetBombIcon();

if (pPlayer->m_iTeam == TERRORIST) {
pPlayer->pev->body = 1;
}

pPlayer->SetBombIcon();

} else if (FStrEq(pszName, "weapon_shield")) {
pPlayer->DropPrimary();
pPlayer->DropPlayerItem("weapon_elite");
Expand All @@ -266,7 +268,7 @@ EXT_FUNC CBaseEntity *CCSPlayer::GiveNamedItemEx(const char *pszName)

EXT_FUNC bool CCSPlayer::IsConnected() const
{
return m_pContainingEntity->has_disconnected == false;
return BaseEntity()->has_disconnected == false;
}

EXT_FUNC void CCSPlayer::SetAnimation(PLAYER_ANIM playerAnim)
Expand Down
10 changes: 3 additions & 7 deletions regamedll/dlls/basemonster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,17 +451,13 @@ BOOL CBaseMonster::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, f

if (pev->health <= 0.0f)
{
g_pevLastInflictor = pevInflictor;

if (bitsDamageType & DMG_ALWAYSGIB)
Killed(pevAttacker, GIB_ALWAYS);

KilledInflicted(pevInflictor, pevAttacker, GIB_ALWAYS);
else if (bitsDamageType & DMG_NEVERGIB)
Killed(pevAttacker, GIB_NEVER);
KilledInflicted(pevInflictor, pevAttacker, GIB_NEVER);
else
Killed(pevAttacker, GIB_NORMAL);
KilledInflicted(pevInflictor, pevAttacker, GIB_NORMAL);

g_pevLastInflictor = nullptr;
return FALSE;
}
if ((pev->flags & FL_MONSTER) && !FNullEnt(pevAttacker))
Expand Down
16 changes: 16 additions & 0 deletions regamedll/dlls/cbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,11 @@ BOOL CBaseEntity::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, fl
pev->health -= flDamage;
if (pev->health <= 0)
{
#ifdef REGAMEDLL_FIXES
KilledInflicted(pevInflictor, pevAttacker, GIB_NORMAL);
#else
Killed(pevAttacker, GIB_NORMAL);
#endif
return FALSE;
}

Expand Down Expand Up @@ -866,6 +870,17 @@ BOOL CBaseEntity::IsInWorld()
}

// speed
#ifdef REGAMEDLL_FIXES
float maxvel = g_psv_maxvelocity->value;
if (pev->velocity.x > maxvel || pev->velocity.y > maxvel || pev->velocity.z > maxvel)
{
return FALSE;
}
if (pev->velocity.x < -maxvel || pev->velocity.y < -maxvel || pev->velocity.z < -maxvel)
{
return FALSE;
}
#else
if (pev->velocity.x >= 2000.0 || pev->velocity.y >= 2000.0 || pev->velocity.z >= 2000.0)
{
return FALSE;
Expand All @@ -874,6 +889,7 @@ BOOL CBaseEntity::IsInWorld()
{
return FALSE;
}
#endif

return TRUE;
}
Expand Down
3 changes: 3 additions & 0 deletions regamedll/dlls/cbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ class CBaseEntity {
void ResetDmgPenetrationLevel();
int GetDmgPenetrationLevel() const;

void KilledInflicted(entvars_t *pevInflictor, entvars_t *pevAttacker, int iGib);
entvars_t *GetLastInflictor();

#ifdef REGAMEDLL_API
CCSEntity *m_pEntity;
CCSEntity *CSEntity() const;
Expand Down
9 changes: 8 additions & 1 deletion regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,12 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
CBaseEntity *pTarget = nullptr;
pPlayer->m_pIntroCamera = UTIL_FindEntityByClassname(nullptr, "trigger_camera");

#ifndef REGAMEDLL_FIXES
if (g_pGameRules && g_pGameRules->IsMultiplayer())
{
CSGameRules()->m_bMapHasCameras = (pPlayer->m_pIntroCamera != nullptr);
}
#endif

if (pPlayer->m_pIntroCamera)
{
Expand All @@ -694,7 +696,12 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
pPlayer->pev->angles = CamAngles;
pPlayer->pev->v_angle = pPlayer->pev->angles;

pPlayer->m_fIntroCamTime = gpGlobals->time + 6;
pPlayer->m_fIntroCamTime =
#ifdef REGAMEDLL_FIXES
(CSGameRules()->m_bMapHasCameras <= 1) ? 0.0 : // no need to refresh cameras if map has only one
#endif
gpGlobals->time + 6;

pPlayer->pev->view_ofs = g_vecZero;
}
#ifndef REGAMEDLL_FIXES
Expand Down
7 changes: 7 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cvar_t *g_psv_friction = nullptr;
cvar_t *g_psv_stopspeed = nullptr;
cvar_t *g_psv_stepsize = nullptr;
cvar_t *g_psv_clienttrace = nullptr;
cvar_t *g_psv_maxvelocity = nullptr;

cvar_t displaysoundlist = { "displaysoundlist", "0", 0, 0.0f, nullptr };
cvar_t timelimit = { "mp_timelimit", "0", FCVAR_SERVER, 0.0f, nullptr };
Expand Down Expand Up @@ -168,6 +169,8 @@ cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0
cvar_t give_c4_frags = { "mp_give_c4_frags", "3", 0, 3.0f, nullptr };
cvar_t deathmsg_flags = { "mp_deathmsg_flags", "abc", 0, 0.0f, nullptr };
cvar_t assist_damage_threshold = { "mp_assist_damage_threshold", "40", 0, 40.0f, nullptr };
cvar_t freezetime_duck = { "mp_freezetime_duck", "1", 0, 1.0f, nullptr };
cvar_t freezetime_jump = { "mp_freezetime_jump", "1", 0, 1.0f, nullptr };

cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr };

Expand Down Expand Up @@ -238,6 +241,7 @@ void EXT_FUNC GameDLLInit()
g_psv_stopspeed = CVAR_GET_POINTER("sv_stopspeed");
g_psv_stepsize = CVAR_GET_POINTER("sv_stepsize");
g_psv_clienttrace = CVAR_GET_POINTER("sv_clienttrace");
g_psv_maxvelocity = CVAR_GET_POINTER("sv_maxvelocity");

CVAR_REGISTER(&displaysoundlist);
CVAR_REGISTER(&timelimit);
Expand Down Expand Up @@ -432,6 +436,9 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&deathmsg_flags);
CVAR_REGISTER(&assist_damage_threshold);

CVAR_REGISTER(&freezetime_duck);
CVAR_REGISTER(&freezetime_jump);

// print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");

Expand Down
5 changes: 4 additions & 1 deletion regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@
extern cvar_t *g_pskill;
extern cvar_t *g_psv_gravity;
extern cvar_t *g_psv_aim;
extern cvar_t *g_footsteps;
extern cvar_t *g_psv_accelerate;
extern cvar_t *g_psv_friction;
extern cvar_t *g_psv_stopspeed;
extern cvar_t *g_psv_stepsize;
extern cvar_t *g_psv_clienttrace;
extern cvar_t *g_footsteps;
extern cvar_t *g_psv_maxvelocity;

extern cvar_t displaysoundlist;
extern cvar_t timelimit;
Expand Down Expand Up @@ -199,6 +200,8 @@ extern cvar_t player_movement_legacy;
extern cvar_t player_movement_penalty_jump;
extern cvar_t deathmsg_flags;
extern cvar_t assist_damage_threshold;
extern cvar_t freezetime_duck;
extern cvar_t freezetime_jump;

#endif

Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ class CHalfLifeMultiplay: public CGameRules
bool m_bMapHasEscapeZone;

BOOL m_bMapHasVIPSafetyZone; // TRUE = has VIP safety zone, FALSE = does not have VIP safetyzone
BOOL m_bMapHasCameras;
int m_bMapHasCameras;
int m_iC4Timer;
int m_iC4Guy; // The current Terrorist who has the C4.
int m_iLoserBonus; // the amount of money the losing team gets. This scales up as they lose more rounds in a row
Expand Down
21 changes: 21 additions & 0 deletions regamedll/dlls/ggrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,13 @@ void CGrenade::BounceSound()

void CGrenade::TumbleThink()
{
#ifdef REGAMEDLL_FIXES
if (pev->velocity.IsLengthGreaterThan(g_psv_maxvelocity->value))
{
pev->velocity = pev->velocity.Normalize() * g_psv_maxvelocity->value;
}
#endif

if (!IsInWorld())
{
UTIL_Remove(this);
Expand Down Expand Up @@ -809,6 +816,13 @@ void CGrenade::TumbleThink()

void CGrenade::SG_TumbleThink()
{
#ifdef REGAMEDLL_FIXES
if (pev->velocity.IsLengthGreaterThan(g_psv_maxvelocity->value))
{
pev->velocity = pev->velocity.Normalize() * g_psv_maxvelocity->value;
}
#endif

if (!IsInWorld())
{
UTIL_Remove(this);
Expand Down Expand Up @@ -1322,6 +1336,13 @@ void AnnounceFlashInterval(float interval, float offset)

void CGrenade::C4Think()
{
#ifdef REGAMEDLL_FIXES
if (pev->velocity.IsLengthGreaterThan(g_psv_maxvelocity->value))
{
pev->velocity = pev->velocity.Normalize() * g_psv_maxvelocity->value;
}
#endif

if (!IsInWorld())
{
#ifdef REGAMEDLL_FIXES
Expand Down
5 changes: 2 additions & 3 deletions regamedll/dlls/gib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ LINK_ENTITY_TO_CLASS(gib, CGib, CCSGib)

void CGib::LimitVelocity()
{
float length = pev->velocity.Length();
float topspeed = CVAR_GET_FLOAT("sv_maxvelocity") * 0.75f;
float topspeed = g_psv_maxvelocity->value * 0.75f;

// ceiling at topspeed. The gib velocity equation is not bounded properly. Rather than tune it
// in 3 separate places again, I'll just limit it here.
if (length > topspeed)
if (pev->velocity.IsLengthGreaterThan(topspeed))
{
// DONE: This should really be sv_maxvelocity * 0.75 or something
pev->velocity = pev->velocity.Normalize() * topspeed;
Expand Down
18 changes: 6 additions & 12 deletions regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay()
m_iNumTerrorist = 0;
m_iNumSpawnableCT = 0;
m_iNumSpawnableTerrorist = 0;
m_bMapHasCameras = FALSE;
m_bMapHasCameras = -1;

m_iLoserBonus = m_rgRewardAccountRules[RR_LOSER_BONUS_DEFAULT];
m_iNumConsecutiveCTLoses = 0;
Expand Down Expand Up @@ -3086,17 +3086,11 @@ void CHalfLifeMultiplay::CheckLevelInitialized()
{
// Count the number of spawn points for each team
// This determines the maximum number of players allowed on each
CBaseEntity *pEnt = nullptr;

m_iSpawnPointCount_Terrorist = 0;
m_iSpawnPointCount_CT = 0;

while ((pEnt = UTIL_FindEntityByClassname(pEnt, "info_player_deathmatch")))
m_iSpawnPointCount_Terrorist++;

while ((pEnt = UTIL_FindEntityByClassname(pEnt, "info_player_start")))
m_iSpawnPointCount_CT++;

m_iSpawnPointCount_Terrorist = UTIL_CountEntities("info_player_deathmatch");
m_iSpawnPointCount_CT = UTIL_CountEntities("info_player_start");
#ifdef REGAMEDLL_FIXES
m_bMapHasCameras = UTIL_CountEntities("trigger_camera");
#endif
m_bLevelInitialized = true;
}
}
Expand Down
6 changes: 4 additions & 2 deletions regamedll/dlls/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,11 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Observer_SetMode)(int iMode)
m_bWasFollowing = false;
}

void CBasePlayer::Observer_Think()
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, Observer_Think)

void EXT_FUNC CBasePlayer::__API_HOOK(Observer_Think)()
{
Observer_HandleButtons();
Observer_CheckTarget();
Observer_CheckProperties();
}
}
Loading

0 comments on commit 4126635

Please sign in to comment.