Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit d48fd3e
Merge: 5268e6b 5d2174f
Author: Alejo <alejoperezherrero@gmail.com>
Date:   Wed Feb 14 19:17:25 2024 -0300

    Merge remote-tracking branch 'upstream/master'

commit 5d2174f
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Mon Feb 5 02:21:49 2024 +0700

    CWeaponBox::Touch: Reworked dropped grenade pickup

commit 4d90a5f
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Thu Feb 1 18:20:11 2024 +0700

    CWeaponBox::Touch: Fix grenade pickup (Resolves s1lentq#923, Closes s1lentq#931)

commit f4c4e89
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Thu Feb 1 16:38:16 2024 +0700

    CBasePlayerWeapon::ExtractAmmo: Fixed reverse-engineering mistake

commit 2489213
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Thu Feb 1 12:21:23 2024 +0700

    Resetable g_weaponSlotInfo

commit fb9eb0d
Author: Francisco Muñoz <fjmunozpena@gmail.com>
Date:   Wed Jan 31 09:38:35 2024 -0300

    Fix excessive punchangle when getting shield shot (s1lentq#919)

commit 0bc4ff1
Author: Rafflesian <56321479+Rafflesian@users.noreply.github.com>
Date:   Wed Jan 31 09:35:26 2024 -0300

    Support for secondary ammo and extra EF_ flags (s1lentq#934)

    Support for secondary ammo and extra EF_ flags

commit 5287f2a
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Wed Jan 31 19:16:37 2024 +0700

    Do not reduce points for bot suicide due bot_kill command

commit 0bbc4bd
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Wed Jan 31 18:38:47 2024 +0700

    Do not reduce points for suicide due to a fatal fall

commit aec3ba2
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Wed Jan 31 18:33:34 2024 +0700

    Fixed m_looseBombArea assertion

commit b34d564
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Wed Jan 31 17:52:38 2024 +0700

    PM_CheckWater: Fix for uninitialized waterlevel value for dead players (incorrect waterlevel values from another player movements persisting)

commit a1af7ca
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Wed Jan 31 17:40:47 2024 +0700

    CBasePlayer::WaterMove: No water sound playback occurs when clients emerge from network lag or was using noclip

commit bde6aa0
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Wed Jan 31 15:51:44 2024 +0700

    Disable door asserts (Resolves s1lentq#926)

commit 2d957a7
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Wed Jan 31 15:10:08 2024 +0700

    utlvector.h fix assert

commit 4b49f63
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Fri Jan 19 20:33:01 2024 +0700

    Fix mismatched damage glock18 in burst mode 18 against 25 (GLOCK18_DAMAGE)

commit 051dc07
Author: Sergey Shorokhov <wopox1337@ya.ru>
Date:   Fri Jan 12 11:55:00 2024 +0300

    New ConVar: `mp_defuser_allocation` (s1lentq#908)

commit 89dda43
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Fri Jan 12 13:30:01 2024 +0700

    fix test demo

commit 02a0516
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Fri Jan 12 13:19:01 2024 +0700

    Reset damage stats on Putin Server

commit c0f4794
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Fri Jan 12 09:27:40 2024 +0700

    PM_CategorizePosition: Do not stick to the ground of an OBSERVER or NOCLIP mode

commit e636cbc
Author: s1lentq <s1lentsk@yandex.ru>
Date:   Fri Jan 12 09:16:20 2024 +0700

    PlayerRelationship: GR_TEAMMATE on checking itself

commit 5268e6b
Merge: 9f54246 15df1a9
Author: Alejo <53284952+aleeperezz16@users.noreply.github.com>
Date:   Tue Jan 2 12:55:47 2024 -0300

    Merge branch 's1lentq:master' into master
  • Loading branch information
aleeperezz16 committed Feb 14, 2024
1 parent f677567 commit 4cc9a09
Show file tree
Hide file tree
Showing 24 changed files with 461 additions and 93 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| 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 |
| mp_defuser_allocation | 0 | 0 | 2 | Give defuser on player spawn.<br/> `0` disabled<br/>`1` Random players. <br/>`2` All players. |
</details>

## How to install zBot for CS 1.6?
Expand Down
8 changes: 8 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,11 @@ mp_freezetime_duck "1"
//
// Default value: "1"
mp_freezetime_jump "1"

// Give defuser on player spawn
// 0 - No free defusers (default behavior)
// 1 - Random players
// 2 - All players
//
// Default value: "0"
mp_defuser_allocation "0"
5 changes: 5 additions & 0 deletions regamedll/common/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@
#define EF_FORCEVISIBILITY BIT(11) // force visibility
#define EF_OWNER_VISIBILITY BIT(12) // visibility for owner
#define EF_OWNER_NO_VISIBILITY BIT(13) // no visibility for owner
#define EF_NOSLERP BIT(14) // no slerp flag for this entity (addtofullpack)
#define EF_FOLLOWKEEPRENDER BIT(15) // the entity following will not copy the render (like it follows nothing)

// Custom flags that aren't handled by the client
#define EF_CUSTOM_BITS (EF_FORCEVISIBILITY | EF_OWNER_VISIBILITY | EF_OWNER_NO_VISIBILITY | EF_NOSLERP | EF_FOLLOWKEEPRENDER)

// state->eflags values
#define EFLAG_SLERP 1 // do studio interpolation of this entity
Expand Down
3 changes: 3 additions & 0 deletions regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ void CCSPlayer::ResetAllStats()
m_iNumKilledByUnanswered[i] = 0;
m_bPlayerDominated[i] = false;
}

m_DamageList.Clear();
}

void CCSPlayer::OnSpawn()
Expand Down Expand Up @@ -586,6 +588,7 @@ void CCSPlayer::OnKilled()
void CCSPlayer::OnConnect()
{
ResetVars();
ResetAllStats();
m_iUserID = GETPLAYERUSERID(BasePlayer()->edict());
}

Expand Down
14 changes: 14 additions & 0 deletions regamedll/dlls/bot/cs_bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,20 @@ bool CCSBot::StayOnNavMesh()
return false;
}

#ifdef REGAMEDLL_FIXES
void CCSBot::Kill()
{
m_LastHitGroup = HITGROUP_GENERIC;

// have the player kill himself
pev->health = 0.0f;
Killed(VARS(eoNullEntity), GIB_NEVER);

if (CSGameRules()->m_pVIP == this)
CSGameRules()->m_iConsecutiveVIP = 10;
}
#endif

void CCSBot::Panic(CBasePlayer *pEnemy)
{
if (IsSurprised())
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/bot/cs_bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ class CCSBot: public CBot

bool IsBuying() const;

#ifdef REGAMEDLL_FIXES
void Kill();
#endif

void Panic(CBasePlayer *pEnemy); // look around in panic
void Follow(CBasePlayer *pPlayer); // begin following given Player
void ContinueFollowing(); // continue following our leader after finishing what we were doing
Expand Down
7 changes: 3 additions & 4 deletions regamedll/dlls/bot/cs_bot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,9 @@ void CCSBotManager::ServerCommand(const char *pcmd)

if (pPlayer->IsBot())
{
CCSBot *pBot = static_cast<CCSBot *>(pPlayer);
if (killThemAll || FStrEq(name, msg))
{
pPlayer->Kill();
}
pBot->Kill();
}
}
}
Expand Down Expand Up @@ -1452,7 +1451,7 @@ void CCSBotManager::SetLooseBomb(CBaseEntity *bomb)
if (bomb)
{
m_looseBombArea = TheNavAreaGrid.GetNearestNavArea(&bomb->pev->origin);
DbgAssert(m_looseBombArea); // TODO: Need investigation and find out why it cannot find nearest area for a lost bomb, just catch it
DbgAssert(!TheNavAreaGrid.IsValid() || m_looseBombArea); // TODO: Need investigation and find out why it cannot find nearest area for a lost bomb, just catch it
}
else
{
Expand Down
7 changes: 7 additions & 0 deletions regamedll/dlls/buttons.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#include "precompiled.h"

#if !defined(DOOR_ASSERT)
#undef DbgAssert
#undef DbgAssertMsg
#define DbgAssert(_exp) ((void)0)
#define DbgAssertMsg(_exp, _msg) ((void)0)
#endif

TYPEDESCRIPTION CEnvGlobal::m_SaveData[] =
{
DEFINE_FIELD(CEnvGlobal, m_globalstate, FIELD_STRING),
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/cbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,11 @@ VectorRef CBaseEntity::__API_HOOK(FireBullets3)(VectorRef vecSrc, VectorRef vecD
pEntity->pev->punchangle.x = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15);
pEntity->pev->punchangle.z = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15);

#ifndef REGAMEDLL_FIXES
if (pEntity->pev->punchangle.x < 4)
#else
if (pEntity->pev->punchangle.x < -4)
#endif
{
pEntity->pev->punchangle.x = -4;
}
Expand Down
28 changes: 24 additions & 4 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void WriteSigonMessages()

#ifdef PLAY_GAMEDLL
// TODO: fix test demo
iFlags &= ~ITEM_FLAG_NOFIREUNDERWATER;
iFlags &= ~ITEM_FLAG_CUSTOM;
#endif

MESSAGE_BEGIN(MSG_INIT, gmsgWeaponList);
Expand Down Expand Up @@ -4494,15 +4494,21 @@ BOOL EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, e

#ifdef REGAMEDLL_ADD
// don't send unhandled custom bits to client
state->effects &= ~(EF_FORCEVISIBILITY | EF_OWNER_VISIBILITY | EF_OWNER_NO_VISIBILITY);
state->effects &= ~EF_CUSTOM_BITS;

if (ent->v.skin == CONTENTS_LADDER &&
(host->v.iuser3 & PLAYER_PREVENT_CLIMB) == PLAYER_PREVENT_CLIMB) {
state->skin = CONTENTS_EMPTY;
}
#endif

if (!player && ent->v.animtime && !ent->v.velocity.x && !ent->v.velocity.y && !ent->v.velocity.z)
// add studio interpolation if non-player entity is moving (why?)
if (!player &&
#ifdef REGAMEDLL_ADD
// adds slerp (studio interpolation) if not set
!(ent->v.effects & EF_NOSLERP) &&
#endif
ent->v.animtime && !ent->v.velocity.x && !ent->v.velocity.y && !ent->v.velocity.z)
state->eflags |= EFLAG_SLERP;

state->scale = ent->v.scale;
Expand All @@ -4528,8 +4534,22 @@ BOOL EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, e

state->aiment = 0;

// following something
if (ent->v.aiment)
state->aiment = ENTINDEX(ent->v.aiment);
{
#ifdef REGAMEDLL_ADD
// if set, it will still follow the player with a bit of "delay", still looks fine (experimental)
if (ent->v.effects & EF_FOLLOWKEEPRENDER)
{
// will keep the current render entity values if it's set
state->movetype = MOVETYPE_NONE;
}
else
#endif
{
state->aiment = ENTINDEX(ent->v.aiment);
}
}

state->owner = 0;
if (ent->v.owner)
Expand Down
10 changes: 7 additions & 3 deletions regamedll/dlls/doors.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#include "precompiled.h"

#if !defined(DOOR_ASSERT)
#undef DbgAssert
#undef DbgAssertMsg
#define DbgAssert(_exp) ((void)0)
#define DbgAssertMsg(_exp, _msg) ((void)0)
#endif

TYPEDESCRIPTION CBaseDoor::m_SaveData[] =
{
DEFINE_FIELD(CBaseDoor, m_bHealthValue, FIELD_CHARACTER),
Expand Down Expand Up @@ -695,10 +702,7 @@ void CBaseDoor::DoorGoDown()
}
}

#ifdef DOOR_ASSERT
DbgAssert(m_toggle_state == TS_AT_TOP);
#endif

m_toggle_state = TS_GOING_DOWN;

SetMoveDone(&CBaseDoor::DoorHitBottom);
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ cvar_t sv_block_vote_commands = { "sv_block_vote_commands", "0", 0, 0
cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr };

cvar_t dying_time = { "mp_dying_time", "3.0", 0, 3.0f, nullptr };
cvar_t defuser_allocation = { "mp_defuser_allocation", "0", 0, 0.0f, nullptr };

void GameDLL_Version_f()
{
Expand Down Expand Up @@ -440,6 +441,7 @@ void EXT_FUNC GameDLLInit()

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

CVAR_REGISTER(&max_alive_name_changes);
CVAR_REGISTER(&legacy_restart_entities);
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ extern cvar_t deathmsg_flags;
extern cvar_t assist_damage_threshold;
extern cvar_t freezetime_duck;
extern cvar_t freezetime_jump;
extern cvar_t defuser_allocation;

extern cvar_t max_alive_name_changes;
extern cvar_t legacy_restart_entities;
Expand Down
9 changes: 9 additions & 0 deletions regamedll/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ enum KillRarity
KILLRARITY_REVENGE = 0x100 // Revenge by the killer
};

enum
{
DEFUSERALLOCATION_NONE = 0,
DEFUSERALLOCATION_RANDOM = 1,
DEFUSERALLOCATION_ALL = 2,
};

class CItem;

class CGameRules
Expand Down Expand Up @@ -738,6 +745,8 @@ class CHalfLifeMultiplay: public CGameRules
int GetRarityOfKill(CBaseEntity *pKiller, CBasePlayer *pVictim, CBasePlayer *pAssister, const char *killerWeaponName, bool bFlashAssist);
CBasePlayer *CheckAssistsToKill(CBaseEntity *pKiller, CBasePlayer *pVictim, bool &bFlashAssist);

void GiveDefuserToRandomPlayer();

private:
void MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int iTeam);

Expand Down
72 changes: 72 additions & 0 deletions regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,11 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)()
GiveC4();
}

#ifdef REGAMEDLL_ADD
if (m_bMapHasBombTarget && (int)defuser_allocation.value == DEFUSERALLOCATION_RANDOM)
GiveDefuserToRandomPlayer();
#endif

if (TheBots)
{
TheBots->OnEvent(EVENT_BUY_TIME_START);
Expand Down Expand Up @@ -3852,6 +3857,10 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(PlayerSpawn)(CBasePlayer *pPlayer)
#ifdef REGAMEDLL_ADD
if (respawn_immunitytime.value > 0)
pPlayer->SetSpawnProtection(respawn_immunitytime.value);

// remove any defusers left over from previous random if there is just one random one
if (m_bMapHasBombTarget && (int)defuser_allocation.value == DEFUSERALLOCATION_RANDOM)
pPlayer->RemoveDefuser();
#endif
}

Expand Down Expand Up @@ -3970,6 +3979,15 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(PlayerKilled)(CBasePlayer *pVictim,
}

FireTargets("game_playerdie", pVictim, pVictim, USE_TOGGLE, 0);

#ifdef REGAMEDLL_FIXES
// Did the player die from a fall?
if (pVictim->m_bitsDamageType & DMG_FALL)
{
// do nothing
}
else
#endif
// Did the player kill himself?
if (pVictim->pev == pKiller)
{
Expand Down Expand Up @@ -4378,6 +4396,9 @@ edict_t *EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GetPlayerSpawnSpot)(CBasePlayer

int CHalfLifeMultiplay::PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pTarget)
{
if (pPlayer == pTarget)
return GR_TEAMMATE;

#ifdef REGAMEDLL_ADD
if (IsFreeForAll())
{
Expand Down Expand Up @@ -5414,3 +5435,54 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(SendDeathMessage)(CBaseEntity *pKil

MESSAGE_END();
}

void CHalfLifeMultiplay::GiveDefuserToRandomPlayer()
{
int iDefusersToGive = 2;
CUtlVector<CBasePlayer *> candidates;
candidates.EnsureCapacity(MAX_CLIENTS);

// add all CT candidates to a list
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer || FNullEnt(pPlayer->edict()))
continue;

if (!pPlayer->IsAlive() || pPlayer->m_iTeam != CT)
continue;

candidates.AddToTail(pPlayer);
}

// randomly shuffle the list; this will keep the selection random in case of ties
for (int i = 0; i < candidates.Count(); i++) {
SWAP(candidates[i], candidates[RANDOM_LONG(0, candidates.Count() - 1)]);
}

// now sort the shuffled list into subgroups
candidates.Sort([](CBasePlayer *const *left, CBasePlayer *const *right) -> int {
// should we prioritize humans over bots?
if (cv_bot_defer_to_human.value != 0.0f)
{
if ((*left)->IsBot() && !(*right)->IsBot())
return 1;

if (!(*left)->IsBot() && (*right)->IsBot())
return -1;
}

return 0;
}
);

// give defusers to the first N candidates
for (int i = 0; i < iDefusersToGive && i < candidates.Count(); ++i)
{
CBasePlayer *pPlayer = candidates[i];
assert(pPlayer && pPlayer->m_iTeam == CT && pPlayer->IsAlive());

pPlayer->GiveDefuser();
ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Got_defuser");
}
}
Loading

0 comments on commit 4cc9a09

Please sign in to comment.