-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add noscope reward
- Loading branch information
Showing
12 changed files
with
157 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System.Collections.Immutable; | ||
using CounterStrikeSharp.API; | ||
using CounterStrikeSharp.API.Core; | ||
using Jailbreak.Public.Extensions; | ||
using Jailbreak.Public.Mod.RTD; | ||
|
||
namespace Jailbreak.RTD.Rewards; | ||
|
||
public class CannotScopeReward : IRTDReward { | ||
private readonly BasePlugin plugin; | ||
|
||
public CannotScopeReward(BasePlugin plugin, WeaponType blocked) : this(plugin, | ||
blocked.GetItems().ToArray()) { } | ||
|
||
public CannotScopeReward(BasePlugin plugin, params string[] weapons) { | ||
this.plugin = plugin; | ||
this.plugin.RegisterEventHandler<EventRoundEnd>(onRoundEnd); | ||
} | ||
|
||
public string Name => "Cannot Scope"; | ||
|
||
public string Description | ||
=> $"You will not be able to pickup {Name} the next round."; | ||
|
||
private bool registered; | ||
|
||
private readonly HashSet<int> blockedPlayerIDs = []; | ||
|
||
public bool GrantReward(CCSPlayerController player) { | ||
if (player.UserId == null) return false; | ||
if (!registered) { | ||
plugin.RegisterListener<Listeners.OnTick>(onTick); | ||
registered = true; | ||
} | ||
|
||
blockedPlayerIDs.Add(player.UserId.Value); | ||
return true; | ||
} | ||
|
||
private HookResult onRoundEnd(EventRoundEnd @event, GameEventInfo info) { | ||
blockedPlayerIDs.Clear(); | ||
plugin.RemoveListener<Listeners.OnTick>(onTick); | ||
registered = false; | ||
return HookResult.Continue; | ||
} | ||
|
||
private void onTick() { | ||
registered = true; | ||
if (blockedPlayerIDs.Count == 0) { | ||
plugin.RemoveListener<Listeners.OnTick>(onTick); | ||
registered = false; | ||
return; | ||
} | ||
|
||
foreach (var player in blockedPlayerIDs.Select( | ||
Utilities.GetPlayerFromUserid)) { | ||
if (player == null || player.UserId == null || !player.IsValid) continue; | ||
disableScope(player); | ||
} | ||
} | ||
|
||
private void disableScope(CCSPlayerController player) { | ||
if (!player.IsReal()) return; | ||
var pawn = player.PlayerPawn.Value; | ||
if (pawn == null || !pawn.IsValid) return; | ||
var weaponServices = pawn.WeaponServices; | ||
if (weaponServices == null) return; | ||
var activeWeapon = weaponServices.ActiveWeapon.Value; | ||
if (activeWeapon == null || !activeWeapon.IsValid) return; | ||
activeWeapon.NextSecondaryAttackTick = Server.TickCount + 500; | ||
} | ||
} |
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,23 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
using Jailbreak.Public.Mod.RTD; | ||
using Jailbreak.Public.Mod.Warden; | ||
|
||
namespace Jailbreak.RTD.Rewards; | ||
|
||
public class GuaranteedWardenReward(IWardenSelectionService service) | ||
: IRTDReward { | ||
public string Name => "Guaranteed Warden"; | ||
|
||
public string Description | ||
=> "You are guaranteed to be warden next round if you queue for it"; | ||
|
||
public bool CanGrantReward(CCSPlayerController player) { | ||
return player.Team == CsTeam.CounterTerrorist; | ||
} | ||
|
||
public bool GrantReward(CCSPlayerController player) { | ||
service.SetGuaranteedWarden(player); | ||
return true; | ||
} | ||
} |
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