/// <summary> /// Returns the position zone, Los Santos or Blaine County /// </summary> /// <param name="position">Position</param> /// <returns>the position zone </returns> public static EWorldArea GetArea(Vector3 position) { ulong GetMapZoneAtCoordsHash = 0x7ee64d51e8498728; EWorldArea zone = (EWorldArea)NativeFunction.CallByHash <int>(GetMapZoneAtCoordsHash, position.X, position.Y, position.Z); return(zone); }
/// <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 override bool OnBeforeCalloutDisplayed() { float f = 200f; for (int i = 0; i < 10; i++) { GameFiber.Yield(); spawnPointOnStreet = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(f + 150f)).GetSafeCoordinatesForPed(); if (spawnPointOnStreet != Vector3.Zero) { break; } } if (spawnPointOnStreet == Vector3.Zero) { spawnPointOnStreet = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(500f)); } if (Vector3.Distance(Game.LocalPlayer.Character.Position, spawnPointOnStreet) < 25.0f) { return(false); } EWorldArea spawnZone = WorldZone.GetArea(spawnPointOnStreet); if (spawnZone == EWorldArea.Los_Santos) { return(false); } attackedPed = new Ped(spawnPointOnStreet); if (!attackedPed.Exists()) { return(false); } Vector3 animalSpawnPos = spawnPointOnStreet.AroundPosition(25.0f); for (int i = 0; i < 10; i++) { if (Vector3.Distance(animalSpawnPos, attackedPed.Position) > 8.75f) { break; } animalSpawnPos = spawnPointOnStreet.AroundPosition(25.0f + i); } animal = new Ped(animalModel, animalSpawnPos.ToGround(), 0.0f); if (!animal.Exists()) { return(false); } attackedPed.RelationshipGroup = new RelationshipGroup("PED"); animal.RelationshipGroup = "COUGAR"; this.ShowCalloutAreaBlipBeforeAccepting(spawnPointOnStreet, 35f); this.AddMinimumDistanceCheck(20.0f, attackedPed.Position); this.CalloutMessage = "Animal attack"; this.CalloutPosition = spawnPointOnStreet; int audioRnd = Globals.Random.Next(0, 2); if (audioRnd == 0) { LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT CRIME_VICIOUS_ANIMAL_ON_THE_LOOSE IN_OR_ON_POSITION UNITS_RESPOND_CODE_03", spawnPointOnStreet); } if (audioRnd == 1) { LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT CRIME_VICIOUS_ANIMAL_ON_THE_LOOSE IN_OR_ON_POSITION UNITS_RESPOND_CODE_99", spawnPointOnStreet); } return(base.OnBeforeCalloutDisplayed()); }
///// <summary> ///// Returns a ExtendedPosition ///// </summary> ///// <param name="position">Position</param> ///// <returns>a ExtendedPosition</returns> //public static ExtendedPosition GetExtendedPosition(Vector3 position) //{ // ExtendedPosition z = new ExtendedPosition(); // z.Position = position; // return z; //} /// <summary> /// Gets the area name /// </summary> /// <param name="area">Area</param> /// <returns>the area name</returns> public static string GetAreaName(EWorldArea area) { String name = Enum.GetName(typeof(EWorldArea), area); return(name.Replace("_", " ")); }
/// <summary> /// Returns the position zone, Los Santos or Blaine County /// </summary> /// <param name="position">Position</param> /// <returns>the position zone </returns> public static EWorldArea GetArea(Vector3 position) { EWorldArea zone = (EWorldArea)NativeFunction.Natives.x7ee64d51e8498728 <int>(position.X, position.Y, position.Z); //GetMapZoneAtCoords return(zone); }
public override bool OnBeforeCalloutDisplayed() { spawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(400f)); if (Vector3.Distance(Game.LocalPlayer.Character.Position, spawnPoint) < 40.0f) { return(false); } EWorldArea spawnZone = WorldZone.GetArea(spawnPoint); if (spawnZone == EWorldArea.Los_Santos) { return(false); } hunterVeh = new Vehicle(hunterVehicleModels.GetRandomElement(true), spawnPoint); if (!hunterVeh.Exists()) { return(false); } Vector3 hunterSpawnPos = hunterVeh.Position.AroundPosition(9.5f); while (Vector3.Distance(hunterSpawnPos, hunterVeh.Position) < 4.0f) { hunterSpawnPos = hunterVeh.Position.AroundPosition(9.5f); GameFiber.Yield(); } hunter = new Ped(huntersModels.GetRandomElement(true), hunterSpawnPos, 0.0f); if (!hunter.Exists()) { return(false); } hunter.Inventory.GiveNewWeapon(hunterWeapons.GetRandomElement(true), 666, true); Vector3 spawnPos = hunter.Position.AroundPosition(0.2f); Vector3 spawnPos2 = spawnPos + new Vector3(MathHelper.GetRandomSingle(-0.05f, 0.05f), MathHelper.GetRandomSingle(-0.05f, 0.05f), 0.0f); Vector3 spawnPos3 = new Vector3(spawnPos2.X, spawnPos2.Y, spawnPos2.GetGroundZ() + 0.1525f); /// Gets the Z position animal = new Ped(animalsModels.GetRandomElement(true), hunter.Position.AroundPosition(0.5f).ToGroundUsingRaycasting(hunter), 0.0f); if (!animal.Exists() || animal.Position.Z < 0.5f) { return(false); } hunter.RelationshipGroup = new RelationshipGroup("HUNTER"); hunter.BlockPermanentEvents = true; if (animal.Exists()) { animal.IsRagdoll = true; } if (hunter.Exists()) { hunter.Heading = hunter.GetHeadingTowards(animal); } if (Globals.Random.Next(60) <= 1) { hunterVeh.InstallRandomMods(); } this.ShowCalloutAreaBlipBeforeAccepting(spawnPoint, 35f); this.AddMinimumDistanceCheck(20.0f, hunter.Position); this.CalloutMessage = "Possible illegal hunting"; this.CalloutPosition = spawnPoint; int rndAudioNum = Globals.Random.Next(0, 8); if (rndAudioNum == 0) { LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_GUNFIRE IN_OR_ON_POSITION UNITS_RESPOND_CODE_03", spawnPoint); } else if (rndAudioNum == 1) { LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_ANIMAL_KILL IN_OR_ON_POSITION UNITS_RESPOND_CODE_02", spawnPoint); } else if (rndAudioNum == 2) { LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_ANIMAL_CRUELTY IN_OR_ON_POSITION UNITS_RESPOND_CODE_02", spawnPoint); } else if (rndAudioNum == 3) { LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_UNAUTHORIZED_HUNTING IN_OR_ON_POSITION UNITS_RESPOND_CODE_02", spawnPoint); } else if (rndAudioNum == 4) { LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_HUNTING_AN_ENDANGERED_SPECIES IN_OR_ON_POSITION UNITS_RESPOND_CODE_02", spawnPoint); } else if (rndAudioNum == 5) { LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_HUNTING_WITHOUT_A_PERMIT IN_OR_ON_POSITION UNITS_RESPOND_CODE_02", spawnPoint); } else if (rndAudioNum == 6) { LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_KILLING_ANIMALS IN_OR_ON_POSITION UNITS_RESPOND_CODE_02", spawnPoint); } else if (rndAudioNum == 7) { LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_SHOOTING_AT_ANIMALS IN_OR_ON_POSITION UNITS_RESPOND_CODE_02", spawnPoint); } return(base.OnBeforeCalloutDisplayed()); }