Skip to content

Commit

Permalink
Fix "bow" gunmod location not working (#1569)
Browse files Browse the repository at this point in the history
* Fix "bow" location not working at all

Also add warning in strict json mode

* Use ' instead of " for the quotes in hack
  • Loading branch information
Coolthulhu authored May 28, 2022
1 parent 86e432c commit a47ce63
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 14 deletions.
8 changes: 4 additions & 4 deletions data/json/items/gunmod/accessories.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"symbol": ":",
"color": "dark_gray",
"location": "accessories",
"mod_targets": [ "bow" ],
"mod_targets": [ "archery" ],
"dispersion_modifier": -100
},
{
Expand All @@ -29,7 +29,7 @@
"symbol": ":",
"color": "brown",
"location": "stabilizer",
"mod_targets": [ "bow" ],
"mod_targets": [ "archery" ],
"dispersion_modifier": -100
},
{
Expand All @@ -45,7 +45,7 @@
"symbol": ":",
"color": "brown",
"location": "stabilizer",
"mod_targets": [ "bow" ],
"mod_targets": [ "archery" ],
"dispersion_modifier": -150,
"flags": [ "NEEDS_UNFOLD" ]
},
Expand All @@ -62,7 +62,7 @@
"symbol": ":",
"color": "brown",
"location": "dampening",
"mod_targets": [ "bow", "crossbow" ],
"mod_targets": [ "archery", "crossbow" ],
"dispersion_modifier": -50,
"loudness_modifier": -8
},
Expand Down
2 changes: 1 addition & 1 deletion data/json/items/gunmod/grip.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"symbol": ":",
"color": "dark_gray",
"location": "grip",
"mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "launcher", "bow" ],
"mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "launcher", "archery" ],
"handling_modifier": 4
},
{
Expand Down
2 changes: 1 addition & 1 deletion data/json/items/gunmod/mount.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"symbol": ":",
"color": "light_gray",
"location": "underbarrel mount",
"mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "launcher", "bow" ],
"mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "launcher", "archery" ],
"install_time": "5 m",
"add_mod": [ [ "underbarrel", 1 ] ],
"flags": [ "INSTALL_DIFFICULT", "IRREMOVABLE" ]
Expand Down
6 changes: 3 additions & 3 deletions data/json/items/gunmod/sights.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"symbol": ":",
"color": "dark_gray",
"location": "sights",
"mod_targets": [ "bow" ],
"mod_targets": [ "archery" ],
"sight_dispersion": 10,
"aim_speed": 5
},
Expand All @@ -31,7 +31,7 @@
"symbol": ":",
"color": "dark_gray",
"location": "sights",
"mod_targets": [ "bow" ],
"mod_targets": [ "archery" ],
"sight_dispersion": 25,
"aim_speed": 8
},
Expand All @@ -49,7 +49,7 @@
"symbol": ":",
"color": "dark_gray",
"location": "sights",
"mod_targets": [ "bow" ],
"mod_targets": [ "archery" ],
"sight_dispersion": 5,
"aim_speed": 2,
"flags": [ "ZOOM" ]
Expand Down
2 changes: 1 addition & 1 deletion data/json/items/gunmod/underbarrel.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
"symbol": ":",
"color": "dark_gray",
"location": "underbarrel",
"mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "bow", "launcher" ],
"mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "archery", "launcher" ],
"sight_dispersion": 30,
"aim_speed": 9,
"flags": [ "PUMP_RAIL_COMPATIBLE" ]
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Magiclysm/items/enchanted_gunmods.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"symbol": ":",
"color": "dark_gray",
"location": "underbarrel",
"mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "bow", "launcher" ],
"mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "archery", "launcher" ],
"sight_dispersion": 27,
"aim_speed": 9,
"min_skills": [ [ "weapon", 2 ], [ "gun", 2 ] ],
Expand Down
8 changes: 5 additions & 3 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6926,8 +6926,6 @@ skill_id item::gun_skill() const

gun_type_type item::gun_type() const
{
static skill_id skill_archery( "archery" );

if( !is_gun() ) {
return gun_type_type( std::string() );
}
Expand Down Expand Up @@ -7503,6 +7501,8 @@ ret_val<bool> item::is_gunmod_compatible( const item &mod ) const
return ret_val<bool>::make_failure();
}
static const gun_type_type pistol_gun_type( translate_marker_context( "gun_type_type", "pistol" ) );
static const skill_id skill_archery( "archery" );
static const std::string bow_hack_str( "bow" );

if( !is_gun() ) {
return ret_val<bool>::make_failure( _( "isn't a weapon" ) );
Expand All @@ -7520,8 +7520,10 @@ ret_val<bool> item::is_gunmod_compatible( const item &mod ) const
return ret_val<bool>::make_failure( _( "doesn't have enough room for another %s mod" ),
mod.type->gunmod->location.name() );

// TODO: Get rid of the "archery"->"bow" hack
} else if( !mod.type->gunmod->usable.count( gun_type() ) &&
!mod.type->gunmod->usable.count( typeId().str() ) ) {
!mod.type->gunmod->usable.count( typeId().str() ) &&
!( gun_skill() == skill_archery && mod.type->gunmod->usable.count( bow_hack_str ) > 0 ) ) {
return ret_val<bool>::make_failure( _( "cannot have a %s" ), mod.tname() );

} else if( typeId() == itype_hand_crossbow &&
Expand Down
4 changes: 4 additions & 0 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,10 @@ void Item_factory::check_definitions() const
continue;
}

if( json_report_strict && t.name_ == "bow" ) {
msg += string_format( "'bow' location is deprecated, use 'archery' instead" );
}

// We need to check is_skill because something can be both an item and a skill
if( !is_skill && is_item ) {
const itype *target = &*item_type;
Expand Down

0 comments on commit a47ce63

Please sign in to comment.