Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public override void GridInitialising(IMyCubeGrid grid)
        {
            if (!grid.IsControlledByNpcFaction())
            {
                return;
            }

            if (grid.IsStatic)
            {
                OfferPotentialDestination(grid);
            }
            else
            {
                OfferPotentialNpcShip(grid);
            }
        }
Exemplo n.º 3
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);
                }
            }
        }
Exemplo n.º 4
0
        internal override void Update()
        {
            if (!leader.IsControlledByNpcFaction())
            {
                leader     = null;
                GroupState = NpcGroupState.Disbanded;
                return;
            }

            if (GroupState == NpcGroupState.Travelling && Vector3D.Distance(Destination, leader.GetPosition()) < 40.0)
            {
                GroupState = NpcGroupState.Disbanding;
            }

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

            if (DuckUtils.IsAnyPlayerNearPosition(leader.GetPosition(), 1000) &&
                (GroupState == NpcGroupState.Travelling || GroupState == NpcGroupState.Disbanding))
            {
                GroupState = NpcGroupState.InCombat;
                leader.SetLightingColors(Color.Red);
                leader.RemoveFromFirstBeaconName(ReturningToBase);
                leader.AppendToFirstBeaconName(InterceptingBeaconSuffix);
                audioSystem.PlayAudio(CalAudioClip.TargetFoundDronesAttack, CalAudioClip.TargetIdentifiedUnitsConverge);
            }

            if (GroupState == NpcGroupState.InCombat)
            {
                if (!leader.HasUsableGun())
                {
                    GroupState = NpcGroupState.Disbanding;
                    leader.SendToPosition(Destination);
                    audioSystem.PlayAudio(CalAudioClip.DroneDisarmed);
                }
                else
                {
                    var player = DuckUtils.GetNearestPlayerToPosition(leader.GetPosition(), 1250);
                    if (player == null)
                    {
                        GroupState = NpcGroupState.Disbanding;                         // Return to normal, cowardly players have run off or died
                        // TODO: get lighting per-faction
                        leader.SetLightingColors(GcorpBlue);
                        leader.RemoveFromFirstBeaconName(InterceptingBeaconSuffix);
                        leader.AppendToFirstBeaconName(ReturningToBase);
                        leader.SendToPosition(Destination);
                        audioSystem.PlayAudio(CalAudioClip.HostileDisappeared, CalAudioClip.TargetFleeingPursuit);
                    }
                    else
                    {
                        leader.SendToPosition(player.GetPosition(), 2);
                    }
                }
            }
        }