示例#1
0
        internal static Action AddGps(string name, string description, Vector3D coords)
        {
            MyStringId nameID;
            MyStringId descriptionID;

            string _name        = name;
            string _description = description;

            if (MyStringId.TryGet(name, out nameID))
            {
                _name = VRage.MyTexts.Get(nameID).ToString();
//                ModLog.Info("Found GPS localization for " + name+ " as:" + _name);
            }
            else
            {
                ModLog.Info("No name found for GPS:" + name);
            }
            if (MyStringId.TryGet(description, out descriptionID))
            {
                _description = VRage.MyTexts.Get(descriptionID).ToString();
//                ModLog.Info("Found GPS localization for " + description + " as:" + _description);
            }

            return(() => { DuckUtils.AddGpsToAllPlayers(_name, _description, coords); });
        }
示例#2
0
        internal void HandleClientJoinedMessage(Message message)
        {
            var playerId = message.PlayerId;

            research.UnlockTechForJoiningPlayer(playerId);

            //V27 for SE 1.192
            DuckUtils.SetPlayerReputation(playerId, "MIKI", 0);

            // V37 to force CRASH faction
            DuckUtils.PutPlayerIntoFaction(playerId, "CRASH");

            if (!RegisteredPlayers.Contains(playerId))
            {
                //V26 fix no player in DS
                ulong steamID = 0;
                if (MyAPIGateway.Session.Player != null)
                {
                    steamID = MyAPIGateway.Session.Player.SteamUserId;
                }
                var msgBytes = Encoding.UTF8.GetBytes(MyAPIGateway.Utilities.SerializeToXML(new Message
                {
                    SenderSteamId = steamID,
                    MessageType   = MessageType.ClearToolbar,
                    PlayerId      = playerId
                }));

                MyAPIGateway.Multiplayer.SendMessageTo(ModId, msgBytes, message.SenderSteamId);
            }
        }
示例#3
0
        internal void Update()
        {
            // TODO: need a reference to the whole base grid to properly determine ownership
            // TODO: use faction info from faction definition.

            if (!RemoteControl.IsControlledByFaction("GCORP"))
            {
//				return; // Maybe remove from list of bases?
            }


            // TODO: use faction info from faction definition.
            var player = DuckUtils.GetNearestPlayerToPosition(RemoteControl.GetPosition(), 1000);

            if (!DebugStopBackupGroups && player != null)
            {
                if (lastBackupRespondTime + BackupTimeDelay < MyAPIGateway.Session.GameDateTime)
                {
                    // TODO: use faction info from faction definition.
                    SpawnHelperPatrol(player);
                    waitingOnBackup       = true;
                    lastBackupRespondTime = MyAPIGateway.Session.GameDateTime;
                    // TODO: use faction info from faction definition.
                    audioSystem.PlayAudio(CalAudioClip.FacilityDetectedHostile, CalAudioClip.GCorpFacilityThreatened);
                }
            }
        }
示例#4
0
        public void SpawnConvoyTransport(IMyShipController baseToSpawnAt)
        {
            var factionId       = baseToSpawnAt.OwnerId;
            var spawnerPosition = baseToSpawnAt.GetPosition();
            var gravity         = baseToSpawnAt.GetNaturalGravity();
            var unitType        = baseToSpawnAt.CustomName.Contains("GROUND") ? UnitType.Ground : UnitType.Air;
            var cargoSize       = heatSystem.GenerateCargoShipSize();

            if (unitType == UnitType.Air)
            {
                var positionToSpawn = spawnerPosition + gravity * -5f + baseToSpawnAt.WorldMatrix.Forward * 30;
                var transportPrefab = CalPrefabFactory.GetAirTransport(cargoSize);
                DuckUtils.SpawnInGravity(positionToSpawn, gravity, factionId, transportPrefab.PrefabName,
                                         transportPrefab.InitialBeaconName,
                                         Vector3D.Normalize(baseToSpawnAt.WorldMatrix.Forward));
            }
            else
            {
                var positionToSpawn = spawnerPosition + gravity * -1f + baseToSpawnAt.WorldMatrix.Forward * 35;
                var transportPrefab = CalPrefabFactory.GetGroundTransport(cargoSize);
                DuckUtils.SpawnInGravity(positionToSpawn, gravity, factionId, transportPrefab.PrefabName,
                                         transportPrefab.InitialBeaconName,
                                         Vector3D.Normalize(baseToSpawnAt.WorldMatrix.Forward));
            }
        }
        public void Update1()
        {
            if (!arePlayersNear)
            {
                return;
            }

            // TODO: need a reference to the whole base grid to properly determine ownership
            if (!remoteControl.IsControlledByFaction("GCORP"))
            {
//				return; // No point bothering to remove from the list, it will disappear next time the game reloads
            }

            double useRange = Range * 2;

            useRange = Math.Min(Range, 800);
            var player = DuckUtils.GetNearestPlayerToPosition(rotorMountedGrid.GetPosition(), useRange);

            if (player == null)
            {
                return;
            }

            if (rotorMountedGrid.HasUsableGun())
            {
                TurnToFacePosition(player.GetPosition());
            }
            else
            {
                rotorMountedGrid.AttemptSelfDestruct();
            }
        }
示例#6
0
        private void SpawnConvoy(IMyShipController baseToSpawnAt)
        {
            var factionId       = baseToSpawnAt.OwnerId;
            var spawnerPosition = baseToSpawnAt.GetPosition();
            var gravity         = baseToSpawnAt.GetNaturalGravity();
            var unitType        = baseToSpawnAt.CustomName.Contains("GROUND") ? UnitType.Ground : UnitType.Air;
            var cargoSize       = heatSystem.GenerateCargoShipSize();

            //TODO: Should let base define the convoy spawn points
            //TODO: gravity is not normalized and is being used to scale the spawn point...  It should be normalized and then meters used to modify.
            // NOTE: The .Forward IS normalized, so the scalar is in meters.
            if (unitType == UnitType.Air)
            {
                var positionToSpawn = spawnerPosition + gravity * -5f + baseToSpawnAt.WorldMatrix.Forward * 30;
                var transportPrefab = PrefabGrid.GetAirTransport(cargoSize);
                DuckUtils.SpawnInGravity(positionToSpawn, gravity, factionId, transportPrefab.PrefabName,
                                         transportPrefab.InitialBeaconName,
                                         Vector3D.Normalize(baseToSpawnAt.WorldMatrix.Forward));
            }
            else
            {
                var positionToSpawn = spawnerPosition + gravity * -1f + baseToSpawnAt.WorldMatrix.Forward * 35;
                var transportPrefab = PrefabGrid.GetGroundTransport(cargoSize);
                DuckUtils.SpawnInGravity(positionToSpawn, gravity, factionId, transportPrefab.PrefabName,
                                         transportPrefab.InitialBeaconName,
                                         Vector3D.Normalize(baseToSpawnAt.WorldMatrix.Forward));
            }
        }
