Skip to content

Commit

Permalink
More spring cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
DGvagabond committed May 4, 2022
1 parent 8eb6d71 commit 387d0bb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 48 deletions.
21 changes: 2 additions & 19 deletions EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void OnVerified(VerifiedEventArgs ev)

public void OnHurt(HurtingEventArgs ev)
{
if (ev.Attacker == null || ev.Target == null) return;
if(ev.Attacker.Role==RoleType.Scp0492) ev.Amount=Scp008X.Instance.Config.ZombieDamage;
if (ev.Target.ArtificialHealth >= 0)
{
ev.IsAllowed = false;
Expand Down Expand Up @@ -69,29 +69,12 @@ public void OnHealed(UsedItemEventArgs ev)
}
}

public void OnRoleChange(ChangingRoleEventArgs ev)
{
Timing.CallDelayed(1f, () =>
{
if(ev.NewRole == RoleType.Scp0492)
{
if(ev.Player.GetEffect(EffectType.Scp207).IsEnabled) ev.Player.DisableEffect(EffectType.Scp207);
CustomRole.Get(typeof(Scp008))?.AddRole(ev.Player);
ev.Player.AddAhp(Scp008X.Instance.Config.StartingAhp,Scp008X.Instance.Config.MaxAhp,0);
}
else if (ev.NewRole.GetTeam() != Team.SCP)
{
ev.Player.ArtificialHealth = 0;
}
});
}

public void OnReviving(StartingRecallEventArgs ev)
{
if (!Scp008X.Instance.Config.BuffDoctor) return;

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

Expand Down
54 changes: 27 additions & 27 deletions Roles/Scp008.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,65 @@

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

[CustomRole(RoleType.Scp0492)]
public class Scp008 : CustomRole
{
public override uint Id { get; set; } = 008;
public override RoleType Role { get; set; } = RoleType.Scp0492;
public override int MaxHealth { get; set; } = Scp008X.Instance.Config.ZombieHealth;
public override string Name { get; set; } = "SCP-008";
public override string Description { get; set; } =
"An instance of SCP-008 that spreads the 008 infection with each hit.";
"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 events..", Scp008X.Instance.Config.DebugMode);
Log.Debug($"{nameof(SubscribeEvents)}: Loading 008 custom role events..", Scp008X.Instance.Config.DebugMode);
Exiled.Events.Handlers.Player.Hurting += OnHurting;
Exiled.Events.Handlers.Player.ChangingRole += OnSpawning;
base.SubscribeEvents();
}

protected override void UnsubscribeEvents()
{
Log.Debug($"{nameof(UnsubscribeEvents)}: Unloading 008 events..", Scp008X.Instance.Config.DebugMode);
Log.Debug($"{nameof(UnsubscribeEvents)}: Unloading 008 custom role events..", Scp008X.Instance.Config.DebugMode);
Exiled.Events.Handlers.Player.Hurting -= OnHurting;
Exiled.Events.Handlers.Player.ChangingRole -= OnSpawning;
base.UnsubscribeEvents();
}

private void OnHurting(HurtingEventArgs ev)
private void OnSpawning(ChangingRoleEventArgs ev)
{
ev.Amount = Scp008X.Instance.Config.ZombieDamage;

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);

if (ev.Target.IsHuman && ev.Target.Health - ev.Amount <= 0 &&
ev.Target.TryGetEffect(EffectType.Poisoned, out PlayerEffect poisoned) && poisoned.Intensity > 0)
if(ev.NewRole == RoleType.Scp0492)
{
ev.IsAllowed = false;
ev.Amount = 0;
ev.Target.DropItems();
ev.Target.SetRole(RoleType.Scp0492, SpawnReason.ForceClass, true);
if(ev.Player.GetEffect(EffectType.Scp207).IsEnabled) ev.Player.DisableEffect(EffectType.Scp207);
ev.Player.AddAhp(Scp008X.Instance.Config.StartingAhp, Scp008X.Instance.Config.MaxAhp, 0);
}

if (!Check(ev.Attacker))
return;

if (ev.Target.Role.Team == Team.SCP)
else if (ev.NewRole.GetTeam() != Team.SCP)
{
ev.Amount = 0f;
return;
ev.Player.ArtificialHealth = 0;
}
}

if (Scp008X.Instance.Rng.Next(100) < Scp008X.Instance.Config.InfectionChance)
private void OnHurting(HurtingEventArgs ev)
{
if (ev.Attacker.Role == RoleType.Scp0492)
{
ev.Target.ShowHint($"<color=yellow><b>SCP-008</b></color>\n{Scp008X.Instance.Config.InfectionAlert}");
ev.Target.EnableEffect(EffectType.Poisoned);
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);

if (Scp008X.Instance.Rng.Next(100) > Scp008X.Instance.Config.InfectionChance)
{
ev.Target.ShowHint($"<color=yellow><b>SCP-008</b></color>\n{Scp008X.Instance.Config.InfectionAlert}");
ev.Target.EnableEffect(EffectType.Poisoned);
}
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions Scp008X.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ private void RegisterEvents()
PlayerEvents.Shooting += _events.OnShoot;
PlayerEvents.Verified += _events.OnVerified;
PlayerEvents.UsedItem += _events.OnHealed;
PlayerEvents.ChangingRole += _events.OnRoleChange;

Scp049.StartingRecall += _events.OnReviving;

Expand All @@ -66,7 +65,6 @@ private void UnregisterEvents()
PlayerEvents.Shooting -= _events.OnShoot;
PlayerEvents.Verified -= _events.OnVerified;
PlayerEvents.UsedItem -= _events.OnHealed;
PlayerEvents.ChangingRole -= _events.OnRoleChange;

Scp049.StartingRecall -= _events.OnReviving;

Expand Down

0 comments on commit 387d0bb

Please sign in to comment.