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

Fix attack of the tentacle dogs #39918

Merged
merged 4 commits into from
May 4, 2020
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
2 changes: 2 additions & 0 deletions data/json/monsters/nether.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@
"default_faction": "mutant",
"bodytype": "dog",
"species": [ "NETHER" ],
"diff": 2,
"volume": "62500 ml",
"weight": "81500 g",
"hp": 120,
Expand Down Expand Up @@ -747,6 +748,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