Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions EXILED/Exiled.Events/EventArgs/Item/CacklingEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="CacklingEventArgs.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
Expand All @@ -20,13 +20,12 @@ public class CacklingEventArgs : IMarshmallowEvent, IDeniableEvent
/// <summary>
/// Initializes a new instance of the <see cref="CacklingEventArgs"/> class.
/// </summary>
/// <param name="player">The Player cackling.</param>
/// <param name="marshmallow">The marshmallow item of the player cackling.</param>
/// <param name="isAllowed">Whether the player is allowed to cackle.</param>
public CacklingEventArgs(Player player, MarshmallowItem marshmallow, bool isAllowed = true)
public CacklingEventArgs(MarshmallowItem marshmallow, bool isAllowed = true)
{
Player = player;
Marshmallow = Item.Get<Marshmallow>(marshmallow);
Player = Marshmallow.Owner;
IsAllowed = isAllowed;
}

Expand Down
7 changes: 3 additions & 4 deletions EXILED/Exiled.Events/EventArgs/Item/PunchingEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="PunchingEventArgs.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
Expand All @@ -20,13 +20,12 @@ public class PunchingEventArgs : IMarshmallowEvent, IDeniableEvent
/// <summary>
/// Initializes a new instance of the <see cref="PunchingEventArgs"/> class.
/// </summary>
/// <param name="player">The Player attacking.</param>
/// <param name="marshmallow">The marshmallow item of the player attacking.</param>
/// <param name="isAllowed">Whether the player is allowed to punch.</param>
public PunchingEventArgs(Player player, MarshmallowItem marshmallow, bool isAllowed = true)
public PunchingEventArgs(MarshmallowItem marshmallow, bool isAllowed = true)
{
Player = player;
Marshmallow = Item.Get<Marshmallow>(marshmallow);
Player = Marshmallow.Owner;
IsAllowed = isAllowed;
}

Expand Down
3 changes: 3 additions & 0 deletions EXILED/Exiled.Events/Handlers/Internal/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public static void OnSpawningRagdoll(SpawningRagdollEventArgs ev)
{
if (ev.Role.IsDead() || !ev.Role.IsFpcRole())
ev.IsAllowed = false;

if (ev.DamageHandlerBase is Exiled.Events.Patches.Fixes.FixMarshmallowManFF fixMarshamllowManFf)
ev.DamageHandlerBase = fixMarshamllowManFf.MarshmallowItem.NewDamageHandler;
}

/// <inheritdoc cref="Scp049.OnActivatingSense(ActivatingSenseEventArgs)" />
Expand Down
12 changes: 4 additions & 8 deletions EXILED/Exiled.Events/Patches/Events/Item/Cackling.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="Cackling.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
Expand Down Expand Up @@ -38,18 +38,14 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

newInstructions.InsertRange(index, new[]
{
// player = Player.Get(Owner);
// this;
new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]),
new(OpCodes.Callvirt, PropertyGetter(typeof(MarshmallowItem), nameof(MarshmallowItem.Owner))),

// item = this;
new(OpCodes.Ldarg_0),

// true
new(OpCodes.Ldc_I4_1),

// ev = new CacklingEventArgs(player, item, true);
new(OpCodes.Newobj, Constructor(typeof(CacklingEventArgs), new[] { typeof(Player), typeof(MarshmallowItem), typeof(bool) })),
// ev = new CacklingEventArgs(MarshmallowItem, bool);
new(OpCodes.Newobj, Constructor(typeof(CacklingEventArgs), new[] { typeof(MarshmallowItem), typeof(bool) })),
new(OpCodes.Dup),
new(OpCodes.Call, Method(typeof(Handlers.Item), nameof(Handlers.Item.OnCackling))),

Expand Down
12 changes: 4 additions & 8 deletions EXILED/Exiled.Events/Patches/Events/Item/Punching.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="Punching.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
Expand Down Expand Up @@ -40,18 +40,14 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

newInstructions.InsertRange(index, new[]
{
// player = Player.Get(Owner);
// this;
new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]),
new(OpCodes.Callvirt, PropertyGetter(typeof(MarshmallowItem), nameof(MarshmallowItem.Owner))),

// item = this;
new(OpCodes.Ldarg_0),

// true
new(OpCodes.Ldc_I4_1),

// ev = new PunchingEventArgs(player, item, true);
new(OpCodes.Newobj, Constructor(typeof(PunchingEventArgs), new[] { typeof(Player), typeof(MarshmallowItem), typeof(bool) })),
// ev = new PunchingEventArgs(MarshmallowItem, bool);
new(OpCodes.Newobj, Constructor(typeof(PunchingEventArgs), new[] { typeof(MarshmallowItem), typeof(bool) })),
new(OpCodes.Dup),
new(OpCodes.Call, Method(typeof(Handlers.Item), nameof(Handlers.Item.OnPunching))),

Expand Down
14 changes: 8 additions & 6 deletions EXILED/Exiled.Events/Patches/Fixes/FixMarshmallowManFF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Exiled.Events.Patches.Fixes
using InventorySystem.Items.ThrowableProjectiles;
using Mirror;
using PlayerRoles;
using PlayerRoles.FirstPersonControl;
using PlayerStatsSystem;
using Respawning.NamingRules;
using Subtitles;
Expand All @@ -35,16 +36,17 @@ internal class FixMarshmallowManFF : AttackerDamageHandler
#pragma warning disable SA1600 // Elements should be documented
public FixMarshmallowManFF(MarshmallowItem marshmallowItem, bool isEvilMode)
{
MarshmallowItem = marshmallowItem;
Attacker = new(marshmallowItem.Owner);
Damage = marshmallowItem._attackDamage;
IsFriendlyFire = isEvilMode;
AllowSelfDamage = false;
ServerLogsText = "MarshmallowManFF Fix";
ForceFullFriendlyFire = isEvilMode;
}

public MarshmallowItem MarshmallowItem { get; set; }

public override Footprint Attacker { get; set; }

public override bool AllowSelfDamage { get; }
public override bool AllowSelfDamage { get; } = false;

public override float Damage { get; set; }

Expand All @@ -61,7 +63,7 @@ public FixMarshmallowManFF(MarshmallowItem marshmallowItem, bool isEvilMode)

public override string DeathScreenText { get; } = DeathTranslations.MarshmallowMan.DeathscreenTranslation;

public override string ServerLogsText { get; }
public override string ServerLogsText => "Stabbed with Marshmallow Item by " + Attacker.Nickname;
#pragma warning restore SA1600 // Elements should be documented
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter

Expand All @@ -77,7 +79,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
{
new(OpCodes.Ldarg_0),
new(OpCodes.Callvirt, PropertyGetter(typeof(MarshmallowItem), nameof(MarshmallowItem.EvilMode))),
new(OpCodes.Newobj, Constructor(typeof(FixMarshmallowManFF), new[] { typeof(MarshmallowItem) })),
new(OpCodes.Newobj, Constructor(typeof(FixMarshmallowManFF), new[] { typeof(MarshmallowItem), typeof(bool) })),
});

for (int z = 0; z < newInstructions.Count; z++)
Expand Down
Loading