Example #1
0
        /// <summary>
        /// Called before the callout is displayed. Do all spawning here, so that if spawning isn't successful, the player won't notice, as the callout won't be shown.
        /// </summary>
        /// <returns></returns>
        public override bool OnBeforeCalloutDisplayed()
        {
            //Get a valid spawnpoint for the callout, and spawn the Aggressor there
            spawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(300f));
            Aggressor = new Ped(spawnPoint);

            //Spawn the victim in front of the aggressor
            Victim = new Ped(Aggressor.GetOffsetPosition(new Vector3(0, 1.8f, 0)));

            //If for some reason, the spawning of either two peds failed, don't display the callout
            if(!Aggressor.Exists()) return false;
            if(!Victim.Exists()) return false;

            //If the peds are valid, display the area that the callout is in.
            this.ShowCalloutAreaBlipBeforeAccepting(spawnPoint, 15f);
            this.AddMinimumDistanceCheck(5f, spawnPoint);

            //Give the aggressor his weapon
            Aggressor.GiveNewWeapon("WEAPON_PISTOL", 500, true);

            //Set the callout message(displayed in the notification), and the position(also shown in the notification)
            this.CalloutMessage = "Mugging";
            this.CalloutPosition = spawnPoint;

            //Play the scanner audio.
            Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT_03 CRIME_POSSIBLE_MUGGING IN_OR_ON_POSITION", this.spawnPoint);

            return base.OnBeforeCalloutDisplayed();
        }
Example #2
0
        private LHandle pursuit; // an API pursuit handle

        /// <summary>
        /// OnBeforeCalloutDisplayed is where we create a blip for the user to see where the pursuit is happening, we initiliaize any variables above and set
        /// the callout message and position for the API to display
        /// </summary>
        /// <returns></returns>
        public override bool OnBeforeCalloutDisplayed()
        {
            //Set our spawn point to be on a street around 300f (distance) away from the player.
            SpawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(300f));

            //Create our ped in the world
            myPed = new Ped("a_m_y_mexthug_01", SpawnPoint, 0f);

            //Create the vehicle for our ped
            myVehicle = new Vehicle("DUKES2", SpawnPoint);

            //Now we have spawned them, check they actually exist and if not return false (preventing the callout from being accepted and aborting it)
            if (!myPed.Exists()) return false;
            if (!myVehicle.Exists()) return false;

            //If we made it this far both exist so let's warp the ped into the driver seat
            myPed.WarpIntoVehicle(myVehicle, -1);

            // Show the user where the pursuit is about to happen and block very close peds.
            this.ShowCalloutAreaBlipBeforeAccepting(SpawnPoint, 15f);
            this.AddMinimumDistanceCheck(5f, myPed.Position);

            // Set up our callout message and location
            this.CalloutMessage = "Example Callout Message";
            this.CalloutPosition = SpawnPoint;

            //Play the police scanner audio for this callout (available as of the 0.2a API)
            Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT CRIME_RESIST_ARREST IN_OR_ON_POSITION", SpawnPoint);

            return base.OnBeforeCalloutDisplayed();
        }
        /// <summary>
        /// Adds a ped to list of armed peds. These peds will not be re-assigned to certain events.
        /// </summary>
        /// <param name="p"></param>
        public static void AddWeaponedPed(Ped p)
        {
            if (p?.Exists() == false)
            {
                return;
            }

            Entry.weaponedPeds.Add(p);
        }
        public override bool OnBeforeCalloutDisplayed()
        {
            spawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(215.0f));
            while (spawnPoint.DistanceTo(Game.LocalPlayer.Character.Position) < 30.0f)
            {
                spawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(210.0f)).GetSafeCoordinatesForPed();
                GameFiber.Yield();
            }
            if (spawnPoint == Vector3.Zero)
            {
                spawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(195.0f));
            }

            suspect = new Ped(spawnPoint);
            if (!suspect.Exists())
            {
                return(false);
            }
            hostage = new Ped(spawnPoint + suspect.ForwardVector * 0.9f);
            if (!hostage.Exists())
            {
                return(false);
            }

            suspect.BlockPermanentEvents = true;
            hostage.BlockPermanentEvents = true;

            hostage.Heading = suspect.Heading = MathHelper.GetRandomSingle(1f, 359f);

            RelationshipGroup hostageRelation = new RelationshipGroup("HOSTAGE");

            hostage.RelationshipGroup = hostageRelation;
            Game.SetRelationshipBetweenRelationshipGroups(hostageRelation, "COP", Relationship.Companion);
            Game.SetRelationshipBetweenRelationshipGroups(hostageRelation, "PLAYER", Relationship.Companion);
            Game.SetRelationshipBetweenRelationshipGroups("COP", hostageRelation, Relationship.Companion);

            RelationshipGroup suspectRelation = new RelationshipGroup("SUSPECT");

            suspect.RelationshipGroup = suspectRelation;
            Game.SetRelationshipBetweenRelationshipGroups(suspectRelation, "COP", Relationship.Dislike);
            Game.SetRelationshipBetweenRelationshipGroups(suspectRelation, "PLAYER", Relationship.Dislike);
            Game.SetRelationshipBetweenRelationshipGroups("COP", suspectRelation, Relationship.Dislike);

            this.ShowCalloutAreaBlipBeforeAccepting(spawnPoint, 17.5f);
            this.AddMinimumDistanceCheck(15.0f, suspect.Position);

            // Set up our callout message and location
            this.CalloutMessage  = "Hostage situation";
            this.CalloutPosition = spawnPoint;

            //Play the police scanner audio for this callout (available as of the 0.2a API)
            Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT CRIME_ASSAULT_CIVILIAN IN_OR_ON_POSITION UNITS_RESPOND_CODE_03", spawnPoint);

            return(base.OnBeforeCalloutDisplayed());
        }
Example #5
0
        public override void OnCalloutNotAccepted()
        {
            // If the player didn't accept the callout we delete all of our entities
            if (Aggressor1.Exists())
            {
                Aggressor1.Delete();
            }
            if (Aggressor2.Exists())
            {
                Aggressor2.Delete();
            }
            if (Aggressor3.Exists())
            {
                Aggressor3.Delete();
            }
            if (Aggressor4.Exists())
            {
                Aggressor4.Delete();
            }
            if (Barracks.Exists())
            {
                Barracks.Delete();
            }
            if (ABlip1.Exists())
            {
                ABlip1.Delete();
            }
            if (ABlip2.Exists())
            {
                ABlip2.Delete();
            }
            if (ABlip3.Exists())
            {
                ABlip3.Delete();
            }
            if (ABlip4.Exists())
            {
                ABlip4.Delete();
            }

            base.OnCalloutNotAccepted();
        }
