Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

36 prefire mode #43

Merged
merged 3 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CSPracc/CSPracc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@
<Version>0.9.1.1</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>$(DefineConstants);unsafe</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<DefineConstants>$(DefineConstants);unsafe</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.90" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.141" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions CSPracc/CSPraccConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using static CSPracc.DataModules.Enums;

namespace CSPracc
{
Expand All @@ -16,6 +17,8 @@ public class CSPraccConfig : BasePluginConfig
[JsonPropertyName("ChatPrefix")] public string ChatPrefix { get; set; } = $" {ChatColors.Green}[{ChatColors.Red}CSPRACC{ChatColors.Green}]{ChatColors.White} ";
[JsonPropertyName("RconPassword")] public string RconPassword { get; set; } = "secret";
[JsonPropertyName("DemoSettings")] public DemoManagerSettings DemoManagerSettings { get; set; } = new DemoManagerSettings();
[JsonPropertyName("StandardMode")] public PluginMode ModeToLoad { get; set; } = PluginMode.Base;
[JsonPropertyName("AdminRequirement")] public bool AdminRequirement { get; set; } = true;

}
}
107 changes: 86 additions & 21 deletions CSPracc/DataModules/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,55 +25,116 @@ public class RETAKE_COMMAND
public const string addspawnb = ".addspawnb";
}

public class PRACC_COMMAND
public class PREFIRE_COMMAND
{
public const string options = ".options";
public const string routes = ".routes";
public const string route = ".route";
public const string addroute = ".addroute";
public const string deleteroute = ".deleteroute";
public const string editroute = ".editroute";
public const string next = ".next";
public const string back = ".back";
public const string guns = ".guns";
public const string addspawn = ".addspawn";
public const string addstartingpoint = ".addstart";
public const string savecurrentroute = ".save";
public const string restart = ".restart";
}


public class BASE_COMMAND
{
public const string MODE = ".menu";
public const string PRACC = ".pracc";
public const string MATCH = ".match";
public const string DryRun = ".dryrun";
public const string Prefire = ".prefire";
public const string Retake = ".retake";
public const string Unload = ".unload";
public const string HELP = ".help";
public const string FAKERCON = ".rcon";
public const string MAP = ".map";
public const string GOT = ".t";
public const string GOCT = ".ct";
public const string GOSPEC = ".spec";
public const string SWAP = ".swap";
public const string ALIAS = ".alias";
public const string REMOVEALIAS = ".ralias";
}

public class MATCH_COMMAND
{
public const string PAUSE = ".pause";
public const string UNPAUSE = ".unpause";
public const string READY = ".ready";
public const string UNREADY = ".unready";
public const string FORCEREADY = ".forceready";
public const string STOP = ".stop";
public const string WARMUP = ".warmup";
public const string HELP = ".help";
public const string RESTART = ".restart";
public const string SPAWN = ".spawn";
public const string TSPAWN = ".tspawn";
public const string CTSPAWN = ".ctspawn";
public const string COACH = ".coach";
public const string STOPCOACH = ".stopcoach";
public const string FAKERCON = ".rcon";
public const string BACKUPMENU = ".backup";
public const string NADES = ".nades";
public const string SAVE = ".save";
public const string REMOVE = ".remove";
public const string MAP = ".map";
public const string RESTORE = ".restore";
public const string FORCEUNPAUSE = ".forceunpause";
public const string DEMO = ".demo";
}

public class DRYRUN_COMMAND
{
public const string refill = ".refill";
public const string ak = ".ak";
public const string m4 = ".m4";
public const string awp = ".awp";
public const string m4a1 = ".m4a1";
}

public class PRACC_COMMAND
{
public const string SPAWN = ".spawn";
public const string TSPAWN = ".tspawn";
public const string CTSPAWN = ".ctspawn";
public const string NADES = ".nades";
public const string SAVE = ".save";
public const string Description = ".desc";
public const string Rename = ".rename";
public const string AddTag = ".addtag";
public const string RemoveTag = ".removetag";
public const string ClearTags = ".cleartags";
public const string DeleteTag = ".deletetag";
public const string Last = ".last";
public const string BACK = ".back";
public const string forward = ".forward";
public const string bestspawn = ".bestspawn";
public const string worstspawn = ".worstspawn";

public const string Delete = ".delete";
public const string BOT = ".bot";
public const string tBOT = ".tbot";
public const string ctBOT = ".ctbot";
public const string BOOST = ".boost";
public const string WATCHME = ".watchme";
public const string NOBOT = ".nobot";
public const string CLEARBOTS = ".clearbots";
public const string CROUCHBOT = ".crouchbot";
public const string CROUCHBOOST = ".crouchboost";
public const string GOT = ".t";
public const string GOCT = ".ct";
public const string GOSPEC = ".spec";
public const string SWAP = ".swap";
public const string ALIAS = ".alias";
public const string REMOVEALIAS = ".ralias";
public const string SwapBot = ".swapbot";
public const string MoveBot = ".movebot";

public const string CLEAR = ".clear";
public const string ClearAll = ".clearall";
public const string DEMO = ".demo";
public const string ClearAll = ".clearall";
public const string SAVELAST = ".savelast";
public const string CHECKPOINT = ".checkpoint";
public const string BACK = ".back";
public const string UserRole = ".userrole";
public const string DryRun = ".dryrun";
public const string TELEPORT = ".tp";

public const string UserRole = ".userrole";
public const string timer = ".timer";
public const string countdown = ".countdown";
public const string rethrow = ".throw";
public const string flash = ".flash";
public const string noflash = ".noflash";
public const string stop = ".stop";
}

