-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Unmute everyone on round start regardless of peace status * Dont enable LR if already enabled * Fix warden breaking after guaranteed warden rtd * Add count command * Cleanup
- Loading branch information
Showing
15 changed files
with
147 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
using Jailbreak.Formatting.Base; | ||
using Jailbreak.Formatting.Logistics; | ||
using Jailbreak.Formatting.Views.Warden; | ||
|
||
namespace Jailbreak.English.Warden; | ||
|
||
public class WardenCmdCountLocale : IWardenCmdCountLocale, | ||
ILanguage<Formatting.Languages.English> { | ||
public IView PrisonersInMarker(int prisoners) { | ||
return new SimpleView { | ||
WardenLocale.PREFIX, | ||
ChatColors.Grey + "There " + (prisoners == 1 ? "is" : " are"), | ||
prisoners, | ||
ChatColors.Grey + "prisoner" + (prisoners == 1 ? "" : "s") | ||
+ " in the marker." | ||
}; | ||
} | ||
|
||
public IView CannotCountYet(int seconds) { | ||
return new SimpleView { | ||
WardenLocale.PREFIX, | ||
"You must wait", | ||
seconds, | ||
"seconds before counting prisoners." | ||
}; | ||
} | ||
|
||
public IView NoMarkerSet | ||
=> new SimpleView { WardenLocale.PREFIX, "No marker set." }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Core.Attributes.Registration; | ||
using CounterStrikeSharp.API.Modules.Commands; | ||
using CounterStrikeSharp.API.Modules.Cvars; | ||
using CounterStrikeSharp.API.Modules.Cvars.Validators; | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
using Jailbreak.Formatting.Extensions; | ||
using Jailbreak.Formatting.Views.Warden; | ||
using Jailbreak.Public.Behaviors; | ||
using Jailbreak.Public.Mod.Warden; | ||
using Jailbreak.Public.Utils; | ||
|
||
namespace Jailbreak.Warden.Commands; | ||
|
||
public class CountCommandsBehavior(IWardenService warden, IWardenLocale msg, | ||
IWardenCmdCountLocale locale, IMarkerService markers) : IPluginBehavior { | ||
public static readonly FakeConVar<int> CV_COUNT_COMMAND_COOLDOWN = new( | ||
"css_jb_warden_count_cooldown", | ||
"Minimum seconds warden must wait before being able to count perisoners in marker.", | ||
30, customValidators: new RangeValidator<int>(0, 300)); | ||
|
||
[ConsoleCommand("css_count", "Counts the prisoners in marker")] | ||
public void Command_Count(CCSPlayerController? executor, CommandInfo info) { | ||
if (executor == null) return; | ||
if (!warden.IsWarden(executor)) { | ||
msg.NotWarden.ToChat(executor); | ||
return; | ||
} | ||
|
||
if (RoundUtil.GetTimeElapsed() < CV_COUNT_COMMAND_COOLDOWN.Value) { | ||
locale.CannotCountYet(CV_COUNT_COMMAND_COOLDOWN.Value).ToChat(executor); | ||
return; | ||
} | ||
|
||
if (markers.MarkerPosition == null) { | ||
locale.NoMarkerSet.ToChat(executor); | ||
return; | ||
} | ||
|
||
var prisoners = PlayerUtil.FromTeam(CsTeam.Terrorist) | ||
.Count(markers.InMarker); | ||
|
||
locale.PrisonersInMarker(prisoners); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
public/Jailbreak.Formatting/Views/Warden/IWardenCmdCountLocale.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Jailbreak.Formatting.Base; | ||
|
||
namespace Jailbreak.Formatting.Views.Warden; | ||
|
||
public interface IWardenCmdCountLocale { | ||
public IView NoMarkerSet { get; } | ||
public IView PrisonersInMarker(int prisoners); | ||
public IView CannotCountYet(int seconds); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
using Jailbreak.Public.Extensions; | ||
|
||
namespace Jailbreak.Public.Mod.Warden; | ||
|
||
public interface IMarkerService { | ||
Vector? MarkerPosition { get; } | ||
float radius { get; } | ||
|
||
public bool InMarker(Vector pos) { | ||
if (MarkerPosition == null) return false; | ||
var widenedRadius = radius + 32; | ||
return MarkerPosition.DistanceSquared(pos) <= widenedRadius * widenedRadius; | ||
} | ||
|
||
public bool InMarker(CCSPlayerController player) { | ||
if (MarkerPosition == null) return false; | ||
var pos = player.PlayerPawn.Value?.AbsOrigin; | ||
return pos != null && InMarker(pos); | ||
} | ||
} |