Skip to content

Commit 08cb0b3

Browse files
ZitchasRisingLeafHurleveurwarp-coretibetiroka
authored
feat(scanning): extra and more finegrained tactical and strategic scanning options (endless-sky#8172)
Co-authored-by: Rising Leaf <85687254+RisingLeaf@users.noreply.github.com> Co-authored-by: Hurleveur <94366726+Hurleveur@users.noreply.github.com> Co-authored-by: warp-core <warp-core@users.noreply.github.com> Co-authored-by: tibetiroka <68112292+tibetiroka@users.noreply.github.com>
1 parent e46596c commit 08cb0b3

21 files changed

+317
-49
lines changed

copyright

+14
Original file line numberDiff line numberDiff line change
@@ -3606,9 +3606,23 @@ Comment:
36063606

36073607
Files:
36083608
images/ui/red?alert*
3609+
images/ui/tactical/acceleration*
3610+
images/ui/tactical/gun?range*
3611+
images/ui/tactical/turret?range*
3612+
images/ui/tactical/turn*
3613+
images/ui/tactical/velocity*
36093614
Copyright: Zitchas (zitchas.jma@gmail.com)
36103615
License: CC-BY-SA-4.0
36113616

3617+
Files:
3618+
images/ui/tactical/crew*
3619+
images/ui/tactical/energy*
3620+
images/ui/tactical/fuel*
3621+
images/ui/tactical/thermal*
3622+
Copyright: Zitchas
3623+
License: CC-BY-SA-4.0
3624+
Comment: Derived from works by Michael Zahniser (under the same license).
3625+
36123626
Files:
36133627
images/_menu/haze-brown*
36143628
Copyright: RisingLeaf (https://github.com/RisingLeaf)

data/_ui/interfaces.txt

+103-26
Original file line numberDiff line numberDiff line change
@@ -726,32 +726,6 @@ interface "hud"
726726
dimensions 110 110
727727
color "disabled hull"
728728
size 1.5
729-
730-
visible if "range display"
731-
sprite "ui/range"
732-
from 130 263
733-
align top left
734-
string "target range"
735-
from 160 260
736-
align top left
737-
visible if "tactical display"
738-
sprite "ui/tactical"
739-
from 130 290
740-
align top left
741-
string "target crew"
742-
from 162 298
743-
align top left
744-
string "target fuel"
745-
from 162 318
746-
align top left
747-
string "target energy"
748-
from 157 338
749-
align top left
750-
string "target heat"
751-
from 147 358
752-
align top left
753-
visible
754-
755729
string "target name"
756730
center 75 395
757731
color "bright"
@@ -773,6 +747,109 @@ interface "hud"
773747
center 75 455
774748
color "medium"
775749

750+
visible if "range display"
751+
sprite "ui/tactical/range"
752+
from 130 263
753+
align top left
754+
string "target range"
755+
from 160 260
756+
align top left
757+
758+
visible if "strategic range display"
759+
sprite "ui/tactical/range"
760+
from 2 255
761+
align top left
762+
string "target range"
763+
from 2 240
764+
align top left
765+
766+
visible if "target crew display"
767+
sprite "ui/tactical/crew"
768+
from 148 286
769+
align top left
770+
string "target crew"
771+
from 162 286
772+
align top left
773+
774+
visible if "mobility crew display"
775+
sprite "ui/tactical/crew"
776+
from 13 354
777+
align top left
778+
string "target crew"
779+
from 17 372
780+
align top center
781+
782+
visible if "target fuel display"
783+
sprite "ui/tactical/fuel"
784+
from 146 308
785+
align top left
786+
string "target fuel"
787+
from 162 306
788+
align top left
789+
790+
visible if "target energy display"
791+
sprite "ui/tactical/energy"
792+
from 144 324
793+
align top left
794+
string "target energy"
795+
from 157 325
796+
align top left
797+
798+
visible if "target thermal display"
799+
sprite "ui/tactical/thermal"
800+
from 136 343
801+
align top left
802+
string "target heat"
803+
from 147 346
804+
align top left
805+
806+
visible if "target weapon range display"
807+
sprite "ui/tactical/gun range"
808+
from 154 252
809+
align top center
810+
sprite "ui/tactical/turret range"
811+
from 190 252
812+
align top center
813+
string "target gun"
814+
from 152 268
815+
align top center
816+
string "target turret"
817+
from 190 268
818+
align top center
819+
820+
visible if "turn while combined"
821+
sprite "ui/tactical/turn"
822+
from 118 370
823+
align top left
824+
string "target turnrate"
825+
from 139 370
826+
align top left
827+
828+
visible if "turn while not combined"
829+
sprite "ui/tactical/turn"
830+
from 145 288
831+
align top left
832+
string "target turnrate"
833+
from 162 286
834+
align top left
835+
836+
visible if "target velocity display"
837+
sprite "ui/tactical/velocity"
838+
from 142 288
839+
align top left
840+
string "target velocity"
841+
from 158 286
842+
align top left
843+
844+
visible if "target acceleration display"
845+
sprite "ui/tactical/acceleration"
846+
from 194 286
847+
align top left
848+
string "target acceleration"
849+
from 208 286
850+
align top left
851+
852+
776853
# Other HUD elements:
777854
box "escorts"
778855
from 0 460 top left

data/_ui/tooltips.txt

+35-1
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,42 @@ tip "solar collection:"
693693
tip "solar heat:"
694694
`Heat produced depending on how far this ship is from the star at the center of the system.`
695695

696+
tip "strategic scan power:"
697+
`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.`
698+
696699
tip "tactical scan power:"
697-
`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.`
700+
`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.`
701+
702+
tip "acceleration scan power:"
703+
`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.`
704+
705+
tip "crew scan power:"
706+
`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.`
707+
708+
tip "energy scan power:"
709+
`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.`
710+
711+
tip "fuel scan power:"
712+
`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.`
713+
714+
tip "maneuver scan power:"
715+
`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.`
716+
717+
tip "mobility scan power:"
718+
`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.`
719+
720+
tip "range finder power:"
721+
`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.`
722+
723+
tip "thermal scan power:"
724+
`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.`
725+
726+
tip "velocity scan power:"
727+
`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.`
728+
729+
tip "weapon scan power:"
730+
`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.`
731+
698732

699733
tip "thrust:"
700734
`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.`

images/ui/tactical/acceleration.png

706 Bytes
Loading

images/ui/tactical/crew.png

697 Bytes
Loading

images/ui/tactical/energy.png

871 Bytes
Loading

images/ui/tactical/fuel.png

773 Bytes
Loading

images/ui/tactical/gun range.png

757 Bytes
Loading
File renamed without changes.
File renamed without changes.

images/ui/tactical/thermal.png

721 Bytes
Loading

images/ui/tactical/turn.png

884 Bytes
Loading

images/ui/tactical/turret range.png

714 Bytes
Loading

images/ui/tactical/velocity.png

640 Bytes
Loading

source/AI.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2730,7 +2730,7 @@ void AI::Attack(Ship &ship, Command &command, const Ship &target)
27302730
// Have a 10% minimum to avoid ships getting in a chase loop.
27312731
const bool isAbleToRun = target.MaxVelocity() * SAFETY_MULTIPLIER < ship.MaxVelocity();
27322732

2733-
ShipAICache &shipAICache = ship.GetAICache();
2733+
const ShipAICache &shipAICache = ship.GetAICache();
27342734
const bool useArtilleryAI = shipAICache.IsArtilleryAI() && isAbleToRun;
27352735
const double shortestRange = shipAICache.ShortestRange();
27362736
const double shortestArtillery = shipAICache.ShortestArtillery();

source/Engine.cpp

+103-14
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ this program. If not, see <https://www.gnu.org/licenses/>.
5757
#include "shader/RingShader.h"
5858
#include "Screen.h"
5959
#include "Ship.h"
60+
#include "ship/ShipAICache.h"
6061
#include "ShipEvent.h"
6162
#include "ShipJumpNavigation.h"
6263
#include "image/Sprite.h"
@@ -820,7 +821,7 @@ void Engine::Step(bool isActive)
820821

821822
targetVector = targetAsteroid->Position() - center;
822823

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

872873
targetVector = target->Position() - center;
873874

874-
// Check if the target is close enough to show tactical information.
875-
double tacticalRange = 100. * sqrt(flagship->Attributes().Get("tactical scan power"));
875+
// Finds the range from the center of the flagship to the center of the target
876876
double targetRange = target->Position().Distance(flagship->Position());
877-
if(tacticalRange)
878-
{
879-
info.SetCondition("range display");
877+
// Finds the range of the scan collections (tactical and strategic)
878+
double tacticalRange = 100. * sqrt(flagship->Attributes().Get("tactical scan power"));
879+
double strategicScanRange = 100. * sqrt(flagship->Attributes().Get("strategic scan power"));
880+
// Finds the range of the individual information types
881+
double crewScanRange = 100. * sqrt(flagship->Attributes().Get("crew scan power"));
882+
double energyScanRange = 100. * sqrt(flagship->Attributes().Get("energy scan power"));
883+
double fuelScanRange = 100. * sqrt(flagship->Attributes().Get("fuel scan power"));
884+
double maneuverScanRange = 100. * sqrt(flagship->Attributes().Get("maneuver scan power"));
885+
double accelerationScanRange = 100. * sqrt(flagship->Attributes().Get("acceleration scan power"));
886+
double velocityScanRange = 100. * sqrt(flagship->Attributes().Get("velocity scan power"));
887+
double thermalScanRange = 100. * sqrt(flagship->Attributes().Get("thermal scan power"));
888+
double weaponScanRange = 100. * sqrt(flagship->Attributes().Get("weapon scan power"));
889+
// The range display currently does not care about the distance,
890+
// it is either present or not; but treating it the same makes it
891+
// easy for people to change this if desired.
892+
double rangeFinder = 100. * sqrt(flagship->Attributes().Get("range finder power"));
893+
// Range information. If the player has any range finding,
894+
// then calculate the range and store it. If they do not
895+
// have strategic or weapon range info, use normal display.
896+
// If they do, then use strategic range display.
897+
if(tacticalRange || strategicScanRange || rangeFinder)
880898
info.SetString("target range", to_string(static_cast<int>(round(targetRange))));
881-
}
882-
// Actual tactical information requires a scrutable
883-
// target that is within the tactical scanner range.
884-
if((targetRange <= tacticalRange && !target->Attributes().Get("inscrutable"))
885-
|| (tacticalRange && target->IsYours()))
899+
if((tacticalRange || rangeFinder) && !strategicScanRange)
900+
info.SetCondition("range display");
901+
else if(strategicScanRange)
902+
info.SetCondition("strategic range display");
903+
// Actual information requires a scrutable target
904+
// that is within the relevant scanner range.
905+
bool scrutable = !target->Attributes().Get("inscrutable");
906+
if((targetRange <= (tacticalRange + crewScanRange) && scrutable)
907+
|| ((tacticalRange || crewScanRange) && target->IsYours()))
886908
{
887-
info.SetCondition("tactical display");
888909
info.SetString("target crew", to_string(target->Crew()));
889-
int fuel = round(target->Fuel() * target->Attributes().Get("fuel capacity"));
890-
info.SetString("target fuel", to_string(fuel));
910+
if(targetRange <= (strategicScanRange + accelerationScanRange)
911+
|| targetRange <= (strategicScanRange + velocityScanRange)
912+
|| target->IsYours())
913+
{
914+
info.SetCondition("mobility crew display");
915+
}
916+
else
917+
info.SetCondition("target crew display");
918+
}
919+
if((targetRange <= (tacticalRange + energyScanRange) && scrutable)
920+
|| ((tacticalRange || energyScanRange) && target->IsYours()))
921+
{
922+
info.SetCondition("target energy display");
891923
int energy = round(target->Energy() * target->Attributes().Get("energy capacity"));
892924
info.SetString("target energy", to_string(energy));
925+
}
926+
if((targetRange <= (tacticalRange + fuelScanRange) && scrutable)
927+
|| ((tacticalRange || fuelScanRange) && target->IsYours()))
928+
{
929+
info.SetCondition("target fuel display");
930+
int fuel = round(target->Fuel() * target->Attributes().Get("fuel capacity"));
931+
info.SetString("target fuel", to_string(fuel));
932+
}
933+
if((targetRange <= (tacticalRange + thermalScanRange) && scrutable)
934+
|| ((tacticalRange || thermalScanRange) && target->IsYours()))
935+
{
936+
info.SetCondition("target thermal display");
893937
int heat = round(100. * target->Heat());
894938
info.SetString("target heat", to_string(heat) + "%");
895939
}
940+
if((targetRange <= (strategicScanRange + weaponScanRange) && scrutable)
941+
|| ((strategicScanRange || weaponScanRange) && target->IsYours()))
942+
{
943+
info.SetCondition("target weapon range display");
944+
int turretRange = round(target->GetAICache().TurretRange());
945+
info.SetString("target turret", to_string(turretRange) + " ");
946+
int gunRange = round(target->GetAICache().GunRange());
947+
info.SetString("target gun", to_string(gunRange) + " ");
948+
}
949+
// This calculates the turn speed and selects the display position.
950+
if((targetRange <= (tacticalRange + crewScanRange)
951+
&& targetRange <= (strategicScanRange + maneuverScanRange) && scrutable)
952+
|| ((targetRange <= (strategicScanRange + accelerationScanRange) && scrutable))
953+
|| ((strategicScanRange || maneuverScanRange || velocityScanRange || accelerationScanRange)
954+
&& (tacticalRange || crewScanRange) && target->IsYours()))
955+
{
956+
info.SetCondition("turn while combined");
957+
int turnRate = round(60 * target->TrueTurnRate());
958+
info.SetString("target turnrate", to_string(turnRate) + " ");
959+
}
960+
else if((targetRange >= (tacticalRange + crewScanRange)
961+
&& targetRange <= (strategicScanRange + maneuverScanRange) && scrutable)
962+
|| ((strategicScanRange || maneuverScanRange) && target->IsYours()
963+
&& !tacticalRange && !crewScanRange))
964+
{
965+
info.SetCondition("turn while not combined");
966+
int turnRate = round(60 * target->TrueTurnRate());
967+
info.SetString("target turnrate", to_string(turnRate) + " ");
968+
}
969+
// This calculates the current speed
970+
if((targetRange <= (strategicScanRange + accelerationScanRange) && scrutable)
971+
|| ((tacticalRange || accelerationScanRange) && target->IsYours()))
972+
{
973+
info.SetCondition("target velocity display");
974+
int presentSpeed = round(60 * target->CurrentSpeed());
975+
info.SetString("target velocity", to_string(presentSpeed) + " ");
976+
}
977+
// This calculates the current maximum acceleration
978+
if((targetRange <= (strategicScanRange + velocityScanRange) && scrutable)
979+
|| ((tacticalRange || velocityScanRange) && target->IsYours()))
980+
{
981+
info.SetCondition("target acceleration display");
982+
int presentAcceleration = 3600 * target->TrueAcceleration();
983+
info.SetString("target acceleration", to_string(presentAcceleration) + " ");
984+
}
896985
}
897986
}
898987
if(!Preferences::Has("Ship outlines in HUD"))

source/PlayerInfo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ bool PlayerInfo::TakeOff(UI *ui, const bool distributeCargo)
16931693
if(!ship->IsParked() && !ship->IsDisabled())
16941694
{
16951695
// Recalculate the weapon cache in case a mass-less change had an effect.
1696-
ship->GetAICache().Calibrate(*ship.get());
1696+
ship->UpdateCaches(true);
16971697
if(ship->GetSystem() != system)
16981698
{
16991699
ship->Recharge(Port::RechargeType::None, false);

0 commit comments

Comments
 (0)