Skip to content

Commit

Permalink
Fix for tranq gun clearing existing effects.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joker-119 committed Mar 3, 2021
1 parent 4f82e89 commit 5a21c03
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CustomItems/CustomItems.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
<Reference Include="Mirror, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>$(EXILED_REFERENCES)\Mirror.dll</HintPath>
</Reference>
<Reference Include="NorthwoodLib, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\References\NorthwoodLib.dll</HintPath>
</Reference>
<Reference Include="Subclass">
<HintPath>$(EXILED_REFERENCES)\Subclass.dll</HintPath>
</Reference>
Expand Down
16 changes: 13 additions & 3 deletions CustomItems/Items/ImplosionGrenade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ public class ImplosionGrenade : CustomGrenade
public float SuctionPerTick { get; set; } = 0.125f;

/// <summary>
/// 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.
/// </summary>
[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;

/// <summary>
/// Gets or sets a list of roles unable to be affected by Implosion grenades.
/// </summary>
[Description("What roles will not be able to be affected by Implosion Grenades. Keeping SCP-173 on this list is highly recommended.")]
public HashSet<RoleType> BlacklistedRoles { get; set; } = new HashSet<RoleType> { RoleType.Scp173, RoleType.Tutorial, };

private List<CoroutineHandle> Coroutines { get; set; } = new List<CoroutineHandle>();

/// <inheritdoc/>
Expand Down Expand Up @@ -110,9 +116,10 @@ private IEnumerator<float> 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);
}
Expand All @@ -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
Expand Down
16 changes: 14 additions & 2 deletions CustomItems/Items/TranquilizerGun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,19 @@ protected override void OnHurting(HurtingEventArgs ev)
private IEnumerator<float> 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<PlayerEffect> activeEffects = NorthwoodLib.Pools.ListPool<PlayerEffect>.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())
Expand Down Expand Up @@ -171,7 +177,13 @@ private IEnumerator<float> 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<PlayerEffect>.Shared.Return(activeEffects);

if (Warhead.IsDetonated && player.Position.y < 900)
{
Expand Down
2 changes: 1 addition & 1 deletion CustomItems/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

0 comments on commit 5a21c03

Please sign in to comment.