Skip to content

Commit 1ac01ff

Browse files
committed
Compound update
- new addon: landing_screen - applies new logo during the spawning screen - now only deathmatch-type spawning screen is shown - revive disabled in non survival mode - updated credits - bump version
1 parent 1416f90 commit 1ac01ff

File tree

10 files changed

+191
-17
lines changed

10 files changed

+191
-17
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ If you are interested in helping us, contact us on [Discord](https://discord.gg/
4646
- [Steam](https://steamcommunity.com/id/Krozis_Kane/) | [GitHub](https://github.com/KrozisKane)
4747
- __Balimbanana__ | programming, reverse engineering
4848
- [Steam](https://steamcommunity.com/id/Balimbanana/) | [GitHub](https://github.com/Balimbanana)
49+
- __raicovx__ | programming
50+
- [GitHub](https://github.com/raicovx)
51+
- __Jimmy-Baby__ | programming
52+
- [GitHub](https://github.com/Jimmy-Baby)
4953
#### Playtesters
5054
- [Lear](https://steamcommunity.com/id/SKGNick)
5155
- [bddu](https://steamcommunity.com/id/bddu/)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"MonitorScreen"
2+
{
3+
"$basetexture" "sourcecoop/landing_screen"
4+
"$translucent" "1"
5+
"$contrast" "0"
6+
7+
"Proxies"
8+
{
9+
"Sine"
10+
{
11+
"sineperiod" "4"
12+
"sinemin" "0"
13+
"sinemax" "10"
14+
"resultVar" "$contrast"
15+
}
16+
17+
"Clamp"
18+
{
19+
"srcVar1" "$contrast"
20+
"min" "0"
21+
"max" "3"
22+
"resultVar" "$contrast"
23+
}
24+
}
25+
}
Binary file not shown.

scripting/include/srccoop/classdef.inc

+5
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,11 @@ methodmap CBM_MP_GameRules
13811381
{
13821382
GameRules_SetProp(szStateProp, bInIntermission, _, STATE_ELEMENT_IS_IN_INTERMISSION);
13831383
}
1384+
1385+
public static bool IsTeamplay()
1386+
{
1387+
return GetTeamCount() >= 4;
1388+
}
13841389
}
13851390

13861391
methodmap CGlobalState

scripting/include/srccoop/globals.inc

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ char g_szSteamIds[MAXPLAYERS+1][32];
7777
bool g_bTempDontHookEnts;
7878
bool g_bMapStarted;
7979
float g_flNextStuck[MAXPLAYERS+1];
80+
bool g_bPostTeamSelect[MAXPLAYERS+1];
8081
EngineVersion g_Engine;
8182
OperatingSystem g_serverOS;
8283
FeatureMap g_pFeatureMap;

scripting/include/srccoop/playerpatch.inc

+29-15
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,18 @@ public Action OnPlayerRunCmd(int iClient, int &iButtons, int &iImpulse, float fV
131131
return Plugin_Continue;
132132
}
133133

134+
if (mouse[0] || mouse[1])
135+
{
136+
g_bPostTeamSelect[iClient] = true;
137+
}
138+
134139
// Spectator fixes
135140
// Credit: harper
136141

137142
if (IsClientObserver(iClient))
138143
{
139144
// hide bugged ctrl menu
140-
if(tickcount % 10 == 0)
145+
if (g_bPostTeamSelect[iClient] && tickcount % 64 == 0)
141146
ShowVGUIPanel(iClient, "specmenu", _, false);
142147

143148
Obs_Mode iMode = view_as<Obs_Mode> (GetEntProp(iClient, Prop_Send, "m_iObserverMode"));
@@ -294,11 +299,13 @@ public void Hook_PlayerSpawnPost(int iClient)
294299
ClientCommand(iClient, "hidepanel team");
295300
ClientCommand(iClient, "hidepanel deathmatch");
296301
ChangeClientTeam(iClient, TEAM_SCIENTIST);
302+
g_bPostTeamSelect[iClient] = true;
297303
}
298304
else
299305
{
300-
// If this was not here, the specmenu fix in OnPlayerRunCmd would periodically blink the initial team select menu for some reason.
301-
ClientCommand(iClient, "chooseteam");
306+
// always show DM variant of team select
307+
ClientCommand(iClient, "hidepanel team");
308+
ClientCommand(iClient, "showpanel deathmatch");
302309
}
303310
}
304311
}
@@ -330,9 +337,9 @@ public MRESReturn Hook_PlayerKilled(int _this, DHookParam hParams)
330337

331338
public MRESReturn Hook_PlayerKilledPost(int _this, DHookParam hParams)
332339
{
340+
CBasePlayer pPlayer = CBasePlayer(_this);
333341
if (g_pNewRagdoll.IsValid())
334342
{
335-
CBasePlayer pPlayer = CBasePlayer(_this);
336343
CBaseEntity pRagdoll = pPlayer.GetRagdoll();
337344
CBaseEntity pViewEnt = pPlayer.GetViewEntity();
338345

@@ -351,6 +358,9 @@ public MRESReturn Hook_PlayerKilledPost(int _this, DHookParam hParams)
351358

352359
g_pNewRagdoll = CBaseEntity(-1);
353360

361+
}
362+
if (CoopManager.IsCoopModeEnabled())
363+
{
354364
SurvivalManager.HandlePlayerDeath(pPlayer);
355365
}
356366
return MRES_Ignored;
@@ -398,27 +408,31 @@ public MRESReturn Hook_PlayerChangeTeam(int _this, Handle hParams)
398408
{
399409
if (CoopManager.IsCoopModeEnabled())
400410
{
411+
if (!CBM_MP_GameRules.IsTeamplay())
412+
return MRES_Ignored;
413+
401414
int iTeamNum = DHookGetParam(hParams, 1);
402-
if (iTeamNum == TEAM_SCIENTIST || iTeamNum == TEAM_MARINES)
415+
if (iTeamNum == TEAM_SCIENTIST || iTeamNum == TEAM_MARINES || iTeamNum == TEAM_UNASSIGNED)
403416
{
404417
char szTeam[16]; g_pConvarCoopTeam.GetString(szTeam, sizeof(szTeam));
405418
if (StrEqual(szTeam, "scientist", false))
406419
{
407-
if (iTeamNum == TEAM_MARINES)
408-
{
409-
DHookSetParam(hParams, 1, TEAM_SCIENTIST);
410-
return MRES_ChangedHandled;
411-
}
420+
DHookSetParam(hParams, 1, TEAM_SCIENTIST);
421+
return MRES_ChangedHandled;
412422
}
413423
else if (StrEqual(szTeam, "marines", false))
414424
{
415-
if (iTeamNum == TEAM_SCIENTIST)
416-
{
417-
DHookSetParam(hParams, 1, TEAM_MARINES);
418-
return MRES_ChangedHandled;
419-
}
425+
DHookSetParam(hParams, 1, TEAM_MARINES);
426+
return MRES_ChangedHandled;
427+
}
428+
if (iTeamNum == TEAM_UNASSIGNED)
429+
{
430+
DHookSetParam(hParams, 1, TEAM_SCIENTIST);
431+
return MRES_ChangedHandled;
420432
}
421433
}
434+
435+
422436
}
423437
return MRES_Ignored;
424438
}

scripting/include/srccoop_api.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <srccoop/classdef.inc>
1111
#include <srccoop/utils.inc>
1212

13-
#define SRCCOOP_VERSION "1.1.1"
13+
#define SRCCOOP_VERSION "1.1.2"
1414

1515
/* The library name registered by the core plugin */
1616
#define SRCCOOP_LIBRARY "SRCCOOP"

scripting/srccoop.sp

+1
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ public void OnClientDisconnect_Post(int client)
331331
SurvivalManager.GameOverCheck();
332332
g_flNextStuck[client] = 0.0;
333333
g_szSteamIds[client] = "";
334+
g_bPostTeamSelect[client] = false;
334335
}
335336

336337
public void Event_PlayerDisconnect(Event hEvent, const char[] szName, bool bDontBroadcast)
+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#include <sourcemod>
2+
#include <sdktools>
3+
#include <sdkhooks>
4+
5+
#include <srccoop_api>
6+
7+
#pragma newdecls required
8+
#pragma semicolon 1
9+
10+
public Plugin myinfo =
11+
{
12+
name = "SourceCoop landing screen",
13+
author = "Alienmario",
14+
description = "SourceCoop landing screen overlay",
15+
version = SRCCOOP_VERSION,
16+
url = "https://github.com/ampreeT/SourceCoop"
17+
};
18+
19+
ConVar pCvarLogoMaterial;
20+
bool bEnabled;
21+
bool bHidden[MAXPLAYERS + 1];
22+
bool bReApply[MAXPLAYERS + 1];
23+
24+
public void OnPluginStart() {
25+
pCvarLogoMaterial = CreateConVar("sourcecoop_logo_material", "sourcecoop/landing_screen");
26+
27+
HookEvent("player_team", Event_PlayerChangeTeam, EventHookMode_Post);
28+
}
29+
30+
public void OnMapStart()
31+
{
32+
bEnabled = IsCurrentMapCoop();
33+
if (bEnabled)
34+
{
35+
char szBuffer[PLATFORM_MAX_PATH], szVMT[PLATFORM_MAX_PATH], szVTF[PLATFORM_MAX_PATH];
36+
pCvarLogoMaterial.GetString(szBuffer, sizeof(szBuffer));
37+
Format(szVMT, sizeof(szVMT), "materials/%s.vmt", szBuffer);
38+
Format(szVTF, sizeof(szVTF), "materials/%s.vtf", szBuffer);
39+
AddFileToDownloadsTable(szVMT);
40+
AddFileToDownloadsTable(szVTF);
41+
PrecacheModel(szVMT, true);
42+
}
43+
}
44+
45+
public void OnClientPutInServer(int client)
46+
{
47+
if (bEnabled)
48+
{
49+
bHidden[client] = false;
50+
bReApply[client] = true;
51+
ApplyOverlay(client);
52+
}
53+
else
54+
{
55+
bHidden[client] = true;
56+
}
57+
}
58+
59+
public void Event_PlayerChangeTeam(Event hEvent, const char[] szName, bool bDontBroadcast)
60+
{
61+
int client = GetClientOfUserId(hEvent.GetInt("userid"));
62+
if (!bHidden[client])
63+
{
64+
int iTeam = hEvent.GetInt("team");
65+
if (iTeam == TEAM_SCIENTIST || iTeam == TEAM_MARINES || iTeam == TEAM_UNASSIGNED)
66+
{
67+
ClientCommand(client, "r_screenoverlay 0");
68+
bHidden[client] = true;
69+
}
70+
}
71+
}
72+
73+
public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3], int weapon, int subtype, int cmdnum, int tickcount, int seed, const int mouse[2])
74+
{
75+
if (!bHidden[client])
76+
{
77+
if (mouse[0] || mouse[1])
78+
{
79+
ClientCommand(client, "r_screenoverlay 0");
80+
bHidden[client] = true;
81+
}
82+
else if (bReApply[client]) // in some cases, the overlay can poof during the spawn-in process, gotta reapply
83+
{
84+
bReApply[client] = false;
85+
ApplyOverlay(client);
86+
}
87+
}
88+
}
89+
90+
void ApplyOverlay(int client)
91+
{
92+
static char szBuffer[PLATFORM_MAX_PATH];
93+
pCvarLogoMaterial.GetString(szBuffer, sizeof(szBuffer));
94+
ClientCommand(client, "r_screenoverlay %s", szBuffer);
95+
}

scripting/srccoop_addon_revive.sp

+30-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define SND_RESPAWN "weapons/tau/gauss_undercharge.wav"
1313

1414
ConVar g_pConVarReviveTime, g_pConVarReviveScore, g_pConVarReviveMessages, g_pConVarRagdollParticle;
15+
ConVar g_pConVarSurvivalMode;
1516

1617
int g_BeamSprite = -1;
1718
int g_ColorGreen[4] = {0, 255, 0, 255};
@@ -45,12 +46,21 @@ public void OnPluginStart()
4546
HookEvent("player_death", Event_PlayerDeath);
4647
}
4748

49+
public void OnAllPluginsLoaded()
50+
{
51+
if ((g_pConVarSurvivalMode = FindConVar("sourcecoop_survival_mode")) == null)
52+
SetFailState("ConVar sourcecoop_survival_mode not found.");
53+
54+
g_pConVarSurvivalMode.AddChangeHook(OnSurvivalModeChanged);
55+
}
56+
4857
public void OnMapStart()
4958
{
50-
if (!(g_bEnabled = IsCurrentMapCoop()))
59+
if (!IsCurrentMapCoop())
5160
{
5261
return;
5362
}
63+
SetEnabledState();
5464

5565
PrecacheSound(SND_RESPAWN, true);
5666
PrecacheSound(SND_START, true);
@@ -68,6 +78,25 @@ public void OnMapStart()
6878
}
6979
}
7080

81+
public void OnSurvivalModeChanged(ConVar convar, const char[] oldValue, const char[] newValue)
82+
{
83+
SetEnabledState();
84+
}
85+
86+
void SetEnabledState()
87+
{
88+
if (g_pConVarSurvivalMode.IntValue && IsCurrentMapCoop())
89+
{
90+
g_bEnabled = true;
91+
}
92+
else
93+
{
94+
g_bEnabled = false;
95+
for (int i = 1; i <= MaxClients; i++)
96+
ResetReviveStatus(i);
97+
}
98+
}
99+
71100
public Action Command_ForceRespawn(int client, int args)
72101
{
73102
static char szTarget[64];

0 commit comments

Comments
 (0)