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

FREE CustomBradley : 1.5.2 1.5.2

Нет прав для скачивания
C#:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Facepunch;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
using Random = UnityEngine.Random;
using Rust;
using HarmonyLib;
namespace Oxide.Plugins {
    [Info("CustomBradley", "shaitobu", "1.5.2")]
    public class CustomBradley : RustPlugin {
        [PluginReference]
        Plugin ImageLibrary, Economics, ServerRewards, BankSystem;
        private static Harmony _harmony;
        public static CustomBradley Instance = null;
        public static CustomBradleyComponent controller;
        Dictionary<ulong, DataPlayer> _playerData = new Dictionary<ulong, DataPlayer>();
        class DataPlayer {
            public long Cooldown = 0;
        }
#region Configuration
        private PluginConfig _config;
        private class PluginConfig {
            public class NPCConfig {
                public class ClothItem {
                    [JsonProperty("Shortname")]
                    public string Shortname;
                    [JsonProperty("SkinID")]
                    public ulong SkinID = 0;
                }
                public class SellItem {
                    [JsonProperty("DisplayName")]
                    public string DisplayName = "Vanilla Bradley";
                    [JsonProperty("Saleitem Image URL")]
                    public string url = "https://i.ibb.co/z6mr2kx/tanc01.png";
                    [JsonProperty("Description")]
                    public string BuyDescription = "Default Vanilla Bradley";
                    [JsonProperty("Permission")]
                    public string Permission = "";
                    [JsonProperty("ServerRewards costs")]
                    public int srCost = 10;
                    [JsonProperty("BankSystem costs")]
                    public int bkCost = 10;
                    [JsonProperty("Economics costs")]
                    public float ecCost = 10f;
                    [JsonProperty("Item displayname to pay with")]
                    public string itemName = "";
                    [JsonProperty("ItemID to pay with")]
                    public int itemPay = 0;
                    [JsonProperty("Item costs")]
                    public int scCost = 0;
                    [JsonProperty("Profilename")]
                    public string ProfileName = "easy";
                }
                [JsonProperty("Seller name")]
                public string DisplayName;
                [JsonProperty("Description in Shop")]
                public string Description;
                [JsonProperty("Local Position at Launchsite")]
                public Vector3 position;
                [JsonProperty("Rotation")]
                public float rotation;
                [JsonProperty("Clothing")]
                public List<ClothItem> Clothes;
                [JsonProperty("Tiers to sell")]
                public List<SellItem> ItemList;
            }
            public class UIConfig {
                [JsonProperty("Display countdown on spawn")]
                public bool UseCountdown = true;
                [JsonProperty("Countdown in seconds")]
                public float Countdown = 60;
                [JsonProperty("Countdown AnchorMin")]
                public string CountdownAnchorMin = "0 0.7694442";
                [JsonProperty("Countdown AnchorMax")]
                public string CountdownAnchorMax = "1 0.8249997";
                [JsonProperty("Timer AnchorMin")]
                internal string TimerPanelAnchorMin = "0.3445 0.1435";
                [JsonProperty("Timer AnchorMax")]
                internal string TimerPanelAnchorMax = "0.49 0.167";
            }
            [JsonProperty("Displayname for Economisc")]
            public string EconomicsName = "Eco";
            [JsonProperty("Displayname for ServerRewards")]
            public string ServerRewardsName = "RP";
            [JsonProperty("Displayname for BankSystem")]
            public string BankSystemName = "CR";
            [JsonProperty("Seller NPC")]
            public NPCConfig Seller;
            [JsonProperty("Broadcast spawns")]
            internal bool UseBroadcast = true;
            [JsonProperty("Use Countdown Sound")]
            internal bool UseCountdownSound = true;
            [JsonProperty("UI Settings")]
            internal UIConfig UI = new UIConfig();
            public static PluginConfig DefaultConfig => new PluginConfig {
                Seller = new NPCConfig() {
                    DisplayName = "Bradley Seller", Description = "just doing my job", position = new Vector3(263.8f, 3.5f, 56.5f), rotation = 0.8f, Clothes = new List<NPCConfig.ClothItem>() {
                        new NPCConfig.ClothItem {
                            Shortname = "hoodie", SkinID = 1362361447
                        }
                        , new NPCConfig.ClothItem {
                            Shortname = "pants", SkinID = 1320611965
                        }
                        , new NPCConfig.ClothItem {
                            Shortname = "mask.balaclava", SkinID = 1362511189
                        }
                        , new NPCConfig.ClothItem {
                            Shortname = "shoes.boots", SkinID = 1132775378
                        }
                        , new NPCConfig.ClothItem {
                            Shortname = "burlap.gloves", SkinID = 1438131479
                        }
                    }
                    , ItemList = new List<NPCConfig.SellItem>() {
                        new NPCConfig.SellItem(), new NPCConfig.SellItem() {
                            ProfileName = "normal", Permission = "CustomBradley.medium", url = "https://i.ibb.co/kcnMbPk/tanc02.png", DisplayName = "Always moving Bradley", BuyDescription = "Moving Vanilla Bradley with increased loot"
                        }
                    }
                }
            }
            ;
        }
        public APCSettings[] _profiles;
        public Dictionary<string, LootSettings[]> _lootTables = new Dictionary<string, LootSettings[]>();
        public class LootSettings {
            public class ItemDefinition {
                [JsonProperty("Item Shortname")]
                public string Shortname = "scrap";
                [JsonProperty("Custom Displayname")]
                public string DisplayName = string.Empty;
                [JsonProperty("SkinID")]
                public ulong SkinID = 0;
                [JsonProperty("Item chance (0.01% - 100%)")]
                public float Chance = 100;
                [JsonProperty("Min.Amount")]
                public int AmountMin = 1;
                [JsonProperty("Max.Amount")]
                public int AmountMax = 1000;
            }
            [JsonProperty("LootTable")]
            public ItemDefinition[] Items = {
                new ItemDefinition() {
                    Shortname = "scrap", DisplayName = "", SkinID = 0, AmountMin = 1, AmountMax = 1000
                }
            }
            ;
        }
        public class APCSettings {
            public class BaseConfig {
                [JsonProperty("Profile name")]
                public string Name = "easy";
                [JsonProperty("Display name in chat")]
                internal object displayName = string.Empty;
                [JsonProperty("Cooldown")]
                public float Cooldown = 7200.0f;
                [JsonProperty("Cooldown modifier if failed to kill")]
                public float CooldownModifierOnFail = 0.5f;
                [JsonProperty("Time to kill")]
                public float DespawnTime = 900.0f;
                [JsonProperty("Time to loot after kill")]
                public float LootingTime = 600.0f;
                [JsonProperty("HP")]
                public float Health = 1000.0f;
                [JsonProperty("Recieved Damage modifier")]
                public float RecivedDamage = 1.0f;
                [JsonProperty("Accuracy")]
                public float Accuracy = 1.0f;
                [JsonProperty("Lock for players Team")]
                public bool LockForTeam = true;
                [JsonProperty("Allow players with cooldown to damage bradley")]
                public bool IgnoreCooldown = false;
                [JsonProperty("Destroy flame balls")]
                public bool DestroyFlames = true;
                [JsonProperty("Block FP NPCs from spawn")]
                public bool BlockNPCs = false;
            }
            public class LootConfig {
                [JsonProperty("Crate amount")]
                public int CrateAmount = 3;
                [JsonProperty("Loot scale per Attacker")]
                internal float AttackerScale = 0.0f;
                [JsonProperty("LootTable name")]
                public string LootTables;
            }
            public class MainTurretConfig {
                [JsonProperty("View distance")]
                public float ViewDistance = 100.0f;
                [JsonProperty("Can use basic rockets")]
                public bool UseRockets = false;
                [JsonProperty("Rocket speed modifier")]
                public float RocketSpeed = 1.0f;
                [JsonProperty("Delay between rocket bursts")]
                public float TimeBetweenRockets = 5.0f;
                [JsonProperty("Delay between each rocket in burst")]
                public float RocketDelay = 0.25f;
                [JsonProperty("Rockets amount per burst")]
                public int RocketsPerBurst = 4;
                [JsonProperty("Chance to launch homing missiles")]
                public float HomingChance = 60.0f;
                [JsonProperty("Lock to one target per burst")]
                internal bool lockOnce = true;
                [JsonProperty("Time rockets fly up")]
                public float FlyUpTime = 3f;
            }
            public class MachinegunConfig {
                [JsonProperty("Max.distance machine gun should shoot")]
                public float ShootDistance = 40f;
                [JsonProperty("Machinegun shots per burst")]
                public int ShotsPerBurst = 10;
                [JsonProperty("Delay between machinegun bursts")]
                public float TimeBetweenShots = 1.0f;
                [JsonProperty("Delay between each shot in burst")]
                public float ShotDelay = 0.06667f;
                [JsonProperty("Bullet damage")]
                public float BulletDamage = 15.0f;
            }
            public class BradleyBehaviorConfig {
                [JsonProperty("Lock the door at entrance Control point")]
                public bool BlockDoor = true;
                [JsonProperty("Prevent Bradley from hunting Players")]
                public bool AlwaysMove = false;
                [JsonProperty("Heat vision(ignore walls/buildings on targeting)")]
                public bool AlwaysShoot = false;
            }
            public BaseConfig Base = new BaseConfig();
            public BradleyBehaviorConfig Behavior = new BradleyBehaviorConfig();
            public MachinegunConfig Machinegun = new MachinegunConfig();
            public MainTurretConfig Cannon = new MainTurretConfig();
            public LootConfig Loot = new LootConfig();
            [JsonIgnore]
            public static APCSettings Default = new APCSettings();
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            try {
                _config = Config.ReadObject<PluginConfig>();
            }
            catch (Exception ex) {
                PrintError("Failed to load config file(is the config file corrupt ?)(" + ex.Message + ")");
            }
            SaveConfig();
        }
        protected override void LoadDefaultConfig() {
            _config = PluginConfig.DefaultConfig;
            SaveConfig();
        }
        protected override void SaveConfig() {
            Config.WriteObject(_config);
        }
        protected override void LoadDefaultMessages() {
            lang.RegisterMessages(new Dictionary<string, string> {
                ["TextOnTimedKill"]
                = "Time's up.You've missed your chance.", ["TextOnSpawn"] = "You have {0} minutes to kill this Bradley", ["TeamLocked"] = "This Bradley is teamlocked and you've joined after its spawn.", ["Spawn broadcast"] = "<color=#63ff64>{0}</color> calls {1} in.", ["NotOwner"] = "This bradley is called for {0} and his/her team.", ["CooldownDamage"] = "You will be able to damage bradley in {0}", ["CooldownCall"] = "You will be able to call next bradley in {0}", ["CallInLable"] = "Call bradley", ["NoPermission"] = "No Permission", ["CountdownText"] = "Bradley will spawn in {0}", ["LeaveTimerText"] = "Bradley will leave in", ["LootTimerText"] = "Loot will dismiss in", ["LootTimeStarted"] = "You have {0} minutes to loot your bradley.", ["LockOnMessage"] = "Bradley is locking rockets on you."
            }
            , this);
            lang.RegisterMessages(new Dictionary<string, string> {
                ["TextOnTimedKill"]
                = "Время вышло, танк уехал.", ["TextOnSpawn"] = "У вас есть {0} минут на то, чтобы уничтожить танк.", ["TeamLocked"] = "Вы вступили в команду после появления танка и не можете наносить урон.", ["Spawn broadcast"] = "<color=#63ff64>{0}</color> вызывает {1}.", ["NotOwner"] = "Танк вызван для {0} и команды.", ["CooldownDamage"] = "Вы можете атаковать танк через {0}", ["CooldownCall"] = "Новый танк можно вызвать через {0}", ["CallInLable"] = "ВЫЗВАТЬ", ["NoPermission"] = "НЕТ ПРАВ", ["CountdownText"] = "Танк появится через {0}", ["LeaveTimerText"] = "Танк уедет через", ["LootTimerText"] = "Лут исчезнет через", ["LootTimeStarted"] = "У вас есть {0} минут чтобы залутать танк.", ["LockOnMessage"] = "Танк наводит на вас снаряды."
            }
            , this, "ru");
        }
        public string _(string key, string userId, params object[] args) {
            return string.Format(lang.GetMessage(key, this, userId), args);
        }
#endregion
#region Oxide-Hooks
        bool wasBradley = true;
        public static GameObject gO = null;
        private void OnServerInitialized() {
            if (TerrainMeta.Path.Monuments.FirstOrDefault(p => p.name.Contains("launch_site_1")) == null) {
                Interface.Oxide.LogError("launch_site_1 not found.unloading...");
                Interface.Oxide.UnloadPlugin(Name);
                return;
            }
            LoadProfiles();
            LoadLootTables();
            Instance = this;
            foreach (var p in BaseNetworkable.serverEntities.OfType<VendingMachineMapMarker>().Where(i => i.markerShopName == _config.Seller.DisplayName)) p.Kill();
            foreach (var p in BaseNetworkable.serverEntities.OfType<BasePlayer>().Where(i => !i.userID.IsSteamId() && i.displayName == _config.Seller.DisplayName)) p.Kill();
            _playerData = Interface.Oxide.DataFileSystem.ReadObject<Dictionary<ulong, DataPlayer>>($"{Title}{System.IO.Path.DirectorySeparatorChar}playerData");
            timer.Once(2f, () => {
                wasBradley = ConVar.Bradley.enabled;
                ConVar.Bradley.enabled = false;
                if (_harmony == null) _harmony = new Harmony("com.o_o.CustomBradley");
                _harmony.Patch(AccessTools.Method(typeof(BradleyAPC), nameof(BradleyAPC.DoWeapons)), new HarmonyMethod(typeof(BradleyPatch), "Prefix"));
                _harmony.Patch(AccessTools.Method(typeof(BradleyAPC), "TrySpawnScientists"), new HarmonyMethod(typeof(BradleyPatch), "Spawn"));
                foreach (var i in _config.Seller.ItemList) {
                    if (!string.IsNullOrEmpty(i.Permission) && !permission.PermissionExists(i.Permission)) permission.RegisterPermission(i.Permission.ToLower(), this);
                    if (!string.IsNullOrEmpty(i.url)) AddImage(i.url, $"{i.url.GetHashCode()}");
                }
                gO = new GameObject("CustomBradleySpawner");
                controller = gO.AddComponent<CustomBradleyComponent>();
                SpawnSeller();
                SpawnDoor();
            }
            );
        }
        BaseEntity door = null;
        private void SpawnDoor() {
            MonumentInfo monument = TerrainMeta.Path.Monuments.FirstOrDefault(x => x.name.Contains("launch_site_1"));
            var pos = monument.transform.TransformPoint(new Vector3(97.2f, 3.4f, -20.5f));
            var rot = monument.transform.rotation;
            door = GameManager.server.CreateEntity("assets/bundled/prefabs/static/door.hinged.industrial_a_f.prefab", pos, rot);
            door.Spawn();
            door.SetFlag(BaseEntity.Flags.Busy, true);
            door.SendNetworkUpdate();
        }
        private void LoadLootTables() {
            try {
                foreach (string s in Interface.Oxide.DataFileSystem.GetFiles($"{Interface.Oxide.DataDirectory}{System.IO.Path.DirectorySeparatorChar}{Title}{System.IO.Path.DirectorySeparatorChar}Loot")) {
                    string fileName = s.Split(System.IO.Path.DirectorySeparatorChar).Last().Split('.').First();
                    LootSettings[] d = Interface.Oxide.DataFileSystem.ReadObject<LootSettings[]>($"{Interface.Oxide.DataDirectory}{System.IO.Path.DirectorySeparatorChar}{Title}{System.IO.Path.DirectorySeparatorChar}Loot{System.IO.Path.DirectorySeparatorChar}{fileName}");
                    if (!_lootTables.ContainsKey(fileName)) _lootTables.Add(fileName, d);
                }
            }
            catch (Exception ex) {
                PrintError(ex.Message);
                _lootTables = new Dictionary<string, LootSettings[]>() {
                    {
                        "normal", new LootSettings[] {
                            new LootSettings() {
                                Items = new LootSettings.ItemDefinition[] {
                                    new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle", DisplayName= "", SkinID= 0, AmountMin= 128, AmountMax= 300
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle.incendiary", DisplayName= "", SkinID= 0, AmountMin= 60, AmountMax= 200
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle.explosive", DisplayName= "", SkinID= 0, AmountMin= 60, AmountMax= 100
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle.hv", DisplayName= "", SkinID= 0, AmountMin= 80, AmountMax= 150
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "techparts", DisplayName= "", SkinID= 0, AmountMin= 15, AmountMax= 25
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosive.timed", DisplayName= "", SkinID= 0, AmountMin= 2, AmountMax= 4
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rocket.fire", DisplayName= "", SkinID= 0, AmountMin= 5, AmountMax= 8
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rocket.hv", DisplayName= "", SkinID= 0, AmountMin= 3, AmountMax= 5
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.l96", DisplayName= "", SkinID= 0, AmountMin= 0, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "weapon.mod.8x.scope", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "lmg.m249", DisplayName= "", SkinID= 0, AmountMin= 0, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "smg.thompson", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "smg.mp5", DisplayName= "", SkinID= 0, AmountMin= 0, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.ak", DisplayName= "", SkinID= 0, AmountMin= 0, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.bolt", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.lr300", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "hazmatsuit", DisplayName= "", SkinID= 0, AmountMin= 0, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "hazmatsuit.spacesuit", DisplayName= "", SkinID= 0, AmountMin= 0, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "hazmatsuit.arcticsuit", DisplayName= "", SkinID= 0, AmountMin= 0, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metal.refined", DisplayName= "", SkinID= 0, AmountMin= 50, AmountMax= 100
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "crude.oil", DisplayName= "", SkinID= 0, AmountMin= 100, AmountMax= 150
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "supply.signal", DisplayName= "", SkinID= 0, AmountMin= 0, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosive.satchel", DisplayName= "", SkinID= 0, AmountMin= 4, AmountMax= 6
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metalpipe", DisplayName= "", SkinID= 0, AmountMin= 12, AmountMax= 25
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosives", DisplayName= "", SkinID= 0, AmountMin= 5, AmountMax= 10
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "gunpowder", DisplayName= "", SkinID= 0, AmountMin= 500, AmountMax= 1000
                                    }
                                }
                            }
                        }
                    }
                    , {
                        "hard", new LootSettings[] {
                            new LootSettings() {
                                Items = new LootSettings.ItemDefinition[] {
                                    new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle", DisplayName= "", SkinID= 0, AmountMin= 300, AmountMax= 500
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle.incendiary", DisplayName= "", SkinID= 0, AmountMin= 200, AmountMax= 300
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle.explosive", DisplayName= "", SkinID= 0, AmountMin= 150, AmountMax= 200
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle.hv", DisplayName= "", SkinID= 0, AmountMin= 150, AmountMax= 250
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "techparts", DisplayName= "", SkinID= 0, AmountMin= 25, AmountMax= 35
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosive.timed", DisplayName= "", SkinID= 0, AmountMin= 10, AmountMax= 15
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rocket.fire", DisplayName= "", SkinID= 0, AmountMin= 10, AmountMax= 15
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rocket.hv", DisplayName= "", SkinID= 0, AmountMin= 10, AmountMax= 15
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.l96", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "weapon.mod.8x.scope", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "lmg.m249", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "smg.thompson", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "smg.mp5", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.ak", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.ak", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.lr300", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "hazmatsuit", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "hazmatsuit.spacesuit", DisplayName= "", SkinID= 0, AmountMin= 0, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "hazmatsuit.arcticsuit", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metal.refined", DisplayName= "", SkinID= 0, AmountMin= 200, AmountMax= 300
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "crude.oil", DisplayName= "", SkinID= 0, AmountMin= 1000, AmountMax= 1500
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "supply.signal", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosive.satchel", DisplayName= "", SkinID= 0, AmountMin= 8, AmountMax= 15
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metalpipe", DisplayName= "", SkinID= 0, AmountMin= 30, AmountMax= 50
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosives", DisplayName= "", SkinID= 0, AmountMin= 30, AmountMax= 45
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "gunpowder", DisplayName= "", SkinID= 0, AmountMin= 3500, AmountMax= 5000
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metal.facemask", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metal.facemask", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metal.plate.torso", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metal.plate.torso", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                }
                            }
                        }
                    }
                    , {
                        "extreme", new LootSettings[] {
                            new LootSettings() {
                                Items = new LootSettings.ItemDefinition[] {
                                    new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle", DisplayName= "", SkinID= 0, AmountMin= 300, AmountMax= 500
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle", DisplayName= "", SkinID= 0, AmountMin= 300, AmountMax= 500
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle.incendiary", DisplayName= "", SkinID= 0, AmountMin= 300, AmountMax= 500
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle.explosive", DisplayName= "", SkinID= 0, AmountMin= 250, AmountMax= 400
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rifle.hv", DisplayName= "", SkinID= 0, AmountMin= 250, AmountMax= 450
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "techparts", DisplayName= "", SkinID= 0, AmountMin= 35, AmountMax= 50
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosive.timed", DisplayName= "", SkinID= 0, AmountMin= 20, AmountMax= 25
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rocket.fire", DisplayName= "", SkinID= 0, AmountMin= 20, AmountMax= 25
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "ammo.rocket.hv", DisplayName= "", SkinID= 0, AmountMin= 20, AmountMax= 25
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "launcher", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.l96", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "weapon.mod.8x.scope", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "lmg.m249", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "lmg.m249", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.ak", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.ak", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "rifle.lr300", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "hazmatsuit", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "hazmatsuit.spacesuit", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "hazmatsuit.arcticsuit", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metal.refined", DisplayName= "", SkinID= 0, AmountMin= 300, AmountMax= 500
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "crude.oil", DisplayName= "", SkinID= 0, AmountMin= 3000, AmountMax= 4500
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "supply.signal", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "supply.signal", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosive.satchel", DisplayName= "", SkinID= 0, AmountMin= 8, AmountMax= 15
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosive.satchel", DisplayName= "", SkinID= 0, AmountMin= 8, AmountMax= 15
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosive.satchel", DisplayName= "", SkinID= 0, AmountMin= 8, AmountMax= 15
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metalpipe", DisplayName= "", SkinID= 0, AmountMin= 40, AmountMax= 60
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosives", DisplayName= "", SkinID= 0, AmountMin= 30, AmountMax= 45
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "explosives", DisplayName= "", SkinID= 0, AmountMin= 30, AmountMax= 45
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "gunpowder", DisplayName= "", SkinID= 0, AmountMin= 3500, AmountMax= 5000
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "gunpowder", DisplayName= "", SkinID= 0, AmountMin= 3500, AmountMax= 5000
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metal.facemask", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metal.facemask", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metal.plate.torso", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                    , new LootSettings.ItemDefinition() {
                                        Shortname= "metal.plate.torso", DisplayName= "", SkinID= 0, AmountMin= 1, AmountMax= 1
                                    }
                                }
                            }
                        }
                    }
                }
                ;
                foreach (var l in _lootTables) Interface.Oxide.DataFileSystem.WriteObject<LootSettings[]>($"{Interface.Oxide.DataDirectory}{System.IO.Path.DirectorySeparatorChar}{Title}{System.IO.Path.DirectorySeparatorChar}Loot{System.IO.Path.DirectorySeparatorChar}{l.Key}", l.Value);
            }
        }
        private void LoadProfiles() {
            try {
                _profiles = Interface.Oxide.DataFileSystem.ReadObject<APCSettings[]>($"{Title}{System.IO.Path.DirectorySeparatorChar}profiles");
            }
            catch {
                _profiles = new APCSettings[] {
                    APCSettings.Default, new APCSettings() {
                        Base = new APCSettings.BaseConfig {
                            Name = "normal", displayName = "lazy bradley", Cooldown = 7200.0f, DespawnTime = 900.0f, LootingTime = 600.0f, Health = 2000.0f, RecivedDamage = 1f, Accuracy = 1f, LockForTeam = true
                        }
                        , Behavior = new APCSettings.BradleyBehaviorConfig {
                            AlwaysMove = true, AlwaysShoot = false, BlockDoor = false
                        }
                        , Cannon = new APCSettings.MainTurretConfig {
                            ViewDistance = 100.0f, UseRockets = false, HomingChance = 0f, lockOnce = false, RocketSpeed = 1.0f, TimeBetweenRockets = 5.0f, RocketDelay = 0.25f, RocketsPerBurst = 3
                        }
                        , Machinegun = new APCSettings.MachinegunConfig {
                            ShotsPerBurst = 10, TimeBetweenShots = 1f, ShotDelay = 0.06667f, BulletDamage = 15.0f, ShootDistance = 80f
                        }
                        , Loot = new APCSettings.LootConfig {
                            CrateAmount = 3, AttackerScale = 0f, LootTables = "normal"
                        }
                    }
                }
                ;
            }
            Interface.Oxide.DataFileSystem.WriteObject<APCSettings[]>($"{Title}{System.IO.Path.DirectorySeparatorChar}profiles", _profiles);
        }
        void Unload() {
            if (gO) UnityEngine.Object.DestroyImmediate(gO);
            if (_harmony != null) _harmony.UnpatchAll("com.o_o.CustomBradley");
            DestroyGUI();
            if (startCorutine != null) {
                ServerMgr.Instance.StopCoroutine(startCorutine);
                startCorutine = null;
            }
            foreach (var b in BaseNetworkable.serverEntities.OfType<BradleyAPC>().Where(x => x.skinID == 1231236555)) b.Kill();
            foreach (var p in BasePlayer.activePlayerList) CuiHelper.DestroyUi(p, Layer + p.userID);
            foreach (var p in BasePlayer.activePlayerList) CuiHelper.DestroyUi(p, "BradleyUIPanel");
            if (seller) seller.Kill();
            if (door) door.Kill();
            Interface.Oxide.DataFileSystem.WriteObject($"{Title}{System.IO.Path.DirectorySeparatorChar}playerData", _playerData);
            ConVar.Bradley.enabled = wasBradley;
        }
