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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_timelimit | 0 | - | - | Period between map rotations.<br />`0` means no limit |
| mp_forcerespawn | 0 | 0 | - | Players will automatically respawn when killed.<br/>`0` disabled<br/>`>0.00001` time delay to respawn |
| mp_hostage_hurtable | 1 | 0 | 1 | The hostages can take damage.<br/>`0` disabled<br/>`1` from any team<br/>`2` only from `CT`<br/>`3` only from `T` |
| mp_hostage_fear | 1 | 0 | 1 | The hostages with improved AI (`hostage_ai_enable 1`) get scared of gunfire, explosions and nearby deaths.<br/>`0` disabled (hostages stay calm)<br/>`1` enabled |
| mp_show_radioicon | 1 | 0 | 1 | Show radio icon.<br/>`0` disabled<br/>`1` enabled |
| mp_show_scenarioicon | 0 | 0 | 1 | Show scenario icon in HUD such as count of alive hostages or ticking bomb.<br/>`0` disabled<br/>`1` enabled |
| mp_show_bomb_timer | 0 | 0 | 1 | Show the time until the planted bomb explodes on the HUD round timer.<br/>`0` disabled<br/>`1` enabled (when the bomb is planted, the round timer shows the C4 countdown) |
| mp_old_bomb_defused_sound | 1 | 0 | 1 | Play "Bomb has been defused" sound instead of "Counter-Terrorists win" when bomb was defused<br/>`0` disabled<br/>`1` enabled |
| showtriggers | 0 | 0 | 1 | Debug cvar shows triggers. |
| sv_alltalk | 0 | 0 | 5 | When players can hear each other ([further explanation](../../wiki/sv_alltalk)).<br/>`0` dead don't hear alive<br/>`1` no restrictions<br/>`2` teammates hear each other<br/>`3` Same as 2, but spectators hear everybody<br/>`4` alive hear alive, dead hear dead and alive.<br/>`5` alive hear alive teammates, dead hear dead and alive.
Expand Down Expand Up @@ -143,6 +145,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_playerid_showhealth | 1 | 0 | 2 | Player ID display mode.<br/>`0` don't show health<br/>`1` show health for teammates only (default CS behaviour)<br/>`2` show health for all players |
| mp_playerid_field | 3 | 0 | 3 | Player ID field display mode.<br/>`0` don't show additional information<br/>`1` show team name<br/>`2` show health percentage<br/>`3` show both team name and health percentage |
| mp_knockback | 170 | - | - | Knockback force applied to the victim when damaged by strong weapons (e.g. `AWP`, `AK47`).<br/>Works only if not crouching, and not hit in the legs.<br/>Set to `0` to disable. |
| mp_knife_wall_sparks | 0 | 0 | 1 | Show a spark effect at the point of impact when a knife hits a wall.<br/>`0` disabled<br/>`1` enabled |

</details>

Expand Down
22 changes: 22 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ mp_forcerespawn "0"
// Default value: "1"
mp_hostage_hurtable "1"

// The hostages with improved AI (hostage_ai_enable 1)
// get scared of gunfire, explosions and nearby deaths.
// 0 - disabled (hostages stay calm)
// 1 - enabled (default behaviour)
//
// Default value: "1"
mp_hostage_fear "1"

// Show radio icon.
// 0 - disabled
// 1 - enabled (default behavior)
Expand All @@ -191,6 +199,13 @@ mp_show_radioicon "1"
// Default value: "0"
mp_show_scenarioicon "0"

// Show the time until the planted bomb explodes on the HUD round timer
// 0 - disabled (default behavior)
// 1 - enabled (when the bomb is planted, the round timer shows the C4 countdown)
//
// Default value: "0"
mp_show_bomb_timer "0"

// Play "Bomb has been defused" sound instead of "Counter-Terrorists win" when bomb was defused
// 0 - disabled (default behavior)
// 1 - enabled
Expand Down Expand Up @@ -698,3 +713,10 @@ mp_playerid_field "3"
//
// Default: "170"
mp_knockback "170"

// Show a spark effect at the point of impact when a knife hits a wall
// 0 - disabled (default behavior)
// 1 - enabled
//
// Default value: "0"
mp_knife_wall_sparks "0"
1 change: 1 addition & 0 deletions regamedll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ endif()

