C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
// #define TESTING
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using Facepunch;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using Rust;
using UnityEngine;
using Analytics = Facepunch.Rust.Analytics;
using Random = UnityEngine.Random;
namespace Oxide.Plugins
{
[Info("Skills", "Mevent", "1.31.21")]
[Description("Adds a system of skills")]
public class Skills : RustPlugin
{
#region Fields
[PluginReference] private Plugin
ImageLibrary = null,
Notifications = null,
Notify = null,
UINotify = null,
TimedPermissions = null;
private const string Layer = "Com.Mevent.Main";
private static Skills _instance;
private bool _enabledImageLibrary;
private const string PERM_Bypass = "skills.bypass";
private const string PERM_Wipe = "skills.wipe";
private readonly Dictionary<ulong, RecoverComponent> _recoverPlayers =
new Dictionary<ulong, RecoverComponent>();
private HashSet<ulong> _containers = new HashSet<ulong>();
private readonly Dictionary<ulong, float> _timeSinceLastMetabolism = new Dictionary<ulong, float>();
private enum SkillType
{
Wood,
Stones,
Metal,
Sulfur,
Attack,
Secure,
Regeneration,
Metabolism,
ComponentsRates,
StandUpChance,
CraftSpeed,
FastOven,
Kits,
None,
Cloth,
Butcher,
Scrap,
RecyclerSpeed,
TransferWipe,
MixingTableSpeed,
Gather,
CraftRates
//RecyclerChance,
//PowerEffieciency
}
private readonly Dictionary<BaseOven, BasePlayer> _playerByOven = new Dictionary<BaseOven, BasePlayer>();
/*
private readonly Dictionary<uint, ulong> _playerIdByRecycler = new Dictionary<uint, ulong>();
*/
#endregion
#region Config
private static Configuration _config;
private class Configuration : SerializableConfiguration
{
[JsonProperty(PropertyName = "Permission (example: skills.use)")]
public string Permission = string.Empty;
[JsonProperty(PropertyName = "Command")]
public string Command = "skills";
[JsonProperty(PropertyName = "Auto wipe?")]
public bool Wipe = true;
[JsonProperty(PropertyName = "Work with Notify?")]
public bool UseNotify = true;
[JsonProperty(PropertyName = "Store the data on the looted containers in the data-files?")]
public bool StoreContainers = false;
[JsonProperty(PropertyName = "Economy")]
public EconomyConf Economy = new EconomyConf
{
Type = EconomyType.Plugin,
AddHook = "Deposit",
BalanceHook = "Balance",
RemoveHook = "Withdraw",
Plug = "Economics",
ShortName = "scrap",
DisplayName = string.Empty,
Skin = 0
};
[JsonProperty(PropertyName = "Maximum level notify")]
public INotify MaxLevel = new INotify
{
Image = "warning",
Url = "https://i.imgur.com/p3tKXJV.png",
Delay = 0.9f
};
[JsonProperty(PropertyName = "Out of balance notify")]
public INotify NotMoney = new INotify
{
Image = "warning",
Url = "https://i.imgur.com/p3tKXJV.png",
Delay = 0.9f
};
[JsonProperty(PropertyName = "Background")]
public IPanel Background = new IPanel
{
AnchorMin = "0 0", AnchorMax = "1 1",
OffsetMin = "0 0", OffsetMax = "0 0",
Image = string.Empty,
Color = new IColor("#0D1F4E", 95),
isRaw = false,
Sprite = "Assets/Content/UI/UI.Background.Tile.psd",
Material = "Assets/Icons/IconMaterial.mat"
};
[JsonProperty(PropertyName = "Title")] public IText Title = new IText
{
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5",
OffsetMin = "-150 300", OffsetMax = "150 360",
Font = "robotocondensed-bold.ttf",
Align = TextAnchor.MiddleCenter,
FontSize = 38,
Color = new IColor("#FFFFFF", 100)
};
[JsonProperty(PropertyName = "Back")] public IText Back = new IText
{
AnchorMin = "0 0.5", AnchorMax = "0 0.5",
OffsetMin = "0 -40", OffsetMax = "65 40",
Font = "robotocondensed-bold.ttf",
Align = TextAnchor.MiddleCenter,
FontSize = 60,
Color = new IColor("#FFFFFF", 100)
};
[JsonProperty(PropertyName = "Next")] public IText Next = new IText
{
AnchorMin = "1 0.5", AnchorMax = "1 0.5",
OffsetMin = "-65 -40", OffsetMax = "0 40",
Font = "robotocondensed-bold.ttf",
Align = TextAnchor.MiddleCenter,
FontSize = 60,
Color = new IColor("#FFFFFF", 100)
};
[JsonProperty(PropertyName = "Balance")]
public IText BalanceText = new IText
{
AnchorMin = "0.5 0", AnchorMax = "0.5 0",
OffsetMin = "-150 0", OffsetMax = "150 75",
Font = "robotocondensed-regular.ttf",
Align = TextAnchor.MiddleCenter,
FontSize = 24,
Color = new IColor("#FFFFFF", 100)
};
[JsonProperty(PropertyName = "Enable Balance Icon")]
public bool EnableBalanceIcon = false;
[JsonProperty(PropertyName = "Balance Icon")]
public BalanceIcon BalanceIcon = new BalanceIcon
{
OffsetMinY = 20,
OffsetMaxY = 55,
Length = 35
};
[JsonProperty(PropertyName = "Close")] public IText CloseLabel = new IText
{
AnchorMin = "1 1", AnchorMax = "1 1",
OffsetMin = "-35 -35", OffsetMax = "-5 -5",
Font = "robotocondensed-bold.ttf",
Align = TextAnchor.MiddleCenter,
FontSize = 24,
Color = new IColor("#FFFFFF", 100)
};
[JsonProperty(PropertyName = "Skill Panel")]
public SkillPanel SkillPanel = new SkillPanel
{
Background = new SIPanel
{
Image = string.Empty,
Color = new IColor("#1D3676", 98),
isRaw = false,
Sprite = "Assets/Content/UI/UI.Background.Tile.psd",
Material = "Assets/Icons/IconMaterial.mat",
HeightCorrect = 5
},
Image = new InterfacePosition
{
AnchorMin = "0 0", AnchorMax = "0 0",
OffsetMin = "10 10", OffsetMax = "160 160"
},
Title = new IText
{
AnchorMin = "0 0", AnchorMax = "1 0",
OffsetMin = "165 135", OffsetMax = "-5 160",
Align = TextAnchor.MiddleLeft,
FontSize = 20,
Font = "robotocondensed-bold.ttf",
Color = new IColor("#FFFFFF", 100)
},
Description = new IText
{
AnchorMin = "0 0", AnchorMax = "1 0",
OffsetMin = "165 30", OffsetMax = "-5 130",
Align = TextAnchor.UpperLeft,
FontSize = 14,
Font = "robotocondensed-regular.ttf",
Color = new IColor("#FFFFFF", 100)
},
Button = new IButton
{
AnchorMin = "1 0", AnchorMax = "1 0",
OffsetMin = "-105 10", OffsetMax = "-10 30",
AColor = new IColor("#B5FFC9", 100),
DColor = new IColor("#B5FFC9", 25),
TextUi = new IText
{
AnchorMin = "0 0", AnchorMax = "1 1",
OffsetMin = "0 0", OffsetMax = "0 0",
Align = TextAnchor.MiddleCenter,
FontSize = 14,
Font = "robotocondensed-regular.ttf",
Color = new IColor("#1D3676", 100)
}
},
DescriptionButton = new DescriptionButton
{
Enabled = false,
AnchorMin = "1 0", AnchorMax = "1 0",
OffsetMin = "-105 35", OffsetMax = "-10 55",
AColor = new IColor("#B5FFC9", 100),
DColor = new IColor("#B5FFC9", 25),
TextUi = new IText
{
AnchorMin = "0 0", AnchorMax = "1 1",
OffsetMin = "0 0", OffsetMax = "0 0",
Align = TextAnchor.MiddleCenter,
FontSize = 14,
Font = "robotocondensed-regular.ttf",
Color = new IColor("#1D3676", 100)
}
},
Cost = new IText
{
AnchorMin = "1 0", AnchorMax = "1 0",
OffsetMin = "-150 10", OffsetMax = "-110 30",
Align = TextAnchor.MiddleRight,
FontSize = 14,
Font = "robotocondensed-regular.ttf",
Color = new IColor("#FFFFFF", 100)
},
AddCost = "$",
EnableCostImage = false,
AddCostImage = new IPanel
{
AnchorMin = "1 0", AnchorMax = "1 0",
OffsetMin = "-130 10", OffsetMax = "-110 30",
Color = new IColor("#FFFFFF", 100),
isRaw = true,
Image = "https://i.imgur.com/5GdD0cU.png",
Sprite = string.Empty,
Material = string.Empty
},
Stages = new IProgress
{
AnchorMin = "0 0", AnchorMax = "0 0",
OffsetMin = "160 10", OffsetMax = "160 10",
Height = 20,
Width = 10,
Margin = 5,
AColor = new IColor("#8C70D6", 100),
DColor = new IColor("#8C70D6", 25)
},
Count = 6,
Height = 170,
Width = 565,
Margin = 20,
ShowAllStages = true
};
[JsonProperty(PropertyName = "Skills", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<Skill> Skills = new List<Skill>
{
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Wood,
ID = 0,
ShortName = string.Empty,
Image = "https://gspics.org/images/2020/09/02/xz6Fy.png",
Title = "Woodman",
Description =
"It's in charge of the tree mining\nWhen you learn the skill, the rate increases by x1",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty,
10,
133,
0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 25,
164,
0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 40,
200,
0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Stones,
ID = 0,
ShortName = string.Empty,
Image = "https://gspics.org/images/2020/09/02/xz9mX.png",
Title = "Stone Miner",
Description =
"It's in charge of the stones mining\nWhen you learn the skill, the rate increases by x1",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10,
133,
0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 25,
164,
0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 40,
200,
0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Metal,
ID = 0,
ShortName = string.Empty,
Image = "https://gspics.org/images/2020/09/02/xznT3.png",
Title = "Metal Miner",
Description =
"It's in charge of the metal ore mining\nWhen you learn the skill, the rate increases by x1",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10,
133,
0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 25,
164,
0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 40,
200,
0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Sulfur,
ID = 0,
ShortName = string.Empty,
Image = "https://gspics.org/images/2020/09/02/xz4te.png",
Title = "Sulfure Miner",
Description =
"It's in charge of the sulfur ore mining\nWhen you learn the skill, the rate increases by x1",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10,
133,
0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 25,
164,
0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 40,
200,
0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Attack,
ID = 0,
ShortName = string.Empty,
Image = "https://gspics.org/images/2020/09/02/xzXza.png",
Title = "Attack",
Description =
"Changes the damage of any weapon\nWhen you learn the skill, you'll increase your damage by 15%.",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 20,
5,
0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 35,
10,
0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 50,
15,
0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Secure,
ID = 0,
ShortName = string.Empty,
Image = "https://gspics.org/images/2020/09/02/xzAfi.png",
Title = "Secure",
Description =
"Changes the damage of any weapon\nWhen you learn the skill, you'll increase your protection by 15%.",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 20,
5,
0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 35,
10,
0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 50,
15,
0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Regeneration,
ID = 0,
ShortName = string.Empty,
Image = "https://gspics.org/images/2020/09/02/xzGrO.png",
Title = "Regeneration",
Description =
"Speed health regeneration\nWhen you learn the skill, you'll increase the rate of regeneration by 50%.",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10,
0.5f,
0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 15,
1,
0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 20,
2,
0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Metabolism,
ID = 0,
ShortName = string.Empty,
Image = "https://gspics.org/images/2020/09/02/xzWdI.png",
Title = "Metabolism",
Description =
"Changes the restoration of thirst and hunger\nWhen you learn the skill, you will get calories and hydration",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10, 0.5f, 0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 15, 1, 0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 20, 2, 0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.ComponentsRates,
ID = 0,
ShortName = string.Empty,
Image = "https://gspics.org/images/2020/09/02/xz15L.png",
Title = "Rates to components",
Description =
"Changes the rates of extractive components\nWhen we learn the skill, the components found will be x4",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10, 2, 0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 15, 3, 0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 20, 4, 0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.StandUpChance,
ID = 0,
ShortName = string.Empty,
Image = "https://gspics.org/images/2020/09/02/xzTDD.png",
Title = "Increased chance to stand",
Description =
"It's a bigger chance to get up when you're wounded\nWhen you learn the skill, the chance goes up from standard 20% to 50%.",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10, 30, 40,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 15, 40, 50,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 20, 50, 60,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.CraftSpeed,
ID = 0,
ShortName = string.Empty,
Image = "https://i.imgur.com/fAti1Cj.png",
Title = "Craft Speed",
Description =
"Speeds up your craft.\nWhen you learn the skill, you can craft items in almost instant",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10, 30, 0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 15, 40, 0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 20, 50, 0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Kits,
ID = 0,
ShortName = string.Empty,
Image = "https://i.imgur.com/Log7sQR.png",
Title = "Kits Speed",
Description =
"Accelerates the delay between receiving kits",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10, 30, 0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 15, 40, 0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 20, 50, 0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.FastOven,
ID = 0,
ShortName = string.Empty,
Image = "https://i.imgur.com/IifHk5l.png",
Title = "Fast Oven",
Description =
"Accelerating furnace melting",
Stages = new Dictionary<int, StageConf>()
},
new Skill
{
Enabled = true,
Permission = string.Empty,
ID = 0,
ShortName = string.Empty,
Type = SkillType.None,
Image = "https://i.imgur.com/RqdcAm0.png",
Title = "Sorting",
Description =
"With each stage, you discover new types of sorting",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 25, 0, 0, new List<string>(), new List<string>(),
new List<string>
{
"furnacesplitter.use"
},
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 40, 0, 0, new List<string>(), new List<string>(),
new List<string>
{
"activesort.use"
},
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
ID = 1,
ShortName = string.Empty,
Type = SkillType.None,
Image = "https://i.imgur.com/S4xulmj.png",
Title = "Teleportation",
Description =
"You teleport faster with each stage",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 30, 0, 0, new List<string>(), new List<string>(),
new List<string>
{
"nteleportation.vip"
},
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 50, 0, 0, new List<string>(), new List<string>(),
new List<string>
{
"nteleportation.premium"
},
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 80, 0, 0, new List<string>(), new List<string>(),
new List<string>
{
"nteleportation.deluxe"
},
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Cloth,
ID = 0,
ShortName = string.Empty,
Image = "https://i.imgur.com/5fixMch.png",
Title = "Cannabis Picker",
Description =
"It's in charge of the collection of cloth\nWhen you learn the skill, the rate increases by x1",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10, 133, 0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 25, 164, 0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 40, 200, 0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Butcher,
ID = 0,
ShortName = string.Empty,
Image = "https://i.imgur.com/4WlHK7u.png",
Title = "Butcher",
Description =
"It's in charge of the animals prey\nWhen you learn the skill, the rate increases by x1",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10, 133, 0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 25, 164, 0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 40, 200, 0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Scrap,
ID = 0,
ShortName = string.Empty,
Image = "https://i.imgur.com/SEvG4EU.png",
Title = "Scrap",
Description =
"Changes scrap mining rates\nWhen we learn the skill, the components found will be x4",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10, 2, 0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 15, 3, 0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 20, 4, 0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.RecyclerSpeed,
ID = 0,
ShortName = string.Empty,
Image = "https://i.imgur.com/31k3bM0.png",
Title = "Recycler Speed",
Description =
"Changes rate of recycling components\nWhen we learn the skill, the components will be recycler 2 times faster",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10, 4, 0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 15, 3, 0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 20, 2.5f, 0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.TransferWipe,
ID = 0,
ShortName = string.Empty,
Image = "https://i.imgur.com/W23JZVo.png",
Title = "Transfer Wipe",
Description =
"Transferring Skills to the Next Wipe\nWhen we learn this skill, skills will be carried over to the next wipe",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 100, 0, 0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.MixingTableSpeed,
ID = 0,
ShortName = string.Empty,
Image = "https://i.imgur.com/W6uHKeU.png",
Title = "Mixing Table Speed",
Description =
"Changes rate of mixing recipes\nWhen we learn the skill, the recipes will be mixed instantly",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10, 0.8f, 0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 15, 0.45f, 0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 20, 0f, 0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.Gather,
ShortName = "blue.berry|red.berry|white.berry|black.berry",
ID = 3490432,
Image = "https://i.imgur.com/D8RsOS3.png",
Title = "Berry Hunter",
Description =
"It's in charge of picking blueberries\nWhen you learn the skill, the rate increases by x1",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10,
133,
0,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 25,
164,
0,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 40,
200,
0,
new List<RequiredSkillStage>())
}
},
new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.CraftRates,
ShortName = string.Empty,
ID = 0,
Image = "https://i.imgur.com/jnH4ELO.png",
Title = "Craft Rates",
Description =
"Item crafting rates\nIf you learn this skill, you will have an increased chance of getting an increased amount of an item when crafting",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty, 10,
140,
10,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty, 25,
160,
20,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty, 40,
200,
30,
new List<RequiredSkillStage>())
}
}
/*new Skill
{
Enabled = true,
Permission = string.Empty,
Type = SkillType.RecyclerChance,
ShortName = string.Empty,
ID = 0,
Image = "https://i.imgur.com/jnH4ELO.png", //TODO: Change image
Title = "Recycler Change",
Description = //TODO: Change Description
"Item crafting rates\nIf you learn this skill, you will have an increased chance of getting an increased amount of an item when crafting",
Stages = new Dictionary<int, StageConf>
{
[1] = new StageConf(string.Empty,10,
30,
10,
new List<RequiredSkillStage>()),
[2] = new StageConf(string.Empty,25,
50,
20,
new List<RequiredSkillStage>()),
[3] = new StageConf(string.Empty,40,
70,
30,
new List<RequiredSkillStage>())
}
}*/
};
[JsonProperty(PropertyName = "Animals", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> Animals = new List<string>
{
"chicken.corpse",
"boar.corpse",
"bear.corpse",
"wolf.corpse",
"stag.corpse",
"polarbear.corpse"
};
[JsonProperty(PropertyName = "Ovens Black List", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> OvensBlackList = new List<string>
{
"entity shortnameprefab 1",
"entity shortnameprefab 2"
};
[JsonProperty(PropertyName = "Containers Black List",
ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> ContainersBlackList = new List<string>
{
"entity prefab name 1",
"entity prefab name 2"
};
[JsonProperty(PropertyName = "Blacklist for Attack skill",
ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> AttackBlackList = new List<string>
{
"entity prefab name 1",
"entity prefab name 2"
};
[JsonProperty(PropertyName = "Additional settings for the Fast Oven skill")]
public FastOvenSkill FastOven = new FastOvenSkill
{
Stages = new Dictionary<int, FastOvenStage>
{
[1] = new FastOvenStage
{
Permission = string.Empty,
Cost = 10,
Rates = new Dictionary<string, int>
{
{"ore", 1},
{"meat", 1},
{"hq.metal.ore", 1},
{"wood", 1},
{"*", 1}
},
RequiredSkillStages = new List<RequiredSkillStage>
{
new RequiredSkillStage
{
ID = 0,
Type = SkillType.CraftSpeed,
Stage = 1,
RequireSkill = false
}
}
},
[2] = new FastOvenStage
{
Permission = string.Empty,
Cost = 15,
Rates = new Dictionary<string, int>
{
{"ore", 2},
{"meat", 2},
{"hq.metal.ore", 2},
{"wood", 2},
{"*", 2}
},
RequiredSkillStages = new List<RequiredSkillStage>()
},
[3] = new FastOvenStage
{
Permission = string.Empty,
Cost = 20,
Rates = new Dictionary<string, int>
{
{"ore", 3},
{"meat", 3},
{"hq.metal.ore", 3},
{"wood", 3},
{"*", 3}
},
RequiredSkillStages = new List<RequiredSkillStage>()
}
}
};
[JsonProperty(PropertyName = "Additional settings for the Components Rates skill")]
public ComponentsRatesSkill ComponentsRates = new ComponentsRatesSkill
{
AllowedCategories = new List<ItemCategory>
{
ItemCategory.Component
},
AllowedItems = new List<string>
{
"targeting.computer",
"cctv.camera"
},
BlockList = new List<string>
{
"glue",
"techparts"
}
};
[JsonProperty(PropertyName = "Additional Buttons Settings")]
public AdditionalButtonsSettings AdditionalButtons = new AdditionalButtonsSettings
{
Buttons = new List<AdditionalButtonsSettings.AdditinalButton>
{
new AdditionalButtonsSettings.AdditinalButton(false, "https://i.imgur.com/C83Rprq.png", "leaders",
true)
},
UI = new AdditionalButtonsSettings.ButtonsUI
{
SideIndent = 45,
UpIndent = 5,
Size = 30,
Margin = 5
}
};
[JsonProperty(PropertyName = "Additional settings for the Transfer Wipe skill")]
public TransferWipeSkill TransferWipe = new TransferWipeSkill
{
ResetSigle = false
};
[JsonProperty(PropertyName = "Additional settings for the Craft Rates skill")]
public CraftRatesSkill CraftRates = new CraftRatesSkill
{
AllowedList = new List<string>
{
"gunpowder",
"lowgradefuel",
"rock"
}
};
[JsonProperty(PropertyName = "Broadcasting Settings")]
public Broadcasting Broadcasting = new Broadcasting
{
UseLearnSkill = true
};
[JsonProperty(PropertyName = "Use bonus mode for mining skills?")]
public bool UseBonusMode = false;
public VersionNumber Version;
}
private class Broadcasting
{
[JsonProperty(PropertyName = "Enable broadcast when learning a skill?")]
public bool UseLearnSkill;
public void LearnSkill(BasePlayer player, Skill skill, int stage)
{
if (!UseLearnSkill) return;
foreach (var target in BasePlayer.activePlayerList)
{
if (target.EqualNetID(player))
continue;
target.ChatMessage(_instance.Msg(target, BroadcastLearnSkill).Replace("{username}", player.displayName).Replace("{skill_name}", skill.Title).Replace("{stage}", stage.ToString()));
}
}
}
private class TransferWipeSkill
{
[JsonProperty(PropertyName = "Reset after a single use?")]
public bool ResetSigle;
}
private class ComponentsRatesSkill
{
[JsonProperty(PropertyName = "Allowed Categories",
ObjectCreationHandling = ObjectCreationHandling.Replace,
ItemConverterType = typeof(StringEnumConverter))]
public List<ItemCategory> AllowedCategories = new List<ItemCategory>();
[JsonProperty(PropertyName = "Allowed Items", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> AllowedItems = new List<string>();
[JsonProperty(PropertyName = "Components Block List (shortname)",
ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> BlockList = new List<string>();
}
private class AdditionalButtonsSettings
{
[JsonProperty(PropertyName = "Buttons", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<AdditinalButton> Buttons = new List<AdditinalButton>();
[JsonProperty(PropertyName = "Interface Settings")]
public ButtonsUI UI;
public class AdditinalButton
{
[JsonProperty(PropertyName = "Enabled")]
public bool Enabled;
[JsonProperty(PropertyName = "Image")] public string Image;
[JsonProperty(PropertyName = "Command")]
public string Command;
[JsonProperty(PropertyName = "Close Menu")]
public bool CloseMenu;
public AdditinalButton(bool enabled, string image, string command, bool closeMenu)
{
Enabled = enabled;
Image = image;
Command = command;
CloseMenu = closeMenu;
}
}
public class ButtonsUI
{
[JsonProperty(PropertyName = "Side Indent")]
public float SideIndent;
[JsonProperty(PropertyName = "Up Indent")]
public float UpIndent;
[JsonProperty(PropertyName = "Margin")]
public float Margin;
[JsonProperty(PropertyName = "Size")] public float Size;
}
}
private class BalanceIcon
{
[JsonProperty(PropertyName = "Offset Min Y")]
public float OffsetMinY;
[JsonProperty(PropertyName = "Offset Max Y")]
public float OffsetMaxY;
[JsonProperty(PropertyName = "Length")]
public float Length;
}
private class INotify
{
[JsonProperty(PropertyName = "Image Key")]
public string Image;
[JsonProperty(PropertyName = "Image Url")]
public string Url;
[JsonProperty(PropertyName = "Show Time")]
public float Delay;
}
private enum EconomyType
{
Plugin,
Item
}
private class EconomyConf
{
[JsonProperty(PropertyName = "Type (Plugin/Item)")] [JsonConverter(typeof(StringEnumConverter))]
public EconomyType Type;
[JsonProperty(PropertyName = "Plugin name")]
public string Plug;
[JsonProperty(PropertyName = "Balance add hook")]
public string AddHook;
[JsonProperty(PropertyName = "Balance remove hook")]
public string RemoveHook;
[JsonProperty(PropertyName = "Balance show hook")]
public string BalanceHook;
[JsonProperty(PropertyName = "ShortName")]
public string ShortName;
[JsonProperty(PropertyName = "Display Name (empty - default)")]
public string DisplayName;
[JsonProperty(PropertyName = "Skin")] public ulong Skin;
public double ShowBalance(BasePlayer player)
{
switch (Type)
{
case EconomyType.Plugin:
{
var plugin = _instance?.plugins?.Find(Plug);
if (plugin == null) return 0;
return Math.Round(Convert.ToDouble(plugin.Call(BalanceHook, player.userID)), 2);
}
case EconomyType.Item:
{
return ItemCount(player.inventory.AllItems(), ShortName, Skin);
}
default:
return 0;
}
}
public void AddBalance(BasePlayer player, double amount)
{
switch (Type)
{
case EconomyType.Plugin:
{
var plugin = _instance?.plugins?.Find(Plug);
if (plugin == null) return;
switch (Plug)
{
case "Economics":
plugin.Call(AddHook, player.userID, amount);
break;
default:
plugin.Call(AddHook, player.userID, (int) amount);
break;
}
break;
}
case EconomyType.Item:
{
var am = (int) amount;
var item = ToItem(am);
if (item == null) return;
player.GiveItem(item);
break;
}
}
}
public bool RemoveBalance(BasePlayer player, double amount)
{
switch (Type)
{
case EconomyType.Plugin:
{
if (ShowBalance(player) < amount) return false;
var plugin = _instance?.plugins.Find(Plug);
if (plugin == null) return false;
switch (Plug)
{
case "Economics":
plugin.Call(RemoveHook, player.userID, amount);
break;
default:
plugin.Call(RemoveHook, player.userID, (int) amount);
break;
}
return true;
}
case EconomyType.Item:
{
var playerItems = player.inventory.AllItems();
var am = (int) amount;
if (ItemCount(playerItems, ShortName, Skin) < am) return false;
Take(playerItems, ShortName, Skin, am);
return true;
}
default:
return false;
}
}
private Item ToItem(int amount)
{
var item = ItemManager.CreateByName(ShortName, amount, Skin);
if (item == null)
{
Debug.LogError($"Error creating item with ShortName: '{ShortName}'");
return null;
}
if (!string.IsNullOrEmpty(DisplayName)) item.name = DisplayName;
return item;
}
private int ItemCount(Item[] items, string shortname, ulong skin)
{
return items.Where(item =>
item.info.shortname == shortname && !item.isBroken && (skin == 0 || item.skin == skin)).Sum(item => item.amount);
}
private void Take(IEnumerable<Item> itemList, string shortname, ulong skinId, int iAmount)
{
var num1 = 0;
if (iAmount == 0) return;
var list = Pool.GetList<Item>();
foreach (var item in itemList)
{
if (item.info.shortname != shortname ||
(skinId != 0 && item.skin != skinId) || item.isBroken) continue;
var num2 = iAmount - num1;
if (num2 <= 0) continue;
if (item.amount > num2)
{
item.MarkDirty();
item.amount -= num2;
break;
}
if (item.amount <= num2)
{
num1 += item.amount;
list.Add(item);
}
if (num1 == iAmount)
break;
}
foreach (var obj in list)
obj.RemoveFromContainer();
Pool.FreeList(ref list);
}
}
private class CraftRatesSkill
{
[JsonProperty(PropertyName = "Allowed List", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> AllowedList = new List<string>();
}
private class FastOvenSkill : ISkill
{
[JsonProperty(PropertyName = "Work with campfires")]
public bool WorkWithCampfires = true;
[JsonProperty(PropertyName = "Charcoal multiplier")]
public float CharcoalMultiplier = 2;
[JsonProperty(PropertyName = "Stop burning food")]
public bool StopBurningFood = true;
[JsonProperty(PropertyName = "Stages", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public Dictionary<int, FastOvenStage> Stages;
public FastOvenStage GetStage(BasePlayer player)
{
if (player == null) return null;
var skillData = PlayerData.GetOrLoad(player.UserIDString)?.GetSkillData(SkillType.FastOven);
if (skillData == null) return null;
FastOvenStage stage;
return Stages.TryGetValue(skillData.Stage, out stage) ? stage : null;
}
public Dictionary<int, IStage> GetStages(string userid)
{
return Stages.Where(x => x.Value.HasAccess(userid)).ToDictionary(x => x.Key, y => (IStage) y.Value);
}
}
private class FastOvenStage : IStage
{
[JsonProperty(PropertyName = "Permission (ex: skills.vip)")]
public string Permission;
[JsonProperty(PropertyName = "Cost")] public float Cost;
[JsonProperty(PropertyName = "Rates", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public Dictionary<string, int> Rates;
[JsonProperty(PropertyName = "Required skill stages",
ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<RequiredSkillStage> RequiredSkillStages;
public float GetCost()
{
return Cost;
}
public bool HasAccess(string userid)
{
return _config.SkillPanel.ShowAllStages || HasPermissions(userid);
}
public bool HasPermissions(string userid)
{
return string.IsNullOrEmpty(Permission) ||
_instance.permission.UserHasPermission(userid, Permission);
}
public List<RequiredSkillStage> GetRequiredSkillStages()
{
return RequiredSkillStages;
}
}
private class Skill : ISkill
{
[JsonProperty(PropertyName = "Enabled")]
public bool Enabled;
[JsonProperty(PropertyName = "Permission")]
public string Permission = string.Empty;
[JsonProperty(PropertyName = "Type")] [JsonConverter(typeof(StringEnumConverter))]
public SkillType Type;
[JsonProperty(PropertyName = "ID (for None)")]
public int ID;
[JsonProperty(PropertyName = "Image")] public string Image;
[JsonProperty(PropertyName = "Title")] public string Title;
[JsonProperty(PropertyName = "Description")]
public string Description;
[JsonProperty(PropertyName = "Shortname")]
public string ShortName;
[JsonProperty(PropertyName = "Stages", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public Dictionary<int, StageConf> Stages;
public Dictionary<int, IStage> GetStages(string userid)
{
return Stages.Where(x => x.Value.HasAccess(userid)).ToDictionary(x => x.Key, y => (IStage) y.Value);
}
}
private class RequiredSkillStage
{
[JsonProperty(PropertyName = "Type")] [JsonConverter(typeof(StringEnumConverter))]
public SkillType Type;
[JsonProperty(PropertyName = "ID")] public int ID;
[JsonProperty(PropertyName = "Stage")] public int Stage;
[JsonProperty(PropertyName =
"Require the presence of this skill? (otherwise only the stage will be checked)")]
public bool RequireSkill;
public bool? Has(BasePlayer player)
{
var skill = _config.Skills.Find(x => x.Type == Type && x.ID == ID);
if (skill == null) return null;
var dataSkill = PlayerData.GetOrLoad(player.UserIDString)?.GetSkillData(Type, ID);
if (dataSkill == null)
return RequireSkill ? false : (bool?) null;
return dataSkill.Stage >= Stage;
}
}
private class StageConf : IStage
{
[JsonProperty(PropertyName = "Permission (ex: skills.vip)")]
public string Permission;
[JsonProperty(PropertyName = "Cost")] public float Cost;
[JsonProperty(PropertyName =
"Value [metabolism - value, for everyone else %]")]
public float Value;
[JsonProperty(PropertyName = "Value 2")]
public float Value2;
[JsonProperty(PropertyName = "Commands", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> Commands;
[JsonProperty(PropertyName = "Groups", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> Groups;
[JsonProperty(PropertyName = "Permissions", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> Permissions;
[JsonProperty(PropertyName = "Required skill stages",
ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<RequiredSkillStage> RequiredSkillStages;
public StageConf(string permission = "", float cost = 0f, float value = 0f, float value2 = 0f,
List<RequiredSkillStage> requiredSkillStages = null)
{
Permission = permission;
Cost = cost;
Value = value;
Value2 = value2;
RequiredSkillStages = requiredSkillStages ?? new List<RequiredSkillStage>();
Commands = new List<string>();
Groups = new List<string>();
Permissions = new List<string>();
}
[JsonConstructor]
public StageConf(string permission, float cost, float value, float value2, List<string> commands,
List<string> groups,
List<string> permissions, List<RequiredSkillStage> requiredSkillStages)
{
Permission = permission;
Cost = cost;
Value = value;
Value2 = value2;
Commands = commands;
Groups = groups;
Permissions = permissions;
RequiredSkillStages = requiredSkillStages;
}
public bool HasAccess(string userid)
{
return _config.SkillPanel.ShowAllStages || HasPermissions(userid);
}
public bool HasPermissions(string userid)
{
return string.IsNullOrEmpty(Permission) ||
_instance.permission.UserHasPermission(userid, Permission);
}
public float GetCost()
{
return Cost;
}
public List<RequiredSkillStage> GetRequiredSkillStages()
{
return RequiredSkillStages;
}
}
private class SkillPanel
{
[JsonProperty(PropertyName = "Background")]
public SIPanel Background;
[JsonProperty(PropertyName = "Image")] public InterfacePosition Image;
[JsonProperty(PropertyName = "Title")] public IText Title;
[JsonProperty(PropertyName = "Description")]
public IText Description;
[JsonProperty(PropertyName = "Button")]
public IButton Button;
[JsonProperty(PropertyName = "Description Button")]
public DescriptionButton DescriptionButton;
[JsonProperty(PropertyName = "Cost")] public IText Cost;
[JsonProperty(PropertyName = "Add to cost")]
public string AddCost;
[JsonProperty(PropertyName = "Enable Add to cost (image)")]
public bool EnableCostImage;
[JsonProperty(PropertyName = "Add to cost (image)")]
public IPanel AddCostImage;
[JsonProperty(PropertyName = "Stages")]
public IProgress Stages;
[JsonProperty(PropertyName = "Count On Page")]
public int Count;
[JsonProperty(PropertyName = "Height")]
public float Height;
[JsonProperty(PropertyName = "Width")] public float Width;
[JsonProperty(PropertyName = "Margin")]
public float Margin;
[JsonProperty(PropertyName = "Show all stages of skills")]
public bool ShowAllStages;
public void Get(ref CuiElementContainer container,
PlayerData data,
string layer,
int page,
string parent,
int index,
BasePlayer player,
Skill skill,
float oMinX, float oMinY, float oMaxX, float oMaxY,
bool hasBypass)
{
Background?.Get(ref container, parent, parent + $".Skill.{index}", oMinX, oMinY, oMaxX, oMaxY);
container.Add(new CuiElement
{
Parent = parent + $".Skill.{index}",
Components =
{
new CuiRawImageComponent
{Png = _instance?.ImageLibrary?.Call<string>("GetImage", skill.Image)},
new CuiRectTransformComponent
{
AnchorMin = Image.AnchorMin, AnchorMax = Image.AnchorMax, OffsetMin = Image.OffsetMin,
OffsetMax = Image.OffsetMax
}
}
});
Title?.Get(ref container, parent + $".Skill.{index}", parent + $".Skill.{index}.Title", skill.Title);
if (data?.CanSeeDescription(skill) == true)
Description?.Get(ref container, parent + $".Skill.{index}", parent + $".Skill.{index}.Desciprition",
skill.Description);
var cost = _instance?.GetNextPrice(player, skill) ?? -1;
Button?.Get(ref container, player, parent + $".Skill.{index}", parent + $".Skill.{index}.Upgrade.Btn",
$"UI_Skills upgrade {skill.Type} {page} {layer} {skill.ID}", "", cost > 0);
if (DescriptionButton.Enabled)
DescriptionButton?.Get(ref container, player, parent + $".Skill.{index}",
parent + $".Skill.{index}.Description.Btn",
$"UI_Skills changedescview {skill.Type} {page} {layer} {skill.ID}");
if (cost > 0)
{
Cost?.Get(ref container, parent + $".Skill.{index}", parent + $".Skill.{index}.Cost",
$"{cost}{AddCost}");
if (EnableCostImage)
AddCostImage?.Get(ref container, parent + $".Skill.{index}");
}
#region Stages
container.Add(new CuiPanel
{
RectTransform =
{
AnchorMin = Stages.AnchorMin, AnchorMax = Stages.AnchorMax,
OffsetMin = Stages.OffsetMin, OffsetMax = Stages.OffsetMax
},
Image = {Color = "0 0 0 0"}
}, parent + $".Skill.{index}", parent + $".Skill.{index}.Stages");
var skillData = PlayerData.GetOrCreate(player.UserIDString)?.Skills
?.FirstOrDefault(x => x.Type == skill.Type && x.ID == skill.ID);
var xSwitch = 0f;
foreach (var stage in GetSkillStages(skill, player.UserIDString).Keys)
{
var color =
hasBypass ? Stages.AColor
: skillData != null && stage <= skillData.Stage ? Stages.AColor : Stages.DColor;
container.Add(new CuiPanel
{
RectTransform =
{
AnchorMin = "0 0", AnchorMax = "0 0",
OffsetMin = $"{xSwitch} 0", OffsetMax = $"{xSwitch + Stages.Width} {Stages.Height}"
},
Image = {Color = color.Get()}
}, parent + $".Skill.{index}.Stages", parent + $".Skill.{index}.Stages.{stage}");
xSwitch += Stages.Width + Stages.Margin;
}
#endregion
}
}
private class IProgress : InterfacePosition
{
[JsonProperty(PropertyName = "Height")]
public float Height;
[JsonProperty(PropertyName = "Weidth")]
public float Width;
[JsonProperty(PropertyName = "Margin")]
public float Margin;
[JsonProperty(PropertyName = "Active Color")]
public IColor AColor;
[JsonProperty(PropertyName = "No Active Color")]
public IColor DColor;
}
private class IButton : InterfacePosition
{
[JsonProperty(PropertyName = "Color")] public IColor AColor;
[JsonProperty(PropertyName = "No Active Color")]
public IColor DColor;
[JsonProperty(PropertyName = "Text Setting")]
public IText TextUi;
public void Get(ref CuiElementContainer container, BasePlayer player, string parent, string name = null,
string cmd = ""
// ... [Code preview truncated due to length. Full source in attached file] ...