Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add teleport to stage start command #1207

Merged
merged 8 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/shavit-checkpoints.sp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public void OnPluginStart()
RegConsoleCmd("sm_checkpoints", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu.");
RegConsoleCmd("sm_save", Command_Save, "Saves a checkpoint.");
RegConsoleCmd("sm_tele", Command_Tele, "Teleports to a checkpoint. Usage: sm_tele [number]");
RegConsoleCmd("sm_teleport", Command_Tele, "Teleports to a checkpoint. Usage: sm_tele [number]");
RegConsoleCmd("sm_prevcp", Command_PrevCheckpoint, "Selects the previous checkpoint.");
RegConsoleCmd("sm_nextcp", Command_NextCheckpoint, "Selects the next checkpoint.");
RegConsoleCmd("sm_deletecp", Command_DeleteCheckpoint, "Deletes the current checkpoint.");
Expand Down
55 changes: 55 additions & 0 deletions addons/sourcemod/scripting/shavit-zones.sp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ public void OnPluginStart()
RegConsoleCmd("sm_stage", Command_Stages, "Opens the stage menu. Usage: sm_stage [stage #]");
RegConsoleCmd("sm_s", Command_Stages, "Opens the stage menu. Usage: sm_s [stage #]");

RegConsoleCmd("sm_rs", Command_StageRestart, "Teleports the player to the current stage. Only works on surf maps.");
RegConsoleCmd("sm_stagerestart", Command_StageRestart, "Teleports the player to the current stage. Only works on surf maps.");
RegConsoleCmd("sm_restartstage", Command_StageRestart, "Teleports the player to the current stage. Only works on surf maps.");

RegConsoleCmd("sm_set", Command_SetStart, "Set current position as spawn location in start zone.");
RegConsoleCmd("sm_setstart", Command_SetStart, "Set current position as spawn location in start zone.");
RegConsoleCmd("sm_ss", Command_SetStart, "Set current position as spawn location in start zone.");
Expand Down Expand Up @@ -2462,6 +2466,57 @@ public Action Command_Stages(int client, int args)
return Plugin_Handled;
}

public Action Command_StageRestart(int client, int args)
{
// This command should only work on surf maps for now
// There are quite a few bhop maps that have checkpoint triggers and this command would ruin those maps
// Ideally there would be a zone-based solution to this problem
if(!IsValidClient(client) || strncmp(gS_Map, "surf_", 5))
{
return Plugin_Handled;
}

if(!IsPlayerAlive(client))
{
Shavit_PrintToChat(client, "%T", "StageCommandAlive", client);
return Plugin_Handled;
}

int last = gI_LastStage[client];
int track = Shavit_GetClientTrack(client);

// crude way to prevent cheesing
if (InsideZone(client, Zone_Stage, track) || InsideZone(client, Zone_Start, -1))
{
return Plugin_Handled;
}

if (last <= 0)
{
Shavit_RestartTimer(client, track);
}
else
{
for(int i = 0; i < gI_MapZones; i++)
{
if (gA_ZoneCache[i].iType == Zone_Stage && gA_ZoneCache[i].iData == last && gA_ZoneCache[i].iTrack == track)
{
if (!EmptyVector(gA_ZoneCache[i].fDestination))
{
TeleportEntity(client, gA_ZoneCache[i].fDestination, NULL_VECTOR, view_as<float>({0.0, 0.0, 0.0}));
}
else
{
TeleportEntity(client, gV_ZoneCenter[i], NULL_VECTOR, view_as<float>({0.0, 0.0, 0.0}));
}
}
}
}

return Plugin_Handled;
}


public int MenuHandler_SelectStage(Menu menu, MenuAction action, int param1, int param2)
{
if(action == MenuAction_Select)
Expand Down
Loading