1.0.2
This commit is contained in:
parent
68f26a22f4
commit
68776c3382
28 changed files with 819 additions and 116 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using static dRandomSkills.dRandomSkills;
|
||||
|
||||
namespace dRandomSkills
|
||||
|
|
@ -8,8 +10,31 @@ namespace dRandomSkills
|
|||
|
||||
public static void LoadRozbrojenie()
|
||||
{
|
||||
Utils.RegisterSkill("Rozbrojenie", "Masz 25% szans na wyrzucenie broni wroga po trafieniu", "#FF4500");
|
||||
|
||||
Utils.RegisterSkill("Rozbrojenie", "Masz losow¹ szanse na wyrzucenie broni wroga po trafieniu", "#FF4500", false);
|
||||
|
||||
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
|
||||
{
|
||||
Instance.AddTimer(0.1f, () =>
|
||||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!IsPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != "Rozbrojenie") continue;
|
||||
|
||||
float newChance = (float)Instance.Random.NextDouble() * (.40f - .20f) + .20f;
|
||||
playerInfo.SkillChance = newChance;
|
||||
newChance = (float)Math.Round(newChance, 2) * 100;
|
||||
newChance = (float)Math.Round(newChance);
|
||||
|
||||
Utils.PrintToChat(player, $"{ChatColors.DarkRed}\"Rozbrojenie\"{ChatColors.Lime}: Twoje szanse na wyrzucenie broni wroga to: {newChance}%", false);
|
||||
}
|
||||
});
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
|
||||
{
|
||||
var attacker = @event.Attacker;
|
||||
|
|
@ -23,23 +48,22 @@ namespace dRandomSkills
|
|||
|
||||
if (playerInfo?.Skill == "Rozbrojenie" && victim.PawnIsAlive)
|
||||
{
|
||||
if (Instance.Random.NextDouble() <= 0.25)
|
||||
if (Instance.Random.NextDouble() <= playerInfo.SkillChance)
|
||||
{
|
||||
var weaponServices = victim.PlayerPawn?.Value?.WeaponServices;
|
||||
if (weaponServices?.MyWeapons == null) return HookResult.Continue;
|
||||
if (weaponServices?.ActiveWeapon == null) return HookResult.Continue;
|
||||
|
||||
foreach (var weapon in weaponServices.MyWeapons)
|
||||
{
|
||||
var weaponName = weapon.Value.DesignerName;
|
||||
if (weaponName != null && !weaponName.Contains("weapon_knife") && !weaponName.Contains("weapon_c4"))
|
||||
{
|
||||
victim.DropActiveWeapon();
|
||||
}
|
||||
}
|
||||
var weaponName = weaponServices?.ActiveWeapon?.Value?.DesignerName;
|
||||
if (weaponName != null && !weaponName.Contains("weapon_knife") && !weaponName.Contains("weapon_c4"))
|
||||
victim.DropActiveWeapon();
|
||||
}
|
||||
}
|
||||
return HookResult.Continue;
|
||||
});
|
||||
}
|
||||
private static bool IsPlayerValid(CCSPlayerController player)
|
||||
{
|
||||
return player != null && player.IsValid && player.PlayerPawn?.Value != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue