-
Notifications
You must be signed in to change notification settings - Fork 0
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
8 changed files
with
61 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using CounterStrikeSharp.API.Core; | ||
|
||
namespace Zones; | ||
|
||
public static class ControllerExtends | ||
{ | ||
public static bool IsValid(this CCSPlayerController? controller, bool checkBot = false) | ||
{ | ||
if (checkBot) | ||
return controller is { IsValid: true, IsBot: false }; | ||
|
||
return controller is { IsValid: true }; | ||
} | ||
|
||
public static void Bounce(this CCSPlayerController? controller) | ||
{ | ||
if (controller == null || !controller.IsValid() || controller.PlayerPawn.Value == null) | ||
return; | ||
|
||
var vel = controller.PlayerPawn.Value.AbsVelocity; | ||
var speed = Math.Sqrt(vel.X * vel.X + vel.Y * vel.Y); | ||
|
||
vel *= (-350 / (float)speed); | ||
vel.Z = vel.Z <= 0 ? 150 : Math.Min(vel.Z, 150); | ||
controller.PlayerPawn.Value.Teleport(controller.PlayerPawn.Value.AbsOrigin, controller.PlayerPawn.Value.EyeAngles, vel); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Zones; | ||
namespace Zones.Enums; | ||
|
||
public enum ZoneType | ||
{ | ||
|
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 |
---|---|---|
@@ -1,19 +1,13 @@ | ||
using CounterStrikeSharp.API.Core.Capabilities; | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
using RetakesPluginShared; | ||
|
||
namespace Zones; | ||
|
||
public partial class Zones | ||
{ | ||
public override string ModuleName => "Retakes-Zones"; | ||
public override string ModuleVersion => "1.0.2"; | ||
public override string ModuleVersion => "1.1.0"; | ||
public override string ModuleAuthor => "https://github.com/oscar-wos/Retakes-Zones"; | ||
private static PluginCapability<IRetakesPluginEventSender> RetakesPluginEventSenderCapability { get; } = new("retakes_plugin:event_sender"); | ||
|
||
private readonly List<Zone> _zones = []; | ||
private readonly Dictionary<int, List<Zone>> _playerZones = []; | ||
private readonly Dictionary<int, List<Zone>> _playerGreenZones = []; | ||
private readonly Dictionary<int, Vector> _playerLastPosition = []; | ||
private readonly Dictionary<int, Vector> _playerLastVelocity = []; | ||
} |
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 |
---|---|---|
@@ -1,11 +1,23 @@ | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
using CounterStrikeSharp.API; | ||
|
||
namespace Zones; | ||
|
||
public partial class Zones | ||
{ | ||
private void OnTick() | ||
{ | ||
} | ||
|
||
private void OnMapStart(string mapName) | ||
{ | ||
LoadJson(mapName); | ||
} | ||
|
||
private void OnClientPutInServer(int playerSlot) | ||
{ | ||
var controller = Utilities.GetPlayerFromSlot(playerSlot); | ||
|
||
if (controller == null || !controller.IsValid()) | ||
return; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,18 +1,19 @@ | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
using RetakesPluginShared.Enums; | ||
using Zones.Enums; | ||
|
||
namespace Zones; | ||
|
||
public class Zone(Bombsite bombsite, ZoneType type, CsTeam[] teams, Vector minPoint, Vector maxPoint) | ||
public class Zone(Bombsite bombsite, ZoneType type, CsTeam[] teams, float[] minPoint, float[] maxPoint) | ||
{ | ||
public Bombsite Bombsite { get; init; } = bombsite; | ||
public ZoneType Type { get; init; } = type; | ||
public CsTeam[] Teams { get; init; } = teams; | ||
public Vector MinPoint { get; init; } = minPoint; | ||
public Vector MaxPoint { get; init; } = maxPoint; | ||
private float[] MinPoint { get; } = minPoint; | ||
private float[] MaxPoint { get; } = maxPoint; | ||
|
||
public bool IsInZone(Vector point) | ||
{ | ||
return point.X >= MinPoint.X && point.X <= MaxPoint.X && point.Y >= MinPoint.Y && point.Y <= MaxPoint.Y && point.Z >= MinPoint.Z && point.Z <= MaxPoint.Z; | ||
return point.X >= MinPoint[0] && point.X <= MaxPoint[0] && point.Y >= MinPoint[1] && point.Y <= MaxPoint[1] && point.Z >= MinPoint[2] && point.Z <= MaxPoint[2]; | ||
} | ||
} |
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