Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crossbow gunmod compatibility #1526

Merged
merged 2 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,11 @@
"type": "json_flag",
"context": [ ]
},
{
"id": "CROSSBOW",
"type": "json_flag",
"context": [ ]
},
{
"id": "CUSTOM_EXPLOSION",
"type": "json_flag",
Expand Down
2 changes: 1 addition & 1 deletion data/json/items/gunmod/accessories.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"symbol": ":",
"color": "brown",
"location": "dampening",
"mod_targets": [ "bow" ],
"mod_targets": [ "bow", "crossbow" ],
"dispersion_modifier": -50,
"loudness_modifier": -8
},
Expand Down
14 changes: 7 additions & 7 deletions data/json/items/ranged/crossbows.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
"price": 20000,
"price_postapoc": 2000,
"material": [ "wood", "iron" ],
"flags": [ "STR_RELOAD", "PRIMITIVE_RANGED_WEAPON" ],
"flags": [ "STR_RELOAD", "PRIMITIVE_RANGED_WEAPON", "CROSSBOW" ],
"skill": "rifle",
"ammo": "pebble",
"weight": "1906 g",
Expand Down Expand Up @@ -317,7 +317,7 @@
"price": 55000,
"price_postapoc": 2500,
"material": [ "steel", "plastic" ],
"flags": [ "PRIMITIVE_RANGED_WEAPON" ],
"flags": [ "PRIMITIVE_RANGED_WEAPON", "CROSSBOW" ],
"skill": "pistol",
"ammo": "bolt",
"weight": "900 g",
Expand Down Expand Up @@ -352,7 +352,7 @@
"price": 6000,
"price_postapoc": 3500,
"material": [ "wood" ],
"flags": "PRIMITIVE_RANGED_WEAPON",
"flags": [ "PRIMITIVE_RANGED_WEAPON", "CROSSBOW" ],
"skill": "rifle",
"ammo": "bolt",
"weight": "2728 g",
Expand Down Expand Up @@ -380,7 +380,7 @@
"price": 89000,
"price_postapoc": 4000,
"material": [ "wood", "bone" ],
"flags": "PRIMITIVE_RANGED_WEAPON",
"flags": [ "PRIMITIVE_RANGED_WEAPON", "CROSSBOW" ],
"skill": "rifle",
"ammo": "bolt",
"weight": "3500 g",
Expand Down Expand Up @@ -417,7 +417,7 @@
"description": "A high-power crossbow with shaped cams and extra cables for high-power shots. Takes less time to reload due to a modern string-pulling system.",
"price": 200000,
"material": [ "steel", "plastic" ],
"flags": "PRIMITIVE_RANGED_WEAPON",
"flags": [ "PRIMITIVE_RANGED_WEAPON", "CROSSBOW" ],
"skill": "rifle",
"ammo": "bolt",
"weight": "3000 g",
Expand Down Expand Up @@ -455,7 +455,7 @@
"description": "A HUGE medieval crossbow from Germany with a very slow, difficult reloading process not suited for unskilled users. Its tension is so powerful that you feel it shake after firing. Bolts fired from this weapon have a good chance of remaining intact for re-use.",
"price": 32400,
"material": [ "iron", "wood" ],
"flags": [ "FIRE_TWOHAND", "PRIMITIVE_RANGED_WEAPON", "TRADER_AVOID" ],
"flags": [ "FIRE_TWOHAND", "PRIMITIVE_RANGED_WEAPON", "TRADER_AVOID", "CROSSBOW" ],
"skill": "rifle",
"ammo": "bolt",
"weight": "6803 g",
Expand Down Expand Up @@ -483,7 +483,7 @@
"description": "A custom-made crossbow with a clever mechanism that loads and fires bolts in a single motion, it has a wooden magazine that holds 10 bolts. Bolts fired from this weapon have a good chance of remaining intact for re-use.",
"price": 324000,
"material": [ "steel", "wood" ],
"flags": [ "FIRE_TWOHAND", "PRIMITIVE_RANGED_WEAPON", "TRADER_AVOID" ],
"flags": [ "FIRE_TWOHAND", "PRIMITIVE_RANGED_WEAPON", "TRADER_AVOID", "CROSSBOW" ],
"skill": "smg",
"ammo": "bolt",
"weight": "3628 g",
Expand Down
2 changes: 1 addition & 1 deletion data/mods/More_Survival_Tools/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
"clip_size": 1,
"reload": 300,
"valid_mod_locations": [ [ "underbarrel", 1 ], [ "sights", 1 ], [ "accessories", 2 ] ],
"flags": [ "PRIMITIVE_RANGED_WEAPON" ]
"flags": [ "PRIMITIVE_RANGED_WEAPON", "CROSSBOW" ]
},
{
"id": "heavy_snare_kit",
Expand Down
12 changes: 4 additions & 8 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ static const gun_mode_id gun_mode_REACH( "REACH" );
static const itype_id itype_barrel_small( "barrel_small" );
static const itype_id itype_blood( "blood" );
static const itype_id itype_brass_catcher( "brass_catcher" );
static const itype_id itype_bullet_crossbow( "bullet_crossbow" );
static const itype_id itype_cig_butt( "cig_butt" );
static const itype_id itype_cig_lit( "cig_lit" );
static const itype_id itype_cigar_butt( "cigar_butt" );
Expand Down Expand Up @@ -175,6 +174,7 @@ static const std::string flag_COLLAPSIBLE_STOCK( "COLLAPSIBLE_STOCK" );
static const std::string flag_CONDUCTIVE( "CONDUCTIVE" );
static const std::string flag_CONSUMABLE( "CONSUMABLE" );
static const std::string flag_CORPSE( "CORPSE" );
static const std::string flag_CROSSBOW( "CROSSBOW" );
static const std::string flag_DANGEROUS( "DANGEROUS" );
static const std::string flag_DEEP_WATER( "DEEP_WATER" );
static const std::string flag_DIAMOND( "DIAMOND" );
Expand Down Expand Up @@ -6931,15 +6931,11 @@ gun_type_type item::gun_type() const
if( !is_gun() ) {
return gun_type_type( std::string() );
}
if( has_flag( flag_CROSSBOW ) ) {
return gun_type_type( translate_marker_context( "gun_type_type", "crossbow" ) );
}
// TODO: move to JSON and remove extraction of this from "GUN" (via skill id)
//and from "GUNMOD" (via "mod_targets") in lang/extract_json_strings.py
if( gun_skill() == skill_archery ) {
if( ammo_types().count( ammotype( "bolt" ) ) || typeId() == itype_bullet_crossbow ) {
return gun_type_type( translate_marker_context( "gun_type_type", "crossbow" ) );
} else {
return gun_type_type( translate_marker_context( "gun_type_type", "bow" ) );
}
}
return gun_type_type( gun_skill().str() );
}

Expand Down