Example #6
0
        private async Task OnStateUpdateTick()
        {
            if (this.IsConnected && this.IsIngame)
            {
                List <PlayerState> playerStates = new List <PlayerState>();

                Vector3 playerPosition = Game.PlayerPed.Position;

                foreach (VoiceClient client in this.VoiceClients)
                {
                    if (client.Player == null)
                    {
                        client.Player = this.PlayerList[client.ServerId];

                        if (client.Player == null)
                        {
                            continue;
                        }
                    }

                    Ped ped = client.Player.Character;

                    if (!ped.Exists())
                    {
                        continue;
                    }

                    playerStates.Add(
                        new PlayerState(
                            client.TeamSpeakName,
                            ped.Position,
                            client.VoiceRange,
                            client.Player.IsAlive
                            )
                        );
                }

                this.ExecuteCommand(
                    new PluginCommand(
                        Command.BulkUpdate,
                        this.ServerUniqueIdentifier,
                        new BulkUpdate(
                            playerStates,
                            new SelfState(
                                playerPosition,
                                API.GetGameplayCamRot(0).Z
                                )
                            )
                        )
                    );
            }

            await BaseScript.Delay(250);
        }
Example #7
0
 public override void OnCalloutNotAccepted()
 {
     base.OnCalloutNotAccepted();
     if (Buyer.Exists())
     {
         Buyer.Delete();
     }
     if (SpawnBlip.Exists())
     {
         SpawnBlip.Delete();
     }
     if (Seller.Exists())
     {
         Seller.Delete();
     }
     if (Car.Exists())
     {
         Car.Delete();
     }
 }
 public override void OnCalloutNotAccepted()
 {
     base.OnCalloutNotAccepted();
     if (Suspect.Exists())
     {
         Suspect.Delete();
     }
     if (SuspectCar.Exists())
     {
         SuspectCar.Delete();
     }
     if (SuspectBlip.Exists())
     {
         SuspectBlip.Delete();
     }
     //if (EntryPoint.OtherUnitTakingCallAudio)
     //{
     //    Functions.PlayScannerAudio("OTHER_UNIT_TAKING_CALL");
     //}
 }
        public static void Main()
        {
            Ped p = GetNearestValidPed();

            if (p.Exists())
            {
                Persona pers = Functions.GetPersonaForPed(p);
                Game.DisplayNotification("~b~" + PoliceSmartRadio.PlayerName + "~s~: Dispatch, could you run a person check through for me? It's ~b~" + pers.FullName + "~s~, born on ~b~" + pers.Birthday.ToShortDateString() + "~s~.");
                displayRecords(pers);
            }
        }
Example #10
0
 public override void OnCalloutNotAccepted()
 {
     if (_Blip.Exists())
     {
         _Blip.Delete();
     }
     if (_Blip2.Exists())
     {
         _Blip2.Delete();
     }
     if (_AG1.Exists())
     {
         _AG1.Delete();
     }
     if (_AG2.Exists())
     {
         _AG2.Delete();
     }
     base.OnCalloutNotAccepted();
 }
 private void dissimAllSuspect(Ped[] suspectsArray)
 {
     for (int i = 0; i < suspectsArray.Length; i++)
     {
         Ped currentPed = suspects[i];
         if (currentPed.Exists())
         {
             currentPed.Dismiss();
         }
     }
 }
Example #12
0
 public static float getDotVectorResult(Ped source, Ped target)
 {
     if (source.Exists() && target.Exists())
     {
         Vector3 dir = (target.Position - source.Position).Normalized; return(Vector3.Dot(dir, source.ForwardVector));
     }
     else
     {
         return(-1.0f);
     }
 }
Example #13
0
 public override void OnCalloutNotAccepted()
 {
     if (Dealer.Exists())
     {
         Dealer.Delete();
     }
     if (Victim.Exists())
     {
         Victim.Delete();
     }
     if (Blip.Exists())
     {
         Blip.Delete();
     }
     if (Blip2.Exists())
     {
         Blip2.Delete();
     }
     base.OnCalloutNotAccepted();
 }
Example #14
0
 /// <summary>
 /// Prevents this ped from being taken over by a Traffic Policer ambient event.
 /// </summary>
 /// <param name="ped"></param>
 public static void MakePedImmuneToAmbientEvents(Ped ped)
 {
     if (ped.Exists())
     {
         TrafficPolicerHandler.driversConsidered.Add(ped);
     }
     else
     {
         Game.LogTrivial("Traffic Policer API - MakePedImmuneToAmbientEvents ped doesn't exist.");
     }
 }
Example #15
0
 public override void OnCalloutNotAccepted()
 {
     base.OnCalloutNotAccepted();
     if (_Buyer.Exists())
     {
         _Buyer.Delete();
     }
     if (_Blip.Exists())
     {
         _Blip.Delete();
     }
     if (_Seller.Exists())
     {
         _Seller.Delete();
     }
     if (_Car.Exists())
     {
         _Car.Delete();
     }
 }
        public override void OnCalloutNotAccepted()
        {
            if (attackedPed.Exists())
            {
                attackedPed.Delete();
            }
            if (animal.Exists())
            {
                animal.Delete();
            }
            if (animalBlip.Exists())
            {
                animalBlip.Delete();
            }
            if (attackedPedBlip.Exists())
            {
                attackedPedBlip.Delete();
            }

            base.OnCalloutNotAccepted();
        }
Example #17
0
 private void Blipper()
 {
     GameFiber.StartNew(delegate
     {
         while (!PursuitStarted && Criminal.Exists())
         {
             if (CriminalBlip.Exists())
             {
                 CriminalBlip.Delete();
             }
             CriminalBlip = new Blip(Criminal.Position.Around(0f, 25f), 75f)
             {
                 IsFriendly     = false,
                 Color          = Color.Gold,
                 IsRouteEnabled = true,
                 Alpha          = 0.5f
             };
             GameFiber.Sleep(60000);
         }
     });
 }
Example #18
0
        public static string Name(this Ped ped, EcsEntity entity)
        {
            string name = ped.Exists()
                ? ped.Model.Name
                : "NOT_EXISTS";

#if DEBUG
            return($"{name}({entity})");
#else
            return($"{name}");
#endif
        }
