Add CVar: mp_afk_bomb_drop_time. (#369)

* Add CVar: mp_afk_bomb_drop_time.
 Player that have never moved sience they last move will drop the bomb after this amount of time. (in seconds)
This commit is contained in:
Shorohov Sergey 2019-06-07 21:07:12 +03:00 committed by Dmitry Novikov
parent 935064c31e
commit 823eb10f2f
7 changed files with 43 additions and 0 deletions

View File

@ -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 | 1 | 0 | `999999` | Player that have never moved sience they last move will drop the bomb after this amount of time. (in seconds).<br/>`0` disabled<br/>`>0.00001` 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)

9
dist/game.cfg vendored
View File

@ -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
// >0.00001 - delay to drop
//
// Default value: "0"
mp_afk_bomb_drop_time "0"

View File

@ -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);
}

View File

@ -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 };
@ -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);

View File

@ -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;

View File

@ -4231,6 +4231,13 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)()
// check every 5 seconds
m_flIdleCheckTime = gpGlobals->time + 5.0;
#ifdef REGAMEDLL_ADD
if (CSPlayer()->CheckActivityInGame())
{
m_fLastMovement = gpGlobals->time;
}
#endif
real_t flLastMove = gpGlobals->time - m_fLastMovement;
//check if this player has been inactive for 2 rounds straight
@ -4246,6 +4253,15 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)()
m_fLastMovement = gpGlobals->time;
}
}
#ifdef REGAMEDLL_ADD
if (afk_bomb_drop_time.value > 0.0 && IsBombGuy())
{
if (flLastMove > afk_bomb_drop_time.value && !CSGameRules()->IsFreezePeriod())
{
DropPlayerItem("weapon_c4");
}
}
#endif
}
if (g_pGameRules && g_pGameRules->FAllowFlashlight())

View File

@ -95,12 +95,14 @@ public:
};
EProtectionState GetProtectionState() const;
bool CheckActivityInGame();
public:
char m_szModel[32];
bool m_bForceShowMenu;
float m_flRespawnPending;
float m_flSpawnProtectionEndTime;
Vector m_vecOldvAngle;
};
// Inlines