示例#7
0
        public void Update1()
        {
            if (!arePlayersNear)
            {
                return;
            }

            if (!remoteControl.IsControlledByFaction("GCORP"))
            {
                return;                 // No point bothering to remove from the list, it will disappear next time the game reloads
            }

//            var player = DuckUtils.GetNearestPlayerToPosition(position, 300);
            var player = DuckUtils.GetNearestPlayerToPosition(rotorMountedGrid.GetPosition(), 100);

            if (player == null)
            {
                return;
            }

            if (rotorMountedGrid.HasUsableGun())
            {
                TurnToFacePosition(player.GetPosition());
            }
            else
            {
                rotorMountedGrid.AttemptSelfDestruct();
            }
        }
示例#8
0
        // after loading of saved data
        protected override void InitHostPostLoading(IModSystemRegistry modSystemRegistry)
        {
            ModLog.Info("Original world was loaded by Version:" + modBuildWhenGameStarted.ToString());
            ModLog.Info("Loaded world was saved by Version:" + modBuildWhenLastSaved.ToString());

            npcGroupManager.SetBuildWhenSaved(modBuildWhenLastSaved);

            researchHacking.InitHackingLocations(); // Uses research restrictions and save data
            DuckUtils.MakePeaceBetweenFactions("MIKI", "CRASH");
            DuckUtils.MakePeaceBetweenFactions("MIKI", "GCORP");

            //V27 for SE 1.192
            DuckUtils.RemoveFaction("SPRT");
            DuckUtils.SetAllPlayerReputation("MIKI", 0);

            audioSystem.AudioRelay = networkComms;
            networkComms.StartWipeHostToolbar();
            modSystemRegistry.AddRapidUpdatableModSystem(turretManager);
            modSystemRegistry.AddUpatableModSystem(researchHacking);
            modSystemRegistry.AddUpatableModSystem(missionSystem);
            modSystemRegistry.AddUpatableModSystem(mikiScrapManager);
            modSystemRegistry.AddUpatableModSystem(npcGroupManager);
            modSystemRegistry.AddUpatableModSystem(baseManager);
            modSystemRegistry.AddUpatableModSystem(convoySpawner);
        }
示例#9
0
        public override void GridInitialising(IMyCubeGrid grid)
        {
            BlocksFixup(grid);

            if (grid.IsStatic && grid.IsControlledByFaction("GCORP"))
            {
                var slimBlocks = new List <IMySlimBlock>();
                grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyRemoteControl);
                foreach (var slim in slimBlocks)
                {
                    var remoteControl = slim.FatBlock as IMyRemoteControl;
                    if (remoteControl.IsControlledByFaction("GCORP") &&
                        remoteControl.CustomName.Contains("DELIVERY")   // AIR_DELIVERY_SPAWNER // GROUND_DELIVERY_SPAWNER //Remote Control
                        )
                    {
                        var planet = DuckUtils.FindPlanetInGravity(remoteControl.GetPosition());

                        if (planet == null)
                        {
                            continue; // Space bases not yet supported.
                        }
                        bases.Add(new GCorpBase(remoteControl, ZeroDate, planet, heatSystem, audioSystem));
                        return; // Accepted grid, no need to keep looping
                    }
                }
            }
        }
示例#10
0
        public override void AllGridsInitialised()
        {
            // add unlock points
            ModLog.Info("Found " + unlockLocationList.Count().ToString() + " Unlock locations");
            foreach (var unlockLocation in unlockLocationList)
            {
                AddHackingLocation((TechGroup)unlockLocation.techGroup, unlockLocation.location, unlockLocation.unlockradius);

                if (researchControl.bDebugLocations)
                {
                    string name = "PBUnlock " + unlockLocation.techGroup.ToString();
                    DuckUtils.AddGpsToAllPlayers(name, "PB Unlock location", unlockLocation.location);
                }
            }
            // all grids have been loaded during game load.
            researchControl.AllowUnlockedTechs();


            //
            if (researchControl.bDebugLocations)
            {
                foreach (var unlockLocation in hackingLocations)
                {
                    string name = "Unlock " + unlockLocation.TechGroup.ToString();
                    DuckUtils.AddGpsToAllPlayers(name, "Unlock location", unlockLocation.Coords);
                }
            }
        }
示例#11
0
        public void Update60()
        {
            if (!remoteControl.IsControlledByFaction("GCORP"))
            {
//				return; // No point bothering to remove from the list, it will disappear next time the game reloads
            }

            /*
             * TODO:
             * refill weapon inventory (if designated?)
             * sequence shooting when multiple on same sub-grid
             * appropriate sequencing for missile launchers
             */
            playerTarget = DuckUtils.GetNearestPlayerToPosition(bodyGrid.GetPosition(), Range);
            if (playerTarget != null)
            {
//MyAPIGateway.Utilities.ShowNotification("Found Player: " + info.Type, 2000, MyFontEnum.DarkBlue);

                IHitInfo hitInfo;
                if (MyAPIGateway.Physics.CastLongRay(weapons[0].GetPosition(), playerTarget.GetPosition(), out hitInfo, false))
                {
                    if (!spoken)
                    {
                        bodyGrid.PlaySoundBlocks();
                        spoken = true;
                    }

                    if (timeSincePlayerSeen < 3)
                    {
                        timeSincePlayerSeen++;
                        return;
                    }

                    var info = MyDetectedEntityInfoHelper.Create((MyEntity)hitInfo.HitEntity, remoteControl.OwnerId, hitInfo.Position);
                    if (info.Relationship == MyRelationsBetweenPlayerAndBlock.Enemies ||
                        info.Relationship == MyRelationsBetweenPlayerAndBlock.NoOwnership ||
                        info.Relationship == MyRelationsBetweenPlayerAndBlock.Neutral)
                    {
                        SetWeaponsShooting(true);
                    }
                    else
                    {
                        SetWeaponsShooting(false);
                    }
//					MyAPIGateway.Utilities.ShowNotification("Hit: " + info.Type, 2000, MyFontEnum.DarkBlue);
//					MyAPIGateway.Utilities.ShowNotification("Relation: " + info.Relationship, 2000, MyFontEnum.DarkBlue);
                }
                else
                {
                    SetWeaponsShooting(true);
                }
            }
            else
            {
                SetWeaponsShooting(false);
                StopAllRotors();
            }
        }
示例#12
0
        public void Update60()
        {
            double useRange = Range * 4;

            useRange = Math.Min(Range, 800);
            var player = DuckUtils.GetNearestPlayerToPosition(rotorMountedGrid.GetPosition(), useRange);

            arePlayersNear = player != null;
        }
示例#13
0
        public override void GridInitialising(IMyCubeGrid grid)
        {
            /* Try to fix text not showing on text panels
             *
             * (on further testing, panels are showing.. maybe Keen fixed this themselves?)
             *
             * Saw on Rity's stream that they were NOT showing in all places.
             * And on EpikTek's https://www.youtube.com/watch?v=CkpGGPZd78k
             * */
            var slimBlocks2 = new List <IMySlimBlock>();

            grid.GetBlocks(slimBlocks2, b => b.FatBlock is IMyTextPanel);
            foreach (var slim in slimBlocks2)
            {
                var  textPanel = slim.FatBlock as IMyTextPanel;
                bool bShow     = textPanel.GetValueBool("ShowTextOnScreen");
                //                bool bShow = textPanel.ShowOnScreen != VRage.Game.GUI.TextPanel.ShowTextOnScreenFlag.NONE;
                if (bShow)
                {
                    textPanel.SetValue("ShowTextOnScreen", false);
                    //                     textPanel.SetShowOnScreen(VRage.Game.GUI.TextPanel.ShowTextOnScreenFlag.NONE);
                    textPanel.SetValue("ShowTextOnScreen", true);
                    //                      textPanel.SetShowOnScreen(VRage.Game.GUI.TextPanel.ShowTextOnScreenFlag.PUBLIC);
                }
                else
                {
                    // TODO: go through entityIDs and fix up graphics references
                }
            }


            //			if (grid.IsStatic && grid.IsControlledByFaction("GCORP"))
            {
                var slimBlocks = new List <IMySlimBlock>();
                grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyRemoteControl);
                foreach (var slim in slimBlocks)
                {
                    var remoteControl = slim.FatBlock as IMyRemoteControl;
//					if (remoteControl.IsControlledByFaction("GCORP"))
//TODO: use another method to determine NPC bases.
                    {
                        var planet = DuckUtils.FindPlanetInGravity(remoteControl.GetPosition());

                        if (planet == null)
                        {
                            continue;                             // Space bases not yet supported.
                        }

                        //TODO determine faction owner in above code
                        bases.Add(new GCorpBase(remoteControl, ZeroDate, planet, audioSystem, CalFactions.Gcorp));
                        return;                         // Accepted grid, no need to keep looping
                    }
                }
            }
        }
示例#14
0
        private void SpawnEscortGrid(PrefabGrid prefabGrid, Vector3D naturalGravity, EscortPosition escortPosition,
                                     UnitType convoyUnitType, IMyCubeGrid convoyLeaderGrid)
        {
            var positionToSpawn = Convoy.GetEscortPositionVector(convoyLeaderGrid, naturalGravity, escortPosition,
                                                                 GetAdditionalHeightModifier(convoyUnitType));
            var factionId = convoyLeaderGrid.GetGridControllerFaction();
            var forwards  = convoyLeaderGrid.WorldMatrix.Forward;

            DuckUtils.SpawnInGravity(positionToSpawn, naturalGravity, factionId, prefabGrid.PrefabName,
                                     prefabGrid.InitialBeaconName, forwards);
        }
示例#15
0
        public void Update60()
        {
//            var player = DuckUtils.GetNearestPlayerToPosition(position, 500);
            // change in EFM V 10: allow moveable custom turrets
            var player = DuckUtils.GetNearestPlayerToPosition(rotorMountedGrid.GetPosition(), 300);

            arePlayersNear = player != null;

            // NOTE: gun is shot by sensor on gun turret..
            // so max range of gun is only 50m since that's max range of sensor...
        }
示例#16
0
        protected override void InitClient(IModSystemRegistry modSystemRegistry)
        {
            var player = MyAPIGateway.Session.Player;

            if (player != null)
            {
                networkComms.NotifyServerClientJoined(player);

                DuckUtils.PutPlayerIntoFaction("CRASH"); // V28
            }
        }
示例#17
0
        public void Update60()
        {
            // TODO: need a reference to the whole base grid to properly determine ownership
            if (!remoteControl.IsControlledByFaction("GCORP"))
            {
//				return; // No point bothering to remove from the list, it will disappear next time the game reloads
            }

            playerTarget = DuckUtils.GetNearestPlayerToPosition(bodyGrid.GetPosition(), Range);
            if (playerTarget != null)
            {
                IHitInfo hitInfo;
                if (MyAPIGateway.Physics.CastLongRay(weapons[0].GetPosition(), playerTarget.GetPosition(), out hitInfo, false))
                {
                    if (!spoken)
                    {
                        bodyGrid.PlaySoundBlocks();
                        spoken = true;
                    }

                    if (timeSincePlayerSeen < 3)
                    {
                        timeSincePlayerSeen++;
                        return;
                    }

                    var info = MyDetectedEntityInfoHelper.Create((MyEntity)hitInfo.HitEntity, remoteControl.OwnerId, hitInfo.Position);
                    if (info.Relationship == MyRelationsBetweenPlayerAndBlock.Enemies ||
                        info.Relationship == MyRelationsBetweenPlayerAndBlock.NoOwnership ||
                        info.Relationship == MyRelationsBetweenPlayerAndBlock.Neutral)
                    {
                        SetWeaponsShooting(true);
                    }
                    else
                    {
                        SetWeaponsShooting(false);
                    }
                    //	MyAPIGateway.Utilities.ShowNotification("Hit: " + info.Type, 2000, MyFontEnum.DarkBlue);
                    //	MyAPIGateway.Utilities.ShowNotification("Relation: " + info.Relationship, 2000, MyFontEnum.DarkBlue);
                }
                else
                {
                    SetWeaponsShooting(true);
                }
            }
            else
            {
                SetWeaponsShooting(false);
                StopAllRotors();
            }
        }
