public override bool OnBeforeCalloutDisplayed(MurderInvestigation owner)
 {
     scenario              = Var1Scenario.GetRandomScenario();
     owner.CalloutMessage  = scenario.CalloutMessage;
     owner.CalloutPosition = scenario.CalloutPosition;
     owner.ShowCalloutAreaBlipBeforeAccepting(owner.CalloutPosition, 25f);
     return(true);
 }
 public override bool OnCalloutAccepted(MurderInvestigation owner)
 {
     owner.HelpText              = @"What if you search for a CCTV camera? Or a weapon?~n~If you found out how the suspect is you could ask a pedestrian if he saw him pressing ~b~" + Controls.SecondaryAction.ToUserFriendlyName() + "~s~";
     objects                     = new List <Rage.Object>();
     alreadyAskedPeds            = new List <Ped>();
     state                       = Var1State.EnRoute;
     blipLocation                = new Blip(scenario.CalloutPosition);
     blipLocation.IsRouteEnabled = true;
     return(createScenario());
 }
            public CalloutMenu(MurderInvestigation owner)
            {
                MainMenu = new UIMenu("Wilderness Callouts", "Murder Investigation");
                MainMenu.AllowCameraMovement  = true;
                MainMenu.MouseControlsEnabled = false;
                MenuCommon.Pool.Add(MainMenu);
                UIMenuCheckboxItem showReportCheckboxItem = new UIMenuCheckboxItem("Show CAD Report", false, "If checked displays the CAD report with information about this callout");

                showReportCheckboxItem.CheckboxEvent += (sender, itemChecked) => { owner.Report.IsVisible = itemChecked; };

                EvidencesSubMenu = new UIMenu("Wilderness Callouts", "Murder Investigation: Evidences");
                EvidencesSubMenu.AllowCameraMovement  = true;
                EvidencesSubMenu.MouseControlsEnabled = false;
                MenuCommon.Pool.Add(EvidencesSubMenu);

                UIMenuItem evidencesItem = new UIMenuItem("Evidences", "Opens the evidences menu");

                MainMenu.AddItem(showReportCheckboxItem);
                MainMenu.AddItem(evidencesItem);
                MainMenu.RefreshIndex();

                MainMenu.BindMenuToItem(EvidencesSubMenu, evidencesItem);
            }
            public override void Process(MurderInvestigation owner)
            {
                if (state == Var1State.EnRoute)
                {
                    if (Game.LocalPlayer.Character.IsInRangeOf2D(victimPed, 12.5f))
                    {
                        state = Var1State.CrimeSceneReached;
                        return;
                    }
                }
                else if (state == Var1State.CrimeSceneReached)
                {
                    Game.DisplayNotification("~b~" + Settings.General.Name + ": ~w~Dispatch, I'm on scene, ~g~victim is dead");
                    GameFiber.Wait(1250);
                    Game.DisplayNotification("~b~Dispatch: ~w~Roger, investigate the scene");

                    state = Var1State.SearchingEvidences;
                    owner.IsPlayerOnScene = true;
                    return;
                }
                else if (state == Var1State.SearchingEvidences)
                {
//                    if (owner.InvestigationModeRaycastResult.Hit)
//                    {
//                        if (owner.InvestigationModeRaycastResult.HitEntity != null)
//                        {
//                            if (owner.InvestigationModeRaycastResult.HitEntity == cctvObject)
//                            {
//                                Game.DisplayHelp("~b~Investigation Mode:~s~ Press ~b~" + Controls.SecondaryAction.ToUserFriendlyName() + "~s~ to watch the ~g~CCTV camera footage~s~", 10);
//                                //cctvObjectVar1.Opacity = cctvObjectVar1.Opacity == 1.0f ? 0.33f : 1.0f;
//                                if (Controls.SecondaryAction.IsJustPressed())
//                                {
//                                    //cctvObjectVar1.Opacity = 1.0f;
//                                    watchCCTVCameraFootage(owner);
//                                }
//                            }
//                            else if (owner.InvestigationModeRaycastResult.HitEntity == knifeObject)
//                            {
//                                Game.DisplayHelp("~b~Investigation Mode:~s~ Press ~b~" + Controls.SecondaryAction.ToUserFriendlyName() + "~s~ to collect the ~g~knife~s~ as an evidence", 10);

//                                if (Controls.SecondaryAction.IsJustPressed())
//                                {
//                                    if (!hasFoundKnife)
//                                    {
//                                        if (knifeObject.Exists())
//                                            knifeObject.Delete();
//                                        owner.Report.AddTextToReport(
//    @"[" + DateTime.UtcNow.ToShortDateString() + "  " + DateTime.UtcNow.ToLongTimeString() + @"]
//Knife found.
//Has blood remains.
//Possible crime weapon.");
//                                    }
//                                    hasFoundKnife = true;
//                                }
//                            }
//                        }
//                    }

                    if (hasCCTVTextBeenAddedToReport)
                    {
                        if (Controls.SecondaryAction.IsJustPressed())
                        {
                            Ped closestPed = World.GetClosestEntity(Game.LocalPlayer.Character.Position, 5.0f, GetEntitiesFlags.ConsiderHumanPeds | GetEntitiesFlags.ExcludePlayerPed) as Ped;
                            if (closestPed.Exists())
                            {
                                if (alreadyAskedPeds.Contains(closestPed))
                                {
                                    Game.DisplayHelp("You already asked this pedestrian");
                                    return;
                                }

                                if (closestPed.IsDead)
                                {
                                    string[] phrases =
                                    {
                                        "What do you think you're doing? You can't ask a dead body...",
                                        "Ha, ha, ha! So funny... Asking a dead body...",
                                        "Mmh, I think that's a dead body, you shouldn't ask " + (closestPed.IsMale ? "him" : "her"),
                                    };
                                    Game.DisplayHelp(phrases.GetRandomElement(), 5750);
                                    return;
                                }

                                closestPed.BlockPermanentEvents = true;
                                bool askingPed = true;
                                GameFiber.StartNew(delegate
                                {
                                    while (askingPed && closestPed.Exists())
                                    {
                                        GameFiber.Yield();
                                        closestPed.Tasks.AchieveHeading(closestPed.GetHeadingTowards(Game.LocalPlayer.Character));
                                    }
                                });
                                GameFiber.Sleep(225);

                                bool pedDisrespectPolice = Globals.Random.Next(12) <= 1 ? true : false;
                                bool pedSawMurderer      = Globals.Random.Next(3) == 1 ? true : false;
                                if (closestPed.IsMale)
                                {
                                    Game.DisplaySubtitle("~b~" + Settings.General.Name + ": ~w~Sir, have you seen this person?", 3250); //TODO: implement asking peds
                                }
                                else
                                {
                                    Game.DisplaySubtitle("~b~" + Settings.General.Name + ": ~w~Ma'am, have you seen this person?", 3250);
                                }
                                GameFiber.Sleep(3150);
                                if (closestPed == murdererPed)
                                {
                                    askingPed = false;
                                    murdererPed.Tasks.Clear();
                                    murdererPed.Flee(Game.LocalPlayer.Character, 1000.0f, 60000); // notfleeing
                                }
                                else
                                {
                                    if (pedSawMurderer)
                                    {
                                        if (pedDisrespectPolice)
                                        {
                                            Game.DisplaySubtitle("pedSawMurderer pedDisrespectPolice", 5000);
                                        }
                                        else
                                        {
                                            Game.DisplaySubtitle("pedSawMurderer", 5000);
                                        }
                                    }
                                    else
                                    {
                                        if (pedDisrespectPolice)
                                        {
                                            string notSawDisrespect = new string[] { "Ha, ha! So now you pigs need my help!? Go ask your speed tickets!" }.GetRandomElement();
                                            Game.DisplaySubtitle("~b~Pedestrian: ~w~" + notSawDisrespect, 3250);
                                        }
                                        else
                                        {
                                            Game.DisplaySubtitle("pedNOTSawMurderer", 5000);
                                        }
                                    }
                                }
                                askingPed = false;
                                alreadyAskedPeds.Add(closestPed);
                            }
                        }
                    }
                }
                else if (state == Var1State.SuspectFound)
                {
                }
            }
            private void watchCCTVCameraFootage(MurderInvestigation owner)
            {
                // set up
                isCCTVCameraFootageActive = true;
                Game.FadeScreenOut(1750, true);


                List <Entity> invisibleEntities = new List <Entity>();

                invisibleEntities.AddRange(World.GetEntities(scenario.VictimSpawnPoint.Position, 150.0f, GetEntitiesFlags.ConsiderAllVehicles | GetEntitiesFlags.ConsiderAllPeds));
                Vector3[] invisibleEntitiesInitialPositions = new Vector3[invisibleEntities.Count];
                for (int i = 0; i < invisibleEntities.Count; i++)
                {
                    if (invisibleEntities[i].Exists())
                    {
                        invisibleEntitiesInitialPositions[i] = invisibleEntities[i].Position;
                        if (invisibleEntities[i] != victimPed && invisibleEntities[i] != murdererPed)
                        {
                            invisibleEntities[i].SetPositionZ(invisibleEntities[i].Position.X + 50.0f);
                        }
                        invisibleEntities[i].IsPositionFrozen = true;
                        invisibleEntities[i].IsVisible        = false;
                        Ped asPed = invisibleEntities[i] as Ped;
                        if (asPed.Exists())
                        {
                            asPed.BlockPermanentEvents = true;
                        }
                    }
                }

                victimPedClone = victimPed.Clone(0.0f);

                NativeFunction.Natives.REVIVE_INJURED_PED(victimPedClone);
                NativeFunction.Natives.SET_ENTITY_HEALTH(victimPedClone, 200.0f);
                NativeFunction.Natives.RESURRECT_PED(victimPedClone);
                victimPedClone.Tasks.ClearImmediately();

                victimPedClone.Position = scenario.VictimFootageSpawnPoint.Position;
                victimPedClone.Heading  = scenario.VictimFootageSpawnPoint.Heading;
                victimPedClone.ClearBlood();
                victimPedClone.Tasks.ClearImmediately();
                victimPedClone.CanPlayAmbientAnimations = true;

                murdererPedClone          = murdererPed.Clone(0.0f);
                murdererPedClone.Position = scenario.MurdererFootageSpawnPoint.Position;
                murdererPedClone.Heading  = scenario.MurdererFootageSpawnPoint.Heading;


                Game.LocalPlayer.Character.IsPositionFrozen = true;
                cctvObject.IsVisible = false;

                footageCamera          = new Camera(true);
                footageCamera.FOV     -= 20;
                footageCamera.Position = cctvObject.Position;
                footageCamera.PointAtEntity(victimPed, Vector3.Zero, true);
                NativeFunction.Natives.SET_NOISEOVERIDE(true);
                NativeFunction.Natives.SET_NOISINESSOVERIDE(0.1f);

                victimPedClone.Health         = 170;
                murdererPedClone.IsInvincible = true;
                victimPedClone.IsInvincible   = false;

                DateTime initialTime = World.DateTime;

                World.DateTime = footageInitialDateTime;

                Logger.LogTrivial(cctvFootageVictimScenario.Item1 + "   " + cctvFootageVictimScenario.Item2);
                Scenario.StartInPlace(victimPedClone, cctvFootageVictimScenario.Item1, cctvFootageVictimScenario.Item2);

                GameFiber.StartNew(delegate
                {
                    while (isCCTVCameraFootageActive)
                    {
                        GameFiber.Yield();

                        NativeFunction.Natives.HIDE_HUD_AND_RADAR_THIS_FRAME();
                        new ResRectangle(new Point(0, 0), new Size(245, 195), Color.FromArgb(145, Color.Gray)).Draw();
                        new ResText("CCTV #" + cctvCameraNumber + "~n~" + DateTime.UtcNow.ToShortDateString() + "~n~" + DateTime.UtcNow.ToLongTimeString(), new Point(5, 5), 0.747f).Draw();
                    }
                });
                Game.FadeScreenIn(1750, true);

                // footage
                Task murdererMoveTask = murdererPedClone.Tasks.GoToOffsetFromEntity(victimPedClone, 1.1325f, 180.0f, 0.5f);

                NativeFunction.Natives.SET_PED_STEALTH_MOVEMENT(murdererPedClone, 1, 0);
                murdererMoveTask.WaitForCompletion();
                murdererPedClone.Inventory.GiveNewWeapon(WeaponHash.Knife, 1, true);
                victimPedClone.Tasks.Clear();
                murdererPedClone.Tasks.FightAgainst(victimPedClone, -1).WaitForCompletion();

                GameFiber.Sleep(1200);

                murdererPedClone.Inventory.Weapons.Remove(WeaponHash.Knife);
                murdererPedClone.Tasks.FollowNavigationMeshToPosition(scenario.MurdererSpawnPoint.Position, scenario.MurdererSpawnPoint.Heading, 2.0f, 5.0f, -1).WaitForCompletion();
                murdererPedClone.Tasks.Wander();
                GameFiber.Sleep(700);

                // clean up
                Game.FadeScreenOut(1750, true);
                NativeFunction.Natives.SET_NOISEOVERIDE(false);
                NativeFunction.Natives.SET_NOISINESSOVERIDE(0.0f);
                footageCamera.Delete();
                murdererPedClone.Delete();
                victimPedClone.Delete();
                Game.LocalPlayer.Character.IsPositionFrozen = false;
                cctvObject.IsVisible = true;
                for (int i = 0; i < invisibleEntities.Count; i++)
                {
                    if (invisibleEntities[i].Exists())
                    {
                        invisibleEntities[i].Position         = invisibleEntitiesInitialPositions[i];
                        invisibleEntities[i].IsPositionFrozen = false;
                        invisibleEntities[i].IsVisible        = true;
                        Ped asPed = invisibleEntities[i] as Ped;
                        if (asPed.Exists())
                        {
                            asPed.BlockPermanentEvents = false;
                        }
                    }
                }
                invisibleEntities.Clear();
                invisibleEntities = null;
                invisibleEntitiesInitialPositions = null;
                World.DateTime            = initialTime;
                isCCTVCameraFootageActive = false;
                if (!hasCCTVTextBeenAddedToReport)
                {
                    owner.Report.AddTextToReport(
                        @"[" + DateTime.UtcNow.ToShortDateString() + "  " + DateTime.UtcNow.ToLongTimeString() + @"]
CCTV Camera footage found.
Shows suspect attacking victim with a knife and fleeing the crime scene.
" + scenario.MurderDescription + "");
                    hasCCTVTextBeenAddedToReport = true;
                }
                Game.FadeScreenIn(2000, true);
            }
            public override void CleanUp(MurderInvestigation ownerCallout)
            {
#if DEBUG
                Game.DisplayNotification("Cleaning up var 1");
#endif
                if (ownerCallout.HasBeenAccepted)
                {
                    if (victimPed.Exists())
                    {
                        victimPed.Dismiss();
                    }
                    if (murdererPed.Exists())
                    {
                        murdererPed.Dismiss();
                    }
                    if (murdererPed.Exists())
                    {
                        murdererPed.Dismiss();
                    }
                    if (objects != null)
                    {
                        foreach (Rage.Object o in objects)
                        {
                            if (o.Exists())
                            {
                                o.Dismiss();
                            }
                        }
                    }
                }
                else
                {
                    if (victimPed.Exists())
                    {
                        victimPed.Delete();
                    }
                    if (murdererPed.Exists())
                    {
                        murdererPed.Delete();
                    }
                    if (objects != null)
                    {
                        foreach (Rage.Object o in objects)
                        {
                            if (o.Exists())
                            {
                                o.Delete();
                            }
                        }
                    }
                }
                if (footageCamera.Exists())
                {
                    footageCamera.Delete();
                }
                if (victimPedClone.Exists())
                {
                    victimPedClone.Delete();
                }
                if (murdererPedClone.Exists())
                {
                    murdererPedClone.Delete();
                }
                if (blipLocation.Exists())
                {
                    blipLocation.Delete();
                }
                Game.LocalPlayer.Character.IsVisible        = true;
                Game.LocalPlayer.Character.IsPositionFrozen = false;
            }
 public abstract void CleanUp(MurderInvestigation ownerCallout);
 public abstract void Process(MurderInvestigation ownerCallout);
 public abstract bool OnCalloutAccepted(MurderInvestigation ownerCallout);
 public abstract bool OnBeforeCalloutDisplayed(MurderInvestigation ownerCallout);