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

Burn just 1 item from a stack when refueling #34641

Merged
merged 2 commits into from
Oct 13, 2019
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
19 changes: 5 additions & 14 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2822,13 +2822,8 @@ void try_fuel_fire( player_activity &act, player &p, const bool starting_fire )
if( !contained && fire_age < -40_minutes && fd.fuel_produced > 1.0f && !it.made_of( LIQUID ) ) {
// Too much - we don't want a firestorm!
// Move item back to refueling pile
// Note: this handles messages (they're the generic "you drop x")
drop_on_map( p, item_drop_reason::deliberate, { it }, *refuel_spot );

const int distance = std::max( rl_dist( *best_fire, *refuel_spot ), 1 );
p.mod_moves( -Pickup::cost_to_move_item( p, it ) * distance );

g->m.i_rem( *best_fire, &it );
// Note: move_item() handles messages (they're the generic "you drop x")
move_item( p, it, 0, *best_fire, *refuel_spot, nullptr, -1 );
return;
}
}
Expand All @@ -2849,13 +2844,9 @@ void try_fuel_fire( player_activity &act, player &p, const bool starting_fire )
float last_fuel = fd.fuel_produced;
it.simulate_burn( fd );
if( fd.fuel_produced > last_fuel ) {
// Note: this handles messages (they're the generic "you drop x")
drop_on_map( p, item_drop_reason::deliberate, { it }, *best_fire );

const int distance = std::max( rl_dist( *refuel_spot, *best_fire ), 1 );
p.mod_moves( -Pickup::cost_to_move_item( p, it ) * distance );

g->m.i_rem( *refuel_spot, &it );
int quantity = std::max( 1, std::min( it.charges, it.charges_per_volume( 250_ml ) ) );
// Note: move_item() handles messages (they're the generic "you drop x")
move_item( p, it, quantity, *refuel_spot, *best_fire, nullptr, -1 );
return;
}
}
Expand Down
18 changes: 16 additions & 2 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7039,6 +7039,13 @@ float item::simulate_burn( fire_data &frd ) const
burn_added = 1;
}

if( count_by_charges() ) {
int stack_burnt = rng( type->stack_size / 2, type->stack_size );
time_added *= stack_burnt;
smoke_added *= stack_burnt;
burn_added *= stack_burnt;
}

frd.fuel_produced += time_added;
frd.smoke_produced += smoke_added;
return burn_added;
Expand All @@ -7053,10 +7060,17 @@ bool item::burn( fire_data &frd )
}

if( count_by_charges() ) {
burn_added *= rng( type->stack_size / 2, type->stack_size );
charges -= roll_remainder( burn_added );
if( type->volume == 0_ml ) {
charges = 0;
} else {
charges -= roll_remainder( burn_added * units::legacy_volume_factor * type->stack_size /
( 3.0 * type->volume ) );
}

if( charges <= 0 ) {
return true;
} else {
return false;
}
}

Expand Down