v1.0.4
This commit is contained in:
parent
a7009be3e0
commit
898f86f888
137 changed files with 3553 additions and 3780 deletions
|
|
@ -3,7 +3,6 @@ using CounterStrikeSharp.API.Core;
|
|||
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using jRandomSkills.src.player;
|
||||
using static CounterStrikeSharp.API.Core.Listeners;
|
||||
using static jRandomSkills.jRandomSkills;
|
||||
|
||||
namespace jRandomSkills
|
||||
|
|
@ -18,64 +17,45 @@ namespace jRandomSkills
|
|||
public static void LoadSkill()
|
||||
{
|
||||
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
|
||||
}
|
||||
|
||||
Instance.RegisterEventHandler<EventRoundStart>((@event, info) =>
|
||||
{
|
||||
decoys.Clear();
|
||||
return HookResult.Continue;
|
||||
});
|
||||
public static void NewRound()
|
||||
{
|
||||
decoys.Clear();
|
||||
}
|
||||
|
||||
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
|
||||
{
|
||||
Instance.AddTimer(0.1f, () =>
|
||||
public static void DecoyStarted(EventDecoyStarted @event)
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid) return;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
decoys.Add(new Vector(@event.X, @event.Y, @event.Z));
|
||||
}
|
||||
|
||||
public static void DecoyDetonate(EventDecoyDetonate @event)
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid) return;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
decoys.RemoveAll(v => v.X == @event.X && v.Y == @event.Y && v.Z == @event.Z);
|
||||
}
|
||||
|
||||
public static void OnTick()
|
||||
{
|
||||
foreach (Vector decoyPos in decoys)
|
||||
foreach (var player in Utilities.GetPlayers().Where(p => p.Team == CsTeam.Terrorist || p.Team == CsTeam.CounterTerrorist))
|
||||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null) return;
|
||||
double distance = SkillUtils.GetDistance(decoyPos, pawn.AbsOrigin);
|
||||
if (distance <= decoyRadius)
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
double modifier = Math.Clamp(distance / decoyRadius, 0f, 1f);
|
||||
pawn.VelocityModifier = (float)Math.Pow(modifier, slownessMultiplier);
|
||||
}
|
||||
});
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
Instance.RegisterEventHandler<EventDecoyStarted>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
decoys.Add(new Vector(@event.X, @event.Y, @event.Z));
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
Instance.RegisterEventHandler<EventDecoyDetonate>((@event, @info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
decoys.RemoveAll(v => v.X == @event.X && v.Y == @event.Y && v.Z == @event.Z);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
Instance.RegisterListener<OnTick>(() =>
|
||||
{
|
||||
foreach (Vector decoyPos in decoys)
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null) return;
|
||||
double distance = SkillUtils.GetDistance(decoyPos, pawn.AbsOrigin);
|
||||
if (distance <= decoyRadius)
|
||||
{
|
||||
double modifier = Math.Clamp(distance / decoyRadius, 0f, 1f);
|
||||
pawn.VelocityModifier = (float)Math.Pow(modifier, slownessMultiplier);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue