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()); }
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(); } } }
protected void AttachNotepadToPedDriver() { _notepad = new Rage.Object("prop_notepad_01", PedDriver.Position); int boneId = PedDriver.GetBoneIndex(PedBoneId.LeftPhHand); NativeFunction.Natives.AttachEntityToEntity( _notepad, PedDriver, boneId, 0f, 0f, 0f, 0f, 0f, 0f, true, false, false, false, 2, 1); }
private static Rage.Object[] CreateConesAtVehicleSide(Vehicle vehicle, float distanceFromVehicle, bool freezeConesPosition, bool createSideCones, bool createFrontCones, bool createRearCones, Vector3 sidePosition, Vector3 sideVector) { // TODO: CreateConesAtVehicleSide(): make the vehicles go around the cones instead of ramming into them List <Rage.Object> cones = new List <Rage.Object>(); Action <Vector3> createCone = (pos) => { Rage.Object o = new Rage.Object("prop_mp_cone_02", pos); float? z = World.GetGroundZ(o.Position, false, true); if (z.HasValue) { o.SetPositionZ(z.Value); } o.IsPositionFrozen = freezeConesPosition; cones.Add(o); }; float length = vehicle.Length; Vector3 forwardVector = vehicle.ForwardVector; const float separation = 2.0f; if (createSideCones) { // create cones at the side of the vehicle createCone(sidePosition + (sideVector * distanceFromVehicle)); // middle cone for (float i = separation, j = -separation; i < (length / 2); i += separation, j -= separation) { createCone(sidePosition + (sideVector * distanceFromVehicle) + (forwardVector * i)); // from middle to front cones createCone(sidePosition + (sideVector * distanceFromVehicle) + (forwardVector * j)); // from middle to rear cones } } float width = vehicle.Width; Vector3 rearPosition = vehicle.RearPosition; Vector3 frontPosition = vehicle.FrontPosition; float rearFrontConesdistanceFromVehicle = distanceFromVehicle * 2 + length / 2; // create cones at the front and rear, going from one side to the other for (float i = -(width / 2) - distanceFromVehicle; i < (width / 2); i += separation / 2) { if (createRearCones) { createCone(rearPosition + (forwardVector * -(rearFrontConesdistanceFromVehicle + (i * separation))) + (sideVector * -i)); // rear cones } if (createFrontCones) { createCone(frontPosition + (forwardVector * (rearFrontConesdistanceFromVehicle + (i * separation))) + (sideVector * -i)); // front cones } } return(cones.ToArray()); }
public static void GiveParkingTicket(GiveParkingTicketEvent parkingTicketEvent) { Vehicle vehicle = parkingTicketEvent.Vehicle; string modelName = vehicle.Model.Name.ToLower(); string licencePlate = vehicle.LicensePlate; string lexemArticle = ParkingTicketsEventHandler.Vowels.Contains <string>(modelName[0].ToString()) ? "an" : "a"; string licencePlateAudioMessage = ""; if (ParkingTicketsEventHandler.Numbers.Contains <string>(modelName.Last().ToString())) { modelName = modelName.Substring(0, modelName.Length - 1); } modelName = char.ToUpper(modelName[0]) + modelName.Substring(1); foreach (char character in licencePlate) { if (!Char.IsWhiteSpace(character)) { licencePlateAudioMessage = licencePlateAudioMessage + " " + character; } } ParkingTicketsEventHandler.Infos.Enabled = true; ParkingTicketsEventHandler.Infos.Text = "Vehicle " + modelName + " (" + licencePlate + ")"; ParkingTicketsEventHandler.Infos.Enabled = false; Game.DisplayNotification("~g~Traffic Officer ~s~is reporting an ~r~illegally parked vehicle."); Game.DisplayNotification("~b~Processing a parking ticket (" + parkingTicketEvent.Amount + ") for " + lexemArticle + " ~r~" + modelName + "~b~ with licence plate: ~r~" + licencePlate + "."); Game.DisplayNotification("~b~The offending ~r~" + modelName + " ~b~is parked on ~o~" + World.GetStreetName(vehicle.Position) + "."); PedsManager.LocalPlayer().Inventory.GiveNewWeapon(new WeaponAsset("WEAPON_UNARMED"), 0, true); Rage.Object notepad = new Rage.Object("prop_notepad_02", PedsManager.LocalPlayer().Position); int boneIndex = NativeFunction.Natives.GET_PED_BONE_INDEX <int>(PedsManager.LocalPlayer(), (int)PedBoneId.LeftThumb2); NativeFunction.Natives.ATTACH_ENTITY_TO_ENTITY(notepad, PedsManager.LocalPlayer(), boneIndex, 0f, 0f, 0f, 0f, 0f, 0f, true, false, false, false, 2, 1); PedsManager.LocalPlayer().Tasks.PlayAnimation("veh@busted_std", "issue_ticket_cop", 1f, AnimationFlags.Loop | AnimationFlags.UpperBodyOnly).WaitForCompletion(8000); notepad.Delete(); vehicle.IsPersistent = false; PedsManager.LocalPlayer().Tasks.PlayAnimation("random@arrests", "generic_radio_enter", 0.7f, AnimationFlags.UpperBodyOnly | AnimationFlags.StayInEndFrame).WaitForCompletion(1500); GameFiber.Sleep(2000); FunctionsLSPDFR.PlayScannerAudioUsingPosition("INTRO_01 OFFICERS_REPORT_02 ILLEGALLY_PARKED_VEHICLE IN_OR_ON_POSITION INTRO_02 OUTRO_03 TARGET_VEHICLE_LICENCE_PLATE UHH" + licencePlateAudioMessage + " NOISE_SHORT CODE4_ADAM OFFICER_INTRO_02 PROCEED_WITH_PATROL NOISE_SHORT OUTRO_02", PedsManager.LocalPlayer().Position); PedsManager.LocalPlayer().Tasks.PlayAnimation("random@arrests", "generic_radio_exit", 1.0f, AnimationFlags.UpperBodyOnly); ParkingTicketsEventHandler.AlreadyGivedTicketsLicencePlateCollection.Add(vehicle.LicensePlate); }
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); }
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; } }); } }); }
private void DealWithBody(Ped body) { bodiesBeingHandled.Add(body); passenger.Tasks.GoToOffsetFromEntity(body, 10000, -2.0f, -1.0f, 8.0f); driver.Tasks.GoToOffsetFromEntity(body, 10000, 2.4f, 1.0f, 8.0f).WaitForCompletion(); if (Vector3.Distance(driver.Position, Game.LocalPlayer.Character.Position) < 60f) { Rage.Object camera = new Rage.Object("prop_ing_camera_01", driver.GetOffsetPosition(Vector3.RelativeTop * 30)); driver.Tasks.PlayAnimation("anim@mp_player_intupperphotography", "idle_a_fp", 8.0F, AnimationFlags.None); camera.Heading = driver.Heading - 180; camera.Position = driver.GetOffsetPosition(Vector3.RelativeTop * 0.68f + Vector3.RelativeFront * 0.33f); camera.IsPositionFrozen = true; Vector3 dirVect = body.Position - driver.Position; dirVect.Normalize(); GameFiber.Wait(900); NativeFunction.Natives.DRAW_SPOT_LIGHT(driver.GetOffsetPosition(Vector3.RelativeFront * 0.5f).X, driver.GetOffsetPosition(Vector3.RelativeFront * 0.5f).Y, driver.GetOffsetPosition(Vector3.RelativeFront * 0.5f).Z, dirVect.X, dirVect.Y, dirVect.Z, 100, 100, 100, 90.0f, 50.0f, 90.0f, 80.0f, 90.0f); cameraSound.Play(); GameFiber.Wait(1500); NativeFunction.Natives.DRAW_SPOT_LIGHT(driver.GetOffsetPosition(Vector3.RelativeFront * 0.5f).X, driver.GetOffsetPosition(Vector3.RelativeFront * 0.5f).Y, driver.GetOffsetPosition(Vector3.RelativeFront * 0.5f).Z, dirVect.X, dirVect.Y, dirVect.Z, 100, 100, 100, 90.0f, 50.0f, 90.0f, 80.0f, 90.0f); cameraSound.Play(); GameFiber.Wait(1500); NativeFunction.Natives.DRAW_SPOT_LIGHT(driver.GetOffsetPosition(Vector3.RelativeFront * 0.5f).X, driver.GetOffsetPosition(Vector3.RelativeFront * 0.5f).Y, driver.GetOffsetPosition(Vector3.RelativeFront * 0.5f).Z, dirVect.X, dirVect.Y, dirVect.Z, 100, 100, 100, 90.0f, 50.0f, 90.0f, 80.0f, 90.0f); cameraSound.Play(); GameFiber.Wait(1000); camera.Delete(); Game.DisplaySubtitle("~b~Driver~w~: I've got enough pictures, I'll time stamp them.", 4000); passenger.Tasks.PlayAnimation("amb@medic@standing@tendtodead@enter", "enter", 8.0F, AnimationFlags.None); GameFiber.Wait(1000); passenger.Tasks.PlayAnimation("amb@medic@standing@tendtodead@base", "base", 8.0F, AnimationFlags.None); GameFiber.Wait(1000); passenger.Tasks.PlayAnimation("amb@medic@standing@tendtodead@exit", "exit", 8.0F, AnimationFlags.None).WaitForCompletion(); GameFiber.Wait(1000); } Game.DisplaySubtitle("~b~Passenger~w~: " + GetCauseOfDeathPrelude() + GetCauseOfDeathString(body) + "~b~.", 6000); if (body.Exists()) { if (deadBodies.Contains(body)) { deadBodies.Remove(body); } if (bodiesBeingHandled.Contains(body)) { bodiesBeingHandled.Remove(body); } if (!body.IsInAnyVehicle(true)) { bodyBags.Add(new Rage.Object("xm_prop_body_bag", body.Position) { IsPositionFrozen = false, }); } if (body.Exists()) { body.Delete(); } } GameFiber.Wait(2500); }
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 void CheckForDeliverTicketTrigger() { if (!Globals.HasTrafficTicketsInHand() && (ShouldEndPullover.HasValue && ShouldEndPullover.Value) && !Game.LocalPlayer.Character.HasScenario()) { ShouldEndPullover = null; GameFiber.StartNew(() => { if (Game.LocalPlayer.LastVehicle && !Game.LocalPlayer.LastVehicle.HasDriver) { Game.DisplayNotification("The driver will wait until you are back in your vehicle before taking off"); } while (Game.LocalPlayer.LastVehicle && !Game.LocalPlayer.LastVehicle.HasDriver) { GameFiber.Yield(); //Wait for the player to enter their vehicle } Function.Log("Starting Ending pull over wait timer for ped to leave"); var stopAt = DateTime.Now.AddMilliseconds(5000); //have the sadPed drive off in 5 seconds if the traffic stop isnt over while (DateTime.Now < stopAt) { GameFiber.Yield(); } try { lock (mPromptedCitations) mPromptedCitations.Clear(); var handle = Functions.GetCurrentPullover(); if (handle != null) { Functions.ForceEndCurrentPullover(); } } catch (Exception e) { Function.LogCatch(e.Message); } }); } else if (Globals.HasTrafficTicketsInHand() && !Game.LocalPlayer.Character.HasScenario()) //only run when we have tickets and we're not already doing WORLD_HUMAN_CLIPBOARD { var stopped = World.GetEntities(Game.LocalPlayer.Character.Position, 2.5f, GetEntitiesFlags.ConsiderAllPeds); if (stopped != null && stopped.Count() > 0) { var pedsAboutToGetTheSmackDown = stopped.Select(x => x as Ped) .Where(x => x.DistanceTo(Game.LocalPlayer.Character.FrontPosition) < 2f && Globals.GetTrafficCitationsInHandForPed(x) != null); //may have to add ordering by distance foreach (var sadPed in pedsAboutToGetTheSmackDown) { if (Configs.GiveTicketsToPed.Any(x => x.IsPressed)) { //The user wants to give the sad ped the ticket now.. GameFiber.StartNew(() => { var item = new Rage.Object(new Model("prop_cs_documents_01"), Game.LocalPlayer.Character.Position); item.AttachTo(Game.LocalPlayer.Character, Game.LocalPlayer.Character.GetBoneIndex(PedBoneId.RightThumb1), new Vector3(item.Model.Dimensions.Length() * 0.4f, 0, 0), Rotator.Zero); Game.LocalPlayer.Character.Tasks.PlayAnimation("mp_common", "givetake1_b", 3f, AnimationFlags.None).WaitForCompletion(); item.Detach(); item.Delete(); }); ShouldEndPullover = true; Globals.RemoveTrafficCitationsInHandForPed(sadPed); break; } else { //Prompt the user that they can deliver the ticket OnFacingPedWithPendingTickets(null, sadPed, Globals.GetTrafficCitationsInHandForPed(sadPed)); } } } } else if (Functions.GetCurrentPullover() == null && Globals.HasTrafficTicketsInHand()) { Globals.ClearTrafficCitationsInHand(); return; } }
public Editor() { Children = new List<INestedMenu>(); #region NativeUI Initialization _menuPool = new MenuPool(); #region Main Menu _mainMenu = new UIMenu("Mission Creator", "MAIN MENU"); _mainMenu.ResetKey(Common.MenuControls.Back); _mainMenu.ResetKey(Common.MenuControls.Up); _mainMenu.ResetKey(Common.MenuControls.Down); _mainMenu.SetKey(Common.MenuControls.Up, GameControl.CellphoneUp, 0); _mainMenu.SetKey(Common.MenuControls.Down, GameControl.CellphoneDown, 0); _menuPool.Add(_mainMenu); { var menuItem = new NativeMenuItem("Create a Mission", "Create a new mission."); menuItem.Activated += (sender, item) => { CreateNewMission(); EnterFreecam(); }; _mainMenu.AddItem(menuItem); } { var menuItem = new NativeMenuItem("Play Mission", "Play a mission."); menuItem.Activated += (sender, item) => { GameFiber.StartNew(delegate { DisableControlEnabling = true; var newMenu = new LoadMissionMenu(); _mainMenu.Visible = false; newMenu.RebuildMenu(); newMenu.ParentMenu = _mainMenu; newMenu.Visible = true; while (newMenu.Visible) { newMenu.ProcessControl(); newMenu.Draw(); GameFiber.Yield(); } DisableControlEnabling = false; if (newMenu.ReturnedData == null) return; LeaveEditor(); EntryPoint.MissionPlayer.Load(newMenu.ReturnedData); }); }; _mainMenu.AddItem(menuItem); } { var menuItem = new NativeMenuItem("Load Mission", "Load your mission for editing."); menuItem.Activated += (sender, item) => { GameFiber.StartNew(delegate { DisableControlEnabling = true; _mainMenu.Visible = false; var newMenu = new LoadMissionMenu(); newMenu.RebuildMenu(); newMenu.ParentMenu = _mainMenu; newMenu.Visible = true; while (newMenu.Visible) { newMenu.ProcessControl(); newMenu.Draw(); GameFiber.Yield(); } DisableControlEnabling = false; if (newMenu.ReturnedData == null) return; LoadMission(newMenu.ReturnedData); }); }; _mainMenu.AddItem(menuItem); } { var menuItem = new NativeMenuItem("Exit to Grand Theft Auto V", "Leave the Mission Creator"); menuItem.Activated += (sender, item) => { if(!EntryPoint.MissionPlayer.IsMissionPlaying) LeaveEditor(); else { GameFiber.StartNew(delegate { _mainMenu.Visible = false; EntryPoint.MissionPlayer.FailMission(reason: "You canceled the mission."); IsInMainMenu = false; _menuPool.CloseAllMenus(); BigMinimap = false; IsInFreecam = false; IsInEditor = false; }); } }; _mainMenu.AddItem(menuItem); } _menuPool.ToList().ForEach(menu => { menu.RefreshIndex(); menu.MouseControlsEnabled = false; menu.MouseEdgeEnabled = false; }); #endregion #region Editor Menu _missionMenu = new UIMenu("Mission Creator", "MISSION MAIN MENU"); _missionMenu.ResetKey(Common.MenuControls.Back); _missionMenu.MouseControlsEnabled = false; _missionMenu.ResetKey(Common.MenuControls.Up); _missionMenu.ResetKey(Common.MenuControls.Down); _missionMenu.SetKey(Common.MenuControls.Up, GameControl.CellphoneUp, 0); _missionMenu.SetKey(Common.MenuControls.Down, GameControl.CellphoneDown, 0); _menuPool.Add(_missionMenu); #endregion #endregion RingData = new RingData() { Display = true, Type = RingType.HorizontalCircleSkinny, Radius = 2f, Color = Color.Gray, }; MarkerData = new MarkerData() { Display = false, }; MarkerData.OnMarkerTypeChange += (sender, args) => { if (string.IsNullOrEmpty(MarkerData.MarkerType)) { if (_mainObject != null && _mainObject.IsValid()) _mainObject.Delete(); return; } var pos = Game.LocalPlayer.Character.Position; if (_mainObject != null && _mainObject.IsValid()) { pos = _mainObject.Position; _mainObject.Delete(); } GameFiber.StartNew(delegate { _mainObject = new Object(Util.RequestModel(MarkerData.MarkerType), pos); NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", _mainObject.Handle.Value, false, 0); }); }; _cutsceneUi = new CutsceneUi(); CameraClampMax = -30f; CameraClampMin = -85f; _blips = new List<Blip>(); _instructButts = new Scaleform(); if (!Directory.Exists(basePath)) { try { Directory.CreateDirectory(basePath); } catch (UnauthorizedAccessException) { Game.DisplayNotification("~r~~h~ERROR~h~~n~~w~Access denied for folder creation. Run as administrator."); } } }
public void LoadMission(MissionData tmpMiss) { if(tmpMiss.Cutscenes == null) tmpMiss.Cutscenes = new List<SerializableCutscene>(); GameFiber.StartNew(delegate { LoadInteriors(tmpMiss); foreach (var vehicle in tmpMiss.Vehicles) { var newv = new Vehicle(Util.RequestModel(vehicle.ModelHash), vehicle.Position) { PrimaryColor = Color.FromArgb((int)vehicle.PrimaryColor.X, (int)vehicle.PrimaryColor.Y, (int)vehicle.PrimaryColor.Z), SecondaryColor = Color.FromArgb((int)vehicle.SecondaryColor.X, (int)vehicle.SecondaryColor.Y, (int)vehicle.SecondaryColor.Z), }; var blip = newv.AttachBlip(); blip.Color = Color.Orange; blip.Scale = 0.7f; _blips.Add(blip); newv.Rotation = vehicle.Rotation; vehicle.SetEntity(newv); } foreach (var ped in tmpMiss.Actors) { ped.SetEntity(new Ped(Util.RequestModel(ped.ModelHash), ped.Position - new Vector3(0,0,1), ped.Rotation.Yaw) { BlockPermanentEvents = true, }); var blip = ped.GetEntity().AttachBlip(); blip.Color = Color.Orange; blip.Scale = 0.7f; _blips.Add(blip); if (ped.WeaponHash != 0) ((Ped)ped.GetEntity()).GiveNewWeapon(ped.WeaponHash, ped.WeaponAmmo, true); } foreach (var o in tmpMiss.Objects) { var newo = new Object(o.ModelHash, o.Position); newo.Position = o.Position; o.SetEntity(newo); } foreach (var spawnpoint in tmpMiss.Spawnpoints) { spawnpoint.SetEntity(new Ped(spawnpoint.ModelHash, spawnpoint.Position - new Vector3(0,0,1), spawnpoint.Rotation.Yaw) { BlockPermanentEvents = true, }); if(spawnpoint.WeaponHash != 0) ((Ped)spawnpoint.GetEntity()).GiveNewWeapon(spawnpoint.WeaponHash, spawnpoint.WeaponAmmo, true); var blip = spawnpoint.GetEntity().AttachBlip(); blip.Color = Color.White; _blips.Add(blip); } foreach (var pickup in tmpMiss.Pickups) { var tmpObject = new Rage.Object("prop_mp_repair", pickup.Position); tmpObject.Rotation = pickup.Rotation; tmpObject.Position = pickup.Position; tmpObject.IsPositionFrozen = true; pickup.SetEntity(tmpObject); } foreach (var ped in tmpMiss.Objectives.OfType<SerializableActorObjective>()) { ped.SetPed(new Ped(Util.RequestModel(ped.ModelHash), ped.Position - new Vector3(0,0,1), ped.Rotation.Yaw) { BlockPermanentEvents = true, }); if (ped.WeaponHash != 0) ((Ped)ped.GetPed()).GiveNewWeapon(ped.WeaponHash, ped.WeaponAmmo, true); var blip = ped.GetPed().AttachBlip(); blip.Color = Color.Red; blip.Scale = 0.7f; _blips.Add(blip); } foreach (var vehicle in tmpMiss.Objectives.OfType<SerializableVehicleObjective>()) { var newv = new Vehicle(Util.RequestModel(vehicle.ModelHash), vehicle.Position) { PrimaryColor = Color.FromArgb((int)vehicle.PrimaryColor.X, (int)vehicle.PrimaryColor.Y, (int)vehicle.PrimaryColor.Z), SecondaryColor = Color.FromArgb((int)vehicle.SecondaryColor.X, (int)vehicle.SecondaryColor.Y, (int)vehicle.SecondaryColor.Z), }; newv.Rotation = vehicle.Rotation; var blip = newv.AttachBlip(); blip.Color = Color.Red; blip.Scale = 0.7f; _blips.Add(blip); vehicle.SetVehicle(newv); } foreach (var pickup in tmpMiss.Objectives.OfType<SerializablePickupObjective>()) { var tmpObject = new Rage.Object("prop_mp_repair", pickup.Position); tmpObject.Rotation = pickup.Rotation; tmpObject.Position = pickup.Position; tmpObject.IsPositionFrozen = true; pickup.SetObject(tmpObject); } }); CurrentMission = tmpMiss; EnterFreecam(); menuDirty = true; }
public StageObject(Rage.Object obj) { Object = obj; }
//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()); }
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); }
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()); } }); }
public static void EnableBinoculars() { GameFiber.StartNew(delegate { _isActive = true; Rage.Object binocular = new Rage.Object("prop_binoc_01", Game.LocalPlayer.Character.Position); binocular.AttachToEntity(Game.LocalPlayer.Character, Game.LocalPlayer.Character.GetBoneIndex(PedBoneId.RightPhHand), Vector3.Zero, Rotator.Zero); Game.LocalPlayer.Character.Tasks.PlayAnimation("amb@world_human_binoculars@male@base", "base", 8f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop); GameFiber.Sleep(1000); Camera binocCam = new Camera(true); binocCam.AttachToEntity(binocular, new Vector3(0.0f, -0.1f, 0.0f), true); binocCam.Rotation = Game.LocalPlayer.Character.Rotation; _isTextureRenderRunning = true; Game.RawFrameRender += RawFrameRender; while (true) { //float moveSpeed = (binocCam.FOV / 100)/* * 3.0f*/; WildernessCallouts.Common.DisEnableGameControls(false, GameControl.LookUpDown, GameControl.LookLeftRight, GameControl.WeaponWheelPrev, GameControl.WeaponWheelNext, GameControl.SelectWeapon, GameControl.SelectNextWeapon, GameControl.SelectPrevWeapon, GameControl.Sprint); //float leftRight = NativeFunction.CallByName<float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.LookLeftRight); //float upDown = NativeFunction.CallByName<float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.LookUpDown); if (Controls.ToggleBinoculars.IsJustPressed() || Game.LocalPlayer.Character.IsDead || Game.LocalPlayer.Character.IsInAnyVehicle(false)) { break; } //if (/*wheelBackwards != 0*/Game.IsKeyDownRightNow(Settings.ZoomOutBinocKey) && binocCam.FOV < 75.0f) binocCam.FOV += 0.51225f; //if (/*wheelForwards != 0*/Game.IsKeyDownRightNow(Settings.ZoomInBinocKey) && binocCam.FOV > 1.0f) binocCam.FOV -= 0.51225f; //if (/*leftRight < -0.05f*/Game.IsKeyDownRightNow(Settings.LookLeftBinocKey)) binocCam.SetRotationYaw(binocCam.Rotation.Yaw + moveSpeed); //if (/*leftRight > 0.05f*/Game.IsKeyDownRightNow(Settings.LookRightBinocKey)) binocCam.SetRotationYaw(binocCam.Rotation.Yaw - moveSpeed); //if (/*upDown < -0.05f*/Game.IsKeyDownRightNow(Settings.LookUpBinocKey) && binocCam.Rotation.Pitch <= 85.0f) binocCam.SetRotationPitch(binocCam.Rotation.Pitch + moveSpeed); //if (/*upDown > 0.05f*/Game.IsKeyDownRightNow(Settings.LookDownBinocKey) && binocCam.Rotation.Pitch >= -85.0f) binocCam.SetRotationPitch(binocCam.Rotation.Pitch - moveSpeed); float moveSpeed = (binocCam.FOV / 100) * (WildernessCallouts.Common.IsUsingController() ? 3.5f : 5.25f); float upDown = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.LookUpDown) * moveSpeed; float leftRight = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.LookLeftRight) * moveSpeed; binocCam.Rotation = new Rotator(binocCam.Rotation.Pitch - upDown, binocCam.Rotation.Roll, binocCam.Rotation.Yaw - leftRight); if (binocCam.Rotation.Pitch >= 85.0f) { binocCam.SetRotationPitch(84.98f); } else if (binocCam.Rotation.Pitch <= -85.0f) { binocCam.SetRotationPitch(-84.98f); } float wheelForwards = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.WeaponWheelPrev) * 1.81125f; float wheelBackwards = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.WeaponWheelNext) * 1.81125f; if (WildernessCallouts.Common.IsUsingController()) { binocCam.FOV -= wheelBackwards - wheelForwards; } else { binocCam.FOV -= wheelForwards - wheelBackwards; } if (binocCam.FOV > 75.0f) { binocCam.FOV = 75.0f; } else if (binocCam.FOV < 1.0f) { binocCam.FOV = 1.0f; } if (Controls.ToggleBinocularsHeliCamNightVision.IsJustPressed() && !WildernessCallouts.Common.IsNightVisionActive() && !WildernessCallouts.Common.IsThermalVisionActive()) { NativeFunction.Natives.PLAY_SOUND_FRONTEND(-1, "THERMAL_VISION_GOGGLES_ON_MASTER", 0, 1); WildernessCallouts.Common.SetNightVision(true); GameFiber.Sleep(25); } else if (Controls.ToggleBinocularsHeliCamNightVision.IsJustPressed() && WildernessCallouts.Common.IsNightVisionActive()) { NativeFunction.Natives.PLAY_SOUND_FRONTEND(-1, "THERMAL_VISION_GOGGLES_OFF_MASTER", 0, 1); WildernessCallouts.Common.SetNightVision(false); GameFiber.Sleep(25); } if (Controls.ToggleBinocularsHeliCamThermalVision.IsJustPressed() && !WildernessCallouts.Common.IsThermalVisionActive() && !WildernessCallouts.Common.IsNightVisionActive()) { NativeFunction.Natives.PLAY_SOUND_FRONTEND(-1, "THERMAL_VISION_GOGGLES_ON_MASTER", 0, 1); WildernessCallouts.Common.SetThermalVision(true); GameFiber.Sleep(25); } else if (Controls.ToggleBinocularsHeliCamThermalVision.IsJustPressed() && WildernessCallouts.Common.IsThermalVisionActive()) { NativeFunction.Natives.PLAY_SOUND_FRONTEND(-1, "THERMAL_VISION_GOGGLES_OFF_MASTER", 0, 1); WildernessCallouts.Common.SetThermalVision(false); GameFiber.Sleep(25); } if (!Game.LocalPlayer.Character.IsPlayingAnimation("amb@world_human_binoculars@male@base", "base")) { Game.LocalPlayer.Character.Tasks.PlayAnimation("amb@world_human_binoculars@male@base", "base", 8f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop); } Game.LocalPlayer.Character.Heading = binocCam.Rotation.Yaw; //if (Settings.General.IsDebugBuild) Game.DisplaySubtitle("FOV: " + binocCam.FOV.ToString() + " PITCH: " + binocCam.Rotation.Pitch + " YAW: " + binocCam.Rotation.Yaw + " MOVE SPEED: " + moveSpeed.ToString(), 1000); GameFiber.Yield(); } if (WildernessCallouts.Common.IsNightVisionActive()) { NativeFunction.Natives.PLAY_SOUND_FRONTEND(-1, "THERMAL_VISION_GOGGLES_OFF_MASTER", 0, 1); WildernessCallouts.Common.SetNightVision(false); } if (WildernessCallouts.Common.IsThermalVisionActive()) { NativeFunction.Natives.PLAY_SOUND_FRONTEND(1, "THERMAL_VISION_GOGGLES_OFF_MASTER", 0, 1); WildernessCallouts.Common.SetThermalVision(false); } binocCam.Delete(); _isTextureRenderRunning = false; Game.RawFrameRender -= RawFrameRender; Game.LocalPlayer.Character.Tasks.Clear(); GameFiber.Sleep(250); binocular.Delete(); WildernessCallouts.Common.DisEnableGameControls(true, GameControl.LookUpDown, GameControl.LookLeftRight, GameControl.WeaponWheelPrev, GameControl.WeaponWheelNext, GameControl.SelectWeapon, GameControl.SelectNextWeapon, GameControl.SelectPrevWeapon, GameControl.Sprint); _isActive = false; }); }
public override bool OnBeforeCalloutDisplayed() { Game.LogTrivial("[FireyCallouts][Log] Initialising 'Campfire' callout."); int fireAmplify; float offsetx, offsety, offsetz; decision = mrRandom.Next(0, 8); int makeFire = mrRandom.Next(0, 10); int hasWeapons = mrRandom.Next(0, 4); // Check locations around 800f to the player List <Vector3> possibleLocations = new List <Vector3>(); foreach (Vector3 l in locations) { if (l.DistanceTo(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeFront)) < 800f) { possibleLocations.Add(l); } } if (possibleLocations.Count < 1) { return(AbortCallout()); } // Random location for the fire int chosenLocation = mrRandom.Next(0, possibleLocations.Count); spawnPoint = possibleLocations[chosenLocation]; ShowCalloutAreaBlipBeforeAccepting(spawnPoint, 30f); AddMinimumDistanceCheck(40f, spawnPoint); CalloutMessage = "Campfire"; CalloutPosition = spawnPoint; // Lower spawn point due to the wood spawning in mid air spawnPoint.Z -= 2; fireWood = new Rage.Object("prop_fncwood_16g", spawnPoint); fireWood.MakePersistent(); if (decision < 4) { // No one there nobodyThere = true; } else { // People there - spawn 2 to 4 people int maxPeds = mrRandom.Next(2, 5); int suspectWander = mrRandom.Next(0, 9); int weaponsGiven = 0; for (int ii = 0; ii < maxPeds; ii++) { suspects.Add(new Ped(spawnPoint.Around2D(5f)) { IsPersistent = true, BlockPermanentEvents = true }); if (weaponsGiven < hasWeapons) { suspects[ii].Inventory.GiveNewWeapon(new WeaponAsset(weaponList[mrRandom.Next(0, weaponList.Length)]), 8, true); weaponsGiven++; } if (suspectWander > 6) { suspects[ii].Tasks.Wander(); nobodyThere = true; } } } if (makeFire > 2) { fireBurning = true; int maxFires = 7; if (nobodyThere && mrRandom.Next(0, 10) < 7) { maxFires = mrRandom.Next(20, 40); } // Create Fire for (int f = 1; f < maxFires; f++) { // Spawn several fires with random offset positions to generate a bigger fire fireAmplify = mrRandom.Next(0, 4); offsetx = fireAmplify * (f / 50); fireAmplify = mrRandom.Next(0, 3); offsety = fireAmplify * (f / 50); fireAmplify = mrRandom.Next(0, 2); offsetz = fireAmplify * (1 / 50); fireAmplify = mrRandom.Next(0, 2); if (fireAmplify == 0) { offsetx = -offsetx; } fireAmplify = mrRandom.Next(0, 2); if (fireAmplify == 0) { offsety = -offsety; } // These fires do not extinguish by themselves. fire = NativeFunction.Natives.StartScriptFire <uint>(spawnPoint.X + offsetx, spawnPoint.Y + offsety, spawnPoint.Z + offsetz, 25, true); fireList.Add(fire); } } suspectsDead = 0; suspectsArrested = 0; dialogueChoice = mrRandom.Next(0, dialogues.Count); investigationChoiceBurning = mrRandom.Next(0, 2); investigationChoiceNotBurning = mrRandom.Next(2, 4); Functions.PlayScannerAudioUsingPosition("ASSISTANCE_REQUIRED IN_OR_ON_POSITION", spawnPoint); Functions.PlayScannerAudio("UNITS_RESPOND_CODE_03"); Game.DisplayNotification("web_lossantospolicedept", "web_lossantospolicedept", "~y~FireyCallouts", "~r~Campfire", "~w~Someone called because of a campfire. Investigate the situation. Respond ~r~Code 2"); return(base.OnBeforeCalloutDisplayed()); }
public static void MakeMissionObject(this Rage.Object obj) => obj.IsPersistent = true;
public ParkingTicket(bool create = true) { if (!create) { return; } Vehicle[] nearbyCars = playerPed.GetNearbyVehicles(1); if (nearbyCars.Length == 0) { return; } if (Functions.IsPlayerPerformingPullover()) { Game.DisplayHelp("Finish your ~b~traffic stop ~s~before reporting a vehicle for a parking offence."); return; } car = nearbyCars[0]; car.IsPersistent = true; if (Vector3.Distance(playerPed.Position, car.Position) > 3.7f) { return; } if (TrafficPolicerHandler.vehiclesTicketedForParking.Contains(car)) { Game.DisplayNotification("You have already given that vehicle a ~b~parking ticket."); Functions.PlayScannerAudio("BEEP"); return; } if (car.IsPoliceVehicle) { Game.DisplayHelp("~b~Police vehicles ~s~are exempt from parking laws.", 5000); Functions.PlayScannerAudio("BEEP"); return; } if (Vector3.Distance(playerPed.Position, car.Position) > 2.3f) { Game.DisplayHelp("You need to be ~b~closer~s~ to the vehicle.", 4000); return; } Vector3 directionFromPedToCar = (car.Position - playerPed.Position); directionFromPedToCar.Normalize(); playerPed.Tasks.AchieveHeading(MathHelper.ConvertDirectionToHeading(directionFromPedToCar)).WaitForCompletion(1800); string modelName = car.Model.Name.ToLower(); if (vowels.Contains <string>(modelName[0].ToString())) { article = "an"; } else { article = "a"; } if (numbers.Contains <string>(modelName.Last().ToString())) { modelName = modelName.Substring(0, modelName.Length - 1); } modelName = char.ToUpper(modelName[0]) + modelName.Substring(1); string licencePlate = car.LicensePlate; foreach (char character in licencePlate) { if (!Char.IsWhiteSpace(character)) { licencePlateAudioMessage = licencePlateAudioMessage + " " + character; licencePlateNotificationMessage = licencePlateNotificationMessage + character; } } Game.DisplayNotification("~g~Traffic Officer ~b~" + TrafficPolicerHandler.DivisionUnitBeat + " ~s~is reporting an ~r~illegally parked vehicle."); Game.DisplayNotification("~b~Processing a parking ticket for " + article + " ~r~" + modelName + "~b~ with licence plate: ~r~" + licencePlateNotificationMessage + "."); Game.DisplayNotification("~b~The offending ~r~" + modelName + " ~b~is parked on ~o~" + World.GetStreetName(car.Position) + "."); if (TrafficPolicerHandler.IsLSPDFRPlusRunning) { API.LSPDFRPlusFunctions.AddCountToStatistic(Main.PluginName, "Parking tickets issued"); } playerPed.Inventory.GiveNewWeapon(new WeaponAsset("WEAPON_UNARMED"), 0, true); Rage.Object notepad = new Rage.Object("prop_notepad_02", playerPed.Position); int boneIndex = NativeFunction.Natives.GET_PED_BONE_INDEX <int>(playerPed, (int)PedBoneId.LeftThumb2); NativeFunction.Natives.ATTACH_ENTITY_TO_ENTITY(notepad, playerPed, boneIndex, 0f, 0f, 0f, 0f, 0f, 0f, true, false, false, false, 2, 1); playerPed.Tasks.PlayAnimation("veh@busted_std", "issue_ticket_cop", 1f, AnimationFlags.Loop | AnimationFlags.UpperBodyOnly).WaitForCompletion(8000); notepad.Delete(); Game.DisplayNotification("~g~Traffic Officer ~b~" + TrafficPolicerHandler.DivisionUnitBeat + " ~s~is reporting an ~r~illegally parked vehicle."); Game.DisplayNotification("~b~Processing a parking ticket for " + article + " ~r~" + modelName + "~b~ with licence plate: ~r~" + licencePlateNotificationMessage + "."); Game.DisplayNotification("~b~The offending ~r~" + modelName + " ~b~is parked on ~o~" + World.GetStreetName(car.Position) + "."); playerPed.Tasks.PlayAnimation("random@arrests", "generic_radio_enter", 0.7f, AnimationFlags.UpperBodyOnly | AnimationFlags.StayInEndFrame).WaitForCompletion(1500); Functions.PlayScannerAudioUsingPosition("WE_HAVE_01 ILLEGALLY_PARKED_VEHICLE IN_OR_ON_POSITION INTRO_02 TARGET_VEHICLE_LICENCE_PLATE UHH" + licencePlateAudioMessage + " OUTRO_03 NOISE_SHORT INTRO_01 CODE4_ADAM PROCEED_WITH_PATROL NOISE_SHORT", playerPed.Position); TrafficPolicerHandler.vehiclesTicketedForParking.Add(car); car.IsPersistent = false; GameFiber.Sleep(5900); Game.DisplayNotification("~g~Traffic Officer ~b~" + TrafficPolicerHandler.DivisionUnitBeat + " ~s~is reporting an ~r~illegally parked vehicle."); Game.DisplayNotification("~b~Processing a parking ticket for " + article + " ~r~" + modelName + "~b~ with licence plate: ~r~" + licencePlateNotificationMessage + "."); Game.DisplayNotification("~b~The offending ~r~" + modelName + " ~b~is parked on ~o~" + World.GetStreetName(car.Position) + "."); playerPed.Tasks.PlayAnimation("random@arrests", "generic_radio_exit", 1.0f, AnimationFlags.UpperBodyOnly); }
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); }
public static void Command_SynchronizedSceneTest() { if (BenchThreadActivated) { return; } GameFiber.StartNew(delegate { BenchThreadActivated = true; SynchronizedScene syncScene = null; List <uint> benchHash = new List <uint>() { 0x6ba514ac, //prop_bench_01a 0x7977b051, //prop_bench_01b 0xb78a2c75, //prop_bench_01c 0xda867f80, //prop_bench_02 0xc0a6cbcd, //prop_bench_03 0xd2786f70, //prop_bench_04 0x9ec80810, //prop_bench_05 0xb17ead7d, //prop_bench_06 0xfbbe41fb, //prop_bench_07 0xe7ed1a59, //prop_bench_08 0xfa11bea2, //prop_bench_09 0x1a117fd1, //prop_bench_10 0x4cece57b, //prop_bench_11 0xfbca504f, //prop_fib_3b_bench 0x723e2ae0, //prop_ld_bench01 0x0ff3a92b, //prop_wait_bench_01 0x5515a05a, //v_res_fh_benchlong 0x883cb2e8, //v_res_fh_benchshort 0xbac3f7a8, //v_ind_rc_bench 0x90aa8a87, //hei_heist_stn_benchshort }; Rage.Object bench = null; int benchStatus = 0; Vector3 benchInitialPos = Vector3.Zero; Vector3 sitPos = Vector3.Zero; Rage.Task closeTask = null; string sitStr = Game.GetLocalizedString("MPTV_WALK"); //Press ~INPUT_CONTEXT~ to sit down. string standUpStr = Game.GetLocalizedString("MPOFSEAT_PCEXIT"); string[] benchIdles = { "idle_a", "idle_b", "idle_c" }; AnimationDictionary seating = Game.LocalPlayer.Character.IsMale ? "anim@amb@office@seating@male@var_a@base@" : "anim@amb@office@seating@female@var_d@base@"; seating.LoadAndWait(); while (true) { GameFiber.Yield(); if (Game.LocalPlayer.Character.IsInAnyVehicle(false) || Game.LocalPlayer.Character.IsDead || Game.IsPaused || Game.Console.IsOpen || Game.IsScreenFadingOut) { continue; } switch (benchStatus) { case 0: Entity[] objs = World.GetEntities(Game.LocalPlayer.Character.Position, 2f, GetEntitiesFlags.ConsiderAllObjects).ToArray(); bench = (Rage.Object)objs.Where(x => x && benchHash.Contains(x.Model.Hash)).OrderBy(x => Vector3.DistanceSquared(x.Position, Game.LocalPlayer.Character)).FirstOrDefault(); if (!bench) { break; } Game.DisplayHelp(sitStr, 100); if (Game.IsControlPressed(2, GameControl.Context)) { benchStatus = 1; } break; case 1: sitPos = bench.Position + bench.RightVector * 0.85f; benchInitialPos = sitPos + bench.ForwardVector * -1; closeTask = Game.LocalPlayer.Character.Tasks.FollowNavigationMeshToPosition(benchInitialPos, bench.Heading - 180, 1f, 10000); benchStatus = 2; break; case 2: if (closeTask.Status == TaskStatus.InProgress) { break; } syncScene = new SynchronizedScene(sitPos, bench.Rotation); synchronizedScenes.Add(syncScene); syncScene.TaskToPed(Game.LocalPlayer.Character, seating, "enter", 13); benchStatus = 3; break; case 3: if (syncScene.Phase != 1f) { break; } syncScene = new SynchronizedScene(sitPos, bench.Rotation); synchronizedScenes.Add(syncScene); syncScene.TaskToPed(Game.LocalPlayer.Character, seating, "base", 13, playbackRate: 1148846080); benchStatus = 4; break; case 4: Game.DisplayHelp(standUpStr, 100); if (Game.IsControlPressed(2, GameControl.ScriptRRight)) { benchStatus = 5; } if (syncScene.Phase != 1f) { break; } syncScene = new SynchronizedScene(sitPos, bench.Rotation); synchronizedScenes.Add(syncScene); syncScene.TaskToPed(Game.LocalPlayer.Character, seating, benchIdles.GetRandomElement(), 13, playbackRate: 1148846080); benchStatus = 3; break; case 5: syncScene = new SynchronizedScene(sitPos, bench.Rotation); synchronizedScenes.Add(syncScene); syncScene.TaskToPed(Game.LocalPlayer.Character, seating, "exit", 13, playbackRate: 1000f); benchStatus = 6; break; case 6: if (syncScene.Phase != 1f) { break; } Game.LocalPlayer.Character.Tasks.Clear(); synchronizedScenes.ForEach(x => { if (x.IsValid()) { x.Delete(); } }); synchronizedScenes = new List <SynchronizedScene>(); benchStatus = 0; break; } } }); }
/// <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(400f)); EWorldArea spawnZone = WorldZone.GetArea(spawnPoint); if (spawnZone == EWorldArea.Los_Santos) { return(false); } if (Vector3.Distance(Game.LocalPlayer.Character.Position, spawnPoint) < 30.0f) { return(false); } int a = Globals.Random.Next(12, 30); rockModel.Shuffle(); for (int i = 1; i < a; i++) { Vector3 spawnPos = spawnPoint.AroundPosition(8.5f); Vector3 spawnPos2 = spawnPos + new Vector3(MathHelper.GetRandomSingle(0.0f, 8.0f), MathHelper.GetRandomSingle(0.0f, 8.0f), 325.0f); Rage.Object rock = new Rage.Object(rockModel.GetRandomElement(), spawnPos2.ToGroundUsingRaycasting(Game.LocalPlayer.Character)); //Game.LogTrivial("1 : ~b~" + rock.Position.Z.ToString()); rock.Heading = MathHelper.GetRandomSingle(0.0f, 360.0f); //rock.SetPositionZ(funct.GetGroundZForVector3(rock.Position) + 0.125f); NativeFunction.Natives.SET_ACTIVATE_OBJECT_PHYSICS_AS_SOON_AS_IT_IS_UNFROZEN(rock, true); rocksList.Add(rock); } foreach (Rage.Object rocks in rocksList) { if (rocks.Exists()) { float z = rocks.Position.GetGroundZ(); //Game.LogTrivial("2 : ~r~" + rocks.Position.Z.ToString()); if (rocks.Exists()) { rocks.SetPositionZ(z); } } } foreach (Rage.Object rocks in rocksList) { if (!rocks.Exists()) { return(false); } if (rocks.Exists() && rocks.Position.Z < 1.25f) { return(false); } } //Now we have spawned them, check they actually exist and if not return false (preventing the callout from being accepted and aborting it) //if (!rock.Exists()) return false; // Show the user where the pursuit is about to happen and block very close peds. this.ShowCalloutAreaBlipBeforeAccepting(spawnPoint, 35f); this.AddMinimumDistanceCheck(20f, spawnPoint); // Set up our callout message and location this.CalloutMessage = "Rocks blocking the road"; this.CalloutPosition = spawnPoint; LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("WE_HAVE ROAD_BLOCKED IN_OR_ON_POSITION UNITS_RESPOND_CODE_02", spawnPoint); return(base.OnBeforeCalloutDisplayed()); }
public static void RoadSignsMainLogic() { GameFiber.StartNew(delegate { createRoadSignsMenu(); try { while (true) { GameFiber.Yield(); if (PlaceSignMenu.Visible && EnablePreviewItem.Checked) { if (TrafficSignPreview.Exists()) { if (TrafficSignPreview.DistanceTo2D(DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString()))) > 0.4f) { TrafficSignPreview.Position = DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString())); TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z + 3f); } TrafficSignPreview.Rotation = RotationToPlaceAt; if (barriersList.Collection[barriersList.Index].Value.ToString() == "Stripes Left") { //TrafficSignPreview.Heading = Game.LocalPlayer.Character.Heading + 180f; TrafficSignPreview.Heading += 180f; } TrafficSignPreview.Heading += float.Parse(HeadingItem.Collection[HeadingItem.Index].Value.ToString()); int waitCount = 0; while (TrafficSignPreview.HeightAboveGround > 0.01f) { GameFiber.Yield(); TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z - (TrafficSignPreview.HeightAboveGround * 0.75f)); //Game.LogTrivial("Heighaboveground: " + TrafficSignPreview.HeightAboveGround); waitCount++; if (waitCount >= 1000) { break; } } TrafficSignPreview.IsPositionFrozen = true; TrafficSignPreview.Opacity = 0.7f; TrafficSignPreview.NeedsCollision = false; NativeFunction.Natives.SET_ENTITY_COLLISION(TrafficSignPreview, false, false); } if (SignTypeToPlace == SignTypes.Barrier && !TrafficSignPreview.Exists()) { if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } TrafficSignPreview = new Rage.Object(barriersToChooseFrom[barriersList.Index], DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString()))); TrafficSignPreview.Rotation = RotationToPlaceAt; TrafficSignPreview.NeedsCollision = false; } else if (SignTypeToPlace == SignTypes.Cone && !TrafficSignPreview.Exists()) { if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } TrafficSignPreview = new Rage.Object(conesToChooseFrom[conesList.Index], DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString()))); TrafficSignPreview.Rotation = RotationToPlaceAt; TrafficSignPreview.NeedsCollision = false; } } else { if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } } if (!PlaceSignMenu.Visible) { if (!Game.LocalPlayer.Character.IsInAnyVehicle(false)) { if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyCombinationDownComputerCheck(placeSignShortcutKey, placeSignShortcutModifierKey)) { RotationToPlaceAt = Game.LocalPlayer.Character.Rotation; dropSign(SignTypeToPlace == SignTypes.Barrier ? barriersToChooseFrom[barriersList.Index] : conesToChooseFrom[conesList.Index], false, Game.LocalPlayer.Character.GetOffsetPositionFront(2), 0); Game.LogTrivial("Shortcut Sign dropped"); Rage.Native.NativeFunction.Natives.SET_PED_STEALTH_MOVEMENT(Game.LocalPlayer.Character, 0, 0); } else if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyCombinationDownComputerCheck(removeAllSignsKey, removeAllSignsModifierKey)) { removeAllSigns(); } } } } } catch { removeAllSigns(); if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } } }); }
public SerializableObject CreateObject(Model model, Vector3 pos, Rotator rot) { var tmpObject = new Object(model, pos); tmpObject.Rotation = rot; tmpObject.Position = pos; var tmpObj = new SerializableObject(); tmpObj.SetEntity(tmpObject); tmpObj.SpawnAfter = 0; tmpObj.RemoveAfter = 0; CurrentMission.Objects.Add(tmpObj); return tmpObj; }
public void Display(MissionData data) { Clear(); #region Player { var item = new UIMenuItem("Player"); var dict = StaticData.PedData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Player Skin", "PLACE SPAWNPOINT"); menu.Build("Main Characters"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.PlayerSpawnOpen = true; Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; GameFiber.StartNew(delegate { var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) Editor.MarkerData.RepresentedBy.Delete(); Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; Editor.PlayerSpawnOpen = false; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Objectives { var item = new UIMenuItem("Objectives"); var newMenu = new ObjectivePlacementMenu(data); Editor.Children.Add(newMenu); BindMenuToItem(newMenu, item); AddItem(item); } #endregion #region Actors { var item = new UIMenuItem("Actors"); var dict = StaticData.PedData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Actor"); menu.Build("Cops and Army"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; GameFiber.StartNew(delegate { var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) Editor.MarkerData.RepresentedBy.Delete(); Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Cars { var item = new UIMenuItem("Cars"); var dict = StaticData.VehicleData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Vehicle"); menu.Build("Muscle"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; Editor.RingData.HeightOffset = 1f; Editor.MarkerData.HeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.VehicleData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Vehicle(Util.RequestModel(hash), Game.LocalPlayer.Character.Position); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if(Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) Editor.MarkerData.RepresentedBy.Delete(); Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.VehicleData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Vehicle(Util.RequestModel(hash), Game.LocalPlayer.Character.Position); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); Vector3 max; Vector3 min; Util.GetModelDimensions(veh.Model, out max, out min); Editor.RingData.HeightOffset = min.Z - max.Z + 0.2f; Editor.MarkerData.HeightOffset = min.Z - max.Z + 0.2f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Pickups { var item = new UIMenuItem("Pickups"); var dict = StaticData.PickupData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Weapon"); menu.Build("Pistols"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = false; Editor.MarkerData.RepresentationHeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.PickupData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel("prop_mp_repair"), pos); Editor.PlacedWeaponHash = hash; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) Editor.MarkerData.RepresentedBy.Delete(); Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.MarkerData.RepresentationHeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; Editor.PlacedWeaponHash = 0; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { var hash = StaticData.PickupData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; Editor.PlacedWeaponHash = hash; //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; }); }; } #endregion #region Objects { { var item = new UIMenuItem("Objects"); var dict = StaticData.ObjectData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Model"); menu.Build("Ramps"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; Editor.MarkerData.RepresentationHeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.ObjectData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel(hash), pos); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) Editor.MarkerData.RepresentedBy.Delete(); Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.MarkerData.RepresentationHeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.ObjectData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel(hash), pos); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } } #endregion RefreshIndex(); }
public SerializableObject CreateObject(SerializableObject orig) { var tmpObject = new Object(orig.GetEntity().Model, orig.GetEntity().Position); tmpObject.Rotation = orig.GetEntity().Rotation; tmpObject.Position = orig.GetEntity().Position; var tmpObj = (SerializableObject)orig.Clone(); tmpObj.SetEntity(tmpObject); CurrentMission.Objects.Add(tmpObj); return tmpObj; }
public void Display(MissionData data) { Clear(); #region Player { var item = new NativeMenuItem("Player"); var dict = StaticData.PedData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Player Skin", "PLACE SPAWNPOINT"); menu.Build("Main Characters"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.PlayerSpawnOpen = true; Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; GameFiber.StartNew(delegate { var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { Editor.MarkerData.RepresentedBy.Delete(); } Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; Editor.PlayerSpawnOpen = false; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Objectives { var item = new NativeMenuItem("Objectives"); var newMenu = new ObjectivePlacementMenu(data); Editor.Children.Add(newMenu); BindMenuToItem(newMenu, item); AddItem(item); } #endregion #region Actors { var item = new NativeMenuItem("Actors"); var dict = StaticData.PedData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Actor"); menu.Build("Cops and Army"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; GameFiber.StartNew(delegate { var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { Editor.MarkerData.RepresentedBy.Delete(); } Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Cars { var item = new NativeMenuItem("Cars"); var dict = StaticData.VehicleData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Vehicle"); menu.Build("Muscle"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; Editor.RingData.HeightOffset = 1f; Editor.MarkerData.HeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.VehicleData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Vehicle(Util.RequestModel(hash), Game.LocalPlayer.Character.Position); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { Editor.MarkerData.RepresentedBy.Delete(); } Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.VehicleData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Vehicle(Util.RequestModel(hash), Game.LocalPlayer.Character.Position); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); Vector3 max; Vector3 min; Util.GetModelDimensions(veh.Model, out max, out min); Editor.RingData.HeightOffset = min.Z - max.Z + 0.2f; Editor.MarkerData.HeightOffset = min.Z - max.Z + 0.2f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Pickups { var item = new NativeMenuItem("Pickups"); var dict = StaticData.PickupData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Weapon"); menu.Build("Pistols"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = false; Editor.MarkerData.RepresentationHeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.PickupData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel("prop_mp_repair"), pos); Editor.PlacedWeaponHash = hash; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { Editor.MarkerData.RepresentedBy.Delete(); } Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.MarkerData.RepresentationHeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; Editor.PlacedWeaponHash = 0; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { var hash = StaticData.PickupData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; Editor.PlacedWeaponHash = hash; //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; }); }; } #endregion #region Objects { { var item = new NativeMenuItem("Objects"); var dict = StaticData.ObjectData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Model"); menu.Build("Ramps"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; Editor.MarkerData.RepresentationHeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.ObjectData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel(hash), pos); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { Editor.MarkerData.RepresentedBy.Delete(); } Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.MarkerData.RepresentationHeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.ObjectData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel(hash), pos); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } } #endregion RefreshIndex(); }
public override bool OnBeforeCalloutDisplayed() { _Location1 = new Vector3(-10.93565f, -1434.329f, 31.11683f); _Location2 = new Vector3(-1.838376f, 523.2645f, 174.6274f); _Location3 = new Vector3(-801.5516f, 178.7447f, 72.83471f); _Location4 = new Vector3(-801.5516f, 178.7447f, 72.83471f); _Location5 = new Vector3(-812.7239f, 178.7438f, 76.74079f); _Location6 = new Vector3(3.542758f, 526.8926f, 170.6218f); _Location7 = new Vector3(-1155.698f, -1519.297f, 10.63272f); _Location8 = new Vector3(1392.589f, 3613.899f, 38.94194f); _Location9 = new Vector3(2435.457f, 4966.514f, 46.8106f); _DeadPersonSpawn = new Vector3(1162.029f, 2371.788f, 57.66312f); _Cop1Spawn = new Vector3(1174.725f, 2369.399f, 57.59957f); _Cop2Spawn = new Vector3(1167.733f, 2382.189f, 57.61982f); _Coroner1Spawn = new Vector3(1161.486f, 2369.885f, 57.76299f); _Coroner2Spawn = new Vector3(1165.3f, 2374.227f, 57.63049f); _CopVSpawn = new Vector3(1174.684f, 2375.117f, 57.6276f); _CoronerVSpawn = new Vector3(1165.686f, 2360.025f, 57.62796f); Random random = new Random(); List <string> list = new List <string> { "Location1", "Location2", "Location3", "Location4", "Location5", "Location6", "Location7", "Location8", "Location9", }; int num = random.Next(0, 9); if (list[num] == "Location1") { _MurderLocation = _Location1; } if (list[num] == "Location2") { _MurderLocation = _Location2; } if (list[num] == "Location3") { _MurderLocation = _Location3; } if (list[num] == "Location4") { _MurderLocation = _Location4; } if (list[num] == "Location5") { _MurderLocation = _Location5; } if (list[num] == "Location6") { _MurderLocation = _Location6; } if (list[num] == "Location7") { _MurderLocation = _Location7; } if (list[num] == "Location8") { _MurderLocation = _Location8; } if (list[num] == "Location9") { _MurderLocation = _Location9; } scenario = new Random().Next(0, 100); _CopV = new Vehicle(_CopCars[new Random().Next((int)_CopCars.Length)], _CopVSpawn, 76.214f); _CopV.IsEngineOn = true; _CopV.IsInteriorLightOn = true; _CopV.IsSirenOn = true; _CopV.IsSirenSilent = true; _CoronerV = new Vehicle("Speedo", _CoronerVSpawn, 22.32638f); _CoronerV.IsEngineOn = true; _CoronerV.IsInteriorLightOn = true; _CoronerV.IndicatorLightsStatus = VehicleIndicatorLightsStatus.Both; _DeadPerson = new Ped(_DeadPersonSpawn); _Murder = new Ped(_MurderLocation); _DeadPerson2 = new Ped(_Murder.GetOffsetPosition(new Vector3(0, 1.8f, 0))); _DeadPerson2.IsPersistent = true; _DeadPerson2.BlockPermanentEvents = true; _Cop1 = new Ped("s_m_y_sheriff_01", _Cop1Spawn, 0f); _Cop2 = new Ped("s_m_y_sheriff_01", _Cop2Spawn, 0f); _Coroner1 = new Ped("S_M_M_Doctor_01", _Coroner1Spawn, 0f); _Coroner2 = new Ped("S_M_M_Doctor_01", _Coroner2Spawn, 0f); _DeadPerson.Kill(); _DeadPerson.IsPersistent = true; _DeadPerson.BlockPermanentEvents = true; _Murder.IsPersistent = true; _Murder.Inventory.GiveNewWeapon(new WeaponAsset(_WepList[new Random().Next((int)_WepList.Length)]), 500, true); _Murder.BlockPermanentEvents = true; _Murder.Health = 200; _Murder.Armor = 300; NativeFunction.CallByName <uint>("TASK_AIM_GUN_AT_ENTITY", _Murder, _DeadPerson2, -1, true); _DeadPerson.Tasks.PlayAnimation("random@arrests@busted", "idle_a", 8.0F, AnimationFlags.Loop); Functions.IsPedACop(_Cop1); Functions.IsPedACop(_Cop2); _Cop1.IsInvincible = true; _Cop1.IsPersistent = true; _Cop1.BlockPermanentEvents = true; _Cop1.IsInvincible = true; _Cop1.IsPersistent = true; _Cop1.BlockPermanentEvents = true; _Coroner1.IsPersistent = true; _Coroner1.IsInvincible = true; _Coroner1.Face(_DeadPerson); _Coroner1.BlockPermanentEvents = true; _Coroner2.IsInvincible = true; _Coroner2.Face(_DeadPerson); _Coroner2.IsPersistent = true; _Coroner2.BlockPermanentEvents = true; _Coroner1.KeepTasks = false; _Coroner2.KeepTasks = false; Rage.Object camera = new Rage.Object("prop_ing_camera_01", _Coroner1.GetOffsetPosition(Vector3.RelativeTop * 30)); Rage.Object camera2 = new Rage.Object("prop_ing_camera_01", _Coroner2.GetOffsetPosition(Vector3.RelativeTop * 30)); _Coroner1.Tasks.PlayAnimation("amb@world_human_paparazzi@male@idle_a", "idle_a", 8.0F, AnimationFlags.Loop); _Coroner2.Tasks.PlayAnimation("amb@medic@standing@kneel@base", "base", 8.0F, AnimationFlags.Loop); _Cop2.Tasks.PlayAnimation("amb@world_human_cop_idles@male@idle_a", "idle_a", 1.5f, AnimationFlags.Loop); switch (new Random().Next(1, 2)) { case 1: _Scene1 = true; break; case 2: _Scene2 = true; break; } ShowCalloutAreaBlipBeforeAccepting(_DeadPersonSpawn, 100f); AddMinimumDistanceCheck(10f, _DeadPerson.Position); switch (new Random().Next(1, 2)) { case 1: CalloutMessage = "[UC]~w~ We have found a dead body and need the ~y~FIB~w~ here."; _callOutMessage = 1; break; case 2: CalloutMessage = "[UC]~w~ The police found a dead body and need the ~y~FIB~w~ here."; _callOutMessage = 2; break; } CalloutPosition = _DeadPersonSpawn; return(base.OnBeforeCalloutDisplayed()); }