Skip to content

Commit

Permalink
8.11.0 (ExMod-Team#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
Misfiy authored Jul 20, 2024
2 parents 7ab6f66 + e20f7cc commit 2765d42
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 14 deletions.
2 changes: 1 addition & 1 deletion EXILED/EXILED.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PropertyGroup>
<!-- This is the global version and is used for all projects that don't have a version -->
<Version Condition="$(Version) == ''">8.10.1-pre</Version>
<Version Condition="$(Version) == ''">8.11.0</Version>
<!-- Enables public beta warning via the PUBLIC_BETA constant -->
<PublicBeta>false</PublicBeta>

Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Items/Firearm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal Firearm(ItemType type)
if (Base.HasAdvantageFlag(AttachmentDescriptiveAdvantages.Flashlight))
firearmStatusFlags |= FirearmStatusFlags.FlashlightEnabled;

Base.Status = new FirearmStatus(Base.AmmoManagerModule.MaxAmmo, firearmStatusFlags, Base.Status.Attachments);
Base.Status = new FirearmStatus(MaxAmmo, firearmStatusFlags, Base.Status.Attachments);
}

/// <inheritdoc cref="BaseCodesValue"/>.
Expand Down
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Items/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public ushort Serial
/// <summary>
/// Gets or sets the scale for the item.
/// </summary>
public Vector3 Scale { get; set; } = Vector3.one;
public virtual Vector3 Scale { get; set; } = Vector3.one;

/// <summary>
/// Gets the <see cref="ItemBase"/> of the item.
Expand Down Expand Up @@ -259,7 +259,7 @@ public static Item Get(ItemBase itemBase)
public static Item Create(ItemType type, Player owner = null) => type switch
{
ItemType.SCP268 => new Usable(type),
ItemType.Adrenaline or ItemType.Medkit or ItemType.Painkillers or ItemType.SCP500 or ItemType.SCP207 or ItemType.SCP1853 => new Consumable(type),
ItemType.Adrenaline or ItemType.Medkit or ItemType.Painkillers or ItemType.SCP500 or ItemType.SCP207 or ItemType.SCP1853 or ItemType.AntiSCP207 => new Consumable(type),
ItemType.SCP244a or ItemType.SCP244b => new Scp244(type),
ItemType.Ammo9x19 or ItemType.Ammo12gauge or ItemType.Ammo44cal or ItemType.Ammo556x45 or ItemType.Ammo762x39 => new Ammo(type),
ItemType.Flashlight or ItemType.Lantern => new Flashlight(type),
Expand Down
9 changes: 8 additions & 1 deletion EXILED/Exiled.API/Features/Items/Throwable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ internal Throwable(ItemType type, Player player = null)
{
}

/// <inheritdoc/>
public override Vector3 Scale
{
get => base.Scale;
set => Projectile.Scale = base.Scale = value;
}

/// <summary>
/// Gets the <see cref="ThrowableItem"/> base for this item.
/// </summary>
Expand Down Expand Up @@ -101,4 +108,4 @@ public void Throw(bool fullForce = true)
/// <returns>A string containing Throwable-related data.</returns>
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{PinPullTime}|";
}
}
}
5 changes: 4 additions & 1 deletion EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences
/// Gets a value indicating whether or not the player's <see cref="RoleTypeId"/> is any NTF rank.
/// Equivalent to checking the player's <see cref="Team"/>.
/// </summary>
public bool IsNTF => Role?.Team is Team.FoundationForces && Role?.Type is not RoleTypeId.FacilityGuard;
// TODO: Change logic for FacilityGuard in next major update
public bool IsNTF => Role?.Team is Team.FoundationForces;

/// <summary>
/// Gets a value indicating whether or not the player's <see cref="RoleTypeId"/> is any Chaos rank.
Expand Down Expand Up @@ -2153,6 +2154,8 @@ public bool UseItem(Item item)
usableItem.Base.Owner = referenceHub;
usableItem.Base.ServerOnUsingCompleted();

