Example #1
0
        private void SpawnHelicopter(int num)
        {
            bool lifetime = false;

            if (ConVar.PatrolHelicopter.lifetimeMinutes == 0)
            {
                ConVar.PatrolHelicopter.lifetimeMinutes = 1;
                lifetime = true;
            }

            for (int i = 0; i < num; i++)
            {
                BaseEntity entity = GameManager.server.CreateEntity("assets/prefabs/npc/patrol helicopter/patrolhelicopter.prefab", new Vector3(), new Quaternion(), true);
                if (entity)
                {
                    BaseHelicopter heli = entity.GetComponent <BaseHelicopter>();
                    entity.Invoke("CS_Helicopter", 3600f);
                    entity.Spawn();
                    var csHeli = heli.gameObject.AddComponent <CS_Helicopter>();
                    CSHelicopters.Add(csHeli);
                    csHeli.UIHealth = CSHelicopters.Count - 1;

                    heli.GetComponent <CS_Helicopter>().enabled = true;
                    MoveToArena(entity);
                    _spawnTime.SetValue(entity.GetComponent <PatrolHelicopterAI>(), UnityEngine.Time.realtimeSinceStartup * 10);
                }
            }
            if (lifetime)
            {
                timer.Once(5f, () => ConVar.PatrolHelicopter.lifetimeMinutes = 0);
            }
        }
Example #2
0
        private bool CallHeliForPlayer(BasePlayer player)
        {
            var   playerPos = player.transform.position;
            float mapWidth  = (TerrainMeta.Size.x / 2) - 50f;
            var   heliPos   = new Vector3(
                playerPos.x < 0 ? -mapWidth : mapWidth,
                30,
                playerPos.z < 0 ? -mapWidth : mapWidth
                );

            BaseHelicopter heli = GameManager.server.CreateEntity("assets/prefabs/npc/patrol helicopter/patrolhelicopter.prefab", new Vector3(), new Quaternion(), true) as BaseHelicopter;

            if (!heli)
            {
                return(false);
            }
            PatrolHelicopterAI heliAI = heli.GetComponent <PatrolHelicopterAI>();

            heli.Spawn();
            heli.transform.position = heliPos;
            var component = heli.gameObject.AddComponent <PersonalHeliComponent>();

            component.Init(this, player);
            foreach (var p in BasePlayer.activePlayerList)
            {
                SendReply(p, _("PlayerCalled", p.UserIDString, $"<color=#63ff64>{player.displayName}</color>"));
            }
            return(true);
        }
Example #3
0
 void Awake()
 {
     Helicopter = GetComponent <BaseHelicopter>();
     AI         = Helicopter.GetComponent <PatrolHelicopterAI>();
     Helicopter.maxCratesToSpawn = 0;
     enabled = true;
     chopperSurvival.timer.Once(config.HelicopterSettings.CheckDistanceTimer, () => {
         if (this != null)
         {
             CheckDistance(GetComponent <BaseEntity>());
         }
     });
 }
Example #4
0
        private void OnEntityTakeDamage(BaseHelicopter baseHelicopter, HitInfo hitInfo)
        {
            if (baseHelicopter == null || hitInfo == null)
            {
                return;
            }

            if (baseHelicopter.GetComponent <EventHelicopter>())
            {
                if (EventManager.GetUser(hitInfo.InitiatorPlayer) == null)
                {
                    EventManager.ClearDamage(hitInfo);
                }
            }
        }
        public static bool ExecuteCommand(BasePlayer player, string command)
        {
            string[] args = command.Split(' ');

            if (player == null || args.Length == 0 || !playerInfo.ContainsKey(player.userID))
            {
                return(false);
            }

            PlayerInfo info = playerInfo[player.userID];

            switch (args[0])
            {
            // Add subscriptions
            // syntax: subscription <name> <duration in seconds>
            case "subscription":
                if (args.Length != 3)
                {
                    return(false);
                }

                info.AddSubscription(Convert.ToString(args[1]), Convert.ToInt32(args[2]));
                break;

            // Give item
            // syntax: give <itemname> [amount] [inventory]
            case "give":
                if (args.Length == 1)
                {
                    return(false);
                }

                // Parameters
                int           amount    = args.Length == 3 ? Convert.ToInt32(args[2]) : 1;
                ItemContainer inventory = player.inventory.containerMain;
                if (args.Length == 4 && Convert.ToString(args[3]) == "belt")
                {
                    inventory = player.inventory.containerBelt;
                }
                else if (args.Length == 4 && Convert.ToString(args[3]) == "wear")
                {
                    inventory = player.inventory.containerWear;
                }

                ItemDefinition definition = ItemManager.FindItemDefinition(Convert.ToString(args[1]));
                if (definition == null)
                {
                    return(false);
                }

                Item item = ItemManager.CreateByItemID(definition.itemid, amount);

                if (inventory.itemList.Count >= 24)
                {
                    item.Drop(player.transform.position, new Vector3(0, 1f, 0));
                }
                else
                {
                    player.inventory.GiveItem(ItemManager.CreateByItemID(definition.itemid, amount), inventory);
                }
                break;

            // Call the helicopter to the caller
            // syntax: helicopter
            case "helicopter":
                BaseHelicopter helicopter = (BaseHelicopter)GameManager.server.CreateEntity("assets/prefabs/npc/patrol helicopter/patrolhelicopter.prefab", new Vector3(), new Quaternion(), true);
                if (helicopter == null)
                {
                    return(false);
                }

                var ai = helicopter?.GetComponent <PatrolHelicopterAI>() ?? null;
                if (ai == null)
                {
                    return(false);
                }

                ai.SetInitialDestination(player.transform.position + new Vector3(0, 25f, 0));

                helicopter.Spawn();
                break;
            }

            return(true);
        }