Skip to content

Commit

Permalink
feat(radar): auto-zoom to cargo cannisters
Browse files Browse the repository at this point in the history
Similar to auto-zooming on ships, add the capability for the radar to
auto-zoom on cargo containers. This is very useful when scooping multiple
cargo containers in an area, as otherwise the radar is liable to zoom out
to infinity in-between scooping containers. This makes it very difficult
to lock on to the next container.

TODO: the radar should be switchable between auto and manual modes, with
the manual mode being controllable by the keyboard/joystick. A radar
mode and range indicator might also be useful to add.

In future, different radar equipment could provide different ranges
and/or capabilities.
  • Loading branch information
mwerle committed Nov 3, 2024
1 parent 7b175ad commit 60491c8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions data/pigui/modules/radar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ local function display3DRadar(center, size)
local navTarget = player:GetNavTarget()
local maxBodyDist = 0.0
local maxShipDist = 0.0
local maxCargoDist = 0.0

radar.size = size
radar.zoom = currentZoomDist
Expand All @@ -136,6 +137,9 @@ local function display3DRadar(center, size)
-- only snap to ships if they're less than 50km away (arbitrary constant based on crime range)
if v.body:IsShip() and v.distance < 50000 then maxShipDist = math.max(maxShipDist, v.distance) end

-- only snap to cargo containers if they're less than 25km away (arbitrary)
if v.body:IsCargoContainer() and v.distance < 25000 then maxCargoDist = math.max(maxCargoDist, v.distance) end

if v.distance < currentZoomDist and v.rel_position.y < 0.0 then
local color = (v.body == navTarget and colors.navTarget) or (v.body == combatTarget and colors.combatTarget) or getColorFor(v)
drawTarget(v, scale, center, color)
Expand Down Expand Up @@ -165,6 +169,8 @@ local function display3DRadar(center, size)
maxDist = combatTarget:GetPositionRelTo(player):length() * 1.4
elseif maxShipDist > 0 then
maxDist = maxShipDist * 1.4
elseif maxCargoDist > 0 then
maxDist = maxCargoDist * 1.4
elseif navTarget then
local dist = navTarget:GetPositionRelTo(player):length()
maxDist = dist > MAX_RADAR_SIZE and maxBodyDist or dist * 1.4
Expand Down

0 comments on commit 60491c8

Please sign in to comment.