typeof(UsableItemsController).InvokeStaticEvent(nameof(UsableItemsController.ServerOnUsingCompleted), new object[] { referenceHub, usableItem.Base });

if (usableItem.Base is not null)
usableItem.Destroy();

Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static class Round
/// <summary>
/// Gets a value indicating whether the round in progress or not.
/// </summary>
public static bool InProgress => ReferenceHub.LocalHub is not null && RoundSummary.RoundInProgress();
public static bool InProgress => ReferenceHub.LocalHub != null && RoundSummary.RoundInProgress();

/// <summary>
/// Gets a value indicating whether the round is ended or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,28 @@ namespace Exiled.Events.EventArgs.Player
using API.Features;

using Exiled.API.Enums;
using Exiled.API.Features.Items;

using Interfaces;

using InventorySystem.Items.Radio;

using static InventorySystem.Items.Radio.RadioMessages;

/// <summary>
/// Contains all information before radio preset is changed.
/// </summary>
public class ChangingRadioPresetEventArgs : IPlayerEvent, IDeniableEvent
public class ChangingRadioPresetEventArgs : IPlayerEvent, IItemEvent, IDeniableEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="ChangingRadioPresetEventArgs" /> class.
/// </summary>
/// <param name="player">
/// <inheritdoc cref="Player" />
/// </param>
/// <param name="item">
/// <inheritdoc cref="Item" />
/// </param>
/// <param name="oldValue">
/// <inheritdoc cref="OldValue" />
/// </param>
Expand All @@ -35,9 +41,10 @@ public class ChangingRadioPresetEventArgs : IPlayerEvent, IDeniableEvent
/// <param name="isAllowed">
/// <inheritdoc cref="IsAllowed" />
/// </param>
public ChangingRadioPresetEventArgs(Player player, RadioRangeLevel oldValue, RadioRangeLevel newValue, bool isAllowed = true)
public ChangingRadioPresetEventArgs(Player player, RadioItem item, RadioRangeLevel oldValue, RadioRangeLevel newValue, bool isAllowed = true)
{
Player = player;
Radio = (Radio)Item.Get(item);
OldValue = (RadioRange)oldValue;
NewValue = (RadioRange)newValue;
IsAllowed = isAllowed;
Expand All @@ -64,5 +71,13 @@ public ChangingRadioPresetEventArgs(Player player, RadioRangeLevel oldValue, Rad
/// Gets the player who's using the radio.
/// </summary>
public Player Player { get; }

/// <inheritdoc/>
public Item Item => Radio;

/// <summary>
/// Gets the <see cref="API.Features.Items.Radio" /> which is being used.
/// </summary>
public Radio Radio { get; }
}
}
7 changes: 6 additions & 1 deletion EXILED/Exiled.Events/EventArgs/Player/HurtingEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace Exiled.Events.EventArgs.Player
{
using API.Features;
using API.Features.DamageHandlers;

using Interfaces;
using PlayerStatsSystem;

using CustomAttackerHandler = API.Features.DamageHandlers.AttackerDamageHandler;
using DamageHandlerBase = PlayerStatsSystem.DamageHandlerBase;
Expand Down Expand Up @@ -55,6 +55,11 @@ public float Amount
/// <inheritdoc/>
public CustomDamageHandler DamageHandler { get; set; }

/// <summary>
/// Gets a value indicating whether the incoming damage is an instant kill.
/// </summary>
public bool IsInstantKill => Amount == StandardDamageHandler.KillValue;

/// <inheritdoc/>
public bool IsAllowed { get; set; } = true;
}
Expand Down
57 changes: 57 additions & 0 deletions EXILED/Exiled.Events/EventArgs/Scp939/PlayingFootstepEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// -----------------------------------------------------------------------
// <copyright file="PlayingFootstepEventArgs.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.EventArgs.Scp939
{
using API.Features;
using Exiled.API.Features.Roles;
using Interfaces;

/// <summary>
/// Contains all information before the footsteps are being shown to SCP-939.
/// </summary>
public class PlayingFootstepEventArgs : IScp939Event, IDeniableEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="PlayingFootstepEventArgs" /> class.
/// </summary>
/// <param name="player">
/// The player who's controlling SCP-939.
/// </param>
/// <param name="target">
/// The player who's being shown to SCP-939.
/// </param>
/// <param name="isAllowed">
/// Indicates whether the footstep action is allowed.
/// </param>
public PlayingFootstepEventArgs(Player target, Player player, bool isAllowed = true)
{
Player = player;
Scp939 = Player.Role.As<Scp939Role>();
Target = target;
IsAllowed = isAllowed;
}

/// <summary>
/// Gets the player who's controlling SCP-939.
/// </summary>
public Player Player { get; }

/// <inheritdoc/>
public Scp939Role Scp939 { get; }

/// <summary>
/// Gets the player who's being shown to SCP-939.
/// </summary>
public Player Target { get; }

/// <summary>
/// Gets or sets a value indicating whether footsteps are visible.
/// </summary>
public bool IsAllowed { get; set; }
}
}
11 changes: 11 additions & 0 deletions EXILED/Exiled.Events/Handlers/Scp939.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public static class Scp939
/// </summary>
public static Event<PlayingVoiceEventArgs> PlayingVoice { get; set; } = new();