示例#18
0
        protected static bool AttemptDespawn(IMyCubeGrid grid)
        {
            if (!grid.IsControlledByNpcFaction())
            {
                return(true);                // If we are not GCorp don't try to despawn, we may be wreckage or player hijacked
            }

            if (!DuckUtils.IsAnyPlayerNearPosition(grid.GetPosition(), 1750))
            {
                grid.CloseAll();
                return(true);
            }

            return(false);
        }
示例#19
0
        protected static bool AttemptDespawn(IMyCubeGrid grid, Int32 minplayerdistance = 1750)
        {
            if (!grid.IsControlledByFaction("GCORP"))
            {
                return(true);                // If we are not GCorp don't try to despawn, we may be wreckage or player hijacked
            }

            // if player is 'near' base, then disabled drones near the base won't be despawned
            //			if (!DuckUtils.IsAnyPlayerNearPosition(grid.GetPosition(), 1750))

            // V26
            if (!DuckUtils.IsAnyPlayerNearPosition(grid.GetPosition(), minplayerdistance))
            {
                grid.CloseAll();
                return(true);
            }

            return(false);
        }
示例#20
0
        internal void Update()
        {
            if (timeSinceSpoken == -2)
            {
                if (DuckUtils.GetNearestPlayerToPosition(speaker.GetPosition(), 3000) != null)
                {
                    audioSystem.PlayAudio(CalAudioClip.GreetingsMartianColonists);
                    timeSinceSpoken = -1;
                }

                return;
            }

            var playerVisiting = DuckUtils.GetNearestPlayerToPosition(speaker.GetPosition(), 50) != null;

            if (timeSinceSpoken == -1 && playerVisiting)
            {
                audioSystem.PlayAudio(CalAudioClip.WelcomeMikiScrap);
                timeSinceSpoken = AudioCommentTime;
            }
            else if (timeSinceSpoken >= 0 && timeSinceSpoken < AudioMaxTime)
            {
                timeSinceSpoken++;
            }
            else if (timeSinceSpoken == AudioMaxTime && playerVisiting)
            {
                audioSystem.PlayAudioRandomChance(1.0, CalAudioClip.TellAllFriends, CalAudioClip.TiredOfGrindingCrap,
                                                  CalAudioClip.NewMikiScrapsOpen);
                timeSinceSpoken = AudioCommentTime;
            }

            var scrap = scrapIn.GetItemAmount(scrapMetal);

            if (scrap > 0)
            {
                ProcessScrap(scrap > 500 ? 500 : scrap);
            }

            if (playerVisiting)
            {
                UpdateFurnaceState();
            }
        }
示例#21
0
        private void SpawnUndergroundDefense(IMyPlayer player)
        {
            var playerPos            = player.GetPosition();
            var playerNaturalGravity = marsPlanet.GetGravityAtPoint(playerPos);
            var vng = playerNaturalGravity;

            vng.Normalize();

            var surface      = marsPlanet.GetClosestSurfacePointGlobal(player.GetPosition());
            var belowsurface = Vector3D.Distance(playerPos, surface);

            //            ModLog.Info("Below Surface=" + belowsurface.ToString("0.00"));

            var up = 50 + belowsurface; // 150m above the surface
//            var up = 150 + belowsurface; // 150m above the surface
            var locationToSpawn = playerPos + vng * -up;

            var naturalGravityAtSpawn = marsPlanet.GetGravityAtPoint(locationToSpawn);

//            DuckUtils.AddGpsToAllPlayers("Location to Spawn", "Above player", locationToSpawn);

            var spawnLocation = MyAPIGateway.Entities.FindFreePlace(locationToSpawn, 10, 20, 5, 10);

            if (spawnLocation.HasValue)
            {
                PrefabGrid bomb = PrefabGrid.GetBomb();
                DuckUtils.SpawnInGravity(spawnLocation.Value, naturalGravityAtSpawn, RemoteControl.OwnerId,
                                         bomb.PrefabName, bomb.InitialBeaconName);

                //DEBUG
//                DuckUtils.AddGpsToAllPlayers("Bomb Spawn", "bomb for player", spawnLocation.Value);
//                ModLog.Info("Spawning Bomb!");
            }
            else
            {
                ModLog.DebugError("Couldn't spawn bomb!", locationToSpawn);
            }
        }
示例#22
0
        private void SpawnHelperPatrol(IMyPlayer player)
        {
            var playerPos             = player.GetPosition();
            var playerNaturalGravity  = marsPlanet.GetGravityAtPoint(playerPos);
            var perpendicularDistance = MyUtils.GetRandomPerpendicularVector(ref playerNaturalGravity) * 400;         //4km away NOTE: since mars NG is not 1.0, it's NOT 4km
            var locationToSpawnPatrol = playerPos + perpendicularDistance + playerNaturalGravity * -200f;             // 2km up
            var naturalGravityAtSpawn = marsPlanet.GetGravityAtPoint(locationToSpawnPatrol);

            var spawnLocation = MyAPIGateway.Entities.FindFreePlace(locationToSpawnPatrol, 10, 20, 5, 10);

//            ModLog.Info("Spawning helper patrol. perpD=" + perpendicularDistance.ToString("N2"));

            if (spawnLocation.HasValue)
            {
                PrefabGrid backup = PrefabGrid.GetBackup(heatSystem.GenerateBackupShipSize());
                DuckUtils.SpawnInGravity(spawnLocation.Value, naturalGravityAtSpawn, RemoteControl.OwnerId,
                                         backup.PrefabName, backup.InitialBeaconName);
            }
            else
            {
                ModLog.DebugError("Couldn't spawn backup!", locationToSpawnPatrol);
            }
        }
示例#23
0
        private void SpawnHelperPatrol(IMyPlayer player)
        {
            var playerPos            = player.GetPosition();
            var playerNaturalGravity = marsPlanet.GetGravityAtPoint(playerPos);
            //TODO does perpendicularDistance maybe need to be normalised?
            // TODO: use faction info from faction definition.
            var perpendicularDistance = MyUtils.GetRandomPerpendicularVector(ref playerNaturalGravity) * 400; //4km away
            var locationToSpawnPatrol = playerPos + perpendicularDistance + playerNaturalGravity * -200f;     // 2km up
            var naturalGravityAtSpawn = marsPlanet.GetGravityAtPoint(locationToSpawnPatrol);

            var spawnLocation = MyAPIGateway.Entities.FindFreePlace(locationToSpawnPatrol, 10, 20, 5, 10);

            if (spawnLocation.HasValue)
            {
                PrefabGrid backup = faction.Ships.GetBackupShip();
                DuckUtils.SpawnInGravity(spawnLocation.Value, naturalGravityAtSpawn, RemoteControl.OwnerId,
                                         // TODO: use faction info from faction definition.
                                         backup.PrefabName, backup.InitialBeaconName);
            }
            else
            {
                ModLog.DebugError("Couldn't spawn backup!", locationToSpawnPatrol);
            }
        }
