Skip to content

Commit

Permalink
Merge branch 's1lentq:master' into semiclip-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenKal authored Jul 24, 2023
2 parents 4937343 + 9427767 commit 7679fb1
Show file tree
Hide file tree
Showing 34 changed files with 184 additions and 66 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_give_c4_frags | 3 | - | - | How many bonuses (frags) will get the player who defused or exploded the bomb. |
| mp_hostages_rescued_ratio | 1.0 | 0.0 | 1.0 | Ratio of hostages rescued to win the round. |
| mp_legacy_vehicle_block | 1 | 0 | 1 | Legacy func_vehicle behavior when blocked by another entity.<br/>`0` New behavior <br/>`1` Legacy behavior |
| mp_dying_time | 3.0 | 0.0 | - | Time for switch to free observing after death.<br/>`0` - disable spectating around death.<br/>`>0.00001` - time delay to start spectate.<br/>`NOTE`: The countdown starts when the player’s death animation is finished.|
</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 @@ -521,3 +521,11 @@ mp_hostages_rescued_ratio "1.0"
//
// Default value: "1"
mp_legacy_vehicle_block "1"
// Time for switch to free observing after death.
// NOTE: The countdown starts when the player’s death animation is finished.
// 0 - disable spectating around death
// >0.00001 - time delay to start spectate
//
// Default value: "3.0"
mp_dying_time "3.0"
1 change: 1 addition & 0 deletions regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ GAMEHOOK_REGISTRY(CBasePlayer_DeathSound);
GAMEHOOK_REGISTRY(CBasePlayer_JoiningThink);

GAMEHOOK_REGISTRY(FreeGameRules);
GAMEHOOK_REGISTRY(PM_LadderMove);

int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR;
Expand Down
7 changes: 7 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ typedef IHookChainRegistryImpl<void, struct playermove_s *, int> CReGameHookRegi
typedef IHookChainImpl<void, int> CReGameHook_PM_AirMove;
typedef IHookChainRegistryImpl<void, int> CReGameHookRegistry_PM_AirMove;

// PM_LadderMove hook
typedef IHookChainImpl<void, struct physent_s *> CReGameHook_PM_LadderMove;
typedef IHookChainRegistryImpl<void, struct physent_s *> CReGameHookRegistry_PM_LadderMove;

// HandleMenu_ChooseAppearance hook
typedef IHookChainImpl<void, CBasePlayer *, int> CReGameHook_HandleMenu_ChooseAppearance;
typedef IHookChainRegistryImpl<void, CBasePlayer *, int> CReGameHookRegistry_HandleMenu_ChooseAppearance;
Expand Down Expand Up @@ -777,6 +781,8 @@ class CReGameHookchains: public IReGameHookchains {
CReGameHookRegistry_CBasePlayer_Pain m_CBasePlayer_Pain;
CReGameHookRegistry_CBasePlayer_DeathSound m_CBasePlayer_DeathSound;
CReGameHookRegistry_CBasePlayer_JoiningThink m_CBasePlayer_JoiningThink;

CReGameHookRegistry_PM_LadderMove m_PM_LadderMove;

CReGameHookRegistry_FreeGameRules m_FreeGameRules;

Expand Down Expand Up @@ -912,6 +918,7 @@ class CReGameHookchains: public IReGameHookchains {
virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink();

virtual IReGameHookRegistry_FreeGameRules *FreeGameRules();
virtual IReGameHookRegistry_PM_LadderMove *PM_LadderMove();
};

extern CReGameHookchains g_ReGameHookchains;
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ EXT_FUNC bool CCSPlayer::JoinTeam(TeamName team)
pPlayer->StartObserver(pentSpawnSpot->v.origin, pentSpawnSpot->v.angles);

// do we have fadetoblack on? (need to fade their screen back in)
if (fadetoblack.value)
if (fadetoblack.value == FADETOBLACK_STAY)
{
UTIL_ScreenFade(pPlayer, Vector(0, 0, 0), 0.001, 0, 0, FFADE_IN);
}
Expand Down
5 changes: 5 additions & 0 deletions regamedll/dlls/animating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ NOXREF int CBaseAnimating::GetBodygroup(int iGroup)
return ::GetBodygroup(GET_MODEL_PTR(ENT(pev)), pev, iGroup);
}

float CBaseAnimating::GetSequenceDuration() const
{
return ::GetSequenceDuration(GET_MODEL_PTR(ENT(pev)), pev);
}

