v1.21.1.b8
This commit is contained in:
parent
abd3aed8fd
commit
10dbf6629e
77 changed files with 1507 additions and 974 deletions
|
|
@ -1,8 +1,6 @@
|
|||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using CS2TraceRay.Class;
|
||||
using CS2TraceRay.Struct;
|
||||
using static src.jRandomSkills;
|
||||
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;
|
||||
using System.Collections.Concurrent;
|
||||
|
|
@ -13,7 +11,7 @@ namespace src.player.skills
|
|||
public class Shade : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Shade;
|
||||
private static readonly ConcurrentDictionary<CCSPlayerController, float> noSpace = [];
|
||||
private static readonly ConcurrentDictionary<uint, float> noSpace = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -44,25 +42,32 @@ namespace src.player.skills
|
|||
{
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
|
||||
float newChance = (float)Instance.Random.NextDouble() * (SkillsInfo.GetValue<float>(skillName, "ChanceTo") - SkillsInfo.GetValue<float>(skillName, "ChanceFrom")) + SkillsInfo.GetValue<float>(skillName, "ChanceFrom");
|
||||
playerInfo.SkillChance = newChance;
|
||||
|
||||
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetSkillName(skillName)}{ChatColors.Lime}: {player.GetSkillDescription(skillName, newChance)}",
|
||||
border: !Utilities.GetPlayers().Any(p => p.Team == player.Team && !p.IsBot && p != player) ? "tb" : "t");
|
||||
}
|
||||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
noSpace.TryRemove(player, out _);
|
||||
noSpace.TryRemove(player.Index, out _);
|
||||
SkillUtils.ResetPrintHTML(player);
|
||||
}
|
||||
|
||||
public static void OnTick()
|
||||
{
|
||||
foreach (var item in noSpace)
|
||||
if (item.Value >= Server.TickCount)
|
||||
UpdateHUD(item.Key);
|
||||
foreach (var (playerIndex, time) in noSpace)
|
||||
{
|
||||
var player = Utilities.GetPlayerFromIndex((int)playerIndex);
|
||||
if (player == null || !player.IsValid) continue;
|
||||
|
||||
if (time >= Server.TickCount)
|
||||
UpdateHUD(player);
|
||||
else
|
||||
SkillUtils.ResetPrintHTML(item.Key);
|
||||
SkillUtils.ResetPrintHTML(player);
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player)
|
||||
|
|
@ -72,45 +77,29 @@ namespace src.player.skills
|
|||
playerInfo.PrintHTML = $"<font color='#FF0000'>{player.GetTranslation("shade_nospace")}</font>";
|
||||
}
|
||||
|
||||
private unsafe static bool CheckTeleport(CCSPlayerController player, Vector startPos, Vector endPos)
|
||||
private unsafe static bool CheckTeleport(CCSPlayerController attacker, CCSPlayerController victim, Vector startPos, Vector endPos, QAngle angle)
|
||||
{
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid) return false;
|
||||
var attackerPawn = attacker.PlayerPawn.Value;
|
||||
if (attackerPawn == null || !attackerPawn.IsValid) return false;
|
||||
|
||||
Vector s = startPos + new Vector(0, 0, pawn.ViewOffset.Z / 2);
|
||||
Vector e = endPos + new Vector(0, 0, pawn.ViewOffset.Z / 2);
|
||||
var victimPawn = attacker.PlayerPawn.Value;
|
||||
if (victimPawn == null || !victimPawn.IsValid) return false;
|
||||
|
||||
ulong mask = pawn.Collision.CollisionAttribute.InteractsWith;
|
||||
ulong contents = pawn.Collision.CollisionGroup;
|
||||
CGameTrace trace = TraceRay.TraceShape(startPos, endPos, mask, contents, player);
|
||||
var result = RayTrace.TraceHullShape(
|
||||
startPos,
|
||||
endPos,
|
||||
victim,
|
||||
attackerPawn.Collision.Mins,
|
||||
attackerPawn.Collision.Maxs,
|
||||
null,
|
||||
null,
|
||||
angle
|
||||
);
|
||||
|
||||
if (trace.DidHit()) return false;
|
||||
return IsPositionSafe(player, endPos);
|
||||
}
|
||||
if (!result.HasValue)
|
||||
return false;
|
||||
|
||||
private static bool IsPositionSafe(CCSPlayerController player, Vector pos)
|
||||
{
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid || playerPawn.AbsOrigin == null) return false;
|
||||
|
||||
float footHeight = 0;
|
||||
float headHeight = 70;
|
||||
float innerDist = 12;
|
||||
|
||||
ulong mask = playerPawn.Collision.CollisionAttribute.InteractsWith;
|
||||
ulong contents = playerPawn.Collision.CollisionGroup;
|
||||
|
||||
Vector s1 = new(pos.X - innerDist, pos.Y - innerDist, pos.Z + footHeight);
|
||||
Vector e1 = new(pos.X + innerDist, pos.Y + innerDist, pos.Z + headHeight);
|
||||
CGameTrace t1 = TraceRay.TraceShape(s1, e1, mask, contents, player);
|
||||
if (t1.DidHit() || t1.AllSolid) return false;
|
||||
|
||||
Vector s2 = new(pos.X + innerDist, pos.Y - innerDist, pos.Z + footHeight);
|
||||
Vector e2 = new(pos.X - innerDist, pos.Y + innerDist, pos.Z + headHeight);
|
||||
CGameTrace t2 = TraceRay.TraceShape(s2, e2, mask, contents, player);
|
||||
if (t2.DidHit() || t2.AllSolid) return false;
|
||||
|
||||
return true;
|
||||
return !result.Value.DidHit;
|
||||
}
|
||||
|
||||
private static void TeleportAttackerBehindVictim(CCSPlayerController attacker, CCSPlayerController victim)
|
||||
|
|
@ -133,7 +122,7 @@ namespace src.player.skills
|
|||
Vector direction = SkillUtils.GetForwardVector(targetAngle);
|
||||
Vector targetPos = victimPos - (direction * distance);
|
||||
|
||||
if (CheckTeleport(victim, victimPos, targetPos))
|
||||
if (CheckTeleport(attacker, victim, victimPos, targetPos, targetAngle))
|
||||
{
|
||||
attackerPawn.Teleport(targetPos, targetAngle, Vector.Zero);
|
||||
teleported = true;
|
||||
|
|
@ -142,7 +131,7 @@ namespace src.player.skills
|
|||
}
|
||||
|
||||
if (!teleported)
|
||||
noSpace.AddOrUpdate(attacker, Server.TickCount + (64 * 2), (_, _) => Server.TickCount + (64 * 2));
|
||||
noSpace.AddOrUpdate(attacker.Index, Server.TickCount + (64 * 2), (_, _) => Server.TickCount + (64 * 2));
|
||||
}
|
||||
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#4d4d4d", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", float teleportDistance = 100f, float chanceFrom = .3f, float chanceTo = .45f) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue