Esempio n. 1
0
        public bool AbortCallout()
        {
            Game.LogTrivial("[FireyCallouts][Log] Abort 'Dumpster Fire' callout. Locations too far away (> 800).");

            // Clean up if not accepted
            if (locationBlip.Exists())
            {
                locationBlip.Delete();
            }
            if (fireWood.Exists())
            {
                fireWood.Delete();
            }

            foreach (uint f in fireList)
            {
                NativeFunction.Natives.RemoveScriptFire(f);
            }
            foreach (Ped p in suspects)
            {
                if (p.Exists())
                {
                    p.Delete();
                }
            }

            Game.LogTrivial("[FireyCallouts][Log] Cleaned up 'Campfire' callout.");
            return(false);
        }
 public static void ToggleMobilePhone(Ped ped, bool toggle)
 {
     if (toggle)
     {
         if (MobilePhone.Exists())
         {
             MobilePhone.Delete();
         }
         NativeFunction.Natives.SET_PED_CAN_SWITCH_WEAPON(ped, false);
         ped.Inventory.GiveNewWeapon(new WeaponAsset("WEAPON_UNARMED"), -1, true);
         MobilePhone = new Rage.Object(new Model("prop_police_phone"), new Vector3(0, 0, 0));
         int boneIndex = NativeFunction.Natives.GET_PED_BONE_INDEX <int>(ped, (int)PedBoneId.RightPhHand);
         NativeFunction.Natives.ATTACH_ENTITY_TO_ENTITY(MobilePhone, ped, boneIndex, 0f, 0f, 0f, 0f, 0f, 0f, true, true, false, false, 2, 1);
         ped.Tasks.PlayAnimation("cellphone@", "cellphone_call_listen_base", 1.45f, AnimationFlags.Loop | AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask);
     }
     else
     {
         NativeFunction.Natives.SET_PED_CAN_SWITCH_WEAPON(ped, true);
         ped.Tasks.Clear();
         if (GameFiber.CanSleepNow)
         {
             GameFiber.Wait(800);
         }
         if (MobilePhone.Exists())
         {
             MobilePhone.Delete();
         }
     }
 }
        /// <summary>
        /// OnCalloutAccepted is where we begin our callout's logic. In this instance we create our pursuit and add our ped from eariler to the pursuit as well
        /// </summary>
        /// <returns></returns>
        public override bool OnCalloutAccepted()
        {
            //We accepted the callout, so lets initilize our blip from before and attach it to our ped so we know where he is.
            heliBlip = crash.AttachBlip();
            if (crash.Model == new Model("prop_crashed_heli") || crash.Model == new Model("prop_wrecked_buzzard"))
            {
                heliBlip.Sprite = BlipSprite.Helicopter;
            }
            else if (crash.Model == new Model("prop_shamal_crash") || crash.Model == new Model("apa_mp_apa_crashed_usaf_01a"))
            {
                heliBlip.Sprite = BlipSprite.Plane;
            }
            heliBlip.Color = Color.Yellow;
            heliBlip.EnableRoute(Color.Yellow);

            Functions.PlayScannerAudioUsingPosition("CRIME_AMBULANCE_REQUESTED IN_OR_ON_POSITION", spawnPoint);

            explosionBool = true;

            GameFiber.StartNew(delegate
            {
                GameFiber.Sleep(MathHelper.GetRandomInteger(500, 12501));
                if (crash.Exists())
                {
                    int rndFarExplosion = MathHelper.GetRandomInteger(101);
                    if (rndFarExplosion < 75)
                    {
                        World.SpawnExplosion(crash.Position.AroundPosition(5.0f), 5, 10.0f, true, false, MathHelper.GetRandomSingle(0.0f, 4.0f));
                    }
                }
            });

            return(base.OnCalloutAccepted());
        }
Esempio n. 4
0
 /// <summary>
 /// If you don't accept the callout this will be called, we clear anything we spawned here to prevent it staying in the game
 /// </summary>
 public override void OnCalloutNotAccepted()
 {
     base.OnCalloutNotAccepted();
     if (ped.Exists())
     {
         ped.Delete();
     }
     if (blip.Exists())
     {
         blip.Delete();
     }
     if (pedObj.Exists())
     {
         pedObj.Delete();
     }
 }
Esempio n. 5
0
        public void CleanUp()
        {
            if (Pilot.Exists())
            {
                Pilot.Dismiss();
            }

            if (Paramedic1.Exists())
            {
                Paramedic1.Delete();
            }
            if (Paramedic2.Exists())
            {
                Paramedic2.Delete();
            }

            if (Helicopter.Exists())
            {
                Helicopter.Dismiss();
            }

            if (_heliBlip.Exists())
            {
                _heliBlip.Delete();
            }

            if (_notepad.Exists())
            {
                _notepad.Delete();
            }
        }
Esempio n. 6
0
        public override bool OnCalloutAccepted()
        {
            karen = new Ped(spawnPoint);

            if (!karen.Exists())
            {
                return(false);
            }

            karenBlip = karen.AttachBlip();

            phone = new Rage.Object("prop_npc_phone", Vector3.Zero);

            if (phone.Exists())
            {
                phone.AttachTo(karen, karen.GetBoneIndex(PedBoneId.LeftHand), new Vector3(0.1490f, 0.0560f, -0.0100f), new Rotator(-17f, -142f, -151f));
            }
            karen.Tasks.PlayAnimation("cellphone@", "cellphone_photo_idle", 1.3f, AnimationFlags.Loop | AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask);

            karen.BlockPermanentEvents = true;

            //Ped[] nearbyPeds = karen.GetNearbyPeds(5);
            //Ped storeClerk = nearbyPeds.OrderBy(x => x.Position.DistanceTo(karen.Position)).FirstOrDefault();
            //karen.Tasks.AchieveHeading(MathHelper.ConvertDirectionToHeading(storeClerk.Direction - karen.Direction));


            Game.DisplaySubtitle("A gas station ~o~attendant~w~ reports a ~r~customer~w~ yelling in the store and refusing to leave", 10000);
            return(base.OnCalloutAccepted());
        }
Esempio n. 7
0
        public override void End()
        {
            this.Code4();
            if (karen.Exists())
            {
                if (karen.IsDead)
                {
                    karen.Dismiss();
                }
                else if (!Functions.IsPedArrested(karen))
                {
                    karen.Dismiss();
                }
            }
            if (phone.Exists())
            {
                phone.Delete();
            }

            if (karenBlip.Exists())
            {
                karenBlip.Delete();
            }
            base.End();
        }
            private bool createScenario()
            {
                cctvObject = new Rage.Object(scenario.CCTVCameraModelPositionRotation.Item1, scenario.CCTVCameraModelPositionRotation.Item2);
                if (!cctvObject.Exists())
                {
                    return(false);
                }
                cctvObject.Rotation = scenario.CCTVCameraModelPositionRotation.Item3;
                objects.Add(cctvObject);


                knifeObject = new Rage.Object(scenario.KnifeModelPositionRotation.Item1, scenario.KnifeModelPositionRotation.Item2);
                if (!knifeObject.Exists())
                {
                    return(false);
                }
                knifeObject.Rotation = scenario.KnifeModelPositionRotation.Item3;
                objects.Add(knifeObject);


                victimPed = new Ped(scenario.VictimPedModel, scenario.VictimSpawnPoint.Position, scenario.VictimSpawnPoint.Heading);
                if (!victimPed.Exists())
                {
                    return(false);
                }
                NativeFunction.Natives.TASK_WRITHE(victimPed, Game.LocalPlayer.Character, -1, false);
                victimPed.ApplyDamagePack(DamagePack.BigHitByVehicle, MathHelper.GetRandomSingle(1.0f, 10.0f), MathHelper.GetRandomSingle(1.0f, 15.0f));

                murdererPed = new Ped(scenario.MurdererPedModel, scenario.MurdererSpawnPoint.Position, scenario.MurdererSpawnPoint.Heading);
                if (!murdererPed.Exists())
                {
                    return(false);
                }
                murdererPed.Tasks.Wander();

                return(true);
            }
