Skip to content

Commit

Permalink
JSONize gunmod weight multiplier (#36388)
Browse files Browse the repository at this point in the history
  • Loading branch information
pawnishoovy authored and kevingranade committed Dec 27, 2019
1 parent f532754 commit 5c0b19e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion data/json/items/gunmod/grip.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"mod_targets": [ "pistol", "smg", "rifle", "shotgun", "crossbow", "launcher" ],
"handling_modifier": -2,
"min_skills": [ [ "weapon", 3 ] ],
"flags": [ "REDUCED_WEIGHT", "REDUCED_BASHING" ]
"weight_multiplier": 0.75,
"flags": [ "REDUCED_BASHING" ]
},
{
"id": "pistol_grip",
Expand Down
7 changes: 7 additions & 0 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4127,6 +4127,13 @@ units::mass item::weight( bool include_contents, bool integral ) const
ret *= 0.75;
}

// if this is a gun apply all of its gunmods' weight multipliers
if( type->gun ) {
for( const item *mod : gunmods() ) {
ret *= mod->type->gunmod->weight_multiplier;
}
}

if( count_by_charges() ) {
ret *= charges;

Expand Down
1 change: 1 addition & 0 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,7 @@ void Item_factory::load( islot_gunmod &slot, const JsonObject &jo, const std::st
assign( jo, "consume_divisor", slot.consume_divisor );
assign( jo, "ammo_effects", slot.ammo_effects, strict );
assign( jo, "ups_charges_multiplier", slot.ups_charges_multiplier );
assign( jo, "weight_multiplier", slot.weight_multiplier );
if( jo.has_int( "time" ) ) {
slot.install_time = jo.get_int( "time" );
} else if( jo.has_string( "time" ) ) {
Expand Down
2 changes: 2 additions & 0 deletions src/itype.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,8 @@ struct islot_gunmod : common_ranged_data {

/** Increases base gun UPS consumption by this many times per shot */
float ups_charges_multiplier = 1.0f;
/** Increases gun weight by this many times */
float weight_multiplier = 1.0f;

/** Firing modes added to or replacing those of the base gun */
std::map<gun_mode_id, gun_modifier_data> mode_modifier;
Expand Down

0 comments on commit 5c0b19e

Please sign in to comment.