Couch turbophysics HUD
This commit is contained in:
@@ -149,7 +149,7 @@ public void OnPluginStart()
|
||||
g_fwdOnClientBlocked = new GlobalForward("Couch_OnClientBlocked", ET_Ignore, Param_Cell, Param_Cell);
|
||||
|
||||
g_cvModel = CreateConVar("sm_couch_model", COUCH_DEFAULT_MODEL, "Model used for the couch. Applies to the next spawn.", FCVAR_NOTIFY);
|
||||
g_cvPushScale = CreateConVar("sm_couch_push_scale", "1.0", "Multiplier on the force bullets apply to the couch. 1.0 is the engine's own push.", FCVAR_NOTIFY, true, 0.0, true, 100.0);
|
||||
g_cvPushScale = CreateConVar("sm_couch_push_scale", "6.0", "Multiplier on the force bullets apply to the couch. 1.0 is the engine's own push.", FCVAR_NOTIFY, true, 0.0, true, 100.0);
|
||||
g_cvPistolOnly = CreateConVar("sm_couch_pistol_only", "0", "Only pistols and knives move the couch; other guns and grenades are ignored.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
|
||||
g_cvAllowUse = CreateConVar("sm_allow_couch_use", "1", "Players may push the couch by holding +use on it. 0 means it can only be moved by shooting it.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
|
||||
g_cvEffect = CreateConVar("sm_couch_effect", "0", "Colour cycle and pulsing light on the couch.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
// Longer names are cut so one can't eat the whole message.
|
||||
#define HUD_NAME_BYTES 20
|
||||
|
||||
// +use reports every tick it's held; the list is resent at most this often for it. Well under
|
||||
// sm_couch_hud_time's minimum, so the text never lapses while someone keeps pushing.
|
||||
#define HUD_USE_RESEND 0.1
|
||||
|
||||
// Put in front of the name of anyone whose grenade hit the couch recently.
|
||||
#define HUD_GRENADE_TAG "<G!> "
|
||||
|
||||
@@ -30,6 +34,7 @@ Handle g_hExpireTimer;
|
||||
float g_fExpire[MAXPLAYERS + 1]; // GetGameTime() at which this client drops off the list.
|
||||
float g_fLastHit[MAXPLAYERS + 1]; // Ordering key: the most recent shooter is listed first.
|
||||
float g_fGrenadeUntil[MAXPLAYERS + 1]; // GetGameTime() at which this client loses the grenade tag.
|
||||
float g_fNextUseSend[MAXPLAYERS + 1]; // GetGameTime() before which this client's +use doesn't resend.
|
||||
|
||||
float g_fNextExpiry; // Soonest expiry or tag drop among the names currently listed.
|
||||
float g_fLastExpiry; // Latest expiry among them; the text is held until then.
|
||||
@@ -52,7 +57,7 @@ public void OnPluginStart()
|
||||
g_hHudSync = CreateHudSynchronizer();
|
||||
|
||||
g_cvEnabled = CreateConVar("sm_couch_hud_enabled", "1", "Show the list of players shooting the couch.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
|
||||
g_cvTime = CreateConVar("sm_couch_hud_time", "0.5", "How long a player stays on the list after their last hit, in seconds.", FCVAR_NOTIFY, true, 0.5, true, 30.0);
|
||||
g_cvTime = CreateConVar("sm_couch_hud_time", "0.5", "How long a player stays on the list after their last hit or +use push, in seconds.", FCVAR_NOTIFY, true, 0.5, true, 30.0);
|
||||
g_cvGrenadeTime = CreateConVar("sm_couch_hud_time_grenade", "4.0", "How long a player stays on the list, tagged " ... HUD_GRENADE_TAG ... ", after their grenade hits the couch, in seconds.", FCVAR_NOTIFY, true, 0.5, true, 30.0);
|
||||
|
||||
g_cvEnabled.AddChangeHook(OnEnabledChanged);
|
||||
@@ -74,6 +79,7 @@ public void OnMapStart()
|
||||
g_fExpire[i] = 0.0;
|
||||
g_fLastHit[i] = 0.0;
|
||||
g_fGrenadeUntil[i] = 0.0;
|
||||
g_fNextUseSend[i] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +88,7 @@ public void OnClientPutInServer(int client)
|
||||
g_fExpire[client] = 0.0;
|
||||
g_fLastHit[client] = 0.0;
|
||||
g_fGrenadeUntil[client] = 0.0;
|
||||
g_fNextUseSend[client] = 0.0;
|
||||
}
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
@@ -91,6 +98,7 @@ public void OnClientDisconnect(int client)
|
||||
g_fExpire[client] = 0.0;
|
||||
g_fLastHit[client] = 0.0;
|
||||
g_fGrenadeUntil[client] = 0.0;
|
||||
g_fNextUseSend[client] = 0.0;
|
||||
|
||||
if (bListed)
|
||||
QueueFlush();
|
||||
@@ -125,13 +133,32 @@ public void Couch_OnCouchDamaged(int couch, int attacker, float damage)
|
||||
QueueFlush();
|
||||
}
|
||||
|
||||
// Fires just after Couch_OnCouchDamaged for the same hit, so the ordering is already updated.
|
||||
// Hits fire just after Couch_OnCouchDamaged for the same hit, so the ordering is already updated.
|
||||
// +use never goes through damage, so it is listed from here.
|
||||
public void Couch_OnCouchInteraction(int couch, int client, CouchMethod method, const char[] weapon)
|
||||
{
|
||||
if (!g_cvEnabled.BoolValue || method != CouchMethod_Grenade)
|
||||
if (!g_cvEnabled.BoolValue)
|
||||
return;
|
||||
|
||||
g_fGrenadeUntil[client] = GetGameTime() + g_cvGrenadeTime.FloatValue;
|
||||
float fNow = GetGameTime();
|
||||
|
||||
if (method == CouchMethod_Use)
|
||||
{
|
||||
g_fLastHit[client] = fNow;
|
||||
g_fExpire[client] = MaxFloat(g_fExpire[client], fNow + g_cvTime.FloatValue);
|
||||
|
||||
if (fNow < g_fNextUseSend[client])
|
||||
return;
|
||||
|
||||
g_fNextUseSend[client] = fNow + HUD_USE_RESEND;
|
||||
QueueFlush();
|
||||
return;
|
||||
}
|
||||
|
||||
if (method != CouchMethod_Grenade)
|
||||
return;
|
||||
|
||||
g_fGrenadeUntil[client] = fNow + g_cvGrenadeTime.FloatValue;
|
||||
g_fExpire[client] = MaxFloat(g_fExpire[client], g_fGrenadeUntil[client]);
|
||||
|
||||
QueueFlush();
|
||||
@@ -350,6 +377,7 @@ void ResetAll()
|
||||
g_fExpire[i] = 0.0;
|
||||
g_fLastHit[i] = 0.0;
|
||||
g_fGrenadeUntil[i] = 0.0;
|
||||
g_fNextUseSend[i] = 0.0;
|
||||
}
|
||||
|
||||
ClearAll();
|
||||
|
||||
Reference in New Issue
Block a user