/// <summary> /// Returns the enum of the area /// </summary> /// <param name="position"></param> /// <returns>the name of the area</returns> public static EWorldArea GetArea(this Vector3 position) { return(WorldZone.GetArea(position)); }
static Player FindPlayerWithOptions(WorldZone options) { switch (options) { case WorldZone.ZoneCorrupt: return Main.player.Where(x => x.active && x.ZoneCorrupt).Random(); case WorldZone.ZoneCrimson: return Main.player.Where(x => x.active && x.ZoneCrimson).Random(); case WorldZone.ZoneDesert: return Main.player.Where(x => x.active && x.ZoneDesert).Random(); case WorldZone.ZoneDungeon: return Main.player.Where(x => x.active && x.ZoneDungeon).Random(); case WorldZone.ZoneGlowshroom: return Main.player.Where(x => x.active && x.ZoneGlowshroom).Random(); case WorldZone.ZoneHoly: return Main.player.Where(x => x.active && x.ZoneHoly).Random(); case WorldZone.ZoneJungle: return Main.player.Where(x => x.active && x.ZoneJungle).Random(); case WorldZone.ZoneMeteor: return Main.player.Where(x => x.active && x.ZoneMeteor).Random(); case WorldZone.ZonePeaceCandle: return Main.player.Where(x => x.active && x.ZonePeaceCandle).Random(); case WorldZone.ZoneSnow: return Main.player.Where(x => x.active && x.ZoneSnow).Random(); case WorldZone.ZoneTowerNebula: return Main.player.Where(x => x.active && x.ZoneTowerNebula).Random(); case WorldZone.ZoneTowerSolar: return Main.player.Where(x => x.active && x.ZoneTowerSolar).Random(); case WorldZone.ZoneTowerStardust: return Main.player.Where(x => x.active && x.ZoneTowerStardust).Random(); case WorldZone.ZoneTowerVortex: return Main.player.Where(x => x.active && x.ZoneTowerVortex).Random(); case WorldZone.ZoneUndergroundDesert: return Main.player.Where(x => x.active && x.ZoneUndergroundDesert).Random(); case WorldZone.ZoneWaterCandle: return Main.player.Where(x => x.active && x.ZoneWaterCandle).Random(); default: return Main.player.Where(x => x.active).Random(); } return null; }
static Player FindPlayerWithOptions(WorldZone options) { if (Main.rand == null) Main.rand = new Random((new Random()).Next()); Player[] ply; switch (options) { //1.3 //case WorldZone.Blood: // ply = (from x in Main.player where x.zoneBlood select x).ToArray(); // if (ply.Length > 0) // return ply[Main.rand.Next(0, ply.Length - 1)]; // break; //case WorldZone.Candle: // ply = (from x in Main.player where x.zoneCandle select x).ToArray(); // if (ply.Length > 0) // return ply[Main.rand.Next(0, ply.Length - 1)]; // break; //case WorldZone.Dungeon: // ply = (from x in Main.player where x.zoneDungeon select x).ToArray(); // if (ply.Length > 0) // return ply[Main.rand.Next(0, ply.Length - 1)]; // break; //case WorldZone.Holy: // ply = (from x in Main.player where x.zoneHoly select x).ToArray(); // if (ply.Length > 0) // return ply[Main.rand.Next(0, ply.Length - 1)]; // break; //case WorldZone.Meteor: // ply = (from x in Main.player where x.zoneMeteor select x).ToArray(); // if (ply.Length > 0) // return ply[Main.rand.Next(0, ply.Length - 1)]; // break; //case WorldZone.Snow: // ply = (from x in Main.player where x.zoneSnow select x).ToArray(); // if (ply.Length > 0) // return ply[Main.rand.Next(0, ply.Length - 1)]; // break; //case WorldZone.Jungle: // ply = (from x in Main.player where x.zoneJungle select x).ToArray(); // if (ply.Length > 0) // return ply[Main.rand.Next(0, ply.Length - 1)]; // break; //case WorldZone.Hell: // ply = (from x in Main.player where x.zoneHoly select x).ToArray(); // if (ply.Length > 0) // return ply[Main.rand.Next(0, ply.Length - 1)]; // break; //case WorldZone.Any: default: if (Main.player.Length > 0) return Main.player[Main.rand.Next(0, Main.player.Length - 1)]; break; } return null; }
public static bool IsZoneMainCity(WorldZone zone) { return(zone == WorldZone.Stormwind_City || zone == WorldZone.Darnassus || zone == WorldZone.Ironforge || zone == WorldZone.Orgrimmar || zone == WorldZone.Undercity || zone == WorldZone.Thunder_Bluff); }
public static bool IsZoneBattleground(WorldZone zone) { return(zone == WorldZone.Warsong_Gulch || zone == WorldZone.Arathi_Basin || zone == WorldZone.Alterac_Valley); }
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> /// 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()); }
// We found two WorldChunkZone who match ! // Remove the WorldZone related to this and merge into sideWorldZone void RemoveAndMergeIntoSideZone(WorldChunkComputed.WorldChunkZone chunkZone, Direction direction, WorldChunk sideChunk, WorldChunkComputed.WorldChunkZone sideChunkZone, List <int> matchingCoords, WorldChunkSettings setting) { Direction inverseDirection = Coord.GetDirectionInverse(direction); // Get ref everytime ! // (If A is merged to B, and try after to be merged with C, take ref to {AmergedB} instead of {deletedA}) WorldZone zone = chunkZone.worldZoneRef; WorldZone sideZone = sideChunkZone.worldZoneRef; /* * if (zone.state > sideZone.state) { * sideZone.state = zone.state; * }*/ if (zone.requireZoneState > sideZone.requireZoneState) { sideZone.requireZoneState = zone.requireZoneState; } // Loop all chunk who are on the zone to be remove for (int chunk_idx = zone.chunks.Count - 1; chunk_idx >= 0; chunk_idx--) { Coord zoneCoord = zone.chunks [chunk_idx]; // This chunk didn't exist on sideZone if (!sideZone.chunks.Contains(zoneCoord)) { sideZone.chunks.Add(zoneCoord); sideZone.chunkZones.Add(zoneCoord, new List <WorldChunkComputed.WorldChunkZone> ()); } // Remove missing chunk on both zone: chunkZone.missingChunks.Remove(sideChunk.coord); // sideChunkZone.missingChunks.Remove(this.coord); // Update matching coords chunkZone.directionChunkBorderCoords[direction] = matchingCoords; // sideChunkZone.directionChunkBorderCoords[inverseDirection] = matchingCoords; // if (zone.chunkZones.ContainsKey(zoneCoord)) { for (int zoneChunkZone_idx = zone.chunkZones [zoneCoord].Count - 1; zoneChunkZone_idx >= 0; zoneChunkZone_idx--) { WorldChunkComputed.WorldChunkZone zoneChunkZone = zone.chunkZones [zoneCoord] [zoneChunkZone_idx]; // In case of corners, the diagonal chunk will be merge to both sides (who are shared by diagonals) and a loop is created // Check it's not the same if (zoneChunkZone.worldZoneRef != sideChunkZone.worldZoneRef) { sideZone.chunkZones [zoneCoord].Add(zoneChunkZone); zoneChunkZone.worldZoneRef = sideChunkZone.worldZoneRef; } } } // Update all refs (to the new zone) on every chunk who contain this removed zone for (int chunkCoord_idx = zone.chunks.Count - 1; chunkCoord_idx >= 0; chunkCoord_idx--) { MapEndless.instance.worldChunks [zone.chunks [chunkCoord_idx]].worldZonesRefs.Remove(zone); if (!MapEndless.instance.worldChunks [zone.chunks [chunkCoord_idx]].worldZonesRefs.Contains(sideZone)) { MapEndless.instance.worldChunks [zone.chunks [chunkCoord_idx]].worldZonesRefs.Add(sideZone); } } this.worldZonesRefs.Remove(zone); if (!this.worldZonesRefs.Contains(sideZone)) { this.worldZonesRefs.Add(sideZone); } MapEndless.instance.worldZones.Remove(zone); zone.isDeleted = true; } }
void TestZonesCompletedAndSeeMore(WorldChunkSettings setting) { // Loop all zones to check if completed for (int zone_idx = this.worldZonesRefs.Count - 1; zone_idx >= 0; zone_idx--) { if (this.worldZonesRefs [zone_idx].isMainGround) { continue; } WorldZone sideZone = this.worldZonesRefs [zone_idx]; if (sideZone.GetMissingChunks().Count == 0) { sideZone.OnMergeCompleted(); } else { // See more ?! if (sideZone.requireZoneState >= WorldZoneStates.Merged) { // BY ALL MISSNIG ? // Don't use by Direction because can create a missing chunk is one was already loaded (see bug-SeeMore-not-per-direction-but-missing.png) List <Coord> missingCoords = sideZone.GetMissingChunks(); for (int missing_idx = 0; missing_idx < missingCoords.Count; missing_idx++) { if (!MapEndless.instance.worldChunks.ContainsKey(missingCoords [missing_idx])) { MapEndless.instance.CreateChunk(missingCoords [missing_idx], ChunkStates.Computed); } else if (MapEndless.instance.worldChunks [missingCoords [missing_idx]].state < ChunkStates.Computed) { MapEndless.instance.worldChunks [missingCoords [missing_idx]].UpdateState(setting, ChunkStates.Computed); } } /**/ // BY CHUNK DIRECTION /* * for (int e = 0; e < Coord.directions.Length; e++) { * Direction seeMoreDirection = Coord.directions [e]; * Coord seeMoreCoord = this.coord.GetDirection (seeMoreDirection); * * if (sideZone.chunks.Contains (seeMoreCoord)) { * // continue; // skip if already on this zone * } * * // If it's not the direction we come from * // And the zone who was used to merge, is also bordered on another chunk * for (int idx = this.worldZonesRefs [zone_idx].chunkZones[this.coord].Count - 1; idx >= 0; idx--) { * if (this.worldZonesRefs [zone_idx].chunkZones[this.coord][idx].missingChunks.Contains(seeMoreCoord)) { * // Already exist * if (MapEndless.instance.worldChunks.ContainsKey(seeMoreCoord)) { * continue; * } * * MapEndless.instance.CreateChunk (seeMoreCoord, ChunkStates.Computed); * } * } * } * /**/ } } } }
// Get Height map as saved: // Size: 50x50 - Scale: 10 -> coord from [0;0] to [5;5] // coord can be on a side chunk (ex x:-1 or y:setting.scaledSize), return sidechunk value he's merged public float GetHeightValue(Coord coord, WorldChunkSettings setting) { if (this.state < ChunkStates.Merged) { return(0f); } // It's on a side chunk, get the chunk and the right coord if (coord.x < 0 || coord.y < 0 || coord.x >= setting.scaledSize || coord.y >= setting.scaledSize) { Coord chunkCoord = new Coord(this.coord.x, this.coord.y); if (coord.x < 0) { chunkCoord.x += Coord.Left.x; // x-- } else if (coord.x >= setting.scaledSize) { chunkCoord.x += Coord.Right.x; // x++ } if (coord.y < 0) { chunkCoord.y += Coord.Bottom.y; // y-- } else if (coord.y >= setting.scaledSize) { chunkCoord.y += Coord.Top.y; // y++ } // The chunk is loaded AND merged if (this.chunkBorders.sidesChunks.ContainsKey(chunkCoord)) { WorldChunk sideChunk = this.chunkBorders.sidesChunks [chunkCoord]; if (sideChunk.state >= ChunkStates.Merged) { if (coord.x < 0) { coord.x += setting.scaledSize; } else if (coord.x >= setting.scaledSize) { coord.x -= setting.scaledSize; } if (coord.y < 0) { coord.y += setting.scaledSize; } else if (coord.y >= setting.scaledSize) { coord.y -= setting.scaledSize; } return(sideChunk.GetHeightValue(coord, setting)); } } // The chunk isn't loaded.. take the nearest on the same chunk by updating the coord requested if (coord.x < 0) { coord.x = 0; } else if (coord.x >= setting.scaledSize) { coord.x = setting.scaledSize - 1; } if (coord.y < 0) { coord.y = 0; } else if (coord.y >= setting.scaledSize) { coord.y = setting.scaledSize - 1; } } // Reset index, cause x/y may was updated coord.SetIndex(setting); float noiseHeight = this.chunkData.GetHeightValue(coord); WorldZone zone = this.chunkComputed.GetZone(coord).worldZoneRef; return(MeshGenerator.GetRealHeight(noiseHeight, zone.type, setting)); }
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()); }
void OnAwake() { this.mainGround = new WorldZone(WorldZoneTypes.Ground); }
/// <summary> /// Returns the name of the zone /// </summary> /// <param name="position"></param> /// <returns>the name of the zone</returns> public static string GetZoneName(this Vector3 position) { return(WorldZone.GetZoneName(WorldZone.GetZone(position))); }
/// <summary> /// Returns the enum of the zone /// </summary> /// <param name="position"></param> /// <returns>the name of the zone</returns> public static EWorldZone GetZone(this Vector3 position) { return(WorldZone.GetZone(position)); }