Skip to content

Commit

Permalink
EXILED 6 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
DGvagabond committed Dec 30, 2022
1 parent 809347f commit 61d6e73
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 80 deletions.
4 changes: 2 additions & 2 deletions Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace SCP008X
public sealed class Config : IConfig
{
/// <inheritdoc />
[Description("Join our Discord for instant support: discord.gg/Ffj29UTg3q")]
public bool IsEnabled { get; set; } = true;

[Description("Only enable this if you're looking for bug sources!")]
public bool DebugMode { get; set; } = false;
public bool Debug { get; set; }

[Description("Percent chance to create infection.")]
public int InfectionChance { get; set; } = 100;
Expand Down
22 changes: 8 additions & 14 deletions DamageUtilities/Scp008GenericDamage.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using Exiled.API.Features;
using Exiled.API.Features.DamageHandlers;
using Footprinting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SCP008X.DamageUtilities
{
Expand All @@ -15,18 +9,18 @@ internal class Scp008GenericDamage : PlayerStatsSystem.AttackerDamageHandler

public Scp008GenericDamage(Player target, Player attacker, float damage, string customReason)
{
this.Player = target;
this.Attacker = attacker.Footprint;
this.Damage = damage;
this.ServerLogsText = customReason;
Log.Debug($"Scp008x log: Target {Player}, Attacker {Attacker} Amount {Damage}", Scp008X.Instance.Config.DebugMode);
Player = target;
Attacker = attacker.Footprint;
Damage = damage;
ServerLogsText = customReason;
Log.Debug($"Scp008x log: Target {Player}, Attacker {Attacker} Amount {Damage}");
}

public Scp008GenericDamage(Player player, Player attacker, float damageAmount)
{
this.Player = player;
this.Attacker = attacker.Footprint;
this.Damage = damageAmount;
Player = player;
Attacker = attacker.Footprint;
Damage = damageAmount;
}

public override bool AllowSelfDamage => true;
Expand Down
53 changes: 25 additions & 28 deletions EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
// </copyright>
// -----------------------------------------------------------------------

using Exiled.Events.EventArgs.Player;
using Exiled.Events.EventArgs.Scp049;
using PlayerRoles;

namespace SCP008X
{
using Exiled.CustomRoles.API.Features;
using Exiled.Events.EventArgs;
using Exiled.API.Features;
using Exiled.API.Enums;
using MEC;
Expand All @@ -16,32 +19,26 @@ public class EventHandlers
{
public void OnRoundStart()
{
if (Scp008X.Instance.Config.CassieAnnounce && Scp008X.Instance.Config.Announcement != null)
{
Cassie.Message(Scp008X.Instance.Config.Announcement);
}
}

public void OnVerified(VerifiedEventArgs ev)
{
ev.Player.SendConsoleMessage("This server uses SCP-008-X, all zombies have been reworked!", "yellow");
if(Scp008X.Instance.Config.CassieAnnounce && Scp008X.Instance.Config.Announcement != null) Cassie.Message(Scp008X.Instance.Config.Announcement);
}

public void OnVerified(VerifiedEventArgs ev) => ev.Player.SendConsoleMessage("This server uses SCP-008-X, all zombies have been reworked.", "yellow");

public void OnHurt(HurtingEventArgs ev)
{
if (ev.Attacker == null) return;
if (ev.Player == null) return;

if (ev.Attacker.Role == RoleType.Scp0492) {
if (ev.Player.Role == RoleTypeId.Scp0492) {
ev.Amount = Scp008X.Instance.Config.ZombieDamage;
}

if (ev.Target.ArtificialHealth >= 0)
if (ev.Player.ArtificialHealth >= 0)
{
ev.IsAllowed = false;
if (ev.Target.ArtificialHealth <= ev.Amount) {
var leftover = ev.Amount - ev.Target.ArtificialHealth;
ev.Target.ArtificialHealth = 0;
ev.Target.Health -= leftover;
if (ev.Player.ArtificialHealth <= ev.Amount) {
var leftover = ev.Amount - ev.Player.ArtificialHealth;
ev.Player.ArtificialHealth = 0;
ev.Player.Health -= leftover;
}
}
}
Expand All @@ -57,15 +54,15 @@ public void OnHealed(UsedItemEventArgs ev)
if (chance <= Scp008X.Instance.Config.CureChance)
{
ev.Player.DisableEffect(EffectType.Poisoned);
Log.Debug($"{ev.Player.Nickname} cured themselves with {chance}% probability.", Scp008X.Instance.Config.DebugMode);
Log.Debug($"{ev.Player.Nickname} cured themselves with {chance}% probability.");
return;
}

Log.Debug($"{ev.Player.Nickname} failed to cure themselves with {chance}% probability.", Scp008X.Instance.Config.DebugMode);
Log.Debug($"{ev.Player.Nickname} failed to cure themselves with {chance}% probability.");
break;
case ItemType.SCP500:
ev.Player.DisableEffect(EffectType.Poisoned);
Log.Debug($"{ev.Player.Nickname} cured themselves with SCP-500.", Scp008X.Instance.Config.DebugMode);
Log.Debug($"{ev.Player.Nickname} cured themselves with SCP-500.");
break;
}
}
Expand All @@ -76,33 +73,33 @@ public void OnReviving(StartingRecallEventArgs ev)

ev.IsAllowed = false;
CustomRole.Get(typeof(Scp008))?.AddRole(ev.Target);
ev.Scp049.ShowHint($"Revived <b><color=green>{ev.Target.Nickname}</color></b>");
ev.Player.ShowHint($"Revived <b><color=green>{ev.Target.Nickname}</color></b>");
}

public void OnDying(DyingEventArgs ev)
{
if (ev.Killer == null && ev.Handler?.Type is DamageType.Poison)
if (ev.Player == null && ev.DamageHandler?.Type is DamageType.Poison)
{
ev.IsAllowed = false;
CustomRole.Get(typeof(Scp008))?.AddRole(ev.Target);
CustomRole.Get(typeof(Scp008))?.AddRole(ev.Player);
return;
}

if(ev.Killer?.Role == RoleType.Scp0492){
if(ev.Player?.Role == RoleTypeId.Scp0492){
ev.IsAllowed = false;
CustomRole.Get(typeof(Scp008))?.AddRole(ev.Target);
CustomRole.Get(typeof(Scp008))?.AddRole(ev.Player);
Timing.CallDelayed(1f, delegate
{
ev.Killer.ShowHint($"Infected <b><color=red>{ev.Target.Nickname}</color></b>", 5);
ev.Player.ShowHint($"Infected <b><color=red>{ev.Player.Nickname}</color></b>", 5);
});
}
}

public void OnShoot(ShootingEventArgs ev)
{
Player targetPlayer = Player.Get(ev.TargetNetId);
var targetPlayer = Player.Get(ev.TargetNetId);
if(targetPlayer != null){
if(ev.Shooter.Role.Side is Side.Scp && targetPlayer.Role.Side is Side.Scp){
if(ev.Player.Role.Side is Side.Scp && targetPlayer.Role.Side is Side.Scp){
ev.IsAllowed = false;
}
}
Expand Down
5 changes: 2 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SCP008X")]
[assembly: AssemblyDescription("An EXILED 2.0 plugin that adds SCP-008 to SCP:SL")]
[assembly: AssemblyDescription("An EXILED 6.0 plugin that adds SCP-008 to SCP:SL")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SCP-008-X")]
[assembly: AssemblyCopyright("Copyright © DGvagabond 2020")]
[assembly: AssemblyCopyright("Copyright © DGvagabond 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
45 changes: 17 additions & 28 deletions Roles/Scp008.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@
// </copyright>
// -----------------------------------------------------------------------

using Exiled.Events.EventArgs.Player;
using PlayerRoles;

namespace SCP008X
{
using Exiled.API.Enums;
using Exiled.API.Features;
using Exiled.API.Features.Attributes;
using Exiled.CustomRoles.API.Features;
using Exiled.Events.EventArgs;
using MEC;

[CustomRole(RoleType.Scp0492)]
[CustomRole(RoleTypeId.Scp0492)]
public class Scp008 : CustomRole
{
public override uint Id { get; set; } = 008;
public override RoleType Role { get; set; } = RoleType.Scp0492;
public override RoleTypeId Role { get; set; } = RoleTypeId.Scp0492;
public override int MaxHealth { get; set; } = Scp008X.Instance.Config.MaxZombieHealth;
public override string Name { get; set; } = "SCP-008";
public override string Description { get; set; } =
"An instance of SCP-008 that spreads the infection with each hit.";
public override string CustomInfo { get; set; } = "SCP-008";
protected override void SubscribeEvents()
{
Log.Debug($"{nameof(SubscribeEvents)}: Loading 008 custom role events..", Scp008X.Instance.Config.DebugMode);
Log.Debug($"{nameof(SubscribeEvents)}: Loading 008 custom role events..");
Exiled.Events.Handlers.Player.Hurting += OnHurting;
Exiled.Events.Handlers.Player.Spawning += OnSpawning;
Exiled.Events.Handlers.Player.ChangingRole += OnRoleChange;
Expand All @@ -34,7 +36,7 @@ protected override void SubscribeEvents()

protected override void UnsubscribeEvents()
{
Log.Debug($"{nameof(UnsubscribeEvents)}: Unloading 008 custom role events..", Scp008X.Instance.Config.DebugMode);
Log.Debug($"{nameof(UnsubscribeEvents)}: Unloading 008 custom role events..");
Exiled.Events.Handlers.Player.Hurting -= OnHurting;
Exiled.Events.Handlers.Player.Spawning -= OnSpawning;
Exiled.Events.Handlers.Player.ChangingRole += OnRoleChange;
Expand All @@ -43,14 +45,10 @@ protected override void UnsubscribeEvents()

private void OnSpawning(SpawningEventArgs ev)
{
if (ev.Player.Role == RoleType.Scp0492)
{
if (ev.Player.Role == RoleTypeId.Scp0492) {
Timing.CallDelayed(.5f, delegate
{
if (ev.Player.GetEffect(EffectType.Scp207).IsEnabled)
{
ev.Player.DisableEffect(EffectType.Scp207);
}
if (ev.Player.GetEffect(EffectType.Scp207).IsEnabled) ev.Player.DisableEffect(EffectType.Scp207);
ev.Player.AddAhp(Scp008X.Instance.Config.StartingAhp, Scp008X.Instance.Config.MaxAhp, 0);
ev.Player.Health = Scp008X.Instance.Config.ZombieHealth;
ev.Player.MaxHealth = MaxHealth;
Expand All @@ -61,14 +59,10 @@ private void OnSpawning(SpawningEventArgs ev)

private void OnRoleChange(ChangingRoleEventArgs ev)
{
if (ev.NewRole == RoleType.Scp0492)
{
if (ev.NewRole == RoleTypeId.Scp0492) {
Timing.CallDelayed(.5f, delegate
{
if (ev.Player.GetEffect(EffectType.Scp207).IsEnabled)
{
ev.Player.DisableEffect(EffectType.Scp207);
}
if (ev.Player.GetEffect(EffectType.Scp207).IsEnabled) ev.Player.DisableEffect(EffectType.Scp207);
ev.Player.AddAhp(Scp008X.Instance.Config.StartingAhp, Scp008X.Instance.Config.MaxAhp, 0);
ev.Player.Health = Scp008X.Instance.Config.ZombieHealth;
ev.Player.MaxHealth = MaxHealth;
Expand All @@ -78,20 +72,15 @@ private void OnRoleChange(ChangingRoleEventArgs ev)

private void OnHurting(HurtingEventArgs ev)
{
if (ev.Attacker == null)
{
return;
}
if (ev.Attacker.Role == RoleType.Scp0492)
{
if (ev.Player == null) return;
if (ev.Player.Role == RoleTypeId.Scp0492) {
var buff = Scp008X.Instance.Config.Scp008Buff;
var max = Scp008X.Instance.Config.MaxAhp;
ev.Attacker.AddAhp(buff > 0 && ev.Attacker.ArtificialHealth + buff < max ? buff : (ushort)0,Scp008X.Instance.Config.MaxAhp,0);
ev.Player.AddAhp(buff > 0 && ev.Player.ArtificialHealth + buff < max ? buff : (ushort)0,Scp008X.Instance.Config.MaxAhp,0);

if (UnityEngine.Random.Range(0, 100) <= Scp008X.Instance.Config.InfectionChance)
{
ev.Target.EnableEffect(EffectType.Poisoned);
ev.Target.ShowHint($"<color=yellow><b>SCP-008</b></color>\n{Scp008X.Instance.Config.InfectionAlert}", 5);
if (UnityEngine.Random.Range(0, 100) <= Scp008X.Instance.Config.InfectionChance) {
ev.Player.EnableEffect(EffectType.Poisoned);
ev.Player.ShowHint($"<color=yellow><b>SCP-008</b></color>\n{Scp008X.Instance.Config.InfectionAlert}", 5);
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions SCP008X.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SCP008X</RootNamespace>
<AssemblyName>SCP008X</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<Targe0tFrameworkVersion>v4.0</Targe0tFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -66,8 +67,10 @@
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\Downloads\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="UnityEngine.CoreModule" HintPath="$(EXILED_REFERENCES)\UnityEngine.dll" Private="false" />
Expand All @@ -84,7 +87,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="EXILED">
<Version>5.2.1</Version>
<Version>6.0.0-beta.17</Version>
</PackageReference>
</ItemGroup>
<ItemGroup />
Expand Down
4 changes: 2 additions & 2 deletions Scp008X.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class Scp008X : Plugin<Config>

public override string Author => "DGvagabond";
public override string Name => "Scp008X";
public override Version Version { get; } = new Version(3, 1, 2, 0);
public override Version RequiredExiledVersion { get; } = new Version(5, 2, 1);
public override Version Version { get; } = new Version(4, 0, 0, 0);
public override Version RequiredExiledVersion { get; } = new Version(6, 0, 0);

private EventHandlers _events;

Expand Down

0 comments on commit 61d6e73

Please sign in to comment.