Skip to content

Commit

Permalink
feat(balance): uncanny dodge can now actually roll to dodge bullets (#…
Browse files Browse the repository at this point in the history
…4125)

* feat(balance): uncanny dodge can now actually roll to dodge bullets

* Update character_functions.cpp

Co-Authored-By: scarf <greenscarf005@gmail.com>

* On second thought use get_dodge

* style(autofix.ci): automated formatting

---------

Co-authored-by: scarf <greenscarf005@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 24, 2024
1 parent 8004866 commit 8c0dd4a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
5 changes: 3 additions & 2 deletions data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -1082,13 +1082,14 @@
"id": "bio_uncanny_dodge",
"type": "bionic",
"name": { "str": "Uncanny Dodge" },
"description": "Your nervous system has been augmented with bionic processors, allowing you to dodge attacks beyond normal human capability, including bullets.",
"description": "Your nervous system has been augmented with bionic processors, increasing your ability to dodge while active. Your dodge skill will also grant a chance to evade attacks beyond normal human capability, such as bullets.",
"occupied_bodyparts": [ [ "torso", 12 ], [ "arm_l", 3 ], [ "arm_r", 3 ], [ "leg_l", 5 ], [ "leg_r", 5 ], [ "foot_l", 1 ], [ "foot_r", 1 ] ],
"flags": [ "BIONIC_TOGGLED" ],
"act_cost": "6 J",
"react_cost": "6 J",
"trigger_cost": "75 kJ",
"time": 1
"time": 1,
"enchantments": [ "ENCH_UNCANNY_DODGE" ]
},
{
"id": "bio_ups",
Expand Down
16 changes: 16 additions & 0 deletions data/json/enchantments.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,21 @@
{ "value": "ARMOR_STAB", "multiply": -0.08 },
{ "value": "ARMOR_BULLET", "multiply": -0.15 }
]
},
{
"type": "enchantment",
"id": "ENCH_UNCANNY_DODGE",
"condition": "ACTIVE",
"mutations": [ "ENCH_UNCANNY_DODGE_EFFECT" ]
},
{
"type": "mutation",
"id": "ENCH_UNCANNY_DODGE_EFFECT",
"name": { "str": "Uncanny Dodge" },
"points": 0,
"valid": false,
"description": "You're currently under the effects of the Uncanny Dodge CBM.",
"dodge_modifier": 2,
"player_display": false
}
]
2 changes: 1 addition & 1 deletion data/json/items/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@
"type": "BIONIC_ITEM",
"name": { "str": "Uncanny Dodge CBM" },
"looks_like": "bio_int_enhancer",
"description": "Bionic processors that augment the user's nervous system, allowing them to dodge attacks beyond normal human capability, including bullets.",
"description": "Bionic processors that augment the user's nervous system, increasing their ability to dodge while active. Dodge skill will also allow evading attacks beyond normal human capability, such as bullets.",
"price": "9500 USD",
"weight": "1000 g",
"difficulty": 11
Expand Down
22 changes: 16 additions & 6 deletions src/character_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,19 +604,29 @@ bool try_uncanny_dodge( Character &who )
who.mod_power_level( -trigger_cost );
bool is_u = who.is_avatar();
bool seen = is_u || get_player_character().sees( who );
std::optional<tripoint> adjacent = pick_safe_adjacent_tile( who );
if( adjacent ) {
// If successful, dodge for free. If we already burned bonus dodges this turn then get_dodge fails and we're overwhelmed.
if( x_in_y( who.get_dodge(), 10 ) ) {
if( is_u ) {
add_msg( _( "Time seems to slow down and you instinctively dodge!" ) );
add_msg( m_good, _( "Time seems to slow down and you effortlessly dodge!" ) );
} else if( seen ) {
add_msg( _( "%s dodges… so fast!" ), who.disp_name() );
add_msg( m_good, _( "%s effortlessly dodges… so fast!" ), who.disp_name() );
}
return true;
// Didn't get a free dodge, burn dodges_left instead. If this zeros them out and there's still more attacks coming this turn the next shot will hit.
} else if( who.dodges_left > 0 ) {
if( is_u ) {
add_msg( m_mixed, _( "Time seems to slow down and you instinctively dodge!" ) );
} else if( seen ) {
add_msg( m_mixed, _( "%s dodges… so fast!" ), who.disp_name() );
}
who.dodges_left--;
return true;
// No dodges left, catch those hands.
} else {
if( is_u ) {
add_msg( _( "You try to dodge but there's no room!" ) );
add_msg( m_bad, _( "You try to dodge but fail!" ) );
} else if( seen ) {
add_msg( _( "%s tries to dodge but there's no room!" ), who.disp_name() );
add_msg( m_bad, _( "%s tries to dodge but fails!" ), who.disp_name() );
}
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,9 @@ static double occupied_tile_fraction( creature_size target_size )

double Creature::ranged_target_size() const
{
if( const_cast<Creature &>( *this ).uncanny_dodge() ) {
return 0.0;
}
if( has_flag( MF_HARDTOSHOOT ) ) {
switch( get_size() ) {
case creature_size::tiny:
Expand Down

0 comments on commit 8c0dd4a

Please sign in to comment.