Esempio n. 9
0
        public static void dropSign(string selectedSign, bool swapHeading, Vector3 Location, float HeadingModifier)
        {
            GameFiber.StartNew(delegate
            {
                try
                {
                    //string selectedCone = barriersToChooseFrom[EntryPoint.rnd.Next(barriersToChooseFrom.Length)];
                    //string selectedCone = "PROP_MP_ARROW_BARRIER_01";
                    if (TrafficPolicerHandler.IsLSPDFRPlusRunning)
                    {
                        API.LSPDFRPlusFunctions.AddCountToStatistic(Main.PluginName, "Road signs placed");
                    }
                    Rage.Object trafficCone  = new Rage.Object(selectedSign, Location);
                    trafficCone.IsPersistent = true;
                    trafficCone.IsInvincible = true;
                    trafficCone.Rotation     = RotationToPlaceAt;
                    if (swapHeading)
                    {
                        trafficCone.Heading = Game.LocalPlayer.Character.Heading + 180f;
                    }
                    trafficCone.Heading += HeadingModifier;

                    trafficCone.IsPositionFrozen = false;
                    if (TrafficSignPreview.Exists())
                    {
                        TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z + 3f);
                    }
                    int waitCount = 0;
                    while (trafficCone.HeightAboveGround > 0.01f)
                    {
                        trafficCone.SetPositionZ(trafficCone.Position.Z - (trafficCone.HeightAboveGround * 0.75f));
                        waitCount++;
                        if (waitCount >= 1000)
                        {
                            break;
                        }
                    }

                    if (trafficCone.Exists())
                    {
                        trafficCone.IsPositionFrozen = true;
                        roadSignsDropped.Add(trafficCone);
                        UInt32 handle = World.AddSpeedZone(trafficCone.Position, 5f, 5f);
                        speedZones.Add(handle);
                        Rage.Object invWall  = new Rage.Object("p_ice_box_01_s", trafficCone.Position);
                        invWall.IsPersistent = true;
                        Ped invPed           = new Ped(trafficCone.Position);
                        invPed.MakeMissionPed();
                        invPed.IsVisible        = false;
                        invPed.IsPositionFrozen = true;

                        invWall.Heading   = Game.LocalPlayer.Character.Heading;
                        invWall.IsVisible = false;
                        RoadSignsWithInvisWallsAndPeds.Add(trafficCone, invWall, invPed);
                    }
                }
                catch (Exception e)
                {
                    Game.LogTrivial(e.ToString());
                }
            });
        }
Esempio n. 10
0
        public void CreateScenario(int scenario)
        {
            GameFiber.StartNew(delegate
            {
                Logger.LogTrivial(this.GetType().Name, "Scenario: " + scenario);

                if (scenario == 1)     // SHOOT
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Shoot");
                    ped.Inventory.GiveNewWeapon(weaponAssets.GetRandomElement(true), 9999, true);

                    Vector3 posToShoot = ped.Position + (ped.ForwardVector * MathHelper.GetRandomSingle(1.5f, 8.0f)) + (ped.UpVector * MathHelper.GetRandomSingle(8.0f, 20.0f)) + (ped.RightVector * MathHelper.GetRandomSingle(-15.0f, 15.0f));
                    NativeFunction.CallByName <uint>("TASK_SHOOT_AT_COORD", ped, posToShoot.X, posToShoot.Y, posToShoot.Z, -1, (uint)Rage.FiringPattern.BurstFire);
                }
                else if (scenario == 2)     // PROTEST
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Protest");
                    ped.Tasks.PlayAnimation("special_ped@griff@monologue_1@monologue_1e", "iamnotaracist_4", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object("prop_cs_protest_sign_01", Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.RightPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        //GameFiber.StartNew(delegate
                        //{
                        //    while (!hasEnded && ped.Exists() && ped.IsAlive && !Functions.IsPedArrested(ped))
                        //    {
                        //        if (Vector3.Distance(Game.LocalPlayer.Character.Position, ped.Position) < 17.5f)
                        //        {
                        //            if (new Random().Next(0, 151) < 20)
                        //            {
                        //                string[] protestSpeeches = { "GENERIC_CURSE_MED", "GENERIC_CURSE_HIGH", "GENERIC_FUCK_YOU" };
                        //                ped.PlayAmbientSpeech(null, protestSpeeches[new Random().Next(protestSpeeches.Length)], 0, SpeechModifier.Force);
                        //            }
                        //            GameFiber.Sleep(2500);
                        //        }
                        //        GameFiber.Yield();
                        //    }
                        //});
                        GameFiber.Sleep(125);
                        while (ped.IsPlayingAnimation("special_ped@griff@monologue_1@monologue_1e", "iamnotaracist_4") && ped.IsPersistent)
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 3)        // DRUNK NUDE GUY
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Drunk nude guy");
                    ped.SetMovementAnimationSet("move_m@drunk@verydrunk");
                    ped.Tasks.Wander();
                }
                else if (scenario == 4)     // GUITARRIST
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Guitarrist");

                    ped.Tasks.PlayAnimation("amb@world_human_musician@guitar@male@base", "base", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object(guitarModels.GetRandomElement(true), Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.LeftPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation("amb@world_human_musician@guitar@male@base", "base") && ped.IsPersistent)
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 5)         // TOPLESS GIRL
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Topless girl");
                    ped.Tasks.PlayAnimation("amb@world_human_prostitute@hooker@base", "base", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                }
                else if (scenario == 6)     // SUNBATHE
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Sunbathe");

                    AnimationDictionary maleAnimDict   = sunbatheMale.GetRandomElement(true);
                    AnimationDictionary femaleAnimDict = sunbatheFemale.GetRandomElement(true);

                    if (ped.IsMale)
                    {
                        ped.Tasks.PlayAnimation(maleAnimDict, "base", 2.0f, AnimationFlags.Loop);
                    }
                    else if (ped.IsFemale)
                    {
                        ped.Tasks.PlayAnimation(femaleAnimDict, "base", 2.0f, AnimationFlags.Loop);
                    }

                    ped.BlockPermanentEvents = true;

                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        if (ped.IsMale)
                        {
                            while (ped.IsPlayingAnimation(maleAnimDict, "base") && ped.IsPersistent)
                            {
                                GameFiber.Yield();
                            }
                            if (!hasEnded && ped.Exists())
                            {
                                ped.BlockPermanentEvents = false;
                            }
                        }
                        else if (ped.IsFemale)
                        {
                            while (ped.IsPlayingAnimation(femaleAnimDict, "base") && ped.IsPersistent)
                            {
                                GameFiber.Yield();
                            }
                            if (!hasEnded && ped.Exists())
                            {
                                ped.BlockPermanentEvents = false;
                            }
                        }
                    });
                }
                else if (scenario == 7)        // FREAK OUT GUY
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Freak out guy");

                    string animName = monkeyFreakOutAnimNames.GetRandomElement();
                    ped.Tasks.PlayAnimation("missfbi5ig_30monkeys", animName, 5.0f, AnimationFlags.Loop);
                    ped.BlockPermanentEvents = true;
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation("missfbi5ig_30monkeys", animName) && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && ped.Exists())
                        {
                            ped.BlockPermanentEvents = false;
                        }
                    });
                }
                else if (scenario == 8)      // EPSILON
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Epsilon");

                    ped.Tasks.PlayAnimation("rcmepsilonism3", "ep_3_rcm_marnie_meditating", 2.0f, AnimationFlags.Loop);
                    ped.BlockPermanentEvents = true;
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (!hasEnded)
                        {
                            if (ped.Exists())
                            {
                                if (Vector3.Distance(Game.LocalPlayer.Character.Position, ped.Position) < 6.0f)
                                {
                                    if (ped.IsMale)
                                    {
                                        ped.PlayAmbientSpeech(epsilonVoicesMale.GetRandomElement(), "KIFFLOM_GREET", 0, SpeechModifier.Force);
                                    }
                                    else
                                    {
                                        ped.PlayAmbientSpeech(epsilonVoicesFemale.GetRandomElement(), "KIFFLOM_GREET", 0, SpeechModifier.Force);
                                    }
                                    break;
                                }
                            }
                            GameFiber.Yield();
                        }
                        if (!hasEnded && ped.Exists())
                        {
                            ped.BlockPermanentEvents = false;
                        }
                    });
                }
                else if (scenario == 9)     // BONGOS
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Bongos");

                    ped.Tasks.PlayAnimation("amb@world_human_musician@bongos@male@idle_a", "idle_a", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object(bongosModel, Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.LeftPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation("amb@world_human_musician@bongos@male@idle_a", "idle_a") && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 10)     // BEGGER
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Begger");
                    string[] idles  = { "idle_a", "idle_b", "idle_c" };
                    string idleUsed = idles.GetRandomElement();
                    ped.Tasks.PlayAnimation("amb@world_human_bum_freeway@male@idle_a", idleUsed, 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object(beggersSignModels.GetRandomElement(), Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.RightPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(125);
                        while (ped.IsPlayingAnimation("amb@world_human_bum_freeway@male@idle_a", idleUsed) && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 11)    // NUDE GIRL CHEERING
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Topless girl cheering");
                    char[] letters = { 'a', 'b', 'c', 'd' };
                    ped.Tasks.PlayAnimation("amb@world_human_cheering@female_" + letters.GetRandomElement(), "base", 5.0f, AnimationFlags.Loop);
                }
                else if (scenario == 12)     // Pushups
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Pushups");

                    Tuple <AnimationDictionary, string>[] anims  = { new Tuple <AnimationDictionary, string>("amb@world_human_push_ups@male@idle_a", "idle_d"), new Tuple <AnimationDictionary, string>("amb@world_human_push_ups@male@base", "base") };
                    Tuple <AnimationDictionary, string> animUsed = anims.GetRandomElement();

                    ped.Tasks.PlayAnimation(animUsed.Item1, animUsed.Item2, 2.0f, AnimationFlags.Loop);

                    ped.BlockPermanentEvents = true;

                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation(animUsed.Item1, animUsed.Item2) && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && ped.Exists())
                        {
                            ped.BlockPermanentEvents = false;
                        }
                    });
                }
            });
        }
