Skip to content

Commit

Permalink
Use +inspect instead of ducking to show description
Browse files Browse the repository at this point in the history
  • Loading branch information
M60TM committed Nov 12, 2024
1 parent c2a36a9 commit 48edc00
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions addons/sourcemod/scripting/ff2r_epic_abilities.sp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ ConVar CvarMaxUnlag;
bool HookedWeaponSwap[MAXTF2PLAYERS];

int HasAbility[MAXTF2PLAYERS];
bool PressedInspectKey[MAXTF2PLAYERS];

Handle TimescaleTimer;
float DodgeFor[MAXTF2PLAYERS];
Expand Down Expand Up @@ -559,6 +560,7 @@ public void FF2R_OnBossRemoved(int client)
WallLagComped[client] = false;
ClassSwap[client] = TFClass_Unknown;
StealNext[client] = 0;
PressedInspectKey[client] = false;

if(DodgeFor[client])
DodgeFor[client] = 1.0;
Expand Down Expand Up @@ -811,6 +813,22 @@ public void OnClientDisconnect(int client)
WeapRef[client] = INVALID_ENT_REFERENCE;
}

public Action OnClientCommandKeyValues(int client, KeyValues kv) {
if (!HasAbility[client] || !IsPlayerAlive(client)) {
return Plugin_Continue;
}

char command[64];
kv.GetSectionName(command, sizeof(command));
if (strcmp(command, "+inspect_server") == 0) {
PressedInspectKey[client] = true;
} else if (strcmp(command, "-inspect_server") == 0) {
PressedInspectKey[client] = false;
}

return Plugin_Continue;
}

public Action OnPlayerRunCmd(int client, int &buttons)
{
if(DodgeFor[client])
Expand Down Expand Up @@ -962,19 +980,19 @@ public void OnPlayerRunCmdPost(int client, int buttons)
{
if(!hud)
{
static bool wasDucking[MAXTF2PLAYERS];
if(buttons & IN_DUCK)
static bool wasInspect[MAXTF2PLAYERS];
if(PressedInspectKey[client])
{
if(!wasDucking[client])
if(!wasInspect[client])
{
hud = true;
wasDucking[client] = true;
wasInspect[client] = true;
}
}
else if(!wasDucking[client])
else if(!wasInspect[client])
{
hud = true;
wasDucking[client] = false;
wasInspect[client] = false;
}
}

Expand Down Expand Up @@ -1013,15 +1031,15 @@ public void OnPlayerRunCmdPost(int client, int buttons)
if(val.tag == KeyValType_Section && val.cfg)
{
ConfigData cfg = view_as<ConfigData>(val.cfg);
if(!(buttons & IN_DUCK) || !GetBossNameCfg(cfg, val.data, sizeof(val.data), lang, "desc"))
if(!PressedInspectKey[client] || !GetBossNameCfg(cfg, val.data, sizeof(val.data), lang, "desc"))
{
if(!GetBossNameCfg(cfg, val.data, sizeof(val.data), lang))
strcopy(val.data, sizeof(val.data), key);
}

bool blocked = true;

if(buttons & IN_DUCK)
if(PressedInspectKey[client])
{
switch(button[i])
{
Expand Down Expand Up @@ -1139,7 +1157,7 @@ public void OnPlayerRunCmdPost(int client, int buttons)
if(val.tag == KeyValType_Section && val.cfg)
{
ConfigData cfg = view_as<ConfigData>(val.cfg);
if(!(buttons & IN_DUCK) || !GetBossNameCfg(cfg, val.data, sizeof(val.data), lang, "desc"))
if(!PressedInspectKey[client] || !GetBossNameCfg(cfg, val.data, sizeof(val.data), lang, "desc"))
{
if(!GetBossNameCfg(cfg, val.data, sizeof(val.data), lang))
strcopy(val.data, sizeof(val.data), key);
Expand All @@ -1148,7 +1166,7 @@ public void OnPlayerRunCmdPost(int client, int buttons)
GetButtons(ability, true, count, button);

bool blocked = true;
if((buttons & IN_DUCK) && count)
if((PressedInspectKey[client]) && count)
{
switch(button[0])
{
Expand Down

0 comments on commit 48edc00

Please sign in to comment.