Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait Period Improvements #180

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Prevent shooting during wait period, Freeze angles
  • Loading branch information
ampreeT committed Nov 24, 2024
commit 1e12d0ced0897bee491642a028cf20b06b577a52
12 changes: 10 additions & 2 deletions scripting/include/srccoop/classdef.inc
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,14 @@ methodmap CBaseEntity
{
SetEntityFlags(this.GetEntIndex(), iFlags);
}
public void AddFlags(const int iFlags)
{
this.SetFlags(this.GetFlags() | iFlags);
}
public void RemoveFlags(const int iFlags)
{
this.SetFlags(this.GetFlags() & ~iFlags);
}
public int GetEFlags()
{
return GetEntProp(this.GetEntIndex(), Prop_Data, "m_iEFlags");
Expand Down Expand Up @@ -2262,7 +2270,7 @@ methodmap CBasePlayer < CBaseCombatCharacter
public void StartDucking() // (taken from point_teleport code)
{
this.SetButtons(this.GetButtons() | IN_DUCK);
this.SetFlags(this.GetFlags() | FL_DUCKING);
this.AddFlags(FL_DUCKING);
int iClient = this.GetEntIndex();
SetEntProp(iClient, Prop_Send, "m_bDucked", true);
SetEntProp(iClient, Prop_Send, "m_bDucking", true);
Expand All @@ -2275,7 +2283,7 @@ methodmap CBasePlayer < CBaseCombatCharacter
public void StopDucking()
{
this.SetButtons(this.GetButtons() & ~IN_DUCK);
this.SetFlags(this.GetFlags() & ~FL_DUCKING);
this.RemoveFlags(FL_DUCKING);
int iClient = this.GetEntIndex();
SetEntProp(iClient, Prop_Send, "m_bDucked", false);
SetEntProp(iClient, Prop_Send, "m_bDucking", false);
Expand Down
21 changes: 18 additions & 3 deletions scripting/include/srccoop/manager.inc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ methodmap CoopManager
Timer_DecrementUntilMapStart(null);
}
}

public static void OnPlayerRunCmd(CBasePlayer pPlayer)
{
if (!data.m_bStarted)
{
CBaseCombatWeapon pWeapon = pPlayer.GetActiveWeapon();
if (pWeapon != NULL_CBASEENTITY)
{
PreventWeaponFiring(pWeapon, 1.5);
}
}
}

public static void OnPlayerSpawned(CBasePlayer pPlayer)
{
Expand Down Expand Up @@ -236,12 +248,12 @@ methodmap CoopManager
{
if (g_pLevelLump.m_iIntroType == INTRO_FADE)
{
pPlayer.AddFlags(FL_ATCONTROLS | FL_FROZEN); // Freeze controls and angles.
Client_ScreenFade(pPlayer.GetEntIndex(), 0, FFADE_STAYOUT);
pPlayer.SetFlags(pPlayer.GetFlags() | FL_ATCONTROLS);
}
else if (g_pLevelLump.m_iIntroType == INTRO_FREEZE)
{
pPlayer.SetFlags(pPlayer.GetFlags() | FL_ATCONTROLS);
pPlayer.AddFlags(FL_ATCONTROLS); // Freeze controls.
Client_ScreenFade(pPlayer.GetEntIndex(), Conf.FROZEN_FADE_DUR_IN, FFADE_OUT | FFADE_STAYOUT, _,
Conf.FROZEN_FADE_COLOR[0], Conf.FROZEN_FADE_COLOR[1], Conf.FROZEN_FADE_COLOR[2], Conf.FROZEN_FADE_COLOR[3]);
}
Expand Down Expand Up @@ -546,7 +558,10 @@ public Action Timer_DecrementUntilMapStart(Handle hTimer)
if (IsClientInGame(i) && !IsFakeClient(i))
{
CBasePlayer pClient = CBasePlayer(i);
pClient.SetFlags(pClient.GetFlags() & ~FL_ATCONTROLS);
// TODO: Look into this.
// `FL_FROZEN` is being removed even without the below line in Black Mesa (i doubt this affects other games).
// `CBM_MP_GameRules.SetStateEndTime` might be the culprit and might have side effects for other behaviors too.
pClient.RemoveFlags(FL_ATCONTROLS | FL_FROZEN);
if (g_pLevelLump.m_iIntroType == INTRO_FREEZE)
{
Client_ScreenFade(pClient.GetEntIndex(), Conf.FROZEN_FADE_DUR_OUT, FFADE_PURGE | FFADE_IN, 1,
Expand Down
11 changes: 6 additions & 5 deletions scripting/include/srccoop/playerpatch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,17 @@ public Action OnPlayerRunCmd(int iClient, int &iButtons, int &iImpulse, float fV
if (mouse[0] || mouse[1])
g_bPostTeamSelect[iClient] = true;

// Spectator fixes
// Credit: harper

Obs_Mode iObsMode = view_as<Obs_Mode> (GetEntProp(iClient, Prop_Send, "m_iObserverMode"));
CBasePlayer pClient = CBasePlayer(iClient);

// Spectator fixes; Credits: harper
Obs_Mode iObsMode = view_as<Obs_Mode>(GetEntProp(iClient, Prop_Send, "m_iObserverMode"));
if (iObsMode > OBS_MODE_DEATHCAM)
{
// hide bugged ctrl menu
if (g_bPostTeamSelect[iClient] && tickcount % 10 == 0)
ShowVGUIPanel(iClient, "specmenu", _, false);

CBasePlayer pTarget = CBasePlayer(GetEntPropEnt(iClient, Prop_Send, "m_hObserverTarget"));
CBasePlayer pClient = CBasePlayer(iClient);

// Make sure target is not an info_observer_menu
// force free-look where appropriate - this removes the extra (pointless) third person spec mode
Expand All @@ -178,6 +177,8 @@ public Action OnPlayerRunCmd(int iClient, int &iButtons, int &iImpulse, float fV
}
}

CoopManager.OnPlayerRunCmd(pClient);

if (g_iAddButtons[iClient])
{
iButtons |= g_iAddButtons[iClient];
Expand Down