Skip to content

Commit

Permalink
add basic strafer thing to autogain
Browse files Browse the repository at this point in the history
  • Loading branch information
rtldg committed May 21, 2022
1 parent e817a9a commit c2e5076
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 5 deletions.
22 changes: 21 additions & 1 deletion addons/sourcemod/scripting/include/shavit/tas.inc
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,31 @@ native bool Shavit_GetAutoPrestrafe(int client);
native void Shavit_SetAutoJumpOnStart(int client, bool value);

/**
* Retrieves hether the client automatically jumps when they leave the start zone.
* Retrieves whether the client automatically jumps when they leave the start zone.
*
* @param client Client index
* @return The current auto jump value.
*/
native bool Shavit_GetAutoJumpOnStart(int client);

/**
* Sets whether the client uses the autogain basic strafer.
*
* @param client Client index
* @param value New value to set the autogain basic strafer to.
* @noreturn
*/
native void Shavit_SetAutogainBasicStrafer(int client, bool value);

/**
* Retrieves whether the client has has enabled the autogain basic strafer :tm:
*
* @param client Client index
* @return The current autogain basic strafer setting.
*/
native bool Shavit_GetAutogainBasicStrafer(int client);



// taken from shavit's oryx
stock bool IsSurfing(int client)
Expand Down Expand Up @@ -217,5 +235,7 @@ public void __pl_shavit_tas_SetNTVOptional()
MarkNativeAsOptional("Shavit_GetAutoJumpOnStart");
MarkNativeAsOptional("Shavit_SetEdgeJump");
MarkNativeAsOptional("Shavit_GetEdgeJump");
MarkNativeAsOptional("Shavit_SetAutogainBasicStrafer");
MarkNativeAsOptional("Shavit_GetAutogainBasicStrafer");
}
#endif
56 changes: 54 additions & 2 deletions addons/sourcemod/scripting/shavit-tas.sp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ bool gB_Prestrafe[MAXPLAYERS + 1];
bool gB_AutoJumpOnStart[MAXPLAYERS + 1];
bool gB_EdgeJump[MAXPLAYERS + 1];
float g_fPower[MAXPLAYERS + 1] = {1.0, ...};
bool gB_AutogainBasicStrafer[MAXPLAYERS + 1];

bool gB_ForceJump[MAXPLAYERS+1];

Expand Down Expand Up @@ -91,6 +92,8 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("Shavit_GetAutoJumpOnStart", Native_GetAutoJumpOnStart);
CreateNative("Shavit_SetEdgeJump", Native_SetEdgeJump);
CreateNative("Shavit_GetEdgeJump", Native_GetEdgeJump);
CreateNative("Shavit_SetAutogainBasicStrafer", Native_SetAutogainBasicStrafer);
CreateNative("Shavit_GetAutogainBasicStrafer", Native_GetAutogainBasicStrafer);

gB_Late = late;
RegPluginLibrary("shavit-tas");
Expand Down Expand Up @@ -147,12 +150,15 @@ public void OnPluginStart()
AddCommandListener(CommandListener_Toggler, "-autojumponstart");
AddCommandListener(CommandListener_Toggler, "+edgejump");
AddCommandListener(CommandListener_Toggler, "-edgejump");
AddCommandListener(CommandListener_Toggler, "+autogainbss");
AddCommandListener(CommandListener_Toggler, "-autogainbss");

RegConsoleCmd("sm_autostrafer", Command_Toggler, "Usage: !autostrafe [1|0]");
RegConsoleCmd("sm_autostrafe", Command_Toggler, "Usage: !autostrafe [1|0]");
RegConsoleCmd("sm_autoprestrafe", Command_Toggler, "Usage: !autoprestrafe [1|0}");
RegConsoleCmd("sm_autojumponstart", Command_Toggler, "Usage: !autojumponstart [1|0}");
RegConsoleCmd("sm_edgejump", Command_Toggler, "Usage: !edgejump [1|0}");
RegConsoleCmd("sm_autogainbss", Command_Toggler, "Usage: !autogainbss [1|0}");

RegConsoleCmd("sm_tasm", Command_TasSettingsMenu, "Opens the TAS settings menu.");
RegConsoleCmd("sm_tasmenu", Command_TasSettingsMenu, "Opens the TAS settings menu.");
Expand Down Expand Up @@ -212,6 +218,7 @@ public void OnClientConnected(int client)
gB_EdgeJump[client] = true;
gB_Prestrafe[client] = true;
g_fPower[client] = 1.0;
gB_AutogainBasicStrafer[client] = true;
}

