Skip to content

Commit

Permalink
burst_when_thrown_filled item property and condom to use it (#29801)
Browse files Browse the repository at this point in the history
* Added condom to containers and added a property named 'burst_when_thrown_filled' that takes a number which represents a percentage.
  • Loading branch information
Kaltag1925 authored and kevingranade committed May 10, 2019
1 parent 783fd96 commit d5f27f7
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 17 deletions.
1 change: 1 addition & 0 deletions SIGNOFF
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ Patrik Stridvall <patrik@stridvall.se>
Ryan Schneider (RadHazard) <rslego@gmail.com>
Paul Bransford (draeath) <draeath@gmail.com>
Mark Langsdorf (mlangsdorf) <mark.langsdorf@gmail.com> / <mlangsdo@redhat.com>
Davis Bray (Kaltag1925) <pdavisbray@gmail.com>
19 changes: 19 additions & 0 deletions data/json/items/containers.json
Original file line number Diff line number Diff line change
Expand Up @@ -1011,5 +1011,24 @@
"contains": 17,
"seals": true,
"watertight": true
},
{
"id": "condom",
"type": "CONTAINER",
"category": "other",
"name": "condom",
"description": "A gentleman's balloon. A single use life preventer. A thumbless latex mitten. This could be used as a makeshift water container, but otherwise it's anyone's guess what it's for.",
"weight": 5,
"volume": 0,
"price": 0,
"to_hit": -5,
"rigid": false,
"material": "plastic",
"symbol": ")",
"color": "white",
"contains": 15,
"watertight": true,
"seals": true,
"properties": [ [ "burst_when_filled", "75" ] ]
}
]
16 changes: 0 additions & 16 deletions data/json/items/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -2912,22 +2912,6 @@
"volume": 2,
"bashing": 5
},
{
"id": "condom",
"type": "GENERIC",
"category": "other",
"name": "condom",
"looks_like": "lens",
"description": "A gentleman's balloon. A single use life preventer. A thumbless latex mitten. This could be used as a makeshift water container, but otherwise it's anyone's guess what it's for.",
"weight": 5,
"volume": "5ml",
"price": 200,
"material": "plastic",
"symbol": "*",
"color": "white",
"bashing": 5,
"to_hit": -3
},
{
"type": "GENERIC",
"id": "lock",
Expand Down
3 changes: 2 additions & 1 deletion data/json/mapgen/cs_sex_shop.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
[ "leather_collar", 20 ],
[ "bondage_mask", 20 ],
[ "bullwhip", 20 ],
[ "candle", 20 ]
[ "candle", 20 ],
[ "condom", 20 ]
]
},
{
Expand Down
1 change: 1 addition & 0 deletions msvc-full-features/Cataclysm-vcpkg-static.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,4 @@
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

14 changes: 14 additions & 0 deletions src/ballistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ static void drop_or_embed_projectile( const dealt_projectile_attack &attack )
return;
}

if( effects.count( "BURST" ) ) {
// Drop the contents, not the thrown item
if( g->u.sees( pt ) ) {
add_msg( _( "The %s bursts!" ), drop_item.tname() );
}

for( const item &i : drop_item.contents ) {
g->m.add_item_or_charges( pt, i );
}

//TODO: Sound
return;
}

// Copy the item
item dropped_item = drop_item;

Expand Down
11 changes: 11 additions & 0 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,12 @@ dealt_projectile_attack player::throw_item( const tripoint &target, const item &
const bool shatter = !thrown.active && thrown.made_of( material_id( "glass" ) ) &&
rng( 0, units::to_milliliter( 2000_ml - volume ) ) < get_str() * 100;

// Item will burst upon landing, destroying the item, and spilling its contents
const bool burst = thrown.has_property( "burst_when_filled" ) && thrown.is_container() &&
thrown.get_property_long( "burst_when_filled" ) <= ( ( double )
thrown.get_contained().volume().value() ) / thrown.get_container_capacity().value() * 100;


// Add some flags to the projectile
if( weight > 500_gram ) {
proj_effects.insert( "HEAVY_HIT" );
Expand Down Expand Up @@ -545,6 +551,11 @@ dealt_projectile_attack player::throw_item( const tripoint &target, const item &
proj_effects.insert( "SHATTER_SELF" );
}

//TODO: Add wet effect if other things care about that
if( burst ) {
proj_effects.insert( "BURST" );
}

// Some minor (skill/2) armor piercing for skillful throws
// Not as much as in melee, though
for( damage_unit &du : impact.damage_units ) {
Expand Down

0 comments on commit d5f27f7

Please sign in to comment.