From 7caa82b054a834a8a781088274e6a1388ffb8cb8 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Tue, 14 Jun 2016 22:00:27 +0700 Subject: [PATCH] Removed the dependency of the mode FFA from the cvar mp_friendlyfire 2 Added cvar mp_freeforall for FFA Reworked cvar bot_deathmatch --- README.md | 4 ++-- dist/game.cfg | 8 +++----- regamedll/dlls/bot/cs_bot_weapon.cpp | 3 +++ regamedll/dlls/game.cpp | 2 ++ regamedll/dlls/game.h | 1 + regamedll/dlls/gamerules.h | 9 ++++----- regamedll/dlls/multiplay_gamerules.cpp | 2 +- regamedll/dlls/player.cpp | 6 +++--- regamedll/dlls/util.cpp | 6 ++++++ regamedll/game_shared/bot/bot.h | 4 +++- 10 files changed, 28 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 6c429e34..7b8f57c1 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure' ## Configuration (cvars) | CVar | Default | Min | Max | Description | | :---------------------------- | :-----: | :-: | :----------: | :--------------------------------------------- | -| mp_friendlyfire | 0 | 0 | 2 | Allow inflict damage to teammates
`0` disabled
`1` enabled
`2` FFA mode | +| mp_freeforall | 0 | 0 | 1 | The style of gameplay where there aren't any teams (FFA mode)
`0` disabled
`1` enabled | | mp_maxmoney | 16000 | 0 | `0x7FFFFFFF` | The maximum allowable amount of money in the game | mp_round_infinite | 0 | 0 | 1 | Flags for fine grained control (choose as many as needed)
`0` disabled
`1` enabled

or flags
`a` block round time round end check
`b` block needed players round end check
`c` block VIP assassination/success round end check
`d` block prison escape round end check
`e` block bomb round end check
`f` block team extermination round end check
`g` block hostage rescue round end check