set(UNITTESTS_SRCS
"unittests/animation_tests.cpp"
"unittests/shared_util_tests.cpp"
"unittests/struct_offsets_tests.cpp"
"unittests/TestRunner.cpp"
)
Expand Down
9 changes: 9 additions & 0 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,15 @@ BOOL EXT_FUNC __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *pPlayer, int slot)
}
}

#ifdef REGAMEDLL_FIXES
// Both teams are full and no bot could be vacated, deny;
// otherwise the player would get into the game while on UNASSIGNED team
if (team == UNASSIGNED)
{
return FALSE;
}
#endif

break;
}
case MENU_SLOT_TEAM_SPECT:
Expand Down
8 changes: 8 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ cvar_t round_restart_delay = { "mp_round_restart_delay", "5", FCVAR_SERVER, 0.
cvar_t showtriggers = { "showtriggers", "0", 0, 0.0f, nullptr }; // debug cvar shows triggers
// TODO: Maybe it's better to register in the engine?
cvar_t hostagehurtable = { "mp_hostage_hurtable", "1", FCVAR_SERVER, 1.0f, nullptr };
cvar_t hostagefear = { "mp_hostage_fear", "1", FCVAR_SERVER, 1.0f, nullptr };
cvar_t roundover = { "mp_roundover", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t forcerespawn = { "mp_forcerespawn", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t show_radioicon = { "mp_show_radioicon", "1", 0, 1.0f, nullptr };
Expand Down Expand Up @@ -201,6 +202,9 @@ cvar_t playerid_field = { "mp_playerid_field", "3", 0, 3.0f, nullptr };

cvar_t knockback = { "mp_knockback", "170", 0, 170.0f, nullptr };

cvar_t knife_wall_sparks = { "mp_knife_wall_sparks", "0", 0, 0.0f, nullptr };
cvar_t show_bomb_timer = { "mp_show_bomb_timer", "0", 0, 0.0f, nullptr };

void GameDLL_Version_f()
{
if (Q_stricmp(CMD_ARGV(1), "version") != 0)
Expand Down Expand Up @@ -403,6 +407,7 @@ void EXT_FUNC GameDLLInit()

CVAR_REGISTER(&showtriggers);
CVAR_REGISTER(&hostagehurtable);
CVAR_REGISTER(&hostagefear);
CVAR_REGISTER(&roundover);
CVAR_REGISTER(&forcerespawn);
CVAR_REGISTER(&show_radioicon);
Expand Down Expand Up @@ -489,6 +494,9 @@ void EXT_FUNC GameDLLInit()

CVAR_REGISTER(&knockback);

CVAR_REGISTER(&knife_wall_sparks);
CVAR_REGISTER(&show_bomb_timer);

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

Expand Down
3 changes: 3 additions & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ extern cvar_t round_restart_delay;

extern cvar_t showtriggers;
extern cvar_t hostagehurtable;
extern cvar_t hostagefear;
extern cvar_t roundover;
extern cvar_t forcerespawn;
extern cvar_t show_radioicon;
Expand Down Expand Up @@ -217,6 +218,8 @@ extern cvar_t randomspawn;
extern cvar_t playerid_showhealth;
extern cvar_t playerid_field;
extern cvar_t knockback;
extern cvar_t knife_wall_sparks;
extern cvar_t show_bomb_timer;

#endif

Expand Down
13 changes: 13 additions & 0 deletions regamedll/dlls/ggrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ void CGrenade::__API_HOOK(Explode2)(TraceResult *pTrace, int bitsDamageType)
m_bJustBlew = true;
CSGameRules()->CheckWinConditions();

#ifdef REGAMEDLL_ADD
// restore the HUD round timer if the round did not end on the explosion
// (e.g. mp_round_infinite blocks the bomb round-end check)
if (show_bomb_timer.value != 0.0f)
SyncRoundTimerForAll();
#endif

// Pull out of the wall a bit
if (pTrace->flFraction != 1.0f)
{
Expand Down Expand Up @@ -1155,6 +1162,12 @@ void CGrenade::__API_HOOK(DefuseBombEnd)(CBasePlayer *pPlayer, bool bDefused)
g_pGameRules->m_bBombDropped = FALSE;
m_pBombDefuser = nullptr;
m_bStartDefuse = false;

#ifdef REGAMEDLL_ADD
// restore the HUD round timer
if (show_bomb_timer.value != 0.0f)
SyncRoundTimerForAll();
#endif
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions regamedll/dlls/hostage/hostage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,11 @@ void CHostageManager::ServerActivate()

#ifdef REGAMEDLL_ADD
if (!AreRunningCZero()) {
// Free stale navigation data of the previous map,
// CCSBotManager::LoadNavigationMap does this only when bots are allowed
if (!AreBotsAllowed())
DestroyNavigationMap();

LoadNavigationMap();
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions regamedll/dlls/hostage/hostage_improv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,12 @@ bool CHostageImprov::IsScared() const

void CHostageImprov::Frighten(ScareType scare)
{
#ifdef REGAMEDLL_ADD
// keep hostages calm, they won't get scared of gunfire, explosions or nearby deaths
if (hostagefear.value <= 0.0f)
return;
#endif

const float ignoreTime = 10.0f;

if (!IsScared())
Expand Down
74 changes: 67 additions & 7 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3240,13 +3240,14 @@ void CBasePlayer::WaterMove()
if (pev->dmg > 5)
pev->dmg = 5;

TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->dmg, DMG_DROWN);

#ifdef REGAMEDLL_FIXES
// NOTE: If we died after the damage of above and was followed respawn,
// so we should get out of code.
if (!(m_bitsDamageType & DMG_DROWN))
// Don't track drowning damage that wasn't actually applied (player is
// invulnerable/DAMAGE_NO, or died from it and possibly respawned) -
// otherwise it would be "given back" as free health when surfacing.
if (!TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->dmg, DMG_DROWN))
return;
#else
TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->dmg, DMG_DROWN);
#endif

pev->pain_finished = gpGlobals->time + 1;
Expand Down Expand Up @@ -3603,15 +3604,60 @@ void CBasePlayer::ResetMenu()
MESSAGE_END();
}

#ifdef REGAMEDLL_ADD
// Find the planted C4 in the world, if any
static CGrenade *FindPlantedBomb()
{
CGrenade *pBomb = nullptr;
while ((pBomb = UTIL_FindEntityByClassname(pBomb, "grenade")))
{
// skip the ones marked for removal (just defused)
if (pBomb->m_bIsC4 && !(pBomb->pev->flags & FL_KILLME))
return pBomb;
}

return nullptr;
}

// Resync the HUD round timer for all players
// (used when the timer switches between the round time and the C4 countdown)
void SyncRoundTimerForAll()
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (UTIL_IsValidPlayer(pPlayer))
pPlayer->SyncRoundTimer();
}
}
#endif

void CBasePlayer::SyncRoundTimer()
{
float tmRemaining = 0;
BOOL bFreezePeriod = g_pGameRules->IsFreezePeriod();

#ifdef REGAMEDLL_ADD
bool bBombTimer = false;
#endif

if (g_pGameRules->IsMultiplayer())
{
tmRemaining = CSGameRules()->GetRoundRemainingTimeReal();

#ifdef REGAMEDLL_ADD
// show the time until the planted bomb explodes instead of the round timer
if (show_bomb_timer.value != 0.0f && !bFreezePeriod)
{
CGrenade *pBomb = FindPlantedBomb();
if (pBomb && pBomb->m_flC4Blow > gpGlobals->time)
{
tmRemaining = pBomb->m_flC4Blow - gpGlobals->time;
bBombTimer = true;
}
}
#endif

#ifdef REGAMEDLL_FIXES
// hide timer HUD because it is useless.
if (tmRemaining <= 0.0f && CSGameRules()->m_iRoundTime <= 0) {
Expand All @@ -3631,6 +3677,15 @@ void CBasePlayer::SyncRoundTimer()
if (tmRemaining < 0)
tmRemaining = 0;

#ifdef REGAMEDLL_ADD
// the client hides the HUD timer once the bomb is planted, re-show it
if (bBombTimer)
{
MESSAGE_BEGIN(MSG_ONE, gmsgShowTimer, nullptr, pev);
MESSAGE_END();
}
#endif

MESSAGE_BEGIN(MSG_ONE, gmsgRoundTime, nullptr, pev);
WRITE_SHORT(int(tmRemaining));
MESSAGE_END();
Expand Down Expand Up @@ -9851,14 +9906,18 @@ void CBasePlayer::PrioritizeAutoBuyString(char (&autobuyString)[MAX_AUTOBUY_LENG
int i = 0;

// get the next token from the priority string.
while (*priorityChar != '\0' && *priorityChar != ' ')
while (*priorityChar != '\0' && *priorityChar != ' ' && i < (int)sizeof(priorityToken) - 1)
{
priorityToken[i++] = *priorityChar;
priorityChar++;
}

priorityToken[i] = '\0';

// skip the rest of an oversized token that did not fit
while (*priorityChar != '\0' && *priorityChar != ' ')
priorityChar++;

// skip spaces
while (*priorityChar == ' ')
priorityChar++;
Expand Down Expand Up @@ -10731,7 +10790,8 @@ bool EXT_FUNC CBasePlayer::__API_HOOK(GetIntoGame)()
void CBasePlayer::PlayerRespawnThink()
{
#ifdef REGAMEDLL_ADD
if (GetObserverMode() != OBS_NONE && (m_iTeam == UNASSIGNED || m_iTeam == SPECTATOR))
// Players without a team can never respawn (e.g. stuck at team menu when both teams are full)
if (m_iTeam == UNASSIGNED || m_iTeam == SPECTATOR)
return;

// Player cannot respawn while in the Choose Appearance menu
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1060,3 +1060,7 @@ bool IsSecondaryWeaponClass(int classId);
bool IsSecondaryWeaponId(int id);
const char *GetWeaponAliasFromName(const char *weaponName);
bool CurrentWeaponSatisfies(CBasePlayerWeapon *pWeapon, int id, int classId);

#ifdef REGAMEDLL_ADD
void SyncRoundTimerForAll();
#endif
3 changes: 2 additions & 1 deletion regamedll/dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ void CBasePlayerItem::DefaultTouch(CBaseEntity *pOther)
&& m_iId != WEAPON_DEAGLE
&& m_iId != WEAPON_KNIFE
#else
!IsSecondaryWeapon(m_iId)
m_iId != WEAPON_KNIFE
&& !IsSecondaryWeapon(m_iId)
#endif

)
Expand Down
7 changes: 7 additions & 0 deletions regamedll/dlls/wpn_shared/wpn_c4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ void CC4::PrimaryAttack()
WRITE_BYTE(BOMB_FLAG_PLANTED);
MESSAGE_END();

#ifdef REGAMEDLL_ADD
// show the C4 countdown on the HUD round timer;
// must be sent after gmsgBombDrop, the client hides the timer on it
if (show_bomb_timer.value != 0.0f)
SyncRoundTimerForAll();
#endif

UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Bomb_Planted");
if (TheBots)
{
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/wpn_shared/wpn_famas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void CFamas::FamasFire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL

void CFamas::Reload()
{
#ifndef REGAMEDLL_FXES
#ifndef REGAMEDLL_FIXES
if (m_pPlayer->ammo_556nato <= 0)
return;
#endif
Expand Down
12 changes: 12 additions & 0 deletions regamedll/dlls/wpn_shared/wpn_knife.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,12 @@ BOOL CKnife::Swing(BOOL fFirst)
{
// also play knife strike
EMIT_SOUND_DYN(m_pPlayer->edict(), CHAN_ITEM, "weapons/knife_hitwall1.wav", VOL_NORM, ATTN_NORM, 0, RANDOM_LONG(0, 3) + 98);

#ifdef REGAMEDLL_ADD
// spark effect at the point of impact
if (knife_wall_sparks.value)
UTIL_Sparks(tr.vecEndPos);
#endif
}
}

Expand Down Expand Up @@ -633,6 +639,12 @@ BOOL CKnife::Stab(BOOL fFirst)
{
// also play knife strike
EMIT_SOUND_DYN(m_pPlayer->edict(), CHAN_ITEM, "weapons/knife_hitwall1.wav", VOL_NORM, ATTN_NORM, 0, RANDOM_LONG(0, 3) + 98);

#ifdef REGAMEDLL_ADD
// spark effect at the point of impact
if (knife_wall_sparks.value)
UTIL_Sparks(tr.vecEndPos);
#endif
}
}

Expand Down
Loading
Loading