Skip to content

Commit

Permalink
feat(scanning): extra and more finegrained tactical and strategic sca…
Browse files Browse the repository at this point in the history
…nning options (endless-sky#8172)

Co-authored-by: Rising Leaf <[email protected]>
Co-authored-by: Hurleveur <[email protected]>
Co-authored-by: warp-core <[email protected]>
Co-authored-by: tibetiroka <[email protected]>
  • Loading branch information
5 people authored Dec 15, 2024
1 parent e46596c commit 08cb0b3
Show file tree
Hide file tree
Showing 21 changed files with 317 additions and 49 deletions.
14 changes: 14 additions & 0 deletions copyright
Original file line number Diff line number Diff line change
Expand Up @@ -3606,9 +3606,23 @@ Comment:

Files:
images/ui/red?alert*
images/ui/tactical/acceleration*
images/ui/tactical/gun?range*
images/ui/tactical/turret?range*
images/ui/tactical/turn*
images/ui/tactical/velocity*
Copyright: Zitchas ([email protected])
License: CC-BY-SA-4.0

Files:
images/ui/tactical/crew*
images/ui/tactical/energy*
images/ui/tactical/fuel*
images/ui/tactical/thermal*
Copyright: Zitchas
License: CC-BY-SA-4.0
Comment: Derived from works by Michael Zahniser (under the same license).

Files:
images/_menu/haze-brown*
Copyright: RisingLeaf (https://github.com/RisingLeaf)
Expand Down
129 changes: 103 additions & 26 deletions data/_ui/interfaces.txt
Original file line number Diff line number Diff line change
Expand Up @@ -726,32 +726,6 @@ interface "hud"
dimensions 110 110
color "disabled hull"
size 1.5

visible if "range display"
sprite "ui/range"
from 130 263
align top left
string "target range"
from 160 260
align top left
visible if "tactical display"
sprite "ui/tactical"
from 130 290
align top left
string "target crew"
from 162 298
align top left
string "target fuel"
from 162 318
align top left
string "target energy"
from 157 338
align top left
string "target heat"
from 147 358
align top left
visible

string "target name"
center 75 395
color "bright"
Expand All @@ -773,6 +747,109 @@ interface "hud"
center 75 455
color "medium"

visible if "range display"
sprite "ui/tactical/range"
from 130 263
align top left
string "target range"
from 160 260
align top left

visible if "strategic range display"
sprite "ui/tactical/range"
from 2 255
align top left
string "target range"
from 2 240
align top left

visible if "target crew display"
sprite "ui/tactical/crew"
from 148 286
align top left
string "target crew"
from 162 286
align top left

visible if "mobility crew display"
sprite "ui/tactical/crew"
from 13 354
align top left
string "target crew"
from 17 372
align top center

visible if "target fuel display"
sprite "ui/tactical/fuel"
from 146 308
align top left
string "target fuel"
from 162 306
align top left

visible if "target energy display"
sprite "ui/tactical/energy"
from 144 324
align top left
string "target energy"
from 157 325
align top left

visible if "target thermal display"
sprite "ui/tactical/thermal"
from 136 343
align top left
string "target heat"
from 147 346
align top left

visible if "target weapon range display"
sprite "ui/tactical/gun range"
from 154 252
align top center
sprite "ui/tactical/turret range"
from 190 252
align top center
string "target gun"
from 152 268
align top center
string "target turret"
from 190 268
align top center

visible if "turn while combined"
sprite "ui/tactical/turn"
from 118 370
align top left
string "target turnrate"
from 139 370
align top left

visible if "turn while not combined"
sprite "ui/tactical/turn"
from 145 288
align top left
string "target turnrate"
from 162 286
align top left

visible if "target velocity display"
sprite "ui/tactical/velocity"
from 142 288
align top left
string "target velocity"
from 158 286
align top left

visible if "target acceleration display"
sprite "ui/tactical/acceleration"
from 194 286
align top left
string "target acceleration"
from 208 286
align top left


# Other HUD elements:
box "escorts"
from 0 460 top left
Expand Down
36 changes: 35 additions & 1 deletion data/_ui/tooltips.txt
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,42 @@ tip "solar collection:"
tip "solar heat:"
`Heat produced depending on how far this ship is from the star at the center of the system.`

tip "strategic scan power:"
`Strategic scanners allow you to view your current target's distance from you, maximum gun range, maximum turret range, current speed, maximum acceleration, and turning speed when it is within range. The range is proportional to the square root of this value.`

tip "tactical scan power:"
`Allows viewing your current target's crew complement, fuel, heat, and energy levels when it is within range. The range is proportional to the square root of this value.`
`Tactical scanners allow you to view your current target's crew complement, fuel, heat, and energy levels when it is within range. The range is proportional to the square root of this value.`

tip "acceleration scan power:"
`Mobility scanners allow you to view your current target's current maximum acceleration when it is within range. The range is proportional to the square root of this value.`

tip "crew scan power:"
`Crew scanners allow you to view your current target's crew complement when it is within range. The range is proportional to the square root of this value.`

tip "energy scan power:"
`Energy scanners allow you to view your current target's energy levels when it is within range. The range is proportional to the square root of this value.`

tip "fuel scan power:"
`Fuel scanners allow you to view your current target's fuel levels when it is within range. The range is proportional to the square root of this value.`

tip "maneuver scan power:"
`Maneuver scanners allow you to view your current target's current maximum turn speed when it is within range. The range is proportional to the square root of this value.`

tip "mobility scan power:"
`Mobility scanners allow you to view your current target's current speed and maximum acceleration when it is within range. The range is proportional to the square root of this value.`

tip "range finder power:"
`Range finders allow you to view the distance from the center of your ship to the center of your current target. There is no range limit.`

tip "thermal scan power:"
`Thermal scanners allow you to view your current target's thermal level when it is within range. The range is proportional to the square root of this value.`

tip "velocity scan power:"
`Mobility scanners allow you to view your current target's current speed when it is within range. The range is proportional to the square root of this value.`

tip "weapon scan power:"
`Weapon scanners allow you to view your current target's weapons' maximum range when it is within scanner range. Specifically, it shows the longest range of all weapons in a gun hardpoint; and the longest range of all weapons in a turret hardpoint. These ranges include the weapon offset and thus show the maximum range from the center of the ship its shots can reach. The scanner range is proportional to the square root of this value.`


tip "thrust:"
`Thrust produced by engines. Higher thrust increases a ship's acceleration and top speed. The more mass a ship has, the more thrust is needed to achieve the same acceleration.`
Expand Down
Binary file added images/ui/tactical/acceleration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ui/tactical/crew.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ui/tactical/energy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ui/tactical/fuel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ui/tactical/gun range.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added images/ui/tactical/thermal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ui/tactical/turn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ui/tactical/turret range.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ui/tactical/velocity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion source/AI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2730,7 +2730,7 @@ void AI::Attack(Ship &ship, Command &command, const Ship &target)
// Have a 10% minimum to avoid ships getting in a chase loop.
const bool isAbleToRun = target.MaxVelocity() * SAFETY_MULTIPLIER < ship.MaxVelocity();

ShipAICache &shipAICache = ship.GetAICache();
const ShipAICache &shipAICache = ship.GetAICache();
const bool useArtilleryAI = shipAICache.IsArtilleryAI() && isAbleToRun;
const double shortestRange = shipAICache.ShortestRange();
const double shortestArtillery = shipAICache.ShortestArtillery();
Expand Down
117 changes: 103 additions & 14 deletions source/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ this program. If not, see <https://www.gnu.org/licenses/>.
#include "shader/RingShader.h"
#include "Screen.h"
#include "Ship.h"
#include "ship/ShipAICache.h"
#include "ShipEvent.h"
#include "ShipJumpNavigation.h"
#include "image/Sprite.h"
Expand Down Expand Up @@ -820,7 +821,7 @@ void Engine::Step(bool isActive)

targetVector = targetAsteroid->Position() - center;

if(flagship->Attributes().Get("tactical scan power"))
if(flagship->Attributes().Get("tactical scan power") || flagship->Attributes().Get("strategic scan power"))
{
info.SetCondition("range display");
info.SetBar("target hull", targetAsteroid->Hull(), 20.);
Expand Down Expand Up @@ -871,28 +872,116 @@ void Engine::Step(bool isActive)

targetVector = target->Position() - center;

// Check if the target is close enough to show tactical information.
double tacticalRange = 100. * sqrt(flagship->Attributes().Get("tactical scan power"));
// Finds the range from the center of the flagship to the center of the target
double targetRange = target->Position().Distance(flagship->Position());
if(tacticalRange)
{
info.SetCondition("range display");
// Finds the range of the scan collections (tactical and strategic)
double tacticalRange = 100. * sqrt(flagship->Attributes().Get("tactical scan power"));
double strategicScanRange = 100. * sqrt(flagship->Attributes().Get("strategic scan power"));
// Finds the range of the individual information types
double crewScanRange = 100. * sqrt(flagship->Attributes().Get("crew scan power"));
double energyScanRange = 100. * sqrt(flagship->Attributes().Get("energy scan power"));
double fuelScanRange = 100. * sqrt(flagship->Attributes().Get("fuel scan power"));
double maneuverScanRange = 100. * sqrt(flagship->Attributes().Get("maneuver scan power"));
double accelerationScanRange = 100. * sqrt(flagship->Attributes().Get("acceleration scan power"));
double velocityScanRange = 100. * sqrt(flagship->Attributes().Get("velocity scan power"));
double thermalScanRange = 100. * sqrt(flagship->Attributes().Get("thermal scan power"));
double weaponScanRange = 100. * sqrt(flagship->Attributes().Get("weapon scan power"));
// The range display currently does not care about the distance,
// it is either present or not; but treating it the same makes it
// easy for people to change this if desired.
double rangeFinder = 100. * sqrt(flagship->Attributes().Get("range finder power"));
// Range information. If the player has any range finding,
// then calculate the range and store it. If they do not
// have strategic or weapon range info, use normal display.
// If they do, then use strategic range display.
if(tacticalRange || strategicScanRange || rangeFinder)
info.SetString("target range", to_string(static_cast<int>(round(targetRange))));
}
// Actual tactical information requires a scrutable
// target that is within the tactical scanner range.
if((targetRange <= tacticalRange && !target->Attributes().Get("inscrutable"))
|| (tacticalRange && target->IsYours()))
if((tacticalRange || rangeFinder) && !strategicScanRange)
info.SetCondition("range display");
else if(strategicScanRange)
info.SetCondition("strategic range display");
// Actual information requires a scrutable target
// that is within the relevant scanner range.
bool scrutable = !target->Attributes().Get("inscrutable");
if((targetRange <= (tacticalRange + crewScanRange) && scrutable)
|| ((tacticalRange || crewScanRange) && target->IsYours()))
{
info.SetCondition("tactical display");
info.SetString("target crew", to_string(target->Crew()));
int fuel = round(target->Fuel() * target->Attributes().Get("fuel capacity"));
info.SetString("target fuel", to_string(fuel));
if(targetRange <= (strategicScanRange + accelerationScanRange)
|| targetRange <= (strategicScanRange + velocityScanRange)
|| target->IsYours())
{
info.SetCondition("mobility crew display");
}
else
info.SetCondition("target crew display");
}
if((targetRange <= (tacticalRange + energyScanRange) && scrutable)
|| ((tacticalRange || energyScanRange) && target->IsYours()))
{
info.SetCondition("target energy display");
int energy = round(target->Energy() * target->Attributes().Get("energy capacity"));
info.SetString("target energy", to_string(energy));
}
if((targetRange <= (tacticalRange + fuelScanRange) && scrutable)
|| ((tacticalRange || fuelScanRange) && target->IsYours()))
{
info.SetCondition("target fuel display");
int fuel = round(target->Fuel() * target->Attributes().Get("fuel capacity"));
info.SetString("target fuel", to_string(fuel));
}
if((targetRange <= (tacticalRange + thermalScanRange) && scrutable)
|| ((tacticalRange || thermalScanRange) && target->IsYours()))
{
info.SetCondition("target thermal display");
int heat = round(100. * target->Heat());
info.SetString("target heat", to_string(heat) + "%");
}
if((targetRange <= (strategicScanRange + weaponScanRange) && scrutable)
|| ((strategicScanRange || weaponScanRange) && target->IsYours()))
{
info.SetCondition("target weapon range display");
int turretRange = round(target->GetAICache().TurretRange());
info.SetString("target turret", to_string(turretRange) + " ");
int gunRange = round(target->GetAICache().GunRange());
info.SetString("target gun", to_string(gunRange) + " ");
}
// This calculates the turn speed and selects the display position.
if((targetRange <= (tacticalRange + crewScanRange)
&& targetRange <= (strategicScanRange + maneuverScanRange) && scrutable)
|| ((targetRange <= (strategicScanRange + accelerationScanRange) && scrutable))
|| ((strategicScanRange || maneuverScanRange || velocityScanRange || accelerationScanRange)
&& (tacticalRange || crewScanRange) && target->IsYours()))
{
info.SetCondition("turn while combined");
int turnRate = round(60 * target->TrueTurnRate());
info.SetString("target turnrate", to_string(turnRate) + " ");
}
else if((targetRange >= (tacticalRange + crewScanRange)
&& targetRange <= (strategicScanRange + maneuverScanRange) && scrutable)
|| ((strategicScanRange || maneuverScanRange) && target->IsYours()
&& !tacticalRange && !crewScanRange))
{
info.SetCondition("turn while not combined");
int turnRate = round(60 * target->TrueTurnRate());
info.SetString("target turnrate", to_string(turnRate) + " ");
}
// This calculates the current speed
if((targetRange <= (strategicScanRange + accelerationScanRange) && scrutable)
|| ((tacticalRange || accelerationScanRange) && target->IsYours()))
{
info.SetCondition("target velocity display");
int presentSpeed = round(60 * target->CurrentSpeed());
info.SetString("target velocity", to_string(presentSpeed) + " ");
}
// This calculates the current maximum acceleration
if((targetRange <= (strategicScanRange + velocityScanRange) && scrutable)
|| ((tacticalRange || velocityScanRange) && target->IsYours()))
{
info.SetCondition("target acceleration display");
int presentAcceleration = 3600 * target->TrueAcceleration();
info.SetString("target acceleration", to_string(presentAcceleration) + " ");
}
}
}
if(!Preferences::Has("Ship outlines in HUD"))
Expand Down
2 changes: 1 addition & 1 deletion source/PlayerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ bool PlayerInfo::TakeOff(UI *ui, const bool distributeCargo)
if(!ship->IsParked() && !ship->IsDisabled())
{
// Recalculate the weapon cache in case a mass-less change had an effect.
ship->GetAICache().Calibrate(*ship.get());
ship->UpdateCaches(true);
if(ship->GetSystem() != system)
{
ship->Recharge(Port::RechargeType::None, false);
Expand Down
Loading

0 comments on commit 08cb0b3

Please sign in to comment.