This commit is contained in:
Juzlus 2026-01-27 12:09:47 +01:00
parent 711350f50c
commit 9c4a0b687b
13 changed files with 80 additions and 29 deletions

View file

@ -14,9 +14,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.346" />
<PackageReference Include="CS2TraceRay" Version="1.0.8" />
<PackageReference Include="MaxMind.Db" Version="4.2.0" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.361" />
<PackageReference Include="CS2TraceRay" Version="1.0.9" />
<PackageReference Include="MaxMind.Db" Version="4.3.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>

View file

@ -27,7 +27,7 @@ namespace src
public override string ModuleName => "[CS2] [ jRandomSkills ]";
public override string ModuleAuthor => "D3X, Juzlus";
public override string ModuleDescription => "Plugin adds random skills every round for CS2 by D3X. Modified by Juzlus.";
public override string ModuleVersion => "1.1.9 BETA";
public override string ModuleVersion => "1.1.9f";
public override void Load(bool hotReload)
{

View file

@ -3,7 +3,6 @@ using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Modules.Admin;
using CounterStrikeSharp.API.Modules.Cvars;
using CounterStrikeSharp.API.Modules.Entities;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.UserMessages;

View file

@ -27,10 +27,6 @@ namespace src.player
{
Instance.GameRules = null;
Event.OnMapChange();
foreach (var entity in Utilities.GetAllEntities())
if (entity.DesignerName == "post_processing_volume")
entity.AcceptInput("Kill");
}
private static void InitializeGameRules()
@ -124,6 +120,7 @@ namespace src.player
if (string.IsNullOrEmpty(skillLine)) return;
if (player == null || !player.IsValid) return;
if (SkillUtils.HasMenu(player)) return;
Event.UpdateSkillHUD(player, infoLine, skillLine, remainingLine, isDescription);
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
@ -24,7 +25,7 @@ namespace src.player.skills
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
// SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
jRandomSkills.Instance.AddToManifest(cameraPropModel);
jRandomSkills.Instance.AddToManifest(cameraViewModel);
}
@ -124,6 +125,11 @@ namespace src.player.skills
BlockWeapon(player.Player, player.CameraActive);
pawn!.CameraServices!.ViewEntity.Raw = player.CameraActive && player.CameraView != null ? player.CameraView.EntityHandle.Raw : player.PlayerCameraRaw;
Utilities.SetStateChanged(pawn, "CBasePlayerPawn", "m_pCameraServices");
if (player.CameraActive && player.CameraView != null)
{
SkillUtils.ApplyScreenColor(player.Player, 0, 0, 255, 20, 100, 1020);
}
}
private static CDynamicProp? CreateCameraProp(CCSPlayerController player)
@ -233,13 +239,14 @@ namespace src.player.skills
CTraceFilter filter = new(playerPawn.Index, playerPawn.Index)
{
m_nObjectSetMask = 0xf,
m_nCollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_PLAYER_MOVEMENT,
m_nInteractsWith = playerPawn.GetInteractsWith(),
m_nCollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_PROJECTILE,
m_nInteractsWith = 8589946881,
m_nInteractsExclude = 0,
m_nBits = 11,
m_bIterateEntities = true,
m_bHitTriggers = false,
m_nInteractsAs = 0x40000
m_nInteractsAs = 0x40000,
m_bOnlyHitIfHasPhysics = true
};
filter.m_nHierarchyIds[0] = playerPawn.GetHierarchyId();

View file

@ -15,7 +15,7 @@ namespace src.player.skills
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
// SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
}
public static void NewRound()

View file

@ -1,3 +1,4 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;

View file

@ -1,6 +1,7 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Timers;
using CounterStrikeSharp.API.Modules.Utils;
@ -21,7 +22,7 @@ namespace src.player.skills
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
// SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
}
public static void NewRound()
@ -200,6 +201,31 @@ namespace src.player.skills
return !trace.DidHit();
}
private static float CalculateDamage(CCSPlayerController player, string weaponName, float damage, bool isHeadshot)
{
float calculatedDamage = damage;
var weapon = Utilities.FindAllEntitiesByDesignerName<CCSWeaponBase>(weaponName).FirstOrDefault();
if (weapon == null) return calculatedDamage;
var vdata = weapon.GetVData<CCSWeaponBaseVData>();
if (vdata == null) return calculatedDamage;
float penetration = vdata.ArmorRatio * .5f;
if (isHeadshot)
{
calculatedDamage *= vdata.HeadshotMultiplier;
if (player.PawnHasHelmet)
calculatedDamage *= penetration;
}
else
if (player.PawnArmor > 0)
calculatedDamage *= penetration;
return calculatedDamage;
}
public static void OnTakeDamage(DynamicHook h)
{
CEntityInstance param = h.GetParam<CEntityInstance>(0);
@ -218,12 +244,33 @@ namespace src.player.skills
var player = Utilities.GetPlayerFromSteamId(steamID);
if (player == null) return;
float dealDamage = param2.Damage;
if (playersInfo.TryGetValue(player, out var playerSkill))
{
if (playerSkill.CloneProp != null && playerSkill.CloneProp.IsValid && playerSkill.CloneProp.AbsOrigin != null)
{
Vector pos = param2.DamagePosition;
Vector posCl = playerSkill.CloneProp.AbsOrigin;
bool isHead = false;
float viewOffset = 63.27f;
float diff = 2f;
if (pos.Z >= posCl.Z + viewOffset - diff)
isHead = true;
float damage = param2.Damage;
string? weapon = param2.Ability?.Value?.DesignerName;
if (weapon != null)
dealDamage = CalculateDamage(player, weapon, damage, isHead);
}
KillClone(playerSkill);
var playerPawn = player.PlayerPawn.Value;
if (playerPawn != null)
SkillUtils.TakeHealth(playerPawn, (int)param2.Damage);
SkillUtils.TakeHealth(playerPawn, (int)dealDamage);
}
}

View file

@ -23,7 +23,7 @@ namespace src.player.skills
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
// SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
Instance.AddToManifest(melonProp);
}
@ -283,7 +283,7 @@ namespace src.player.skills
public string PlayerModel { get; set; }
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#d0d930", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = true, bool needsTeammates = false, string requiredPermission = "", float cooldown = 30, float duration = 10) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission)
public class SkillConfig(Skills skill = skillName, bool active = false, string color = "#d0d930", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = true, bool needsTeammates = false, string requiredPermission = "", float cooldown = 30, float duration = 10) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission)
{
public float Cooldown { get; set; } = cooldown;
public float Duration { get; set; } = duration;

View file

@ -43,16 +43,18 @@ namespace src.player.skills
if (player == null) return;
players.TryAdd(player, 0);
Server.PrintToChatAll($"Enter: {player?.PlayerName}");
}
public static void OnTriggerExit(CBaseTrigger trigger, CBaseEntity entity)
{
if (!trigger.Globalname.StartsWith(triggerName) || entity.DesignerName != "player") return;
var player = entity.As<CCSPlayerController>();
CCSPlayerPawn playerPawn = new(entity.Handle);
if (playerPawn == null || playerPawn.Controller?.Value == null) return;
CCSPlayerController player = playerPawn.Controller.Value.As<CCSPlayerController>();
if (player == null) return;
players.TryRemove(player, out _);
Server.PrintToChatAll($"Exit: {player?.PlayerName}");
}
public static void OnEntitySpawned(CEntityInstance entity)