public void OnClientPutInServer(int client)
Expand Down Expand Up @@ -552,6 +559,20 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
}
else if (type == AutostrafeType_Autogain || type == AutostrafeType_AutogainNoSpeedLoss)
{
if (gB_AutogainBasicStrafer[client])
{
float delta = AngleNormalize(angles[1] - oldyaw);

if (delta < 0.0)
{
vel[1] = g_fMaxMove;
}
else if (delta > 0.0)
{
vel[1] = -g_fMaxMove;
}
}

ObliviousOnPlayerRunCmd(client, buttons, impulse, vel, angles, weapon, subtype, cmdnum, tickcount, seed, mouse,
sv_airaccelerate.FloatValue, flSurfaceFriction, g_flAirSpeedCap, g_fMaxMove,
(type == AutostrafeType_AutogainNoSpeedLoss));
Expand Down Expand Up @@ -689,6 +710,11 @@ void OpenTasSettingsMenu(int client, int pos=0)
(ov == AutostrafeOverride_Normal ? "AutostrafeOverride_Normal" : (ov == AutostrafeOverride_Surf ? "AutostrafeOverride_Surf" : (ov == AutostrafeOverride_Surf_W_Okay ? "AutostrafeOverride_Surf_W_Okay" : "AutostrafeOverride_All"))), client);
menu.AddItem("override", display);

FormatEx(display, sizeof(display), "[%s] %T", gB_AutogainBasicStrafer[client] ? "":"", "AutogainBasicStrafer", client);
menu.AddItem("autogainbss", display,
(tastype == AutostrafeType_Autogain || tastype == AutostrafeType_AutogainNoSpeedLoss) ?
ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED);

if (Shavit_GetStyleSettingBool(Shavit_GetBhopStyle(client), "segments"))
{
menu.ExitBackButton = true;
Expand Down Expand Up @@ -724,6 +750,10 @@ public int MenuHandler_TasSettings(Menu menu, MenuAction action, int param1, int
{
gB_Prestrafe[param1] = !gB_Prestrafe[param1];
}
else if (StrEqual(info, "autogainbss"))
{
gB_AutogainBasicStrafer[param1] = !gB_AutogainBasicStrafer[param1];
}
else if (StrEqual(info, "type"))
{
AutostrafeType tastype = view_as<AutostrafeType>(Shavit_GetStyleSettingInt(Shavit_GetBhopStyle(param1), "autostrafe"));
Expand Down Expand Up @@ -784,9 +814,12 @@ void Command_Toggler_Internal(int client, const char[] asdfcommand, int x)
command = "autostrafe";
}

if (!Shavit_GetStyleSettingBool(Shavit_GetBhopStyle(client), command))
if (!StrEqual(command, "autogainbss"))
{
return;
if (!Shavit_GetStyleSettingBool(Shavit_GetBhopStyle(client), command))
{
return;
}
}

bool set;
Expand All @@ -812,6 +845,11 @@ void Command_Toggler_Internal(int client, const char[] asdfcommand, int x)
set = gB_EdgeJump[client] = (x == -1) ? !gB_EdgeJump[client] : (x != 0);
translation = "EdgeJump";
}
else if (StrEqual(command, "autogainbss"))
{
set = gB_AutogainBasicStrafer[client] = (x == -1) ? !gB_AutogainBasicStrafer[client] : (x != 0);
translation = "AutogainBasicStrafer";
}

Shavit_StopChatSound();
Shavit_PrintToChat(client, "%T: %s%T", translation, client, (set ? gS_ChatStrings.sVariable : gS_ChatStrings.sWarning), (set ? "TASEnabled" : "TASDisabled"), client);
Expand Down Expand Up @@ -956,3 +994,17 @@ public any Native_GetEdgeJump(Handle plugin, int numParams)
int client = GetNativeCell(1);
return gB_EdgeJump[client];
}

public any Native_SetAutogainBasicStrafer(Handle plugin, int numParams)
{
int client = GetNativeCell(1);
bool value = GetNativeCell(2);
gB_AutogainBasicStrafer[client] = value;
return 0;
}

public any Native_GetAutogainBasicStrafer(Handle plugin, int numParams)
{
int client = GetNativeCell(1);
return gB_AutogainBasicStrafer[client];
}
8 changes: 6 additions & 2 deletions addons/sourcemod/translations/shavit-misc.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@
{
"en" "Edge jump"
}
"AutogainBasicStrafer"
{
"en" "Autogain basic strafer"
}
"AutoPrestrafe"
{
"en" "Auto Prestrafe"
Expand All @@ -239,11 +243,11 @@
}
"Autostrafer_autogain"
{
"en" "Velocity (oblivious)"
"en" "Velocity/autogain (oblivious)"
}
"Autostrafer_autogain_nsl"
{
"en" "Velocity (No speed loss) (oblivious)"
"en" "Velocity/autogain (No speed loss) (oblivious)"
}
"Autostrafer_basic"
{
Expand Down

0 comments on commit c2e5076

Please sign in to comment.