From c3032c7e1c2742e5a4bdcde67264350a31d8e870 Mon Sep 17 00:00:00 2001 From: Substrata1 <62188329+Substrata1@users.noreply.github.com> Date: Thu, 7 Nov 2024 19:55:05 -0500 Subject: [PATCH] Update to v0.6.9 --- Inbound.cs | 48 +++++++++++++++++++++++++----------------------- README.md | 5 +---- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/Inbound.cs b/Inbound.cs index b7027b2..5dec07e 100644 --- a/Inbound.cs +++ b/Inbound.cs @@ -10,7 +10,7 @@ namespace Oxide.Plugins { - [Info("Inbound", "Substrata", "0.6.8")] + [Info("Inbound", "Substrata", "0.6.9")] [Description("Broadcasts notifications when patrol helicopters, supply drops, cargo ships, etc. are inbound")] class Inbound : RustPlugin @@ -21,7 +21,7 @@ class Inbound : RustPlugin AirdropPrecision, FancyDrop; bool initialized; - float worldSize; int xGridNum; int zGridNum; float gridBottom; float gridTop; float gridLeft; float gridRight; + float worldSize; int cellCount; float cellSize; float gridBottom; float gridTop; float gridLeft; float gridRight; bool hasOilRig; bool hasLargeRig; Vector3 oilRigPos; Vector3 largeRigPos; bool hasExcavator; Vector3 excavatorPos; ulong chatIconID; string webhookURL; @@ -370,22 +370,27 @@ string GetHarborLocation(CargoShip cargoShip) return string.Empty; } - string GetGrid(Vector3 pos) // Credit: yetzt & JakeRich + string GetGrid(Vector3 pos) { - float x = Mathf.Floor((pos.x+(worldSize/2)) / 146.3f); - float zGrids = configData.location.gridOffset ? Mathf.Floor(worldSize/146.3f) : Mathf.Floor(worldSize/146.3f)-1; - float z = zGrids-Mathf.Floor((pos.z+(worldSize/2)) / 146.3f); + int x = Mathf.FloorToInt((pos.x + (worldSize / 2)) / cellSize); + int z = Mathf.FloorToInt((pos.z + (worldSize / 2)) / cellSize); - int num = (int)x; - int num2 = Mathf.FloorToInt((float)(num / 26)); - int num3 = num % 26; - string text = string.Empty; - if (num2 > 0) + string columnLabel = string.Empty; + int num = x / 26; + + if (num > 0) { - for (int i = 0; i < num2; i++) - text += Convert.ToChar(65 + i); + for (int i = 0; i < num; i++) + { + columnLabel += Convert.ToChar(65 + i); + } } - return (text + Convert.ToChar(65 + num3))+z; + + columnLabel += Convert.ToChar(65 + (x % 26)); + + int row = cellCount - 1 - z; + + return $"{columnLabel}{row}"; } private CalledDrop GetCalledDrop(CargoPlane plane, SupplyDrop drop) @@ -416,7 +421,7 @@ private bool HideCrateAlert(HackableLockedCrate crate) return (configData.misc.hideCargoCrates && IsAtCargoShip(crate)) || (configData.misc.hideRigCrates && (IsAtOilRig(pos) || IsAtLargeRig(pos))); } - const string filterTags = @"(?i)<\/?(align|alpha|color|cspace|indent|line-height|line-indent|margin|mark|mspace|pos|size|space|voffset).*?>|<\/?(b|i|lowercase|uppercase|smallcaps|s|u|sup|sub)>"; + const string filterTags = @"(?i)<\/?(align|alpha|color|cspace|indent|line-height|line-indent|margin|mark|mspace|pos|size|space|voffset|b|i|lowercase|uppercase|smallcaps|s|u|sup|sub)(\s*=[^>]*?)?\s*\/?>"; private bool IsAtOilRig(Vector3 pos) => hasOilRig && Vector3Ex.Distance2D(oilRigPos, pos) <= 60f; private bool IsAtLargeRig(Vector3 pos) => hasLargeRig && Vector3Ex.Distance2D(largeRigPos, pos) <= 75f; private bool IsAtCargoShip(BaseEntity entity) => entity?.GetComponentInParent(); @@ -428,13 +433,13 @@ void InitVariables() { // Grid worldSize = TerrainMeta.Size.x; - xGridNum = (int)Mathf.Ceil(worldSize / 146.3f); - zGridNum = (int)Mathf.Floor(worldSize / 146.3f); - if (configData.location.gridOffset) zGridNum += 1; + cellCount = Mathf.FloorToInt((worldSize * 7) / 1024); + cellSize = worldSize / cellCount; + gridBottom = TerrainMeta.Position.z; - gridTop = gridBottom + (146.3f * zGridNum); + gridTop = gridBottom + (cellSize * cellCount); gridLeft = TerrainMeta.Position.x; - gridRight = gridLeft + (146.3f * xGridNum); + gridRight = gridLeft + (cellSize * cellCount); // Monuments foreach (MonumentInfo monument in TerrainMeta.Path.Monuments) @@ -585,8 +590,6 @@ public class Location public bool showExcavator { get; set; } [JsonProperty(PropertyName = "Hide Unmarked Grids")] public bool hideOffGrid { get; set; } - [JsonProperty(PropertyName = "Grid Offset")] - public bool gridOffset { get; set; } [JsonProperty(PropertyName = "Show Coordinates")] public bool showCoords { get; set; } [JsonProperty(PropertyName = "Hide Y Coordinate")] @@ -691,7 +694,6 @@ private ConfigData GetBaseConfig() showCargoShip = true, showExcavator = true, hideOffGrid = true, - gridOffset = false, showCoords = false, hideYCoord = false, hideCoordDecimals = false diff --git a/README.md b/README.md index 0737829..211cf6e 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,6 @@ "Show 'Cargo Ship' Label": true, "Show 'Excavator' Label": true, "Hide Unmarked Grids": true, - "Grid Offset": false, "Show Coordinates": false, "Hide Y Coordinate": false, "Hide Coordinate Decimals": false @@ -62,14 +61,13 @@ "Version (Do not modify)": { "Major": 0, "Minor": 6, - "Patch": 8 + "Patch": 9 } } ``` - **Show Supply Drop Player** will add the name of the player who called in a Cargo Plane / Supply Drop when those alerts are shown. This can be further tweaked in the language file. - **Hide Player-Called Supply Drop Messages** will hide alerts for Cargo Planes and Supply Drops that have been called in by a player, with a supply signal or at the Excavator signal computer. **Hide Random Supply Drop Messages** will hide alerts for those that have not. -- **Grid Offset** will offset the grid number by 1, if needed. See Known Issues for more info. - For info on creating a Webhook for Discord Messages, check out [Intro to Webhooks](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks). ## Localization @@ -104,7 +102,6 @@ ## Known Issues - The **Show Supply Drop Player**, **Hide Player-Called Supply Drop Messages**, and **Hide Random Supply Drop Messages** options do not currently work with any plugins that kill & respawn the Cargo Plane or Supply Drop. These include Fancy Drop, Airdrop Precision, and possibly others. Compatibility for these can hopefully be added at some point. -- On some map sizes (3500, for example), the grid number may be off by 1. If this is the case for you, you can use the **Grid Offset** option to correct it. This is on Facepunch to fix. - Unmarked grids to the left of the map will not show, as there is currently no good way of labeling these. ## Credits