Example #19
0
        // If we don't accept the callout this will be called and we will clear anything that we have spawned to prevent it staying in the game.
        public override void OnCalloutNotAccepted()
        {
            base.OnCalloutNotAccepted();

            if (Aggressor.Exists())
            {
                Aggressor.Delete();
            }
            if (Lorry.Exists())
            {
                Lorry.Delete();
            }
            if (ABlip.Exists())
            {
                ABlip.Delete();
            }
            if (Tanker.Exists())
            {
                Tanker.Delete();
            }
        }
Example #20
0
 public static void FootOfficerPursuitPed(Ped officer, Ped target)
 {
     // Let's do a quick check before using these
     if (officer == null || target == null)
     {
         throw new ArgumentNullException();
     }
     if (!officer.Exists() || !target.Exists())
     {
         throw new NonExistingObjectException();
     }
 }
Example #21
0
        public override void OnCalloutNotAccepted()
        {
            Game.LogTrivial("[FireyCallouts][Log] Not accepted 'Helicopter Crash' callout.");

            // Clean up if callout not accepted
            if (suspect.Exists())
            {
                suspect.Delete();
            }
            if (suspectVehicle.Exists())
            {
                suspectVehicle.Delete();
            }
            if (locationBlip.Exists())
            {
                locationBlip.Delete();
            }

            base.OnCalloutNotAccepted();
            Game.LogTrivial("[FireyCallouts][Log] Cleaned up 'Helicopter Crash' callout.");
        }
Example #22
0
 public override void End()
 {
     if (Criminal.Exists())
     {
         Criminal.Dismiss();
     }
     if (Aircraft.Exists())
     {
         Aircraft.Dismiss();
     }
     base.End();
 }
Example #23
0
        void Modules()
        {
            UIMenu submenu = modMenuPool.AddSubMenu(mainMenu, "Modules");

            OutfitsMenu(submenu);
            LoadoutsMenu(submenu);

            UIMenuItem charterMenu = new UIMenuItem("Charter Flights (v0.1)");

            submenu.AddItem(charterMenu);
            UIMenuItem atc = new UIMenuItem("ATC");

            submenu.AddItem(atc);
            submenu.RefreshIndex();

            submenu.OnItemSelect += (sender, item, index) =>
            {
                if (item == charterMenu)
                {
                    if (charter == null)
                    {
                        float   pilot_heading = 43.63f;
                        float   plane_heading = 315.443f;
                        Vector3 pilot_spawn   = new Vector3(1503.31f, 3104.58f, 41f);
                        Vector3 plane_spawn   = new Vector3(1500.399f, 3099.608f, 42.69702f);
                        Ped     pilot         = Maps.Functions.SpawnPed("s_m_m_pilot_01", pilot_spawn, pilot_heading);
                        Vehicle plane         = Maps.Functions.SpawnVehicle("nimbus", plane_spawn, plane_heading, 112, 40, -1);
                        while (!plane.Exists() || !pilot.Exists())
                        {
                            Debug("not loaded");
                            Yield();
                        }
                        Debug(plane.Position);
                        Debug(pilot.Position);
                        //new Charter();
                        charter = InstantiateScript <Charter>();
                        charter.Load(plane, pilot);
                        GTA.UI.Notification.Show("Charter Flights Activated");
                    }
                    else
                    {
                        charter.Unload();
                        charter.Abort();
                        charter = null;
                        GTA.UI.Notification.Show("Charter Flights Deactivated");
                    }
                }
                else if (item == atc)
                {
                    ATC.Run();
                }
            };
        }
Example #24
0
        public bool AbortCallout()
        {
            Game.LogTrivial("[FireyCallouts][Log] Abort 'Campfire' callout. Locations too far away (> 800).");

            // Clean up if not accepted
            if (suspect.Exists())
            {
                suspect.Delete();
            }
            if (suspectVehicle.Exists())
            {
                suspectVehicle.Delete();
            }
            if (suspectBlip.Exists())
            {
                suspectBlip.Delete();
            }

            // Remove emergency services
            foreach (Vehicle ev in emergencyVehicles)
            {
                if (ev.Exists())
                {
                    ev.Delete();
                }
            }

            Game.LogTrivial("[FireyCallouts][Log] Cleaned up 'Campfire' callout.");
            return(false);
        }
 public override void OnCalloutNotAccepted()
 {
     if (_Aggressor1.Exists())
     {
         _Aggressor1.Delete();
     }
     if (_Aggressor2.Exists())
     {
         _Aggressor2.Delete();
     }
     if (_Aggressor3.Exists())
     {
         _Aggressor3.Delete();
     }
     if (_Aggressor4.Exists())
     {
         _Aggressor4.Delete();
     }
     if (_stockade.Exists())
     {
         _stockade.Delete();
     }
     if (_Blip1.Exists())
     {
         _Blip1.Delete();
     }
     if (_Blip2.Exists())
     {
         _Blip2.Delete();
     }
     if (_Blip3.Exists())
     {
         _Blip3.Delete();
     }
     if (_Blip4.Exists())
     {
         _Blip4.Delete();
     }
     base.OnCalloutNotAccepted();
 }
Example #26
0
 public override void Destroy()
 {
     if (GameReference.Exists())
     {
         GameReference.Delete();
     }
 }
        private static Ped FindRandomPed()
        {
            var rnd  = new Random(DateTime.Now.Millisecond);
            var peds = World.EnumeratePeds().Take(50).ToArray();
            Ped ped  = null;

            while (!ped.Exists() || ped.RelationshipGroup == "COP")
            {
                int position = rnd.Next(0, peds.Count() - 1);
                ped = peds.ElementAt(position);
            }
            return(ped);
        }
Example #28
0
        public override void OnCalloutNotAccepted()
        {
            // If the player didn't accept the callout we cleanup this mess
            if (A1.Exists())
            {
                A1.Delete();
            }
            if (C1.Exists())
            {
                C1.Delete();
            }
            if (B1.Exists())
            {
                B1.Delete();
            }
            if (B2.Exists())
            {
                B2.Delete();
            }

            base.OnCalloutNotAccepted();
        }
Example #29
0
        public override void End()
        {
            base.End();

            if (hearthAttackPed.Exists())
            {
                hearthAttackPed.Dismiss();
            }
            if (hearthAttackBlip.Exists())
            {
                hearthAttackBlip.Delete();
            }
        }
        public void Run()
        {
            foreach (int i in _hitPeds)
            {
                Ped ped = _hitPeds.Components1[i].ThisPed;
                if (!ped.Exists())
                {
                    continue;
                }

                NativeFunction.Natives.CLEAR_PED_LAST_WEAPON_DAMAGE(ped);
            }
        }
Example #31
0
        //public static Texture GetTextureFromEmbeddedResource(string resourceName)
        //{
        //    System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
        //    System.IO.Stream stream = assembly.GetManifestResourceStream(resourceName);
        //    string tempPath = System.IO.Path.GetTempFileName();
        //    using (System.IO.FileStream fs = new System.IO.FileStream(tempPath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write))
        //    {
        //        fs.SetLength(0);
        //        byte[] buffer = new byte[stream.Length];
        //        stream.Read(buffer, 0, buffer.Length);
        //        fs.Write(buffer, 0, buffer.Length);
        //    }

        //    return Game.CreateTextureFromFile(tempPath);
        //}

        /// <summary>
        /// Get a valid animal for vet pickup, or return null if no animal was found.
        /// </summary>
        /// <returns></returns>
        public static Ped GetValidAnimalForVetPickup()
        {
            Ped animal = WildernessCallouts.Common.GetClosestAnimal(Game.LocalPlayer.Character.Position, 30.0f);

            int timesToLoop = 0;

            while (timesToLoop < 20)
            {
                if (animal.Exists() && animal.IsDead && !Vet.TakenAnimals.Contains(animal))
                {
                    break;
                }
                animal = WildernessCallouts.Common.GetClosestAnimal(Game.LocalPlayer.Character.Position, 35.0f);
                timesToLoop++;
            } // Gets the closest dead animal

            if (!animal.Exists() || animal.IsAlive || Vet.TakenAnimals.Contains(animal))
            {
                return(animal);
            }
            return(animal);
        }