#endregion
#region Hooks
        object CanPopulateLoot(LootContainer container) {
            if (controller != null && controller.currentAPC && controller.IsBradleyCrate(container)) return false;
            return null;
        }
        void OnEntityTakeDamage(BaseEntity entity, HitInfo info) {
            if (info == null || !entity) return;
            if (seller == entity) info?.damageTypes.ScaleAll(0f);
            var bradley = (info.WeaponPrefab?.creatorEntity as BradleyAPC ?? info.Initiator as BradleyAPC);
            if (info != null && bradley && bradley == controller.currentAPC) {
                if (!(entity is BasePlayer) || !(entity as BasePlayer).userID.IsSteamId()) info.damageTypes.ScaleAll(0f);
            }
        }
        void OnEntityTakeDamage(BradleyAPC entity, HitInfo info) {
            if (entity == null || info == null) return;
            if (info.Initiator is BradleyAPC) {
                info.damageTypes.ScaleAll(0f);
                return;
            }
            var player = info.InitiatorPlayer;
            if (player == null || player.IsAdmin) return;
            if (!player.userID.IsSteamId()) {
                info.damageTypes.ScaleAll(0f);
                return;
            }
            if (!controller || controller.currentAPC != entity) return;
            if (controller.apcSettings.Base.LockForTeam && !CanInteractWith(player, entity)) {
                info.damageTypes.ScaleAll(0);
                if (player.Team != null && player.Team.members.Contains(controller.currentOwner.userID)) {
                    SendReply(player, _("TeamLocked", player.UserIDString));
                    return;
                }
                BasePlayer owner = controller.currentOwner;
                if (owner) SendReply(player, _("NotOwner", player.UserIDString, owner.displayName));
                return;
            }
            DataPlayer f;
            if (controller.apcSettings.Base.IgnoreCooldown || CanDamageBradley(player, entity, out f)) {
                info.damageTypes.ScaleAll(controller.apcSettings.Base.RecivedDamage);
                return;
            }
            info.damageTypes.ScaleAll(0f);
            SendReply(player, _("CooldownDamage", player.UserIDString, TimeSpan.FromTicks(f.Cooldown - DateTime.Now.Ticks).ToString(@"hh\:mm\:ss")));
        }
        private object OnPlayerAttack(BasePlayer attacker, HitInfo info) {
            if (info.HitEntity is ServerGib && attacker && !attacker.IsNpc) {
                if (controller.IsBradleyPart(info.HitEntity) && controller.apcSettings.Base.LockForTeam) {
                    if (!CanInteractWith(attacker, info.HitEntity)) {
                        BasePlayer owner = controller.currentOwner;
                        if (owner) SendReply(attacker, _("NotOwner", attacker.UserIDString, owner.displayName));
                        info.damageTypes.ScaleAll(0);
                        return false;
                    }
                }
            }
            return null;
        }
        void OnEntityDeath(BradleyAPC entity, HitInfo info) {
            if (entity == null) return;
            if (entity == controller.currentAPC) {
                controller.OnAPCDeath();
            }
        }
        object CanLootEntity(BasePlayer player, StorageContainer container) {
            if (player == null || container == null || controller is null) return null;
            if (controller.IsBradleyCrate(container)) {
                if (!CanInteractWith(player, container)) {
                    BasePlayer owner = controller.currentOwner;
                    if (owner) SendReply(player, _("NotOwner", player.UserIDString, owner.displayName));
                    return false;
                }
            }
// ... [Code preview truncated due to length. Full source in attached file] ...

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

Другие ресурсы пользователя 15FPS

Сверху