From 32c07ef847c4bc53e5e9d799c945c80d61fd4d48 Mon Sep 17 00:00:00 2001 From: Goober5000 Date: Sat, 29 Nov 2025 00:57:17 -0500 Subject: [PATCH] enhance and clean up scannable ship types The `$Scannable` field in objecttypes.tbl controls whether a ship can be targeted by the "target unscanned ship" key. This is independent of which ship types can actually be *scanned*, which is not connected to any field in objecttypes.tbl. So, this PR renames the `$Scannable` field to `$Targetable as unscanned:` to be clearer about what it actually does, and it adds the missing counterpart `$Scannable by default:` flag to specify which ship types can actually be scanned. Note that this is only relevant for legacy scanning behavior. Mods which use `$Unify scanning behavior:` do not need either of the ship type flags. --- code/def_files/data/tables/objecttypes.tbl | 8 +++++--- code/hud/hudtarget.cpp | 2 +- code/playerman/playercontrol.cpp | 4 +--- code/ship/ship.cpp | 8 ++++++-- code/ship/ship_flags.h | 3 ++- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/code/def_files/data/tables/objecttypes.tbl b/code/def_files/data/tables/objecttypes.tbl index b763e1e2ef2..1847eb3204b 100644 --- a/code/def_files/data/tables/objecttypes.tbl +++ b/code/def_files/data/tables/objecttypes.tbl @@ -53,8 +53,9 @@ $AI: +Ignored on cripple by: ( "navbuoy" "sentry gun" "escape pod" "cargo" "support" "fighter" "bomber" "transport" "freighter" "awacs" "gas miner" "cruiser" "corvette" "capital" "super cap" "drydock" "knossos device" ) $Skip Death Roll Percent Chance: 0.0 -$Name: Cargo -$Scannable: YES +$Name: Cargo +$Targetable as unscanned: YES +$Scannable by default: YES $Max Debris Speed: 200 $FF Multiplier: 0.10 $EMP Multiplier: 10.0 @@ -156,7 +157,8 @@ $Praise Destruction: YES $On Hotkey List: YES $Target as Threat: YES $Show Attack Direction: YES -$Scannable: YES +$Targetable as unscanned: YES +$Scannable by default: YES $Max Debris Speed: 150 $FF Multiplier: 1.0 $EMP Multiplier: 2.0 diff --git a/code/hud/hudtarget.cpp b/code/hud/hudtarget.cpp index 529328311d5..017bdaa5eea 100644 --- a/code/hud/hudtarget.cpp +++ b/code/hud/hudtarget.cpp @@ -1608,7 +1608,7 @@ int hud_target_ship_can_be_scanned(ship *shipp) return 1; } else if (Use_new_scanning_behavior) { return 0; - } else if ((sip->class_type < 0) || !(Ship_types[sip->class_type].flags[Ship::Type_Info_Flags::Scannable])) { + } else if ((sip->class_type < 0) || !(Ship_types[sip->class_type].flags[Ship::Type_Info_Flags::Targetable_as_unscanned])) { return 0; } diff --git a/code/playerman/playercontrol.cpp b/code/playerman/playercontrol.cpp index c9708e13fb2..b27a9bc1f3f 100644 --- a/code/playerman/playercontrol.cpp +++ b/code/playerman/playercontrol.cpp @@ -1690,7 +1690,7 @@ bool player_inspect_cargo(float frametime, char *outstr) // scannable cargo behaves differently. Scannable cargo is either "scanned" or "not scanned". This flag // can be set on any ship. Any ship with this set won't have "normal" cargo behavior if (!(cargo_sp->flags[Ship::Ship_Flags::Scannable])) { - if (!(cargo_sip->flags[Ship::Info_Flags::Cargo] || cargo_sip->flags[Ship::Info_Flags::Transport])) { + if ((cargo_sip->class_type < 0) || !(Ship_types[cargo_sip->class_type].flags[Ship::Type_Info_Flags::Scannable_by_default])) { return false; } } @@ -1710,8 +1710,6 @@ bool player_inspect_cargo(float frametime, char *outstr) auto cargo_name = (cargo_sp->cargo1 & CARGO_INDEX_MASK) == 0 ? XSTR("Nothing", 1674) : Cargo_names[cargo_sp->cargo1 & CARGO_INDEX_MASK]; - //Why was this assert here? I'm not sure it makes much sense because any ship can be scanned and have cargo revealed... - //Assert(cargo_sip->flags[Ship::Info_Flags::Cargo] || cargo_sip->flags[Ship::Info_Flags::Transport]); if (cargo_sp->cargo_title[0] != '\0') { if (cargo_sp->cargo_title[0] == '#') { diff --git a/code/ship/ship.cpp b/code/ship/ship.cpp index 1747a59eaea..2494d8fc8eb 100644 --- a/code/ship/ship.cpp +++ b/code/ship/ship.cpp @@ -6145,8 +6145,12 @@ static void parse_ship_type(const char *filename, const bool replace) stuff_boolean_flag(stp->flags, Ship::Type_Info_Flags::Show_attack_direction); } - if(optional_string("$Scannable:")) { - stuff_boolean_flag(stp->flags, Ship::Type_Info_Flags::Scannable); + if(optional_string("$Scannable:") || optional_string("$Targetable as unscanned:")) { + stuff_boolean_flag(stp->flags, Ship::Type_Info_Flags::Targetable_as_unscanned); + } + + if(optional_string("$Scannable by default:")) { + stuff_boolean_flag(stp->flags, Ship::Type_Info_Flags::Scannable_by_default); } if(optional_string("$Warp Pushes:")) { diff --git a/code/ship/ship_flags.h b/code/ship/ship_flags.h index 683dc43ad53..69e4fccd3c4 100644 --- a/code/ship/ship_flags.h +++ b/code/ship/ship_flags.h @@ -230,7 +230,8 @@ namespace Ship { Target_as_threat, Show_attack_direction, No_class_display, - Scannable, + Targetable_as_unscanned, + Scannable_by_default, Warp_pushes, Warp_pushable, Turret_tgt_ship_tgt,