From 48179e7481698c4d2a602c95193760576efcd8bf Mon Sep 17 00:00:00 2001 From: Snivy Films Date: Sat, 15 Mar 2025 09:15:49 -0400 Subject: [PATCH 1/4] Fixes the Frenchie's English --- EXILED/Exiled.API/Features/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 0210830293..2f6597d830 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -3278,7 +3278,7 @@ public void EnableEffect(EffectType type, float duration = 0f, bool addDurationI /// The intensity of the effect will be active for. /// The amount of time the effect will be active for. /// If the effect is already active, setting to will add this duration onto the effect. - /// return if the effect has been Enable. + /// A bool indicating whether the effect was valid and successfully enabled. public bool EnableEffect(EffectType type, byte intensity, float duration = 0f, bool addDurationIfActive = false) => TryGetEffect(type, out StatusEffectBase statusEffect) && EnableEffect(statusEffect, intensity, duration, addDurationIfActive); From 08f940e7bd6714a2625220d7306b8ab336742986 Mon Sep 17 00:00:00 2001 From: Snivy Films Date: Fri, 25 Apr 2025 14:17:26 -0400 Subject: [PATCH 2/4] New Custom Stuff (Untested) --- .../API/Features/CustomWeapon.cs | 20 +++++++++++++++++++ .../API/Features/CustomRole.cs | 12 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs b/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs index e775ee3e9f..0fcffcd789 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs @@ -5,6 +5,8 @@ // // ----------------------------------------------------------------------- +using Exiled.Events.EventArgs.Item; + namespace Exiled.CustomItems.API.Features { using System; @@ -151,6 +153,7 @@ protected override void SubscribeEvents() Exiled.Events.Handlers.Player.Shooting += OnInternalShooting; Exiled.Events.Handlers.Player.Shot += OnInternalShot; Exiled.Events.Handlers.Player.Hurting += OnInternalHurting; + Exiled.Events.Handlers.Item.ChangingAttachments += OnInternalAttachmentChanging; base.SubscribeEvents(); } @@ -163,6 +166,7 @@ protected override void UnsubscribeEvents() Exiled.Events.Handlers.Player.Shooting -= OnInternalShooting; Exiled.Events.Handlers.Player.Shot -= OnInternalShot; Exiled.Events.Handlers.Player.Hurting -= OnInternalHurting; + Exiled.Events.Handlers.Item.ChangingAttachments -= OnInternalAttachmentChanging; base.UnsubscribeEvents(); } @@ -209,6 +213,14 @@ protected virtual void OnHurting(HurtingEventArgs ev) ev.Amount = Damage; } + /// + /// Handles attachment changing for custom weapons. + /// + /// . + protected virtual void OnAttachmentChanging(ChangingAttachmentsEventArgs ev) + { + } + private void OnInternalReloading(ReloadingWeaponEventArgs ev) { if (!Check(ev.Player.CurrentItem)) @@ -321,5 +333,13 @@ private void OnInternalHurting(HurtingEventArgs ev) OnHurting(ev); } + + private void OnInternalAttachmentChanging(ChangingAttachmentsEventArgs ev) + { + if (!Check(ev.Player.CurrentItem)) + return; + + OnAttachmentChanging(ev); + } } } \ No newline at end of file diff --git a/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs b/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs index 7d7fd8b5bf..c52f4418e5 100644 --- a/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs +++ b/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs @@ -5,6 +5,9 @@ // // ----------------------------------------------------------------------- +using System.Numerics; +using Exiled.API.Features.Items; + namespace Exiled.CustomRoles.API.Features { using System; @@ -535,7 +538,14 @@ public virtual void AddRole(Player player) foreach (string itemName in Inventory) { Log.Debug($"{Name}: Adding {itemName} to inventory."); - TryAddItem(player, itemName); + if (TryAddItem(player, itemName) && CustomItem.TryGet(itemName, out CustomItem? customItem) && customItem is CustomWeapon customWeapon) + { + if (player.CurrentItem is Firearm firearm && !customWeapon.Attachments.IsEmpty()) + { + firearm.AddAttachment(customWeapon.Attachments); + Log.Debug($"{Name}: Applied attachments to {itemName}."); + } + } } if (Ammo.Count > 0) From dfa668ae32e96bacb5854e5d8f5486444499e088 Mon Sep 17 00:00:00 2001 From: Snivy Films Date: Fri, 25 Apr 2025 15:37:03 -0400 Subject: [PATCH 3/4] Corrected Attachment Changing --- .../Exiled.CustomItems/API/Features/CustomWeapon.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs b/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs index 0fcffcd789..ac8930dee9 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs @@ -5,8 +5,6 @@ // // ----------------------------------------------------------------------- -using Exiled.Events.EventArgs.Item; - namespace Exiled.CustomItems.API.Features { using System; @@ -18,6 +16,7 @@ namespace Exiled.CustomItems.API.Features using Exiled.API.Features.DamageHandlers; using Exiled.API.Features.Items; using Exiled.API.Features.Pickups; + using Exiled.Events.EventArgs.Item; using Exiled.Events.EventArgs.Player; using InventorySystem; using InventorySystem.Items.Firearms.Attachments; @@ -153,7 +152,7 @@ protected override void SubscribeEvents() Exiled.Events.Handlers.Player.Shooting += OnInternalShooting; Exiled.Events.Handlers.Player.Shot += OnInternalShot; Exiled.Events.Handlers.Player.Hurting += OnInternalHurting; - Exiled.Events.Handlers.Item.ChangingAttachments += OnInternalAttachmentChanging; + Exiled.Events.Handlers.Item.ChangingAttachments += OnInternalChangingAttachment; base.SubscribeEvents(); } @@ -166,7 +165,7 @@ protected override void UnsubscribeEvents() Exiled.Events.Handlers.Player.Shooting -= OnInternalShooting; Exiled.Events.Handlers.Player.Shot -= OnInternalShot; Exiled.Events.Handlers.Player.Hurting -= OnInternalHurting; - Exiled.Events.Handlers.Item.ChangingAttachments -= OnInternalAttachmentChanging; + Exiled.Events.Handlers.Item.ChangingAttachments -= OnInternalChangingAttachment; base.UnsubscribeEvents(); } @@ -217,7 +216,7 @@ protected virtual void OnHurting(HurtingEventArgs ev) /// Handles attachment changing for custom weapons. /// /// . - protected virtual void OnAttachmentChanging(ChangingAttachmentsEventArgs ev) + protected virtual void OnChangingAttachment(ChangingAttachmentsEventArgs ev) { } @@ -334,12 +333,12 @@ private void OnInternalHurting(HurtingEventArgs ev) OnHurting(ev); } - private void OnInternalAttachmentChanging(ChangingAttachmentsEventArgs ev) + private void OnInternalChangingAttachment(ChangingAttachmentsEventArgs ev) { if (!Check(ev.Player.CurrentItem)) return; - OnAttachmentChanging(ev); + OnChangingAttachment(ev); } } } \ No newline at end of file From dab59f3748be40a72d77fc9108df2c1629a45c3c Mon Sep 17 00:00:00 2001 From: Snivy Films Date: Fri, 25 Apr 2025 15:37:23 -0400 Subject: [PATCH 4/4] Minor fix --- EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs b/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs index c52f4418e5..64b6e5d243 100644 --- a/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs +++ b/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs @@ -5,9 +5,6 @@ // // ----------------------------------------------------------------------- -using System.Numerics; -using Exiled.API.Features.Items; - namespace Exiled.CustomRoles.API.Features { using System; @@ -20,6 +17,7 @@ namespace Exiled.CustomRoles.API.Features using Exiled.API.Extensions; using Exiled.API.Features; using Exiled.API.Features.Attributes; + using Exiled.API.Features.Items; using Exiled.API.Features.Pools; using Exiled.API.Features.Spawn; using Exiled.API.Interfaces;