`Example setting:` "ae" blocks round time and bomb round end checks | | mp_hegrenade_penetration | 0 | 0 | 1 | Disable grenade damage through walls
`0` disabled
`1` enabled | @@ -29,7 +29,7 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure' | mp_roundrespawn_time | 20 | 0 | - | Player cannot respawn until next round if more than N seconds has elapsed since the beginning round | | mp_auto_reload_weapons | 0 | 0 | 1 | Automatically reload each weapon on player spawn
`0` disabled
`1` enabled | | mp_refill_bpammo_weapons | 0 | 0 | 2 | Refill amount of backpack ammo up to the max
`0` disabled
`1` refill backpack ammo on player spawn
`2` refill backpack ammo on each weapon reload | -| bot_deathmatch | 0 | 0 | 2 | Set's the mode for the zBot
`0` disabled
`1` enable mode Deathmatch and not allow to do the scenario
`2` enable Deathmatch and FFA mode | +| bot_deathmatch | 0 | 0 | 1 | Set's the mode for the zBot
`0` disabled
`1` enable mode Deathmatch and not allow to do the scenario | ## How to install zBot for CS 1.6? * Extract all the files from an [archive](regamedll/extra/zBot/bot_profiles.zip?raw=true) diff --git a/dist/game.cfg b/dist/game.cfg index 4e55ce7c..418e9921 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -1,13 +1,12 @@ // ReGameDLL Configuration File echo Executing ReGameDLL Configuration File -// Allow inflict damage to teammates -// 0 - disabled +// The style of gameplay where there aren't any teams (FFA mode) +// 0 - disabled (default behaviour) // 1 - enabled -// 2 - FFA mode // // Default value: "0" -mp_friendlyfire 0 +mp_freeforall 0 // The maximum allowable amount of money in the game // @@ -68,7 +67,6 @@ mp_refill_bpammo_weapons 0 // Set's the mode for the zBot // 0 - disabled // 1 - enable mode Deathmatch and not allow to do the scenario -// 2 - enable Deathmatch and FFA mode (Free for all) // // Default value: "0" bot_deathmatch 0 diff --git a/regamedll/dlls/bot/cs_bot_weapon.cpp b/regamedll/dlls/bot/cs_bot_weapon.cpp index 0614f563..c5820339 100644 --- a/regamedll/dlls/bot/cs_bot_weapon.cpp +++ b/regamedll/dlls/bot/cs_bot_weapon.cpp @@ -840,6 +840,9 @@ void CCSBot::__MAKE_VHOOK(OnTouchingWeapon)(CWeaponBox *box) // TODO: Check more rays for safety. bool CCSBot::IsFriendInLineOfFire() { + if (CSGameRules()->IsFreeForAll()) + return false; + UTIL_MakeVectors(pev->punchangle + pev->v_angle); // compute the unit vector along our view diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 11bbb382..1791c495 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -103,6 +103,7 @@ cvar_t nadedrops = { "mp_nadedrops", "0", 0, 0.0f, nullptr }; cvar_t roundrespawn_time = { "mp_roundrespawn_time", "20", 0, 20.0f, nullptr }; cvar_t auto_reload_weapons = { "mp_auto_reload_weapons", "0", 0, 0.0f, nullptr }; cvar_t refill_bpammo_weapons = { "mp_refill_bpammo_weapons", "0", 0, 0.0f, nullptr }; // Useful for mods like DeathMatch, GunGame, ZombieMod etc +cvar_t freeforall = { "mp_freeforall", "0", FCVAR_SERVER, 0.0f, nullptr }; void GameDLL_Version_f() { @@ -232,6 +233,7 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&roundrespawn_time); CVAR_REGISTER(&auto_reload_weapons); CVAR_REGISTER(&refill_bpammo_weapons); + CVAR_REGISTER(&freeforall); // print version CONSOLE_ECHO("ReGameDLL build: " __TIME__ " " __DATE__ " (" APP_VERSION_STRD ")\n"); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index b0620660..3635be14 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -140,6 +140,7 @@ extern cvar_t nadedrops; extern cvar_t roundrespawn_time; extern cvar_t auto_reload_weapons; extern cvar_t refill_bpammo_weapons; +extern cvar_t freeforall; #endif diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index 4aeda18e..62d1434b 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -637,8 +637,8 @@ public: void TerminateRound(float tmDelay, int iWinStatus); float GetRoundRespawnTime() const; - // allow the mode of fire on a friendly player (FFA) - bool IsFriendlyFireAttack() const; + // has a style of gameplay when aren't any teams + bool IsFreeForAll() const; bool HasRoundInfinite(bool time_expired = false) const; private: @@ -813,11 +813,10 @@ inline float CHalfLifeMultiplay::GetRoundRespawnTime() const #endif } -// allow the mode of fire on a friendly player (FFA) -inline bool CHalfLifeMultiplay::IsFriendlyFireAttack() const +inline bool CHalfLifeMultiplay::IsFreeForAll() const { #ifdef REGAMEDLL_ADD - if (friendlyfire.string[0] == '2') + if (freeforall.value != 0.0f) return true; #endif return false; diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 8e243196..9bacc594 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -3680,7 +3680,7 @@ void CHalfLifeMultiplay::__API_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars { // if a player dies in a deathmatch game and the killer is a client, award the killer some points CBasePlayer *killer = GetClassPtr((CBasePlayer *)pKiller); - bool killedByFFA = CSGameRules()->IsFriendlyFireAttack(); + bool killedByFFA = CSGameRules()->IsFreeForAll(); if (killer->m_iTeam == pVictim->m_iTeam && !killedByFFA) { diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 32c02bf4..7293aae2 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -1016,7 +1016,7 @@ int CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pev if (CVAR_GET_FLOAT("mp_friendlyfire")) { - if (!CSGameRules()->IsFriendlyFireAttack() && pGrenade->m_iTeam == m_iTeam) + if (!CSGameRules()->IsFreeForAll() && pGrenade->m_iTeam == m_iTeam) bTeamAttack = TRUE; pAttack = CBasePlayer::Instance(pevAttacker); @@ -1174,7 +1174,7 @@ int CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pev { pAttack = GetClassPtr((CBasePlayer *)pevAttacker); - bool bAttackFFA = CSGameRules()->IsFriendlyFireAttack(); + bool bAttackFFA = CSGameRules()->IsFreeForAll(); // warn about team attacks if (pAttack != this && pAttack->m_iTeam == m_iTeam && !bAttackFFA) @@ -6928,7 +6928,7 @@ void EXT_ALIGN CBasePlayer::__API_VHOOK(UpdateClientData)() m_tmNextRadarUpdate = gpGlobals->time + 1.0f; #ifdef REGAMEDLL_ADD - if (CSGameRules()->IsFriendlyFireAttack()) + if (CSGameRules()->IsFreeForAll()) vecOrigin = g_vecZero; #endif diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp index 13caeac0..c23e7074 100644 --- a/regamedll/dlls/util.cpp +++ b/regamedll/dlls/util.cpp @@ -2354,6 +2354,12 @@ bool UTIL_AreBotsAllowed() } #ifdef REGAMEDLL_ADD + // let enables zBot by default from listen server? + if (!IS_DEDICATED_SERVER()) + { + return true; + } + // allow the using of bots for CS 1.6 int bots = ENG_CHECK_PARM("-bots", NULL); if (bots) diff --git a/regamedll/game_shared/bot/bot.h b/regamedll/game_shared/bot/bot.h index 44f488de..4b66490c 100644 --- a/regamedll/game_shared/bot/bot.h +++ b/regamedll/game_shared/bot/bot.h @@ -32,6 +32,8 @@ #pragma once #endif +#include "gamerules.h" + class BotProfile; template @@ -422,7 +424,7 @@ inline bool CBot::__MAKE_VHOOK(IsPlayerLookingAtMe)(CBasePlayer *other) const inline CBot::BotRelationshipTeam CBot::BotRelationship(CBasePlayer *pTarget) const { #ifdef REGAMEDLL_ADD - if (cv_bot_deathmatch.value > 1.0f) + if (CSGameRules()->IsFreeForAll()) return BOT_ENEMY; #endif