Esempio n. 11
0
        public void Start(bool cleanUpOnEnd = true)
        {
            if (PedToRescue.Exists())
            {
                Game.DisplayNotification("~b~" + Settings.General.Name + ":~w~ Dispatch, I need an air ambulance in " + Game.LocalPlayer.Character.Position.GetZoneName());
                GameFiber.Sleep(1000);
                Game.DisplayNotification("~b~Dispatch:~w~ Roger, " + Settings.AirAmbulance.ParamedicName.ToLower() + " en route");

                Functions.PlayScannerAudioUsingPosition("WE_HAVE MEDICAL_EMERGENCY IN_OR_ON_POSITION UNITS_RESPOND_CODE_99 OUTRO OFFICER_INTRO HELI_APPROACHING_DISPATCH", Game.LocalPlayer.Character.Position);

                Vector3 posToFly = PedToRescue.Position + Vector3.WorldUp * 32.5f;

                GameFiber.Sleep(100);

                NativeFunction.CallByName <uint>("TASK_HELI_MISSION", Pilot, Helicopter, 0, 0, posToFly.X, posToFly.Y, posToFly.Z, 6, 40.0f, 1.0f, 36.0f, 15, 15, -1.0f, 1);

                while (true)
                {
                    if (Helicopter.Exists())
                    {
                        if (Vector3.Distance2D(posToFly, Helicopter.Position) < 7.0f && Helicopter.Speed < 1.0f)
                        {
                            if (Paramedic1.Exists() && Paramedic1.IsInVehicle(Helicopter, false))
                            {
                                Paramedic1.Tasks.RappelFromHelicopter();
                            }
                            if (Paramedic2.Exists() && Paramedic2.IsInVehicle(Helicopter, false))
                            {
                                Paramedic2.Tasks.RappelFromHelicopter().WaitForCompletion();
                            }
                            break;
                        }
                    }
                    GameFiber.Yield();
                }

                if (PedToRescue.Exists())
                {
                    if (Paramedic1.Exists())
                    {
                        Paramedic1.Tasks.FollowNavigationMeshToPosition(Game.LocalPlayer.Character.Position + Game.LocalPlayer.Character.ForwardVector * 1.1125f, Game.LocalPlayer.Character.Heading - 180.0f, 10.0f);
                    }

                    if (Paramedic2.Exists())
                    {
                        Paramedic2.Tasks.FollowNavigationMeshToPosition(PedToRescue.Position + Vector3.RelativeRight, PedToRescue.Heading - 180, 10.0f).WaitForCompletion(4500);
                    }
                }

                if (Paramedic1.Exists())
                {
                    Paramedic1.Tasks.AchieveHeading(Paramedic1.GetHeadingTowards(Game.LocalPlayer.Character)).WaitForCompletion(700);
                }

                if (PedToRescue.Exists())
                {
                    if (Paramedic1.Exists() && Paramedic1.IsMale)
                    {
                        Paramedic1.PlayAmbientSpeech(epsilonVoices.GetRandomElement(), Globals.Random.Next(2) == 1 ? Speech.GENERIC_HI : Speech.KIFFLOM_GREET, 0, SpeechModifier.ForceShouted);
                    }

                    if (PedToRescue.IsMale)
                    {
                        Game.DisplaySubtitle("~b~" + Settings.AirAmbulance.ParamedicName + ":~w~ " + phraseToSayToThePlayerMaleVersion, 3000);
                    }
                    else
                    {
                        Game.DisplaySubtitle("~b~" + Settings.AirAmbulance.ParamedicName + ":~w~ " + phraseToSayToThePlayerFemaleVersion, 3000);
                    }
                }

                GameFiber.StartNew(delegate
                {
                    if (PedToRescue.Exists())
                    {
                        if (Paramedic2.Exists())
                        {
                            Paramedic2.Tasks.AchieveHeading(Paramedic2.GetHeadingTowards(PedToRescue)).WaitForCompletion(800);
                        }

                        if (Paramedic2.Exists())
                        {
                            Paramedic2.Tasks.PlayAnimation("amb@medic@standing@tendtodead@idle_a", tendToDeadIdles.GetRandomElement(), 2.0f, AnimationFlags.Loop);

                            Paramedic2.PlayAmbientSpeech(null, Speech.GENERIC_SHOCKED_HIGH, 0, SpeechModifier.ForceShouted);
                        }
                    }
                });

                GameFiber.Sleep(1300);

                if (Paramedic1.Exists() && Paramedic2.Exists())
                {
                    Paramedic1.Tasks.FollowNavigationMeshToPosition(Paramedic2.Position + Paramedic2.ForwardVector * 2.25f, Paramedic2.Heading - 180.0f, 10.0f).WaitForCompletion(12750);
                }

                if (PedToRescue.Exists() && Paramedic1.Exists())
                {
                    Paramedic1.Tasks.AchieveHeading(Paramedic1.GetHeadingTowards(PedToRescue)).WaitForCompletion(800);
                }

                if (Paramedic1.Exists())
                {
                    Paramedic1.Tasks.PlayAnimation("amb@medic@standing@timeofdeath@base", "base", 2.0f, AnimationFlags.Loop);
                }

                _notepad = new Rage.Object("prop_notepad_02", Vector3.Zero);
                if (Paramedic1.Exists() && _notepad.Exists())
                {
                    _notepad.AttachToEntity(Paramedic1, Paramedic1.GetBoneIndex(PedBoneId.LeftPhHand), Vector3.Zero, Rotator.Zero);
                }

                GameFiber.Sleep(11750);

                if (Paramedic1.Exists())
                {
                    Paramedic1.Tasks.Clear();
                    if (Paramedic1.IsMale)
                    {
                        Paramedic1.PlayAmbientSpeech("a_m_m_beach_02_black_full_01", Speech.GENERIC_BYE, 0, SpeechModifier.ForceShouted);
                    }
                }
                if (Paramedic2.Exists())
                {
                    Paramedic2.Tasks.Clear();
                    if (Paramedic2.IsMale)
                    {
                        Paramedic2.PlayAmbientSpeech("a_m_o_genstreet_01_white_full_01", Speech.GENERIC_BYE, 0, SpeechModifier.ForceShouted);
                    }
                }

                GameFiber.Sleep(1350);

                if (PedToRescue.Exists())
                {
                    PedToRescue.Delete();
                }

                if (Helicopter.Exists())
                {
                    if (Paramedic1.Exists())
                    {
                        Paramedic1.WarpIntoVehicle(Helicopter, 1);
                    }
                    if (Paramedic2.Exists())
                    {
                        Paramedic2.WarpIntoVehicle(Helicopter, 2);
                    }
                }

                GameFiber.Sleep(775);
            }
            if (cleanUpOnEnd)
            {
                CleanUp();
            }
        }
        //private bool breakForceEnd = false;

        /// <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.AroundPosition(800f));

            if (Vector3.Distance(Game.LocalPlayer.Character.Position, spawnPoint) < 115.0f)
            {
                return(false);
            }


            //Create the vehicle for our ped
            crash = new Rage.Object(crashVehModel.GetRandomElement(), spawnPoint);

            //Create our ped in the world
            dead = new Ped(pilotModel.GetRandomElement(), crash.Position.AroundPosition(5.0f), 0f);
            if (dead.Exists())
            {
                dead.IsRagdoll = true;
            }
            GameFiber.Wait(500);
            if (dead.Exists())
            {
                dead.Kill();
            }

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

            GameFiber.StartNew(delegate
            {
                GameFiber.Sleep(MathHelper.GetRandomInteger(500, 12501));
                if (crash.Exists())
                {
                    int rndFarExplosion = MathHelper.GetRandomInteger(101);
                    if (rndFarExplosion < 80)
                    {
                        World.SpawnExplosion(crash.Position.AroundPosition(5.0f), 5, 10.0f, true, false, MathHelper.GetRandomSingle(0.0f, 4.0f));
                    }
                }
            });

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

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

            Functions.PlayScannerAudioUsingPosition("ATTENTION_ALL_UNITS ASSISTANCE_REQUIRED CRIME_AIRCRAFT_CRASH IN_OR_ON_POSITION UNITS_RESPOND_CODE_99", spawnPoint);

            return(base.OnBeforeCalloutDisplayed());
        }