C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
// Reference: 0Harmony
using Facepunch;
#if CARBON
using HarmonyLib;
#else
using Harmony;
#endif
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.Assertions;
using static ConsoleSystem;
/* Suggestions
* Add NPCs to drop list
* Add permission options to items.* Add random perk from recycling.* Add command to toggle the button UI.*/
/* 1.0.11
* Updated the ipgive commands to take modifiers for each buff if specified.IE Butcher 1.2 would be a 120% buff given to the Butcher perk.* Added new command: ipgivewithskin <id> <skin> <optional: shortname> <optional: buffs/modifiers>
*/
namespace Oxide.Plugins {
[Info("Item Perks", "imthenewguy", "1.0.11")]
[Description("Perks that can be attached to items when they spawn")]
class ItemPerks : RustPlugin {
#region Config
private Configuration config;
public class Configuration {
[JsonProperty("Enhancement Settings")]
public EnhancementSettings enhancementSettings = new EnhancementSettings();
[JsonProperty("HUD Settings")]
public PlayerSettings playerSettings = new PlayerSettings();
[JsonProperty("Third Party Plugin Settings")]
public ThirdpartyPluginSettings thirdpartyPluginSettings = new ThirdpartyPluginSettings();
public string ToJson() => JsonConvert.SerializeObject(this);
public Dictionary<string, object> ToDictionary() => JsonConvert.DeserializeObject<Dictionary<string, object>>(ToJson());
}
public class ThirdpartyPluginSettings {
[JsonProperty("ItemPerks Settings")]
public ItemPerksSettings itemPerkSettings = new ItemPerksSettings();
public class ItemPerksSettings {
[JsonProperty("Enhancement Settings")]
public bool allow_max_repair_on_enhanced_items = false;
}
[JsonProperty("RandomTrader Integration")]
public RandomTraderAPI random_trader_api = new RandomTraderAPI();
}
protected override void LoadConfig() {
base.LoadConfig();
try {
config = Config.ReadObject<Configuration>();
if (config == null) {
throw new JsonException();
}
if (!config.ToDictionary().Keys.SequenceEqual(Config.ToDictionary(x => x.Key, x => x.Value).Keys)) {
PrintToConsole("Configuration appears to be outdated; updating and saving");
}
}
catch {
PrintToConsole($"Configuration file {Name}.json is invalid; using defaults");
LoadDefaultConfig();
}
SaveConfig();
}
protected override void SaveConfig() {
PrintToConsole($"Configuration changes saved to {Name}.json");
Config.WriteObject(config, true);
}
#endregion
#region Default Config
protected override void LoadDefaultConfig() {
config = new Configuration();
config.enhancementSettings.additional_perk_chances = DefaultAdditionalPerksChance;
config.enhancementSettings.lootSettings.container = DefaultCrates;
config.enhancementSettings.lootSettings.enhanceable_blacklist = DefaultBlackList;
config.enhancementSettings.perk_config.thriftySettings.blacklist_shortnames.Add("gunpowder");
config.enhancementSettings.perk_config.thriftySettings.blacklist_shortnames.Add("explosives");
config.enhancementSettings.perk_config.thriftySettings.blacklist_shortnames.Add("sulfur");
config.enhancementSettings.perk_config.fabricateSettings.blacklist_shortnames.Add("gunpowder");
config.enhancementSettings.perk_config.fabricateSettings.blacklist_shortnames.Add("explosives");
config.enhancementSettings.perk_config.componentLuckSettings.blacklist_shortnames = new List<string>() {
"generic", "chassis", "glue", "bleach", "ducttape", "sticks", "vehicle.chassis", "vehicle.module", "vehicle.chassis.4mod", "vehicle.chassis.3mod", "vehicle.chassis.2mod", "electric.generator.small"
}
;
config.enhancementSettings.perk_config.electricalLuckSettings.blacklist_shortnames = new List<string>() {
"electric.generator.small"
}
;
config.enhancementSettings.perk_config.woodcuttingLuckSettings.drop_rates = DefaultGatherLuck;
config.enhancementSettings.perk_config.miningLuckSettings.drop_rates = DefaultGatherLuck;
config.enhancementSettings.perk_config.skinningLuckSettings.drop_rates = DefaultGatherLuck;
config.enhancementSettings.perk_config.fishingLuckSettings.drop_rates = DefaultGatherLuck;
config.enhancementSettings.chance_modifier_settings.loot_chance_permissions = DefaultLootChancePermissions;
config.enhancementSettings.chance_modifier_settings.recycle_chance_permissions = DefaultRecycleChancePermissions;
config.enhancementSettings.chance_modifier_settings.craft_chance_permissions = DefaultCraftChancePermissions;
config.enhancementSettings.enhancement_kit_settings.upgrade_settings.custom_item = new CustomCostItem() {
shortname = "scrap", skin = 0
}
;
}
Dictionary<string, float> DefaultLootChancePermissions {
get {
return new Dictionary<string, float>() {
["itemperks.lootchance.10"]
= 0.1f, ["itemperks.lootchance.20"] = 0.2f, ["itemperks.lootchance.30"] = 0.3f, ["itemperks.lootchance.40"] = 0.4f, ["itemperks.lootchance.50"] = 0.5f
}
;
}
}
Dictionary<string, float> DefaultRecycleChancePermissions {
get {
return new Dictionary<string, float>() {
["itemperks.recyclechance.10"]
= 0.1f, ["itemperks.recyclechance.20"] = 0.2f, ["itemperks.recyclechance.30"] = 0.3f, ["itemperks.recyclechance.40"] = 0.4f, ["itemperks.recyclechance.50"] = 0.5f
}
;
}
}
Dictionary<string, float> DefaultCraftChancePermissions {
get {
return new Dictionary<string, float>() {
["itemperks.craftchance.10"]
= 0.1f, ["itemperks.craftchance.20"] = 0.2f, ["itemperks.craftchance.30"] = 0.3f, ["itemperks.craftchance.40"] = 0.4f, ["itemperks.craftchance.50"] = 0.5f
}
;
}
}
List<string> DefaultBlackList {
get {
return new List<string>() {
"tool.instant_camera", "geiger.counter", "grenade.f1", "grenade.flashbang", "grenade.molotov", "explosive.satchel", "grenade.smoke", "explosive.timed"
}
;
}
}
Dictionary<string, float> DefaultCrates {
get {
return new Dictionary<string, float>() {
["crate_normal_2"]
= 3f, ["crate_normal"] = 5f, ["crate_elite"] = 15f, ["crate_underwater_basic"] = 6f, ["crate_underwater_advanced"] = 12f, ["heli_crate"] = 10f, ["bradley_crate"] = 10f, ["codelockedhackablecrate"] = 10f, ["codelockedhackablecrate_oilrig"] = 10f, ["crate_tools"] = 1.5f, ["loot-barrel-1"] = 1f, ["loot_barrel_1"] = 1f, ["loot-barrel-2"] = 2f, ["loot_barrel_2"] = 2f
}
;
}
}
Dictionary<int, float> DefaultAdditionalPerksChance {
get {
return new Dictionary<int, float>() {
[2]
= 25f, [3] = 10f
}
;
}
}
Dictionary<Perk, PerkSettings> DefaultPerkSettings {
get {
return new Dictionary<Perk, PerkSettings>() {
[Perk.Academic]
= new PerkSettings(true, 0.05f, 0.25f), [Perk.Angler] = new PerkSettings(true, 0.05f, 0.5f), [Perk.Attractive] = new PerkSettings(true, 0.15f, 0.25f), [Perk.BeastBane] = new PerkSettings(true, 0.05f, 0.2f), [Perk.BeastWard] = new PerkSettings(true, 0.05f, 0.2f), [Perk.BlastMine] = new PerkSettings(true, 0.05f, 0.1f), [Perk.Builder] = new PerkSettings(true, 0.02f, 0.1f), [Perk.Butcher] = new PerkSettings(true, 0.05f, 0.2f), [Perk.ComponentLuck] = new PerkSettings(true, 0.03f, 0.08f), [Perk.Deforest] = new PerkSettings(true, 0.02f, 0.06f), [Perk.Durable] = new PerkSettings(true, 0.05f, 0.1f), [Perk.ElectronicsLuck] = new PerkSettings(true, 0.03f, 0.08f), [Perk.Elemental] = new PerkSettings(true, 0.05f, 0.15f), [Perk.Environmentalist] = new PerkSettings(true, 0.05f, 0.15f), [Perk.Fabricate] = new PerkSettings(true, 0.04f, 0.1f), [Perk.FallDamage] = new PerkSettings(true, 0.05f, 0.20f), [Perk.FishingLuck] = new PerkSettings(true, 0.01f, 0.05f), [Perk.FlakJacket] = new PerkSettings(true, 0.15f, 0.25f), [Perk.Forager] = new PerkSettings(true, 0.05f, 0.15f), [Perk.HealShare] = new PerkSettings(true, 0.03f, 0.10f), [Perk.Horticulture] = new PerkSettings(true, 0.02f, 0.10f), [Perk.IronStomach] = new PerkSettings(true, 0.5f, 1), [Perk.Lead] = new PerkSettings(true, 0.05f, 0.2f), [Perk.LineStrength] = new PerkSettings(true, 0.05f, 0.2f, 100, new List<string>() {
"fishingrod.handmade"
}
), [Perk.Lumberjack] = new PerkSettings(true, 0.05f, 0.2f), [Perk.Manufacture] = new PerkSettings(true, 0.05f, 0.2f), [Perk.MeleeWard] = new PerkSettings(true, 0.05f, 0.25f), [Perk.MiningLuck] = new PerkSettings(true, 0.01f, 0.03f), [Perk.Pharmaceutical] = new PerkSettings(true, 0.04f, 0.10f), [Perk.Paramedic] = new PerkSettings(true, 0.05f, 0.15f), [Perk.Prepper] = new PerkSettings(true, 0.05f, 0.15f), [Perk.Prospector] = new PerkSettings(true, 0.05f, 0.2f), [Perk.Regeneration] = new PerkSettings(true, 0.1f, 0.2f), [Perk.Reinforced] = new PerkSettings(true, 0.05f, 0.2f), [Perk.RockCycler] = new PerkSettings(true, 0.03f, 0.07f), [Perk.Sated] = new PerkSettings(true, 0.1f, 0.5f), [Perk.Scavenger] = new PerkSettings(true, 0.05f, 0.2f), [Perk.ScientistBane] = new PerkSettings(true, 0.03f, 0.15f), [Perk.ScientistWard] = new PerkSettings(true, 0.05f, 0.15f), [Perk.SharkBane] = new PerkSettings(true, 0.1f, 0.25f), [Perk.SharkWard] = new PerkSettings(true, 0.1f, 0.25f), [Perk.SkinningLuck] = new PerkSettings(true, 0.01f, 0.05f), [Perk.Smasher] = new PerkSettings(true, 0.5f, 1f), [Perk.Smelter] = new PerkSettings(true, 0.05f, 0.12f), [Perk.Tanner] = new PerkSettings(true, 0.02f, 0.06f), [Perk.Thrifty] = new PerkSettings(true, 0.05f, 0.10f), [Perk.TreePlanter] = new PerkSettings(true, 0.03f, 0.07f), [Perk.UncannyDodge] = new PerkSettings(true, 0.01f, 0.03f), [Perk.Vampiric] = new PerkSettings(true, 0.005f, 0.02f), [Perk.WoodcuttingLuck] = new PerkSettings(true, 0.01f, 0.03f), [Perk.BradleyDamage] = new PerkSettings(true, 0.03f, 0.05f), [Perk.HeliDamage] = new PerkSettings(true, 0.03f, 0.05f),
}
;
}
}
Dictionary<string, DropInfo> DefaultGatherLuck {
get {
return new Dictionary<string, DropInfo>() {
["fuse"]
= new DropInfo(1, 2), ["propanetank"] = new DropInfo(1, 5), ["gears"] = new DropInfo(1, 3), ["metalblade"] = new DropInfo(1, 5), ["metalpipe"] = new DropInfo(1, 3), ["metalspring"] = new DropInfo(1, 2), ["riflebody"] = new DropInfo(1, 1), ["roadsigns"] = new DropInfo(1, 3), ["semibody"] = new DropInfo(1, 2), ["sewingkit"] = new DropInfo(1, 3), ["sheetmetal"] = new DropInfo(1, 2), ["smgbody"] = new DropInfo(1, 2), ["tarp"] = new DropInfo(1, 5), ["techparts"] = new DropInfo(1, 2)
}
;
}
}
Dictionary<string, List<ulong>> DefaultItemSkins() {
var result = new Dictionary<string, List<ulong>>();
System.Random rnd = new System.Random();
foreach (var skin in Rust.Workshop.Approved.All.Values) {
if (EnhanceableItems.Contains(skin.Skinnable.ItemName)) {
List<ulong> list;
if (!result.TryGetValue(skin.Skinnable.ItemName, out list)) result.Add(skin.Skinnable.ItemName, list = new List<ulong>());
list.Add(skin.WorkshopdId);
}
}
// Picks 5 random skins from each result
foreach (var entry in result) {
if (entry.Value.Count > 5) {
List<ulong> skins = Pool.GetList<ulong>();
skins.AddRange(entry.Value.OrderBy(x => rnd.Next()).Take(5));
entry.Value.Clear();
entry.Value.AddRange(skins);
Pool.FreeList(ref skins);
}
else if (entry.Value.Count == 0) entry.Value.Add(0);
}
return result;
}
#endregion
#region Localization
protected override void LoadDefaultMessages() {
Dictionary<string, string> langDict = new Dictionary<string, string>() {
["UICLOSE"]
= "CLOSE", ["UIPERK"] = "PERK", ["UIMOD"] = "MOD", ["UIRESET"] = "RESET", ["UITOTALBONUSES"] = "TOTAL BONUSES", ["hps"] = "hp/s", ["Notify_FirstFindLoot"] = "You have found an Enhanced Item!\nCheck your chat for more information.", ["Enhanced"] = "Enhanced", ["FoundItemMessage"] = "You found an <color=#ffb600>{0}</color>\n{1}", ["CraftedItemMessage"] = "You crafted a <color=#ffb600>{0}</color>\n{1}", ["PerksMessage"] = "<color=#ffff00>Perks:</color>", ["ModsString"] = "\n- <color=#ffb600>{0}</color>", ["FishLuckMessage"] = "As you catch the fish, you find {0} {1}.", ["some"] = "some", ["a"] = "a", ["ComponentsRefundedMessage"] = "Your components were refunded!", ["ItemDuplicatedMessage"] = "Your {0} was duplicated!", ["ItemRationedMessage"] = "You managed to ration your {0}.", ["FreeUpgradeMessage"] = "You received a free upgrade!", ["ResearchRefundedMessage"] = "Your research cost was refunded!", ["WoodcuttingLuckMessage"] = "You found {0} {1} while cutting down the tree.", ["MiningLuckMessage"] = "You found {0} {1} while mining the node.", ["SkinningLuckMessage"] = "You found {0} {1} while skinning the corpse.", ["DodgeMessage"] = "You manage to dodge out of the way of danger!", ["NoPerms"] = "You do not have permission to use this command.", ["MissingItem"] = "Item no longer exists in inventory", ["DisabledRegen"] = "Your regen has been disabled for <color=#ff8000>{0} seconds</color> after taking damage.", ["FailedTofindPlayer"] = "{0} is invalid, not connected or dead.", ["UIEnhancementButton"] = "ENHANCE ITEM", ["UIEnhancementChooseTitle"] = "CHOOSE AN ENHANCEMENT KIT TO USE", ["UIEnhancementChooseNoIKits"] = "<color=#ffff00>You do not have any enhancement kits in your inventory.</color>", ["UIEnhancementChooseKitTitle"] = "<color=#ffae00>{0}</color>", ["UIEnhancementItemSelectTitle"] = "CHOOSE AN ITEM TO ENHANCE", ["UIEnhancementItemSelectNoItems"] = "<color=#ffff00>You do not have any valid items in your inventory.</color>", ["UIEnhancementConfirmTitle"] = "CONFIRM YOUR ENHANCEMENT", ["UIEnhancementConfirmItemTitle"] = "<color=#ffec00>ITEM:</color> {0}", ["UIEnhancementConfirmPerkTitle"] = "<color=#ffec00>PERK:</color> {0}", ["UIEnhancementConfirmCostTitle"] = "<color=#ffec00>COST:</color> {0} {1}", ["UIEnhancementConfirmPerkConfirmation"] = "Enhancing this item will add an additional <color=#00ff00>{0}</color> enhancement with a random value.This cannot be reversed.", ["Eh_econ_NotEnough"] = "You do not have enough money to perform this enhancement.", ["Eh_econ_Error"] = "Something went wrong while withdrawing money for the enhancement.", ["Eh_SRP_NotEnough"] = "You do not have enough points to perform this enhancement.", ["Eh_SRP_Error"] = "Something went wrong while taking points for the enhancement.", ["Eh_Scrap_NotEnough"] = "You do not have enough scrap to perform this enhancement.", ["Eh_Custom_NotEnough"] = "You do not have enough {0} to perform this enhancement.", ["IPGive_Usage"] = "Usage: /ipgive <target> <Optional: shortname> <optional: perks>", ["IPWithSkinGive_Usage"] = "Usage: /ipgive <target> <skin> <Optional: shortname> <optional: perks>", ["ReceivedKit"] = "You received 1x <color=#4cff03>{0}</color>", ["GaveKitConsoleReply"] = "Gave 1x {0} to {1}.", ["KitConsoleUsageRevised"] = "Usage: ipgivekit <target> <optional: perk>", ["KitChatUsage"] = "Usage: /ipgivekit <perk>", ["PerkInvalid"] = "Invalid perk: {0}", ["PerkPlayerLimit"] = "\nPerk capped at: <color=#51ff00>{0}%</color>.", ["serverrewards"] = "RP", ["scrap"] = "Scrap", ["economics"] = "Dollars", ["custom"] = "Custom Item"
}
;
var perks = PerkDescriptions;
foreach (var perk in perks) langDict.Add(perk.Key, perk.Value);
perks.Clear();
perks = null;
foreach (var perk in DefaultPerkSettings) {
var str = perk.Key.ToString();
string value = string.Empty;
bool firstChat = true;
foreach (char c in str) {
if (!firstChat && char.IsUpper(c)) value += " ";
value += c;
firstChat = false;
}
langDict.Add("UI" + str, value);
}
lang.RegisterMessages(langDict, this);
}
Dictionary<string, string> PerkDescriptions {
get {
return new Dictionary<string, string>() {
["Prospector"]
= "This perk increases your mining yield when mining stone, metal and sulfur nodes.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Lumberjack"] = "This perk increases your woodcutting yield when chopping living or dead trees.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Butcher"] = "This perk increases the resources gained from skinning humans and animals.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Horticulture"] = "This perk increases the amount of resources gained when harvesting grown plans.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Forager"] = "This perk increases the amount of resources gained when picking up map generated collectibles.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Angler"] = "This perk increases the amount of fish you receive upon a successful catch.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["BeastBane"] = "This perk increases the damage dealt to animals.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["ScientistBane"] = "This perk increases the damage dealt to scientists.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["FlakJacket"] = "This perk reduces the damage received from explosions.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Elemental"] = "This perk reduces damage received from cold and heat sources.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Scavenger"] = "This perk provides you with a chance to find additional scrap from crates and barrels.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Hybrid"] = "This perk reduces fuel consumption when mounting boats and helicopters.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Manufacture"] = "This perk increases the speed of your crafting.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Durable"] = "This peark reduces the durability damage of all equipped items.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["BeastWard"] = "This perk reduces the damage received from animals.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["ScientistWard"] = "This perk reduces the damage received from scientists.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Equestrian"] = "This perk increases the speed of your mounted horse.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Builder"] = "This perk provides you with a chance for your building upgrades to be free.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Thrifty"] = "This perk provides you with a chance for your crafting components to be refunded upon a successful craft.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Fabricate"] = "This perk provides you with a chance to duplicate an item upon a successful craft.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Pharmaceutical"] = "This perk increases the amount of healing received from all sources.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["MeleeWard"] = "This perk reduces the damage received from melee weapons.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Sails"] = "Ths perk increases the speed of your boat.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Academic"] = "This perk provides you with a chance to receive a scrap refund when researching an item at the research bench.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["FallDamage"] = "This perk reduces the impact damage received from falling.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Lead"] = "This perk reduces the damage from radiation.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Gilled"] = "This perk allows you to breath underwater for a set amount of time.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Smasher"] = "This perk will provide you with a chance to instantly destroy barrels with any amount of damage.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Environmentalist"] = "This perk will increase the speed of recyclers that you activate.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Smelter"] = "This perk will increase the smelting speed of furnaces you activate.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Paramedic"] = "This perk provides players that you revive with additional health.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Prepper"] = "This perk provides you with a chance to not consume food when eating.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Regeneration"] = "This perk will passively regenerate you.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["SharkWard"] = "This perk will reduce the amount of damage received from sharks.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["SharkBane"] = "This perk will increase the amount of damage dealt to sharks.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Deforest"] = "This perk provides you with a chance to cut down nearby trees when successfully cutting a tree down.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["BlastMine"] = "This perk provides you with a chance to mine out nearby nodes when successfully mining out a node.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Tanner"] = "This perk provides you with a chance to skin nearby corpses when successfully skinning out a corpse.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Vampiric"] = "This perk will heal you for a percentage of the damage dealt to certain enemies.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Reinforced"] = "This perk will reduce the the amount of damage that your vehicles receive when mounted.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["ComponentLuck"] = "This perk will provide you with a chance to receive additional components when looting barrels and crates.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["ElectronicsLuck"] = "This perk will provide you with a chance to receive additional electronics when looting barrels and crates.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["UncannyDodge"] = "This perk provides you with a chance to dodge incoming damage, reducing it to 0.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["LineStrength"] = "This perk increases the tensile strength of your fishing line.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["HealShare"] = "This perk will share healing effects with nearby players.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Attractive"] = "This perk will provide you with a chance to automatically pick up components when destroying barrels.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["TreePlanter"] = "This perk will provide a chance for a tree to instantly regrow when cut down.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["RockCycler"] = "This perk will provide a chance for a node to instantly respawn when mined out.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["Sated"] = "This perk will increase the amount of calories and hydration you receive from food and water sources.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["IronStomach"] = "This perk provides you with a chance to negate negative effects when consuming food.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["WoodcuttingLuck"] = "This perk provides you with a chance to find a random item when you cut down a tree.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["MiningLuck"] = "This perk provides you with a chance to find a random item when you mine out a node.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["SkinningLuck"] = "This perk provides you with a chance to find a random item when you skin out a corpse.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["FishingLuck"] = "This perk provides you with a chance to find a random item when you catch a fish.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["BradleyDamage"] = "This perk perk increases the damage dealt to Bradley Tanks.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>", ["HeliDamage"] = "This perk perk increases the damage dealt to Patrol Helicopters.\nPerk rolls - Min: <color=#51ff00>{0}{2}</color> <color=#ffff00><></color> Max: <color=#51ff00>{1}{2}</color>",
}
;
}
}
#endregion
#region Classes
[PluginReference]
private Plugin Cooking, UINotify, Economics, ServerRewards, RandomTrader;
public class PlayerSettings {
[JsonProperty("Command to open the ItemPerks menu")]
public string command = "ip";
[JsonProperty("Send the icon to access the ItemPerks menu?")]
public bool send_menu_icon = true;
[JsonProperty("Icon position")]
public IconSettings iconSettings = new IconSettings(64, 0, 0);
[JsonProperty("Steam workshop ID to use for the hud icon")]
public ulong icon_id = 2907569326;
[JsonProperty("Only show the inspector icon when the player has an enhanced piece equipped/held?")]
public bool only_show_when_equipped = true;
[JsonProperty("Show the UI displaying the combined bonuses for all worn/held items?")]
public bool show_total_bonuses = true;
[JsonProperty("Settings for UINotify")]
public UINotifySettings uinotify_settings = new UINotifySettings();
}
public class UINotifySettings {
[JsonProperty("Send player specific messages using the notify plugin")]
public bool enabled = true;
[JsonProperty("Message type")]
public int messageType = 0;
[JsonProperty("Send notification when an Enhanced item drops from a barrel or crate")]
public bool notify_ItemDrops = true;
[JsonProperty("Send notification when the player crafts an Enhanced item")]
public bool notify_Crafted = true;
[JsonProperty("Send notification when the FishingLuck perk procs")]
public bool notify_FishingLuck = true;
[JsonProperty("Send notification when the WoodcuttingLuck perk procs")]
public bool notify_WoodcuttingLuck = true;
[JsonProperty("Send notification when the MiningLuck perk procs")]
public bool notify_MiningLuck = true;
[JsonProperty("Send notification when the SkinningLuck perk procs")]
public bool notify_SkinningLuck = true;
[JsonProperty("Send notification when the Thrifty perk procs")]
public bool notify_ComponentRefund = true;
[JsonProperty("Send notification when the Fabricate perk procs")]
public bool notify_ItemDuplication = true;
[JsonProperty("Send notification when the Prepper perk procs")]
public bool notify_Rationed = true;
[JsonProperty("Send notification when the Builder perk procs")]
public bool notify_FreeUpgrade = true;
[JsonProperty("Send notification when the Academic perk procs")]
public bool notify_ResearchRefund = true;
[JsonProperty("Send notification when the UncannyDodge perk procs")]
public bool notify_Dodge = true;
}
public class IconSettings {
public float size;
public float offset_x;
public float offset_y;
public string anchor_min = "0.5 0";
public string anchor_max = "0.5 0";
public IconSettings(float size, float offset_x, float offset_y, string anchor_min = "0.5 0", string anchor_max = "0.5 0") {
this.size = size;
this.offset_x = offset_x;
this.offset_y = offset_y;
this.anchor_min = anchor_min;
this.anchor_max = anchor_max;
}
}
public class EnhancementSettings {
[JsonProperty("Loot settings")]
public LootSettings lootSettings = new LootSettings();
[JsonProperty("Chance for an item to receive additional perks after successfully rolling its first perk? [out of 100]")]
public Dictionary<int, float> additional_perk_chances;
[JsonProperty("Allow items to have the same perk more than once?")]
public bool allow_duplicate_perks = true;
[JsonProperty("Naming prefix to show that the item is enhanced.Leaving empty will not adjust the items name.")]
public string item_name_prefix = "Enhanced";
[JsonProperty("Prevent the maximum condition of the item from being reduced when repaired?")]
public bool prevent_max_condition_loss = false;
[JsonProperty("Perk settings")]
public Dictionary<Perk, PerkSettings> perk_settings;
[JsonProperty("Perk configuration")]
public PerkConfigs perk_config = new PerkConfigs();
[JsonProperty("List of skins for item types.If more than 1 skin is added, a random one will be selected when the item is created.")]
public Dictionary<string, List<ulong>> item_skins = new Dictionary<string, List<ulong>>();
[JsonProperty("Permission based modifiers")]
public ChanceModifierSettings chance_modifier_settings = new ChanceModifierSettings();
[JsonProperty("Enhancement kit settings")]
public EnhancementKitSettings enhancement_kit_settings = new EnhancementKitSettings();
}
public class EnhancementKitSettings {
[JsonProperty("Cap the amount of perks that an item can have attached to it?")]
public bool perks_capped = true;
public string displayName = "enhancement kit:";
public string shortname = "blood";
public ulong skin = 2920198584;
[JsonProperty("Recycle Settings")]
public EnhancementRecyclingSettings recycle_settings = new EnhancementRecyclingSettings();
[JsonProperty("Enhancement Settings")]
public EnhancementUpgradeSettings upgrade_settings = new EnhancementUpgradeSettings();
}
public class EnhancementRecyclingSettings {
[JsonProperty("Chance when recycling an enhanced item (per enhancement) to give an enhancement kit [0 = off, 100.0 = 100%]")]
public float perk_kit_chance = 5f;
[JsonProperty("Effect to run over the recycler when a kit is successfully awarded")]
public string success_effect = "assets/prefabs/misc/halloween/lootbag/effects/gold_open.prefab";
[JsonProperty("Provide a random perk if successful (instead of the perk attached to the recycled item)?")]
public bool random_perk = false;
}
public class EnhancementUpgradeSettings {
[JsonProperty("Effect to run when the upgrade is successful")]
public string enhance_effect = "assets/prefabs/misc/halloween/lootbag/effects/gold_open.prefab";
[JsonProperty("Type of currency to use for additional upgrade costs [scrap, economics, serverrewards, custom]")]
public string upgrade_cost_type = "scrap";
[JsonProperty("Custom currency information")]
public CustomCostItem custom_item = new CustomCostItem();
[JsonProperty("Additional cost when enhancing an item via an enhancement kit")]
public Dictionary<Perk, float> additional_upgrade_cost = new Dictionary<Perk, float>();
}
public class CustomCostItem {
[JsonProperty("Currency shortname")]
public string shortname;
[JsonProperty("Currency skin ID")]
public ulong skin;
}
public class LootSettings {
// Key is crate type.Float is chance.[JsonProperty("Chance for a player to receive an enhanced item when looting a container [out of 100]")]
public Dictionary<string, float> container;
[JsonProperty("List of items that cannot be enhanced")]
public List<string> enhanceable_blacklist = new List<string>();
[JsonProperty("Use Rust's default loot profile? [true: Will only give items that the container could provide]")]
public bool use_default_loot_profiles = true;
[JsonProperty("Chance out of 100 for the item to be enhanced when crafting [0 = off]")]
public float craft_chance = 1f;
[JsonProperty("Notify the player in chat when they craft an enhanced item")]
public bool notify_craft_chat = true;
[JsonProperty("List of items that cannot be enhanced when crafting")]
public List<string> craft_blacklist = new List<string>();
[JsonProperty("Cooldown after successfully crafting an enhanced item, before they can craft another one [seconds]")]
public float craft_success_cooldown = 0;
}
public class ChanceModifierSettings {
[JsonProperty("Permission modifiers to increase the chance of obtaining enhanced loot from all sources [1.0 = 100% increase in chance]")]
public Dictionary<string, float> loot_chance_permissions = new Dictionary<string, float>();
[JsonProperty("Permission modifiers to increase the chance of obtaining enhancement kit when recycling [1.0 = 100% increase in chance]")]
public Dictionary<string, float> recycle_chance_permissions = new Dictionary<string, float>();
[JsonProperty("Permission modifiers to increase the chance of obtaining enhanced loot when crafting [1.0 = 100% increase in chance]")]
public Dictionary<string, float> craft_chance_permissions = new Dictionary<string, float>();
}
public class PerkSettings {
public bool enabled;
public float min_mod;
public float max_mod;
public int perkWeight;
public List<string> whitelist;
public List<string> blacklist;
[JsonProperty("Perk modifier cap")]
public float perk_cap;
public PerkSettings(bool enabled, float min_mod, float max_mod, int perkWeight = 100, List<string> whitelist = null, List<string> blacklist = null, float player_mod_limit = 0) {
this.enabled = enabled;
this.min_mod = min_mod;
this.max_mod = max_mod;
this.perkWeight = perkWeight;
this.whitelist = whitelist;
this.blacklist = blacklist;
this.perk_cap = player_mod_limit;
}
}
public class PerkConfigs {
[JsonProperty("Settings for Deforest perk")]
public DeforestSettings deforestSettings = new DeforestSettings();
[JsonProperty("Settings for BlastMine perk")]
public BlastMineSettings blastMineSettings = new BlastMineSettings();
[JsonProperty("Settings for Tanner perk")]
public TannerSettings tannerSettings = new TannerSettings();
[JsonProperty("Settings for Vampiric perk")]
public VampiricSettings vampiricSettings = new VampiricSettings();
[JsonProperty("Maximum amount of scrap that the scavenger perk can award")]
public int scavenger_max_amount = 3;
[JsonProperty("Settings for Thrifty perk")]
public ThriftySettings thriftySettings = new ThriftySettings();
[JsonProperty("Settings for Fabricate perk")]
public FabricateSettings fabricateSettings = new FabricateSettings();
[JsonProperty("Settings for Prepper perk")]
public PrepperSettings prepperSettings = new PrepperSettings();
[JsonProperty("Settings for ComponentLuck perk")]
public ComponentLuckSettings componentLuckSettings = new ComponentLuckSettings();
[JsonProperty("Settings for ElectricalLuck perk")]
public ElectricalLuckSettings electricalLuckSettings = new ElectricalLuckSettings();
[JsonProperty("Settings for Attractive perk")]
public AttractiveSettings attractiveSettings = new AttractiveSettings();
[JsonProperty("Settings for HealShare perk")]
public HealShareSettings healShareSettings = new HealShareSettings();
[JsonProperty("Settings for Regeneration perk")]
public RegenSettings regenerationSettings = new RegenSettings();
[JsonProperty("Settings for WoodcuttingLuck perk")]
public GatherLuckSettings woodcuttingLuckSettings = new GatherLuckSettings();
[JsonProperty("Settings for MiningLuck perk")]
public GatherLuckSettings miningLuckSettings = new GatherLuckSettings();
[JsonProperty("Settings for SkinningLuck perk")]
public GatherLuckSettings skinningLuckSettings = new GatherLuckSettings();
[JsonProperty("Settings for FishingLuck perk")]
public GatherLuckSettings fishingLuckSettings = new GatherLuckSettings();
[JsonProperty("Settings for ScientistBane perk")]
public ScientistBaneSettings ScientistBaneSettings = new ScientistBaneSettings();
[JsonProperty("Settings for Durability perk")]
public DurabilitySettings DurabilitySettings = new DurabilitySettings();
}
#region Perk configs
public class DurabilitySettings {
[JsonProperty("List of items that the Durability perk will not work with")]
public List<string> durability_blacklist = new List<string>();
}
public class DeforestSettings {
[JsonProperty("The radius that the Deforest perk checks for trees to cut down")]
public float deforest_max_radius = 5f;
}
public class BlastMineSettings {
[JsonProperty("The radius that the BlastMine perk checks for nodes to mine out")]
public float blastmine_max_radius = 30f;
}
public class TannerSettings {
[JsonProperty("The radius that the Tanner perk checks for corpses to skin out")]
public float tanner_max_radius = 30f;
}
public class VampiricSettings {
[JsonProperty("Enemy types that the Vampiric ability will work on [scientist, player, animal]")]
public List<string> vampiric_entities = new List<string>();
}
public class ThriftySettings {
[JsonProperty("List of items that will not be refunded upon a successful Thrifty proc")]
public List<string> blacklist_shortnames = new List<string>();
}
public class FabricateSettings {
[JsonProperty("List of items that will not be duplicated upon a successful Fabricate proc")]
public List<string> blacklist_shortnames = new List<string>();
}
public class PrepperSettings {
[JsonProperty("List of items that will not be refunded when the Prepper perk procs")]
public List<string> blacklist_shortnames = new List<string>();
}
public class ComponentLuckSettings {
[JsonProperty("Minimum amount of components that will be given when the ComponentLuck perk procs")]
public int min = 1;
[JsonProperty("Maximum amount of components that will be given when the ComponentLuck perk procs")]
public int max = 3;
[JsonProperty("List of components that are excluded by the ComponentLuck perk")]
public List<string> blacklist_shortnames = new List<string>();
}
public class ElectricalLuckSettings {
[JsonProperty("Minimum amount of electronics that will be given when the ElectricalLuck perk procs")]
public int min = 1;
[JsonProperty("Maximum amount of electronics that will be given when the ElectricalLuck perk procs")]
public int max = 2;
[JsonProperty("List of electrical items that are excluded by the ElectricalLuck perk")]
public List<string> blacklist_shortnames = new List<string>();
}
public class AttractiveSettings {
[JsonProperty("Maximum distance that the Attractive perk will work [0 = no limit]")]
public float max_dist = 0f;
[JsonProperty("Only allow melee perks to trigger the Attractive perk?")]
public bool meleeOnly = false;
}
public class HealShareSettings {
[JsonProperty("Maximum distance that the HealShare perk will work")]
public float distance = 10f;
[JsonProperty("Only allow Healshare to work on members of the players team?")]
public bool team_only = true;
}
public class RegenSettings {
[JsonProperty("Delay after receiving damage before the regen buff continues to heal [set to 0 to ignore damage]")]
public float damage_delay = 5f;
}
public class GatherLuckSettings {
public Dictionary<string, DropInfo> drop_rates = new Dictionary<string, DropInfo>();
}
public class DropInfo {
public int min_amount;
public int max_amount;
public ulong skin;
public string display_name;
public DropInfo(int min_amount, int max_amount, ulong skin = 0, string display_name = null) {
this.min_amount = min_amount;
this.max_amount = max_amount;
this.skin = skin;
this.display_name = display_name;
}
}
public class ScientistBaneSettings {
[JsonProperty("Only allow ScientistBane to work against vanilla scientist NPCs (excludes HumanNPC, scarecrows etc)?")]
public bool scientist_only = false;
}
#endregion
static Dictionary<ulong, PlayerPerks> Player_perks;
public class PlayerPerks {
public Dictionary<Perk, float> perk_modifiers = new Dictionary<Perk, float>();
}
static Dictionary<string, Perk> parsedEnums = new Dictionary<string, Perk>(StringComparer.InvariantCultureIgnoreCase);
List<Perk> PerksList;
Dictionary<string, ItemBlueprint> item_BPs;
Dictionary<string, int> ItemIDs;
// ... [Code preview truncated due to length. Full source in attached file] ...