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

Activate trap on force-moved enemies #2696

Merged
merged 4 commits into from
Apr 25, 2023
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
3 changes: 3 additions & 0 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10857,6 +10857,9 @@ void Character::knock_back_to( const tripoint &to )

} else { // It's no wall
setpos( to );

map &here = get_map();
here.creature_on_trap( *this );
}
}

Expand Down
21 changes: 20 additions & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4260,6 +4260,8 @@ void game::knockback( std::vector<tripoint> &traj, int stun, int dam_mult,
}
std::size_t force_remaining = traj.size();
if( monster *const targ = critter_at<monster>( tp, true ) ) {
tripoint start_pos = targ->pos();

if( stun > 0 ) {
targ->add_effect( effect_stunned, 1_turns * stun );
add_msg( _( "%s was stunned!" ), targ->name() );
Expand Down Expand Up @@ -4317,8 +4319,14 @@ void game::knockback( std::vector<tripoint> &traj, int stun, int dam_mult,
}
}
tp = traj[i];
if( start_pos != targ->pos() ) {
map &here = get_map();
here.creature_on_trap( *targ );
}
}
} else if( npc *const targ = critter_at<npc>( tp ) ) {
tripoint start_pos = targ->pos();

if( stun > 0 ) {
targ->add_effect( effect_stunned, 1_turns * stun );
add_msg( _( "%s was stunned!" ), targ->name );
Expand Down Expand Up @@ -4383,8 +4391,15 @@ void game::knockback( std::vector<tripoint> &traj, int stun, int dam_mult,
}
targ->setpos( traj[i] );
tp = traj[i];

if( start_pos != targ->pos() ) {
map &here = get_map();
here.creature_on_trap( *targ );
}
}
} else if( u.pos() == tp ) {
tripoint start_pos = u.pos();

if( stun > 0 ) {
u.add_effect( effect_stunned, 1_turns * stun );
add_msg( m_bad, vgettext( "You were stunned for %d turn!",
Expand Down Expand Up @@ -4462,8 +4477,12 @@ void game::knockback( std::vector<tripoint> &traj, int stun, int dam_mult,
} else {
u.setpos( traj[i] );
}

tp = traj[i];

if( start_pos != u.pos() ) {
map &here = get_map();
here.creature_on_trap( u );
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,9 @@ void monster::knock_back_to( const tripoint &to )

} else { // It's no wall
setpos( to );

map &here = get_map();
here.creature_on_trap( *this );
}
check_dead_state();
}
Expand Down
1 change: 1 addition & 0 deletions src/teleport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,6 @@ bool teleport::teleport( Creature &critter, int min_distance, int max_distance,
g->update_map( *p );
}
critter.remove_effect( effect_grabbed );
here.creature_on_trap( critter );
return true;
}
Loading