Make thrown glass items drop glass shards when shattered #48727
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Features "Make thrown glass items drop glass shard when shattered"
Purpose of change
Thrown glass item can shatter, but they don't drop glass shard.
This PR aim to correct this.
Describe the solution
Divide mass of the item by mass of glass shard to get max shards.
Drop between half max and max-1 shards, so the item has to weight at least 2 times a glass shard to yield something.
Describe alternatives you've considered
Using volume instead of mass for calculation but it makes less sense I suppose.
Write a message to user when the shattered item yielded no shards ( it's only when item_mass < 2*shard_mass ).
Testing
Additional context
Does not affect smashed items.
This PR should not be merged if #48712 isn't, because the player could duplicate glass shard by repeatedly throwing glass items ( 48712 make shattered items disappear ).
There is inconsistency with the glass bottle, as discussed in 48712.