Skip to content

Commit

Permalink
Misc. changes (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS authored Aug 13, 2024
2 parents f310c1d + 1b15b2a commit b275f46
Show file tree
Hide file tree
Showing 29 changed files with 108 additions and 58 deletions.
14 changes: 3 additions & 11 deletions lang/Jailbreak.English/LastRequest/CoinflipLocale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class CoinflipLocale : LastRequestLocale, ILRCFLocale {
public IView FailedToChooseInTime(bool choice) {
return new SimpleView {
PREFIX,
"You failed to choose in time, defaulting to " + ChatColors.Green,
"You failed to choose in time, defaulting to" + ChatColors.Green,
choice ? "Heads" : "Tails"
};
}
Expand All @@ -18,23 +18,15 @@ public IView GuardChose(CCSPlayerController guard, bool choice) {
return new SimpleView {
PREFIX,
guard,
" chose " + ChatColors.Green,
"chose" + ChatColors.Green,
choice ? "Heads" : "Tails",
ChatColors.Default + ", flipping..."
};
}

public IView CoinLandsOn(bool heads) {
return new SimpleView {
PREFIX, "The coin lands on " + ChatColors.Green, heads ? "Heads" : "Tails"
};
}

public IView FailedToChooseInTime(string choice) {
return new SimpleView {
PREFIX,
"You failed to choose in time, defaulting to " + ChatColors.Green,
choice
PREFIX, "The coin lands on" + ChatColors.Green, heads ? "Heads" : "Tails"
};
}
}
6 changes: 3 additions & 3 deletions lang/Jailbreak.English/LastRequest/LastRequestLocale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public IView InformLastRequest(AbstractLastRequest lr) {
return new SimpleView {
PREFIX,
lr.Prisoner,
"is preparing a",
lr.Type.ToFriendlyString(),
"Last Request against",
ChatColors.Grey + "is preparing a",
ChatColors.White + lr.Type.ToFriendlyString(),
ChatColors.Grey + "Last Request against",
lr.Guard
};
}
Expand Down
5 changes: 4 additions & 1 deletion lang/Jailbreak.English/SpecialDay/SoloDayLocale.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Utils;

namespace Jailbreak.English.SpecialDay;
Expand Down Expand Up @@ -27,7 +28,9 @@ public virtual IView BeginsIn(int seconds) {
}

public IView GenerateStartMessage() {
var result = new SimpleView { PREFIX, { "Today is a", Name, "day!" } };
var result = new SimpleView {
PREFIX, { "Today is a" + (Name[0].IsVowel() ? "n" : ""), Name, "day!" }
};

if (description.Length == 0) return result;

Expand Down
11 changes: 10 additions & 1 deletion lang/Jailbreak.English/SpecialDay/SpeedrunDayLocale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public IView RunnerAssigned(CCSPlayerController player) {
};
}

public IView RunnerReassigned(CCSPlayerController player) {
public IView RunnerLeftAndReassigned(CCSPlayerController player) {
return new SimpleView {
PREFIX,
"The original speedrunner left, so",
Expand All @@ -78,6 +78,15 @@ public IView RunnerReassigned(CCSPlayerController player) {
};
}

public IView RunnerAFKAndReassigned(CCSPlayerController player) {
return new SimpleView {
PREFIX,
"The original speedrunner isn't moving, so",
player,
"is now the speedrunner!"
};
}

public IView PlayerTime(CCSPlayerController player, int position,
float time) {
var place = position switch {
Expand Down
5 changes: 4 additions & 1 deletion lang/Jailbreak.English/SpecialDay/TeamDayLocale.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Utils;

namespace Jailbreak.English.SpecialDay;
Expand Down Expand Up @@ -29,7 +30,9 @@ public virtual IView BeginsIn(int seconds) {
}

public IView GenerateStartMessage() {
var result = new SimpleView { PREFIX, { "Today is a", Name, "day!" } };
var result = new SimpleView {
PREFIX, { "Today is a" + (Name[0].IsVowel() ? "n" : ""), Name, "day!" }
};

if (description.Length == 0) return result;

Expand Down
5 changes: 2 additions & 3 deletions mod/Jailbreak.Debug/Subcommands/DebugZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public override void OnCommand(CCSPlayerController? executor,
specifiedType = success;
}

string map = Server.MapName;
var map = Server.MapName;
switch (info.GetArg(1).ToLower()) {
case "finish":
case "done":
Expand Down Expand Up @@ -190,8 +190,7 @@ await zoneManager.PushZoneWithID(innerZone, innerPair.Value.Item2,
info.ReplyToCommand("Removing " + toRemove.Count
+ " auto-generated zones");
Server.NextFrameAsync(async () => {
foreach (var z in toRemove)
await zoneManager.DeleteZone(z.Id, map);
foreach (var z in toRemove) await zoneManager.DeleteZone(z.Id, map);
});
return;
}
Expand Down
1 change: 0 additions & 1 deletion mod/Jailbreak.SpecialDay/SpecialDayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using CounterStrikeSharp.API.Modules.Cvars;
using CounterStrikeSharp.API.Modules.Menu;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Formatting.Views.Warden;
using Jailbreak.Public.Behaviors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public virtual IView ArmoryReminder

override protected IZone GetZone() {
var manager = provider.GetRequiredService<IZoneManager>();
var zones = manager.GetZones(Server.MapName, ZoneType.ARMORY).GetAwaiter().GetResult();
var zones = manager.GetZones(Server.MapName, ZoneType.ARMORY)
.GetAwaiter()
.GetResult();
if (zones.Count > 0) return new MultiZoneWrapper(zones);

var bounds = new DistanceZone(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public virtual IView CellReminder

override protected IZone GetZone() {
var manager = provider.GetRequiredService<IZoneManager>();
var zones = manager.GetZones(Server.MapName, ZoneType.CELL).GetAwaiter().GetResult();
var zones = manager.GetZones(Server.MapName, ZoneType.CELL)
.GetAwaiter()
.GetResult();
if (zones.Count > 0) return new MultiZoneWrapper(zones);

var bounds = new DistanceZone(
Expand Down
1 change: 0 additions & 1 deletion mod/Jailbreak.SpecialDay/SpecialDays/CustomDay.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CounterStrikeSharp.API.Core;
using Jailbreak.English.SpecialDay;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Public.Mod.SpecialDay;
using Jailbreak.Public.Mod.SpecialDay.Enums;
Expand Down
1 change: 0 additions & 1 deletion mod/Jailbreak.SpecialDay/SpecialDays/FFADay.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using CounterStrikeSharp.API.Core;
using Jailbreak.English.SpecialDay;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Public.Mod.SpecialDay;
using Jailbreak.Public.Mod.SpecialDay.Enums;
Expand Down
6 changes: 3 additions & 3 deletions mod/Jailbreak.SpecialDay/SpecialDays/GunGameDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.English.SpecialDay;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.SpecialDay;
Expand Down Expand Up @@ -115,7 +114,8 @@ private HookResult OnDeath(EventPlayerDeath @event, GameEventInfo info) {
int playerIndex;
if (!progressions.TryGetValue(player.Slot, out playerIndex))
playerIndex = 0;
if (attacker == null || !attacker.IsValid || attacker.Slot == player.Slot) {
if (attacker == null || !attacker.IsValid) return HookResult.Continue;
if (attacker.Slot == player.Slot) {
if (playerIndex <= 0) return HookResult.Continue;
playerIndex--;
msg.DemotedDueToSuicide.ToChat(player);
Expand Down Expand Up @@ -167,7 +167,7 @@ private HookResult OnDeath(EventPlayerDeath @event, GameEventInfo info) {
msg.PlayerOnLastPromotion(attacker).ToAllChat();

msg.PromotedTo(weaponProgression[attackerProgress].GetFriendlyWeaponName(),
weaponProgression.Count - attackerProgress - 1)
weaponProgression.Count - attackerProgress)
.ToChat(attacker);

attacker.RemoveWeapons();
Expand Down
1 change: 0 additions & 1 deletion mod/Jailbreak.SpecialDay/SpecialDays/HideAndSeekDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Jailbreak.English.SpecialDay;
using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.SpecialDay;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.SpecialDay;

namespace Jailbreak.SpecialDay.SpecialDays;
Expand Down
1 change: 0 additions & 1 deletion mod/Jailbreak.SpecialDay/SpecialDays/InfectionDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.English.SpecialDay;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.SpecialDay;
Expand Down
1 change: 0 additions & 1 deletion mod/Jailbreak.SpecialDay/SpecialDays/NoScopeDay.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using Jailbreak.English.SpecialDay;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.SpecialDay;
Expand Down
1 change: 0 additions & 1 deletion mod/Jailbreak.SpecialDay/SpecialDays/OneInTheChamberDay.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CounterStrikeSharp.API.Core;
using Jailbreak.English.SpecialDay;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.SpecialDay;
Expand Down
47 changes: 45 additions & 2 deletions mod/Jailbreak.SpecialDay/SpecialDays/SpeedrunDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public override void Setup() {
}

speedrunner.SetColor(Color.DodgerBlue);
msg.RunnerReassigned(speedrunner).ToAllChat();
msg.RunnerLeftAndReassigned(speedrunner).ToAllChat();
msg.YouAreRunner(CvInitialSpeedrunTime.Value).ToChat(speedrunner);
}

Expand Down Expand Up @@ -254,6 +254,49 @@ private ActivePlayerTrail<BeamTrailSegment> createFirstTrail(
var tps = 1 / trail.UpdateRate;
var didntMoveSeconds = (int)Math.Ceiling(trail.DidntMoveTicks / tps);
var thresholdTicks = (int)Math.Ceiling(tps * 3);
if (start == null) {
panic("start is null");
return;
}

if (start.DistanceSquared(speedrunner?.Pawn.Value?.AbsOrigin!) < 100) {
if (trail.DidntMoveTicks <= tps * 10) return;
// If the player is afk, we need to pick the closet player
// that has moved to continue the run
var end = trail.GetEndSegment()?.GetEnd() ?? start;
if (end == null) {
panic("Speedrunner is invalid, and we cannot find the start");
return;
}

var furthest = PlayerUtil.GetAlive()
.Where(p => p.Pawn.IsValid && p.Pawn.Value != null)
.Where(p => p.Pawn.Value!.IsValid && p.Pawn.Value.AbsOrigin != null)
.Where(p
=> p.Pawn.Value!.AbsOrigin!.DistanceSquared(speedrunner?.Pawn.Value!
.AbsOrigin!) > 100) // Ensure they have moved
.MinBy(p => p.Pawn.Value!.AbsOrigin!.DistanceSquared(end));

if (furthest == null) {
panic("Speedrunner is invalid, and we cannot find a new one");
return;
}

speedrunner = furthest;
foreach (var p in PlayerUtil.GetAlive()) {
if (p.Slot == speedrunner.Slot) continue;
p.Teleport(speedrunner);
}

furthest.Pawn.Value?.Teleport(end);
furthest.SetColor(Color.DodgerBlue);
msg.RunnerAFKAndReassigned(furthest).ToAllChat();
msg.YouAreRunner(RoundUtil.GetTimeRemaining()).ToChat(furthest);
trail.StartTracking(furthest);
trail.DidntMoveTicks = 0;
return;
}

if (trail.DidntMoveTicks < thresholdTicks) return;
if (trail.DidntMoveTicks == thresholdTicks)
msg.StayStillToSpeedup.ToChat(trail.Player);
Expand Down Expand Up @@ -284,7 +327,7 @@ private ActivePlayerTrail<BeamTrailSegment> createFirstTrail(
speedrunner = nearest;
nearest.Pawn.Value?.Teleport(end);
nearest.SetColor(Color.DodgerBlue);
msg.RunnerReassigned(nearest).ToAllChat();
msg.RunnerLeftAndReassigned(nearest).ToAllChat();
msg.YouAreRunner(RoundUtil.GetTimeRemaining()).ToChat(nearest);
trail.StartTracking(nearest);
};
Expand Down
1 change: 0 additions & 1 deletion mod/Jailbreak.SpecialDay/SpecialDays/TeleportDay.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CounterStrikeSharp.API.Core;
using Jailbreak.English.SpecialDay;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.SpecialDay;
Expand Down
1 change: 0 additions & 1 deletion mod/Jailbreak.SpecialDay/SpecialDays/WardayDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.English.SpecialDay;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.SpecialDay;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.SpecialDay;
Expand Down
4 changes: 3 additions & 1 deletion mod/Jailbreak.Trail/ActivePlayerTrail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ActivePlayerTrail(BasePlugin plugin, CCSPlayerController player,
}

public float UpdateRate { get; protected set; }
public int DidntMoveTicks { get; protected set; }
public int DidntMoveTicks { get; set; }

public CCSPlayerController? Player { get; protected set; }
public event Action OnPlayerInvalid = () => { };
Expand Down Expand Up @@ -51,6 +51,8 @@ virtual protected void Tick() {
}

DidntMoveTicks = 0;
if (dist < 5000) return;

AddTrailPoint(pos);
}

Expand Down
1 change: 0 additions & 1 deletion mod/Jailbreak.Warden/Global/WardenBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ public HookResult OnRoundStart(EventRoundStart ev, GameEventInfo info) {
firstWarden = true;
preWardenStats = null;


return HookResult.Continue;
}

Expand Down
2 changes: 2 additions & 0 deletions mod/Jailbreak.Warden/Selection/WardenSelectionBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Generic;
using Jailbreak.Public.Mod.Warden;
using Jailbreak.Public.Utils;
using Microsoft.Extensions.Logging;

namespace Jailbreak.Warden.Selection;
Expand Down Expand Up @@ -78,6 +79,7 @@ public bool InQueue(CCSPlayerController player) {

[GameEventHandler]
public HookResult OnRoundStart(EventRoundStart ev, GameEventInfo info) {
if (RoundUtil.IsWarmup()) return HookResult.Continue;
// Enable the warden queue
queueInactive = false;

Expand Down
3 changes: 3 additions & 0 deletions public/Jailbreak.Formatting/Views/LastRequest/ILRLocale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ public interface ILRLocale {
public IView LastRequestNotEnabled();
public IView InvalidLastRequest(string query);
public IView InformLastRequest(AbstractLastRequest lr);

[Obsolete("Unused, use InformLastRequest instead")]
public IView AnnounceLastRequest(AbstractLastRequest lr);

public IView LastRequestDecided(AbstractLastRequest lr, LRResult result);
public IView CannotLR(string reason);
public IView CannotLR(CCSPlayerController player, string reason);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public interface ISpeedDayLocale : ISDInstanceLocale {

public IView YouAreRunner(int seconds);

public IView RunnerReassigned(CCSPlayerController player);
public IView RunnerLeftAndReassigned(CCSPlayerController player);
public IView RunnerAFKAndReassigned(CCSPlayerController player);

public IView RuntimeLeft(int seconds);

Expand Down
Loading

0 comments on commit b275f46

Please sign in to comment.