示例#24
0
        internal void Update()
        {
            if (!RemoteControl.IsControlledByFaction("GCORP"))
            {
                // V26
                if (!bLostProcessed)
                {
                    // first time processing
                    bLostProcessed = true;

                    // TODO: maybe do something else.
                    // maybe turn OFF all turrets
                    // explode all warheads?

                    // if base is 'lost' increase heat level
                    heatSystem.BaseCaptured();

                    // ?play audio (from mabel?) announcing base captured.
                }

                return; // Maybe remove from list of bases?
            }

            // TODO: get this value from base itself instead of hard-coding?
            var player = DuckUtils.GetNearestPlayerToPosition(RemoteControl.GetPosition(), 1300);

            // turn turrets off on bases if no player is nearby to save simspeed hits
            if (player != null)
            {
                foreach (var turret in turrets)
                {
                    turret.Enabled = true;
                }
            }
            else
            {
                foreach (var turret in turrets)
                {
                    turret.Enabled = false;
                }
            }

            int nPlayers     = 0; // number of players in range
            var playerClose1 = DuckUtils.GetNearestPlayerToPosition(RemoteControl.GetPosition(), 1200, out nPlayers);

            if (!DebugStopBackupGroups && playerClose1 != null)
            {
                if (lastBackupRespondTime + BackupTimeDelay < MyAPIGateway.Session.GameDateTime)
                {
                    //                   ModLog.Info("Heat Difficulty: " + heatSystem.HeatDifficulty);

                    // TODO: if player is INSIDE base, then do something else?
                    // V26: If player is underground, then do something else?
                    var players = new List <IMyPlayer>();
                    MyAPIGateway.Players.GetPlayers(players);
                    foreach (var aplayer in players)
                    {
                        // check each player

                        var controlled = aplayer.Controller.ControlledEntity;
                        if (controlled == null)
                        {
                            continue;
                        }
                        var distSq = Vector3D.DistanceSquared(RemoteControl.GetPosition(), controlled.Entity.GetPosition());
                        if (distSq < 100 * 100) //V29
                        {
                            if (DuckUtils.IsPlayerUnderCover(aplayer))
                            { // player is under cover 'near' the base..
                            }
                        }
                        else if (distSq < 1000 * 1000)
                        { // betwee 100->1000
                            if (DuckUtils.IsPlayerUnderground(aplayer))
                            {
                                // player is underground
                                if (heatSystem.HeatDifficulty > 1)
                                {                                     // only if difficulty is above default
//                                    ModLog.Info("Spawning Bomber");
                                    SpawnUndergroundDefense(aplayer); // on top of player
                                    // if we do this, then ground has lost integrity.. make it into an air base
                                    if (RemoteControl.CustomName.Contains("GROUND"))
                                    {
                                        RemoteControl.CustomName.Replace("GROUND", "AIR");
                                    }
                                }
                            }
                        }
                    }

//                    ModLog.Info("Backup Player Close 1");
                    SpawnHelperPatrol(playerClose1);

                    // if higher difficulty and player(s) get closer, then spawn more backup per backup event
                    if (heatSystem.HeatDifficulty > 1 || (heatSystem.MultiplayerScaling && nPlayers > 1))
                    {
                        var playerClose2 = DuckUtils.GetNearestPlayerToPosition(RemoteControl.GetPosition(), 800);
                        if (playerClose2 != null)
                        {
                            SpawnHelperPatrol(playerClose2);
//                            ModLog.Info("Backup Player Close 2");
                        }
                    }
                    if (heatSystem.HeatDifficulty > 3 || (heatSystem.MultiplayerScaling && nPlayers > 3))
                    {
                        var playerClose3 = DuckUtils.GetNearestPlayerToPosition(RemoteControl.GetPosition(), 300);
                        if (playerClose3 != null)
                        {
                            SpawnHelperPatrol(playerClose3);
//                            ModLog.Info("Backup Player Close 4");
                        }
                    }
                    lastBackupRespondTime = MyAPIGateway.Session.GameDateTime;
                    audioSystem.PlayAudio(AudioClip.FacilityDetectedHostile, AudioClip.GCorpFacilityThreatened);
                    waitingOnBackup = true;
                }
            }
        }
示例#25
0
        private void GiveOrdersToUnassignedShips()
        {
            while (unitialisedNewGrids.Count > 0)
            {
                var grid = unitialisedNewGrids.Dequeue();
                if (!grid.IsControlledByNpcFaction())
                {
                    continue;
                }

                var roleAndUnitType = PrefabGrid.GetRoleAndUnitType(grid);
                if (roleAndUnitType == null)
                {
                    continue;
                }

                var unitType = roleAndUnitType.Value.UnitType;

                switch (roleAndUnitType.Value.UnitRole)
                {
                case UnitRole.Delivery:
                    var cargoType = CargoType.GenerateRandomCargo(random);
                    LoadCargo(grid, cargoType);
                    grid.SetAllBeaconNames("T" + random.Next(10000, 99999) + " - " + cargoType.GetDisplayName() + " Shipment",
                                           20000f);
                    var destination = unitType == UnitType.Air ? airConvoyDestinationPosition : groundConvoyDestinationPosition;
                    SetDestination(grid, destination);
                    RegisterConvoy(grid, NpcGroupState.Travelling, unitType, destination, MyAPIGateway.Session.GameDateTime);

                    var planet = DuckUtils.FindPlanetInGravity(grid.GetPosition());
                    if (planet != null)
                    {
                        CalFactions.Gcorp.Ships.SpawnConvoyEscorts(grid, unitType, planet);
                    }
                    break;

                case UnitRole.Escort:
                    var group = FindNearestJoinableNpcGroup(grid.GetPosition(), unitType);
                    if (group == null)
                    {
                        ModLog.Error("Escort ship spawned but can't find a group to join!");
                        grid.CloseAll();
                    }
                    else
                    {
                        grid.SetAllBeaconNames("E" + random.Next(10000, 99999) + " - Convoy Escort", 20000f);
                        var nearestPlanet = DuckUtils.FindPlanetInGravity(grid.GetPosition());
                        if (nearestPlanet != null)
                        {
                            group.JoinAsEscort(grid, unitType, nearestPlanet);
                        }
                    }
                    break;

                case UnitRole.Backup:
                    var gCorpBase = baseManager.FindBaseWantingBackup();
                    if (gCorpBase == null)
                    {
                        ModLog.Error("Backup ship spawned but can't find the base that asked for it!");
                        grid.CloseAll();
                        break;
                    }
                    var backupPosition = gCorpBase.GetBackupPosition();
                    grid.SendToPosition(backupPosition);
                    grid.SetAllBeaconNames("M" + random.Next(10000, 99999) + " Investigating Backup Call", 20000f);
                    var backupGroup = new BackupGroup(NpcGroupState.Travelling, backupPosition, grid,
                                                      heatSystem, audioSystem, MyAPIGateway.Session.GameDateTime);
                    //damageSensor.RegisterDamageObserver(grid.EntityId, backupGroup);
                    npcGroups.Add(backupGroup);
                    break;

                default:
                    continue;
                }
            }
        }
