Skip to content

Commit

Permalink
1.0.7
Browse files Browse the repository at this point in the history
- Cleaned up the code
- Added Wiki
- Added new features:
  * The probability that the item will disappear
  * Translation when an item is thrown or dropped
  * Translation of dropped items
  • Loading branch information
MrAfitol committed Apr 2, 2023
1 parent 943cba3 commit e432fef
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 119 deletions.
103 changes: 41 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@


A plugin that adds SCP-1162

The idea is taken from the [plugin](https://github.com/SynapseSL/Scp1162)
## How download ?
- *1. Find the SCP SL server config folder*

Expand All @@ -18,15 +20,25 @@ A plugin that adds SCP-1162
- *Run the command in console `p install MrAfitol/SCP-1162`*
## Config
```yml
# What message will be displayed when using SCP-1162?
item_drop_message: <b>You dropped a <color=green>{dropitem}</color> through <color=yellow>SCP-1162</color>, and received a <color=red>{giveitem}</color></b>
# What message will be displayed when using SCP-1162? ({dropitem} - Thrown or dropped item. {giveitem} - Changed item. {dropstatus} - Replaces the text written in the points below in dependence on the drop status.)
item_drop_message:
message: <b>You {dropstatus} a <color=green>{dropitem}</color> through <color=yellow>SCP-1162</color>, and received a <color=red>{giveitem}</color></b>
drop_text: dropped
throw_text: throwed
# What message will be displayed when item are deleted? ({dropitem} - Thrown or dropped item. {dropstatus} - Replaces the text written in the points below in dependence on the drop status.)
item_delete_message:
message: <b>You {dropstatus} a <color=green>{dropitem}</color> through <color=yellow>SCP-1162</color>, and got <color=red>nothing</color></b>
drop_text: dropped
throw_text: throwed
# From what distance can SCP-1162 be used?
s_c_p1162_distance: 2
# Will the hands be cut off if the item is not in the hands?
cutting_hands: true
# What is the chance that the hands will be cut off if the item is not in the hands
chance_cutting: 40
# List of items that may drop from SCP-1162
# What is the chance that the hands will be cut off if the item is not in the hands. (Set to 0 to disable)
cutting_chance: 30
# What is the chance that the item will be deleted. (Set to 0 to disable)
delete_chance: 10
# If this item is enabled, the hands will not be cut off only when the player threw item.
ignore_throw: true
# List of items that may drop from SCP-1162.
dropping_items:
- SCP500
- KeycardContainmentEngineer
Expand All @@ -40,65 +52,32 @@ dropping_items:
- Ammo9x19
- KeycardZoneManager
- KeycardResearchCoordinator
- KeycardGuard
- Ammo762x39
- Ammo556x45
- GrenadeFlash
- KeycardScientist
- KeycardJanitor
- Coin
- Flashlight
# List of items and their name when using SCP-1162, if the item is not in the list the name will be the default.
items_name:
SCP500: SCP-500
KeycardContainmentEngineer: Containment Engineer Keycard
GunCOM15: COM-15
GrenadeFlash: Flashbang Grenade
SCP207: SCP-207
Adrenaline: Adrenaline
GunCOM18: COM-18
Medkit: Medkit
KeycardGuard: Guard Keycard
Ammo9x19: Ammo9x19
KeycardZoneManager: Zone Manager Keycard
KeycardResearchCoordinator: Research Supervisor Keycard
Ammo762x39: Ammo762x39
Ammo556x45: Ammo556x45
KeycardScientist: Scientist Keycard
KeycardJanitor: Janitor Keycard
Coin: Coin
Flashlight: Flashlight
```
**ItemType**
```
KeycardJanitor,
KeycardScientist,
KeycardResearchCoordinator,
KeycardZoneManager,
KeycardGuard,
KeycardNTFOfficer,
KeycardContainmentEngineer,
KeycardNTFLieutenant,
KeycardNTFCommander,
KeycardFacilityManager,
KeycardChaosInsurgency,
KeycardO5,
Radio,
GunCOM15,
Medkit,
Flashlight,
MicroHID,
SCP500,
SCP207,
Ammo12gauge,
GunE11SR,
GunCrossvec,
Ammo556x45,
GunFSP9,
GunLogicer,
GrenadeHE,
GrenadeFlash,
Ammo44cal,
Ammo762x39,
Ammo9x19,
GunCOM18,
SCP018,
SCP268,
Adrenaline,
Painkillers,
Coin,
ArmorLight,
ArmorCombat,
ArmorHeavy,
GunRevolver,
GunAK,
GunShotgun,
SCP330,
SCP2176,
SCP244a,
SCP244b,
SCP1853,
ParticleDisruptor,
GunCom45
```
## Wiki
**Be sure to check out the [Wiki](https://github.com/MrAfitol/SCP-1162/wiki)**
62 changes: 51 additions & 11 deletions SCP1162/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,34 @@ namespace SCP1162

public class Config
{
[Description("What message will be displayed when using SCP-1162?")]
public string ItemDropMessage { get; set; } = "<b>You dropped a <color=green>{dropitem}</color> through <color=yellow>SCP-1162</color>, and received a <color=red>{giveitem}</color></b>";
[Description("What message will be displayed when using SCP-1162? ({dropitem} - Thrown or dropped item. {giveitem} - Changed item. {dropstatus} - Replaces the text written in the points below in dependence on the drop status.)")]
public ItemMessage ItemDropMessage { get; set; } = new ItemMessage()
{
Message = "<b>You {dropstatus} a <color=green>{dropitem}</color> through <color=yellow>SCP-1162</color>, and received a <color=red>{giveitem}</color></b>",
DropText = "dropped",
ThrowText = "throwed"
};

[Description("What message will be displayed when item are deleted? ({dropitem} - Thrown or dropped item. {dropstatus} - Replaces the text written in the points below in dependence on the drop status.)")]
public ItemMessage ItemDeleteMessage { get; set; } = new ItemMessage()
{
Message = "<b>You {dropstatus} a <color=green>{dropitem}</color> through <color=yellow>SCP-1162</color>, and got <color=red>nothing</color></b>",
DropText = "dropped",
ThrowText = "throwed"
};
[Description("From what distance can SCP-1162 be used?")]
public float SCP1162Distance { get; set; } = 2f;

[Description("Will the hands be cut off if the item is not in the hands?")]
public bool CuttingHands { get; set; } = true;
[Description("What is the chance that the hands will be cut off if the item is not in the hands. (Set to 0 to disable)")]
public int CuttingChance { get; set; } = 30;

[Description("What is the chance that the hands will be cut off if the item is not in the hands")]
public int ChanceCutting { get; set; } = 40;
[Description("What is the chance that the item will be deleted. (Set to 0 to disable)")]
public int DeleteChance { get; set; } = 10;

[Description("If this item is enabled, the hands will not be cut off only when the player threw item")]
public bool OnlyThrow { get; set; } = false;
[Description("If this item is enabled, the hands will not be cut off only when the player threw item.")]
public bool IgnoreThrow { get; set; } = true;

[Description("List of items that may drop from SCP-1162")]
[Description("List of items that may drop from SCP-1162.")]
public List<ItemType> DroppingItems { get; set; } = new List<ItemType>
{
ItemType.SCP500,
Expand All @@ -35,14 +47,42 @@ public class Config
ItemType.Ammo9x19,
ItemType.KeycardZoneManager,
ItemType.KeycardResearchCoordinator,
ItemType.KeycardGuard,
ItemType.Ammo762x39,
ItemType.Ammo556x45,
ItemType.GrenadeFlash,
ItemType.KeycardScientist,
ItemType.KeycardJanitor,
ItemType.Coin,
ItemType.Flashlight
};

[Description("List of items and their name when using SCP-1162, if the item is not in the list the name will be the default.")]
public Dictionary<ItemType, string> ItemsName { get; set; } = new Dictionary<ItemType, string>()
{
{ ItemType.SCP500, "SCP-500"},
{ ItemType.KeycardContainmentEngineer, "Containment Engineer Keycard"},
{ ItemType.GunCOM15, "COM-15" },
{ ItemType.GrenadeFlash, "Flashbang Grenade" },
{ ItemType.SCP207, "SCP-207" },
{ ItemType.Adrenaline, "Adrenaline" },
{ ItemType.GunCOM18, "COM-18" },
{ ItemType.Medkit, "Medkit" },
{ ItemType.KeycardGuard, "Guard Keycard" },
{ ItemType.Ammo9x19, "Ammo9x19" },
{ ItemType.KeycardZoneManager, "Zone Manager Keycard" },
{ ItemType.KeycardResearchCoordinator, "Research Supervisor Keycard" },
{ ItemType.Ammo762x39, "Ammo762x39" },
{ ItemType.Ammo556x45, "Ammo556x45" },
{ ItemType.KeycardScientist, "Scientist Keycard" },
{ ItemType.KeycardJanitor, "Janitor Keycard" },
{ ItemType.Coin, "Coin" },
{ ItemType.Flashlight, "Flashlight" }
};
}
}

public class ItemMessage
{
public string Message { get; set; }
public string DropText { get; set; }
public string ThrowText { get; set; }
}
74 changes: 31 additions & 43 deletions SCP1162/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ namespace SCP1162
{
using UnityEngine;
using System.Linq;
using InventorySystem;
using InventorySystem.Items;
using PluginAPI.Core.Attributes;
using PluginAPI.Core.Zones;
Expand All @@ -18,11 +17,6 @@ public class EventHandlers

[PluginEvent(ServerEventType.MapGenerated)]
public void OnGenerationMap()
{
Spawn1162();
}

public void Spawn1162()
{
var Room = LightZone.Rooms.FirstOrDefault(x => x.GameObject.name == "LCZ_173");
var scp1162 = new SimplifiedToy(PrimitiveType.Cylinder, new Vector3(17f, 13f, 3.59f), new Vector3(90f, 0f, 0f),
Expand All @@ -32,57 +26,51 @@ public void Spawn1162()
}

[PluginEvent(ServerEventType.PlayerDropItem)]
public bool OnPlayerDroppedItem(Player player, ItemBase item)
public bool OnPlayerDroppedItem(Player player, ItemBase item) { return OnUseSCP1162(player, item, player.CurrentItem == item); }

private bool OnUseSCP1162(Player player, ItemBase item, bool isThrow)
{
if (!Round.IsRoundStarted) return true;
if (Vector3.Distance(SCP1162Position, player.Position) <= Plugin.Instance.Config.SCP1162Distance)
if (Vector3.Distance(SCP1162Position, player.Position) > Plugin.Instance.Config.SCP1162Distance) return true;

if (isThrow ? !Plugin.Instance.Config.IgnoreThrow && Plugin.Instance.Config.CuttingChance > 0 : Plugin.Instance.Config.CuttingChance > 0)
{
if (Plugin.Instance.Config.CuttingHands)
{
if (Plugin.Instance.Config.OnlyThrow)
{
player.EffectsManager.EnableEffect<SeveredHands>(1000);
return true;
}

if (player.CurrentItem != item)
{
if (Plugin.Instance.Config.ChanceCutting >= Random.Range(0, 101))
{
player.EffectsManager.EnableEffect<SeveredHands>(1000);
return true;
}
}
if (Plugin.Instance.Config.CuttingChance >= Random.Range(0, 101))
{
player.EffectsManager.EnableEffect<SeveredHands>(1000);
return true;
}

OnUseSCP1162(player, item);
return false;
}
return true;
}

[PluginEvent(ServerEventType.PlayerThrowItem)]
public bool OnThrowItem(Player player, ItemBase item, Rigidbody rb)
{
if (!Round.IsRoundStarted) return true;
if (Vector3.Distance(SCP1162Position, player.Position) <= Plugin.Instance.Config.SCP1162Distance)
if (Plugin.Instance.Config.DeleteChance > 0)
{
OnUseSCP1162(player, item);
return false;
if (Plugin.Instance.Config.DeleteChance >= Random.Range(0, 101))
{
player.RemoveItem(new Item(item));
player.ReceiveHint(Plugin.Instance.Config.ItemDeleteMessage.Message
.Replace("{dropitem}", GetItemName(item.ItemTypeId))
.Replace("{dropstatus}", isThrow ? Plugin.Instance.Config.ItemDeleteMessage.ThrowText : Plugin.Instance.Config.ItemDeleteMessage.DropText), 2f);
return true;
}
}
return true;
}

private void OnUseSCP1162(Player player, ItemBase item)
{
var newItemType = Plugin.Instance.Config.DroppingItems.RandomItem();

player.ReceiveHint(
Plugin.Instance.Config.ItemDropMessage.Replace("{dropitem}", item.ItemTypeId.ToString())
.Replace("{giveitem}", newItemType.ToString()), 2f);

player.ReceiveHint(Plugin.Instance.Config.ItemDropMessage.Message
.Replace("{dropitem}", GetItemName(item.ItemTypeId))
.Replace("{giveitem}", GetItemName(newItemType))
.Replace("{dropstatus}", isThrow ? Plugin.Instance.Config.ItemDropMessage.ThrowText : Plugin.Instance.Config.ItemDropMessage.DropText), 2f);
player.RemoveItem(new Item(item));
player.AddItem(newItemType);

return false;
}

public string GetItemName(ItemType itemType)
{
if (Plugin.Instance.Config.ItemsName.TryGetValue(itemType, out string itemName)) return itemName;
return itemType.ToString();
}
}
}
2 changes: 1 addition & 1 deletion SCP1162/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Plugin
public Config Config;

[PluginPriority(LoadPriority.Highest)]
[PluginEntryPoint("SCP-1162", "1.0.6", "A plugin that adds SCP-1162.", "MrAfitol")]
[PluginEntryPoint("SCP-1162", "1.0.7", "A plugin that adds SCP-1162.", "MrAfitol")]
void LoadPlugin()
{
Instance = this;
Expand Down
4 changes: 2 additions & 2 deletions SCP1162/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.6.0")]
[assembly: AssemblyFileVersion("1.0.6.0")]
[assembly: AssemblyVersion("1.0.7.0")]
[assembly: AssemblyFileVersion("1.0.7.0")]

0 comments on commit e432fef

Please sign in to comment.