diff --git a/addons/sourcemod/configs/shavit-zones.cfg b/addons/sourcemod/configs/shavit-zones.cfg index ef1eaa57..b9aa15ab 100644 --- a/addons/sourcemod/configs/shavit-zones.cfg +++ b/addons/sourcemod/configs/shavit-zones.cfg @@ -219,6 +219,20 @@ "width" "0.1" } + "Pause" + { + "visible" "1" + + "red" "10" + "green" "10" + "blue" "255" + + "alpha" "255" + "width" "0.3" + + "flat" "1" + } + "Bonus 1 Start" { "visible" "1" diff --git a/addons/sourcemod/scripting/include/shavit/zones.inc b/addons/sourcemod/scripting/include/shavit/zones.inc index f62a8c2c..4b3f4ff7 100644 --- a/addons/sourcemod/scripting/include/shavit/zones.inc +++ b/addons/sourcemod/scripting/include/shavit/zones.inc @@ -47,6 +47,7 @@ enum Zone_Speedmod, // creates a player_speedmod Zone_NoJump, // blocks the player from jumping while inside the zone Zone_Autobhop, // forces autobhop for the player + Zone_Pause, // pause the player's timer ZONETYPES_SIZE }; @@ -140,6 +141,7 @@ stock void GetZoneName(int client, int zoneType, char[] output, int size) "Zone_Speedmod", "Zone_NoJump", "Zone_Autobhop", + "Zone_Pause", }; if (zoneType < 0 || zoneType >= ZONETYPES_SIZE) diff --git a/addons/sourcemod/scripting/shavit-core.sp b/addons/sourcemod/scripting/shavit-core.sp index 2c8a3da6..2f2e17e3 100644 --- a/addons/sourcemod/scripting/shavit-core.sp +++ b/addons/sourcemod/scripting/shavit-core.sp @@ -3353,7 +3353,9 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3 int flags = GetEntityFlags(client); - if (gA_Timers[client].bClientPaused && IsPlayerAlive(client) && !gCV_PauseMovement.BoolValue) + int track = Shavit_GetClientTrack(client); + + if (gA_Timers[client].bClientPaused && IsPlayerAlive(client) && !gCV_PauseMovement.BoolValue && !Shavit_InsideZone(client, Zone_Pause, track)) { buttons = 0; vel = view_as({0.0, 0.0, 0.0}); diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index ccf26fb9..4e1f7d9c 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -2454,7 +2454,7 @@ public void Shavit_OnRestart(int client, int track) { SetEntPropFloat(client, Prop_Send, "m_flStamina", 0.0); - if (gCV_RestartWithFullHP.BoolValue) + if (gCV_RestartWithFullHP.BoolValue && GetClientHealth(client) < 100) { SetEntityHealth(client, 100); SetEntProp(client, Prop_Send, "m_ArmorValue", 100); diff --git a/addons/sourcemod/scripting/shavit-zones-json.sp b/addons/sourcemod/scripting/shavit-zones-json.sp index dcd5c594..1749aae8 100644 --- a/addons/sourcemod/scripting/shavit-zones-json.sp +++ b/addons/sourcemod/scripting/shavit-zones-json.sp @@ -53,7 +53,8 @@ static char gS_ZoneTypes[ZONETYPES_SIZE][18] = { "gravity", "speedmod", "nojump", - "autobhop" + "autobhop", + "pause" }; static char gS_ZoneForms[5][26] = { diff --git a/addons/sourcemod/scripting/shavit-zones.sp b/addons/sourcemod/scripting/shavit-zones.sp index 170e555c..8d4a233e 100644 --- a/addons/sourcemod/scripting/shavit-zones.sp +++ b/addons/sourcemod/scripting/shavit-zones.sp @@ -131,6 +131,7 @@ Convar gCV_PrebuiltZones = null; Convar gCV_ClimbButtons = null; Convar gCV_Interval = null; Convar gCV_TeleportToStart = null; +Convar gCV_TeleportToStartOnSpawn = null; Convar gCV_TeleportToEnd = null; Convar gCV_AllowDrawAllZones = null; Convar gCV_UseCustomSprite = null; @@ -334,6 +335,7 @@ public void OnPluginStart() gCV_ClimbButtons = new Convar("shavit_zones_usebuttons", "1", "Whether to automatically hook climb_* buttons.", 0, true, 0.0, true, 1.0); gCV_Interval = new Convar("shavit_zones_interval", "1.0", "Interval between each time a mapzone is being drawn to the players.", 0, true, 0.25, true, 5.0); gCV_TeleportToStart = new Convar("shavit_zones_teleporttostart", "1", "Teleport players to the start zone on timer restart?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0); + gCV_TeleportToStartOnSpawn = new Convar("shavit_zones_teleporttostart_onspawn", "1", "Teleport players to the start zone on player spawn?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0); gCV_TeleportToEnd = new Convar("shavit_zones_teleporttoend", "1", "Teleport players to the end zone on sm_end?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0); gCV_AllowDrawAllZones = new Convar("shavit_zones_allowdrawallzones", "1", "Allow players to use !drawallzones to see all zones regardless of zone visibility settings.\n0 - nobody can use !drawallzones\n1 - admins (sm_zones access) can use !drawallzones\n2 - anyone can use !drawallzones", 0, true, 0.0, true, 2.0); gCV_UseCustomSprite = new Convar("shavit_zones_usecustomsprite", "1", "Use custom sprite for zone drawing?\nSee `configs/shavit-zones.cfg`.\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0); @@ -1013,6 +1015,7 @@ bool JumpToZoneType(KeyValues kv, int type, int track) {"Speedmod", ""}, {"No Jump", ""}, {"Autobhop", ""}, + {"Pause", ""}, }; char key[4][50]; @@ -2822,6 +2825,7 @@ public int MenuHandler_HookZone_Editor(Menu menu, MenuAction action, int param1, | (1 << Zone_Speedmod) | (1 << Zone_NoJump) | (1 << Zone_Autobhop) + | (1 << Zone_Pause) // ZoneForm_trigger_teleport , (1 << Zone_End) | (1 << Zone_Respawn) @@ -5071,60 +5075,7 @@ public void Shavit_OnRestart(int client, int track) if(gCV_TeleportToStart.BoolValue) { - bool bCustomStart = gB_HasSetStart[client][track] && !gB_StartAnglesOnly[client][track]; - bool use_CustomStart_over_CustomSpawn = (iIndex != -1) && bCustomStart; - - // custom spawns - if (!use_CustomStart_over_CustomSpawn && !EmptyVector(gF_CustomSpawn[track])) - { - float pos[3]; pos = gF_CustomSpawn[track]; pos[2] += 1.0; - TeleportEntity(client, pos, NULL_VECTOR, ZERO_VECTOR); - } - // standard zoning - else if (bCustomStart || iIndex != -1) - { - float fCenter[3]; - - if (bCustomStart) - { - fCenter = gF_StartPos[client][track]; - } - else - { - fCenter[0] = gV_ZoneCenter[iIndex][0]; - fCenter[1] = gV_ZoneCenter[iIndex][1]; - fCenter[2] = gA_ZoneCache[iIndex].fCorner1[2] + gCV_ExtraSpawnHeight.FloatValue; - } - - fCenter[2] += 1.0; - - TeleportEntity(client, fCenter, gB_HasSetStart[client][track] ? gF_StartAng[client][track] : NULL_VECTOR, view_as({0.0, 0.0, 0.0})); - - if (gB_ReplayRecorder && gB_HasSetStart[client][track]) - { - Shavit_HijackAngles(client, gF_StartAng[client][track][0], gF_StartAng[client][track][1], -1, true); - } - - if (!gB_HasSetStart[client][track] || gB_StartAnglesOnly[client][track]) - { - ResetClientTargetNameAndClassName(client, track); - // normally StartTimer will happen on zone-touch BUT we have this here for zones that are in the air - bool skipGroundCheck = true; - Shavit_StartTimer(client, track, skipGroundCheck); - } - } - // kz buttons - else if (Shavit_IsKZMap(track)) - { - if (EmptyVector(gF_ClimbButtonCache[client][track][0]) || EmptyVector(gF_ClimbButtonCache[client][track][1])) - { - return; - } - - TeleportEntity(client, gF_ClimbButtonCache[client][track][0], gF_ClimbButtonCache[client][track][1], view_as({0.0, 0.0, 0.0})); - - return; - } + TeleportToStart(client, iIndex, track); } if (iIndex != -1) @@ -5214,7 +5165,74 @@ int GetZoneIndex(int type, int track, int start = 0) public void Player_Spawn(Event event, const char[] name, bool dontBroadcast) { - Reset(GetClientOfUserId(event.GetInt("userid"))); + int client = GetClientOfUserId(event.GetInt("userid")); + int track = Shavit_GetClientTrack(client); + int iIndex = GetZoneIndex(Zone_Start, track); + + Reset(client); + + if(GetConVarBool(gCV_TeleportToStartOnSpawn) && (Shavit_ZoneExists(Zone_Start, track) || Shavit_IsKZMap(track))) + { + TeleportToStart(client, iIndex, track); + } +} + +public void TeleportToStart(int client, int iIndex, int track) +{ + bool bCustomStart = gB_HasSetStart[client][track] && !gB_StartAnglesOnly[client][track]; + bool use_CustomStart_over_CustomSpawn = (iIndex != -1) && bCustomStart; + + // custom spawns + if (!use_CustomStart_over_CustomSpawn && !EmptyVector(gF_CustomSpawn[track])) + { + float pos[3]; pos = gF_CustomSpawn[track]; pos[2] += 1.0; + TeleportEntity(client, pos, NULL_VECTOR, ZERO_VECTOR); + } + // standard zoning + else if (bCustomStart || iIndex != -1) + { + float fCenter[3]; + + if (bCustomStart) + { + fCenter = gF_StartPos[client][track]; + } + else + { + fCenter[0] = gV_ZoneCenter[iIndex][0]; + fCenter[1] = gV_ZoneCenter[iIndex][1]; + fCenter[2] = gA_ZoneCache[iIndex].fCorner1[2] + gCV_ExtraSpawnHeight.FloatValue; + } + + fCenter[2] += 1.0; + + TeleportEntity(client, fCenter, gB_HasSetStart[client][track] ? gF_StartAng[client][track] : NULL_VECTOR, view_as({0.0, 0.0, 0.0})); + + if (gB_ReplayRecorder && gB_HasSetStart[client][track]) + { + Shavit_HijackAngles(client, gF_StartAng[client][track][0], gF_StartAng[client][track][1], -1, true); + } + + if (!gB_HasSetStart[client][track] || gB_StartAnglesOnly[client][track]) + { + ResetClientTargetNameAndClassName(client, track); + // normally StartTimer will happen on zone-touch BUT we have this here for zones that are in the air + bool skipGroundCheck = true; + Shavit_StartTimer(client, track, skipGroundCheck); + } + } + // kz buttons + else if (Shavit_IsKZMap(track)) + { + if (EmptyVector(gF_ClimbButtonCache[client][track][0]) || EmptyVector(gF_ClimbButtonCache[client][track][1])) + { + return; + } + + TeleportEntity(client, gF_ClimbButtonCache[client][track][0], gF_ClimbButtonCache[client][track][1], view_as({0.0, 0.0, 0.0})); + + return; + } } public void Round_Start(Event event, const char[] name, bool dontBroadcast) @@ -5409,6 +5427,15 @@ public void StartTouchPost(int entity, int other) SetVariantString(s); AcceptEntityInput(entity, "ModifySpeed", other, entity, 0); } + + case Zone_Pause: + { + if(Shavit_GetTimerStatus(other) != Timer_Stopped) + { + Shavit_PauseTimer(other); + //Should we print? + } + } } gI_InsideZone[other][track] |= (1 << type); @@ -5464,6 +5491,11 @@ public void EndTouchPost(int entity, int other) AcceptEntityInput(entity, "ModifySpeed", other, entity, 0); } + if (type == Zone_Pause) + { + Shavit_ResumeTimer(other); + } + Call_StartForward(gH_Forwards_LeaveZone); Call_PushCell(other); Call_PushCell(type); diff --git a/addons/sourcemod/translations/shavit-zones.phrases.txt b/addons/sourcemod/translations/shavit-zones.phrases.txt index 07b9b842..4a00a4cc 100644 --- a/addons/sourcemod/translations/shavit-zones.phrases.txt +++ b/addons/sourcemod/translations/shavit-zones.phrases.txt @@ -533,6 +533,10 @@ { "en" "Autobhop Zone" } + "Zone_Pause" + { + "en" "Pause Zone" + } "Zone_Unknown" { "en" "UNKNOWN ZONE"