Example #32
0
        public override void OnCalloutNotAccepted()
        {
            if (computerPlusRunning)
            {
                ComputerPlusWrapperClass.AssignCallToAIUnit(callID);
            }

            if (suspect.Exists())
            {
                suspect.Delete();
            }
            if (mechanic.Exists())
            {
                mechanic.Delete();
            }
            if (coBlip.Exists())
            {
                coBlip.Delete();
            }

            base.OnCalloutNotAccepted();
        }
        private void AdvanceStage()
        {
            TimerBars = new TimerBars();
            CurrentStage++;
            CurrentObjectives.Clear();


            foreach (var veh in CurrentMission.Vehicles.Where(v => v.SpawnAfter == CurrentStage))
            {
                var newv = new Vehicle(Util.RequestModel(veh.ModelHash), veh.Position)
                {
                    PrimaryColor = Color.FromArgb((int)veh.PrimaryColor.X, (int)veh.PrimaryColor.Y,
                    (int)veh.PrimaryColor.Z),
                    SecondaryColor = Color.FromArgb((int)veh.SecondaryColor.X, (int)veh.SecondaryColor.Y,
                    (int)veh.SecondaryColor.Z),
                };
                newv.Health = veh.Health;
                newv.Rotation = veh.Rotation;
                GameFiber.StartNew(delegate
                {
                    while (IsMissionPlaying && (veh.RemoveAfter == 0 || veh.RemoveAfter > CurrentStage))
                    {
                        if (veh.FailMissionOnDeath && newv.IsDead)
                        {
                            FailMission(reason: "The vehicle has been destroyed.");
                        }
                        GameFiber.Yield();
                    }

                    if(newv.IsValid())
                        newv.Delete();
                });
            }

            foreach (var veh in CurrentMission.Objectives.OfType<SerializableVehicleObjective>().Where(v => v.SpawnAfter == CurrentStage))
            {
                
                var newv = new Vehicle(Util.RequestModel(veh.ModelHash), veh.Position)
                {
                    PrimaryColor = Color.FromArgb((int)veh.PrimaryColor.X, (int)veh.PrimaryColor.Y,
                    (int)veh.PrimaryColor.Z),
                    SecondaryColor = Color.FromArgb((int)veh.SecondaryColor.X, (int)veh.SecondaryColor.Y,
                    (int)veh.SecondaryColor.Z),
                };
                newv.Health = veh.Health;
                newv.Rotation = veh.Rotation;

                var hasActivated = false;

                if (veh.ActivateAfter == CurrentStage)
                {
                    CurrentObjectives.Add(veh);
                    hasActivated = true;
                }

                GameFiber.StartNew(delegate
                {
                    if(!hasActivated)
                    {
                        while (CurrentStage != veh.ActivateAfter && IsMissionPlaying)
                        {
                            GameFiber.Yield();
                        }
                        CurrentObjectives.Add(veh);
                    }


                    var blip = newv.AttachBlip();
                    

                    if(veh.ObjectiveType == 0)
                    {
                        blip.Color = Color.DarkRed;
                        while (!newv.IsDead && IsMissionPlaying)
                        {
                            if (veh.ShowHealthBar)
                            {
                                TimerBars.UpdateValue(newv.Handle.Value.ToString(), veh.Name, true, (100f*newv.Health / veh.Health).ToString("###") + "%");
                            }
                            GameFiber.Yield();
                        }
                        TimerBars.UpdateValue(newv.Handle.Value.ToString(), veh.Name, true, "0%");
                    }

                    if (veh.ObjectiveType == 1)
                    {
                        blip.Color = Color.CornflowerBlue;
                        while (!Game.LocalPlayer.Character.IsInVehicle(newv, false) && IsMissionPlaying)
                        {
                            GameFiber.Yield();
                        }
                    }


                    CurrentObjectives.Remove(veh);

                    if(blip.IsValid())
                        blip.Delete();

                    while (IsMissionPlaying)
                        GameFiber.Yield();


                    if (newv.IsValid())
                        newv.Delete();

                });
            }

            if (CurrentMission.Spawnpoints.Any(s => s.SpawnAfter == CurrentStage))
            {
                var sp = CurrentMission.Spawnpoints.First(s => s.SpawnAfter == CurrentStage);
                Game.FadeScreenOut(100, true);
                Game.LocalPlayer.Character.Position = sp.Position - new Vector3(0,0,1);
                Game.LocalPlayer.Character.Rotation = sp.Rotation;
                Game.LocalPlayer.Model = Util.RequestModel(sp.ModelHash);

                if (sp.WeaponHash != 0)
                    Game.LocalPlayer.Character.GiveNewWeapon(sp.WeaponHash, sp.WeaponAmmo, true);

                Game.LocalPlayer.Character.Health = sp.Health;
                Game.LocalPlayer.Character.Armor = sp.Armor;
                    
                if (sp.SpawnInVehicle)
                {
                    var vehList = Game.LocalPlayer.Character.GetNearbyVehicles(15).OrderBy(v => (Game.LocalPlayer.Character.Position - v.Position).Length());
                    Game.LocalPlayer.Character.WarpIntoVehicle(vehList.ToList()[0], sp.VehicleSeat);
                }
                    
                Game.FadeScreenIn(500, false);
            }

            foreach (var actor in CurrentMission.Actors.Where(v => v.SpawnAfter == CurrentStage))
            {
                GameFiber.StartNew(delegate
                {
                    var ped = new Ped(Util.RequestModel(actor.ModelHash), actor.Position - new Vector3(0,0,1f), actor.Rotation.Yaw);
                    
                    ped.Rotation = actor.Rotation;
                    ped.Accuracy = actor.Accuracy;

                    var blip = ped.AttachBlip();
                    blip.Scale = 0.6f;

                    if (actor.WeaponHash != 0)
                        ped.GiveNewWeapon(actor.WeaponHash, actor.WeaponAmmo, true);

                    ped.Health = actor.Health;
                    ped.Armor = actor.Armor;

                    if (actor.RelationshipGroup == 0)
                    {
                        ped.RelationshipGroup = StaticData.RelationshipGroups.Groups[1];
                        blip.Color = Color.DodgerBlue;

                        NativeFunction.CallByName<uint>("REMOVE_PED_FROM_GROUP", ped.Handle.Value);
                        NativeFunction.CallByName<uint>("SET_PED_AS_GROUP_MEMBER", ped.Handle.Value, NativeFunction.CallByName<int>("GET_PED_GROUP_INDEX", Game.LocalPlayer.Character.Handle.Value));
                    }
                    else
                    {
                        ped.RelationshipGroup = StaticData.RelationshipGroups.Groups[actor.RelationshipGroup];
                        if(actor.RelationshipGroup == 4 || actor.RelationshipGroup == 5)
                            blip.Color = Color.DarkRed;
                    }

                    if (actor.SpawnInVehicle)
                    {
                        var vehList = ped.GetNearbyVehicles(15).OrderBy(v => (ped.Position - v.Position).Length());
                        ped.WarpIntoVehicle(vehList.ToList()[0], actor.VehicleSeat);
                    }

                    ped.BlockPermanentEvents = false;
                    NativeFunction.CallByName<uint>("SET_PED_FIRING_PATTERN", ped.Handle.Value, 0xC6EE6B4C);

                    if (actor.Behaviour == 3)
                        ped.Tasks.FightAgainstClosestHatedTarget(100f);
                    else if (actor.Behaviour == 2)
                        NativeFunction.CallByName<uint>("TASK_GUARD_CURRENT_POSITION", ped.Handle.Value, 15f, 10f, true);
                    else if (actor.Behaviour == 0)
                        ped.Tasks.Clear();
                    else if (actor.Behaviour == 4)
                    {
                        GameFiber.StartNew(delegate
                        {
                            var wpyList = new List<SerializableWaypoint>(actor.Waypoints);
                            SerializableWaypoint currentWaypoint;
                            if (wpyList.Count > 0)
                                currentWaypoint = wpyList[0];

                            while (ped.IsValid() && ped.Exists() && ped.IsAlive && IsMissionPlaying && wpyList.Count > 0)
                            {
                                if (wpyList.Count == 0) break;
                                currentWaypoint = wpyList[0];
                                Task pedTask = null;
                                switch (currentWaypoint.Type)
                                {
                                    case WaypointTypes.Drive:
                                        if (ped.IsInAnyVehicle(true))
                                        {
                                            pedTask = ped.Tasks.DriveToPosition(currentWaypoint.Position,
                                                currentWaypoint.VehicleSpeed, (DriveToPositionFlags)currentWaypoint.DrivingStyle);
                                        }
                                        break;
                                    case WaypointTypes.Run:
                                        {
                                            var heading = 0f;
                                            if (wpyList.Count >= 2)
                                            {
                                                heading =
                                                    Util.DirectionToRotation(wpyList[1].Position - currentWaypoint.Position)
                                                        .Z;
                                            }

                                            pedTask = ped.Tasks.FollowNavigationMeshToPosition(currentWaypoint.Position,
                                                heading, 2f, 0.3f, currentWaypoint.Duration == 0 ? -1 : (int)currentWaypoint.Duration);

                                        }
                                        break;
                                    case WaypointTypes.Walk:
                                        {
                                            var heading = 0f;
                                            if (wpyList.Count >= 2)
                                            {
                                                heading =
                                                    Util.DirectionToRotation(wpyList[1].Position - currentWaypoint.Position)
                                                        .Z;
                                            }

                                            pedTask = ped.Tasks.FollowNavigationMeshToPosition(currentWaypoint.Position,
                                                heading, 1f, 0.3f, currentWaypoint.Duration == 0 ? -1 : (int)currentWaypoint.Duration);

                                        }
                                        break;
                                    case WaypointTypes.ExitVehicle:
                                        if (ped.IsInAnyVehicle(true))
                                            pedTask = ped.Tasks.LeaveVehicle(LeaveVehicleFlags.None);
                                        break;
                                    case WaypointTypes.EnterVehicle:
                                        Vehicle[] vehs = World.GetAllVehicles().Where(v =>
                                        {
                                            if (v != null && v.IsValid())
                                                return v.Model.Hash == currentWaypoint.VehicleTargetModel;
                                            return false;
                                        }).OrderBy(v => (v.Position - ped.Position).Length()).ToArray();

                                        if (vehs.Any())
                                        {
                                            if ((vehs[0].Position - ped.Position).Length() > 10f)
                                            {
                                                pedTask = ped.Tasks.FollowNavigationMeshToPosition(vehs[0].Position, 0f,
                                                    3f,
                                                    5f);
                                                pedTask.WaitForCompletion(10000);
                                            }
                                            var seat = vehs[0].GetFreeSeatIndex();
                                            if (seat.HasValue)
                                                pedTask = ped.Tasks.EnterVehicle(vehs[0], seat.Value);
                                        }
                                        break;
                                    case WaypointTypes.Wait:
                                        pedTask = ped.Tasks.StandStill(currentWaypoint.Duration);
                                        break;
                                    case WaypointTypes.Wander:
                                        pedTask = ped.Tasks.Wander();
                                        break;
                                    case WaypointTypes.Shoot:
                                        pedTask = null;
                                        NativeFunction.CallByName<uint>("TASK_SHOOT_AT_COORD", ped.Handle.Value,
                                            currentWaypoint.Position.X, currentWaypoint.Position.Y,
                                            currentWaypoint.Position.Z, currentWaypoint.Duration, 0xC6EE6B4C);
                                        GameFiber.Sleep(currentWaypoint.Duration);
                                        break;
                                    case WaypointTypes.Animation:
                                        pedTask = ped.Tasks.PlayAnimation(currentWaypoint.AnimDict,
                                            currentWaypoint.AnimName, 8f, AnimationFlags.None);
                                        break;
                                }
                                pedTask?.WaitForCompletion(currentWaypoint.Duration == 0 ? -1 : currentWaypoint.Duration);
                                if (wpyList.Count > 0)
                                    wpyList.RemoveAt(0);
                                GameFiber.Yield();
                            }
                        });
                    }

                    while (IsMissionPlaying && (actor.RemoveAfter == 0 || actor.RemoveAfter > CurrentStage) && !ped.IsDead)
                    {
                        GameFiber.Yield();
                    }

                    if (actor.FailMissionOnDeath && ped.IsDead)
                    {
                        FailMission(reason: "An ally has died.");
                    }

                    if (blip.IsValid())
                        blip.Delete();

                    while(IsMissionPlaying && (actor.RemoveAfter == 0 || actor.RemoveAfter > CurrentStage))
                        GameFiber.Yield();

                    if(ped.IsValid())
                        ped.Delete();
                });
            }

            foreach (var o in CurrentMission.Objects.Where(v => v.SpawnAfter == CurrentStage))
            {
                GameFiber.StartNew(delegate
                {
                    var prop = new Rage.Object(Util.RequestModel(o.ModelHash), o.Position);
                    prop.Position = o.Position;
                    prop.Rotation = o.Rotation;

                    while (IsMissionPlaying && (o.RemoveAfter == 0 || o.RemoveAfter > CurrentStage))
                    {
                        GameFiber.Yield();
                    }

                    if(prop.IsValid())
                        prop.Delete();
                });
            }

            foreach (var pickup in CurrentMission.Pickups.Where(v => v.SpawnAfter == CurrentStage))
            {
                GameFiber.StartNew(delegate
                {
                    var obj = NativeFunction.CallByName<uint>("CREATE_PICKUP_ROTATE", pickup.PickupHash, pickup.Position.X,
                        pickup.Position.Y, pickup.Position.Z, pickup.Rotation.Pitch, pickup.Rotation.Roll, pickup.Rotation.Yaw,
                        1, pickup.Ammo, 2, 1, 0);

                    int counter = 0;
                    while (IsMissionPlaying && (pickup.RemoveAfter == 0 || pickup.RemoveAfter > CurrentStage))
                    {
                        var alpha = 40 * (Math.Sin(Util.DegToRad(counter % 180)));
                        Util.DrawMarker(28, pickup.Position, new Vector3(), new Vector3(0.75f, 0.75f, 0.75f), Color.FromArgb((int)alpha, 10, 10, 230));
                        counter += 5;
                        if (counter >= 360)
                            counter = 0;

                        if ((pickup.Position - Game.LocalPlayer.Character.Position).Length() < 1f && pickup.Respawn)
                        {
                            NativeFunction.CallByName<uint>("REMOVE_PICKUP", obj);
                            while((pickup.Position - Game.LocalPlayer.Character.Position).Length() < 3f)
                            { GameFiber.Yield();}
                            obj = NativeFunction.CallByName<uint>("CREATE_PICKUP_ROTATE", pickup.PickupHash, pickup.Position.X,
                            pickup.Position.Y, pickup.Position.Z, pickup.Rotation.Pitch, pickup.Rotation.Roll, pickup.Rotation.Yaw,
                            1, pickup.Ammo, 2, 1, 0);
                        }
                        else if ((pickup.Position - Game.LocalPlayer.Character.Position).Length() < 1f && !pickup.Respawn)
                            break;
                        GameFiber.Yield();
                    }
                    NativeFunction.CallByName<uint>("REMOVE_PICKUP", obj);
                });
            }

            foreach (var actor in CurrentMission.Objectives.OfType<SerializableActorObjective>().Where(v => v.SpawnAfter == CurrentStage))
            {
                var ped = new Ped(Util.RequestModel(actor.ModelHash), actor.Position - new Vector3(0, 0, 1f), actor.Rotation.Yaw);

                ped.Rotation = actor.Rotation;
                ped.Accuracy = actor.Accuracy;

                
                if (actor.WeaponHash != 0)
                    ped.GiveNewWeapon(actor.WeaponHash, actor.WeaponAmmo, true);

                NativeFunction.CallByName<uint>("SET_PED_FIRING_PATTERN", ped.Handle.Value, 0xC6EE6B4C);

                ped.Health = actor.Health;
                ped.MaxHealth = actor.Health;
                ped.Armor = actor.Armor;

                if (actor.RelationshipGroup == 0)
                {
                    NativeFunction.CallByName<uint>("REMOVE_PED_FROM_GROUP", ped.Handle.Value);
                    NativeFunction.CallByName<uint>("SET_PED_AS_GROUP_MEMBER", ped.Handle.Value, NativeFunction.CallByName<int>("GET_PED_GROUP_INDEX", Game.LocalPlayer.Character.Handle.Value));
                    ped.RelationshipGroup = StaticData.RelationshipGroups.Groups[1];
                }
                else
                {
                    ped.RelationshipGroup = StaticData.RelationshipGroups.Groups[actor.RelationshipGroup];
                }

                if (actor.SpawnInVehicle)
                {
                    var vehList = ped.GetNearbyVehicles(15).OrderBy(v => (ped.Position - v.Position).Length());
                    ped.WarpIntoVehicle(vehList.ToList()[0], actor.VehicleSeat);
                }

                var hasActivated = false;

                if (actor.ActivateAfter == CurrentStage)
                {
                    CurrentObjectives.Add(actor);
                    hasActivated = true;
                }

                GameFiber.StartNew(delegate
                {
                    
                    if(!hasActivated)
                    {
                        while (CurrentStage != actor.ActivateAfter && IsMissionPlaying)
                        {
                            GameFiber.Yield();
                        }

                        CurrentObjectives.Add(actor);
                    }

                    var blip = ped.AttachBlip();
                    blip.Scale = 0.6f;
                    blip.Color = Color.DarkRed;

                    ped.BlockPermanentEvents = false;

                    if (actor.Behaviour == 3)
                        ped.Tasks.FightAgainstClosestHatedTarget(100f);
                    else if (actor.Behaviour == 2)
                        NativeFunction.CallByName<uint>("TASK_GUARD_CURRENT_POSITION", ped.Handle.Value, 15f, 10f, true);
                    else if(actor.Behaviour == 0)
                        ped.Tasks.Clear();
                    else if (actor.Behaviour == 4)
                    {
                        GameFiber.StartNew(delegate
                        {
                            var wpyList = new List<SerializableWaypoint>(actor.Waypoints);
                            SerializableWaypoint currentWaypoint;
                            if(wpyList.Count > 0)
                                currentWaypoint = wpyList[0];

                            while (ped.IsValid() && ped.Exists() && ped.IsAlive && IsMissionPlaying && wpyList.Count > 0)
                            {
                                if (wpyList.Count == 0) break;
                                currentWaypoint = wpyList[0];
                                Task pedTask = null;
                                switch (currentWaypoint.Type)
                                {
                                    case WaypointTypes.Drive:
                                        if (ped.IsInAnyVehicle(true))
                                        {
                                            pedTask = ped.Tasks.DriveToPosition(currentWaypoint.Position,
                                                currentWaypoint.VehicleSpeed, (DriveToPositionFlags)currentWaypoint.DrivingStyle);
                                        }
                                        break;
                                    case WaypointTypes.Run:
                                        {
                                            var heading = 0f;
                                            if (wpyList.Count >= 2)
                                            {
                                                heading =
                                                    Util.DirectionToRotation(wpyList[1].Position - currentWaypoint.Position)
                                                        .Z;
                                            }

                                            pedTask = ped.Tasks.FollowNavigationMeshToPosition(currentWaypoint.Position,
                                                heading, 2f, 0.3f, currentWaypoint.Duration == 0 ? -1 : (int)currentWaypoint.Duration);

                                        }
                                        break;
                                    case WaypointTypes.Walk:
                                        {
                                            var heading = 0f;
                                            if (wpyList.Count >= 2)
                                            {
                                                heading =
                                                    Util.DirectionToRotation(wpyList[1].Position - currentWaypoint.Position)
                                                        .Z;
                                            }

                                            pedTask = ped.Tasks.FollowNavigationMeshToPosition(currentWaypoint.Position,
                                                heading, 1f, 0.3f, currentWaypoint.Duration == 0 ? -1 : (int)currentWaypoint.Duration);

                                        }
                                        break;
                                    case WaypointTypes.ExitVehicle:
                                        if (ped.IsInAnyVehicle(true))
                                            pedTask = ped.Tasks.LeaveVehicle(LeaveVehicleFlags.None);
                                        break;
                                    case WaypointTypes.EnterVehicle:
                                        Vehicle[] vehs = World.GetAllVehicles().Where(v =>
                                        {
                                            if (v != null && v.IsValid())
                                                return v.Model.Hash == currentWaypoint.VehicleTargetModel;
                                            return false;
                                        }).OrderBy(v => (v.Position - ped.Position).Length()).ToArray();

                                        if (vehs.Any())
                                        {
                                            if ((vehs[0].Position - ped.Position).Length() > 10f)
                                            {
                                                pedTask = ped.Tasks.FollowNavigationMeshToPosition(vehs[0].Position, 0f,
                                                    3f,
                                                    5f);
                                                pedTask.WaitForCompletion(10000);
                                            }
                                            var seat = vehs[0].GetFreeSeatIndex();
                                            if (seat.HasValue)
                                                pedTask = ped.Tasks.EnterVehicle(vehs[0], seat.Value);
                                        }
                                        break;
                                    case WaypointTypes.Wait:
                                        pedTask = ped.Tasks.StandStill(currentWaypoint.Duration);
                                        break;
                                    case WaypointTypes.Wander:
                                        pedTask = ped.Tasks.Wander();
                                        break;
                                    case WaypointTypes.Shoot:
                                        pedTask = null;
                                        NativeFunction.CallByName<uint>("TASK_SHOOT_AT_COORD", ped.Handle.Value,
                                            currentWaypoint.Position.X, currentWaypoint.Position.Y,
                                            currentWaypoint.Position.Z, currentWaypoint.Duration, 0xC6EE6B4C);
                                        GameFiber.Sleep(currentWaypoint.Duration);
                                        break;
                                    case WaypointTypes.Animation:
                                        pedTask = ped.Tasks.PlayAnimation(currentWaypoint.AnimDict,
                                            currentWaypoint.AnimName, 8f, AnimationFlags.None);
                                        break;
                                }
                                pedTask?.WaitForCompletion(currentWaypoint.Duration == 0 ? -1 : currentWaypoint.Duration);
                                if(wpyList.Count > 0)
                                    wpyList.RemoveAt(0);
                                GameFiber.Yield();
                            }
                        });
                    }

                    while (!ped.IsDead && IsMissionPlaying)
                    {
                        if (actor.ShowHealthBar)
                        {
                            TimerBars.UpdateValue(ped.Handle.Value.ToString(), actor.Name, true, (100f*ped.Health/actor.Health).ToString("###") + "%");
                        }
                        GameFiber.Yield();
                    }

                    if (actor.ShowHealthBar)
                    {
                        TimerBars.UpdateValue(ped.Handle.Value.ToString(), actor.Name, true, "0%");
                    }

                    CurrentObjectives.Remove(actor);
                    if(blip.IsValid())
                        blip.Delete();

                    while(IsMissionPlaying)
                        GameFiber.Yield();
                        

                    if (ped.IsValid())
                        ped.Delete();
                });
            }

            foreach (var pickup in CurrentMission.Objectives.OfType<SerializablePickupObjective>().Where(v => v.ActivateAfter == CurrentStage))
            {
                CurrentObjectives.Add(pickup);
                GameFiber.StartNew(delegate
                {
                    var obj = NativeFunction.CallByName<uint>("CREATE_PICKUP_ROTATE", pickup.PickupHash, pickup.Position.X,
                        pickup.Position.Y, pickup.Position.Z, pickup.Rotation.Pitch, pickup.Rotation.Roll, pickup.Rotation.Yaw,
                        1, pickup.Ammo, 2, 1, 0);

                    var blip = new Blip(pickup.Position);
                    blip.Scale = 0.7f;
                    blip.Color = Color.DodgerBlue;

                    var counter = 0;
                    while ((pickup.Position - Game.LocalPlayer.Character.Position).Length() > 1f && IsMissionPlaying)
                    {
                        var alpha = 40 * (Math.Sin(Util.DegToRad(counter % 180)));
                        Util.DrawMarker(28, pickup.Position, new Vector3(), new Vector3(0.75f, 0.75f, 0.75f), Color.FromArgb((int)alpha, 230, 10, 10));
                        counter += 5;
                        if (counter >= 360)
                            counter = 0;
                        GameFiber.Yield();
                    }

                    if(blip != null && blip.IsValid())
                        blip.Delete();
                    
                    NativeFunction.CallByName<uint>("REMOVE_PICKUP", obj);
                    CurrentObjectives.Remove(pickup);
                });
            }

            foreach (var mark in CurrentMission.Objectives.OfType<SerializableMarker>().Where(v => v.ActivateAfter == CurrentStage))
            {
                CurrentObjectives.Add(mark);
                GameFiber.StartNew(delegate
                {
                    var bColor = Color.FromArgb(mark.Alpha, (int) mark.Color.X, (int) mark.Color.Y, (int) mark.Color.Z);
                    var blip = new Blip(mark.Position);
                    blip.Color = bColor;
                    blip.EnableRoute(bColor);
                    while ((mark.Position - Game.LocalPlayer.Character.Position).Length() > 1.5f && IsMissionPlaying)
                    {
                        Util.DrawMarker(mark.Type, mark.Position, new Vector3(mark.Rotation.Pitch, mark.Rotation.Roll, mark.Rotation.Yaw), mark.Scale,
                        bColor);

                        GameFiber.Yield();
                    }
                    if(blip.IsValid())
                        blip.Delete();
                    CurrentObjectives.Remove(mark);
                });
            }


            if (CurrentMission.Cutscenes.Any(c => c.PlayAt == CurrentStage))
            {
                var origPos = Game.LocalPlayer.Character.Position;
                var origRot = Game.LocalPlayer.Character.Rotation;

                Game.FadeScreenIn(100, true);

                Game.LocalPlayer.Character.Opacity = 0f;
                Game.LocalPlayer.Character.IsPositionFrozen = true;

                var cutscene = CurrentMission.Cutscenes.First(c => c.PlayAt == CurrentStage);
                var camLeft = new List<SerializableCamera>(cutscene.Cameras);
                var subLeft = new List<SerializableSubtitle>(cutscene.Subtitles);

                var startTime = Game.GameTime;
                Camera mainCam = null;

                SerializableCamera currentCam = null;
                uint lerpStart = 0;


                while ((Game.GameTime - startTime) < cutscene.Length)
                {
                    var ct = (Game.GameTime - startTime);

                    if (camLeft.Any())
                    {
                        if (camLeft[0].PositionInTime <= ct)
                        {
                            if (mainCam == null || !mainCam.IsValid())
                            {
                                Camera.DeleteAllCameras();
                                mainCam = new Camera(true);
                            }

                            Game.LocalPlayer.HasControl = false;
                            mainCam.Position = cutscene.Cameras[0].Position;
                            mainCam.Rotation = cutscene.Cameras[0].Rotation;
                            currentCam = camLeft[0];
                            camLeft.RemoveAt(0);
                            lerpStart = Game.GameTime;
                            Game.LocalPlayer.Character.Position = mainCam.Position;
                        }
                        else if (currentCam != null)
                        {
                            // Advance cam pos
                            if (currentCam.InterpolationStyle == InterpolationStyle.Linear)
                            {
                                mainCam.Position = Util.LerpVector(currentCam.Position, camLeft[0].Position,
                                    Util.LinearLerp, Game.GameTime - lerpStart,
                                    camLeft[0].PositionInTime - currentCam.PositionInTime);

                                mainCam.Rotation =
                                    Util.LerpVector(currentCam.Rotation.ToVector(), camLeft[0].Rotation.ToVector(),
                                        Util.LinearLerp, Game.GameTime - lerpStart,
                                        camLeft[0].PositionInTime - currentCam.PositionInTime).ToRotator();
                                Game.LocalPlayer.Character.Position = mainCam.Position;
                            }
                            else if (currentCam.InterpolationStyle == InterpolationStyle.Smooth)
                            {
                                mainCam.Position = Util.LerpVector(currentCam.Position, camLeft[0].Position,
                                    Util.QuadraticLerp, Game.GameTime - lerpStart,
                                    camLeft[0].PositionInTime - currentCam.PositionInTime);

                                mainCam.Rotation =
                                    Util.LerpVector(currentCam.Rotation.ToVector(), camLeft[0].Rotation.ToVector(),
                                        Util.QuadraticLerp, Game.GameTime - lerpStart,
                                        camLeft[0].PositionInTime - currentCam.PositionInTime).ToRotator();
                                Game.LocalPlayer.Character.Position = mainCam.Position;
                            }
                        }
                    }
                    else if(currentCam != null && mainCam != null)
                    {
                        mainCam.Position = currentCam.Position;
                        mainCam.Rotation = currentCam.Rotation;
                        Game.LocalPlayer.Character.Position = mainCam.Position;
                    }

                    if (subLeft.Any())
                    {
                        if (subLeft[0].PositionInTime <= ct)
                        {
                            Game.DisplaySubtitle(subLeft[0].Content, subLeft[0].DurationInMs);
                            subLeft.RemoveAt(0);
                        }
                    }
                    GameFiber.Yield();
                }

                mainCam.Active = false;
                Game.LocalPlayer.HasControl = true;
                Game.LocalPlayer.Character.IsPositionFrozen = false;
                Game.LocalPlayer.Character.Position = origPos;
                Game.LocalPlayer.Character.Rotation = origRot;
                Game.LocalPlayer.Character.Opacity = 1f;
                Game.FadeScreenOut(100);
            }


            if (!string.IsNullOrEmpty(CurrentMission.ObjectiveNames[CurrentStage]))
            {
                Game.DisplaySubtitle(CurrentMission.ObjectiveNames[CurrentStage], 10000);
            }

            Game.FadeScreenIn(1);
        }