public class AdminFlags
Expand All @@ -90,5 +151,9 @@ public static void MsgToServer(string msg)
public class DesignerNames
{
public const string ProjectileSmoke = "smokegrenade_projectile";
public const string ProjectileFlashbang = "flashbang_projectile";
public const string ProjectileHE = "hegrenade_projectile";
public const string ProjectileDecoy = "decoy_projectile";
public const string ProjectileMolotov = "molotov_projectile";
}
}
26 changes: 26 additions & 0 deletions CSPracc/DataModules/PrefireRoute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSPracc.DataModules
{
public class PrefireRoute
{
[JsonProperty("Name")]
public string Name { get; set; } = "";

[JsonProperty("SpawnPoints")]
public List<JsonSpawnPoint> spawnPoints { get; set; } = new List<JsonSpawnPoint>();

[JsonProperty("StartingPoint")]
public JsonSpawnPoint? StartingPoint { get; set; }

public PrefireRoute(string name)
{
Name = name;
}
}
}
35 changes: 32 additions & 3 deletions CSPracc/DataModules/ProjectileSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,55 @@
namespace CSPracc.DataModules
{
public class ProjectileSnapshot
{
{
public List<string> Tags { get; set; } = new List<string>();
public ulong initialThrower { get; set; } = 0;
public GrenadeType_t GrenadeType_T { get; set; }
public System.Numerics.Vector3 PlayerPosition { get; init; } = new Vector3(0, 0, 0);
public System.Numerics.Vector3 PlayerVelocity { get; init; } = new Vector3(0,0,0);
public System.Numerics.Vector3 ProjectilePosition { get; init; } = new Vector3(0, 0, 0);
public System.Numerics.Vector3 PlayerAngle { get; init; } = new Vector3(0, 0, 0);
public System.Numerics.Vector3 Velocity { get; init; } = new Vector3(0, 0, 0);
public string Title { get; set; } = "";
public string Description { get; set; } = "";
public ProjectileSnapshot() { }
public ProjectileSnapshot(Vector3 playerPosition, Vector3 projectilePosition, Vector3 playerAngle, string title, string description)
public ProjectileSnapshot(CCSPlayerController player,CBaseCSGrenadeProjectile grenadeProjectile,string title, string description, GrenadeType_t type)
{
PlayerPosition = player.PlayerPawn.Value!.CBodyComponent!.SceneNode!.AbsOrigin.ToVector3();
ProjectilePosition = grenadeProjectile.InitialPosition.ToVector3();
PlayerAngle = player.PlayerPawn.Value!.EyeAngles.ToVector3();
Title = title;
Description = description;
Velocity = grenadeProjectile.InitialVelocity.ToVector3();
GrenadeType_T = type;
initialThrower = player.SteamID;
}

public ProjectileSnapshot(Vector3 playerPosition, Vector3 projectilePosition,Vector3 playerAngle,Vector3 velocity,string title, string description, GrenadeType_t type, ulong steamid = 0)
{
PlayerPosition = playerPosition;
ProjectilePosition = projectilePosition;
PlayerAngle = playerAngle;
Title = title;
Description = description;
Velocity = velocity;
GrenadeType_T = type;
initialThrower = steamid;
}

public void Restore(CCSPlayerController player)
{
Utils.RemoveNoClip(player);
player.PlayerPawn.Value.Teleport(PlayerPosition.ToCSVector(), PlayerAngle.ToCSQAngle(), PlayerVelocity.ToCSVector());
player.PlayerPawn.Value.Teleport(PlayerPosition.ToCSVector(), PlayerAngle.ToCSQAngle(), PlayerVelocity.ToCSVector());
player.PrintToChat($"Teleported to grenade {Title}");
if (Description.Length > 0)
{
player.PrintToChat($"Desc: {ChatColors.Green}{Description}");
}
if (Tags.Count > 0)
{
player.PrintToChat($"Tags: {ChatColors.Green}{String.Join(", ", Tags)}");
}
}
}
}
5 changes: 3 additions & 2 deletions CSPracc/DataModules/enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public enum match_state
}
public enum PluginMode
{
Standard,
Base,
Pracc,
Match,
DryRun,
Retake
Retake,
Prefire
}
}
}
3 changes: 2 additions & 1 deletion CSPracc/DataStorages/JsonStorages/JsonStorage.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CSPracc.DataModules;
using CSPracc.Extensions;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
Expand All @@ -26,7 +27,7 @@ public JsonStorage(FileInfo jsonFile)
}
catch
{
Logging.LogMessage($"Could not read {JsonFile.Name}. Creating new dictonary.");
CSPraccPlugin.Instance!.Logger.LogWarning($"Could not read {JsonFile.Name}. Creating new dictonary.");
Storage = new Dictionary<TKey, TValue>();
}
}
Expand Down
26 changes: 26 additions & 0 deletions CSPracc/DataStorages/JsonStorages/PrefireRouteStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using CSPracc.DataModules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSPracc.DataStorages.JsonStorages
{
public class PrefireRouteStorage : JsonStorage<int, PrefireRoute>
{
public PrefireRouteStorage(FileInfo jsonFile) : base(jsonFile)
{
}

public override bool Get(int key, out PrefireRoute value)
{
if (!Storage.TryGetValue(key, out value))
{
value = new PrefireRoute("");
return false;
}
return true;
}
}
}
31 changes: 25 additions & 6 deletions CSPracc/DataStorages/JsonStorages/ProjectileStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using CSPracc.DataStorages;
using Newtonsoft.Json.Linq;
using CSPracc.DataModules;
using CounterStrikeSharp.API.Core;