示例#26
0
        private void GiveOrdersToUnassignedShips()
        {
            bool bFoundBackup = false;

            while (unitialisedNewGrids.Count > 0)
            {
                var grid = unitialisedNewGrids.Dequeue();
                if (!grid.IsControlledByFaction("GCORP"))
                {
                    continue;
                }

                var roleAndUnitType = PrefabGrid.GetRoleAndUnitType(grid);
                if (roleAndUnitType == null)
                {
                    // V26 debug
                    ModLog.Info("Discarding grid because no role found");
                    continue;
                }

                var unitType = roleAndUnitType.Value.UnitType;

                switch (roleAndUnitType.Value.UnitRole)
                {
                case UnitRole.Delivery:
                    var cargoType = CargoType.GenerateRandomCargo(random);
                    LoadCargo(grid, cargoType);

                    if (cargoType.subtypeName == "SteelPlate")
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.SteelPlateConvoyDispatched, AudioClip.ConvoyDispatched1);
                    }
                    else if (cargoType.subtypeName == "MetalGrid")
                    {
                        audioSystem.PlayAudioRandomChance(1, AudioClip.MetalGridConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Construction")
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.ConstructionConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "InteriorPlate")
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.InteriorPlateConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Girder")
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.GirderConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "SmallTube")
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.SmallTubeConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "LargeTube")
                    {
                        audioSystem.PlayAudioRandomChance(0.2, AudioClip.LargeTubeConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Motor")
                    {
                        audioSystem.PlayAudioRandomChance(0.75, AudioClip.MotorConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Display")
                    {
                        audioSystem.PlayAudioRandomChance(0.2, AudioClip.DisplayConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "BulletproofGlass")
                    {
                        audioSystem.PlayAudioRandomChance(0.3, AudioClip.BulletproofGlassConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Computer")
                    {
                        audioSystem.PlayAudioRandomChance(0.2, AudioClip.ComputerConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Reactor")
                    {
                        audioSystem.PlayAudioRandomChance(0.75, AudioClip.ReactorConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Medical")
                    {
                        audioSystem.PlayAudioRandomChance(0.7, AudioClip.MedicalConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "RadioCommunication")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.RadioCommunicationConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Explosives")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.ExplosivesConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "SolarCell")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.SolarCellConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "PowerCell")
                    {
                        audioSystem.PlayAudioRandomChance(0.75, AudioClip.PowerCellConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "NATO_5p56x45mm")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.NATO_5p56x45mmConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "NATO_25x184mm")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.NATO25x184mmConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Missile200mm")
                    {
                        audioSystem.PlayAudioRandomChance(0.5, AudioClip.Missile200mmConvoyDispatched);
                    }
                    else if (cargoType.subtypeName == "Uranium")
                    {
                        audioSystem.PlayAudioRandomChance(1, AudioClip.UraniumConvoyDispatched);
                    }
                    else      // we don't know what it is..
                    {
                        audioSystem.PlayAudioRandomChance(0.1, AudioClip.ConvoyDispatched1, AudioClip.ConvoyDispatched2, AudioClip.ConvoyDispatched3);
                    }

                    string sPrefix = "T";
                    if (unitType == UnitType.Air)
                    {
                        sPrefix += "A";
                    }
                    else
                    {
                        sPrefix += "G";
                    }

                    grid.SetAllBeaconNames(sPrefix + random.Next(10000, 99999) + " - " + cargoType.GetDisplayName() + " Shipment",
                                           200f);              // V31 set short until initialize check timeout
                    var destination = unitType == UnitType.Air ? airConvoyDestinationPosition : groundConvoyDestinationPosition;

//                        ModLog.Info("Air Destination=" + airConvoyDestinationPosition.ToString());
//                        ModLog.Info("GND Destination=" + groundConvoyDestinationPosition.ToString());
//                        ModLog.Info("Chosen Dest=" + destination.ToString());
                    SetDestination(grid, destination);
                    RegisterConvoy(grid, NpcGroupState.Travelling, unitType, destination, MyAPIGateway.Session.GameDateTime);

                    var planet = DuckUtils.FindPlanetInGravity(grid.GetPosition());
                    if (planet != null)
                    {
                        convoySpawner.SpawnConvoyEscorts(grid, unitType, planet);
                    }
                    break;

                case UnitRole.Escort:
                    var group = FindNearestJoinableNpcGroup(grid.GetPosition(), unitType);
                    if (group == null)
                    {
                        ModLog.Error("Escort ship spawned but can't find a group to join!");
                        grid.CloseAll();
                    }
                    else
                    {
                        grid.SetAllBeaconNames("E" + random.Next(10000, 99999) + " - " + EscortName, 2500f);                                 // V31 shorten escort beacon range to decrease hud spam
                        var nearestPlanet = DuckUtils.FindPlanetInGravity(grid.GetPosition());
                        if (nearestPlanet != null)
                        {
                            group.JoinAsEscort(grid, unitType, nearestPlanet);
                        }
                    }
                    break;

                case UnitRole.Backup:
                    var gCorpBase = baseManager.FindBaseWantingBackup();
                    // V26
                    bFoundBackup = true;

                    if (gCorpBase == null)
                    {
                        gCorpBase = baseManager.FindBaseNear(grid.GetPosition());
                    }

                    if (gCorpBase == null)
                    {
                        ModLog.Error("Backup ship spawned but can't find the base that asked for it!");
                        grid.CloseAll();
                        break;
                    }
                    var backupPosition = gCorpBase.GetBackupPosition();
                    grid.SendToPosition(backupPosition);
                    // backup debug
                    string sBeacon = "M" + random.Next(10000, 99999) + " Investigating Backup Call";
//                        ModLog.Info("Backup Found:" + sBeacon);
//                        ModLog.Info(" Destination=" + backupPosition.ToString());
                    grid.SetAllBeaconNames(sBeacon, 20000f);
                    var backupGroup = new BackupGroup(NpcGroupState.Travelling, backupPosition, grid,
                                                      heatSystem, audioSystem, MyAPIGateway.Session.GameDateTime);
                    //damageSensor.RegisterDamageObserver(grid.EntityId, backupGroup);
                    npcGroups.Add(backupGroup);
                    break;

                case UnitRole.Bomb:
                    bool hasSensors = false;
                    var  slimBlocks = new List <IMySlimBlock>();
                    grid.GetBlocks(slimBlocks, b => b.FatBlock is IMySensorBlock);
                    if (slimBlocks.Count > 0)
                    {
                        hasSensors = true;
                    }


                    grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyWarhead);
                    foreach (var slim in slimBlocks)
                    {
                        var wh = slim.FatBlock as IMyWarhead;
                        wh.IsArmed = true;
                        if (!hasSensors)    // if no sensors, start the countdown
                        {
                            ModLog.Info("BOMB: no sensors: Starting timer");
                            wh.StartCountdown();
                        }
                    }
                    break;

                default:
                    continue;
                }
            }
            if (bFoundBackup)
            {
                baseManager.ClearBaseBackupRequests();
            }
        }
示例#27
0
        internal override void Update()
        {
            if (!leader.IsControlledByFaction("GCORP"))
            {
                leader     = null;
                GroupState = NpcGroupState.Disbanded;
                return;
            }
//            ModLog.Info("Backup:" + leader.EntityId.ToString() + " " + GroupState.ToString());

            if ((GroupState == NpcGroupState.Travelling || GroupState == NpcGroupState.ReturningForRepairs) &&
                Vector3D.DistanceSquared(Destination, leader.GetPosition()) < 40.0 * 40.0)
            {
                // it arrives at destination.  and nothing... get rid of it.
//                ModLog.Info(" Backup arrived at base/target and nothing found.  Disbanding");
                GroupState = NpcGroupState.Disbanding;
            }


            if (GroupState == NpcGroupState.Disbanding)
            {
                var isArmed = leader.HasUsableGun();
                if (AttemptDespawn(leader, 200))                //V26
                {
                    leader     = null;
                    GroupState = NpcGroupState.Disbanded;
                    if (isArmed)
                    {
                        ArrivalObserver.GroupArrivedIntact();
                    }
                }
                return;
            }

            if (DuckUtils.IsAnyPlayerNearPosition(leader.GetPosition(), 2000) && //V29 1000->2000  Backups were getting disbanded when player between 1000 and max spawn distance.
                (GroupState == NpcGroupState.Travelling || GroupState == NpcGroupState.Disbanding))
            {
                GroupState = NpcGroupState.InCombat;
//                ModLog.Info("Backup:" + leader.EntityId.ToString() + " Found Target:" + GroupState.ToString());
                leader.SetLightingColors(Color.Red);
                leader.RemoveFromFirstBeaconName(ReturningToBase);
                leader.AppendToFirstBeaconName(InterceptingBeaconSuffix);
                audioSystem.PlayAudio(AudioClip.TargetFoundDronesAttack, AudioClip.TargetIdentifiedUnitsConverge);
            }
            // todo: if no player nearby go searching for player vehicles near base/convoy
            // todo: if can't target player after a delay (or player under cover?), search for player vehicles near current location

            if (GroupState == NpcGroupState.InCombat)
            {
                if (!leader.HasUsableGun())
                {
//                    GroupState = NpcGroupState.Disbanding;
                    GroupState = NpcGroupState.ReturningForRepairs; //V29
//                    ModLog.Info("Backup:" + leader.EntityId.ToString() + " No Gun." + GroupState.ToString());
                    leader.SetLightingColors(GcorpBlue);
                    leader.RemoveFromFirstBeaconName(" Investigating Backup Call"); // match text in NpcGroupManager
                    leader.RemoveFromFirstBeaconName(InterceptingBeaconSuffix);
                    leader.AppendToFirstBeaconName(ReturningToBase);
                    leader.SendToPosition(Destination);
                    audioSystem.PlayAudio(AudioClip.DroneDisarmed);
                    // disbanding, but for backups we want to extra penalize for killing unit
                    heat.BackupDisabled();
                }
                else
                {
                    var player = DuckUtils.GetNearestPlayerToPosition(leader.GetPosition(), 2000);                     //V29 1250->2000
                    if (player == null)
                    {
                        GroupState = NpcGroupState.Disbanding;                         // Return to normal, cowardly players have run off or died
//                        ModLog.Info("Backup:" + leader.EntityId.ToString() + " No Players in range after Combat mode." + GroupState.ToString());
                        leader.SetLightingColors(GcorpBlue);
                        leader.RemoveFromFirstBeaconName(InterceptingBeaconSuffix);
                        leader.AppendToFirstBeaconName(ReturningToBase);
                        leader.SendToPosition(Destination);
                        audioSystem.PlayAudio(AudioClip.HostileDisappeared, AudioClip.TargetFleeingPursuit);
                    }
                    else
                    {
                        float heightModifier = 15; // Change from 2 pre V26

                        // Added V26
                        if (DuckUtils.IsPlayerUnderCover(player))
                        {
                            heightModifier = 300;
                        }
                        leader.SendToPosition(player.GetPosition(), heightModifier);
                    }
                }
            }
        }
示例#28
0
        /// <summary>
        /// On grid creation, walk the grid and find terminal blocks of interest
        /// </summary>
        /// <param name="grid"></param>
        public override void GridInitialising(IMyCubeGrid grid)
        {
//            ModLog.Info("GridInit:"+grid.EntityId.ToString());
//            ModLog.Info(desiredEntityIDs.Count + " Desired Blocks");
            var slimBlocks = new List <IMySlimBlock>();

            if (grid.EntityId == 92770753627258475 && // crash ship
                modBuildWhenLastSaved < 27    // we haven't done this already
                )
            {
                /*
                 * // 77953268669314449 is oxygen tank.
                 * grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyGasTank);
                 * foreach (var slim in slimBlocks)
                 * {
                 *  IMyGasTank tb = slim.FatBlock as IMyGasTank;
                 *  tb.  nothing to call to set contents to zero :(
                 *
                 * }
                 */

                grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyCargoContainer);

                slimBlocks.Clear();
                grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyCargoContainer);

                //                ModLog.Info("Found Crash Ship on initial load:"+modBuildWhenLastSaved);

                /* SE 1.192 */
                var medkit   = MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_ConsumableItem>("Medkit");
                var powerkit = MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_ConsumableItem>("Powerkit");

                /*
                 * var datapad = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_Datapad>("Datapad");
                 * datapad.Data = "Wico Test\nGPS:Crash Site:1868092.62:-2003480.62:1316653.75:";
                 * datapad.Name = "Wico Name Test";
                 */
                var spacecredit = MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_PhysicalObject>("SpaceCredit");

                var powercells = MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_Component>("PowerCell");

                foreach (var slim in slimBlocks)
                {
                    IMyTerminalBlock tb = slim.FatBlock as IMyTerminalBlock;
//                    ModLog.Info("Cargo: " + tb.CustomName + " " + tb.EntityId);
                    if (tb == null)
                    {
                        continue;
                    }
                    if (tb.EntityId == 115310750474309501)    // Emergency Supplies
                    {
                        tb.CustomName = "Emergency Supplies"; // Not localized...
                        var cargoContainer = (IMyCargoContainer)slim.FatBlock;
                        //                        ModLog.Info("ESupplies LoadCargo: " + cargoContainer.CustomName);
                        var entity = cargoContainer as MyEntity;
                        if (entity.HasInventory)
                        {
                            MyInventory inventory = entity.GetInventoryBase() as MyInventory;
                            if (inventory == null)
                            {
                                continue;
                            }

                            DuckUtils.PlaceItemIntoCargo(inventory, medkit, 15);
                            DuckUtils.PlaceItemIntoCargo(inventory, powerkit, 15);
                            //                            PlaceItemIntoCargo(inventory, datapad, 1);
                            DuckUtils.PlaceItemIntoCargo(inventory, spacecredit, 42);
                        }
                    }
                    if (tb.EntityId == 80222532396731795) // spare parts
                    {
                        tb.CustomName = "Spare Parts";    // Not localized...
                        var cargoContainer = (IMyCargoContainer)slim.FatBlock;
                        //                        ModLog.Info("SpareParts LoadCargo: " + cargoContainer.CustomName);
                        //                        if(powercells!=null) ModLog.Info("Powercells=" + powercells.SubtypeName);
                        //                        else ModLog.Info("Powercells NULL!");
                        //                        MyLog.Default.Flush();
                        var entity = cargoContainer as MyEntity;
                        if (entity.HasInventory)
                        {
                            MyInventory inventory = entity.GetInventoryBase() as MyInventory;
                            if (inventory == null)
                            {
                                continue;
                            }

                            DuckUtils.PlaceItemIntoCargo(inventory, powercells, 8); // 1 sg small battery needs 2
                        }
                    }
                    if (tb.EntityId == 136767719383723898) // Tools Locker
                    {
                        tb.CustomName = "Tools Locker";    // Not localized...
                    }
                    /* */
                }
            }
            grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyTerminalBlock);
            foreach (var slim in slimBlocks)
            {
                IMyTerminalBlock tb = slim.FatBlock as IMyTerminalBlock;

                if (tb == null)
                {
                    /*
                     * if (grid.EntityId == 92770753627258475) // crash ship
                     * {
                     *  ModLog.Info("Crash: Skipping" + slim.FatBlock.ToString());
                     *
                     * }
                     */
                    //                   continue;
                }
                else
                {
                    /*
                     * if (grid.EntityId == 92770753627258475) // crash ship
                     * {
                     *  ModLog.Info("Checking Block:" + tb.EntityId.ToString());
                     * }
                     */
                    if (desiredEntityIDs.Contains(tb.EntityId))
                    {
//                        ModLog.Info("Found desired Entity:" + tb.EntityId.ToString());

                        cachedTerminalBlocks.Add(tb);
                    }
                }
            }
        }
示例#29
0
        internal override void Update()
        {
            CheckEscortsAlive();

            if (!leader.IsControlledByNpcFaction())
            {
                GroupState = NpcGroupState.Disbanding;
                InitiateDisbandProtocols();
            }
            else if ((GroupState == NpcGroupState.Travelling || GroupState == NpcGroupState.InCombat) &&
                     Vector3D.DistanceSquared(Destination, leader.GetPosition()) < 200.0 * 200)    // increase to 200 to allow for variations in height.
            //                     && Vector3D.Distance(Destination, leader.GetPosition()) < 100.0)
            {
                ArrivalObserver.GroupArrivedIntact();
                audioSystem.PlayAudioRandomChance(0.1, CalAudioClip.ConvoyArrivedSafely);
                GroupState = NpcGroupState.Disbanding;
                InitiateDisbandProtocols();
                ResetBeaconNames();
            }

            if (GroupState == NpcGroupState.Disbanding)
            {
                AttemptDespawning();
                return;
            }

            if (DuckUtils.IsAnyPlayerNearPosition(leader.GetPosition(), 1000) && GroupState == NpcGroupState.Travelling)
            {
                GroupState = NpcGroupState.InCombat;
                InitiateAttackProtocols();
            }

            if (GroupState == NpcGroupState.InCombat)
            {
                var player = DuckUtils.GetNearestPlayerToPosition(leader.GetPosition(), 4000);
                if (player == null)
                {
                    GroupState = NpcGroupState.Travelling;       // Return to normal, cowardly players have run off or died
                    ResetBeaconNames();
                    if (escortDic.Count > 0)                     //todo maybe check if the escorts are actually alive? Dunno if doing this already
                    {
                        audioSystem.PlayAudio(CalAudioClip.DisengagingFromHostile, CalAudioClip.TargetLost);
                    }
                    else
                    {
                        audioSystem.PlayAudio(CalAudioClip.PursuitEvaded, CalAudioClip.SensorsLostTrack);
                    }
                }
                else
                {
                    SendArmedEscortsNearPosition(player.GetPosition());                     // Use same position as when escorting, to avoid collisions
                }
            }

            if (GroupState == NpcGroupState.Travelling)
            {
                foreach (var entry in escortDic)
                {
                    SendEscortToGrid(entry.Key, entry.Value, leader);
                }
            }
        }
示例#30
0
 private static bool NoPlayerNearby(VRage.Game.ModAPI.Ingame.IMyEntity baseRc)
 {
     return(DebugConvoys || !DuckUtils.IsAnyPlayerNearPosition(baseRc.GetPosition(), 1000));
 }