Иконка ресурса

FREE Cannibal : 2.0.2 2.0.2

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using Rust;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEngine;
#region Changelogs and ToDo
/**********************************************************************
* 2.0.0 :   Rewrite
* 2.0.1 :   Removed a double using directive
*           Removed usage of ImageLibrary (obsolete)
*           Added more checks on Animal/Npc deaths.*           Added ZombieHorde checks.*           Hud is now completely transparent
* 2.0.2 :   Fixed exploit on meatconsumption outside playerinventory
*           Harvesting heli/bradley gibs hqm will count as hqm gather
*           Fixed Colors running the same after rank 3

**********************************************************************/
#endregion
namespace Oxide.Plugins {
    [Info("Cannibal", "Krungh Crow", "2.0.2")]
    [Description("Cannibal Game Mode")]
    class Cannibal : CovalencePlugin {
        [PluginReference]
        private Plugin SimpleKillFeed;
#region Variables
        ulong SteamIDIcon = 76561199232739560;
        string cannibalicon = "assets/icons/skull.png";
        const string Admin_Perm = "cannibal.admin";
        const string CPermanent_Perm = "cannibal.permanent";
        const string FXEatingSound = "assets/bundled/prefabs/fx/gestures/eat_generic.prefab";
#endregion
#region Configuration
        private ConfigData configData;
        class ConfigData {
            [JsonProperty(PropertyName = "Prefix")]
            public string Prefix = "[Cannibal] ";
            [JsonProperty(PropertyName = "UI Settings")]
            public UISettings Settings = new UISettings();
            [JsonProperty(PropertyName = "FX Settings")]
            public FXSettings FX = new FXSettings();
            [JsonProperty(PropertyName = "Cannibal Settings")]
            public CSettings CannibalS = new CSettings();
        }
        class UISettings {
            [JsonProperty(PropertyName = "Use Bloody background")]
            public bool UseBloody = true;
            [JsonProperty(PropertyName = "Hud Anchor Min")]
            public string Anchormin = "0 0.95";
            [JsonProperty(PropertyName = "Hud Anchor Max")]
            public string Anchormax = "0.10 1";
        }
        class CSettings {
            [JsonProperty(PropertyName = "Save frequency (seconds)")]
            public float TimerAdd = 5;
            [JsonProperty(PropertyName = "Minimum Cannibal time (seconds)")]
            public float MinTime = 300;
            [JsonProperty(PropertyName = "Cannibal Healing")]
            public CHSettings Heal = new CHSettings();
            [JsonProperty(PropertyName = "Cannibal Eating")]
            public CESettings Eat = new CESettings();
            [JsonProperty(PropertyName = "Cannibal Gather")]
            public CGSettings Gather = new CGSettings();
            [JsonProperty(PropertyName = "Cannibal Damage Dealt")]
            public CDSettings Dmg = new CDSettings();
        }
        class FXSettings {
            [JsonProperty(PropertyName = "FX during Melee hits")]
            public string MeleeHit = "assets/bundled/prefabs/fx/player/gutshot_scream.prefab";
            [JsonProperty(PropertyName = "FX Turning Cannibal")]
            public string Turned = "assets/bundled/prefabs/fx/player/howl.prefab";
            [JsonProperty(PropertyName = "FX Buff end notification")]
            public string BuffEnd = "assets/bundled/prefabs/fx/invite_notice.prefab";
        }
        class CHSettings {
            [JsonProperty(PropertyName = "Can heal self (bandages)")]
            public bool CanHealBandage = true;
            [JsonProperty(PropertyName = "Heal Bonus self (bandages)")]
            public int BonusBandage = 5;
            [JsonProperty(PropertyName = "Can heal others (bandage)")]
            public bool CanHealOthersBandage = true;
            [JsonProperty(PropertyName = "Can heal self (syringe)")]
            public bool CanHealSyringe= true;
            [JsonProperty(PropertyName = "Heal Bonus self (syringe)")]
            public int BonusSyringe = 10;
            [JsonProperty(PropertyName = "Can heal others (syringe)")]
            public bool CanHealOthersSyringe = true;
            [JsonProperty(PropertyName = "Can consume largemedkit")]
            public bool CanConsumeLmedkit = true;
            [JsonProperty(PropertyName = "Can consume antiradpill")]
            public bool CanConsumeRadpills = true;
        }
        class CESettings {
            [JsonProperty(PropertyName = "Buff on Human Meat")]
            public bool BuffHumMeat = true;
            [JsonProperty(PropertyName = "Buff Comfort duration (seconds)")]
            public int BuffDuration = 60;
            [JsonProperty(PropertyName = "Buff Comfort (0-100)")]
            public float BuffComfort = 50f;
            [JsonProperty(PropertyName = "Extra nutrition (incl heal)")]
            public int BuffHunger = 20;
            [JsonProperty(PropertyName = "Extra hydration")]
            public int BuffThirst = 30;
            [JsonProperty(PropertyName = "Radiation penalty")]
            public int BuffRadiation = 10;
            [JsonProperty(PropertyName = "Food items (shortname , true/false)")]
            public Dictionary<string , bool> FoodItems = new Dictionary<string , bool> {
            }
            ;
        }
        class CGSettings {
            [JsonProperty(PropertyName = "Wood Gather rate")]
            public float GWood = 1.0f;
            [JsonProperty(PropertyName = "Stone Gather rate")]
            public float GStone = 1.0f;
            [JsonProperty(PropertyName = "Sulfur Gather rate")]
            public float GSulfur = 1.0f;
            [JsonProperty(PropertyName = "Metal Gather rate")]
            public float GMetal = 1.0f;
            [JsonProperty(PropertyName = "HQM Gather rate")]
            public float GHQM = 1.0f;
        }
        class CDSettings {
            [JsonProperty(PropertyName = "Cannibal vs Cannibal Scale Boost")]
            public bool CanScaleBoost = true;
            [JsonProperty(PropertyName = "Melee Weapons (shortname , damagescale)")]
            public Dictionary<string , float> MeleeWeapons = new Dictionary<string , float> {
            }
            ;
            [JsonProperty(PropertyName = "Ranged Weapons (shortname , damagescale)")]
            public Dictionary<string , float> RangedWeapons = new Dictionary<string , float> {
            }
            ;
        }
        private bool LoadConfigVariables() {
            try {
                configData = Config.ReadObject<ConfigData>();
            }
            catch {
                return false;
            }
            SaveConf();
            return true;
        }
        protected override void LoadDefaultConfig() {
            Puts("Fresh install detected Creating a new config file.");
            configData = new ConfigData();
            SaveConf();
        }
        void SaveConf() => Config.WriteObject(configData , true);
#endregion
#region Datafile
        private DynamicConfigFile data;
        DataFile dataFile;
        private CannibalLifeTimeDataFile cannibalLifeTimeDataFile;
        private class CannibalLifeTimeDataFile {
            public Dictionary<string , CannibalLifeTimeData> CannibalLifeTime {
                get;
                set;
            }
            = new Dictionary<string , CannibalLifeTimeData>();
        }
        private class CannibalLifeTimeData {
            [JsonProperty(PropertyName = "Name")]
            public string PlayerName {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Total Time as Cannibal")]
            public double CannibalLifeTime {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Total Human Meat Consumed")]
            public int HumanMeatConsumed {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Total Humans Killed")]
            public int HumansKilled {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Total Cannibals Killed")]
            public int CannibalsKilled {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Total Npc Killed")]
            public int NpcKilled {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Total Animals Killed")]
            public int AnimalsKilled {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Total Wood Collected")]
            public int WoodCollected = 0;
            [JsonProperty(PropertyName = "Total Stone Collected")]
            public int StoneCollected = 0;
            [JsonProperty(PropertyName = "Total Sulfur Ore Collected")]
            public int SulfurCollected = 0;
            [JsonProperty(PropertyName = "Total Metal Ore Collected")]
            public int MetalCollected = 0;
            [JsonProperty(PropertyName = "Total Hqm Ore Collected")]
            public int HQMCollected = 0;
        }
        private void LoadCannibalLifeTimeData() {
            cannibalLifeTimeDataFile = Interface.Oxide.DataFileSystem.ReadObject<CannibalLifeTimeDataFile>("Cannibal/CannibalsLife") ?? new CannibalLifeTimeDataFile();
        }
        private void SaveCannibalLifeTimeData() {
            if (cannibalLifeTimeDataFile == null) {
                cannibalLifeTimeDataFile = new CannibalLifeTimeDataFile();
            }
            Interface.Oxide.DataFileSystem.WriteObject("Cannibal/CannibalsLife" , cannibalLifeTimeDataFile);
        }
        private void SaveData() {
            if (dataFile == null) return;
            Interface.Oxide.DataFileSystem.WriteObject("Cannibal/Cannibals" , dataFile);
        }
        private void LoadData() {
            dataFile = Interface.Oxide.DataFileSystem.ReadObject<DataFile>("Cannibal/Cannibals");
            if (dataFile == null) {
                dataFile = new DataFile();
                SaveData();
            }
        }
        private class DataFile {
            public Dictionary<string , PlayerData> Players = new Dictionary<string , PlayerData>();
        }
        private class PlayerData {
            [JsonProperty(PropertyName = "Name")]
            public string DisplayName = string.Empty;
            [JsonProperty(PropertyName = "Current Time as Cannibal")]
            public double TotalTimeAsCannibal = 0.0;
            [JsonProperty(PropertyName = "Current Human Meat Consumed")]
            public int HumanMeatConsumed = 0;
            [JsonProperty(PropertyName = "Current Humans Killed")]
            public int HumansKilled = 0;
            [JsonProperty(PropertyName = "Current Cannibals Killed")]
            public int CannibalsKilled = 0;
            [JsonProperty(PropertyName = "Current Npc Killed")]
            public int NpcKilled = 0;
            [JsonProperty(PropertyName = "Current Animals Killed")]
            public int AnimalsKilled = 0;
            [JsonProperty(PropertyName = "Wood Collected")]
            public int WoodCollected = 0;
            [JsonProperty(PropertyName = "Stone Collected")]
            public int StoneCollected = 0;
            [JsonProperty(PropertyName = "Sulfur Ore Collected")]
            public int SulfurCollected = 0;
            [JsonProperty(PropertyName = "Metal Ore Collected")]
            public int MetalCollected = 0;
            [JsonProperty(PropertyName = "Hqm Ore Collected")]
            public int HQMCollected = 0;
        }
        private void AddPlayerData(IPlayer player) {
            if (dataFile == null) {
                LoadData();
            }
            string playerId = player.Id;
            if (!dataFile.Players.ContainsKey(playerId)) {
                dataFile.Players.Add(playerId , new PlayerData {
                    DisplayName = player.Name
                }
                );
                SaveData();
                StartCannibalTimer(player);
                if (cannibalLifeTimeDataFile == null) {
                    LoadCannibalLifeTimeData();
                }
            }
        }
        private void RemovePlayer(IPlayer player) {
            if (dataFile == null) {
                LoadData();
            }
            if (cannibalLifeTimeDataFile == null) {
                LoadCannibalLifeTimeData();
            }
            string playerId = player.Id;
            if (dataFile.Players.ContainsKey(playerId)) {
                double cannibalLifeTime = dataFile.Players[playerId].TotalTimeAsCannibal;
                string playerName = player.Name;
                int humanMeatConsumed = dataFile.Players[playerId].HumanMeatConsumed;
                int humansKilled = dataFile.Players[playerId].HumansKilled;
                int cannibalsKilled = dataFile.Players[playerId].CannibalsKilled;
                int animalsKilled = dataFile.Players[playerId].AnimalsKilled;
                int npcKilled = dataFile.Players[playerId].NpcKilled;
                int woodCollected = dataFile.Players[playerId].WoodCollected;
                int stoneCollected = dataFile.Players[playerId].StoneCollected;
                int sulfurCollected = dataFile.Players[playerId].SulfurCollected;
                int metalCollected = dataFile.Players[playerId].MetalCollected;
                int hqmCollected = dataFile.Players[playerId].HQMCollected;
                if (cannibalLifeTimeDataFile.CannibalLifeTime.ContainsKey(playerId)) {
                    cannibalLifeTimeDataFile.CannibalLifeTime[playerId].CannibalLifeTime += cannibalLifeTime;
                    cannibalLifeTimeDataFile.CannibalLifeTime[playerId].HumanMeatConsumed += humanMeatConsumed;
                    cannibalLifeTimeDataFile.CannibalLifeTime[playerId].HumansKilled += humansKilled;
                    cannibalLifeTimeDataFile.CannibalLifeTime[playerId].CannibalsKilled += cannibalsKilled;
                    cannibalLifeTimeDataFile.CannibalLifeTime[playerId].AnimalsKilled += animalsKilled;
                    cannibalLifeTimeDataFile.CannibalLifeTime[playerId].NpcKilled += npcKilled;
                    cannibalLifeTimeDataFile.CannibalLifeTime[playerId].WoodCollected += woodCollected;
                    cannibalLifeTimeDataFile.CannibalLifeTime[playerId].StoneCollected += stoneCollected;
                    cannibalLifeTimeDataFile.CannibalLifeTime[playerId].SulfurCollected += sulfurCollected;
                    cannibalLifeTimeDataFile.CannibalLifeTime[playerId].MetalCollected += metalCollected;
                    cannibalLifeTimeDataFile.CannibalLifeTime[playerId].HQMCollected += hqmCollected;
                }
                else {
                    CannibalLifeTimeData cannibalLifeTimeData = new CannibalLifeTimeData {
                        PlayerName = playerName , CannibalLifeTime = cannibalLifeTime, HumanMeatConsumed = humanMeatConsumed, HumansKilled = humansKilled, CannibalsKilled = cannibalsKilled, AnimalsKilled = animalsKilled, NpcKilled = npcKilled, WoodCollected = woodCollected , StoneCollected = stoneCollected , SulfurCollected = sulfurCollected , MetalCollected = metalCollected , HQMCollected = hqmCollected
                    }
                    ;
                    cannibalLifeTimeDataFile.CannibalLifeTime.Add(playerId , cannibalLifeTimeData);
                }
                dataFile.Players.Remove(playerId);
                SaveData();
                SaveCannibalLifeTimeData();
                Puts($"{playerName} has been removed from the list of cannibals.");
            }
            else {
                //Puts($"{player.Name} was not found in the list of cannibals.");
            }
        }
#endregion
#region LanguageAPI en/fr
        protected override void LoadDefaultMessages() {
            lang.RegisterMessages(new Dictionary<string, string> {
                ["N/a"]
                = "N/a" , ["All"] = "All" , ["SKFTurned"] = "Turned into a Cannibal" , ["TotalCannibals"] = "There are a total of {0} cannibals" , ["TotalCannibalsOnline"] = "There are a {0}/{1} cannibals online" , ["Permission"] = "Permission" , ["Admin"] = "Admin" , ["InvalidInput"] = "Please enter a valid command!" , ["NoPermission"] = "You dont have permission for this command!" , ["AteHumanMeat"] = "You ate human meat and turned into a cannibal!" , ["BuffEnd"] = "Your buff ended eat more meat to have one again." , ["GetCannibalTime"] = "You have been Cannibal for {0} days, {1} hours, {2} minutes, and {3} seconds.", ["StartCannibalCmd"] = "You became a cannibal by choice.", ["NotCannibalCmd"] = "You are not a Cannibal" , ["AllreadyCannibalCmd"] = "You are allready a Cannibal" , ["PermanentCannibalCmd"] = "You are a Cannibal permanantly" , ["EndCannibalCmd"] = "You have been Cannibal long enough and returned to normal life." , ["EndCannibalCmdNotification"] = "{player} Is no longer a cannibal after {0} days, {1} hrs, {2} minutes, and {3} seconds." , ["FailEndCannibalCmd"] = "You have not been Cannibal long enough to return to normal life.", ["BonusHeal"] = "You recieved {0} additional health!" , ["CannotHealSelfBandage"] = "Cannibals cannot be healed with bandages.", ["CannotHealSelfMedkit"] = "Cannibals cannot use Large Medical Kits." , ["CannotHealSelfPills"] = "Cannibals cannot use Anti radiation Pills." , ["CannotHealSelfSyringe"] = "Cannibals cannot be healed with syringes.", ["ExtraDmg"] = "You dealt {0} extra damage." , ["ExtraDmgPenalty"] = "You dealt {0} less damage." , ["OnConsumeHumanMeat"] = "Meaaaaat...!!!!", ["OnConsumeWater"] = "Cannibals cannot drink water in a normal way.", ["InfoTitle"] = "Cannibal Information" , ["InfoTitleMain"] = "Main Page" , ["InfoTitleStat"] = "Statistics" , ["InfoClose"] = "Exit" , ["InfoMainLeftPanelTitle"] = "Server Information" , ["InfoMainLeftPanel"] = "This panel Is for your servers description on the Cannibal system.\n" + "This can be a very long language file entry.\n" + "\n\nPlace your text here for your players to read" , ["InfoWelcome"] = "Welcome to our server" , ["InfoMain"] = "Main" , ["InfoDamage"] = "Damage" , ["InfoStat"] = "Statistics" , ["InfoStatDescription"] = "Description" , ["InfoStatCurrent"] = "Current" , ["InfoStatTotal"] = "Total" , ["InfoStatTime"] = "Time" , ["InfoStatMeats"] = "Human Meat" , ["InfoStatKillHuman"] = "Humans Killed" , ["InfoStatKillCannibal"] = "Cannibals Killed" , ["InfoStatKillNpc"] = "NPC Killed" , ["InfoStatKillAnimal"] = "Animals Killed" , ["InfoStatWood"] = "Wood Collected" , ["InfoStatStone"] = "Stone Collected" , ["InfoStatSulfur"] = "Sulfur Ore Collected" , ["InfoStatMetal"] = "Metal Ore Collected" , ["InfoStatHQM"] = "HQM Ore Collected" , ["InfoStatSubtext"] = "This panel shows your Cannibal related statistics like how long you have been one.\nAnd future placeholder for more related stuff like kills etc etc.", ["InfoWeaponTitle"] = "Weapon Damage Scaling" , ["InfoWeaponTitleMelee"] = "Melee Weapons" , ["InfoWeaponTitleRanged"] = "Ranged Weapons" , ["InfoCmdInfoTitle"] = "Chat Commands" , ["InfoCmdInfo"] = "This Information UI" , ["InfoCmdStart"] = "Manually start Cannibal mode" , ["InfoCmdEnd"] = "Manually end Cannibal mode" , ["InfoCmdTime"] = "Shows how long you are a Cannibal" , ["InfoCmdTotal"] = "Shows total Cannibals logd" , ["InfoCmdOnline"] = "Shows how many Cannibals are on" , ["InfoGatheringTitle"] = "Gathering" , ["InfoGatheringDescription"] = "Gathering Boost or penalty" , ["InfoRankings"] = "Rankings" , ["InfoRankingsTitle"] = "Top 10 Ranks" , ["Top Eaters"] = "Top Eaters" , ["Top Slayers"] = "Top Slayers" , ["Top Traitors"] = "Top Traitors" , ["Top PVE"] = "Top PVE" , ["Top Butchers"] = "Top Butchers" , ["Wood"] = "Wood" , ["Stones"] = "Stones" , ["Sulfur"] = "Sulfur" , ["Metal"] = "Metal" , ["HQM"] = "HQM" ,
            }
            , this);
            lang.RegisterMessages(new Dictionary<string , string> {
                ["N/a"]
                = "N/D" , ["All"] = "Tous" , ["SKFTurned"] = "Transformé en cannibale", ["TotalCannibals"] = "Il y a un total de {0} cannibales" , ["TotalCannibalsOnline"] = "Il y a {0}/{1} cannibales en ligne" , ["Permission"] = "Permission" , ["Admin"] = "Admin" , ["InvalidInput"] = "Veuillez entrer une commande valide !" , ["NoPermission"] = "Vous n'avez pas la permission d'utiliser cette commande !" , ["AteHumanMeat"] = "Vous avez mangé de la viande humaine et êtes devenu cannibale !" , ["BuffEnd"] = "Votre buff a pris fin.Mangez plus de viande pour en obtenir un nouveau." , ["GetCannibalTime"] = "Vous êtes cannibale depuis {0} jours, {1} heures, {2} minutes et {3} secondes." , ["StartCannibalCmd"] = "Vous êtes devenu cannibale par choix." , ["NotCannibalCmd"] = "Vous n'êtes pas un cannibale." , ["AllreadyCannibalCmd"] = "Vous êtes déjà un cannibale." , ["PermanentCannibalCmd"] = "Vous êtes cannibale de manière permanente." , ["EndCannibalCmd"] = "Vous avez été cannibale assez longtemps et êtes revenu à une vie normale." , ["EndCannibalCmdNotification"] = "{player} n'est plus un cannibale après {0} jours, {1} heures, {2} minutes et {3} secondes." , ["FailEndCannibalCmd"] = "Vous n'avez pas été cannibale assez longtemps pour revenir à une vie normale." , ["BonusHeal"] = "Vous avez reçu {0} points de vie supplémentaires !" , ["CannotHealSelfBandage"] = "Les cannibales ne peuvent pas être soignés avec des bandages." , ["CannotHealSelfMedkit"] = "Les cannibales ne peuvent pas utiliser de grands kits médicaux." , ["CannotHealSelfPills"] = "Les cannibales ne peuvent pas utiliser de pilules contre les radiations." , ["CannotHealSelfSyringe"] = "Les cannibales ne peuvent pas être soignés avec des seringues." , ["ExtraDmg"] = "Vous avez infligé {0} dégâts supplémentaires." , ["ExtraDmgPenalty"] = "Vous avez infligé {0} dégâts de moins." , ["OnConsumeHumanMeat"] = "Viande...!!!!" , ["OnConsumeWater"] = "Les cannibales ne peuvent pas boire de l'eau normalement." , ["InfoTitle"] = "Information Cannibale" , ["InfoTitleMain"] = "Page principale" , ["InfoTitleStat"] = "Statistiques" , ["InfoClose"] = "Fermer" , ["InfoWelcome"] = "Bienvenue sur notre serveur" , ["InfoMain"] = "Principal" , ["InfoMainLeftPanelTitle"] = "Informations sur le serveur" , ["InfoMainLeftPanel"] = "Ce panneau est destiné à la description de votre serveur sur le système Cannibal.\n" + "Ceci peut être une entrée de fichier de langue très longue.\n" + "\n\nPlacez votre texte ici pour que vos joueurs le lisent" , ["InfoDamage"] = "Dommages" , ["InfoStat"] = "Statistiques" , ["InfoStatDescription"] = "Description" , ["InfoStatCurrent"] = "Actuel" , ["InfoStatTotal"] = "Total" , ["InfoStatTime"] = "Temps" , ["InfoStatMeats"] = "Viande humaine" , ["InfoStatKillHuman"] = "Humains tués" , ["InfoStatKillCannibal"] = "Cannibales tués" , ["InfoStatKillNpc"] = "PNJ tués" , ["InfoStatKillAnimal"] = "Animaux tués" , ["InfoStatWood"] = "Bois collecté" , ["InfoStatStone"] = "Pierre collectée" , ["InfoStatSulfur"] = "Minerai de soufre collecté" , ["InfoStatMetal"] = "Minerai de métal collecté" , ["InfoStatHQM"] = "Minerai de HQM collecté" , ["InfoStatSubtext"] = "Ce panneau affiche vos statistiques liées au cannibalisme, telles que la durée pendant laquelle vous avez été cannibale.Et futur espace réservé pour plus de statistiques liées, comme les victoires, etc." , ["InfoWeaponTitle"] = "Échelle de dégâts des armes" , ["InfoWeaponTitleMelee"] = "Armes de mêlée" , ["InfoWeaponTitleRanged"] = "Armes à distance" , ["InfoCmdInfoTitle"] = "Commandes de Chat" , ["InfoCmdInfo"] = "Cette interface d'information" , ["InfoCmdStart"] = "Démarrer manuellement le mode cannibale" , ["InfoCmdEnd"] = "Arrêter manuellement le mode cannibale" , ["InfoCmdTime"] = "Affiche depuis combien de temps vous êtes un cannibale" , ["InfoCmdTotal"] = "Affiche le total des Cannibales enregistrés" , ["InfoCmdOnline"] = "Affiche le nombre de Cannibales en ligne" , ["InfoGatheringTitle"] = "Collecte" , ["InfoGatheringDescription"] = "Bonus ou pénalité de collecte" , ["InfoRankings"] = "Classements" , ["InfoRankingsTitle"] = "Top 10 Classements" , ["Top Eaters"] = "Top Mangeurs" , ["Top Slayers"] = "Top Tueurs" , ["Top Traitors"] = "Top Traîtres" , ["Top PVE"] = "Top JcE" , ["Top Butchers"] = "Top Bouchers" , ["Wood"] = "Bois" , ["Stones"] = "Pierres" , ["Sulfur"] = "Soufre" , ["Metal"] = "Métal" , ["HQM"] = "HQM" ,
            }
            , this , "fr");
        }
#endregion
#region Commands
        [Command("Cannibal")]
        private void CannibalCmd(IPlayer player , string command , string[] args) {
            string prefix = configData.Prefix;
            if (args.Length < 1) {
                if (player.IsServer) {
                    Puts(lang.GetMessage("InvalidInput" , this , null));
                    return;
                }
                SendMessage(player , "InvalidInput");
                return;
            }
            switch (args[0]) {
                case "time" : {
                    if (player.IsServer) {
                        Puts(lang.GetMessage("InvalidInput" , this , null));
                        return;
                    }
                    if (IsCannibal(player)) {
                        double GetTime = GetCannibalTime(player);
                        TimeSpan formattedTime = FormatTime(GetTime);
                        string message = lang.GetMessage("GetCannibalTime" , this , player.Id);
                        message = message.Replace("{0}" , formattedTime.Days.ToString());
                        message = message.Replace("{1}" , formattedTime.Hours.ToString());
                        message = message.Replace("{2}" , formattedTime.Minutes.ToString());
                        message = message.Replace("{3}" , formattedTime.Seconds.ToString());
                        SendMessage(player , message);
                        return;
                    }
                    else {
                        SendMessage(player , "NotCannibalCmd");
                    }
                    break;
                }
                case "start" : {
                    if (player.IsServer) {
                        Puts(lang.GetMessage("InvalidInput" , this , null));
                        return;
                    }
                    if (!IsCannibal(player)) {
                        if (!HasPerm(player , CPermanent_Perm)) {
                            SetupPlayer(player);
                            SendMessage(player , "StartCannibalCmd");
                            SimpleKillFeed?.Call("SendKillfeedmessage" , $"{player.Name} {Translate(player, "SKFTurned")}");
                        }
                        else {
                            SendMessage(player , "NoPermission");
                        }
                    }
                    else {
                        SendMessage(player , "AllreadyCannibalCmd");
                    }
                    break;
                }
                case "end" : {
                    if (player.IsServer) {
                        Puts(lang.GetMessage("InvalidInput" , this , null));
                        return;
                    }
                    if (!HasPerm(player , CPermanent_Perm)) {
                        if (IsCannibal(player)) {
                            if (GetCannibalTime(player) > configData.CannibalS.MinTime || HasPerm(player , Admin_Perm)) {
                                double GetTime = GetCannibalTime(player);
                                TimeSpan formattedTime = FormatTime(GetTime);
                                string message = lang.GetMessage("EndCannibalCmdNotification" , this , player.Id);
                                message = message.Replace("{player}" , player.Name.ToString());
                                message = message.Replace("{0}" , formattedTime.Days.ToString());
                                message = message.Replace("{1}" , formattedTime.Hours.ToString());
                                message = message.Replace("{2}" , formattedTime.Minutes.ToString());
                                message = message.Replace("{3}" , formattedTime.Seconds.ToString());
                                SimpleKillFeed?.Call("SendKillfeedmessage" , message);
                                NextTick(() => {
                                    RemovePlayer(player);
                                    SendMessage(player , "EndCannibalCmd");
                                    // Stop and destroy the timer
                                    StopCannibalTimer(player);
                                    Cannibalhud(player.Object as BasePlayer);
                                }
                                );
                                break;
                            }
                            else {
                                SendMessage(player , "FailEndCannibalCmd");
                            }
                        }
                        if (!IsCannibal(player)) {
                            SendMessage(player , "NotCannibalCmd");
                        }
                    }
                    else {
                        SendMessage(player , "PermanentCannibalCmd");
                    }
                    break;
                }
                case "total" : {
                    int cannibalCount = CountCannibals();
                    if (player.IsServer) {
                        Puts($"Total number of cannibals: {cannibalCount}");
                        // Log the count
                        return;
                    }
                    if (HasPerm(player , Admin_Perm)) {
                        string message = lang.GetMessage("TotalCannibals" , this , player.Id);
                        message = message.Replace("{0}" , $"{cannibalCount}");
                        SendMessage(player , message);
                    }
                    else {
                        SendMessage(player , "NoPermission");
                    }
                    break;
                }
                case "info" : {
                    CannibalinfoPanel(player);
                    break;
                }
                case "online" : {
                    int totalCannibalCount = CountCannibals();
                    int onlineCannibalCount = CountOnlineCannibals();
                    if (player.IsServer) {
                        Puts($"Total number of cannibals online: {onlineCannibalCount}");
                        return;
                    }
                    if (HasPerm(player , Admin_Perm)) {
                        string message = lang.GetMessage("TotalCannibalsOnline" , this , player.Id);
                        message = message.Replace("{0}" , $"{onlineCannibalCount}");
                        message = message.Replace("{1}" , $"{totalCannibalCount}");
                        SendMessage(player , message);
                    }
                    else {
                        SendMessage(player , "NoPermission");
                    }
                    break;
                }
                default : if (player.IsServer) {
                    Puts(lang.GetMessage("InvalidInput" , this , null));
                    return;
                }
                player.Reply(prefix + lang.GetMessage("InvalidInput" , this , player.Id));
                break;
            }
        }
#endregion
#region Hooks
        private void OnDispenserBonus(ResourceDispenser dispenser , BasePlayer player , Item item) {
            if (player == null) return;
            OnDispenserGather(dispenser , player , item);
        }
        private void OnDispenserGather(ResourceDispenser dispenser , BaseEntity entity , Item item) {
            BasePlayer player = entity.ToPlayer();
            if (player == null || !player.IsValid() || !IsCannibal(player)) return;
            var ent = dispenser.GetComponent<BaseEntity>();
            if (ent == null) return;
            string itemShortname = item.info.shortname;
            int itemAmount = item.amount;
            float multiplier = GetMultiplierForItem(itemShortname);
            int modifiedAmount = (int)(itemAmount * multiplier);
            int ExtraAmount = modifiedAmount - itemAmount;
            //Puts($"OnDispenserGather: Dispenser {ent} : Player {player} gathered {itemAmount}x {itemShortname}.\nModified Amount: {modifiedAmount} Logd amount : {ExtraAmount}");
            Item modifiedItem = ItemManager.CreateByItemID(item.info.itemid , modifiedAmount);
            switch (modifiedItem.info.shortname) {
                case "wood" : player.GiveItem(modifiedItem);
                dataFile.Players[player.UserIDString].WoodCollected += ExtraAmount;
                item.UseItem(itemAmount);
                break;
                case "stones" : player.GiveItem(modifiedItem);
                dataFile.Players[player.UserIDString].StoneCollected += ExtraAmount;
                item.UseItem(itemAmount);
                break;
                case "metal.ore" : player.GiveItem(modifiedItem);
                dataFile.Players[player.UserIDString].MetalCollected += ExtraAmount;
                item.UseItem(itemAmount);
                break;
                case "sulfur.ore" : player.GiveItem(modifiedItem);
                dataFile.Players[player.UserIDString].SulfurCollected += ExtraAmount;
                item.UseItem(itemAmount);
                break;
                case "hq.metal.ore" : player.GiveItem(modifiedItem);
                dataFile.Players[player.UserIDString].HQMCollected += ExtraAmount;
                item.UseItem(itemAmount);
                break;
                case "metal.refined" : player.GiveItem(modifiedItem);
                dataFile.Players[player.UserIDString].HQMCollected += ExtraAmount;
                item.UseItem(itemAmount);
                break;
                default : player.GiveItem(modifiedItem);
                break;
            }
        }
        private void OnEntityDeath(BaseAnimalNPC animal , HitInfo info) {
            if (animal == null || info.InitiatorPlayer == null) return;
            var attacker = info.InitiatorPlayer;
            // Check if the attacker is a valid player and a cannibal
            if (info.InitiatorPlayer.userID.IsSteamId() && IsCannibal(attacker)) {
                string attackerId = attacker.UserIDString;
                // Check if the attacker's data is in the dictionary
                if (dataFile.Players.TryGetValue(attackerId , out var playerData)) {
                    playerData.AnimalsKilled += 1;
                }
                else {
                    Puts($"Player data not found for {attackerId} in OnEntityDeath method.");
                    if (!IsCannibal(attacker)) return;
                }
            }
        }
        private void OnEntityDeath(BasePlayer victim , HitInfo info) {
            if (victim == null || info == null || info.InitiatorPlayer == null) return;
            var attacker = info.InitiatorPlayer;
            if (IsZombieHorde(attacker)) return;
            if (IsCannibal(attacker) && !victim.IsNpc && victim.UserIDString.Length == 17 && !IsZombieHorde(victim)) {
                //Puts("Human attacker is cannibal victim should not be npc");
                dataFile.Players[attacker.UserIDString].HumansKilled += 1;
                return;
            }
            if (IsCannibal(attacker) && victim.IsNpc && victim.UserIDString.Length < 17 && IsZombieHorde(victim)) {
                //Puts("Human attacker is cannibal victim is npc");
                dataFile.Players[attacker.UserIDString].NpcKilled += 1;
                return;
            }
            if (IsCannibal(attacker) && IsCannibal(victim) && !IsZombieHorde(victim)) {
                //Puts("Human attacker is cannibal victim is cannibal");
                dataFile.Players[attacker.UserIDString].CannibalsKilled += 1;
                return;
            }
            else {
                if (!IsCannibal(attacker)) return;
                //Puts("Human attacker is cannibal victim is a unknown npc type but counted as npc");
                dataFile.Players[attacker.UserIDString].NpcKilled += 1;
                return;
            }
            return;
        }
        private object OnPlayerDrink(BasePlayer player , LiquidContainer container) {
            string containerString = container.ToString();
            Match match = Regex.Match(containerString , @"\[(\d+)\]");
            if (match.Success) {
                string networkId = match.Groups[1].Value;
                string containerStringWithoutId = Regex.Replace(containerString , @"\[\d+\]" , "");
                string containerShortPrefabName = containerStringWithoutId.Replace('_' , '.');
                if (IsCannibal(player)) {
                    if (configData.CannibalS.Eat.FoodItems.TryGetValue(containerShortPrefabName , out bool isAllowed)) {
                        if (isAllowed) {
                            //Puts($"OnPlayerDrink isAllowed is true: {isAllowed}");
                            return null;
                        }
                        else {
                            SendMessage(player , "OnConsumeWater");
                            //Puts($"OnPlayerDrink isAllowed is false: {isAllowed}");
                            return true;
                        }
                    }
                }
            }
            return null;
        }
        private object OnEntityTakeDamage(BaseCombatEntity entity , HitInfo info) {
            BasePlayer attacker = info?.InitiatorPlayer;
            BasePlayer victim = entity as BasePlayer;
            if (entity == null || info == null || attacker == null) return null;
            if (attacker != null && entity != null && IsCannibal(attacker)) {
                if (entity is BasePlayer || entity is BaseAnimalNPC) {
                    if (IsCannibal(attacker) && IsCannibal(victim) && !configData.CannibalS.Dmg.CanScaleBoost) return null;
                    string itemShortName = info?.Weapon?.GetItem()?.info?.shortname;
                    if (itemShortName == null) {
                        BaseEntity heldEntity = attacker.GetHeldEntity();
                        if (heldEntity != null) {
                            string shortName = heldEntity.ShortPrefabName;
                            if (shortName.Contains("rocket_launcher") || shortName.Contains("grenade")) {
                                //Puts($"{shortName}"); //prefab
                                float damageMultiplier = 1.1f;
                                //grab from cfg instead of this test value
                                float originalDamage = info.damageTypes.Total();
                                float modifiedDamage = originalDamage * damageMultiplier;
                                info.damageTypes.ScaleAll(damageMultiplier);
                                if (damageMultiplier > 1.0f) {
                                    SendMessage(attacker , $"Original Damage: {originalDamage}, Modified Damage: {modifiedDamage}");
                                    string message = lang.GetMessage("ExtraDmg" , this , attacker.UserIDString);
                                    message = message.Replace("{0}" , Mathf.Round(modifiedDamage - originalDamage).ToString("F1"));
                                    SendMessage(attacker , message);
                                }
                            }
                            return null;
                        }
                        return null;
                    }
                    if (IsMeleeWeapon(itemShortName , info.Weapon.GetEntity())) {
                        float damageMultiplier = configData.CannibalS.Dmg.MeleeWeapons[itemShortName];
                        float originalDamage = info.damageTypes.Total();
                        float modifiedDamage = originalDamage * damageMultiplier;
                        info.damageTypes.ScaleAll(damageMultiplier);
                        Effect.server.Run(configData.FX.MeleeHit , entity.transform.position + new Vector3(0 , 1 , 0));
                        if (damageMultiplier > 1.0f) {
                            string message = lang.GetMessage("ExtraDmg" , this , attacker.UserIDString);
                            message = message.Replace("{0}" , Mathf.Round(modifiedDamage - originalDamage).ToString("F1"));
                            SendMessage(attacker , message);
                        }
                        else if (damageMultiplier < 1.0f) {
                            string message = lang.GetMessage("ExtraDmgPenalty" , this , attacker.UserIDString);
                            message = message.Replace("{0}" , Mathf.Round(originalDamage - (originalDamage * damageMultiplier)).ToString("F1"));
                            SendMessage(attacker , message);
                        }
                    }
                    else if (IsRangedWeapon(itemShortName , info.Weapon.GetEntity())) {
                        Puts(info?.Initiator.ToString());
                        float damageMultiplier = configData.CannibalS.Dmg.RangedWeapons[itemShortName];
                        float originalDamage = info.damageTypes.Total();
                        float modifiedDamage = originalDamage * damageMultiplier;
                        info.damageTypes.ScaleAll(damageMultiplier);
                        if (damageMultiplier > 1.0f) {
                            string message = lang.GetMessage("ExtraDmg" , this , attacker.UserIDString);
                            message = message.Replace("{0}" , Mathf.Round(modifiedDamage - originalDamage).ToString("F1"));
                            SendMessage(attacker , message);
                        }
                        else if (damageMultiplier < 1.0f) {
                            string message = lang.GetMessage("ExtraDmgPenalty" , this , attacker.UserIDString);
                            message = message.Replace("{0}" , Mathf.Round(originalDamage - (originalDamage * damageMultiplier)).ToString("F1"));
                            SendMessage(attacker , message);
                        }
                    }
                }
                return null;
            }
            return null;
        }
        private object OnHealingItemUse(MedicalTool tool , BasePlayer player) {
            if (!player.userID.IsSteamId()) return null;
            IPlayer iPlayer = covalence.Players.FindPlayerById(player.UserIDString);
            if (!IsCannibal(iPlayer)) return null;
            BasePlayer toolOwner = tool.GetOwnerPlayer();
            if (toolOwner != null) {
                IPlayer toolOwnerIPlayer = covalence.Players.FindPlayerById(toolOwner.UserIDString);
                int itemId = tool.GetItem().info.itemid;
                // Get the item ID from the item
                switch (itemId) {
                    case 1079279582 :  // syringe.medical
                    if (toolOwner == player && configData.CannibalS.Heal.CanHealSyringe) {
                        int BonusSyringe = (configData.CannibalS.Heal.BonusSyringe);
                        if (BonusSyringe != 0) player.Heal(BonusSyringe);
                        if(player._health < player._maxHealth) {
                            string message = lang.GetMessage("BonusHeal" , this , iPlayer.Id);
                            message = message.Replace("{0}" , BonusSyringe.ToString());
                            SendMessage(iPlayer , message);
                        }
                        return null;
                    }
                    else if (toolOwner != player && configData.CannibalS.Heal.CanHealOthersSyringe) return null;
                    else {
                        SendMessage(iPlayer , "CannotHealSelfSyringe");
                        //Puts($"{iPlayer.Name} is using a syringe but not allowed to heal himself and/or others with syringes.");
                        return true;
                    }
                    break;
                    case -2072273936 :  // bandage
                    if (toolOwner == player && configData.CannibalS.Heal.CanHealBandage) {
                        int BonusBandage = (configData.CannibalS.Heal.BonusBandage);
                        if (BonusBandage != 0) player.Heal(BonusBandage);
                        if (player._health < player._maxHealth) {
                            string message = lang.GetMessage("BonusHeal" , this , iPlayer.Id);
                            message = message.Replace("{0}" , BonusBandage.ToString());
                            SendMessage(iPlayer , message);
                        }
                        return null;
                    }
                    else if (toolOwner != player && configData.CannibalS.Heal.CanHealOthersBandage) return null;
                    else {
                        SendMessage(iPlayer , "CannotHealSelfBandage");
                        //Puts($"{iPlayer.Name} is using a bandage but not allowed to heal himself and/or others with bandages.");
                        return true;
                    }
                    break;
                    default : Puts($"{iPlayer.Name} is using an unknown medical tool with item ID {itemId}.");
                    break;
                }
            }
            return null;
        }
        // Define a dictionary to keep track of the last time a player consumed raw human meat
        Dictionary<string , float> lastConsumedTimes = new Dictionary<string , float>();
        private object OnItemAction(Item item , string action , BasePlayer player) {
            if (item == null || item.GetRootContainer() == null) return null;
            //Puts($"Action was {action} with item {item.ToString()}");
            var itemcontainer = item.GetRootContainer();
            if (action == "drop") return null;
            IPlayer iPlayer = covalence.Players.FindPlayerById(player.UserIDString);
            float oldHealth = player.health;
            // Get the player's old health
            string foodShortName = item.info.shortname;
            // Get the shortname of the food item
            string playerId = iPlayer.Id;
            if (IsCannibal(iPlayer) && action == "consumecontents") {
                //Puts($"Consumable was : {item} id : {item.info.itemid} inside consumecontents");
                switch (item.info.shortname) {
                    case "waterjug" :  // waterjug
                    if (configData.CannibalS.Eat.FoodItems.TryGetValue(foodShortName , out bool isAllowed)) {
                        if (isAllowed) {
                            return null;
                        }
                        else {
                            SendMessage(iPlayer , $"OnConsumeWater");
                            return true;
                        }
                    }
                    break;
                    default : {
  
// ... [Code preview truncated due to length. Full source in attached file] ...

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху