public override bool OnCalloutAccepted() { calloutState = CalloutState.Enroute; SuspectBlip = Suspect.AttachBlip(); SuspectBlip.Color = System.Drawing.Color.Red; SuspectBlip.EnableRoute(System.Drawing.Color.Red); Suspect.Tasks.CruiseWithVehicle(SuspectVehicle, 75f, VehicleDrivingFlags.Emergency); // Dialouge needs to be rewritten. Mention something about a person slumped over in the back or passenger seat and that the driver was driving erratic or something, as it is, it doesnt make much sense. Game.DisplaySubtitle("Dispatch: Caller reports seeing two slumped passengers and the driver driving erraticly, no futher details at the moment. Be Advise use caution when aproching vehicle"); Game.LogTrivialDebug("Raven.Attached"); return(base.OnCalloutAccepted()); }
public override bool OnCalloutAccepted() { int r = new Random().Next(1, 3); // Create the pursuit and add the peds to the pursuit pursuit = Functions.CreatePursuit(); Functions.AddPedToPursuit(pursuit, A1); Functions.AddPedToPursuit(pursuit, A2); // Attach the blips B1 = A1.AttachBlip(); B2 = A2.AttachBlip(); if (r == 1) { // Make the peds attack the player //A2.Tasks.FightAgainstClosestHatedTarget(500f); NativeFunction.CallByName <uint>("TASK_COMBAT_PED", A2, Game.LocalPlayer.Character, 0, 1); } // Request backup Functions.RequestBackup(vehicleSpawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.AirUnit); Functions.RequestBackup(vehicleSpawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit); // Shows the player to respond to the scene. Game.DisplaySubtitle("Get to the ~r~pursuit~w~.", 6500); return(base.OnCalloutAccepted()); }
public override bool OnCalloutAccepted() { Game.LogTrivial("UnitedCallouts Log: StolenBus callout accepted."); Game.DisplayNotification("web_lossantospolicedept", "web_lossantospolicedept", "~w~UnitedCallouts", "~y~Stolen Bus", "~b~Dispatch: ~w~Try to arrest the driver to rescue the hostages. Respond with ~r~Code 3"); _Bus = new Vehicle(civVehicles[new Random().Next((int)civVehicles.Length)], _SpawnPoint); _Bus.IsPersistent = true; _Suspect = _Bus.CreateRandomDriver(); _Suspect.IsPersistent = true; _Suspect.BlockPermanentEvents = true; _Suspect.Tasks.CruiseWithVehicle(20f, VehicleDrivingFlags.Emergency); _Blip = _Suspect.AttachBlip(); _Blip.IsFriendly = false; _V1 = new Ped(_SpawnPoint); _V2 = new Ped(_SpawnPoint); _V3 = new Ped(_SpawnPoint); _V1.WarpIntoVehicle(_Bus, 4); _V2.WarpIntoVehicle(_Bus, 2); _V3.WarpIntoVehicle(_Bus, 3); if (Settings.ActivateAIBackup) { Functions.RequestBackup(_SpawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit); Functions.RequestBackup(_SpawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit); Functions.RequestBackup(_SpawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.AirUnit); } return(base.OnCalloutAccepted()); }
public override bool OnCalloutAccepted() { PoliceCar = new Vehicle(CopCarModel, SpawnPoint, SpawnHeading); PoliceCar.RandomiseLicencePlate(); PoliceCar.MakePersistent(); PoliceCar.IsSirenOn = true; PoliceCar.IsSirenSilent = true; PoliceOfficer = PoliceCar.CreateRandomDriver(); PoliceOfficer.MakeMissionPed(); PoliceOfficerBlip = PoliceOfficer.AttachBlip(); PoliceOfficerBlip.Color = Color.Green; PoliceOfficerBlip.IsRouteEnabled = true; PoliceOfficer.RelationshipGroup = "PLAYER"; SuspectCar = new Vehicle(GroundVehiclesToSelectFrom[AssortedCalloutsHandler.rnd.Next(GroundVehiclesToSelectFrom.Length)], PoliceCar.GetOffsetPosition(Vector3.RelativeFront * 9f), PoliceCar.Heading); SuspectCar.RandomiseLicencePlate(); SuspectCar.MakePersistent(); Suspect = SuspectCar.CreateRandomDriver(); Suspect.MakeMissionPed(); Suspect.WarpIntoVehicle(PoliceCar, PoliceCar.PassengerCapacity - 1); Functions.SetPedAsArrested(Suspect, true); Suspect.RelationshipGroup = "TBACKUPCRIMINAL"; MainLogic(); return(base.OnCalloutAccepted()); }
public override bool OnCalloutAccepted() { try { // Attach the blips B1 = A1.AttachBlip(); B2 = C1.AttachBlip(); B2.Color = Color.Blue; A1.BlockPermanentEvents = true; C1.BlockPermanentEvents = true; // Shows the player to respond to the scene. Game.DisplaySubtitle("Get to the ~r~pursuit~w~.", 6500); B1.EnableRoute(Color.Red); // Create the pursuit and add the peds to the pursuit pursuit = Functions.CreatePursuit(); Functions.AddPedToPursuit(pursuit, A1); Functions.AddCopToPursuit(pursuit, C1); // Request backup Functions.RequestBackup(spawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit); } catch (System.Exception ex) { Game.LogTrivial("Error is: " + ex); } return(base.OnCalloutAccepted()); }
public override bool OnCalloutAccepted() { /// <summary /// Once accepted creates the blips, the routes, and gives the ped a weapon. /// </summary suspect.IsPersistent = true; caller.Tasks.StandStill(-1); caller.IsPersistent = true; suspect.BlockPermanentEvents = true; caller.BlockPermanentEvents = true; callerBlip = caller.AttachBlip(); callerBlip.EnableRoute(System.Drawing.Color.MintCream); callerBlip.Color = System.Drawing.Color.MintCream; calloutState = CalloutState.Enroute; suspect.Tasks.Wander(); suspect.Inventory.GiveNewWeapon(1593441988, 120, false); Game.DisplayNotification("Attend to the caller to find out information."); Game.LogTrivialDebug("RG:Callout created"); return(base.OnCalloutAccepted()); }
public override bool OnCalloutAccepted() { Game.LogTrivial("(NakedPerson): Callout Accepted"); hasArrived = false; Functions.PlayScannerAudio(MathHelper.Choose(PTTAudio)); Functions.PlayScannerAudio("RESPOND_CODE_2"); Functions.PlayScannerAudio(MathHelper.Choose(End3rdPRTAudio)); Functions.PlayScannerAudio(MathHelper.Choose(NotiffSound)); Game.DisplayNotification("Respond ~b~Code 2~w~"); Functions.PlayScannerAudio(MathHelper.Choose(NotiffSound)); Game.DisplayHelp("Press ~b~End~s~ to end the callout", 6500); Functions.PlayScannerAudio(MathHelper.Choose(NotiffSound)); Game.DisplayNotification("Get on ~p~scene~w~ and try to ~g~speak~w~ with the suspect."); Functions.PlayScannerAudio(MathHelper.Choose(NotiffSound)); Game.DisplayHelp("If it's a ~r~fake call~w~, press ~b~End~w~ "); Suspect = new Ped(SpawnPoint); Suspect.IsPersistent = true; SuspectsBlip = Suspect.AttachBlip(); SuspectsBlip.Color = Color.Yellow; Game.LogTrivial("(NakedPerson): All Peds' actions loaded."); calloutArea = new Blip(SpawnPoint, 40f); calloutArea.Color = (System.Drawing.Color.Yellow); calloutArea.Alpha = 0.5f; calloutArea.EnableRoute(Color.Yellow); return(base.OnCalloutAccepted()); }
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 override bool OnCalloutAccepted() { Game.LogTrivialDebug("(LostDog Debug): Callout Accepted."); Functions.PlayScannerAudio("RESPOND_CODE_2"); Functions.PlayScannerAudio(MathHelper.Choose(End3rdPRTAudio)); hasArrived = false; OfficerFoundPet = false; Functions.PlayScannerAudio(MathHelper.Choose(NotiffSound)); Game.DisplayNotification("Respond ~b~Code 2~w~"); Game.DisplaySubtitle("Get on ~p~scene~w~ and try to find the ~p~lost~w~ pet from the owners info.", 8000); // Making new Ped and it's Blip. Owner = new Ped(OwnerSpawnPoint); Owner.IsPersistent = true; OwnersBlip = Owner.AttachBlip(); OwnersBlip.Color = Color.Yellow; OwnersBlip.EnableRoute(System.Drawing.Color.Yellow); // Making new Pet. Pet = new Ped("A_C_Chop", PetsSpawnPoint, 1f); Pet.IsPersistent = true; PetsBlip = Pet.AttachBlip(); PetsBlip.Color = Color.White; Game.LogTrivialDebug("(LostDog Debug): Owners and Pets actions loaded."); return(base.OnCalloutAccepted()); }
private void CreateScene(Vector3 spawnPoint) { Random rand = new Random(); int index = rand.Next(VehiclesToSelectFrom.Length); string randomModelName = VehiclesToSelectFrom[index]; brokenVehicle = new Vehicle(randomModelName, spawnPoint); brokenVehicle.IsPersistent = true; VehicleDoor hood = brokenVehicle.Doors[4]; hood.IsOpen = true; vehicleBlip = brokenVehicle.AttachBlip(); vehicleBlip.IsFriendly = true; /// Finds a point on the side of the road and moves the vehicle to that point. Using this method: /// BOOL _GET_ROAD_SIDE_POINT_WITH_HEADING(float x, float y, float z, float heading, Vector3* outPosition); NativeFunction.Natives.xA0F8A7517A273C05 <bool>( spawnPoint.X + 20.0f, spawnPoint.Y + 20.0f, spawnPoint.Z, brokenVehicle.Heading, out Vector3 outPosition); vehicleDesiredPosition = outPosition; driver = brokenVehicle.CreateRandomDriver(); driverBlip = driver.AttachBlip(); driverBlip.IsFriendly = true; driver.IsPersistent = true; driver.BlockPermanentEvents = true; driver.Tasks.DriveToPosition(vehicleDesiredPosition, 30.0f, VehicleDrivingFlags.FollowTraffic); brokenVehicle.EngineHealth = 100.0f; }
public override void OnStart(Ped player) { base.OnStart(player); DrunkSuspect.AttachBlip(); suspectActive = true; base.Tick += IsPedRestrained; int dice = random.Next(0, 100); if (dice < 25) { ShowDialog("[Suspect] What the f**k are you doing here!", 5000, 30f); this.Attack(player); } else if (dice > 25 && dice < 75) { ShowDialog("[Suspect] Oh f**k, who called the cops?!", 5000, 30f); this.Flee(player); } else { ShowDialog("[Suspect] F***s sake, I'm sorry officer.", 5000, 30f); this.Surrender(); } }
public async void Start() { Random random = new Random(); for (int i = 0; i < targets.Length; i++) { Ped targetPed = await Util.CreatePed(PedHash.Business01AMY, targetSpawns[i]); targetPed.Task.StartScenario("WORLD_HUMAN_AA_SMOKE", targetPed.Position); Ped[] bodyguards = await SpawnBodyguards(targetPed, random.Next(1, 4)); Function.Call(Hash.FLASH_MINIMAP_DISPLAY); Blip blip = targetPed.AttachBlip(); blip.Sprite = BlipSprite.Enemy; blip.Color = BlipColor.Red; blip.Name = Strings.MISSIONS_ASSASSINATION_BLIP; blip.Scale = 0.8f; targets[i] = new Target(targetPed, bodyguards); } Util.DisplayHelpText(Strings.MISSIONS_ASSASSINATION_INFO); Screen.ShowSubtitle(Strings.MISSIONS_ASSASSINATION_START, 15000); enableTick = true; }
public override bool OnCalloutAccepted() { Game.LogTrivial("UnitedCallouts Log: GangAttack callout accepted."); Game.DisplayNotification("web_lossantospolicedept", "web_lossantospolicedept", "~w~UnitedCallouts", "~y~Gang Attack", "~b~Dispatch: ~w~The gang members are marked on the map. Respond with ~r~Code 3"); _AG1 = new Ped("g_m_y_ballasout_01", Vector3Extension.ExtensionAround(_SpawnPoint, 20f), 0f); _AG2 = new Ped("g_m_y_ballasout_01", Vector3Extension.ExtensionAround(_SpawnPoint, 30f), 0f); _AG3 = new Ped("g_m_y_ballasout_01", Vector3Extension.ExtensionAround(_SpawnPoint, 22f), 0f); _AG4 = new Ped("g_m_y_famca_01", Vector3Extension.ExtensionAround(_SpawnPoint, 24f), 0f); _AG5 = new Ped("g_m_y_famca_01", Vector3Extension.ExtensionAround(_SpawnPoint, 26f), 0f); _AG6 = new Ped("g_m_y_famca_01", Vector3Extension.ExtensionAround(_SpawnPoint, 28f), 0f); _AG1.Inventory.GiveNewWeapon("WEAPON_MICROSMG", 5000, true); _AG2.Inventory.GiveNewWeapon("WEAPON_PISTOL", 5000, true); _AG3.Inventory.GiveNewWeapon("WEAPON_MICROSMG", 5000, true); _AG4.Inventory.GiveNewWeapon("WEAPON_MICROSMG", 5000, true); _AG5.Inventory.GiveNewWeapon("WEAPON_PISTOL", 5000, true); _AG6.Inventory.GiveNewWeapon("WEAPON_PISTOL", 5000, true); _Blip = _AG1.AttachBlip(); _Blip2 = _AG2.AttachBlip(); _Blip3 = _AG3.AttachBlip(); _Blip4 = _AG4.AttachBlip(); _Blip5 = _AG5.AttachBlip(); _Blip6 = _AG6.AttachBlip(); _Blip.EnableRoute(Color.Yellow); if (Settings.ActivateAIBackup) { Functions.RequestBackup(_SpawnPoint, LSPD_First_Response.EBackupResponseType.Code3, LSPD_First_Response.EBackupUnitType.LocalUnit); Functions.RequestBackup(_SpawnPoint, LSPD_First_Response.EBackupResponseType.Code3, LSPD_First_Response.EBackupUnitType.LocalUnit); } return(base.OnCalloutAccepted()); }
public override bool OnCalloutAccepted() { Game.LogTrivial("UnitedCallouts Log: StolenEmergencyVehicle2 callout accepted."); _PoliceCar = new Vehicle(copVehicles[new Random().Next((int)copVehicles.Length)], _SpawnPoint); _PoliceCar.IsSirenOn = true; Game.DisplayNotification("web_lossantospolicedept", "web_lossantospolicedept", "~w~UnitedCallouts", "~y~Dispatch", "Loading ~g~Information~w~ of the ~y~LSPD Database~w~..."); Functions.DisplayVehicleRecord(_PoliceCar, true); _subject = new Ped(_SpawnPoint); _subject.WarpIntoVehicle(_PoliceCar, -1); _subject.Inventory.GiveNewWeapon("WEAPON_PISTOL", 500, true); _subject.BlockPermanentEvents = true; _Blip = _subject.AttachBlip(); _pursuit = Functions.CreatePursuit(); Functions.AddPedToPursuit(_pursuit, _subject); Functions.SetPursuitIsActiveForPlayer(_pursuit, true); _pursuitCreated = true; if (Settings.ActivateAIBackup) { Functions.RequestBackup(_SpawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit); Functions.RequestBackup(_SpawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit); Functions.RequestBackup(_SpawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.AirUnit); } return(base.OnCalloutAccepted()); }
public async Task OnTick() { await Delay(10); foreach (var player in Players) { Ped ped = player.Character; if (player == Game.Player) { //continue; } // Initializing player blip Blip pedBlip = ped.AttachedBlip; if (pedBlip == null || pedBlip.Exists() == false) { pedBlip = ped.AttachBlip(); pedBlip.Name = player.Name; pedBlip.Scale = .8f; pedBlip.IsFriendly = true; } UpdateBlip(player, ped, pedBlip); } }
private void PreparationSequence() { if (ZoneBlip.Exists()) { ZoneBlip.Delete(); } SpawnSequenceInitiated = true; Game.SetRelationshipBetweenRelationshipGroups(RelationshipGroup.Cop, RelationshipGroup.Gang1, Relationship.Hate); Game.SetRelationshipBetweenRelationshipGroups(RelationshipGroup.Gang1, RelationshipGroup.Cop, Relationship.Hate); Game.SetRelationshipBetweenRelationshipGroups(RelationshipGroup.Gang1, RelationshipGroup.Player, Relationship.Hate); Game.SetRelationshipBetweenRelationshipGroups(RelationshipGroup.Player, RelationshipGroup.Gang1, Relationship.Hate); TargetFlees = Rdm.NextDouble() < 0.5f; if (!TargetFlees) { AlienBlip = Alien.AttachBlip(); AlienBlip.IsFriendly = false; AlienBlip.Name = "Fake Alien"; AlienBlip.Scale = 0.75f; Alien.Tasks.FightAgainst(Game.LocalPlayer.Character); } else { if (Functions.GetActivePursuit() != null) { Functions.ForceEndPursuit(Functions.GetActivePursuit()); } Pursuit = Functions.CreatePursuit(); Functions.AddPedToPursuit(Pursuit, Alien); Functions.SetPursuitIsActiveForPlayer(Pursuit, true); } }
public override bool OnCalloutAccepted() { GameFiber.Wait(10000); calloutState = CalloutState.Enroute; victim.Tasks.Clear(); if (r1 == 1) { victim.Health = 0; Game.LogTrivialDebug("Victim Killed"); } else if (r1 == 2) { shooter = new Ped(victim.FrontPosition); shooter.Inventory.GiveNewWeapon("WEAPON_COMBAT_KNIFE", 0, true); shooter.Tasks.FightAgainst(victim, 5000); victim.Health = 0; Game.LogTrivialDebug("Shooter spawned"); } if (victim.IsDead) { shooter.Tasks.Flee(victim, 100, 10000); GameFiber.Wait(10000); shooter.Tasks.Wander(); } victimBlip = victim.AttachBlip(); Game.DisplaySubtitle("Dispatch: ", 10000); Game.LogTrivialDebug("Raven.Attached"); return(base.OnCalloutAccepted()); }
public override bool OnCalloutAccepted() { vehicle = new Vehicle(SpawnUtil.GetRandomCivilianCarModel(), SpawnPoint) { IsPersistent = true }; driver = vehicle.CreateRandomDriver(); driver.IsPersistent = true; driver.BlockPermanentEvents = true; // Set the ped drunk NativeFunction.Natives.SET_PED_CONFIG_FLAG(driver, 100, true); driver.Tasks.CruiseWithVehicle(214f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.AllowWrongWay | VehicleDrivingFlags.AllowMedianCrossing | VehicleDrivingFlags.AvoidHighways | VehicleDrivingFlags.DriveAroundObjects); Blip = driver.AttachBlip(); Blip.Sprite = BlipSprite.Enemy; Blip.Scale = 0.5f; Blip.SetColor(BlipColor.Red); Blip.SetRouteColor(BlipColor.LightRed); ScannerMessages.DisplayDispatchText("Driver Under The Influence", "Reports of a ~y~driver~w~ under the ~r~influence~w~. Test the driver for ~r~alcohol~w~ and ~r~narcotics."); return(base.OnCalloutAccepted()); }
public override bool OnCalloutAccepted() { start = true; try { Game.LogTrivial("DocumentLack: Creating Entity"); suspectCar = new Vehicle(spawn); suspectCar.IsPersistent = true; suspect = suspectCar.CreateRandomDriver(); suspect.IsPersistent = true; Game.LogTrivial("DocumentLack: Creating Blip"); blip = suspect.AttachBlip(); blip.RouteColor = Color.Red; blip.IsRouteEnabled = true; Game.LogTrivial("DocumentLack: Entity Success, dentermine Situations"); string message; switch (situation) { case EDocumentLackSituation.Insurance: Game.LogTrivial("INSURANCE determined"); if (Integreate.StopThePed) { suspectCar.SetInsurance((HCVehicleStatus)MathHelper.GetRandomInteger(0, 1)); } Game.LogTrivial("INSURANCE set"); message = "The target vehicle has been reported as Uninsured or it's insurance has expired."; break; default: case EDocumentLackSituation.Registration: Game.LogTrivial("REGISTRATION determined"); if (Integreate.StopThePed) { suspectCar.SetRegistration((HCVehicleStatus)MathHelper.GetRandomInteger(0, 1)); } Game.LogTrivial("REGISTRATION set"); message = "The target vehicle has been reported as No registiration or it's expired."; break; } Game.LogTrivial("DocumentLack: Situations determined"); ScannerHelper.DisplayDispatchNote(message); Game.LogTrivial("Checking for Stop The Ped"); if (!Integreate.StopThePed) { Game.DisplayHelp("This callout works best if you install ~y~StopThePed~s~ by BejoIlo."); } Game.LogTrivial("Prepar done"); Game.DisplaySubtitle("Approach the ~r~suspect~s~."); return(base.OnCalloutAccepted()); } catch (Exception ex) { Game.LogExtremelyVerbose("HotCallout Debug: Failed on DocumentLack"); Game.LogExtremelyVerbose("HotCallout Debug: " + ex.GetType().Name); Game.LogExtremelyVerbose("HotCallout Debug: " + ex.Message); Game.LogExtremelyVerbose(ex.StackTrace); Game.DisplayHelp($"The \"{CalloutMessage}\" callout encounterd fatal error and must exit."); return(false); } }
public override bool OnCalloutAccepted() { // Functions.PlayScannerAudio("PTT"); Functions.PlayScannerAudio("RESPOND_CODE_2"); // Functions.PlayScannerAudio("END_3DPRT_PTT"); // hasArrived = false; // Functions.PlayScannerAudio("NOTIF_SOUND"); Game.DisplayNotification("Respond ~b~Code 2~w~"); Game.DisplayHelp("Press ~b~End~w~ to end the callout.", 5000); Game.DisplayNotification("Go on ~p~scene~w~ and try to find the ~p~lost~w~ pet from the owners info."); Game.LogTrivial("(LostCow): Callout Accepted."); //Peds and Pets Blips. Owner = new Ped(OwnerSpawnPoint); Owner.BlockPermanentEvents = true; OwnersBlip = Owner.AttachBlip(); OwnersBlip.Color = (System.Drawing.Color.Green); OwnersBlip.EnableRoute(Color.Green); Pet = new Ped("A_C_Cow", PetsSpawnPoint, 1f); Pet.BlockPermanentEvents = true; PetsBlip = Pet.AttachBlip(); PetsBlip.Color = (System.Drawing.Color.Blue); OwnersBlip.EnableRoute(System.Drawing.Color.Purple); Game.LogTrivial("(LostCow): All Owners And Ped Actions Loaded!"); return(base.OnCalloutAccepted()); }
public async override void OnStart(Ped player) { base.OnStart(player); vic = await SpawnPed(RandomUtils.GetRandomPed(), Location); PedData data = new PedData(); data.BloodAlcoholLevel = 0.07; Utilities.SetPedData(vic.NetworkId, data); vic.AlwaysKeepTask = true; vic.BlockPermanentEvents = true; PedData data1 = await Utilities.GetPedData(vic.NetworkId); string firstname = data1.FirstName; vic.AttachBlip(); Random random = new Random(); int x = random.Next(1, 100 + 1); if (x <= 40) { vic.Task.Wait(1000); //wait DrawSubtitle("~r~[" + firstname + "] ~s~Please grab me and get me out of here!", 5000); } else if (x > 40 && x <= 65) { vic.Task.ReactAndFlee(player); //run DrawSubtitle("~r~[" + firstname + "] ~s~Leave me alone!", 5000); } else { vic.Weapons.Give(WeaponHash.Pistol, 100, true, true); DrawSubtitle("~r~[" + firstname + "] ~s~DIE!", 5000); } }
private async Task OnTick() { await Delay(100); foreach (Player player in Players.Where(player => Game.Player != player)) { Ped playerPed = player.Character; Blip playerBlip = playerPed.AttachedBlip; if (playerBlip == null) { playerBlip = playerPed.AttachBlip(); } playerBlip.Name = player.Name; playerBlip.Color = GetPlayerSuitableBlipColor(player); if (API.IsPauseMenuActive()) { playerBlip.Alpha = 255; } else { FadeBlipByDistance(playerBlip); } API.ShowHeadingIndicatorOnBlip(playerBlip.Handle, true); } }
//Creates a pedestrian, assigns behavior and adds a blip if necessary. Creates a cop if cop=true, criminal if false private void SpawnPedestrian(bool cop) { if (peds.Count >= MaxPeds) { return; } int mod = 1; if (!cop) { mod *= -1; } Ped ped = World.CreatePed(RandomModel(cop), Player.Character.GetOffsetPosition(new Vector3(mod * RandomNumber(spawnRadius / 2, spawnRadius), mod * RandomNumber(spawnRadius / 2, spawnRadius), 0.0f)).ToGround()); if (Exists(ped) && ped != null) { ped.BecomeMissionCharacter(); //makes sure the pedestrian persists while player alive if (cop) { ped.RelationshipGroup = RelationshipGroup.Cop; ped.ChangeRelationship(RelationshipGroup.Criminal, Relationship.Hate); ped.ChangeRelationship(RelationshipGroup.Dealer, Relationship.Hate); ped.ChangeRelationship(RelationshipGroup.Player, Relationship.Respect); ped.MaxHealth = copHealth; ped.Health = copHealth; ped.Armor = 50; } else { ped.RelationshipGroup = RelationshipGroup.Criminal; ped.ChangeRelationship(RelationshipGroup.Cop, Relationship.Hate); ped.ChangeRelationship(RelationshipGroup.Civillian_Male, Relationship.Hate); ped.ChangeRelationship(RelationshipGroup.Civillian_Female, Relationship.Hate); ped.ChangeRelationship(RelationshipGroup.Fireman, Relationship.Hate); ped.ChangeRelationship(RelationshipGroup.Bum, Relationship.Hate); ped.ChangeRelationship(RelationshipGroup.Medic, Relationship.Hate); ped.ChangeRelationship(RelationshipGroup.Player, Relationship.Neutral); ped.MaxHealth = robberHealth; ped.Health = robberHealth; ped.Armor = 0; ped.WantedByPolice = true; ped.StartKillingSpree(true); Blip blip = ped.AttachBlip(); blips.Add(ped, blip); } ped.Task.FightAgainstHatedTargets(fightRadius); //give the pedestrian their task, will repeat RandomWeapons(ped, cop); peds.Add(ped); totalSpawned++; Wait(10); } }
public override void OnStart(Ped player) { base.OnStart(player); suspect.Weapons.Give(WeaponHash.Knife, 1, true, true); suspect.Task.FightAgainst(victim); victim.Task.ReactAndFlee(suspect); suspect.AttachBlip(); victim.AttachBlip(); }
public override bool OnCalloutAccepted() { Blip = Dealer.AttachBlip(); Blip2 = Victim.AttachBlip(); Blip.EnableRoute(Color.Yellow); Game.DisplayNotification("web_lossantospolicedept", "web_lossantospolicedept", "~w~ExampleCallouts", "~y~DrugDeal", "~b~Dispatch: ~w~Try to arrest the Dealer and the buyer!. Respond with ~y~Code 2"); return(base.OnCalloutAccepted()); }
/// <summary> /// OnCalloutAccepted is where we begin our callout's logic. In this instance we create our pursuit and add our ped from eariler to the pursuit as well /// </summary> /// <returns></returns> public override bool OnCalloutAccepted() { //We accepted the callout, so lets initilize our blip from before and attach it to our ped so we know where he is. myBlip = myPed.AttachBlip(); this.pursuit = Functions.CreatePursuit(); Functions.AddPedToPursuit(this.pursuit, this.myPed); return(base.OnCalloutAccepted()); }
public async override void OnStart(Ped player) { base.OnStart(player); vic = await SpawnPed(RandomUtils.GetRandomPed(), Location); vic.Kill(); vic.AlwaysKeepTask = true; vic.BlockPermanentEvents = true; vic.AttachBlip(); }
public async override void OnStart(Ped player) { base.OnStart(player); driver = await SpawnPed(RandomUtils.GetRandomPed(), Location + 2); Random random = new Random(); string cartype = carList[random.Next(carList.Length)]; VehicleHash Hash = (VehicleHash)API.GetHashKey(cartype); car = await SpawnVehicle(Hash, Location); driver.SetIntoVehicle(car, VehicleSeat.Driver); PlayerData playerData = Utilities.GetPlayerData(); string displayName = playerData.DisplayName; Notify("~r~[DrunkCallouts] ~y~Officer ~b~" + displayName + ",~y~ the suspect is driving a " + cartype + "!"); //Driver Data PedData data = new PedData(); data.BloodAlcoholLevel = 0.18; List <Item> items = new List <Item>(); Item BeerBottle = new Item { Name = "Beer", IsIllegal = false }; Item DogCollar = new Item { Name = "Dog Collar", IsIllegal = false }; items.Add(BeerBottle); items.Add(DogCollar); data.Items = items; Utilities.SetPedData(driver.NetworkId, data); Utilities.ExcludeVehicleFromTrafficStop(car.NetworkId, true); //Tasks driver.AlwaysKeepTask = true; driver.BlockPermanentEvents = true; API.SetPedIsDrunk(driver.GetHashCode(), true); API.SetDriveTaskMaxCruiseSpeed(driver.GetHashCode(), 35f); API.SetDriveTaskDrivingStyle(driver.GetHashCode(), 524852); driver.Task.FleeFrom(player); Notify("~o~Officer ~b~" + displayName + ",~o~ the driver is fleeing!"); car.AttachBlip(); driver.AttachBlip(); PedData data1 = await Utilities.GetPedData(driver.NetworkId); string firstname = data1.FirstName; API.Wait(6000); DrawSubtitle("~r~[" + firstname + "] ~s~Is that a bird?", 5000); }
public override bool OnCalloutAccepted() { try { // Show the player to respond Game.DisplaySubtitle("~Get to the ~r~pursuit~w~.", 6500); } catch (System.Exception ex) { Game.LogVerbose("An error occurred when trying to display the text. Error is: " + ex); } // Create the pursuit pursuit = Functions.CreatePursuit(); // Add our peds to the pursuits Functions.AddPedToPursuit(pursuit, Aggressor1); Functions.AddPedToPursuit(pursuit, Aggressor2); if (Aggressor3.Exists()) { Functions.AddPedToPursuit(pursuit, Aggressor3); } if (Aggressor4.Exists()) { Functions.AddPedToPursuit(pursuit, Aggressor4); } // Add blips to our peds ABlip1 = Aggressor1.AttachBlip(); ABlip2 = Aggressor2.AttachBlip(); if (Aggressor3.Exists()) { ABlip3 = Aggressor3.AttachBlip(); } if (Aggressor4.Exists()) { ABlip4 = Aggressor4.AttachBlip(); } if (Aggressor3.Exists() && Aggressor4.Exists()) { // Make the peds attack the player NativeFunction.CallByName <uint>("TASK_COMBAT_PED", Aggressor3, Game.LocalPlayer.Character, 0, 1); NativeFunction.CallByName <uint>("TASK_COMBAT_PED", Aggressor4, Game.LocalPlayer.Character, 0, 1); //Aggressor3.Tasks.FightAgainstClosestHatedTarget(500f); //Aggressor4.Tasks.FightAgainstClosestHatedTarget(500f); } // Request a NOOSE unit Functions.RequestBackup(vehicleSpawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.SwatTeam); return(base.OnCalloutAccepted()); }
public async override void OnStart(Ped player) { base.OnStart(player); PlayerData playerData = Utilities.GetPlayerData(); string displayName = playerData.DisplayName; Notify("~r~[BeachCallouts] ~y~Officer ~b~" + displayName + ",~y~ reports show multiple victims down!"); suspect = await SpawnPed(RandomUtils.GetRandomPed(), Location); vic1 = await SpawnPed(RandomUtils.GetRandomPed(), Location + 1); vic2 = await SpawnPed(RandomUtils.GetRandomPed(), Location + 2); vic3 = await SpawnPed(RandomUtils.GetRandomPed(), Location + 4); vic4 = await SpawnPed(RandomUtils.GetRandomPed(), Location - 5); vic5 = await SpawnPed(RandomUtils.GetRandomPed(), Location - 1); //Suspect 1 PedData data = new PedData(); List <Item> items = new List <Item>(); data.BloodAlcoholLevel = 0.08; Item Rifle = new Item { Name = "Rifle", IsIllegal = true }; items.Add(Rifle); data.Items = items; Utilities.SetPedData(suspect.NetworkId, data); suspect.AlwaysKeepTask = true; suspect.BlockPermanentEvents = true; suspect.AttachBlip(); suspect.Weapons.Give(WeaponHash.MarksmanRifle, 1000, true, true); suspect.Task.ShootAt(player); vic1.Kill(); vic2.Kill(); vic3.Kill(); vic4.Kill(); vic5.Kill(); vic1.AttachBlip(); vic2.AttachBlip(); vic3.AttachBlip(); vic4.AttachBlip(); vic5.AttachBlip(); PedData data1 = await Utilities.GetPedData(suspect.NetworkId); string firstname = data1.FirstName; DrawSubtitle("~r~[" + firstname + "] ~s~I knew this was coming... DIE!", 5000); }
public override bool OnCalloutAccepted() { SuspectVehicle = new Vehicle("ZENTORNO", SpawnPoint); SuspectVehicle.IsPersistent = true; Suspect = SuspectVehicle.CreateRandomDriver(); Suspect.IsPersistent = true; Suspect.BlockPermanentEvents = true; SuspectBlip = Suspect.AttachBlip(); SuspectBlip.IsFriendly = false; Suspect.Tasks.CruiseWithVehicle(20f, VehicleDrivingFlags.Emergency); return base.OnCalloutAccepted(); }
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 SerializableActorObjective CreatePedObjective(Model model, Vector3 pos, float heading) { var tmpPed = new Ped(model, pos, heading); tmpPed.IsPositionFrozen = false; tmpPed.BlockPermanentEvents = true; var blip = tmpPed.AttachBlip(); blip.Color = Color.Red; blip.Scale = 0.7f; _blips.Add(blip); var tmpObj = new SerializableActorObjective(); tmpObj.SetPed(tmpPed); tmpObj.SpawnAfter = 0; tmpObj.ActivateAfter = 0; tmpObj.Behaviour = 2; tmpObj.RelationshipGroup = 5; tmpObj.WeaponAmmo = 9999; tmpObj.WeaponHash = 0; tmpObj.Health = 200; tmpObj.Accuracy = 50; tmpObj.Armor = 0; tmpObj.SpawnInVehicle = false; tmpObj.Waypoints = new List<SerializableWaypoint>(); CurrentMission.Objectives.Add(tmpObj); return tmpObj; }
public SerializableActorObjective CreatePedObjective(SerializableActorObjective orig) { var tmpPed = new Ped(orig.GetPed().Model, orig.GetPed().Position - new Vector3(0,0,1), orig.GetPed().Rotation.Yaw); tmpPed.IsPositionFrozen = false; tmpPed.BlockPermanentEvents = true; var blip = tmpPed.AttachBlip(); blip.Color = Color.Red; blip.Scale = 0.7f; _blips.Add(blip); var tmpObj = (SerializableActorObjective)orig.Clone(); tmpObj.SetPed(tmpPed); CurrentMission.Objectives.Add(tmpObj); return tmpObj; }
public SerializableSpawnpoint CreateSpawnpoint(Model model, Vector3 pos, float heading) { var tmpPed = new Ped(model, pos, heading); tmpPed.IsPositionFrozen = true; tmpPed.BlockPermanentEvents = true; var blip = tmpPed.AttachBlip(); blip.Color = Color.White; _blips.Add(blip); var tmpObj = new SerializableSpawnpoint(); tmpObj.SetEntity(tmpPed); tmpObj.SpawnAfter = 0; tmpObj.RemoveAfter = 0; tmpObj.WeaponAmmo = 9999; tmpObj.WeaponHash = 0; tmpObj.Health = 200; tmpObj.Armor = 0; tmpObj.SpawnInVehicle = false; CurrentMission.Spawnpoints.Add(tmpObj); return tmpObj; }
public SerializableSpawnpoint CreateSpawnpoint(SerializableSpawnpoint orig) { var tmpPed = new Ped(orig.GetEntity().Model, orig.GetEntity().Position, orig.GetEntity().Heading); tmpPed.IsPositionFrozen = true; tmpPed.BlockPermanentEvents = true; var blip = tmpPed.AttachBlip(); blip.Color = Color.White; _blips.Add(blip); var tmpObj = (SerializableSpawnpoint)orig.Clone(); tmpObj.SetEntity(tmpPed); CurrentMission.Spawnpoints.Add(tmpObj); return tmpObj; }