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

FREE RandomRaids : 1.9.4 1.9.4

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System.Collections.Generic;
using System.Collections;
using Oxide.Core.Configuration;
using Newtonsoft.Json;
using Oxide.Core.Plugins;
using UnityEngine;
using System.Linq;
using Oxide.Core;
using System;
using Oxide.Game.Rust.Cui;
using UnityEngine.SceneManagement;
using System.Text.RegularExpressions;
using Color = UnityEngine.Color;
using UnityEngine.AI;
using Facepunch;
using VLB;
using System.Globalization;
using ProtoBuf;
using Newtonsoft.Json.Linq;
using System.IO;
using UnityEngine.Networking;
namespace Oxide.Plugins {
    [Info("RandomRaids", "Razor", "1.9.4")]
    [Description("Npc's that randomly raid bases")]
    public class RandomRaids : RustPlugin {
#region Loading
        public static bool debug = false;
        public const string BlockName = "RandomRaidsTimer";
        private Coroutine QueuedRoutine;
        private Coroutine QueuedRoutinePlayer;
        private Dictionary<string, string> itemNameToConfig = new Dictionary<string, string>();
        private Dictionary<ulong, string> entitySkinToConfig = new Dictionary<ulong, string>();
        private List<string> itemLootSpawn = new List<string>();
        private static readonly string _directory = Path.Combine(Interface.Oxide.LogDirectory, "RandomRaids");
        private static Dictionary<ulong, List<ulong>> supplyDrops = new Dictionary<ulong, List<ulong>>();
        private static string respondok = "assets/prefabs/npc/scientist/sound/respondok.prefab";
        private static string chatter = "assets/prefabs/npc/scientist/sound/chatter.prefab";
        private static string responddeath = "assets/prefabs/npc/scientist/sound/responddeath.prefab";
        private static string takecover = "assets/prefabs/npc/scientist/sound/takecover.prefab";
        private static string agro = "assets/prefabs/npc/scientist/sound/aggro.prefab";
        private static string reload = "assets/prefabs/npc/scientist/sound/reload.prefab";
        private List<string> ItemConfig = new List<string>();
        private const string adminPerm = "randomraids.admin";
        private const string usePerm = "randomraids.use";
        PlayerEntity pcdData;
        private DynamicConfigFile PCDDATA;
        RaidData raidData;
        private DynamicConfigFile RAIDDATA;
        LogData logData;
        private DynamicConfigFile LOGDATA;
        LogDataRB logDataRB;
        private DynamicConfigFile LOGDATARB;
        [PluginReference]
        private Plugin Kits, TruePVE, RaidableBases, CustomLoot, BotReSpawn, AlphaLoot, ServerRewards, Economics;
        public static RandomRaids _;
        private Dictionary<Vector3, DateTime> raidLocations = new Dictionary<Vector3, DateTime>();
        public static double GrabCurrentTime() => DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
        public static List<MLRS> mlrs = new List<MLRS>();
        static int obstructionMask = LayerMask.GetMask(new[] {
            "World", "Terrain"
        }
        );
        private static int groundLayer;
        private static int terrainLayer;
        private static int BuildingLayer;
        private static Vector3 Vector3Down;
        public class eventList {
            public string type;
            public Vector3 location;
            public DateTime lastraidedTime;
            public DateTime lastraidedTimeNpcKills;
        }
        private object CanModifyCustomNPC(BaseEntity entity) {
            if (entity.GetType().ToString() == "RandomRaider") return false;
            return null;
        }
        private void Init() {
            _ = this;
            permission.RegisterPermission(adminPerm, this);
            permission.RegisterPermission(usePerm, this);
            PCDDATA = Interface.Oxide.DataFileSystem.GetFile(Name + "/PlayersTC");
            RAIDDATA = Interface.Oxide.DataFileSystem.GetFile(Name + "/RaidCooldownData");
            LOGDATA = Interface.Oxide.DataFileSystem.GetFile(Name + "/PlayerLog");
            LOGDATARB = Interface.Oxide.DataFileSystem.GetFile(Name + "/PlayerLogRaidableBases");
            LoadData();
            if (configData.raidSettings.raidTypes.Count <= 0) {
                configData.raidSettings.raidTypes.Add("easy", new raidConfig(12, 1, 10, true, 100, 640, new List<string>(), new List<string>() {
                    "explosive.timed", "explosive.satchel"
                }
                , 1, 1.0, false, new List<string>() {
                    "easy"
                }
                , 200));
                configData.raidSettings.raidTypes.Add("medium", new raidConfig(24, 2, 15, true, 200, 900, new List<string>(), new List<string>() {
                    "explosive.timed", "explosive.satchel"
                }
                , 1, 1.0, true, new List<string>() {
                    "easy"
                }
                , 400));
                configData.raidSettings.raidTypes.Add("hard", new raidConfig(32, 3, 20, true, 400, 1200, new List<string>(), new List<string>() {
                    "explosive.timed", "explosive.satchel"
                }
                , 1, 1.0, true, new List<string>() {
                    "easy"
                }
                , 600));
                configData.raidSettings.raidTypes.Add("expert", new raidConfig(42, 4, 30, true, 400, 1500, new List<string>(), new List<string>() {
                    "explosive.timed", "explosive.satchel"
                }
                , 1, 1.0, true, new List<string>() {
                    "medium"
                }
                , 800));
                configData.raidSettings.raidTypes.Add("nightmare", new raidConfig(60, 5, 30, true, 400, 2100, new List<string>(), new List<string>() {
                    "explosive.timed", "explosive.satchel"
                }
                , 1, 1.0, true, new List<string>() {
                    "medium"
                }
                , 1000));
                SaveConfig();
            }
            foreach (var jconfigs in configData.raidSettings.raidTypes.Values) {
                if (jconfigs.juggernaut == null) {
                    jconfigs.juggernaut = new List<string>() {
                        "easy"
                    }
                    ;
                    SaveConfig();
                }
            }
            if (configData.copterSettings.copterProfile.Count <= 0) {
                configData.copterSettings.copterProfile.Add("easy", new copterConfig(1000, 2));
                SaveConfig();
            }
            if (configData.settingsRB.raidSettings.Count <= 0) {
                configData.settingsRB.raidSettings.Add(0, new RBConfig(3, true, 10, 320, new List<string>() {
                    "easy"
                }
                ));
                configData.settingsRB.raidSettings.Add(1, new RBConfig(3, true, 10, 320, new List<string>() {
                    "easy", "medium"
                }
                ));
                configData.settingsRB.raidSettings.Add(2, new RBConfig(3, true, 10, 320, new List<string>() {
                    "easy", "medium"
                }
                ));
                configData.settingsRB.raidSettings.Add(3, new RBConfig(3, true, 10, 320, new List<string>() {
                    "easy", "medium", "hard"
                }
                ));
                configData.settingsRB.raidSettings.Add(4, new RBConfig(3, true, 10, 320, new List<string>() {
                    "hard", "expert", "nightmare"
                }
                ));
                SaveConfig();
            }
            if (configData.settingsNPCKILLS == null) configData.settingsNPCKILLS = new ConfigData.SettingsNPCKILLS();
            if (configData.settingsNPCKILLS.npcSettings == null) configData.settingsNPCKILLS.npcSettings = new Dictionary<string, NPCConfig>();
            if (configData.settingsNPCKILLS.npcSettings.Count <= 0) {
                configData.settingsNPCKILLS.npcSettings.Add("scientistnpc_heavy", new NPCConfig(30, false, 10, 320, new List<string>() {
                    "medium"
                }
                ));
                configData.settingsNPCKILLS.npcSettings.Add("scientistnpc_oilrig", new NPCConfig(60, false, 10, 320, new List<string>() {
                    "easy"
                }
                ));
                configData.settingsNPCKILLS.npcSettings.Add("scientistnpc_patrol", new NPCConfig(60, false, 10, 320, new List<string>() {
                    "easy"
                }
                ));
                configData.settingsNPCKILLS.npcSettings.Add("scientistnpc_junkpile", new NPCConfig(60, false, 10, 320, new List<string>() {
                    "easy"
                }
                ));
                SaveConfig();
            }
            if (configData.juggernautProfile.Count <= 0) {
                configData.juggernautProfile.Add("easy", new juggernautConfig(new Dictionary<int, int>() {
                    {
                        1, 1
                    }
                }
                , 500f, new List<string>()));
                configData.juggernautProfile.Add("medium", new juggernautConfig(new Dictionary<int, int>() {
                    {
                        1, 2
                    }
                }
                , 700f, new List<string>()));
                SaveConfig();
            }
            if (configData.itemProfile.Count <= 0) {
                configData.itemProfile.Add("easy", new itemConfig(2893480896, "Npc Raid Level 1", 5, new List<string>() {
                    "crate_normal", "crate_normal_2"
                }
                ));
                configData.itemProfile.Add("medium", new itemConfig(2893480635, "Npc Raid Level 2", 5, new List<string>() {
                    "crate_normal", "crate_normal_2", "heli_crate"
                }
                ));
                configData.itemProfile.Add("hard", new itemConfig(2893481009, "Npc Raid Level 3", 5, new List<string>() {
                    "bradley_crate", "crate_elite"
                }
                ));
                configData.itemProfile.Add("expert", new itemConfig(2893481137, "Npc Raid Level 4", 5, new List<string>() {
                    "bradley_crate", "crate_elite"
                }
                ));
                configData.itemProfile.Add("nightmare", new itemConfig(2893482048, "Npc Raid Level 5", 5, new List<string>() {
                    "bradley_crate", "crate_elite"
                }
                ));
                SaveConfig();
            }
            if (configData.settings.totalRaids <= 0) {
                configData.settings.totalRaids = 10;
                SaveConfig();
            }
            if (configData.settingsNPCKILLS.CombineProfile == null) {
                configData.settingsNPCKILLS.CombineNpcList = new List<string>() {
                    "scientistnpc_patrol", "scientistnpc_oilrig", "scientistnpc_heavy", "sentry.scientist.barge", "sentry.scientist.barge.static", "sentry.scientist.static", "heavyscientist_youtooz.deployed", "ch47scientists.entity", "scientist_corpse", "scientistnpc_arena", "scientistnpc_cargo", "scientistnpc_cargo_turret_any", "scientistnpc_cargo_turret_lr300", "scientistnpc_ch47_gunner", "scientistnpc_excavator", "scientistnpc_full_any", "scientistnpc_full_lr300", "scientistnpc_full_mp5", "scientistnpc_full_pistol", "scientistnpc_full_shotgun", "scientistnpc_junkpile", "sientistnpc_peacekeeper", "scientistnpc_roam", "scientistnpc_roam_nvg_variant", "scientistnpc_roamtethered", "npc_tunneldweller", "npc_tunneldwellerspawned", "npc_underwaterdweller", "scarecrow"
                }
                ;
                configData.settingsNPCKILLS.CombineProfile = new NPCConfig(70, false, 10, 320, new List<string>() {
                    "easy"
                }
                );
                SaveConfig();
            }
            if (configData.settings.WebHookUrl == null) {
                configData.settings.WebHookUrl = "";
                configData.settings.AvatarURL = "http://images.myvector.xyz/discordimage.png";
                SaveConfig();
            }
            if (configData.itemProfile != null && configData.itemProfile.Count > 0) {
                foreach (var itemName in configData.itemProfile) {
                    if (configData.raidSettings.raidTypes.ContainsKey(itemName.Key) && !entitySkinToConfig.ContainsKey(itemName.Value.itemSkin)) entitySkinToConfig.Add(itemName.Value.itemSkin, itemName.Key);
                    if (configData.raidSettings.raidTypes.ContainsKey(itemName.Key) && !itemNameToConfig.ContainsKey(itemName.Value.itemName)) itemNameToConfig.Add(itemName.Value.itemName, itemName.Key);
                    if (itemName.Value.SpawnEnabled && configData.raidSettings.raidTypes.ContainsKey(itemName.Key)) itemLootSpawn.Add(itemName.Key);
                }
            }
        }
        private void Unload() {
            stopSearch();
            StopAllRaids();
            foreach (BasePlayer current in BasePlayer.activePlayerList) {
                CuiHelper.DestroyUi(current, "RtimerS" + BlockName);
                CuiHelper.DestroyUi(current, "RsurrenderS" + BlockName);
                current.SendConsoleCommand("gametip.hidegametip");
            }
            _ = null;
        }
        private void StopAllRaids() {
            List<EventRandomManager> list = Facepunch.Pool.Get<List<EventRandomManager>>();
            list.AddRange(EventRandomManager._AllRaids);
            foreach (var eventRunning in list) {
                eventRunning.Destroy();
            }
            EventRandomManager._AllRaids.Clear();
            Facepunch.Pool.FreeUnmanaged<EventRandomManager>(ref list);
        }
        private void OnServerInitialized() {
            groundLayer = LayerMask.GetMask("Construction", "Terrain", "World");
            terrainLayer = LayerMask.GetMask("Terrain", "World", "Water");
            BuildingLayer = LayerMask.GetMask("Construction");
            Vector3Down = new Vector3(0f, -1f, 0f);
            pcdData.tcData.Clear();
            foreach (BuildingPrivlidge find in BaseNetworkable.serverEntities.OfType<BuildingPrivlidge>()) {
                if (Convert.ToBoolean(RaidableBases?.CallHook("EventTerritory", find.transform.position))) continue;
                foreach (var playerNameID in find.authorizedPlayers) {
                    if (!pcdData.tcData.ContainsKey(playerNameID.userid)) pcdData.tcData.Add(playerNameID.userid, new List<ulong>() {
                        find.net.ID.Value
                    }
                    );
                    else if (!pcdData.tcData[playerNameID.userid].Contains(find.net.ID.Value)) pcdData.tcData[playerNameID.userid].Add(find.net.ID.Value);
                }
            }
            SaveData();
            if (configData.settings.randomTimer) {
                timer.Every(configData.settings.cooldownSeconds, () => startRestartSearch());
            }
            foreach (var items in configData.itemProfile.Values) ItemConfig.Add(items.itemName);
            if (!configData.settings.lockAirdrop) {
                Unsubscribe(nameof(CanLootEntity));
                Unsubscribe(nameof(OnEntityKill));
            }
        }
#endregion
#region Data
        private void LoadData() {
            try {
                pcdData = Interface.GetMod().DataFileSystem.ReadObject<PlayerEntity>(Name + "/PlayersTC");
            }
            catch {
                PrintWarning("Couldn't load Player data, creating new Playerfile");
                pcdData = new PlayerEntity();
            }
            try {
                raidData = Interface.GetMod().DataFileSystem.ReadObject<RaidData>(Name + "/RaidCooldownData");
            }
            catch {
                PrintWarning("Couldn't load Raid data, creating new RaidCooldownData file");
                raidData = new RaidData();
            }
            try {
                logData = Interface.GetMod().DataFileSystem.ReadObject<LogData>(Name + "/PlayerLog");
            }
            catch {
                PrintWarning("Couldn't load log data, creating new log file");
                logData = new LogData();
            }
            try {
                logDataRB = Interface.GetMod().DataFileSystem.ReadObject<LogDataRB>(Name + "/PlayerLogRaidableBases");
            }
            catch {
                PrintWarning("Couldn't load log data, creating new log file RB");
                logDataRB = new LogDataRB();
            }
        }
        public class PlayerEntity {
            public Dictionary<ulong, List<ulong>> tcData = new Dictionary<ulong, List<ulong>>();
        }
        public class RaidData {
            public Dictionary<ulong, rData> data = new Dictionary<ulong, rData>();
        }
        public class LogData {
            public Dictionary<ulong, lData> pLogs = new Dictionary<ulong, lData>();
        }
        public class lData {
            public Dictionary<string, int> NPCKILLS = new Dictionary<string, int>();
            public int _totalNpcKills;
        }
        public class LogDataRB {
            public Dictionary<ulong, lDataRB> pLogsRB = new Dictionary<ulong, lDataRB>();
        }
        public class lDataRB {
            public Dictionary<int, int> mode = new Dictionary<int, int>();
        }
        public class rData {
            public DateTime LastRaided;
            public DateTime LastRaidedNpcKills;
            public DateTime LastRaidedRB;
            public Dictionary<Vector3, DateTime> raidLocations = new Dictionary<Vector3, DateTime>();
            public List<string> info = new List<string>();
            public List<ulong> info1 = new List<ulong>();
            public List<ulong> info2 = new List<ulong>();
        }
        public void SaveData() {
            PCDDATA.WriteObject(pcdData);
        }
        public void SaveRaidData() {
            RAIDDATA.WriteObject(raidData);
        }
        public void SaveLogData() {
            LOGDATA.WriteObject(logData);
        }
        public void SaveRBLogData() {
            LOGDATARB.WriteObject(logDataRB);
        }
#endregion
#region Config
        private ConfigData configData;
        class ConfigData {
            [JsonProperty(PropertyName = "Random settings")]
            public Settings settings {
                get;
                set;
            }
            [JsonProperty(PropertyName = "All Random Raid Types")]
            public RaidSettings raidSettings {
                get;
                set;
            }
            [JsonProperty(PropertyName = "AttackCopter profiles")]
            public CopterSettings copterSettings {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Block Random raid in colider")]
            public BlockedColliders blockedColliders {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Raidable Base plugin settings")]
            public SettingsRB settingsRB {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Trigger by npc kills")]
            public SettingsNPCKILLS settingsNPCKILLS {
                get;
                set;
            }
            [JsonProperty(PropertyName = "Juggernaut profiles")]
            public Dictionary<string, juggernautConfig> juggernautProfile {
                get;
                set;
            }
            = new Dictionary<string, juggernautConfig>();
            [JsonProperty(PropertyName = "Item profiles")]
            public Dictionary<string, itemConfig> itemProfile {
                get;
                set;
            }
            = new Dictionary<string, itemConfig>();
            public class Settings {
                [JsonProperty(PropertyName = "Total raids allowed at once")]
                public int totalRaids {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "A player on the tc must be online")]
                public bool mustBeOnlinePlayer {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Use random raid timer")]
                public bool randomTimer {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Random raid timer time")]
                public int cooldownSeconds {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Chance of random raid at time (1-100)")]
                public int chanceTime {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Authorized players Cooldown minutes before random raided again by chance")]
                public int raidAgainCooldown {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "The maximum amount of time a rocket will fly before exploding")]
                public float RocketExplodeTime {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Npc spawn damage delay")]
                public float damageDelay {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Display global chat message on raid start")]
                public bool useChat {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Display global map marker on raid start")]
                public bool useMarker {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Display Gui to base owners")]
                public bool useGUI {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "GUI AnchorMin")]
                public string AnchorMin = "0.807 0.96";
                [JsonProperty(PropertyName = "GUI AnchorMax")]
                public string AnchorMax = "0.996 0.99";
                [JsonProperty(PropertyName = "GUI2 AnchorMin")]
                public string AnchorMin2 = "0.807 0.92";
                [JsonProperty(PropertyName = "GUI2 AnchorMax")]
                public string AnchorMax2 = "0.996 0.95";
                [JsonProperty(PropertyName = "Use GameTip announcement to player")]
                public bool gameTip {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "GameTip display time in seconds")]
                public float gameTipTime = 2f;
                [JsonProperty(PropertyName = "Disable radio chatter")]
                public bool disableChatter {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Wait until all NPC are dead before sending in next wave")]
                public bool pauseWave {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Player must have randomraids.use inorder to get raided")]
                public bool musthavePerm {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Use world text to show base location")]
                public bool worldMarker {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "World text display time")]
                public float worldMarkerTime {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Lock airdrop to event players")]
                public bool lockAirdrop {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Use discord Webhook")]
                public bool DiscordWebHook {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Discord Webhook URL")]
                public string WebHookUrl {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Discord Avatar URL")]
                public string AvatarURL {
                    get;
                    set;
                }
            }
            public class SettingsRB {
                [JsonProperty(PropertyName = "Raid player on Raidable Base Completed")]
                public bool raidableBaseComplete {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Warn player in chat of upcoming revenge on them")]
                public bool warnPlayer {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Raidable Base Settings")]
                public Dictionary<int, RBConfig> raidSettings {
                    get;
                    set;
                }
            }
            public class RaidSettings {
                [JsonProperty(PropertyName = "Random raid types")]
                public Dictionary<string, raidConfig> raidTypes {
                    get;
                    set;
                }
            }
            public class CopterSettings {
                [JsonProperty(PropertyName = "Profile Names")]
                public Dictionary<string, copterConfig> copterProfile {
                    get;
                    set;
                }
            }
            public class BlockedColliders {
                public List<string> Blocked {
                    get;
                    set;
                }
            }
            public class SettingsNPCKILLS {
                [JsonProperty(PropertyName = "Enable log kills and random raid on kills")]
                public bool enableKills {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Reset npc kills on player raided.")]
                public bool resetKills {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Warn player in chat of upcoming revenge on them")]
                public bool warnPlayer {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Use total players on tc check on type")]
                public bool enforceAuth {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Use min Base size check on type")]
                public bool BlockCheck {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Enable combine npc kills list")]
                public bool enableKillsCombine {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Combine npc kills list")]
                public List<string> CombineNpcList {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Combine Profile to use")]
                public NPCConfig CombineProfile {
                    get;
                    set;
                }
                [JsonProperty(PropertyName = "Npc kills settings")]
                public Dictionary<string, NPCConfig> npcSettings {
                    get;
                    set;
                }
            }
            public Oxide.Core.VersionNumber Version {
                get;
                set;
            }
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            configData = Config.ReadObject<ConfigData>();
            if (configData.Version < Version) UpdateConfigValues();
            Config.WriteObject(configData, true);
        }
        protected override void LoadDefaultConfig() => configData = GetBaseConfig();
        private ConfigData GetBaseConfig() {
            return new ConfigData {
                settings = new ConfigData.Settings {
                    totalRaids = 2, mustBeOnlinePlayer = true, randomTimer = false, cooldownSeconds = 3600, chanceTime = 10, raidAgainCooldown = 1440, RocketExplodeTime = 4.0f, damageDelay = 2f, useChat = true, useMarker = true, disableChatter = false, pauseWave = false, musthavePerm = false, worldMarker = false, worldMarkerTime = 60f, lockAirdrop = false, DiscordWebHook = false, WebHookUrl = "", AvatarURL = "http://images.myvector.xyz/discordimage.png"
                }
                , settingsRB = new ConfigData.SettingsRB {
                    raidSettings = new Dictionary<int, RBConfig>()
                }
                , raidSettings = new ConfigData.RaidSettings {
                    raidTypes = new Dictionary<string, raidConfig>()
                }
                , copterSettings = new ConfigData.CopterSettings {
                    copterProfile = new Dictionary<string, copterConfig>()
                }
                , blockedColliders = new ConfigData.BlockedColliders {
                    Blocked = new List<string>() {
                        "iceberg", "ice_berg", "ice_sheet", "icesheet", "cliff", "cave"
                    }
                }
                , Version = Version
            }
            ;
        }
        protected override void SaveConfig() => Config.WriteObject(configData, true);
        private void UpdateConfigValues() {
            PrintWarning("Version update detected!");
            ConfigData baseConfig = GetBaseConfig();
            if (configData.Version < new VersionNumber(1, 4, 6)) {
                configData = baseConfig;
                PrintWarning("Config update was needed and now completed!");
            }
            configData.Version = Version;
            PrintWarning("Version update completed!");
        }
        public class raidConfig {
            [JsonProperty(PropertyName = "Total auth players on tc needed")]
            public int TotalAuth;
            [JsonProperty(PropertyName = "Total npcs per wave")]
            public int TotalNpcs;
            [JsonProperty(PropertyName = "How many extra waves")]
            public int TotalNpcWaves;
            [JsonProperty(PropertyName = "Seconds untell next wave")]
            public int NextWaveSeconds;
            [JsonProperty(PropertyName = "Npc fires Mlrs at base")]
            public bool FireMlrs;
            [JsonProperty(PropertyName = "Send in Attack Copter support")]
            public bool attackCopter;
            [JsonProperty(PropertyName = "Total event time in seconds")]
            public int RunTimeSeconds;
            [JsonProperty(PropertyName = "Npc drop loot on death")]
            public bool NpcDropLoot;
            [JsonProperty(PropertyName = "Spawn health of the npc")]
            public float Health;
            [JsonProperty(PropertyName = "Total rockets npc can fire")]
            public int rockets;
            [JsonProperty(PropertyName = "Total explosives npc can toss")]
            public int explosives;
            [JsonProperty(PropertyName = "Total AirDrops on event win")]
            public int WinDrop;
            [JsonProperty(PropertyName = "Rocket damage scale")]
            public double DamageScale;
            [JsonProperty(PropertyName = "Player damage scale from npc")]
            public float playerDamage;
            [JsonProperty(PropertyName = "Auto turret damage scale to npc")]
            public float AutoTurretDamage;
            [JsonProperty(PropertyName = "Raiders aimConeScale")]
            public float aimConeScale;
            [JsonProperty(PropertyName = "Throw Explosive item shortnames")]
            public List<string> explosive;
            [JsonProperty(PropertyName = "Spawn Attack Heli profile")]
            public List<string> spawnCopter;
            [JsonProperty(PropertyName = "Spawn kits for the npcs")]
            public List<string> kits;
            [JsonProperty(PropertyName = "All npc receive the same kit")]
            public bool kitsSame;
            [JsonProperty(PropertyName = "Names to give the npcs")]
            public List<string> NpcNames;
            [JsonProperty(PropertyName = "CustomLoot config profile name")]
            public List<string> lootProfile;
            [JsonProperty(PropertyName = "CustomLoot config profile names for AirDrop")]
            public List<string> lootProfileAirDrop;
            [JsonProperty(PropertyName = "AlphaLoot config profile names")]
            public List<string> lootProfileA;
            [JsonProperty(PropertyName = "AlphaLoot config profile names for AirDrop")]
            public List<string> lootProfileAirDropA;
            [JsonProperty(PropertyName = "Juggernaut config")]
            public List<string> juggernaut;
            [JsonProperty(PropertyName = "Surrender Item")]
            public string surrenderItem;
            [JsonProperty(PropertyName = "Surrender Item Name")]
            public string surrenderName;
            [JsonProperty(PropertyName = "Surrender costs")]
            public int surrenderCosts;
            [JsonProperty(PropertyName = "Notify owners of incoming Random Raid Triggered By Timer")]
            public bool notifyOwners;
            [JsonProperty(PropertyName = "Min Base Blocks Size")]
            public int blockMIN;
            public raidConfig(int minblocks, int TotalAuth, int TotalNpcs, bool OnlyAuthedMembers, float Health, int RunTimeSeconds, List<string> kits, List<string> explosive, int waves, double damage, bool attackCopter, List<string> jconfig, int surrenderCosts1) {
                this.blockMIN = minblocks;
                this.TotalAuth = TotalAuth;
                this.TotalNpcs = TotalNpcs;
                this.NpcDropLoot = OnlyAuthedMembers;
                this.Health = Health;
                this.rockets = 20;
                this.explosives = 10;
                this.attackCopter = attackCopter;
                this.kits = kits;
                this.RunTimeSeconds = RunTimeSeconds;
                this.explosive = explosive;
                this.TotalNpcWaves = waves;
                this.NextWaveSeconds = 120;
                this.NpcNames = new List<string>() {
                    "Cobalt Scientist"
                }
                ;
                this.DamageScale = damage;
                this.AutoTurretDamage = 1.0f;
                this.FireMlrs = false;
                this.playerDamage = 1.0f;
                this.aimConeScale = 2f;
                this.spawnCopter = new List<string>() {
                    "easy"
                }
                ;
                this.juggernaut = jconfig;
                this.lootProfile = new List<string>();
                this.lootProfileAirDrop = new List<string>();
                this.lootProfileA = new List<string>();
                this.lootProfileAirDropA = new List<string>();
                this.WinDrop = 1;
                this.surrenderCosts = surrenderCosts1;
                this.kitsSame = false;
                this.surrenderItem = "scrap";
                this.surrenderName = "Scrap";
            }
        }
        public class copterConfig {
            [JsonProperty(PropertyName = "Heli float health")]
            public float startHealth;
            [JsonProperty(PropertyName = "Total crates to drop")]
            public int maxCratesToSpawn;
            [JsonProperty(PropertyName = "Heli strafe cooldown")]
            public float strafeTime;
            [JsonProperty(PropertyName = "Heli can strafe x times")]
            public int totalStrafe;
            public copterConfig(float startHealth1, int maxCratesToSpawn1) {
                this.startHealth = startHealth1;
                this.maxCratesToSpawn = maxCratesToSpawn1;
                this.totalStrafe = 3;
                this.strafeTime = 50;
            }
        }
        public class RBConfig {
            [JsonProperty(PropertyName = "Total amount of mode complete before ever has chance")]
            public int totalRaids;
            [JsonProperty(PropertyName = "Reset kill count after chance happened")]
            public bool resetKillCount;
            [JsonProperty(PropertyName = "Raidable Base Completed Delay Before Raid chance happens")]
            public float raidableBaseCompleteDelay;
            [JsonProperty(PropertyName = "raid chance (1-100)")]
            public int raidChance;
            [JsonProperty(PropertyName = "Cooldown minutes after raid chance happenes")]
            public int cooldownRB;
            [JsonProperty(PropertyName = "Random raid to send them if chance")]
            public List<string> sendRaids;
            public RBConfig(int totalRaids1, bool resetKillCount1, int raidChance1, float raidableBaseCompleteDelay1, List<string> sendRaids1) {
                this.totalRaids = totalRaids1;
                this.resetKillCount = resetKillCount1;
                this.raidableBaseCompleteDelay = raidableBaseCompleteDelay1;
                this.raidChance = raidChance1;
                this.cooldownRB = 1440;
                this.sendRaids = sendRaids1;
            }
        }
        public class NPCConfig {
            [JsonProperty(PropertyName = "Total amount of Npc killed before chance can happen")]
            public int totalRaids;
            [JsonProperty(PropertyName = "Reset kill count after chance happened")]
            public bool resetKillCount;
            [JsonProperty(PropertyName = "Delay before chance happens")]
            public float raidDelay;
            [JsonProperty(PropertyName = "Raid chance (1-100)")]
            public int raidChance;
            [JsonProperty(PropertyName = "Cooldown minutes before chance can happen again")]
            public int chanceCooldown;
            [JsonProperty(PropertyName = "Random raid to send them if chance")]
            public List<string> sendRaids;
            public NPCConfig(int totalRaids1, bool resetKillCount1, int raidChance1, float raidDelay1, List<string> sendRaids1) {
                this.totalRaids = totalRaids1;
                this.resetKillCount = resetKillCount1;
                this.raidDelay = raidDelay1;
                this.chanceCooldown = 1440;
                this.raidChance = raidChance1;
                this.sendRaids = sendRaids1;
            }
        }
        public class juggernautConfig {
            [JsonProperty(PropertyName = "Juggernaut spawns on witch Wave number/Total to spawn")]
            public Dictionary<int, int> juggernautOnWaves;
            [JsonProperty(PropertyName = "Spawn health of the juggernaut")]
            public float Health;
            [JsonProperty(PropertyName = "Player damage scale from the juggernaut")]
            public float playerDamage;
            [JsonProperty(PropertyName = "juggernaut aimConeScale")]
            public float aimConeScale;
            [JsonProperty(PropertyName = "Names to give the juggernaut")]
            public List<string> NpcNames;
            [JsonProperty(PropertyName = "Spawn kits for the juggernaut")]
            public List<string> kits;
            public juggernautConfig(Dictionary<int, int> juggernautOnWaves, float Health, List<string> kits) {
                this.juggernautOnWaves = juggernautOnWaves;
                this.Health = Health;
                this.kits = kits;
                this.NpcNames = new List<string>() {
                    "Juggernaut Raider"
                }
                ;
                this.playerDamage = 1.0f;
                this.aimConeScale = 2f;
            }
        }
        public class itemConfig {
            [JsonProperty(PropertyName = "Raid call item skin")]
            public ulong itemSkin;
            [JsonProperty(PropertyName = "Raid call item name")]
            public string itemName;
            [JsonProperty(PropertyName = "LootContainer Spawn enabled")]
            public bool SpawnEnabled;
            [JsonProperty(PropertyName = "Can Spawn In LootContainer types")]
            public List<string> LootContainers;
            [JsonProperty(PropertyName = "LootContainer Spawn Chance 1-100")]
            public float SpawnChance;
            public itemConfig(ulong itemSkin, string itemName, float SpawnChance, List<string> lootContainers) {
                this.itemSkin = itemSkin;
                this.itemName = itemName;
                this.SpawnEnabled = false;
                this.SpawnChance = SpawnChance;
                this.LootContainers = lootContainers;
            }
        }
#endregion Config
#region EventRandomManager
        public static float ProjectileDistToGravity(float x, float y, float θ, float v) {
            float f1 = θ * ((float)Math.PI / 180f);
            float f2 = (float)(((double)v * (double)v * (double)x * (double)Mathf.Sin(2f * f1) - 2.0 * (double)v * (double)v * (double)y * (double)Mathf.Cos(f1) * (double)Mathf.Cos(f1)) / ((double)x * (double)x));
            if (float.IsNaN(f2) || (double)f2 < 0.00999999977648258) f2 = -Physics.gravity.y;
            return f2;
        }
        public class EventRandomManager : FacepunchBehaviour {
            public static List<EventRandomManager> _AllRaids = new List<EventRandomManager>();
            public static List<RandomRaider> _AllMembers = new List<RandomRaider>();
            public List<juggernautConfig> jconfig = new List<juggernautConfig>();
            public static bool isFireingMlrs;
            public List<BuildingBlock> _AllFoundations = new List<BuildingBlock>();
            public List<ulong> _authedPlayers = new List<ulong>();
            public List<RandomRaider> members;
            public bool isDestroyed = false;
            public Vector3 location;
            public raidConfig config;
            public string waveType;
            public bool newWave;
            public Coroutine QueuedRoutine;
            public BuildingPrivlidge building;
            public BaseCombatEntity tc;
            public float EndEventTime;
            public float nextWaveTime = 0;
            public int totalWaves = 0;
            public float MlrsEventTime;
            public bool active = false;
            public int totalCopters = 3;
            public PatrolHelicopter heli;
            public MapMarkerExplosion marker;
            public DeployableBoomBox boombox;
            public List<Vector3> savedPosition = new List<Vector3>();
            public List<BasePlayer> _onlinePlayers = new List<BasePlayer>();
            public DateTime activeTime = DateTime.Now;
            public int Duration;
            public DateTime time = DateTime.Now;
            public TimeSpan timeOffset;
            public DateTime lastBlock = DateTime.Now;
            public DateTime lastNotification = DateTime.MinValue;
            public DateTime lastUINotification = DateTime.MinValue;
            public int currentWave = 0;
            public bool sendGUI = false;
            public bool showFinle = false;
            public bool curentlySawning = false;
            public bool showInfinity = false;
            public float useDelay = 0.1f;
            public string sameKit = "";
            public string surrenderItem;
            public int surrenderCost;
            public string surrenderName = "";
            public GameObject gobj;
            public static EventRandomManager Create(Vector3 l, raidConfig c, string t, List<ulong> authedPlayers, GameObject gobj, List<BuildingBlock> blocks, float useDelay = 0.1f) {
                GameObject gobjBew = new GameObject();
                EventRandomManager manager = gobjBew.AddComponent<EventRandomManager>();
                manager.members = Facepunch.Pool.Get<List<RandomRaider>>();
                manager.newWave = true;
                manager.config = c;
                manager.waveType = t;
                manager.location = l;
                manager._authedPlayers = authedPlayers;
                manager._AllFoundations = blocks;
                manager.useDelay = useDelay;
                manager.surrenderItem = c.surrenderItem;
                manager.surrenderCost = c.surrenderCosts;
                manager.surrenderName = c.surrenderName;
                _AllRaids.Add(manager);
                if (c != null && c.juggernaut != null && c.juggernaut.Count > 0) {
                    foreach (var jconfigs in c.juggernaut) {
                        if (_.configData.juggernautProfile.ContainsKey(jconfigs)) {
                            manager.jconfig.Add(_.configData.juggernautProfile[jconfigs]);
                        }
                    }
                }
                manager.sendGUI = _.configData.settings.useGUI;
                return manager;
            }
            public void StartEvent() {
                if (config.kitsSame && config.kits != null && config.kits.Count > 0) {
                    sameKit = config.kits.GetRandom();
                }
                _.timer.Once(useDelay, () => {
                    Interface.Oxide.CallHook("OnRandomRaidStart", waveType, location);
                    MlrsEventTime = Time.time + UnityEngine.Random.Range(15f, 30f);
                    EndEventTime = Time.time + config.RunTimeSeconds;
                    nextWaveTime = Time.time + 3800;
                    QueuedRoutine = StartCoroutine(GenerateEventMembers());
                    if (config.attackCopter && config.spawnCopter.Count > 0) {
                        string copterProfile = config.spawnCopter.GetRandom();
                        if (_.configData.copterSettings.copterProfile.ContainsKey(copterProfile)) heli = spawnHeli(this, location, _.configData.copterSettings.copterProfile[copterProfile]);
                    }
                    if (_.configData.settings.useMarker) marker = SpawnRaidMarker(location, EndEventTime);
                    if (_.configData.settings.useChat) _.notifyChat(location);
                    if (config.TotalNpcWaves <= 0) Duration = config.RunTimeSeconds;
                    else if (_.configData.settings.pauseWave) {
                        Duration = 10;
                    }
                    else Duration = config.NextWaveSeconds;
                    nextWaveTime = Time.time + config.NextWaveSeconds;
                }
                );
            }
            private static MapMarkerExplosion SpawnRaidMarker(Vector3 vector, float timeLimit) {
                MapMarkerExplosion explosionMarker = null;
                explosionMarker = GameManager.server.CreateEntity(StringPool.Get(4060989661), vector) as MapMarkerExplosion;
                if (explosionMarker != null) {
                    explosionMarker.enableSaving = false;
                    explosionMarker.Spawn();
                    explosionMarker.SetDuration(timeLimit);
              
// ... [Code preview truncated due to length. Full source in attached file] ...

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