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

Add 'Brawler' trait, disallowing use of ranged weapons #57948

Merged
merged 6 commits into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -7806,6 +7806,15 @@
"starting_trait": true,
"valid": false
},
{
"type": "mutation",
"id": "BRAWLER",
"name": { "str": "Brawler" },
"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
},
{
"type": "mutation",
"id": "FAST_REFLEXES",
Expand Down
6 changes: 6 additions & 0 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static const move_mode_id move_mode_prone( "prone" );

static const skill_id skill_swimming( "swimming" );

static const trait_id trait_BRAWLER( "BRAWLER" );
static const trait_id trait_GRAZER( "GRAZER" );
static const trait_id trait_RUMINANT( "RUMINANT" );
static const trait_id trait_SHELL2( "SHELL2" );
Expand Down Expand Up @@ -756,6 +757,11 @@ static bool can_fire_turret( avatar &you, const map &m, const turret_data &turre
return false;
}

if( you.has_trait( trait_BRAWLER ) ) {
add_msg( m_bad, _( "You refuse to use the %s." ), turret.name() );
return false;
}

switch( turret.query() ) {
case turret_data::status::no_ammo:
add_msg( m_bad, _( "The %s is out of ammo." ), turret.name() );
Expand Down
9 changes: 9 additions & 0 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,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_HIBERNATE( "HIBERNATE" );
static const trait_id trait_PROF_CHURL( "PROF_CHURL" );
static const trait_id trait_SHELL2( "SHELL2" );
Expand Down Expand Up @@ -1456,11 +1457,19 @@ static void fire()

turret_data turret;
if( vp && ( turret = vp->vehicle().turret_query( player_character.pos() ) ) ) {
if( player_character.has_trait( trait_BRAWLER ) ) {
add_msg( m_bad, _( "You refuse to use the turret." ) );
return;
}
avatar_action::fire_turret_manual( player_character, here, turret );
return;
}

if( vp.part_with_feature( "CONTROLS", true ) ) {
if( player_character.has_trait( trait_BRAWLER ) ) {
add_msg( m_bad, _( "You refuse to use the turret." ) );
return;
}
if( vp->vehicle().turrets_aim_and_fire_all_manual() ) {
return;
}
Expand Down
6 changes: 6 additions & 0 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ static const skill_id skill_gun( "gun" );
static const skill_id skill_launcher( "launcher" );
static const skill_id skill_throw( "throw" );

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

static const trap_str_id tr_practice_target( "tr_practice_target" );
Expand Down Expand Up @@ -3704,6 +3705,11 @@ bool gunmode_checks_common( avatar &you, const map &m, std::vector<std::string>
const gun_mode &gmode )
{
bool result = true;
if( you.has_trait( trait_BRAWLER ) ) {
messages.push_back( string_format( _( "Pfft. You are a brawler; using %s is beneath you." ),
gmode->tname() ) );
result = false;
}

// Check that passed gun mode is valid and we are able to use it
if( !( gmode && you.can_use( *gmode ) ) ) {
Expand Down
20 changes: 14 additions & 6 deletions src/vehicle_use.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ static const quality_id qual_SCREW( "SCREW" );

static const skill_id skill_mechanics( "mechanics" );

static const trait_id trait_BRAWLER( "BRAWLER" );

static const vpart_id vpart_horn_bicycle( "horn_bicycle" );

static const zone_type_id zone_type_VEHICLE_PATROL( "VEHICLE_PATROL" );
Expand Down Expand Up @@ -811,23 +813,29 @@ void vehicle::use_controls( const tripoint &pos )
}
}

if( has_part( "TURRET" ) ) {
options.emplace_back( _( "Set turret targeting modes" ), keybind( "TURRET_TARGET_MODE" ) );
// TODO: Decide - Do I disable options or remove them entirely?
if( has_part( "TURRET" ) /*&& !player_character.has_trait(trait_BRAWLER) */ ) {
bombasticSlacks marked this conversation as resolved.
Show resolved Hide resolved
bool enabled = !player_character.has_trait( trait_BRAWLER );

options.emplace_back( 0, enabled, keybind( "TURRET_TARGET_MODE" ),
_( "Set turret targeting modes" ) );
actions.emplace_back( [&] { turrets_set_targeting(); refresh(); } );

options.emplace_back( _( "Set turret firing modes" ), keybind( "TURRET_FIRE_MODE" ) );
options.emplace_back( 0, enabled, keybind( "TURRET_FIRE_MODE" ), _( "Set turret firing modes" ) );
actions.emplace_back( [&] { turrets_set_mode(); refresh(); } );

// We can also fire manual turrets with ACTION_FIRE while standing at the controls.
options.emplace_back( _( "Aim turrets manually" ), keybind( "TURRET_MANUAL_AIM" ) );
options.emplace_back( 0, enabled, keybind( "TURRET_MANUAL_AIM" ), _( "Aim turrets manually" ) );
actions.emplace_back( [&] { turrets_aim_and_fire_all_manual( true ); refresh(); } );

// This lets us manually override and set the target for the automatic turrets instead.
options.emplace_back( _( "Aim automatic turrets" ), keybind( "TURRET_MANUAL_OVERRIDE" ) );
options.emplace_back( 0, enabled, keybind( "TURRET_MANUAL_OVERRIDE" ),
_( "Aim automatic turrets" ) );
actions.emplace_back( [&] { turrets_override_automatic_aim(); refresh(); } );

options.emplace_back( _( "Aim individual turret" ), keybind( "TURRET_SINGLE_FIRE" ) );
options.emplace_back( 0, enabled, keybind( "TURRET_SINGLE_FIRE" ), _( "Aim individual turret" ) );
actions.emplace_back( [&] { turrets_aim_and_fire_single(); refresh(); } );
// }
}

uilist menu;
Expand Down