-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
337 additions
and
748 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
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
28 changes: 28 additions & 0 deletions
28
lang/Jailbreak.English/LastGuard/LastGuardNotifications.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,28 @@ | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
using Jailbreak.Formatting.Base; | ||
using Jailbreak.Formatting.Logistics; | ||
using Jailbreak.Formatting.Views; | ||
using Jailbreak.Formatting.Core; | ||
using Jailbreak.Formatting.Objects; | ||
|
||
namespace Jailbreak.English.LastGuard; | ||
|
||
public class LastGuardNotifications : ILastGuardNotifications, ILanguage<Formatting.Languages.English> | ||
{ | ||
public static FormatObject PREFIX = | ||
new HiddenFormatObject($" {ChatColors.Blue}[{ChatColors.LightBlue}Last Guard{ChatColors.Blue}]") | ||
{ | ||
// Hide in panorama and center text | ||
Plain = false, | ||
Panorama = false, | ||
Chat = true | ||
}; | ||
|
||
public IView LG_STARTED(int ctHealth, int tHealth) | ||
{ | ||
return new SimpleView() | ||
{ | ||
PREFIX, | ||
$"{ChatColors.Red}Last Guard has been activated! Last guard has", ctHealth, $"{ChatColors.Red}health and T's have", tHealth, $"{ChatColors.Red}health." }; | ||
} | ||
} |
49 changes: 0 additions & 49 deletions
49
lang/Jailbreak.English/SpecialDay/SpecialDayNotifications.cs
This file was deleted.
Oops, something went wrong.
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,101 @@ | ||
using CounterStrikeSharp.API; | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Core.Attributes.Registration; | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
using Jailbreak.Formatting.Extensions; | ||
using Jailbreak.Formatting.Views; | ||
using Jailbreak.Public.Behaviors; | ||
using Jailbreak.Public.Extensions; | ||
using Jailbreak.Public.Mod.LastGuard; | ||
using Jailbreak.Public.Mod.LastRequest; | ||
|
||
namespace Jailbreak.LastGuard; | ||
|
||
public class LastGuard : ILastGuardService, IPluginBehavior | ||
{ | ||
|
||
private readonly LastGuardConfig _config; | ||
private readonly ILastGuardNotifications _notifications; | ||
private readonly ILastRequestManager _lrManager; | ||
private bool _canStart = false; | ||
|
||
public LastGuard(LastGuardConfig config, ILastGuardNotifications notifications, ILastRequestManager lrManager) | ||
{ | ||
_config = config; | ||
_notifications = notifications; | ||
_lrManager = lrManager; | ||
} | ||
|
||
public void Start(BasePlugin plugin) | ||
{ | ||
|
||
} | ||
|
||
[GameEventHandler] | ||
public HookResult OnPlayerDeathEvent(EventPlayerDeath @event, GameEventInfo info) | ||
{ | ||
var target = @event.Userid; | ||
if (target == null) return HookResult.Continue; | ||
if (target.Team != CsTeam.CounterTerrorist) return HookResult.Continue; | ||
var aliveCts = Utilities.GetPlayers() | ||
.Count(plr => plr.IsReal() && plr is { PawnIsAlive: true, Team: CsTeam.CounterTerrorist }) - 1; | ||
|
||
if (aliveCts == 1 && !_lrManager.IsLREnabled) | ||
{ | ||
var lastGuard = Utilities.GetPlayers().First(plr => plr.IsReal() && plr != target && plr is { PawnIsAlive: true, Team: CsTeam.CounterTerrorist }); | ||
|
||
StartLastGuard(lastGuard); | ||
} | ||
return HookResult.Continue; | ||
} | ||
|
||
[GameEventHandler] | ||
public HookResult OnRoundStartEvent(EventRoundStart @event, GameEventInfo info) | ||
{ | ||
_canStart = Utilities.GetPlayers().Count(plr => plr.IsReal() && plr is { PawnIsAlive: true, Team: CsTeam.CounterTerrorist}) >= _config.MinimumCTs; | ||
return HookResult.Continue; | ||
} | ||
|
||
public int CalculateHealth() | ||
{ | ||
var aliveTerrorists = Utilities.GetPlayers() | ||
.Where(plr => plr.IsReal() && plr is { PawnIsAlive: true, Team: CsTeam.Terrorist }); | ||
|
||
foreach (var terrorist in aliveTerrorists) | ||
{ | ||
if (terrorist.PlayerPawn.Value?.Health > 100) terrorist.PlayerPawn.Value.Health = 100; | ||
} | ||
|
||
return aliveTerrorists.Select(player => player.PlayerPawn.Value.Health).Select(playerHealth => (int)(playerHealth * 0.45)).Sum(); | ||
} | ||
|
||
public void StartLastGuard(CCSPlayerController lastGuard) | ||
{ | ||
if (!_canStart) return; | ||
|
||
var ctPlayerPawn = lastGuard.PlayerPawn.Value; | ||
|
||
if (!ctPlayerPawn.IsValid) return; | ||
|
||
var ctHealth = ctPlayerPawn.Health; | ||
var ctCalcHealth = CalculateHealth(); | ||
|
||
ctPlayerPawn.Health = ctHealth > ctCalcHealth ? 125 : ctCalcHealth; | ||
|
||
Utilities.SetStateChanged(ctPlayerPawn, "CBaseEntity", "m_iHealth"); | ||
|
||
var aliveTerrorists = Utilities.GetPlayers() | ||
.Where(plr => plr.IsReal() && plr is { PawnIsAlive: true, Team: CsTeam.Terrorist }); | ||
|
||
|
||
_notifications.LG_STARTED(lastGuard.PlayerPawn.Value.Health, aliveTerrorists.Select(plr => plr.PlayerPawn.Value.Health).Sum()).ToAllCenter().ToAllChat(); | ||
Check warning on line 91 in mod/Jailbreak.LastGuard/LastGuard.cs GitHub Actions / build
|
||
|
||
if (string.IsNullOrEmpty(_config.LastGuardWeapon)) return; | ||
|
||
foreach (var player in aliveTerrorists) | ||
{ | ||
player.GiveNamedItem(_config.LastGuardWeapon); | ||
} | ||
|
||
} | ||
} |
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,7 @@ | ||
namespace Jailbreak.LastGuard; | ||
|
||
public class LastGuardConfig | ||
{ | ||
public string? LastGuardWeapon { get; } = "weapon_glock"; | ||
public int MinimumCTs { get; } = 4; | ||
} |
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,14 @@ | ||
using Jailbreak.Public.Extensions; | ||
using Jailbreak.Public.Mod.LastGuard; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Jailbreak.LastGuard; | ||
|
||
public static class RebelServiceExtension | ||
{ | ||
public static void AddJailbreakLastGuard(this IServiceCollection collection) | ||
{ | ||
collection.AddConfig<LastGuardConfig>("lastguard"); | ||
collection.AddPluginBehavior<ILastGuardService, LastGuard>(); | ||
} | ||
} |
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
Oops, something went wrong.