diff --git a/src/monattack.cpp b/src/monattack.cpp index f2013a3e8ed88..7460c6bdc86d2 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -1427,20 +1427,15 @@ bool mattack::grow_vine( monster *z ) } } z->moves -= 100; - int xshift = rng( 0, 2 ); - int yshift = rng( 0, 2 ); - for( int x = 0; x < 3; x++ ) { - for( int y = 0; y < 3; y++ ) { - tripoint dest( z->posx() + ( x + xshift ) % 3 - 1, - z->posy() + ( y + yshift ) % 3 - 1, - z->posz() ); - if( !g->is_empty( dest ) ) { - continue; - } + for( const tripoint &dest : g->m.points_in_radius( z->pos(), 1 ) ) { + if( dest == z->pos() || !g->is_empty( dest ) ) { + continue; + } - if( monster *const vine = g->summon_mon( mon_creeper_vine, dest ) ) { - vine->make_ally( *z ); - } + if( monster *const vine = g->summon_mon( mon_creeper_vine, dest ) ) { + vine->make_ally( *z ); + // Store position of parent hub in vine goal point. + vine->set_goal( z->pos() ); } } @@ -1451,6 +1446,12 @@ bool mattack::vine( monster *z ) { std::vector grow; int vine_neighbors = 0; + bool parent_out_of_range = !g->m.inbounds( z->move_target() ); + monster *parent = g->critter_at( z->move_target() ); + if( !parent_out_of_range && ( parent == nullptr || parent->type->id != mon_creeper_hub ) ) { + // TODO: Should probably die instead. + return true; + } z->moves -= 100; for( const tripoint &dest : g->m.points_in_radius( z->pos(), 1 ) ) { Creature *critter = g->critter_at( dest ); @@ -1467,9 +1468,8 @@ bool mattack::vine( monster *z ) z->name(), body_part_name_accusative( bphit ) ); damage_instance d; - // TODO: Buff it to more "modern" numbers - 4+4 is nothing - d.add_damage( DT_CUT, 4 ); - d.add_damage( DT_BASH, 4 ); + d.add_damage( DT_CUT, 8 ); + d.add_damage( DT_BASH, 8 ); critter->deal_damage( z, bphit, d ); critter->check_dead_state(); z->moves -= 100; @@ -1485,23 +1485,17 @@ bool mattack::vine( monster *z ) } } // Calculate distance from nearest hub - int dist_from_hub = 999; - for( monster &critter : g->all_monsters() ) { - if( critter.type->id == mon_creeper_hub ) { - int dist = rl_dist( z->pos(), critter.pos() ); - if( dist < dist_from_hub ) { - dist_from_hub = dist; - } - } - } - if( grow.empty() || vine_neighbors > 5 || one_in( 7 - vine_neighbors ) || - !one_in( dist_from_hub ) ) { + int dist_from_hub = rl_dist( z->pos(), z->move_target() ); + if( grow.empty() || dist_from_hub > 20 || vine_neighbors > 5 || + one_in( 7 - vine_neighbors ) || !one_in( dist_from_hub ) ) { return true; } const tripoint target = random_entry( grow ); if( monster *const vine = g->summon_mon( mon_creeper_vine, target ) ) { vine->make_ally( *z ); vine->reset_special( "VINE" ); + // Store position of parent hub in vine goal point. + vine->set_goal( z->move_target() ); } return true;