/// <summary>
/// Invoked before footstep displayed to SCP-939.
/// </summary>
public static Event<PlayingFootstepEventArgs> PlayingFootstep { get; set; } = new();

/// <summary>
/// Invoked before SCP-939 will save Human voice.
/// </summary>
Expand Down Expand Up @@ -94,6 +99,12 @@ public static class Scp939
/// <param name="ev">The <see cref="PlayingSoundEventArgs"/> instance.</param>
public static void OnPlayingSound(PlayingSoundEventArgs ev) => PlayingSound.InvokeSafely(ev);

/// <summary>
/// Called before footstep displayed to SCP-939.
/// </summary>
/// <param name="ev">The <see cref="PlayingFootstepEventArgs" /> instance.</param>
public static void OnPlayingFootstep(PlayingFootstepEventArgs ev) => PlayingFootstep.InvokeSafely(ev);

/// <summary>
/// Called after SCP-939 attacks.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Exiled.Events.Patches.Events.Item
/// Patches <see cref="KeycardPickup.ProcessCollision(Collision)"/>.
/// Adds the <see cref="Handlers.Player.InteractingDoor"/> event.
/// </summary>
[EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.InteractingDoor))]
[EventPatch(typeof(Handlers.Item), nameof(Handlers.Item.KeycardInteracting))]
[HarmonyPatch(typeof(KeycardPickup), nameof(KeycardPickup.ProcessCollision))]
internal static class KeycardInteracting
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Exiled.Events.Patches.Events.Player

using API.Features;
using API.Features.Pools;

using Exiled.Events.Attributes;
using Exiled.Events.EventArgs.Player;

Expand Down Expand Up @@ -50,6 +51,9 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(OpCodes.Call, PropertyGetter(typeof(ItemBase), nameof(ItemBase.Owner))),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),

// this (radioItem)
new(OpCodes.Ldarg_0),

// (RadioRangeLevel)this._rangeId
new(OpCodes.Ldarg_0),
new(OpCodes.Ldfld, Field(typeof(RadioItem), nameof(RadioItem._rangeId))),
Expand All @@ -62,7 +66,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// true
new(OpCodes.Ldc_I4_1),

