From 5a21c0365d30d0f14282e785fc6515dd167ffd15 Mon Sep 17 00:00:00 2001 From: galaxy119 Date: Wed, 3 Mar 2021 06:04:38 -0800 Subject: [PATCH] Fix for tranq gun clearing existing effects. Fix for tranq gun setting current item without respecting old items attributed. Fix for Implosion grenades getting players stuck inside eachother's colliders. Added blacklistedRoles list for Implosion grenade to make it not affect certain roles. --- CustomItems/CustomItems.csproj | 3 +++ CustomItems/Items/ImplosionGrenade.cs | 16 +++++++++++++--- CustomItems/Items/TranquilizerGun.cs | 16 ++++++++++++++-- CustomItems/Properties/AssemblyInfo.cs | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/CustomItems/CustomItems.csproj b/CustomItems/CustomItems.csproj index fea2d08..79f322b 100644 --- a/CustomItems/CustomItems.csproj +++ b/CustomItems/CustomItems.csproj @@ -87,6 +87,9 @@ $(EXILED_REFERENCES)\Mirror.dll + + ..\..\References\NorthwoodLib.dll + $(EXILED_REFERENCES)\Subclass.dll diff --git a/CustomItems/Items/ImplosionGrenade.cs b/CustomItems/Items/ImplosionGrenade.cs index 711239b..fa8eda9 100644 --- a/CustomItems/Items/ImplosionGrenade.cs +++ b/CustomItems/Items/ImplosionGrenade.cs @@ -78,11 +78,17 @@ public class ImplosionGrenade : CustomGrenade public float SuctionPerTick { get; set; } = 0.125f; /// - /// Gets or sets how often each suction tick will occus. Note: Setting the tick-rate and suction-per-tick to lower numbers maks for a 'smoother' suction movement, however causes more stress on your server. Adjust accordingly. + /// Gets or sets how often each suction tick will occurs. Note: Setting the tick-rate and suction-per-tick to lower numbers maks for a 'smoother' suction movement, however causes more stress on your server. Adjust accordingly. /// [Description("How often each suction tick will occus. Note: Setting the tick-rate and suction-per-tick to lower numbers maks for a 'smoother' suction movement, however causes more stress on your server. Adjust accordingly.")] public float SuctionTickRate { get; set; } = 0.025f; + /// + /// Gets or sets a list of roles unable to be affected by Implosion grenades. + /// + [Description("What roles will not be able to be affected by Implosion Grenades. Keeping SCP-173 on this list is highly recommended.")] + public HashSet BlacklistedRoles { get; set; } = new HashSet { RoleType.Scp173, RoleType.Tutorial, }; + private List Coroutines { get; set; } = new List(); /// @@ -110,9 +116,10 @@ private IEnumerator DoSuction(Player player, Vector3 position) for (int i = 0; i < SuctionCount; i++) { Log.Debug($"{player.Nickname} suctioned?", CustomItems.Instance.Config.IsDebugEnabled); - Vector3 newPos = Vector3.MoveTowards(player.Position, position, SuctionPerTick); + Vector3 alteredPosition = position + (1f * (player.Position - position).normalized); + Vector3 newPos = Vector3.MoveTowards(player.Position, alteredPosition, SuctionPerTick); if (!Physics.Linecast(player.Position, newPos, player.ReferenceHub.playerMovementSync.CollidableSurfaces)) - player.Position = Vector3.MoveTowards(player.Position, position, SuctionPerTick); + player.Position = newPos; yield return Timing.WaitForSeconds(SuctionTickRate); } @@ -137,6 +144,9 @@ private void OnExplodingGrenade(ExplodingGrenadeEventArgs ev) foreach (Player player in copiedList.Keys) { ev.TargetToDamages.Add(player, copiedList[player] * DamageModifier); + if (BlacklistedRoles.Contains(player.Role)) + continue; + Log.Debug($"{player.Nickname} starting suction", CustomItems.Instance.Config.IsDebugEnabled); try diff --git a/CustomItems/Items/TranquilizerGun.cs b/CustomItems/Items/TranquilizerGun.cs index 916dc1a..1695b29 100644 --- a/CustomItems/Items/TranquilizerGun.cs +++ b/CustomItems/Items/TranquilizerGun.cs @@ -124,13 +124,19 @@ protected override void OnHurting(HurtingEventArgs ev) private IEnumerator DoTranquilize(Player player, float duration) { Vector3 oldPosition = player.Position; - ItemType previousItem = player.Inventory.curItem; + Inventory.SyncItemInfo previousItem = + player.ReferenceHub.inventory.items[player.ReferenceHub.inventory.GetItemIndex()]; Vector3 previousScale = player.Scale; float newHealth = player.Health - Damage; + List activeEffects = NorthwoodLib.Pools.ListPool.Shared.Rent(); if (newHealth <= 0) yield break; + foreach (PlayerEffect effect in player.ReferenceHub.playerEffectsController.AllEffects.Values) + if (effect.Enabled) + activeEffects.Add(effect); + if (DropItems) { foreach (Inventory.SyncItemInfo item in player.Inventory.items.ToList()) @@ -171,7 +177,13 @@ private IEnumerator DoTranquilize(Player player, float duration) player.IsInvisible = false; if (!DropItems) - player.Inventory.curItem = previousItem; + player.Inventory.CmdSetUnic(previousItem.uniq); + + foreach (PlayerEffect effect in activeEffects) + if ((effect.Duration - duration) > 0) + player.ReferenceHub.playerEffectsController.EnableEffect(effect, effect.Duration - duration); + + NorthwoodLib.Pools.ListPool.Shared.Return(activeEffects); if (Warhead.IsDetonated && player.Position.y < 900) { diff --git a/CustomItems/Properties/AssemblyInfo.cs b/CustomItems/Properties/AssemblyInfo.cs index f5a51e1..9a7cbd6 100644 --- a/CustomItems/Properties/AssemblyInfo.cs +++ b/CustomItems/Properties/AssemblyInfo.cs @@ -38,5 +38,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.7.0")] +[assembly: AssemblyVersion("2.1.8.0")] [assembly: AssemblyFileVersion("2.0.0.0")] \ No newline at end of file