namespace CSPracc.DataStorages.JsonStorages
{
Expand All @@ -27,20 +28,38 @@ public int GetUnusedKey()
}
return id;
}
public void Add(Vector playerPosition, Vector projectilePosition, QAngle playerAngle, string title, string description, string map)

public int Add(CCSPlayerController player, CBaseCSGrenadeProjectile? projectile, string title, string map)
{
ProjectileSnapshot? snapshot = null;
if (projectile != null)
{
snapshot = new ProjectileSnapshot(player, projectile, title, "", GrenadeType_t.GRENADE_TYPE_SMOKE);
}
else
{
snapshot = new ProjectileSnapshot(player.PlayerPawn.Value!.CBodyComponent!.SceneNode!.AbsOrigin.ToVector3(), player.PlayerPawn.Value!.CBodyComponent!.SceneNode!.AbsOrigin.ToVector3(), player.PlayerPawn.Value!.EyeAngles.ToVector3(),new Vector3(0,0,0), title, "", GrenadeType_t.GRENADE_TYPE_SMOKE,player.SteamID);
}

return Add(snapshot);
}

public void Add(Vector playerPosition, Vector projectilePosition, QAngle playerAngle, Vector velocity,string title, string description, string map)
{
ProjectileSnapshot snapshot = new ProjectileSnapshot(playerPosition.ToVector3(), projectilePosition.ToVector3(), playerAngle.ToVector3(), title, description);
ProjectileSnapshot snapshot = new ProjectileSnapshot(playerPosition.ToVector3(), projectilePosition.ToVector3(), playerAngle.ToVector3(), velocity.ToVector3(), title, description,GrenadeType_t.GRENADE_TYPE_SMOKE);
Add(snapshot);
}
public void Add(Vector3 playerPosition, Vector3 projectilePosition, Vector3 playerAngle, string title, string description)
public void Add(Vector3 playerPosition, Vector3 projectilePosition, Vector3 playerAngle, Vector3 velocity,string title, string description)
{
ProjectileSnapshot snapshot = new ProjectileSnapshot(playerPosition, projectilePosition, playerAngle, title, description);
ProjectileSnapshot snapshot = new ProjectileSnapshot(playerPosition, projectilePosition, playerAngle, velocity, title, description, GrenadeType_t.GRENADE_TYPE_SMOKE);
Add(snapshot);
}

public void Add(ProjectileSnapshot snapshot)
public int Add(ProjectileSnapshot snapshot)
{
SetOrAdd(GetUnusedKey(), snapshot);
int newkey = GetUnusedKey();
SetOrAdd(newkey, snapshot);
return newkey;
}
public override bool Get(int id, out ProjectileSnapshot snapshot)
{
Expand Down
Loading