mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-26 22:55:41 +03:00
Spawn protection API and cvar (mp_respawn_immunitytime). (#266)
This commit is contained in:
parent
cbbda5ef21
commit
bc2c3176e4
@ -49,6 +49,7 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure'
|
||||
| bot_quota_mode | normal | - | - | Determines the type of quota.<br/>`normal` default behaviour<br/>`fill` the server will adjust bots to keep `N` players in the game, where `N` is bot_quota |
|
||||
| mp_item_staytime | 300 | - | - | Time to remove item that have been dropped from the players. |
|
||||
| mp_legacy_bombtarget_touch | 1 | 0 | 1 | Legacy func_bomb_target touch. New one is more strict. <br/>`0` New behavior<br/>`1` Legacy behavior|
|
||||
| mp_respawn_immunitytime | 0 | 0 | - | Specifies the players defense time after respawn. (in seconds).<br/>`0` disabled<br/>`>0.00001` time delay to remove protection |
|
||||
|
||||
## How to install zBot for CS 1.6?
|
||||
* Extract all the files from an [archive](regamedll/extra/zBot/bot_profiles.zip?raw=true)
|
||||
|
7
dist/game.cfg
vendored
7
dist/game.cfg
vendored
@ -186,3 +186,10 @@ mp_item_staytime 300
|
||||
//
|
||||
// Default value: "1"
|
||||
mp_legacy_bombtarget_touch "1"
|
||||
|
||||
// Specifies the players defense time after respawn. (in seconds).
|
||||
// 0 - disabled
|
||||
// >0.00001 - time delay to remove protection
|
||||
//
|
||||
// Default value: "0"
|
||||
mp_respawn_immunitytime "0"
|
||||
|
@ -157,6 +157,8 @@ GAMEHOOK_REGISTRY(ThrowHeGrenade);
|
||||
GAMEHOOK_REGISTRY(ThrowFlashbang);
|
||||
GAMEHOOK_REGISTRY(ThrowSmokeGrenade);
|
||||
GAMEHOOK_REGISTRY(PlantBomb);
|
||||
GAMEHOOK_REGISTRY(CBasePlayer_SetSpawnProtection);
|
||||
GAMEHOOK_REGISTRY(CBasePlayer_RemoveSpawnProtection);
|
||||
|
||||
int CReGameApi::GetMajorVersion() {
|
||||
return REGAMEDLL_API_VERSION_MAJOR;
|
||||
|
@ -521,6 +521,14 @@ typedef IHookChainRegistryImpl<CGrenade *, entvars_t *, Vector &, Vector &, floa
|
||||
typedef IHookChainImpl<CGrenade *, entvars_t *, Vector &, Vector &> CReGameHook_PlantBomb;
|
||||
typedef IHookChainRegistryImpl<CGrenade *, entvars_t *, Vector &, Vector &> CReGameHookRegistry_PlantBomb;
|
||||
|
||||
// CBasePlayer::SetSpawnProtection hook
|
||||
typedef IHookChainClassImpl<void, CBasePlayer, float> CReGameHook_CBasePlayer_SetSpawnProtection;
|
||||
typedef IHookChainRegistryClassImpl<void, CBasePlayer, float> CReGameHookRegistry_CBasePlayer_SetSpawnProtection;
|
||||
|
||||
// CBasePlayer::RemoveSpawnProtection hook
|
||||
typedef IHookChainImpl<void, CBasePlayer> CReGameHook_CBasePlayer_RemoveSpawnProtection;
|
||||
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_RemoveSpawnProtection;
|
||||
|
||||
class CReGameHookchains: public IReGameHookchains {
|
||||
public:
|
||||
// CBasePlayer virtual
|
||||
@ -625,6 +633,8 @@ public:
|
||||
CReGameHookRegistry_ThrowFlashbang m_ThrowFlashbang;
|
||||
CReGameHookRegistry_ThrowSmokeGrenade m_ThrowSmokeGrenade;
|
||||
CReGameHookRegistry_PlantBomb m_PlantBomb;
|
||||
CReGameHookRegistry_CBasePlayer_SetSpawnProtection m_CBasePlayer_SetSpawnProtection;
|
||||
CReGameHookRegistry_CBasePlayer_RemoveSpawnProtection m_CBasePlayer_RemoveSpawnProtection;
|
||||
public:
|
||||
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
|
||||
virtual IReGameHookRegistry_CBasePlayer_Precache *CBasePlayer_Precache();
|
||||
@ -727,6 +737,8 @@ public:
|
||||
virtual IReGameHookRegistry_ThrowFlashbang *ThrowFlashbang();
|
||||
virtual IReGameHookRegistry_ThrowSmokeGrenade *ThrowSmokeGrenade();
|
||||
virtual IReGameHookRegistry_PlantBomb *PlantBomb();
|
||||
virtual IReGameHookRegistry_CBasePlayer_SetSpawnProtection *CBasePlayer_SetSpawnProtection();
|
||||
virtual IReGameHookRegistry_CBasePlayer_RemoveSpawnProtection *CBasePlayer_RemoveSpawnProtection();
|
||||
};
|
||||
|
||||
extern CReGameHookchains g_ReGameHookchains;
|
||||
|
@ -489,3 +489,13 @@ EXT_FUNC void CCSPlayer::StartDeathCam()
|
||||
{
|
||||
BasePlayer()->StartDeathCam();
|
||||
}
|
||||
|
||||
EXT_FUNC void CCSPlayer::SetSpawnProtection(float flProtectionTime)
|
||||
{
|
||||
BasePlayer()->SetSpawnProtection(flProtectionTime);
|
||||
}
|
||||
|
||||
EXT_FUNC void CCSPlayer::RemoveSpawnProtection()
|
||||
{
|
||||
BasePlayer()->RemoveSpawnProtection();
|
||||
}
|
||||
|
@ -116,6 +116,7 @@ cvar_t show_radioicon = { "mp_show_radioicon", "1", FCVAR_SERVER, 1.0f,
|
||||
cvar_t old_bomb_defused_sound = { "mp_old_bomb_defused_sound", "1", FCVAR_SERVER, 1.0f, nullptr };
|
||||
cvar_t item_staytime = { "mp_item_staytime", "300", FCVAR_SERVER, 300.0f, nullptr };
|
||||
cvar_t legacy_bombtarget_touch = { "mp_legacy_bombtarget_touch", "1", FCVAR_SERVER, 1.0f, nullptr };
|
||||
cvar_t respawn_immunitytime = { "mp_respawn_immunitytime", "0", FCVAR_SERVER, 0.0f, nullptr };
|
||||
|
||||
void GameDLL_Version_f()
|
||||
{
|
||||
@ -270,6 +271,7 @@ void EXT_FUNC GameDLLInit()
|
||||
CVAR_REGISTER(&old_bomb_defused_sound);
|
||||
CVAR_REGISTER(&item_staytime);
|
||||
CVAR_REGISTER(&legacy_bombtarget_touch);
|
||||
CVAR_REGISTER(&respawn_immunitytime);
|
||||
|
||||
// print version
|
||||
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");
|
||||
|
@ -153,6 +153,7 @@ extern cvar_t show_radioicon;
|
||||
extern cvar_t old_bomb_defused_sound;
|
||||
extern cvar_t item_staytime;
|
||||
extern cvar_t legacy_bombtarget_touch;
|
||||
extern cvar_t respawn_immunitytime;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -3635,6 +3635,11 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(PlayerSpawn)(CBasePlayer *pPlayer)
|
||||
pPlayer->pev->weapons |= (1 << WEAPON_SUIT);
|
||||
pPlayer->OnSpawnEquip();
|
||||
pPlayer->SetPlayerModel(false);
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
if (respawn_immunitytime.value > 0)
|
||||
pPlayer->SetSpawnProtection(respawn_immunitytime.value);
|
||||
#endif
|
||||
}
|
||||
|
||||
LINK_HOOK_CLASS_CUSTOM_CHAIN(BOOL, CHalfLifeMultiplay, CSGameRules, FPlayerCanRespawn, (CBasePlayer *pPlayer), pPlayer)
|
||||
|
@ -4376,6 +4376,13 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)()
|
||||
}
|
||||
|
||||
UpdateLocation();
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
if (CSPlayer()->m_flSpawnProtectionEndTime > 0 && gpGlobals->time > CSPlayer()->m_flSpawnProtectionEndTime)
|
||||
{
|
||||
RemoveSpawnProtection();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// If player is taking time based damage, continue doing damage to player -
|
||||
@ -9516,3 +9523,24 @@ bool CBasePlayer::__API_HOOK(CanSwitchTeam)(TeamName teamToSwap)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, SetSpawnProtection, (float flProtectionTime), flProtectionTime)
|
||||
|
||||
void EXT_FUNC CBasePlayer::__API_HOOK(SetSpawnProtection)(float flProtectionTime)
|
||||
{
|
||||
pev->takedamage = DAMAGE_NO;
|
||||
pev->rendermode = kRenderTransAdd;
|
||||
pev->renderamt = 100.0;
|
||||
|
||||
CSPlayer()->m_flSpawnProtectionEndTime = gpGlobals->time + flProtectionTime;
|
||||
}
|
||||
|
||||
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, RemoveSpawnProtection)
|
||||
|
||||
void CBasePlayer::__API_HOOK(RemoveSpawnProtection)()
|
||||
{
|
||||
pev->takedamage = DAMAGE_AIM;
|
||||
pev->rendermode = kRenderNormal;
|
||||
|
||||
CSPlayer()->m_flSpawnProtectionEndTime = 0.0f;
|
||||
}
|
||||
|
@ -343,7 +343,6 @@ public:
|
||||
virtual BOOL AddPlayerItem(CBasePlayerItem *pItem);
|
||||
virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem);
|
||||
virtual int GiveAmmo(int iAmount, const char *szName, int iMax = -1);
|
||||
|
||||
#ifndef REGAMEDLL_API
|
||||
virtual void StartSneaking() { m_tSneaking = gpGlobals->time - 1; }
|
||||
virtual void StopSneaking() { m_tSneaking = gpGlobals->time + 30; }
|
||||
@ -420,6 +419,8 @@ public:
|
||||
CGrenade *ThrowGrenade_OrigFunc(CBasePlayerWeapon *pWeapon, VectorRef vecSrc, VectorRef vecThrow, float time, unsigned short usEvent = 0);
|
||||
void SwitchTeam_OrigFunc();
|
||||
bool CanSwitchTeam_OrigFunc(TeamName teamToSwap);
|
||||
void SetSpawnProtection_OrigFunc(float flProtectionTime);
|
||||
void RemoveSpawnProtection_OrigFunc();
|
||||
|
||||
CCSPlayer *CSPlayer() const;
|
||||
#endif // REGAMEDLL_API
|
||||
@ -609,6 +610,9 @@ public:
|
||||
CBasePlayerItem *GetItemByName(const char *itemName);
|
||||
CBasePlayerItem *GetItemById(WeaponIdType weaponID);
|
||||
|
||||
void SetSpawnProtection(float flProtectionTime);
|
||||
void RemoveSpawnProtection();
|
||||
|
||||
// templates
|
||||
template<typename T = CBasePlayerItem, typename Functor>
|
||||
T *ForEachItem(int slot, const Functor &func) const
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
class CCSPlayer: public CCSMonster {
|
||||
public:
|
||||
CCSPlayer() : m_bForceShowMenu(false), m_flRespawnPending(0)
|
||||
CCSPlayer() : m_bForceShowMenu(false), m_flRespawnPending(0), m_flSpawnProtectionEndTime(0)
|
||||
{
|
||||
m_szModel[0] = '\0';
|
||||
}
|
||||
@ -80,6 +80,8 @@ public:
|
||||
virtual void ResetSequenceInfo();
|
||||
virtual void StartDeathCam();
|
||||
virtual bool RemovePlayerItemEx(const char* pszItemName, bool bRemoveAmmo);
|
||||
virtual void SetSpawnProtection(float flProtectionTime);
|
||||
virtual void RemoveSpawnProtection();
|
||||
|
||||
CBasePlayer *BasePlayer() const;
|
||||
|
||||
@ -87,6 +89,7 @@ public:
|
||||
char m_szModel[32];
|
||||
bool m_bForceShowMenu;
|
||||
float m_flRespawnPending;
|
||||
float m_flSpawnProtectionEndTime;
|
||||
};
|
||||
|
||||
// Inlines
|
||||
|
@ -424,6 +424,14 @@ typedef IHookChainRegistry<class CGrenade *, entvars_t *, Vector &, Vector &, fl
|
||||
typedef IHookChain<class CGrenade *, entvars_t *, Vector &, Vector &> IReGameHook_PlantBomb;
|
||||
typedef IHookChainRegistry<class CGrenade *, entvars_t *, Vector &, Vector &> IReGameHookRegistry_PlantBomb;
|
||||
|
||||
// CBasePlayer::SetSpawnProtection hook
|
||||
typedef IHookChainClass<void, class CBasePlayer, float> IReGameHook_CBasePlayer_SetSpawnProtection;
|
||||
typedef IHookChainRegistryClass<void, class CBasePlayer, float> IReGameHookRegistry_CBasePlayer_SetSpawnProtection;
|
||||
|
||||
// CBasePlayer::RemoveSpawnProtection hook
|
||||
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_RemoveSpawnProtection;
|
||||
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_RemoveSpawnProtection;
|
||||
|
||||
class IReGameHookchains {
|
||||
public:
|
||||
virtual ~IReGameHookchains() {}
|
||||
@ -529,6 +537,8 @@ public:
|
||||
virtual IReGameHookRegistry_ThrowFlashbang *ThrowFlashbang() = 0;
|
||||
virtual IReGameHookRegistry_ThrowSmokeGrenade *ThrowSmokeGrenade() = 0;
|
||||
virtual IReGameHookRegistry_PlantBomb *PlantBomb() = 0;
|
||||
virtual IReGameHookRegistry_CBasePlayer_RemoveSpawnProtection *CBasePlayer_RemoveSpawnProtection() = 0;
|
||||
virtual IReGameHookRegistry_CBasePlayer_SetSpawnProtection *CBasePlayer_SetSpawnProtection() = 0;
|
||||
};
|
||||
|
||||
struct ReGameFuncs_t {
|
||||
|
Loading…
Reference in New Issue
Block a user