Skip to content

Commit

Permalink
delete redundant melee gun modes, disassociate gun_mode from added ba…
Browse files Browse the repository at this point in the history
…yonet damage (#71295)

* begin

* stuff

* underbarrel

* new way

* doc
  • Loading branch information
KeremBabaG authored Feb 2, 2024
1 parent 31ab4da commit fa7c040
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
6 changes: 3 additions & 3 deletions data/json/items/gunmod/underbarrel.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
"location": "underbarrel",
"//": "underbarrel to interfere with other stuff in the underbarrel slot on the SKS.",
"mod_targets": [ "shotgun", "rifle" ],
"mode_modifier": [ [ "REACH", "bayonet", 1, [ "MELEE" ] ] ],
"is_bayonet": true,
"qualities": [ [ "CUT", 1 ], [ "COOK", 1 ], [ "BUTCHER", -18 ] ],
"flags": [ "SLOW_WIELD", "IRREMOVABLE", "ALLOWS_REMOTE_USE" ],
"melee_damage": { "stab": 10 }
Expand Down Expand Up @@ -530,8 +530,8 @@
"gunmod_data": {
"location": "underbarrel",
"mod_targets": [ "shotgun", "rifle", "smg", "launcher", "crossbow" ],
"is_bayonet": true,
"blacklist_mod": [ "knife_combat_army", "knife_combat", "enfield_bayonet", "knife_combat_marine", "makeshift_bayonet", "sword_bayonet" ],
"mode_modifier": [ [ "REACH", "bayonet", 1, [ "MELEE" ] ] ],
"install_time": "5 m"
},
"extend": { "flags": [ "PUMP_RAIL_COMPATIBLE" ] }
Expand Down Expand Up @@ -643,9 +643,9 @@
"color": "light_gray",
"location": "underbarrel",
"mod_targets": [ "pistol" ],
"is_bayonet": true,
"min_skills": [ [ "weapon", 1 ], [ "melee", 1 ] ],
"qualities": [ [ "CUT", 1 ], [ "BUTCHER", 15 ] ],
"mode_modifier": [ [ "REACH", "bayonet", 1, [ "MELEE" ] ] ],
"flags": [ ],
"melee_damage": { "stab": 6 }
},
Expand Down
12 changes: 6 additions & 6 deletions data/json/items/melee/swords_and_blades.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"gunmod_data": {
"location": "bayonet lug",
"mod_targets": [ "pistol", "smg", "rifle", "shotgun", "launcher", "crossbow" ],
"is_bayonet": true,
"blacklist_mod": [
"crafted_suppressor",
"filter_suppressor",
Expand All @@ -318,7 +319,6 @@
"u_shotgun",
"u_shotgun_mod"
],
"mode_modifier": [ [ "REACH", "bayonet", 1, [ "MELEE" ] ] ],
"install_time": "5 s"
},
"min_skills": [ [ "weapon", 2 ], [ "melee", 1 ] ],
Expand Down Expand Up @@ -368,6 +368,7 @@
"gunmod_data": {
"location": "bayonet lug",
"mod_targets": [ "pistol", "smg", "rifle", "shotgun", "launcher", "crossbow" ],
"is_bayonet": true,
"blacklist_mod": [
"crafted_suppressor",
"filter_suppressor",
Expand All @@ -391,7 +392,6 @@
"u_shotgun",
"u_shotgun_mod"
],
"mode_modifier": [ [ "REACH", "bayonet", 1, [ "MELEE" ] ] ],
"install_time": "5 s"
},
"min_skills": [ [ "weapon", 2 ], [ "melee", 1 ] ],
Expand Down Expand Up @@ -429,6 +429,7 @@
"gunmod_data": {
"location": "bayonet lug",
"mod_targets": [ "pistol", "smg", "rifle", "shotgun", "launcher", "crossbow" ],
"is_bayonet": true,
"blacklist_mod": [
"crafted_suppressor",
"filter_suppressor",
Expand All @@ -452,7 +453,6 @@
"u_shotgun",
"u_shotgun_mod"
],
"mode_modifier": [ [ "REACH", "bayonet", 1, [ "MELEE" ] ] ],
"install_time": "5 s"
},
"min_skills": [ [ "weapon", 2 ], [ "melee", 1 ] ],
Expand Down Expand Up @@ -1660,6 +1660,7 @@
"gunmod_data": {
"location": "bayonet lug",
"mod_targets": [ "smg", "rifle", "shotgun", "launcher", "crossbow" ],
"is_bayonet": true,
"blacklist_mod": [
"crafted_suppressor",
"filter_suppressor",
Expand All @@ -1683,7 +1684,6 @@
"u_shotgun",
"u_shotgun_mod"
],
"mode_modifier": [ [ "REACH", "bayonet", 1, [ "MELEE" ] ] ],
"install_time": "5 s"
},
"min_skills": [ [ "weapon", 2 ], [ "melee", 2 ] ],
Expand Down Expand Up @@ -3090,6 +3090,7 @@
"gunmod_data": {
"location": "bayonet lug",
"mod_targets": [ "number4_mki" ],
"is_bayonet": true,
"blacklist_mod": [
"crafted_suppressor",
"filter_suppressor",
Expand All @@ -3113,7 +3114,6 @@
"u_shotgun",
"u_shotgun_mod"
],
"mode_modifier": [ [ "REACH", "bayonet", 1, [ "MELEE" ] ] ],
"install_time": "5 s"
},
"min_skills": [ [ "weapon", 2 ], [ "melee", 1 ] ],
Expand All @@ -3140,6 +3140,7 @@
"gunmod_data": {
"location": "bayonet lug",
"mod_targets": [ "type99", "type_99_sniper" ],
"is_bayonet": true,
"blacklist_mod": [
"crafted_suppressor",
"filter_suppressor",
Expand All @@ -3163,7 +3164,6 @@
"u_shotgun",
"u_shotgun_mod"
],
"mode_modifier": [ [ "REACH", "bayonet", 1, [ "MELEE" ] ] ],
"install_time": "5 s"
},
"techniques": [ "WBLOCK_2" ],
Expand Down
1 change: 1 addition & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4211,6 +4211,7 @@ Gun mods can be defined like this:
"cooling_value_multiplier": 0.5, // Multiply gun's "cooling_value" by this number; works the same as overheat_threshold_multiplier
"heat_per_shot_modifier": -2, // Add a flat amount to gun's "heat_per_shot"; works the same as overheat_threshold_modifier
"heat_per_shot_multiplier": 2.0, // Multiply the gun's "heat_per_shot" by this number; works the same as overheat_threshold_multiplier
"is_bayonet": true, // Optional, if true, the melee damage of this item is added to the base damage of the gun. Defaults to false.
"blacklist_slot": [ "rail", "underbarrel" ], // prevents installation of the gunmod if the specified slot(s) are present on the gun.
"blacklist_mod": [ "m203", "m320" ], // prevents installation of the gunmod if the specified mods(s) are present on the gun.
```
Expand Down
8 changes: 4 additions & 4 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7390,12 +7390,12 @@ int item::damage_melee( const damage_type_id &dt ) const
res *= 1.3;
}

// consider any melee gunmods
// consider any attached bayonets
if( is_gun() ) {
std::vector<int> opts = { res };
for( const std::pair<const gun_mode_id, gun_mode> &e : gun_all_modes() ) {
if( e.second.target != this && e.second.melee() ) {
opts.push_back( e.second.target->damage_melee( dt ) );
for( const item *mod : gunmods() ) {
if( mod->type->gunmod->is_bayonet ) {
opts.push_back( mod->damage_melee( dt ) );
}
}
return *std::max_element( opts.begin(), opts.end() );
Expand Down
2 changes: 2 additions & 0 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3464,6 +3464,8 @@ void Item_factory::load( islot_gunmod &slot, const JsonObject &jo, const std::st
slot.add_mod.emplace( gunmod_location( curr.get_string( 0 ) ), curr.get_int( 1 ) );
}
}

assign( jo, "is_bayonet", slot.is_bayonet );
assign( jo, "blacklist_mod", slot.blacklist_mod );
assign( jo, "blacklist_slot", slot.blacklist_slot );
assign( jo, "barrel_length", slot.barrel_length );
Expand Down
3 changes: 3 additions & 0 deletions src/itype.h
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,9 @@ struct islot_gunmod : common_ranged_data {
/** Additional gunmod slots to add to the gun */
std::map<gunmod_location, int> add_mod;

// wheter the item is supposed to work as a bayonet when attached
bool is_bayonet = false;

/** Not compatible on weapons that have this mod slot */
std::set<gunmod_location> blacklist_slot;

Expand Down

0 comments on commit fa7c040

Please sign in to comment.