Skip to content

Commit

Permalink
Add no-jump and autobhop zones. (#1216)
Browse files Browse the repository at this point in the history
* Make no jump zone appear in menu

* Preliminary implementation of nojump zone

* Add scaffolding for autobhop zone

* Add implementation of autobhop zone

* Add new zone types to shavit-zones-json

* some touchups for the autobhop & nojump zones

---------

Co-authored-by: rtldg <rtldg@protonmail.com>
  • Loading branch information
Awesomerly and rtldg authored Aug 20, 2024
1 parent 2a23c05 commit c9cfbef
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 2 deletions.
48 changes: 48 additions & 0 deletions addons/sourcemod/configs/shavit-zones.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,30 @@
"width" "1.0"
}
"No Jump"
{
"visible" "0"
"red" "255"
"green" "0"
"blue" "255"
"alpha" "255"
"width" "0.1"
}
"Autobhop"
{
"visible" "0"
"red" "255"
"green" "0"
"blue" "255"
"alpha" "255"
"width" "0.1"
}
"Bonus 1 Start"
{
"visible" "1"
Expand Down Expand Up @@ -374,5 +398,29 @@
"alpha" "255"
"width" "1.0"
}
"Bonus 1 No Jump"
{
"visible" "0"
"red" "255"
"green" "0"
"blue" "255"
"alpha" "255"
"width" "0.1"
}
"Bonus 1 Autobhop"
{
"visible" "0"
"red" "255"
"green" "0"
"blue" "255"
"alpha" "255"
"width" "0.1"
}
}
}
4 changes: 4 additions & 0 deletions addons/sourcemod/scripting/include/shavit/zones.inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ enum
Zone_NoTimerGravity, // prevents the timer from setting gravity while inside this zone
Zone_Gravity, // lets you set a specific gravity while inside this zone
Zone_Speedmod, // creates a player_speedmod
Zone_NoJump, // blocks the player from jumping while inside the zone
Zone_Autobhop, // forces autobhop for the player
ZONETYPES_SIZE
};

Expand Down Expand Up @@ -136,6 +138,8 @@ stock void GetZoneName(int client, int zoneType, char[] output, int size)
"Zone_NoTimerGravity",
"Zone_Gravity",
"Zone_Speedmod",
"Zone_NoJump",
"Zone_Autobhop",
};

if (zoneType < 0 || zoneType >= ZONETYPES_SIZE)
Expand Down
15 changes: 14 additions & 1 deletion addons/sourcemod/scripting/shavit-core.sp
Original file line number Diff line number Diff line change
Expand Up @@ -3553,7 +3553,14 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
bool bInWater = (GetEntProp(client, Prop_Send, "m_nWaterLevel") >= 2);
int iOldButtons = GetEntProp(client, Prop_Data, "m_nOldButtons");

if (GetStyleSettingBool(gA_Timers[client].bsStyle, "autobhop") && gB_Auto[client] && (buttons & IN_JUMP) > 0 && mtMoveType == MOVETYPE_WALK && !bInWater)
if ( gB_Auto[client]
&& (buttons & IN_JUMP) > 0
&& mtMoveType == MOVETYPE_WALK
&& !bInWater
&& ( GetStyleSettingBool(gA_Timers[client].bsStyle, "autobhop")
|| (gB_Zones && Shavit_InsideZone(client, Zone_Autobhop, gA_Timers[client].iTimerTrack))
)
)
{
SetEntProp(client, Prop_Data, "m_nOldButtons", (iOldButtons &= ~IN_JUMP));
}
Expand All @@ -3571,6 +3578,12 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
buttons &= ~IN_JUMP;
}

if (gB_Zones && Shavit_InsideZone(client, Zone_NoJump, gA_Timers[client].iTimerTrack))
{
vel[2] = 0.0;
buttons &= ~IN_JUMP;
}

// enable duck-jumping/bhop in tf2
if (gEV_Type == Engine_TF2 && GetStyleSettingBool(gA_Timers[client].bsStyle, "bunnyhopping") && (buttons & IN_JUMP) > 0 && !(iOldButtons & IN_JUMP) && iGroundEntity != -1)
{
Expand Down
2 changes: 2 additions & 0 deletions addons/sourcemod/scripting/shavit-zones-json.sp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ static char gS_ZoneTypes[ZONETYPES_SIZE][18] = {
"notimergravity",
"gravity",
"speedmod",
"nojump",
"autobhop"
};

static char gS_ZoneForms[5][26] = {
Expand Down
7 changes: 6 additions & 1 deletion addons/sourcemod/scripting/shavit-zones.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,8 @@ bool JumpToZoneType(KeyValues kv, int type, int track)
{"No Timer Gravity", ""},
{"Gravity", ""},
{"Speedmod", ""},
{"No Jump", ""},
{"Autobhop", ""},
};

char key[4][50];
Expand Down Expand Up @@ -1813,7 +1815,10 @@ public void OnClientCookiesCached(int client)

int p = 1;

for (int type = Zone_Start; type < ZONETYPES_SIZE; type++)
// TODO: ZONETYPES_SIZE is too big now so we'll have to come back to do something about this...
// Just make another cookie :pepega: or maybe store the settings in the DB rather than cookie.
//for (int type = Zone_Start; type < ZONETYPES_SIZE; type++)
for (int type = Zone_Start; type <= Zone_Speedmod; type++)
{
for (int track = Track_Main; track <= Track_Bonus; track++)
{
Expand Down
8 changes: 8 additions & 0 deletions addons/sourcemod/translations/shavit-zones.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,14 @@
{
"en" "Speedmod Zone"
}
"Zone_NoJump"
{
"en" "No Jump Zone"
}
"Zone_Autobhop"
{
"en" "Autobhop Zone"
}
"Zone_Unknown"
{
"en" "UNKNOWN ZONE"
Expand Down

0 comments on commit c9cfbef

Please sign in to comment.