Skip to content

Commit

Permalink
Code Overhaul
Browse files Browse the repository at this point in the history
* Project Overhaul

Stylecop, moved to using a component, moved and added patches, redid method class and contained methods, rewrote and added commands, rewrote and added configs.

* Proper Versioning

* Add Win Conditions

Win with tutorials config, brought back a revamped version of the old EndingRound event handler.

* Remove OnlyMimicSpawned Option

that was stupid

* Self Damage, Ranged Notifications, Proper Destruction

* Performance for Ranged Notification

Removed a few GetComponent calls.

* ReadMe update, config sorting

Updated readme to account for ranged notification, moved ranged notification down in the name config to be in alphabetical order, updated description of enabled option in ranged notification.
  • Loading branch information
BuildBoy12 authored Mar 10, 2021
1 parent 42c0170 commit 5885281
Show file tree
Hide file tree
Showing 44 changed files with 1,825 additions and 1,357 deletions.
85 changes: 63 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,71 @@ Adds a passive SCP to the game. A certain amount of items will randomly be selec

**[EXILED](https://github.com/galaxy119/EXILED) must be installed for this to work.**

Place the "scp035.dll" file in your Plugins folder.

See [this page](https://github.com/Cyanox62/scp035/wiki/API) for API usage.
Place the "Scp035.dll" file in your Plugins folder.

# Configs
## Main
| Config | Type | Default | Description
| :-------------: | :---------: | :---------: | :------ |
| is_enabled | Boolean | True | Whether the plugin should load. |
| debug | Boolean | False | Whether debug messages should show. |
| corrode_trail | Boolean | False | Whether a Scp035 should leave a trail behind them. |
| corrode_trail_interval | Integer | 5 | The amount of time between the creation of a part of the trail. |
| scp_friendly_fire | Boolean | False | Whether Scp035 and Scp subjects can damage each other. |
| tutorial_friendly_fire | Boolean | True | Whether Scp035 and tutorials can damage each other. |
| win_with_tutorial | Boolean | True | Whether Scp035 and tutorials will win together. |

## Corrode Host
Configs for the corrosion of Scp035 instances.

| Config | Type | Default | Description
| :-------------: | :---------: | :---------: | :------ |
| is_enabled | Boolean | False | Whether a Scp035 host will lose health over time. |
| damage | Integer | 5 | The amount of damage that will be dealt to a Scp035 host each interval. |
| interval | Float | 6 | The amount of seconds between each damage tick. |

## Corrode Players
Configs for the corrosion of players around Scp035 instances.

| Config | Type | Default | Description
| :-------------: | :---------: | :---------: | :------ |
| is_enabled | Boolean | False | Whether players around a Scp035 host will lose health over time. |
| distance | Float | 1.5 | The minimum distance a player must be to a Scp035 instance to take damage. |
| damage | Integer | 5 | The amount of damage that will be dealt to players around a Scp035 host. |
| life_steal | Boolean | True | Whether Scp035 instances will heal while dealing corrosion damage. |
| interval | Float | 1 | The amount of seconds between each damage tick. |

## Item Spawning
Configs for the spawning of Scp035 item instances.

| Config | Type | Default | Description
| :-------------: | :---------: | :---------: | :------ |
| infected_item_count | Integer | 1 | How many Scp035 item instances will spawn per cycle. |
| rotate_interval | Float | 30 | The amount of seconds between each spawn interval. |
| possible_items | ItemType Array | Adrenaline, Coin, Disarmer, Flashlight, Medkit, Painkillers, Radio, GrenadeFlash, GrenadeFrag, MicroHID | All ItemTypes that a Scp035 item instance can spawn as. |
| spawn_after_death | Boolean | false | Whether a Scp035 item instance will spawn when a Scp035 host dies. |

## Ranged Notification
Configs for the display of a notification to users looking at a Scp035 instance.

| Config | Type | Default | Description
| :-------------: | :---------: | :---------: | :------ |
| is_enabled | Boolean | False | Whether players looking at Scp035 will see a notification. |
| interval | Float | 5 | The time between checking if a player is looking at a Scp035 instance. |
| minimum_range | Float | 10 | The minimum distance a Scp035 instance must be to a player to display a notification. |
| maximum_range | Float | 30 | The maximum distance a Scp035 instance must be to a player to display a notification. |
| use_hints | Boolean | True | Whether hints should be used in place of a broadcast. |
| notification | Broadcast | You are looking at a <color=red>SCP-035</color>! | The message to be displayed to players. |

## Scp035 Modifiers
Configs in relation to Scp035 instances.

| Config | Type | Default | Description
| :-------------: | :---------: | :---------: | :------ |
| 035_enabled | Boolean | True | If SCP-035 is enabled. |
| 035_possible_items | Integer List | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 23, 24, 25, 26, 27, 30, 33, 34 | The item IDs SCP-035 can disguise as. |
| 035_health | Integer | 300 | The amount of health SCP-035 has. |
| 035_rotate_interval | Float | 120 | The amount of time in seconds before SCP-035 will choose a new item on the map to disguise as. |
| 035_scp_friendly_fire | Boolean | False | If SCP-035 is allowed to damage other SCPs. |
| 035_infected_item_count | Integer | 1 | The number of items every refresh that are possessed by SCP-035. |
| 035_win_with_tutorial | Boolean | False | If SCP-035 should win with tutorials. |
| 035_tutorial_friendly_fire | Boolean | False | If friendly fire between SCP-035 and tutorials is enabled. |
| 035_corrode_players | Boolean | True | If SCP-035 should do passive damage to players within a range of him. |
| 035_corrode_distance | Float | 1.5 | The distance in which a player will take corrosion damage from SCP-035. |
| 035_corrode_damage | Integer | 5 | The amount of damage to do to a player within range of corrosion. |
| 035_corrode_interval | Float | 1 | The interval in seconds for corrosion damage. |
| 035_corrode_life_steal | Boolean | True | If SCP-035 should steal any health taken from other players by corrosion. |
| 035_corrode_trail | Boolean | True | If SCP-035 should leave behind a trail of corrosion when he walks. |
| 035_corrode_trail_interval | Integer | 5 | The amount of steps inbetween each corrosion decal placement. |
| 035_corrode_host | Boolean | False | Whether or not 035 should slowly kill his host body. This will prevent him from using medical items. |
| 035_corrode_host_interval | Float | 15 | How often to deal damage to 035's host. |
| 035_corrode_host_amount | Integer | 5 | The amount of damage to deal every host corrosion. |
| 035_can_use_medical_items| Boolean | True | Determines whether or not SCP-035 can use medical items. |
| ammo_amount | Unsigned Integer | 250 | The amount of ammo that is given to Scp035. |
| can_heal_beyond_host_hp | Boolean | True | Whether a Scp035 instance can heal beyond their current roles max health. |
| can_use_medial_items | Boolean | True | Whether a Scp035 instance can use medical items. |
| health | Integer | 300 | The amount of health a Scp035 instance will spawn with. |
| self_inflict | Boolean | False | Whether the user who picks up an item will become an instance or if someone will be chosen to replace them. |
| scale | Vector | z: 1 y: 1 x: 1 | The size of a Scp035 instance. |
| spawn_broadcast | Broadcast | <i>You have picked up <color=\"red\">SCP-035.</color> He has infected your body and is now in control of you.</i> | The broadcast that will be displayed to an Scp035 instance when they spawn. |
16 changes: 16 additions & 0 deletions Scp035.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scp035", "Scp035\Scp035.csproj", "{2CF3F5CA-6207-47DC-9168-1F35AEAE8435}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2CF3F5CA-6207-47DC-9168-1F35AEAE8435}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CF3F5CA-6207-47DC-9168-1F35AEAE8435}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CF3F5CA-6207-47DC-9168-1F35AEAE8435}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CF3F5CA-6207-47DC-9168-1F35AEAE8435}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
48 changes: 48 additions & 0 deletions Scp035/API.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// -----------------------------------------------------------------------
// <copyright file="API.cs" company="Build and Cyanox">
// Copyright (c) Build and Cyanox. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Scp035
{
#pragma warning disable SA1135

using System.Collections.Generic;
using System.Linq;
using Components;
using Exiled.API.Features;

/// <summary>
/// The main API class to get and manipulate data.
/// </summary>
public static class API
{
/// <summary>
/// Gets all active Scp035 instances.
/// </summary>
public static IEnumerable<Player> AllScp035 => Player.List.Where(player => player.SessionVariables.ContainsKey("IsScp035"));

/// <summary>
/// Determines if a given <see cref="Player"/> is a Scp035.
/// </summary>
/// <param name="player">The <see cref="Player"/> to check for being a Scp035 instance.</param>
/// <returns>A value indicating whether the <see cref="Player"/> is a Scp035 instance.</returns>
public static bool IsScp035(Player player) => player.SessionVariables.ContainsKey("IsScp035");

/// <summary>
/// Spawns a user as a Scp035 instance.
/// </summary>
/// <param name="player">The <see cref="Player"/> to spawn in as a Scp035 instance.</param>
/// <param name="toReplace">The <see cref="Player"/> to replace.</param>
public static void Spawn035(Player player, Player toReplace = null) => player.GameObject.AddComponent<Scp035Component>().AwakeFunc(toReplace);

/// <summary>
/// Spawns the specified amount of Scp035 item instances.
/// </summary>
/// <param name="amount">The amount of items to spawn.</param>
/// <returns>All <see cref="Pickup"/>s that were spawned as Scp035 item instances.</returns>
public static IEnumerable<Pickup> SpawnItems(int amount) => Methods.SpawnPickups(amount);
}
}
63 changes: 63 additions & 0 deletions Scp035/Commands/Scp035Parent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// -----------------------------------------------------------------------
// <copyright file="Scp035Parent.cs" company="Build and Cyanox">
// Copyright (c) Build and Cyanox. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Scp035.Commands
{
#pragma warning disable SA1101
#pragma warning disable SA1135

using System;
using System.Text;
using CommandSystem;
using NorthwoodLib.Pools;
using SubCommands;

/// <summary>
/// The command which all Scp035 commands are run off of.
/// </summary>
[CommandHandler(typeof(RemoteAdminCommandHandler))]
public class Scp035Parent : ParentCommand
{
/// <summary>
/// Initializes a new instance of the <see cref="Scp035Parent"/> class.
/// </summary>
public Scp035Parent() => LoadGeneratedCommands();

/// <inheritdoc/>
public override string Command { get; } = "035";

/// <inheritdoc/>
public override string[] Aliases { get; } = Array.Empty<string>();

/// <inheritdoc/>
public override string Description { get; } = "Parent command for Scp035";

/// <inheritdoc/>
public sealed override void LoadGeneratedCommands()
{
RegisterCommand(new Kill());
RegisterCommand(new List());
RegisterCommand(new Spawn());
RegisterCommand(new SpawnItems());
}

/// <inheritdoc/>
protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
StringBuilder stringBuilder = StringBuilderPool.Shared.Rent();
foreach (var command in AllCommands)
{
stringBuilder.AppendLine(command.Aliases.Length > 0
? $"{command.Command} | Aliases: {string.Join(", ", command.Aliases)}"
: command.Command);
}

response = $"Please enter a valid subcommand! Available:\n{StringBuilderPool.Shared.ToStringReturn(stringBuilder)}";
return false;
}
}
}
46 changes: 46 additions & 0 deletions Scp035/Commands/SubCommands/Kill.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// -----------------------------------------------------------------------
// <copyright file="Kill.cs" company="Build and Cyanox">
// Copyright (c) Build and Cyanox. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Scp035.Commands.SubCommands
{
using System;
using CommandSystem;
using Exiled.Permissions.Extensions;

/// <summary>
/// A command which kills all active Scp035 instances.
/// </summary>
public class Kill : ICommand
{
/// <inheritdoc/>
public string Command { get; } = "kill";

/// <inheritdoc/>
public string[] Aliases { get; } = { "k" };

/// <inheritdoc/>
public string Description { get; } = "Kills all alive Scp035s.";

/// <inheritdoc/>
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
if (!sender.CheckPermission("035.kill"))
{
response = "Insufficient permission. Required: 035.kill";
return false;
}

foreach (var player in API.AllScp035)
{
player.Kill();
}

response = "Killed all Scp035 users successfully.";
return false;
}
}
}
42 changes: 42 additions & 0 deletions Scp035/Commands/SubCommands/List.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// -----------------------------------------------------------------------
// <copyright file="List.cs" company="Build and Cyanox">
// Copyright (c) Build and Cyanox. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Scp035.Commands.SubCommands
{
using System;
using System.Linq;
using CommandSystem;
using Exiled.Permissions.Extensions;

/// <summary>
/// A command which lists all active Scp035 instances.
/// </summary>
public class List : ICommand
{
/// <inheritdoc/>
public string Command { get; } = "list";

/// <inheritdoc/>
public string[] Aliases { get; } = { "l" };

/// <inheritdoc/>
public string Description { get; } = "Lists all active Scp035 instances.";

/// <inheritdoc/>
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
if (!sender.CheckPermission("035.list"))
{
response = "Insufficient permission. Required: 035.list";
return false;
}

response = $"Alive Scp035 Instances: {string.Join(", ", API.AllScp035.Select(player => player.Nickname))}";
return true;
}
}
}
67 changes: 67 additions & 0 deletions Scp035/Commands/SubCommands/Spawn.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// -----------------------------------------------------------------------
// <copyright file="Spawn.cs" company="Build and Cyanox">
// Copyright (c) Build and Cyanox. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Scp035.Commands.SubCommands
{
using System;
using CommandSystem;
using Exiled.API.Features;
using Exiled.Permissions.Extensions;
using RemoteAdmin;

/// <summary>
/// A command which spawns an active Scp035 instance.
/// </summary>
public class Spawn : ICommand
{
/// <inheritdoc/>
public string Command { get; } = "spawn";

/// <inheritdoc/>
public string[] Aliases { get; } = { "s" };

/// <inheritdoc/>
public string Description { get; } = "Spawns a user as an instance of Scp035.";

/// <inheritdoc/>
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
if (!sender.CheckPermission("035.spawn"))
{
response = "Insufficient permission. Required: 035.spawn";
return false;
}

Player player = Player.Get((sender as PlayerCommandSender)?.ReferenceHub);
if (arguments.Count > 0)
{
if (!(Player.Get(arguments.At(0)) is Player ply))
{
response = "Could not find the referenced user.";
return false;
}

player = ply;
}

if (API.IsScp035(player))
{
response = $"{player.Nickname} is already a Scp035!";
return false;
}

if (!player.IsAlive || player.IsScp)
{
player.Role = RoleType.ClassD;
}

API.Spawn035(player);
response = $"Spawned {player.Nickname} as a Scp035.";
return true;
}
}
}
Loading

0 comments on commit 5885281

Please sign in to comment.