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

Change throwable extinguisher to perish after use #33561

Merged
merged 2 commits into from
Aug 27, 2019
Merged
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
6 changes: 4 additions & 2 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3397,14 +3397,16 @@ int iuse::throwable_extinguisher_act( player *, item *it, bool, const tripoint &
return 0;
}
if( g->m.get_field( pos, fd_fire ) != nullptr ) {
sounds::sound( pos, 50, sounds::sound_t::combat, _( "Bang!" ), false, "explosion", "small" );
// Reduce the strength of fire (if any) in the target tile.
g->m.mod_field_intensity( pos, fd_fire, 0 - 1 );
g->m.mod_field_intensity( pos, fd_fire, 0 - 2 );
// Slightly reduce the strength of fire around and in the target tile.
for( const tripoint &dest : g->m.points_in_radius( pos, 1 ) ) {
if( g->m.passable( dest ) && dest != pos ) {
g->m.mod_field_intensity( dest, fd_fire, 0 - rng( 0, 1 ) );
g->m.mod_field_intensity( dest, fd_fire, 0 - rng( 0, 2 ) );
}
}
it->charges = -1;
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value of the iuse function indicates whether the item should be deleted. This used to work fine. Returning X here means to remove X item / charges that was used up (and returning 0 means to consume 0 items / charges).

I suspect removing the item manually here and return 1 will lead to bugs as the calling code will attempt to remove the item as well (but it isn't there anymore).

}
it->active = false;
Expand Down