// ChangingRadioPresetEventArgs ev = new(Player, byte, byte, true)
// ChangingRadioPresetEventArgs ev = new(Player, RadioItem, byte, byte, true)
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ChangingRadioPresetEventArgs))[0]),
new(OpCodes.Dup),
new(OpCodes.Dup),
Expand Down Expand Up @@ -91,4 +95,4 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
ListPool<CodeInstruction>.Pool.Return(newInstructions);
}
}
}
}
79 changes: 79 additions & 0 deletions EXILED/Exiled.Events/Patches/Events/Scp939/PlayingFootstep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// -----------------------------------------------------------------------
// <copyright file="PlayingFootstep.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.Patches.Events.Scp939
{
using System.Collections.Generic;
using System.Reflection.Emit;

using Exiled.API.Features.Pools;
using Exiled.Events.Attributes;
using Exiled.Events.EventArgs.Scp939;
using Exiled.Events.Handlers;

using HarmonyLib;
using PlayerRoles.FirstPersonControl.Thirdperson;
using PlayerRoles.PlayableScps.Scp939;
using PlayerRoles.PlayableScps.Scp939.Ripples;
using PlayerRoles.Subroutines;

using static HarmonyLib.AccessTools;

/// <summary>
/// Patches <see cref="FootstepRippleTrigger.OnFootstepPlayed(AnimatedCharacterModel, float)" />
/// to add the <see cref="Scp939.PlayingFootstep" /> event.
/// </summary>
[EventPatch(typeof(Scp939), nameof(Scp939.PlayingFootstep))]
[HarmonyPatch(typeof(FootstepRippleTrigger), nameof(FootstepRippleTrigger.OnFootstepPlayed))]
internal static class PlayingFootstep
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);

Label ret = generator.DefineLabel();

int offset = 3;
int index = newInstructions.FindLastIndex(i => i.Calls(Method(typeof(RippleTriggerBase), nameof(RippleTriggerBase.CheckVisibility)))) + offset;

newInstructions.InsertRange(index, new CodeInstruction[]
{
// Player target = Player.Get(characterModel.OwnerHub);
new CodeInstruction(OpCodes.Ldarg_1).MoveLabelsFrom(newInstructions[index]),
new(OpCodes.Callvirt, PropertyGetter(typeof(CharacterModel), nameof(CharacterModel.OwnerHub))),
new(OpCodes.Call, Method(typeof(API.Features.Player), nameof(API.Features.Player.Get), new[] { typeof(ReferenceHub) })),

// Player player = Player.Get(this.Owner);
new(OpCodes.Ldarg_0),
new(OpCodes.Call, PropertyGetter(typeof(StandardSubroutine<Scp939Role>), nameof(StandardSubroutine<Scp939Role>.Owner))),
new(OpCodes.Call, Method(typeof(API.Features.Player), nameof(API.Features.Player.Get), new[] { typeof(ReferenceHub) })),

// true;
new(OpCodes.Ldc_I4_1),

// PlayingFootstepEventArgs ev = (player, scp939, true);
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(PlayingFootstepEventArgs))[0]),
new(OpCodes.Dup),

// Handlers.Scp939.OnPlayingFootstep(ev);
new(OpCodes.Call, Method(typeof(Scp939), nameof(Scp939.OnPlayingFootstep))),

// if (!IsAllowed)
// return;
new(OpCodes.Callvirt, PropertyGetter(typeof(PlayingFootstepEventArgs), nameof(PlayingFootstepEventArgs.IsAllowed))),
new(OpCodes.Brfalse_S, ret),
});

newInstructions[newInstructions.Count - 1].labels.Add(ret);

for (int z = 0; z < newInstructions.Count; z++)
yield return newInstructions[z];

ListPool<CodeInstruction>.Pool.Return(newInstructions);
}
}
}
1 change: 0 additions & 1 deletion EXILED/Exiled.Events/Patches/Fixes/GrenadePropertiesFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// baseProjectile.transform.position = this.Owner.PlayerCameraReference.position;
// baseProjectile.transform.rotation = this.Owner.PlayerCameraReference.rotation;
// baseProjectile.gameObject.SetActive(true);
// projectile.Spawned = true;
newInstructions.InsertRange(index, new[]
{
// if (Item.Get(this) is Throwable throwable) goto cnt;
Expand Down

0 comments on commit 2765d42

Please sign in to comment.