Skip to content

Commit

Permalink
Update to v0.6.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Substrata1 committed Nov 8, 2024
1 parent 6705d20 commit c3032c7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
48 changes: 25 additions & 23 deletions Inbound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<CargoShip>();
Expand All @@ -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)
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -691,7 +694,6 @@ private ConfigData GetBaseConfig()
showCargoShip = true,
showExcavator = true,
hideOffGrid = true,
gridOffset = false,
showCoords = false,
hideYCoord = false,
hideCoordDecimals = false
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c3032c7

Please sign in to comment.