int CBaseAnimating::ExtractBbox(int sequence, float *mins, float *maxs)
{
return ::ExtractBbox(GET_MODEL_PTR(ENT(pev)), sequence, mins, maxs);
Expand Down
15 changes: 15 additions & 0 deletions regamedll/dlls/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,21 @@ void GetSequenceInfo(void *pmodel, entvars_t *pev, float *pflFrameRate, float *p
*pflGroundSpeed = *pflGroundSpeed * pseqdesc->fps / (pseqdesc->numframes - 1);
}

float GetSequenceDuration(void *pmodel, entvars_t *pev)
{
studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel;
if (!pstudiohdr)
return 0; // model ptr is not valid

if (pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq)
return 0; // sequence is not valid

// get current sequence time
mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + int(pev->sequence);

return pseqdesc->numframes / pseqdesc->fps;
}

int GetSequenceFlags(void *pmodel, entvars_t *pev)
{
studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel;
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ int LookupActivity(void *pmodel, entvars_t *pev, int activity);
int LookupActivityHeaviest(void *pmodel, entvars_t *pev, int activity);
int LookupSequence(void *pmodel, const char *label);
void GetSequenceInfo(void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed);
float GetSequenceDuration(void *pmodel, entvars_t *pev);
int GetSequenceFlags(void *pmodel, entvars_t *pev);
float SetController(void *pmodel, entvars_t *pev, int iController, float flValue);
float SetBlending(void *pmodel, entvars_t *pev, int iBlender, float flValue);
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/cbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ class CBaseAnimating: public CBaseDelay {
float SetBoneController(int iController, float flValue = 0.0f);
void InitBoneControllers();

float GetSequenceDuration() const;
float SetBlending(int iBlender, float flValue);
void GetBonePosition(int iBone, Vector &origin, Vector &angles);
void GetAutomovement(Vector &origin, Vector &angles, float flInterval = 0.1f);
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ BOOL EXT_FUNC __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *pPlayer, int slot)
MESSAGE_END();
#endif
// do we have fadetoblack on? (need to fade their screen back in)
if (fadetoblack.value)
if (fadetoblack.value == FADETOBLACK_STAY)
{
UTIL_ScreenFade(pPlayer, Vector(0, 0, 0), 0.001, 0, 0, FFADE_IN);
}
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ void PlayerBlind(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAt
{
UTIL_ScreenFade(pPlayer, color, fadeTime, fadeHold, alpha, 0);

if (!fadetoblack.value)
if (fadetoblack.value != FADETOBLACK_STAY)
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, n

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

void GameDLL_Version_f()
{
if (Q_stricmp(CMD_ARGV(1), "version") != 0)
Expand Down Expand Up @@ -420,6 +422,8 @@ void EXT_FUNC GameDLLInit()

CVAR_REGISTER(&legacy_vehicle_block);

CVAR_REGISTER(&dying_time);

// print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");

Expand Down
3 changes: 2 additions & 1 deletion regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ extern cvar_t sv_enablebunnyhopping;
extern cvar_t plant_c4_anywhere;
extern cvar_t give_c4_frags;
extern cvar_t hostages_rescued_ratio;

extern cvar_t legacy_vehicle_block;
extern cvar_t dying_time;

#endif

extern cvar_t scoreboard_showmoney;
Expand Down
13 changes: 12 additions & 1 deletion regamedll/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const float ROUND_RESPAWN_TIME = 20.0f;
const float ROUND_BEGIN_DELAY = 5.0f; // delay before beginning new round
const float ITEM_KILL_DELAY = 300.0f;
const float RADIO_TIMEOUT = 1.5f;
const float DEATH_ANIMATION_TIME = 3.0f;

const int MAX_INTERMISSION_TIME = 120; // longest the intermission can last, in seconds

Expand Down Expand Up @@ -206,7 +207,7 @@ enum
SCENARIO_BLOCK_PRISON_ESCAPE_TIME = BIT(8), // flag "i"
SCENARIO_BLOCK_BOMB_TIME = BIT(9), // flag "j"
SCENARIO_BLOCK_HOSTAGE_RESCUE_TIME = BIT(10), // flag "k"

};

// Player relationship return codes
Expand Down Expand Up @@ -336,6 +337,7 @@ class CGameRules
inline void SetGameOver() { m_bGameOver = true; }
static float GetItemKillDelay();
static float GetRadioTimeout();
static float GetDyingTime();

public:
BOOL m_bFreezePeriod; // TRUE at beginning of round, set to FALSE when the period expires
Expand Down Expand Up @@ -921,6 +923,15 @@ inline float CGameRules::GetRadioTimeout()
#endif
}

inline float CGameRules::GetDyingTime()
{
#ifdef REGAMEDLL_ADD
return dying_time.value;
#else
return DEATH_ANIMATION_TIME;
#endif
}

bool IsBotSpeaking();
void SV_Continue_f();
void SV_Tutor_Toggle_f();
Expand Down
9 changes: 5 additions & 4 deletions regamedll/dlls/gib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ LINK_ENTITY_TO_CLASS(gib, CGib, CCSGib)
void CGib::LimitVelocity()
{
float length = pev->velocity.Length();
float topspeed = CVAR_GET_FLOAT("sv_maxvelocity") * 0.75f;

// ceiling at 1500. The gib velocity equation is not bounded properly. Rather than tune it
// ceiling at topspeed. The gib velocity equation is not bounded properly. Rather than tune it
// in 3 separate places again, I'll just limit it here.
if (length > 1500.0)
if (length > topspeed)
{
// This should really be sv_maxvelocity * 0.75 or something
pev->velocity = pev->velocity.Normalize() * 1500;
// DONE: This should really be sv_maxvelocity * 0.75 or something
pev->velocity = pev->velocity.Normalize() * topspeed;
}
}

Expand Down
6 changes: 3 additions & 3 deletions regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2393,7 +2393,7 @@ void CHalfLifeMultiplay::Think()
MESSAGE_BEGIN(MSG_ALL, gmsgForceCam);
WRITE_BYTE(forcecamera.value != 0);
WRITE_BYTE(forcechasecam.value != 0);
WRITE_BYTE(fadetoblack.value != 0);
WRITE_BYTE(fadetoblack.value == FADETOBLACK_STAY);
MESSAGE_END();

m_flForceCameraValue = forcecamera.value;
Expand Down Expand Up @@ -3456,7 +3456,7 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl)
MESSAGE_BEGIN(MSG_ONE, gmsgForceCam, nullptr, pl->edict());
WRITE_BYTE(forcecamera.value != 0);
WRITE_BYTE(forcechasecam.value != 0);
WRITE_BYTE(fadetoblack.value != 0);
WRITE_BYTE(fadetoblack.value == FADETOBLACK_STAY);
MESSAGE_END();

if (m_bGameOver)
Expand Down Expand Up @@ -3874,7 +3874,7 @@ BOOL EXT_FUNC CHalfLifeMultiplay::__API_HOOK(FPlayerCanRespawn)(CBasePlayer *pPl
{
// If this player just connected and fadetoblack is on, then maybe
// the server admin doesn't want him peeking around.
if (fadetoblack.value != 0.0f)
if (fadetoblack.value == FADETOBLACK_STAY)
{
UTIL_ScreenFade(pPlayer, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT));
}
Expand Down
4 changes: 2 additions & 2 deletions regamedll/dlls/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int __API_HOOK(GetForceCamera)(CBasePlayer *pObserver)
{
int retVal;

if (!fadetoblack.value)
if (fadetoblack.value != FADETOBLACK_STAY)
{
retVal = int(CVAR_GET_FLOAT("mp_forcechasecam"));

Expand Down Expand Up @@ -51,7 +51,7 @@ void UpdateClientEffects(CBasePlayer *pObserver, int oldMode)
{
bool clearProgress = false;
bool clearBlindness = false;
bool blindnessOk = (fadetoblack.value == 0);
bool blindnessOk = (fadetoblack.value != FADETOBLACK_STAY);
bool clearNightvision = false;

if (pObserver->GetObserverMode() == OBS_IN_EYE)
Expand Down
6 changes: 6 additions & 0 deletions regamedll/dlls/observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
#define CAMERA_MODE_SPEC_ONLY_TEAM 1
#define CAMERA_MODE_SPEC_ONLY_FIRST_PERSON 2

enum FadeToBlack {
FADETOBLACK_OFF,
FADETOBLACK_STAY,
FADETOBLACK_AT_DYING,
};

int GetForceCamera(CBasePlayer *pObserver);
void UpdateClientEffects(CBasePlayer *pObserver, int oldMode);

Expand Down
Loading

0 comments on commit 7679fb1

Please sign in to comment.