Skip to content

Commit

Permalink
More stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS committed Aug 2, 2024
1 parent 32f350c commit c07002a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 13 additions & 1 deletion mod/Jailbreak.Rebel/JihadC4/JihadC4Behavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Public;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.Rebel;
using MStatsShared;

namespace Jailbreak.Rebel.JihadC4;

Expand Down Expand Up @@ -36,6 +38,10 @@ public void TryGiveC4ToPlayer(CCSPlayerController player) {
public void StartDetonationAttempt(CCSPlayerController player, float delay,
CC4 bombEntity) {
if (plugin == null) return;
var pos = player.Pawn.Value?.AbsOrigin;
if (pos != null)
API.Stats?.PushStat(new ServerStat("JB_BOMB_ATTEMPT",
$"{pos.X:F2} {pos.Y:F2} {pos.Z:F2}"));

tryEmitSound(player, "jb.jihad", 1, 1f, 0f);

Expand Down Expand Up @@ -139,6 +145,7 @@ private void detonate(CCSPlayerController player, CC4 bomb) {
new QAngle(), new Vector());
particleSystemEntity.DispatchSpawn();

var killed = 0;
/* Calculate damage here, only applies to alive CTs. */
foreach (var ct in Utilities.GetPlayers()
.Where(p => p is {
Expand All @@ -153,13 +160,18 @@ private void detonate(CCSPlayerController player, CC4 bomb) {
var damage = 340f;
damage *= (350f - distanceFromBomb) / 350f;
float healthRef = ct.PlayerPawn.Value.Health;
if (healthRef <= damage) { ct.CommitSuicide(true, true); } else {
if (healthRef <= damage) {
ct.CommitSuicide(true, true);
killed++;
} else {
ct.PlayerPawn.Value.Health -= (int)damage;
Utilities.SetStateChanged(ct.PlayerPawn.Value, "CBaseEntity",
"m_iHealth");
}
}

API.Stats?.PushStat(new ServerStat("JB_BOMB_EXPLODED", killed.ToString()));

// If they didn't have the C4 make sure to remove it.
player.CommitSuicide(true, true);
bombs.Remove(bomb);
Expand Down
2 changes: 0 additions & 2 deletions mod/Jailbreak.SpecialDay/SpecialDays/SpeedrunDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ private void endRound() {
.Select(s => s.Value)
.LastOrDefault(-(Server.CurrentTime - FIRST_SPEEDRUNNER_TIME));


if (aliveCount <= 2) {
// Announce winners, end the round, etc.
// Maybe tp the loser to the winner and let the winner kill them
Expand Down Expand Up @@ -361,7 +360,6 @@ private void endRound() {
return;
}


var fastTime = MathF.Abs(fastTimestamp) - roundStartTime!;
var roundTimeWas = Math.Ceiling(Server.CurrentTime - roundStartTime!.Value);
var nextRoundTime = (int)Math.Ceiling(fastTime.Value + 10 - round * 2);
Expand Down

0 comments on commit c07002a

Please sign in to comment.