Skip to content

Commit

Permalink
Fix attack of the tentacle dogs (#39918)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aloxaf authored May 4, 2020
1 parent e635446 commit 5307883
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
2 changes: 2 additions & 0 deletions data/json/monsters/nether.json
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@
"default_faction": "mutant",
"bodytype": "dog",
"species": [ "NETHER" ],
"diff": 2,
"volume": "62500 ml",
"weight": "81500 g",
"hp": 120,
Expand Down Expand Up @@ -755,6 +756,7 @@
"default_faction": "mutant",
"bodytype": "blob",
"species": [ "NETHER" ],
"diff": 2,
"volume": "92500 ml",
"weight": "120 kg",
"hp": 160,
Expand Down
36 changes: 28 additions & 8 deletions src/monattack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2525,14 +2525,18 @@ bool mattack::tentacle( monster *z )
// TODO: handle friendly monsters
return false;
}
Creature *target = &g->u;
if( !z->sees( g->u ) ) {
Creature *target = z->attack_target();
if( target == nullptr || rl_dist( z->pos(), target->pos() ) > 3 || !z->sees( *target ) ) {
return false;
}
add_msg( m_bad, _( "The %s lashes its tentacle at you!" ), z->name() );
game_message_type msg_type = target == &g->u ? m_bad : m_info;
target->add_msg_player_or_npc( msg_type,
_( "The %s lashes its tentacle at you!" ),
_( "The %s lashes its tentacle at <npcname>!" ),
z->name() );
z->moves -= 100;

if( g->u.uncanny_dodge() ) {
if( target->uncanny_dodge() ) {
return true;
}
// Can we dodge the attack? Uses player dodge function % chance (melee.cpp)
Expand All @@ -2544,12 +2548,28 @@ bool mattack::tentacle( monster *z )
}

const bodypart_id hit = target->get_random_body_part();
const body_part hit_token = hit->token;
int dam = rng( 10, 20 );
//~ 1$s is bodypart name, 2$d is damage value.
add_msg( m_bad, _( "Your %1$s is hit for %2$d damage!" ), body_part_name( hit->token ), dam );
g->u.deal_damage( z, hit, damage_instance( DT_BASH, dam ) );
dam = target->deal_damage( z, hit, damage_instance( DT_BASH, dam ) ).total_damage();

if( dam > 0 ) {
target->add_msg_player_or_npc( msg_type,
//~ 1$s is bodypart name, 2$d is damage value.
_( "Your %1$s is hit for %2$d damage!" ),
//~ 1$s is bodypart name, 2$d is damage value.
_( "<npcname>'s %1$s is hit for %2$d damage!" ),
body_part_name( hit_token ),
dam );
} else {
target->add_msg_player_or_npc(
_( "The %1$s lashes its tentacle at your %2$s, but glances off your armor!" ),
_( "The %1$s lashes its tentacle at <npcname>'s %2$s, but glances off their armor!" ),
z->name(),
body_part_name_accusative( hit_token ) );
}

target->on_hit( z, hit, z->type->melee_skill );
g->u.check_dead_state();
target->check_dead_state();

return true;
}
Expand Down

0 comments on commit 5307883

Please sign in to comment.