Skip to content

Commit

Permalink
feat(enhancement): Add a "quiet" personality that prevents passive ha…
Browse files Browse the repository at this point in the history
…ils but still allows direct hails (endless-sky#9857)

By contrast, mute blocks all hails with a ship.
  • Loading branch information
bene-dictator authored Feb 25, 2024
1 parent 36399e5 commit 78fa853
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
11 changes: 10 additions & 1 deletion source/Personality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace {
UNRESTRICTED,
RESTRICTED,
DECLOAKED,
QUIET,

// This must be last so it can be used for bounds checking.
LAST_ITEM_IN_PERSONALITY_TRAIT_ENUM
Expand Down Expand Up @@ -105,7 +106,8 @@ namespace {
{"ramming", RAMMING},
{"unrestricted", UNRESTRICTED},
{"restricted", RESTRICTED},
{"decloaked", DECLOAKED}
{"decloaked", DECLOAKED},
{"quiet", QUIET}
};

// Tokens that combine two or more flags.
Expand Down Expand Up @@ -434,6 +436,13 @@ bool Personality::IsDecloaked() const



bool Personality::IsQuiet() const
{
return flags.test(QUIET);
}



const Point &Personality::Confusion() const
{
return confusion;
Expand Down
3 changes: 2 additions & 1 deletion source/Personality.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Personality {
bool IsMarked() const;
bool IsMute() const;
bool IsDecloaked() const;
bool IsQuiet() const;

// Current inaccuracy in this ship's targeting:
const Point &Confusion() const;
Expand All @@ -101,7 +102,7 @@ class Personality {
private:
// Make sure this matches the number of items in PersonalityTrait,
// or the build will fail.
static const int PERSONALITY_COUNT = 36;
static const int PERSONALITY_COUNT = 37;

bool isDefined = false;

Expand Down
2 changes: 1 addition & 1 deletion source/Ship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ bool Ship::CanSendHail(const PlayerInfo &player, bool allowUntranslated) const
return false;

// Make sure this ship is able to send a hail.
if(!Crew() || Cloaking() >= 1. || GetPersonality().IsMute())
if(!Crew() || Cloaking() >= 1. || GetPersonality().IsMute() || GetPersonality().IsQuiet())
return false;

// Ships that don't share a language with the player shouldn't communicate when hailed directly.
Expand Down

0 comments on commit 78fa853

Please sign in to comment.