Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gun-shy #76536

Merged
merged 14 commits into from
Sep 21, 2024
Merged

Gun-shy #76536

Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -9988,7 +9988,18 @@
"points": -4,
"description": "Whether from personal choice or childhood trauma, using ranged weapons is off-limits to you, even if your life depended on it.",
"starting_trait": true,
"valid": false,
"cancels": [ "GUNSHY" ]
},
{
"type": "mutation",
"id": "GUNSHY",
"name": { "str": "Gun-Shy" },
"points": -3,
"description": "Using a firearm is off limits, due to personal philosophy or a traumatic event. You can still use bows and slings.",
Consoleable marked this conversation as resolved.
Show resolved Hide resolved
"starting_trait": true,
"valid": false
Consoleable marked this conversation as resolved.
Show resolved Hide resolved
"cancels": [ "BRAWLER" ]
},
{
"type": "mutation",
Expand Down
5 changes: 5 additions & 0 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ static const quality_id qual_CUT( "CUT" );
static const skill_id skill_melee( "melee" );

static const trait_id trait_BRAWLER( "BRAWLER" );
static const trait_id trait_GUNSHY( "GUNSHY" );
static const trait_id trait_HIBERNATE( "HIBERNATE" );
static const trait_id trait_PROF_CHURL( "PROF_CHURL" );
static const trait_id trait_SHELL2( "SHELL2" );
Expand Down Expand Up @@ -1696,6 +1697,10 @@ static void fire()
add_msg( m_bad, _( "You refuse to use ranged weapons." ) );
return;
}
if( you.has_trait( trait_GUNSHY ) && weapon->is_firearm() ) {
add_msg( m_bad, _( "You refuse to use firearms." ) );
return;
}
// try firing gun
if( weapon && weapon->is_gun() && !weapon->gun_current_mode().melee() ) {
avatar_action::fire_wielded_weapon( you );
Expand Down
7 changes: 7 additions & 0 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ static const skill_id skill_swimming( "swimming" );
static const skill_id skill_throw( "throw" );

static const trait_id trait_BRAWLER( "BRAWLER" );
static const trait_id trait_GUNSHY( "GUNSHY" );
static const trait_id trait_PYROMANIA( "PYROMANIA" );

static const trap_str_id tr_practice_target( "tr_practice_target" );
Expand Down Expand Up @@ -4178,6 +4179,12 @@ bool gunmode_checks_common( avatar &you, const map &m, std::vector<std::string>
result = false;
}

if( you.has_trait( trait_GUNSHY ) ) {
messages.push_back( string_format( _( "You're too gun-shy to use this." ),
gmode->tname() ) );
result = false;
}

// Check that passed gun mode is valid and we are able to use it
if( !( gmode && you.can_use( *gmode ) ) ) {
messages.push_back( string_format( _( "You can't currently fire your %s." ),
Expand Down
7 changes: 7 additions & 0 deletions src/turret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ static const skill_id skill_gun( "gun" );

static const trait_id trait_BRAWLER( "BRAWLER" );

static const trait_id trait_GUNSHY( "GUNSHY" );

std::vector<vehicle_part *> vehicle::turrets()
{
std::vector<vehicle_part *> res;
Expand Down Expand Up @@ -415,6 +417,11 @@ bool vehicle::turrets_aim( std::vector<vehicle_part *> &turrets )
_( "Pfft. You are a brawler; using turrets is beneath you." ) );
return false;
}
if( player_character.has_trait( trait_GUNSHY ) ) {
player_character.add_msg_if_player(
_( "Firing a gun isn't any better, even if it's mounted." ) );
return false;
}

// Get target
target_handler::trajectory trajectory = target_handler::mode_turrets( player_character, *this,
Expand Down
Loading