v1.1.0
This commit is contained in:
parent
6b8988ade4
commit
26cb787b57
125 changed files with 9157 additions and 1940 deletions
78
jRandomSkills - SRC Files/src/player/skills/Assassin.cs
Normal file
78
jRandomSkills - SRC Files/src/player/skills/Assassin.cs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using jRandomSkills.src.player;
|
||||
using static jRandomSkills.jRandomSkills;
|
||||
|
||||
namespace jRandomSkills
|
||||
{
|
||||
public class Assassin : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Assassin;
|
||||
private static float damageMultiplier = Config.GetValue<float>(skillName, "damageMultiplier");
|
||||
private static float toleranceDeg = Config.GetValue<float>(skillName, "toleranceDeg");
|
||||
private static string[] nades = { "inferno", "flashbang", "smokegrenade", "decoy", "hegrenade" };
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
|
||||
|
||||
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
|
||||
{
|
||||
var damage = @event.DmgHealth;
|
||||
var victim = @event.Userid;
|
||||
var attacker = @event.Attacker;
|
||||
var weapon = @event.Weapon;
|
||||
HitGroup_t hitgroup = (HitGroup_t)@event.Hitgroup;
|
||||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
|
||||
if (nades.Contains(weapon)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
if (IsBehind(attacker, victim))
|
||||
SkillUtils.TakeHealth(victim.PlayerPawn.Value, (int)(damage * (damageMultiplier - 1f)));
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
}
|
||||
|
||||
private static bool IsBehind(CCSPlayerController attacker, CCSPlayerController victim)
|
||||
{
|
||||
var attackerPawn = attacker.PlayerPawn.Value;
|
||||
var victimPawn = victim.PlayerPawn.Value;
|
||||
if (attackerPawn == null || !attackerPawn.IsValid || victimPawn == null || !victimPawn.IsValid) return false;
|
||||
var angles = GetAngleRange(victimPawn.AbsRotation.Y);
|
||||
return IsBeetween(angles.Item1, angles.Item2, attackerPawn.AbsRotation.Y);
|
||||
}
|
||||
|
||||
private static (float, float) GetAngleRange(float angle)
|
||||
{
|
||||
float min = angle - toleranceDeg;
|
||||
float max = angle + toleranceDeg;
|
||||
|
||||
if (min < -180) min += 360f;
|
||||
if (max > 180f) max -= 360f;
|
||||
|
||||
return (min, max);
|
||||
}
|
||||
|
||||
private static bool IsBeetween(float a, float b, float target)
|
||||
{
|
||||
if (a <= b)
|
||||
return (target >= a && target <= b);
|
||||
return (target >= a || target <= b);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
{
|
||||
public float DamageMultiplier { get; set; }
|
||||
public float ToleranceDeg { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d9d9d9", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damageMultiplier = 2f, float toleranceDeg = 45f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
DamageMultiplier = damageMultiplier;
|
||||
ToleranceDeg = toleranceDeg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue