Skip to content

Commit

Permalink
Merge pull request #2 from s1lentq/master
Browse files Browse the repository at this point in the history
up
  • Loading branch information
wopox1337 committed Jun 9, 2019
2 parents c8a6a4a + cee63d9 commit a5283cf
Show file tree
Hide file tree
Showing 16 changed files with 214 additions and 76 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure'
| ff_damage_reduction_grenade | 0.25 | 0.0 | 1.0 | How much to reduce damage done to teammates by a thrown grenade.<br/> Range is from `0` - `1` (with 1 being damage equal to what is done to an enemy) |
| ff_damage_reduction_grenade_self | 1.0 | 0.0 | 1.0 | How much to damage a player does to himself with his own grenade.<br/> Range is from `0` - `1` (with 1 being damage equal to what is done to an enemy) |
| ff_damage_reduction_other | 0.35 | 0.0 | 1.0 | How much to reduce damage done to teammates by things other than bullets and grenades.<br/> Range is from `0` - `1` (with 1 being damage equal to what is done to an enemy) |
| mp_afk_bomb_drop_time | 0 | 5.0 | - | Player that have never moved sience they last move will drop the bomb after this amount of time. (in seconds).<br/>`0` disabled<br/>`>5.0` delay to drop |

## How to install zBot for CS 1.6?
* Extract all the files from an [archive](regamedll/extra/zBot/bot_profiles.zip?raw=true)
Expand Down
7 changes: 7 additions & 0 deletions dep/cppunitlite/msvc/cppunitlite.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,34 @@
<ProjectGuid>{CEB94F7C-E459-4673-AABB-36E2074396C0}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>cppunitlite</RootNamespace>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Nav|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
9 changes: 9 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,12 @@ ff_damage_reduction_grenade_self "1.0"
//
// Default value: "0.35"
ff_damage_reduction_other "0.35"
// Player that have never moved sience they last move
// will drop the bomb after this amount of time. (in seconds).
// 0 - disabled
// >5.0 - delay to drop
//
// Default value: "0"
mp_afk_bomb_drop_time "0"
12 changes: 12 additions & 0 deletions regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,15 @@ EXT_FUNC bool CCSPlayer::HintMessageEx(const char *pMessage, float duration, boo
{
return BasePlayer()->HintMessageEx(pMessage, duration, bDisplayIfPlayerDead, bOverride);
}

EXT_FUNC bool CCSPlayer::CheckActivityInGame()
{
const CBasePlayer* pPlayer = BasePlayer();

const float deltaYaw = (m_vecOldvAngle.y - pPlayer->pev->v_angle.y);
const float deltaPitch = (m_vecOldvAngle.x - pPlayer->pev->v_angle.x);

m_vecOldvAngle = pPlayer->pev->v_angle;

return (fabs(deltaYaw) >= 0.1f && fabs(deltaPitch) >= 0.1f);
}
83 changes: 70 additions & 13 deletions regamedll/dlls/addons/point_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@
void CPointBaseCommand::KeyValue(KeyValueData *pkvd)
{
// add this field to the command list
if (m_uiCommandsCount < MAX_POINT_CMDS)
if (m_vecCommands.Count() < MAX_POINT_CMDS)
{
char command[128];
if (pkvd->szValue[0] != '\0' && Q_strcmp(pkvd->szValue, "-") != 0)
if (pkvd->szValue[0] != '\0' &&
Q_strcmp(pkvd->szValue, "-") != 0)
{
Q_snprintf(command, sizeof(command), "%s \"%s\"", pkvd->szKeyName, pkvd->szValue);
m_vecCommands.AddToTail({ pkvd->szKeyName, pkvd->szValue });
}
else
{
Q_strlcpy(command, pkvd->szKeyName);
m_vecCommands.AddToTail(pkvd->szKeyName);
}

m_iszCommands[m_uiCommandsCount++] = ALLOC_STRING(command);
pkvd->fHandled = TRUE;
return;
}
Expand Down Expand Up @@ -61,12 +60,24 @@ void CPointClientCommand::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE

if (pClient)
{
for (size_t cmd = 0; cmd < m_uiCommandsCount; cmd++) {
CLIENT_COMMAND(pClient, UTIL_VarArgs("%s\n", m_iszCommands[cmd].str()));
for (auto &cmd : m_vecCommands) {
Execute(pClient, "%s \"%s\"\n", cmd.name, cmd.value);
}
}
}

void CPointClientCommand::Execute(edict_t *pEdict, const char *pszFmt, ...)
{
va_list argptr;
char command[128];

va_start(argptr, pszFmt);
Q_vsnprintf(command, sizeof(command), pszFmt, argptr);
va_end(argptr);

CLIENT_COMMAND(pEdict, command);
}

LINK_ENTITY_TO_CLASS(point_servercommand, CPointServerCommand, CCSPointServerCommand)

void CPointServerCommand::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
Expand All @@ -78,20 +89,66 @@ void CPointServerCommand::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE
}
#endif

for (size_t cmd = 0; cmd < m_uiCommandsCount; cmd++) {
Execute(m_iszCommands[cmd]);
for (auto &cmd : m_vecCommands)
{
cvar_t *pCVar = CVAR_GET_POINTER(cmd.name);
if (pCVar &&
pCVar->string &&
pCVar->string[0] != '\0' &&
Q_stricmp(cmd.value, pCVar->string) != 0) {
Q_strlcpy(cmd.valueInitial, pCVar->string);
}

if (cmd.value[0] != '\0')
{
Execute(nullptr, "%s \"%s\"\n", cmd.name, cmd.value);
}
else
{
Execute(nullptr, "%s\n", cmd.name);
}
}
}

void CPointServerCommand::Execute(const char *command)
void CPointServerCommand::Execute(edict_t *pEdict, const char *pszFmt, ...)
{
va_list argptr;
char command[128];

va_start(argptr, pszFmt);
Q_vsnprintf(command, sizeof(command), pszFmt, argptr);
va_end(argptr);

if (!IS_DEDICATED_SERVER())
{
// potentially dangerous for untrusted maps
// so try to use it for passing through filtered svc_stufftext
CLIENT_COMMAND(INDEXENT(1), UTIL_VarArgs("%s\n", command));
CLIENT_COMMAND(pEdict ? pEdict : INDEXENT(1), command);
return;
}

SERVER_COMMAND(UTIL_VarArgs("%s\n", command));
SERVER_COMMAND(command);
}

void CPointBaseCommand::OnDestroy()
{
if (!(pev->spawnflags & SF_POINT_CMD_NORESET))
{
bool bAtLeastOneCmdReset = false;
for (auto &cmd : m_vecCommands)
{
if (cmd.valueInitial[0] != '\0')
{
Execute(nullptr, "%s \"%s\"\n", cmd.name, cmd.valueInitial);
bAtLeastOneCmdReset = true;
}
}

if (bAtLeastOneCmdReset)
{
SERVER_EXECUTE();
}
}

m_vecCommands.RemoveAll();
}
33 changes: 29 additions & 4 deletions regamedll/dlls/addons/point_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,41 @@

#pragma once

#include <utlvector.h>

const int MAX_POINT_CMDS = 16; // maximum number of commands a single point_[server/client]command entity may be assigned

#define SF_POINT_CMD_NORESET BIT(0) // it is not allowed to be resetting to initial value on remove an entity or change level

class CPointBaseCommand: public CPointEntity {
public:
virtual void OnDestroy();
virtual void KeyValue(KeyValueData *pkvd);
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0;
virtual void Execute(edict_t *pEdict, const char *pszFmt, ...) = 0;

protected:
size_t m_uiCommandsCount;
string_t m_iszCommands[MAX_POINT_CMDS];

template <size_t SIZE>
struct command_t
{
command_t(const char *_name, const char *_value = nullptr)
{
value[0] = '\0';
valueInitial[0] = '\0';

Q_strlcpy(name, _name);

if (_value)
{
Q_strlcpy(value, _value);
}
}

char name[SIZE], value[SIZE], valueInitial[SIZE];
};

CUtlVector<command_t<64u>> m_vecCommands;
};

// It issues commands to the client console
Expand All @@ -36,7 +61,7 @@ class CPointClientCommand: public CPointBaseCommand {
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);

private:
void Execute(edict_t *pEdict, const char *command);
void Execute(edict_t *pEdict, const char *pszFmt, ...);
};

// It issues commands to the server console
Expand All @@ -45,5 +70,5 @@ class CPointServerCommand: public CPointBaseCommand {
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);

private:
void Execute(const char *command);
void Execute(edict_t *pEdict, const char *pszFmt, ...);
};
2 changes: 1 addition & 1 deletion regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3298,7 +3298,7 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa
else if (FStrEq(pcmd, "fov"))
{
#if 0
if (g_flWeaponCheat && CMD_ARGC() > 1)
if (CVAR_GET_FLOAT("sv_cheats") != 0.0f && CMD_ARGC() > 1)
GetClassPtr<CCSPlayer>((CBasePlayer *)pev)->m_iFOV = Q_atoi(CMD_ARGV(1));
else
CLIENT_PRINTF(pEntity, print_console, UTIL_VarArgs("\"fov\" is \"%d\"\n", int(GetClassPtr<CCSPlayer>((CBasePlayer *)pev)->m_iFOV)));
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ cvar_t item_staytime = { "mp_item_staytime", "300", FCVAR_SERVER, 300.
cvar_t legacy_bombtarget_touch = { "mp_legacy_bombtarget_touch", "1", 0, 1.0f, nullptr };
cvar_t respawn_immunitytime = { "mp_respawn_immunitytime", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t kill_filled_spawn = { "mp_kill_filled_spawn", "1", 0, 0.0f, nullptr };
cvar_t afk_bomb_drop_time = { "mp_afk_bomb_drop_time", "0", FCVAR_SERVER, 0.0f, nullptr };

cvar_t allow_point_servercommand = { "mp_allow_point_servercommand", "0", 0, 0.0f, nullptr };
cvar_t hullbounds_sets = { "mp_hullbounds_sets", "1", 0, 0.0f, nullptr };
Expand Down Expand Up @@ -304,6 +305,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&legacy_bombtarget_touch);
CVAR_REGISTER(&respawn_immunitytime);
CVAR_REGISTER(&kill_filled_spawn);
CVAR_REGISTER(&afk_bomb_drop_time);
CVAR_REGISTER(&allow_point_servercommand);
CVAR_REGISTER(&hullbounds_sets);

Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ extern cvar_t item_staytime;
extern cvar_t legacy_bombtarget_touch;
extern cvar_t respawn_immunitytime;
extern cvar_t kill_filled_spawn;
extern cvar_t afk_bomb_drop_time;
extern cvar_t allow_point_servercommand;
extern cvar_t hullbounds_sets;
extern cvar_t ff_damage_reduction_bullets;
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3243,7 +3243,7 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl)

UpdateGameMode(pl);

if (!g_flWeaponCheat)
if (!CVAR_GET_FLOAT("sv_cheats"))
{
MESSAGE_BEGIN(MSG_ONE, gmsgViewMode, nullptr, pl->edict());
MESSAGE_END();
Expand Down
Loading

0 comments on commit a5283cf

Please sign in to comment.