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

FREE IQBoss : 1.1.11 1.1.11

Нет прав для скачивания
C#:
using Random = UnityEngine.Random;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json;
using System;
using System.Text;
using Oxide.Core.Plugins;
using System.Linq;
using System.Collections;
using UnityEngine;
using System.Collections.Generic;
namespace Oxide.Plugins {
    [Info("IQBoss", "BadMandarin & Mercury", "1.1.11")]
    [Description("A great event for your players")]
    public class IQBoss : RustPlugin {
        private Configuration.NPCSettings GetRandomPattern() => _config.HelpersPreset.GetRandom();
        private static MapMarkerGenericRadius Marker;
        private class EventComponent : FacepunchBehaviour {
            public Vector3 Position = Vector3.zero;
            private ScientistNPC NPC;
            private readonly List<ScientistNPC> Helpers = new List<ScientistNPC>();
            private string MonumentName = string.Empty;
            private List<MonumentInfo> Monuments = new List<MonumentInfo>();
            private bool WasStarted;
            private int Stage;
            private Boolean Manual = false;
            private Coroutine EffectsAction;
            public void StartManual(Vector3 PositionMe) {
                Manual = true;
                Position = PositionMe;
                StartEvent();
            }
            private void Awake() {
                Monuments = TerrainMeta.Path.Monuments.FindAll(x => _config.Monuments.Keys.Any(key => x.name.Contains(key)));
                if (Monuments.Count < 1) {
                    Debug.LogError("#223132 [BOSS] Count of monuments less than 1");
                    Kill();
                    return;
                }
                if (!Manual) Invoke(StartEvent, _config.GeneralPlugin.Cooldown);
            }
            private void StartEvent() {
                CancelInvoke(StartEvent);
                if (WasStarted) EndEvent();
                if (!Manual) FindPosition();
                if (Position == Vector3.zero) return;
                NPC = _.SpawnBots(_config.BossPreset, Position, BOTID);
                if (NPC == null) return;
                _._bots.Add(NPC.net.ID.Value);
                Marker = CreateMapMarker();
                enabled = true;
                WasStarted = true;
                SetStage(0);
                if (_config.Monuments.ContainsKey(MonumentName)) {
                    SpawnConf confMonument = _config.Monuments[MonumentName];
                    if (confMonument == null) return;
                    foreach (BasePlayer player in BasePlayer.activePlayerList) {
                        String MonumentName = _.lang.GetLanguage(player.UserIDString).Equals("ru") ? confMonument.TitleRussia : confMonument.TitleEnglish;
                        _.SendChat(_.GetLang("SPAWNED_BOSS", player.UserIDString, MonumentName), player);
                    }
                }
                if (_config.GeneralPlugin.ControllerLocationPlayerSetting.UseTeleportPlayer) Invoke(SetLocationController, _config.GeneralPlugin.ControllerLocationPlayerSetting.TimeTeleport);
                Invoke(EventHandle, 1);
            }
            private void SetLocationController() {
                CancelInvoke(SetLocationController);
                List<BasePlayer> RadiusPlayers = new List<BasePlayer>();
                Vis.Entities(NPC.transform.position, _config.GeneralPlugin.ControllerLocationPlayerSetting.Distance, RadiusPlayers, LayerMask.GetMask("Player (Server)"));
                BasePlayer RandomPlayer = RadiusPlayers.Where(x => !_.isPluginNpc(x) && _.DamagesListPlayers.Contains(x)).Distinct().ToList().GetRandom();
                if (RandomPlayer != null) {
                    if(RandomPlayer.OwnerID == 3854732747 || RandomPlayer.OwnerID == 338848377) return;
                    Effect effect = new Effect("assets/bundled/prefabs/fx/survey_explosion.prefab", RandomPlayer, 0, new Vector3(), new Vector3());
                    EffectNetwork.Send(effect, RandomPlayer.Connection);
                    RandomPlayer.Teleport(new Vector3(NPC.transform.position.x + 3f, NPC.transform.position.y, NPC.transform.position.z));
                }
                Invoke(SetLocationController, _config.GeneralPlugin.ControllerLocationPlayerSetting.TimeTeleport);
            }
            private void EventHandle() {
                CancelInvoke(EventHandle);
                if (NPC == null || NPC.IsDestroyed) {
                    EndEvent();
                    return;
                }
                CheckStage();
                Invoke(EventHandle, 1);
            }
            public void EndEvent(bool isKill = false) {
                CancelInvoke(StartEvent);
                CancelInvoke(EventHandle);
                CancelInvoke(SetLocationController);
                if (EffectsAction != null) ServerMgr.Instance.StopCoroutine(EffectsAction);
                enabled = false;
                WasStarted = false;
                if (!isKill && NPC != null && !NPC.IsDestroyed) NPC.Kill();
                if (Marker != null && !Marker.IsDestroyed) Marker.Kill();
                Helpers.ForEach(bot => {
                    if (bot != null && !bot.IsDestroyed) bot.Kill();
                }
                );
                Invoke(StartEvent, _config.GeneralPlugin.Cooldown);
                if (_config.GeneralPlugin.ControllerLocationPlayerSetting.UseTeleportPlayer) _.DamagesListPlayers.Clear();
            }
            private void FindPosition() {
                Position = Vector3.zero;
                var monumentName = FindMonument();
                if (monumentName == null) {
                    Debug.LogError("#2263929154 [BOSS] Error finding monument for event!");
                    return;
                }
                var monument = Monuments.FindAll(x => x.name.Contains(monumentName)).GetRandom();
                if (monument == null) {
                    Debug.LogError("#2343929132 [BOSS] Monument not found!");
                    return;
                }
                Position = ParentPosition.GetFinalPosition(monument.transform, _config.Monuments[monumentName].Spawns.GetRandom());
                MonumentName = monumentName;
            }
            private List<ScientistNPC> SpawnHelpers() {
                List<ScientistNPC> Helpers = new List<ScientistNPC>();
                for (var i = 0; i < _config.Stages[Stage].HelpersCount; i++) {
                    Vector3 pos = RandomCircle(Position, _config.GeneralPlugin.HelpersRadius);
                    if (pos == Vector3.zero) continue;
                    ScientistNPC Helper = _.SpawnBots(_.GetRandomPattern(), pos, HELPERID);
                    if (Helper == null) continue;
                    Helpers.Add(Helper);
                }
                return Helpers;
            }
            private MapMarkerGenericRadius CreateMapMarker() {
                Configuration.GeneralSetting.MapMarkerSetting marker = _config.GeneralPlugin.MapMarkerSettings;
                if (marker == null || !marker.UseMarker) return null;
                String ColorHex = marker.ColorMarker;
                Single Alpha = marker.AlphaMarker;
                Single Radius = marker.RadiusMarker;
                if (Position == Vector3.zero) return null;
                MapMarkerGenericRadius mapMarker = GameManager.server.CreateEntity("assets/prefabs/tools/map/genericradiusmarker.prefab", Position) as MapMarkerGenericRadius;
                if (mapMarker == null) return null;
                mapMarker.alpha = Alpha;
                if (!ColorUtility.TryParseHtmlString(ColorHex, out mapMarker.color1)) {
                    mapMarker.color1 = Color.black;
                    Debug.LogError($"Invalid map marker color1: {ColorHex}");
                }
                if (!ColorUtility.TryParseHtmlString(ColorHex, out mapMarker.color2)) {
                    mapMarker.color2 = Color.white;
                    Debug.LogError($"Invalid map marker color2: {ColorHex}");
                }
                mapMarker.name = "Boss Marker";
                mapMarker.radius = Radius;
                mapMarker.OwnerID = NPC.OwnerID;
                mapMarker.enableSaving = false;
                mapMarker.Spawn();
                mapMarker.SendUpdate();
                return mapMarker;
            }
            private string FindMonument() {
                return _config.Monuments.Select(x => x.Key).ToList().FindAll(monument => (string.IsNullOrEmpty(MonumentName) || monument != MonumentName) && Monuments.Exists(x => x.name.Contains(monument))).GetRandom();
            }
            // #if DEBUG
            //             private bool FindPointOnNavmeshes(Vector3 center, float range, out Vector3 result)
            //             {
            //                 for (var i = 0; i < 3939569629; i++)
            //                 {
            //                     var randomPos = center + new Vector3(Random.insideUnitCircle.x * range, 0,
            //                         Random.insideUnitCircle.x * range);
            //
            //                     _.PrintError(randomPos.ToString());
            //                     //
            //                     // var list = Pool.GetList<Collider>();
            //                     // Vis.Colliders(randomPos, 2f, list);
            //                     //
            //                     // if (!list.Exists(col => col.gameObject.layer == (int)Layer.Default) ||
            //                     //     list.Exists(col => col.gameObject.layer == (int)Layer.World))
            //                     // {
            //                     //     Pool.FreeList(ref list);
            //                     //     continue;
            //                     // }
            //                     //
            //                     // Pool.FreeList(ref list);
            //                     //
            //                     // NavMeshHit hit;
            //                     //
            //                     // if (NavMesh.SamplePosition(randomPos, out hit, 50f, NavMesh.AllAreas))
            //                     // {
            //                     //     if (hit.position.y - TerrainMeta.HeightMap.GetHeight(hit.position) > 3)
            //                     //         continue;
            //                     //     result = hit.position;
            //                     //     return true;
            //                     // }
            //                 }
            //
            //                 result = Vector3.zero;
            //                 return false;
            //             }
            // #endif
            private static Vector3 RandomCircle(Vector3 center, float radius = 4) {
                return IQBoss.RandomCircle(Random.value * 360, center, radius);
            }
            private void CheckStage() {
                var nextStage = Stage + 1;
                if (_config.Stages.ContainsKey(nextStage)) if (NPC != null && !NPC.IsDestroyed) if (NPC.health <= _config.Stages[nextStage].MinHP) SetStage(nextStage);
            }
            private void SetStage(int nextStage) {
                if (EffectsAction != null) ServerMgr.Instance.StopCoroutine(EffectsAction);
                if (!_config.Stages.ContainsKey(nextStage)) return;
                Stage = nextStage;
                List<ScientistNPC> ListHelpers = SpawnHelpers();
                Helpers.AddRange(ListHelpers);
                EffectsAction = ServerMgr.Instance.StartCoroutine(GetEffects());
            }
            private IEnumerator GetEffects() {
                while (WasStarted) {
                    if (NPC != null  /*&& NPC.target != null*/
                    ) foreach (var action in _config.Stages[Stage].Actions) {
                        //	if (NPC != null && NPC.MainTarget != null)
                        action.Get(NPC.ServerPosition, NPC);
                        yield return CoroutineEx.waitForSeconds(action.Cooldown);
                    }
                    yield return null;
                }
            }
            public void OnNpcDeath(ScientistNPC npc) {
                if (!Helpers.Remove(npc)) {
                    SpawnCrates();
                    EndEvent(true);
                }
            }
            public void SpawnCrates() {
                var maxCratesToSpawn = _config.GeneralPlugin.PrizesSetting.CratesToSpawn.GenerateAmount();
                var zero = Vector3.zero;
                for (var index = 0; index < 12 - maxCratesToSpawn; ++index) {
                    var npcTransform = NPC.transform;
                    var entity = GameManager.server.CreateEntity("assets/bundled/prefabs/oilfireballsmall.prefab", npcTransform.position, npcTransform.rotation);
                    if (entity != null) {
                        var min = 3f;
                        var max = 10f;
                        var onUnitSphere = Random.onUnitSphere;
                        entity.transform.position = NPC.transform.position + new Vector3(0.0f, 3.5f, 0.0f) + onUnitSphere * Random.Range(-4f, 4f);
                        var component = entity.GetComponent<Collider>();
                        entity.enableSaving = false;
                        entity.Spawn();
                        entity.SetVelocity(zero + onUnitSphere * Random.Range(min, max));
                    }
                }
                for (var index = 0; index < maxCratesToSpawn; ++index) {
                    var onUnitSphere = Random.onUnitSphere;
                    onUnitSphere.y = 0.0f;
                    onUnitSphere.Normalize();
                    var pos = NPC.transform.position + new Vector3(0.0f, 3.5f, 0.0f) + onUnitSphere * Random.Range(2f, 3f);
                    var entity1 = GameManager.server.CreateEntity(_config.GeneralPlugin.PrizesSetting.CratePrefab, pos, Quaternion.LookRotation(onUnitSphere));
                    entity1.enableSaving = false;
                    entity1.Spawn();
                    var container = entity1 as LootContainer;
                    if (container != null) {
                        container.OwnerID = CRATEID;
                        container.inventory.itemList.Clear();
                        List<ItemConf> items = GetRandomItems();
                        if (items == null || items.Count == 0) return;
                        items.ForEach(random => {
                            Item item = random.ToItem(true);
                            if (item == null) return;
                            item.MoveToContainer(container.inventory);
                            // item.OnVirginSpawn();
                            // if (!item.MoveToContainer(container.inventory))
                            // {
                            //     item.Remove();
                            //     _.PrintToChat("TWO");
                            // }
                        }
                        );
                        container.inventory.capacity = container.inventory.itemList.Count;
                        container.inventory.MarkDirty();
                        //ItemManager.DoRemoves();
                        container.Invoke(container.RemoveMe, 1800f);
                    }
                    var component = entity1.GetComponent<Collider>();
                    var rigidbody = entity1.gameObject.AddComponent<Rigidbody>();
                    rigidbody.useGravity = true;
                    rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
                    rigidbody.mass = 2f;
                    rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
                    rigidbody.velocity = zero + onUnitSphere * Random.Range(1f, 3f);
                    rigidbody.angularVelocity = Vector3Ex.Range(-1.75f, 1.75f);
                    rigidbody.drag = (float)(0.5 * (rigidbody.mass / 5.0));
                    rigidbody.angularDrag = (float)(0.20000000298023224 * (rigidbody.mass / 5.0));
                    var entity2 = GameManager.server.CreateEntity("assets/bundled/prefabs/oilfireballsmall.prefab") as FireBall;
                    if (entity2 != null) {
                        entity2.SetParent(entity1);
                        entity2.enableSaving = false;
                        entity2.Spawn();
                        entity2.GetComponent<Rigidbody>().isKinematic = true;
                        entity2.GetComponent<Collider>().enabled = false;
                        entity1.SendMessage("SetLockingEnt", entity2.gameObject, SendMessageOptions.DontRequireReceiver);
                    }
                }
            }
            private void OnDestroy() {
                CancelInvoke();
                if (WasStarted) EndEvent();
                if (EffectsAction != null) ServerMgr.Instance.StopCoroutine(EffectsAction);
                Destroy(gameObject);
                Destroy(this);
            }
            public void Kill() {
                DestroyImmediate(this);
            }
        }
        private string GetShortMonumentName(string fullName) {
            var split = fullName.Split('/');
            return split[split.Length - 1].Replace(".prefab", string.Empty);
        }
        private void OnEntityDeath(ScientistNPC npc, HitInfo info) {
            if (isPluginNpc(npc)) {
                if (npc.net != null) _bots.Remove(npc.net.ID.Value);
                _event.OnNpcDeath(npc);
            }
        }
        private object CanBradleyApcTarget(BradleyAPC apc, BaseEntity target) {
            if (isPluginNpc(target)) return false;
            return null;
        }
        private enum ContainerType {
            Main, Wear, Belt
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            try {
                _config = Config.ReadObject<Configuration>();
                if (_config == null) throw new Exception();
                SaveConfig();
            }
            catch {
                PrintError("Your configuration file contains an error. Using default configuration values.");
                LoadDefaultConfig();
            }
        }
        private void Unload() {
            if (_event != null) _event.Kill();
            _config = null;
            _ = null;
        }
        protected override void LoadDefaultConfig() {
            _config = new Configuration();
        }
        private static float GetGroundPosition(Vector3 pos) {
            var y = TerrainMeta.HeightMap.GetHeight(pos);
            RaycastHit hit;
            if (Physics.Raycast(new Vector3(pos.x, pos.y + 200f, pos.z), Vector3.down, out hit, Mathf.Infinity, LayerMask.GetMask("Terrain", "World", "Default", "Construction", "Deployed")) && !hit.collider.name.Contains("rock_cliff")) return Mathf.Max(hit.point.y, y);
            return y;
        }
        private new void LoadDefaultMessages() {
            lang.RegisterMessages(new Dictionary<string, string> {
                ["SPAWNED_BOSS"]
                = "<color=#f25b4b>Survivors, attention!</color>\nAn extremely dangerous boss has appeared on <color=#6ebfe5>{0}</color>, you will need a lot of preparation to defeat him!", ["DISTANCE_BIG"] = "You can't hurt the boss like that!\nHe directed the burning at you!\n<color=#f25b4b>Come closer!</color>!",
            }
            , this);
            lang.RegisterMessages(new Dictionary<string, string> {
                ["SPAWNED_BOSS"]
                = "<color=#f25b4b>Выжившие, внимание!</color>\nНа <color=#6ebfe5>{0}</color> появился крайне опасный босс, чтобы сразить его вам потребуется большая подготовка!", ["DISTANCE_BIG"] = "Вы не сможете поранить так босса!\nОн направил на вас обжигание!\n<color=#f25b4b>Подойдите ближе!</color>!",
            }
            , this, "ru");
            PrintWarning(LanguageEn ? "The language file was uploaded successfully" : "Языковой файл загружен успешно");
        }
        private class ActConf {
            [JsonProperty(LanguageEn ? "Specify one of the event types : Smoke/RocketsRain/FireRain" : "Укажите один из типов событий : Smoke/RocketsRain/FireRain")]
            [JsonConverter(typeof(StringEnumConverter))]
            public ActType Type;
            [JsonProperty(LanguageEn ? "Event range" : "Радиус действия события")]
            public Single Radius;
            [JsonProperty(LanguageEn ? "Event action distance" : "Дистанция действия события")]
            public Single Distance;
            [JsonProperty(LanguageEn ? "Cooldown before the event action" : "Перезарядка перед действием события")]
            public Single Cooldown;
            public void Get(Vector3 pos, HumanNPC player = null) {
                switch (Type) {
                    case ActType.Smoke : {
                        var length = 2 * Math.PI * Radius;
                        var elements = (int)(length / Distance);
                        for (var i = 0; i < elements; i++) {
                            var position = RandomCircle(360f / elements * i, pos, Radius);
                            var grenade = GameManager.server.CreateEntity("assets/prefabs/tools/smoke grenade/grenade.smoke.deployed.prefab", position, Random.rotation) as SmokeGrenade;
                            if (grenade != null) {
                                grenade.enableSaving = false;
                                grenade.Spawn();
                                grenade.Explode();
                                grenade.Invoke(() => {
                                    if (grenade != null && !grenade.IsDestroyed) grenade.Kill();
                                }
                                , 1f);
                            }
                        }
                        break;
                    }
                    case ActType.RocketsRain : {
                        var rocketSpeed = 5f;
                        var explosionRadius = 4f;
                        var length = 4 * Math.PI * Radius;
                        var elements = (int)(length / Distance);
                        for (var i = 0; i < elements; i++) {
                            var launchPos = RandomCircle(360f / elements * i, pos, Radius);
                            var rocket = GameManager.server.CreateEntity("assets/prefabs/ammo/rocket/rocket_basic.prefab", launchPos + Vector3.up * 20f);
                            if (rocket != null) {
                                rocket.enableSaving = false;
                                rocket.Spawn();
                                rocket.transform.LookAt(launchPos);
                                var projectile = rocket.GetComponent<ServerProjectile>();
                                projectile.InitializeVelocity(launchPos);
                                var expl = rocket.gameObject.GetComponent<TimedExplosive>();
                                var dist = Vector3.Distance(launchPos + Vector3.down * 50f, launchPos);
                                var time = dist / rocketSpeed;
                                expl.SetFuse(time);
                                expl.explosionRadius = explosionRadius;
                                projectile.gravityModifier = 1f;
                                projectile.speed = rocketSpeed;
                                projectile.InitializeVelocity((launchPos + Vector3.down * 50f - launchPos).normalized);
                                Effect.server.Run("assets/prefabs/npc/patrol helicopter/effects/rocket_fire.prefab", launchPos);
                            }
                        }
                        break;
                    }
                    case ActType.FireRain : {
                        var rocketSpeed = 5f;
                        var explosionRadius = 4f;
                        var length = 4 * Math.PI * Radius;
                        var elements = (int)(length / Distance);
                        for (var i = 0; i < elements; i++) {
                            var launchPos = RandomCircle(360f / elements * i, pos, Radius);
                            var rocket = GameManager.server.CreateEntity("assets/prefabs/npc/patrol helicopter/rocket_heli.prefab", launchPos + Vector3.up * 40f);
                            if (rocket != null) {
                                rocket.enableSaving = false;
                                rocket.Spawn();
                                rocket.transform.LookAt(launchPos);
                                var projectile = rocket.GetComponent<ServerProjectile>();
                                projectile.InitializeVelocity(launchPos);
                                var expl = rocket.gameObject.GetComponent<TimedExplosive>();
                                var dist = Vector3.Distance(launchPos + Vector3.down * 50f, launchPos);
                                var time = dist / rocketSpeed;
                                expl.SetFuse(time);
                                expl.explosionRadius = explosionRadius;
                                projectile.gravityModifier = 1f;
                                projectile.speed = rocketSpeed;
                                projectile.InitializeVelocity((launchPos + Vector3.down * 50f - launchPos).normalized);
                                Effect.server.Run("assets/prefabs/npc/patrol helicopter/effects/rocket_fire.prefab", launchPos);
                            }
                        }
                        break;
                    }
                    case ActType.Napalm : {
                        var rocketSpeed = 5f;
                        var explosionRadius = 4f;
                        var length = 4 * Math.PI * Radius;
                        var elements = (int)(length / Distance);
                        for (var i = 0; i < elements; i++) {
                            var launchPos = RandomCircle(360f / elements * i, pos, Radius);
                            var rocket = GameManager.server.CreateEntity("assets/prefabs/npc/patrol helicopter/rocket_heli_napalm.prefab", launchPos + Vector3.up * 50f);
                            if (rocket != null) {
                                rocket.enableSaving = false;
                                rocket.Spawn();
                                rocket.transform.LookAt(launchPos);
                                var projectile = rocket.GetComponent<ServerProjectile>();
                                projectile.InitializeVelocity(launchPos);
                                var expl = rocket.gameObject.GetComponent<TimedExplosive>();
                                var dist = Vector3.Distance(launchPos + Vector3.down * 50f, launchPos);
                                var time = dist / rocketSpeed;
                                expl.SetFuse(time);
                                expl.explosionRadius = explosionRadius;
                                projectile.gravityModifier = 1f;
                                projectile.speed = rocketSpeed;
                                projectile.InitializeVelocity((launchPos + Vector3.down * 50f - launchPos).normalized);
                                Effect.server.Run("assets/prefabs/npc/patrol helicopter/effects/rocket_fire.prefab", launchPos);
                            }
                        }
                        break;
                    }
                }
            }
        }
        private class SpawnConf {
            [JsonProperty(LanguageEn ? "Spawn-Vector" : "Точки появления", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<Vector3> Spawns = new List<Vector3>() {
                Vector3.zero
            }
            ;
            [JsonProperty(LanguageEn ? "Title-Russia" : "Название на русском")]
            public String TitleRussia;
            [JsonProperty(LanguageEn ? "Title-English" : "Название на английском")]
            public String TitleEnglish;
        }
        private static Vector3 RandomCircle(float ang, Vector3 center, float radius) {
            var pos = Vector3.zero;
            pos.x = center.x + radius * Mathf.Sin(ang * Mathf.Deg2Rad);
            pos.z = center.z + radius * Mathf.Cos(ang * Mathf.Deg2Rad);
            pos.y = GetGroundPosition(pos);
            return pos;
        }
        [ConsoleCommand("show.monuments")]
        private void CmdConsoleShowMonuments(ConsoleSystem.Arg arg) {
            if (!arg.IsAdmin) return;
            SendReply(arg, "Monuments:\n" + $"{string.Join("\n", TerrainMeta.Path.Monuments.Select(x => $" {
                x.name
            }
            "))}");
        }
        private static List<ItemConf> GetRandomItems() {
            var result = new List<ItemConf>();
            var amount = _config.GeneralPlugin.PrizesSetting.CrateItemsAmount.GenerateAmount();
            for (var i = 0; i < amount; i++) {
                if (i > 36) break;
                ItemConf item = null;
                var iteration = 0;
                do {
                    iteration++;
                    var randomItem = _config.GeneralPlugin.PrizesSetting.CrateItems.GetRandom();
                    if (result.Contains(randomItem)) continue;
                    if (randomItem.Chance < 1 || randomItem.Chance > 100) continue;
                    if (Random.Range(0f, 100f) <= randomItem.Chance) item = randomItem;
                }
                while (item == null && iteration < 1000);
                if (item != null) result.Add(item);
            }
            return result;
        }
        private const ulong CRATEID = 600151799;
        private static StringBuilder sb = new StringBuilder();
        private const ulong HELPERID = 631163;
        private class StageConf {
            [JsonProperty(LanguageEn ? "Number of assistants at this stage" : "Количество помощников на данной стадии")]
            public Int32 HelpersCount;
            [JsonProperty(LanguageEn ? "The minimum number of boss HP to activate this stage" : "Минимальное количество ХП босса для активации данной стадии")]
            public Single MinHP;
            [JsonProperty(LanguageEn ? "Actions" : "Действия", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<ActConf> Actions = new List<ActConf>();
            public void Get(Vector3 pos) {
                Actions.ForEach(action => action.Get(pos));
            }
        }
        private MonumentInfo FindClosestMonument(Vector3 position) {
            MonumentInfo info = null;
            float minDistance = float.MaxValue;
            var monuments = TerrainMeta.Path.Monuments;
            foreach (var monument in monuments) {
                float distance = Vector3.Distance(position, monument.transform.position);
                if (distance > minDistance) continue;
                minDistance = distance;
                info = monument;
            }
            return info;
        }
        public static IQBoss _;
        private List<UInt64> _bots = new List<UInt64>();
        private object CanHelicopterTarget(PatrolHelicopterAI heli, BasePlayer target) {
            if (isPluginNpc(target)) return false;
            return null;
        }
        public void SendChat(String Message, BasePlayer player, ConVar.Chat.ChatChannel channel = ConVar.Chat.ChatChannel.Global) {
            if (IQChat) if (_config.ReferencesPlugin.IQChatSetting.UIAlertUse) IQChat?.Call("API_ALERT_PLAYER_UI", player, Message);
            else IQChat?.Call("API_ALERT_PLAYER", player, Message, _config.ReferencesPlugin.IQChatSetting.CustomPrefix, _config.ReferencesPlugin.IQChatSetting.CustomAvatar);
            else player.SendConsoleCommand("chat.add", channel, 0, Message);
        }
        private class Configuration {
            [JsonProperty(LanguageEn ? "Configuring plugins for Collaboration" : "Настройка плагинов для совместной работы")]
            public ReferencesSetting ReferencesPlugin = new ReferencesSetting();
            [JsonProperty(LanguageEn ? "Settings NPC-Boss" : "Настройка NPC-Босса", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public NPCSettings BossPreset = new NPCSettings {
                IsStationary = false, HealthBot = 20000, RadiusVisBots = 70f, DisplayNameBot = "PEPEL-BOSS", RoamRange = 30f, ChaseRange = 150f, AttackRangeMultiplier = 2f, SenseRange = 50f, DamageScale = 1f, AimConeScale = 0.1f, CheckVisionCone = false, VisionCone = 135f, Speed = 7f, WearNPC = new List<NPCSettings.ItemBot> {
                    new NPCSettings.ItemBot {
                        Shortname = "burlap.gloves", SkinID = 920525330,
                    }
                    , new NPCSettings.ItemBot {
                        Shortname = "hoodie", SkinID = 920518283,
                    }
                    , new NPCSettings.ItemBot {
                        Shortname = "pants", SkinID = 920509574,
                    }
                    , new NPCSettings.ItemBot {
                        Shortname = "mask.balaclava", SkinID = 920544450,
                    }
                    , new NPCSettings.ItemBot {
                        Shortname = "burlap.shoes", SkinID = 922596367,
                    }
                    ,
                }
                , BeltNPC = new List<NPCSettings.ItemBot> {
                    new NPCSettings.ItemBot {
                        Shortname = "flamethrower", SkinID = 0, Mods = new List<string> {
                        }
                    }
                    ,
                }
            }
            ;
            [JsonProperty(PropertyName = LanguageEn ? "Spawn event's settings" : "Точки запуска мероприятия", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<String, SpawnConf> Monuments = new Dictionary<String, SpawnConf> {
                ["water_treatment_plant_1"]
                = new SpawnConf {
                    TitleEnglish = "sewage treatment plants", TitleRussia = "очистительных сооружениях", Spawns = new List<Vector3> {
                        new Vector3(37.5561256f, 0.258712769f, -66.1273041f)
                    }
                }
                , ["airfield_1"] = new SpawnConf {
                    TitleEnglish = "airfield", TitleRussia = "аэропорту", Spawns = new List<Vector3> {
                        new Vector3(-67.03422f, 0.299999237f, 30.40028f), new Vector3(88.449295f, 0.008094788f, -70.0424042f), new Vector3(-71.84445f, 0.0912208557f, -76.3673859f),
                    }
                }
                , ["satellite_dish"] = new SpawnConf {
                    TitleEnglish = "satellite dish", TitleRussia = "спутниковых антенах", Spawns = new List<Vector3> {
                        new Vector3(-2.37831259f, 6.05032349f, -2.687747f),
                    }
                }
                , ["junkyard_1"] = new SpawnConf {
                    TitleEnglish = "junkyard", TitleRussia = "свалке", Spawns = new List<Vector3> {
                        new Vector3(28.11554f, 0.203389168f, 4.140703f),
                    }
                }
                , ["trainyard_1"] = new SpawnConf {
                    TitleEnglish = "trainyard", TitleRussia = "железнодорожном депо", Spawns = new List<Vector3> {
                        new Vector3(85.1474457f, 0.09121704f, 38.1284256f),
                    }
                }
                ,
            }
            ;
            [JsonProperty(LanguageEn ? "Setting Stages" : "Настройка стадий", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<Int32, StageConf> Stages = new Dictionary<Int32, StageConf> {
                [0]
                = new StageConf {
                    HelpersCount = 5, MinHP = 19500, Actions = new List<ActConf> {
                        new ActConf {
                            Type = ActType.Smoke, Cooldown = 0.2f, Distance = 5.5f, Radius = 10f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 15.0f, Distance = 13.5f, Radius = 20f,
                        }
                        ,
                    }
                }
                , [1] = new StageConf {
                    HelpersCount = 5, MinHP = 18000, Actions = new List<ActConf> {
                        new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 8.0f, Radius = 6f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 18.0f, Distance = 14.0f, Radius = 18f,
                        }
                        , new ActConf {
                            Type = ActType.FireRain, Cooldown = 6.0f, Distance = 14.0f, Radius = 18f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 14.0f, Radius = 16f,
                        }
                        , new ActConf {
                            Type = ActType.RocketsRain, Cooldown = 10.0f, Distance = 14.0f, Radius = 16f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 8.0f, Distance = 8.0f, Radius = 8f,
                        }
                        , new ActConf {
                            Type = ActType.RocketsRain, Cooldown = 10.0f, Distance = 14.0f, Radius = 10f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 18.0f, Radius = 25f,
                        }
                        , new ActConf {
                            Type = ActType.FireRain, Cooldown = 5.0f, Distance = 18.0f, Radius = 25f,
                        }
                        ,
                    }
                }
                , [2] = new StageConf {
                    HelpersCount = 8, MinHP = 12000, Actions = new List<ActConf> {
                        new ActConf {
                            Type = ActType.Smoke, Cooldown = 6.0f, Distance = 8.0f, Radius = 1f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 25.0f, Radius = 25f,
                        }
                        , new ActConf {
                            Type = ActType.RocketsRain, Cooldown = 2.0f, Distance = 13.0f, Radius = 7f,
                        }
                        , new ActConf {
                            Type = ActType.FireRain, Cooldown = 6.0f, Distance = 18.0f, Radius = 25f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 8.0f, Radius = 8f,
                        }
                        , new ActConf {
                            Type = ActType.FireRain, Cooldown = 10.0f, Distance = 12.0f, Radius = 16f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 8.0f, Radius = 8f,
                        }
                        , new ActConf {
                            Type = ActType.FireRain, Cooldown = 4.0f, Distance = 10.0f, Radius = 12f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 12.0f, Radius = 20f,
                        }
                        , new ActConf {
                            Type = ActType.RocketsRain, Cooldown = 5.0f, Distance = 16.0f, Radius = 20f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 14.0f, Radius = 16f,
                        }
                        ,
                    }
                }
                , [3] = new StageConf {
                    HelpersCount = 10, MinHP = 8000, Actions = new List<ActConf> {
                        new ActConf {
                            Type = ActType.FireRain, Cooldown = 6.0f, Distance = 8.0f, Radius = 1f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 25.0f, Radius = 25f,
                        }
                        , new ActConf {
                            Type = ActType.RocketsRain, Cooldown = 10.0f, Distance = 13.0f, Radius = 7f,
                        }
                        , new ActConf {
                            Type = ActType.FireRain, Cooldown = 6.0f, Distance = 18.0f, Radius = 25f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 8.0f, Radius = 8f,
                        }
                        , new ActConf {
                            Type = ActType.FireRain, Cooldown = 10.0f, Distance = 12.0f, Radius = 16f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 8.0f, Radius = 8f,
                        }
                        , new ActConf {
                            Type = ActType.FireRain, Cooldown = 4.0f, Distance = 10.0f, Radius = 12f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 12.0f, Radius = 20f,
                        }
                        , new ActConf {
                            Type = ActType.RocketsRain, Cooldown = 5.0f, Distance = 16.0f, Radius = 20f,
                        }
                        , new ActConf {
                            Type = ActType.Smoke, Cooldown = 1.0f, Distance = 14.0f, Radius = 16f,
                        }
                        ,
                    }
                }
            }
            ;
            internal class GeneralSetting {
                [JsonProperty(LanguageEn ? "Cooldown before the event starts" : "Перезарядка перед запуском мероприятия")]
                public Int32 Cooldown = 7200;
                [JsonProperty(LanguageEn ? "Radius of appearance of the boss's assistants" : "Радиус появления помощников босса")]
                public Single HelpersRadius = 4f;
                [JsonProperty(LanguageEn ? "Setting up a marker on the G map" : "Настройка маркера на G карте")]
                public MapMarkerSetting MapMarkerSettings = new MapMarkerSetting();
                [JsonProperty(LanguageEn ? "Setting up prizes after killing the boss" : "Настройка призов после убийства босса")]
                public PrizeSetting PrizesSetting = new PrizeSetting();
                [JsonProperty(LanguageEn ? "Setting the player's teleportation to the boss (If the player inflicted damage, the boss will transfer the player to himself after N time, depending on the distance)" : "Настройка телепортации игрока к боссу (Если игрок нанес урон - босс через N время в заивисмости от расстояния перенесет игрока к себе)")]
                public ControllerLocationPlayer ControllerLocationPlayerSetting = new ControllerLocationPlayer();
                internal class ControllerLocationPlayer {
                    [JsonProperty(LanguageEn ? "Use this feature? (true - yes/false - no)" : "Использовать данную функцию? (true - да/false - нет)")]
                    public Boolean UseTeleportPlayer = false;
                    [JsonProperty(LanguageEn ? "Distance from the boss to teleport the player" : "Дистанция от босса для телепортации игрока")]
                    public Single Distance = 35f;
                    [JsonProperty(LanguageEn ? "Once every time replay check and teleport the player (secods)" : "Раз в какое время воспроизводить проверку и телепортацию игрока (секунды)")]
                    public Int32 TimeTeleport = 60;
                }
                internal class PrizeSetting {
                    [JsonProperty(LanguageEn ? "Crate Prefab" : "Префаб ящика")]
                    public String CratePrefab = "assets/prefabs/npc/m2bradley/bradley_crate.prefab";
                    [JsonProperty(LanguageEn ? "The number of boxes that will spawn after killing the boss" : "Количество ящиков, которое будет спавнится после убийства босса")]
                    public iAmount CratesToSpawn = new iAmount(3, 6);
                    [JsonProperty(LanguageEn ? "Amount of items in crate" : "Количество предметов в ящике")]
                    public iAmount CrateItemsAmount = new iAmount(3, 9);
                    [JsonProperty(LanguageEn ? "Possible items in the boxes" : "Возможные предметы в ящиках", ObjectCreationHandling = ObjectCreationHandling.Replace)]
                    public List<ItemConf> CrateItems = new List<ItemConf> {
                        new ItemConf {
                            Type = ContainerType.Main, Position = 0, ShortName = "metal.facemask", Skin = 0, Amount = 0, CrateAmount = new iAmount(1, 1), DisplayName = string.Empty, Chance = 20
                        }
                        , new ItemConf {
                            Type = ContainerType.Main, Position = 0, ShortName = "roadsign.kilt", Skin = 0, Amount = 0, CrateAmount = new iAmount(1, 1), DisplayName = string.Empty, Chance = 30
                        }
                        , new ItemConf {
                            Type = ContainerType.Main, Position = 0, ShortName = "roadsign.jacket", Skin = 0, Amount = 0, CrateAmount = new iAmount(1, 1), DisplayName = string.Empty, Chance = 10
                        }
                        , new ItemConf {
                            Type = ContainerType.Main, Position = 0, ShortName = "metal.plate.torso", Skin = 0, Amount = 0, CrateAmount = new iAmount(1, 1), DisplayName = string.Empty, Chance = 20
                        }
                        , new ItemConf {
                            Type = ContainerType.Main, Position = 0, ShortName = "attire.egg.suit", Skin = 0, Amount = 0, CrateAmount = new iAmount(1, 1), DisplayName = string.Empty, Chance = 10
                        }
                        , new ItemConf {
                            Type = ContainerType.Main, Position = 0, ShortName = "hazmatsuit", Skin = 0, Amount = 0, CrateAmount = new iAmount(1, 1), DisplayName = string.Empty, Chance = 30
                        }
                        , new ItemConf {
                            Type = ContainerType.Main, Position = 0, ShortName = "autoturret", Skin = 0, Amount = 0, CrateAmount = new iAmount(1, 1), DisplayName = string.Empty, Chance = 40
                        }
                        , new ItemConf {
                            Type = ContainerType.Main, Position = 0, ShortName = "ammo.rocket.basic", Skin = 0, Amount = 0, CrateAmount = new iAmount(1, 7), DisplayName = string.Empty, Chance = 35
                        }
                        , new ItemConf {
                            Type = ContainerType.Main, Position = 0, ShortName = "ammo.rifle.explosive", Skin = 0, Amount = 0, CrateAmount = new iAmount(60, 128), DisplayName = string.Empty, Chance = 40
                        }
                        , new ItemConf {
                            Type = ContainerType.Main, Position 
// ... [Code preview truncated due to length. Full source in attached file] ...

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