Skip to content

Commit

Permalink
Bug Fixes (#229)
Browse files Browse the repository at this point in the history
- Fixed LR not being properly resolved
- Removed glocks from last guard
- LRs that TP the CT will now freeze the prisoner for 1 second longer
than the CT.
  • Loading branch information
MSWS authored Jul 16, 2024
2 parents 8565a87 + 29bdf88 commit 7a738c2
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 124 deletions.
43 changes: 36 additions & 7 deletions lang/Jailbreak.English/LastRequest/LastRequestMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Jailbreak.Formatting.Logistics;
using Jailbreak.Formatting.Objects;
using Jailbreak.Formatting.Views;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;

Expand Down Expand Up @@ -80,13 +81,41 @@ public IView AnnounceLastRequest(AbstractLastRequest lr) {
}

public IView LastRequestDecided(AbstractLastRequest lr, LRResult result) {
return new SimpleView {
PREFIX,
(result == LRResult.GUARD_WIN ? ChatColors.Blue : ChatColors.Red)
.ToString(),
result == LRResult.PRISONER_WIN ? lr.Prisoner : lr.Guard,
"won the LR."
};
var tNull = !lr.Prisoner.IsReal();
var gNull = !lr.Guard.IsReal();
if (tNull && gNull)
return new SimpleView() { PREFIX, "Last Request has been decided." };

if (tNull && result == LRResult.PRISONER_WIN) {
return new SimpleView() {
PREFIX, lr.Guard!, "lost the LR, but the prisoner left the game."
};
}

if (gNull && result == LRResult.GUARD_WIN) {
return new SimpleView() {
PREFIX, lr.Prisoner!, "lost the LR, but the guard left the game."
};
}

switch (result) {
case LRResult.TIMED_OUT:
return new SimpleView() {
PREFIX, ChatColors.Grey.ToString(), "Last Request has timed out."
};
case LRResult.INTERRUPTED:
return new SimpleView() {
PREFIX,
ChatColors.Grey.ToString(),
"Last Request has been interrupted."
};
default:
return new SimpleView {
PREFIX,
result == LRResult.PRISONER_WIN ? lr.Prisoner! : lr.Guard!,
"won the LR."
};
}
}

public IView CannotLR(string reason) {
Expand Down
2 changes: 1 addition & 1 deletion mod/Jailbreak.LastGuard/LastGuardConfig.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Jailbreak.LastGuard;

public class LastGuardConfig {
public string? LastGuardWeapon { get; } = "weapon_glock";
public string? LastGuardWeapon { get; } = "";
public int MinimumCTs { get; } = 4;
}
8 changes: 3 additions & 5 deletions mod/Jailbreak.LastRequest/LastRequestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ public HookResult OnTakeDamage(EventPlayerHurt @event, GameEventInfo info) {

[GameEventHandler]
public HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info) {
if (IsLREnabled)
foreach (var lr in ActiveLRs)
EndLastRequest(lr, LRResult.TIMED_OUT);
foreach (var lr in ActiveLRs.ToList())
EndLastRequest(lr, LRResult.TIMED_OUT);

IsLREnabled = false;
return HookResult.Continue;
Expand All @@ -134,8 +133,7 @@ public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) {
return HookResult.Continue;
}

IsLREnabled = true;
messages.LastRequestEnabled().ToAllChat();
EnableLR();
return HookResult.Continue;
}

Expand Down
8 changes: 2 additions & 6 deletions mod/Jailbreak.LastRequest/LastRequests/GunToss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ namespace Jailbreak.LastRequest.LastRequests;

public class GunToss(BasePlugin plugin, ILastRequestManager manager,
CCSPlayerController prisoner, CCSPlayerController guard)
: AbstractLastRequest(plugin, manager, prisoner, guard) {
: TeleportingRequest(plugin, manager, prisoner, guard) {
public override LRType Type => LRType.GUN_TOSS;

public override void Setup() {
// Strip weapons, teleport T to CT
Prisoner.RemoveWeapons();
Guard.RemoveWeapons();
Guard.Teleport(Prisoner);
State = LRState.PENDING;
base.Setup();

Plugin.AddTimer(3, Execute);
}
Expand Down
2 changes: 1 addition & 1 deletion mod/Jailbreak.LastRequest/LastRequests/NoScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public override void Execute() {

public override void OnEnd(LRResult result) {
State = LRState.COMPLETED;
Plugin.RemoveListener(OnTick);
Plugin.RemoveListener<Listeners.OnTick>(OnTick);

if (result != LRResult.GUARD_WIN && result != LRResult.PRISONER_WIN) return;

Expand Down
2 changes: 2 additions & 0 deletions mod/Jailbreak.LastRequest/LastRequests/TeleportingRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public override void Setup() {
Prisoner.Freeze();
Plugin.AddTimer(1, () => {
Guard.UnFreeze();
});
Plugin.AddTimer(2, () => {
Prisoner.UnFreeze();
});
}
Expand Down
103 changes: 64 additions & 39 deletions mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
Original file line number Diff line number Diff line change
@@ -1,65 +1,90 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using Jailbreak.Formatting.Views.Logging;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;

namespace Jailbreak.Logs.Listeners;

public class LogEntityParentListeners(IRichLogService logs) : IPluginBehavior {
private static readonly string[] WEAPON_STRINGS = [
"weapon_ak47", "weapon_aug", "weapon_awp", "weapon_bizon", "weapon_cz75a",
"weapon_deagle", "weapon_famas", "weapon_fiveseven", "weapon_g3sg1",
public class LogEntityParentListeners(IRichLogService logs) : IPluginBehavior
{
private static readonly string[] WEAPON_STRINGS = [
"weapon_ak47", "weapon_aug", "weapon_awp", "weapon_bizon", "weapon_cz75a",
"weapon_deagle", "weapon_elite", "weapon_famas", "weapon_fiveseven", "weapon_g3sg1",
"weapon_galilar", "weapon_glock", "weapon_hkp2000", "weapon_m249",
"weapon_m4a1", "weapon_m4a1_silencer", "weapon_m4a4", "weapon_mac10",
"weapon_mag7", "weapon_mp5sd", "weapon_mp7", "weapon_mp9", "weapon_negev",
"weapon_nova", "weapon_p250", "weapon_p90", "weapon_revolver",
"weapon_sawedoff", "weapon_scar20", "weapon_sg553", "weapon_sg556",
"weapon_ssg08", "weapon_taser", "weapon_tec9", "weapon_ump45",
"weapon_usp_silencer", "weapon_xm1014"
];
"weapon_usp_silencer", "weapon_xm1014", "item_kevlar", "item_assaultsuit",
"weapon_snowball", "weapon_shield", "weapon_c4", "weapon_healthshot",
"weapon_breachcharge", "weapon_tablet", "weapon_bumpmine", "weapon_smokegrenade",
"weapon_flashbang", "weapon_hegrenade", "weapon_molotov", "weapon_incgrenade",
"weapon_decoy", "weapon_tagrenade", "weapon_frag", "weapon_firebomb",
"weapon_diversion", "weapon_knife_t", "weapon_knife"
];

public void Start(BasePlugin _parent) {
_parent
.RegisterListener<
CounterStrikeSharp.API.Core.Listeners.OnEntityParentChanged>(
OnEntityParentChanged);
}
private readonly HashSet<int> recentWeaponEvents = new();

public void OnEntityParentChanged(CEntityInstance affectedEntity,
CEntityInstance newParent) {
if (!affectedEntity.IsValid
|| !WEAPON_STRINGS.Contains(affectedEntity.DesignerName))
return;
public void Start(BasePlugin _parent)
{
_parent
.RegisterListener<
CounterStrikeSharp.API.Core.Listeners.OnEntityParentChanged>(
OnEntityParentChanged);
}

var weaponEntity =
Utilities.GetEntityFromIndex<CCSWeaponBase>((int)affectedEntity.Index);
if (weaponEntity == null
|| weaponEntity.PrevOwner.Get()?.OriginalController.Get() == null)
return;
public void OnEntityParentChanged(CEntityInstance affectedEntity,
CEntityInstance newParent)
{
if (!affectedEntity.IsValid
|| !WEAPON_STRINGS.Contains(affectedEntity.DesignerName))
return;

var weaponOwner = weaponEntity.PrevOwner.Get()?.OriginalController.Get();
if (weaponOwner == null) return;
var weaponEntity =
Utilities.GetEntityFromIndex<CCSWeaponBase>((int)affectedEntity.Index);
if (weaponEntity == null
|| weaponEntity.PrevOwner.Get()?.OriginalController.Get() == null)
return;

if (!newParent.IsValid) // a.k.a parent is world
{
logs.Append(logs.Player(weaponOwner),
$"dropped their {weaponEntity.ToFriendlyString()}");
return;
}
var weaponOwner = weaponEntity.PrevOwner.Get()?.OriginalController.Get();
if (weaponOwner == null) return;

var weaponPickerUpper = Utilities
if (!newParent.IsValid) // a.k.a parent is world
{
logs.Append(logs.Player(weaponOwner),
$"dropped their {weaponEntity.ToFriendlyString()}");
return;
}

if (!recentWeaponEvents.Add((int)weaponEntity.Index))
{
recentWeaponEvents.Remove((int)weaponEntity.Index);
return;
}

var weaponPickerUpper = Utilities
.GetEntityFromIndex<CCSPlayerPawn>((int)newParent.Index)
?.OriginalController.Get();
if (weaponPickerUpper == null) return;
if (weaponPickerUpper == null) return;

if (weaponPickerUpper == weaponOwner)
{
logs.Append(weaponPickerUpper,
$"picked up their {weaponEntity.ToFriendlyString()}");
return;
}

if (weaponPickerUpper == weaponOwner) {
logs.Append(weaponPickerUpper,
$"picked up their {weaponEntity.ToFriendlyString()}");
return;
logs.Append(weaponPickerUpper, "picked up", logs.Player(weaponOwner),
$"{weaponEntity.ToFriendlyString()}");
}

logs.Append(weaponPickerUpper, "picked up", logs.Player(weaponOwner),
$"{weaponEntity.ToFriendlyString()}");
}
[GameEventHandler]
public HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
{
recentWeaponEvents.Clear();
return HookResult.Continue;
}
}
4 changes: 3 additions & 1 deletion mod/Jailbreak.Mute/MuteSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ public void Start(BasePlugin basePlugin) {
basePlugin.RegisterListener<Listeners.OnClientVoice>(OnPlayerSpeak);
}

public void Dispose() { parent!.RemoveListener(OnPlayerSpeak); }
public void Dispose() {
parent!.RemoveListener<Listeners.OnClientVoice>(OnPlayerSpeak);
}

[GameEventHandler]
public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) {
Expand Down
46 changes: 45 additions & 1 deletion public/Jailbreak.Public/Extensions/WeaponExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public static string ToFriendlyString(this CCSWeaponBase weaponEntity) {
return "CZ75";
case "weapon_deagle":
return "Desert Eagle";
case "weapon_elite":
return "Dualies";
case "weapon_famas":
return "Famas";
case "weapon_fiveseven":
Expand Down Expand Up @@ -78,8 +80,50 @@ public static string ToFriendlyString(this CCSWeaponBase weaponEntity) {
return "USPS";
case "weapon_xm1014":
return "XM1014";
case "item_kevlar":
return "Kevlar";
case "item_assaultsuit":
return "Kevlar Helmet";
case "weapon_snowball":
return "Snowball";
case "weapon_shield":
return "Shield";
case "weapon_c4":
return "Bomb";
case "weapon_healthshot":
return "Healthshot";
case "weapon_breachcharge":
return "Breach Charge";
case "weapon_tablet":
return "Tablet";
case "weapon_bumpmine":
return "Bumpmine";
case "weapon_smokegrenade":
return "Smoke Grenade";
case "weapon_flashbang":
return "Flashbang";
case "weapon_hegrenade":
return "HE Grenade";
case "weapon_molotov":
return "Molotov";
case "weapon_incgrenade":
return "Incendiary Grenade";
case "weapon_decoy":
return "Decoy Grenade";
case "weapon_tagrenade":
return "TAGrenade";
case "weapon_frag":
return "Frag Grenade";
case "weapon_firebomb":
return "Firebomb";
case "weapon_diversion":
return "Diversion";
case "weapon_knife_t":
return "Knife";
case "weapon_knife":
return "Knife";
default:
return "UNKNOWN: Pleace Contact Tech";
return "UNKNOWN: Please Contact Tech";
}
}
}
4 changes: 0 additions & 4 deletions public/Jailbreak.Public/Jailbreak.Public.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@
<PackageReference Include="System.Text.Json" Version="8.0.4"/>
</ItemGroup>

<ItemGroup>
<Folder Include="Plugin\"/>
</ItemGroup>

</Project>
37 changes: 0 additions & 37 deletions public/Jailbreak.Public/Utils/FreezeManager.cs

This file was deleted.

19 changes: 0 additions & 19 deletions public/Jailbreak.Public/Utils/TemporaryConvar.cs

This file was deleted.

Loading

0 comments on commit 7a738c2

Please sign in to comment.