From d50f65358d9f57304c47116dbdececce2e9f9898 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Wed, 25 Sep 2019 01:58:02 -0400 Subject: [PATCH 01/38] better gun maint --- src/ranged.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index ab144d9a3489d..94d7a5a85ba0d 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -63,7 +63,7 @@ #include "type_id.h" #include "point.h" -const skill_id skill_throw( "throw" ); +const skill_id skill_throw( "throwx" ); const skill_id skill_gun( "gun" ); const skill_id skill_driving( "driving" ); const skill_id skill_dodge( "dodge" ); From 8232ad6df8fbbcb3cdbe53d30e1a0060ebb4c122 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Thu, 26 Sep 2019 03:41:51 -0400 Subject: [PATCH 02/38] better gun maintenance --- data/json/items/classes/gun.json | 12 ++--- data/json/items/gun/22.json | 16 +++--- data/json/items/gun/223.json | 2 +- data/json/items/gun/3006.json | 8 +-- data/json/items/gun/308.json | 2 +- data/json/items/gun/32.json | 6 +-- data/json/items/gun/38.json | 8 +-- data/json/items/gun/40.json | 8 +-- data/json/items/gun/44.json | 4 +- data/json/items/gun/45.json | 10 ++-- data/json/items/gun/46.json | 2 +- data/json/items/gun/460.json | 2 +- data/json/items/gun/57.json | 4 +- data/json/items/gun/762x25.json | 2 +- data/json/items/gun/9mm.json | 14 +++--- data/json/items/gun/faults_gun.json | 10 ++-- data/json/items/ranged.json | 4 +- src/activity_handlers.cpp | 3 ++ src/avatar_action.cpp | 7 --- src/item.cpp | 1 + src/ranged.cpp | 76 ++++++++++++++++++----------- 21 files changed, 109 insertions(+), 92 deletions(-) diff --git a/data/json/items/classes/gun.json b/data/json/items/classes/gun.json index ac52b068bd36a..4b6626546eb24 100644 --- a/data/json/items/classes/gun.json +++ b/data/json/items/classes/gun.json @@ -6,7 +6,7 @@ "name": "base gun", "symbol": "(", "color": "light_gray", - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ] + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ] }, { "abstract": "flamethrower_base", @@ -30,7 +30,7 @@ "modes": [ [ "DEFAULT", "single", 1, "NPC_AVOID" ] ], "valid_mod_locations": [ [ "accessories", 2 ], [ "barrel", 1 ], [ "sights", 1 ], [ "sling", 1 ] ], "flags": [ "RELOAD_ONE", "RELOAD_EJECT", "NEVER_JAMS" ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ] + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ] }, { "abstract": "pistol_base", @@ -81,7 +81,7 @@ "proportional": { "reload": 0.7 }, "extend": { "flags": [ "RELOAD_ONE", "RELOAD_EJECT", "NEVER_JAMS" ] }, "//": "Revolvers exclude the muzzle location preventing installation of suppressors", - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "valid_mod_locations": [ [ "accessories", 2 ], [ "barrel", 1 ], @@ -102,7 +102,7 @@ "reload": 150, "extend": { "flags": [ "RELOAD_ONE", "NO_UNLOAD" ] }, "//": "Slower reloads, no unloading. Base, unskilled person should take 1.5 seconds per chamber. No underbarrel mods, that's where the ram goes.", - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "valid_mod_locations": [ [ "accessories", 2 ], [ "barrel", 1 ], @@ -142,7 +142,7 @@ "name": "rifle with manual actions", "name_plural": "rifles with manual actions", "//": "Manual actions exclude the magazine location preventing installation of belt-feed adaptors", - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "valid_mod_locations": [ [ "accessories", 4 ], [ "barrel", 1 ], @@ -199,7 +199,7 @@ "name": "pump action shotgun", "reload_noise": "chuk chuk.", "flags": [ "RELOAD_ONE", "PUMP_ACTION" ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ] + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ] }, { "abstract": "smg_base", diff --git a/data/json/items/gun/22.json b/data/json/items/gun/22.json index 8dad295c9c71e..7e31cf8e6cf4d 100644 --- a/data/json/items/gun/22.json +++ b/data/json/items/gun/22.json @@ -36,7 +36,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "22", [ "a180mag" ] ] ] }, { @@ -76,7 +76,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_ONE" ] }, { @@ -109,7 +109,7 @@ [ "stock mount", 1 ], [ "underbarrel mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_ONE", "NEVER_JAMS", "RELOAD_EJECT" ] }, { @@ -147,7 +147,7 @@ [ "sights mount", 1 ], [ "underbarrel mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_EJECT" ] }, { @@ -184,7 +184,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "22", [ "360_200_mag", "360_400_mag" ] ] ], "flags": [ "WATERPROOF_GUN", "NEVER_JAMS" ] }, @@ -224,7 +224,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "22", [ "ruger1022mag", "ruger1022bigmag" ] ] ] }, @@ -272,7 +272,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "22", [ "mosquitomag" ] ] ] }, @@ -314,7 +314,7 @@ "dispersion": 600, "durability": 5, "min_cycle_recoil": 39, - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "22", [ "j22mag" ] ] ] }, { diff --git a/data/json/items/gun/223.json b/data/json/items/gun/223.json index 1902a783b2faf..3ba0c229f2964 100644 --- a/data/json/items/gun/223.json +++ b/data/json/items/gun/223.json @@ -353,7 +353,7 @@ [ "sights mount", 1 ], [ "underbarrel mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_EJECT" ] }, { diff --git a/data/json/items/gun/3006.json b/data/json/items/gun/3006.json index 8e94e7021f254..4680cdf2909dd 100644 --- a/data/json/items/gun/3006.json +++ b/data/json/items/gun/3006.json @@ -35,7 +35,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "magazine_well": 1, "magazines": [ [ "3006", [ "blrmag" ] ] ] }, @@ -72,7 +72,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "3006", [ "garandclip" ] ] ] }, @@ -147,7 +147,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "3006", [ "m1918mag", "m1918bigmag" ] ] ] }, { @@ -208,7 +208,7 @@ [ "sights mount", 1 ], [ "underbarrel mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_EJECT" ] }, { diff --git a/data/json/items/gun/308.json b/data/json/items/gun/308.json index 7b6fb57adcd96..d2e1a61019d52 100644 --- a/data/json/items/gun/308.json +++ b/data/json/items/gun/308.json @@ -70,7 +70,7 @@ "reload": 400, "valid_mod_locations": [ [ "brass catcher", 1 ], [ "sling", 1 ], [ "rail mount", 1 ], [ "sights mount", 1 ] ], "modes": [ [ "DEFAULT", "low auto", 50 ], [ "AUTO", "high auto", 100 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "magazines": [ [ "308", [ "belt308" ] ] ], "flags": [ "NEVER_JAMS", "MOUNTED_GUN" ] }, diff --git a/data/json/items/gun/32.json b/data/json/items/gun/32.json index 7f7f8ca02b450..60a45d4b4f255 100644 --- a/data/json/items/gun/32.json +++ b/data/json/items/gun/32.json @@ -32,7 +32,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "32", [ "sigp230mag" ] ] ] }, @@ -72,7 +72,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "32", [ "skorpion61mag" ] ] ] }, { @@ -108,7 +108,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "32", [ "ppkmag" ] ] ] }, diff --git a/data/json/items/gun/38.json b/data/json/items/gun/38.json index 781465e80a304..3e90d7224714a 100644 --- a/data/json/items/gun/38.json +++ b/data/json/items/gun/38.json @@ -30,7 +30,7 @@ [ "rail mount", 1 ], [ "stock mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_ONE", "RELOAD_EJECT" ] }, { @@ -62,7 +62,7 @@ [ "stock mount", 1 ], [ "underbarrel mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_ONE", "NEVER_JAMS", "RELOAD_EJECT" ] }, { @@ -99,7 +99,7 @@ [ "sights mount", 1 ], [ "underbarrel mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_EJECT" ] }, { @@ -202,7 +202,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "38", [ "taurus38mag" ] ] ] } diff --git a/data/json/items/gun/40.json b/data/json/items/gun/40.json index 0f60f2313ef75..38b9ea39926fb 100644 --- a/data/json/items/gun/40.json +++ b/data/json/items/gun/40.json @@ -34,7 +34,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "40", [ "glock40mag", "glock40bigmag" ] ] ] }, @@ -72,7 +72,7 @@ [ "sights mount", 1 ], [ "underbarrel mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_EJECT" ] }, { @@ -108,7 +108,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "40", [ "sig40mag" ] ] ] }, @@ -184,7 +184,7 @@ [ "underbarrel", 1 ], [ "rail mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_ONE", "NEVER_JAMS", "RELOAD_EJECT" ] }, { diff --git a/data/json/items/gun/44.json b/data/json/items/gun/44.json index a4c239f22ebc0..ade01e1e26322 100644 --- a/data/json/items/gun/44.json +++ b/data/json/items/gun/44.json @@ -33,7 +33,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "44", [ "deaglemag" ] ] ] }, @@ -106,7 +106,7 @@ [ "sights mount", 1 ], [ "underbarrel mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_EJECT" ] }, { diff --git a/data/json/items/gun/45.json b/data/json/items/gun/45.json index 2dcb39c36d378..efe45ffd50ba3 100644 --- a/data/json/items/gun/45.json +++ b/data/json/items/gun/45.json @@ -33,7 +33,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 2, "magazines": [ [ "45", [ "tdi_mag" ] ] ] }, @@ -72,7 +72,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "45", [ "ump45mag" ] ] ] }, { @@ -145,7 +145,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "45", [ "mac10mag" ] ] ] }, @@ -184,7 +184,7 @@ [ "sights mount", 1 ], [ "underbarrel mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_EJECT" ] }, { @@ -285,7 +285,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "45", [ "thompson_mag", "thompson_bigmag", "thompson_drum" ] ] ] }, { diff --git a/data/json/items/gun/46.json b/data/json/items/gun/46.json index b44e2145b0977..e10f0cbb196a2 100644 --- a/data/json/items/gun/46.json +++ b/data/json/items/gun/46.json @@ -33,7 +33,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "46", [ "hk46mag", "hk46bigmag" ] ] ] } diff --git a/data/json/items/gun/460.json b/data/json/items/gun/460.json index d100bb54ec71a..0714108e5c7b9 100644 --- a/data/json/items/gun/460.json +++ b/data/json/items/gun/460.json @@ -94,7 +94,7 @@ [ "rail mount", 1 ], [ "stock mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_ONE" ] } ] diff --git a/data/json/items/gun/57.json b/data/json/items/gun/57.json index 02e4655068908..dc9c8698600ce 100644 --- a/data/json/items/gun/57.json +++ b/data/json/items/gun/57.json @@ -32,7 +32,7 @@ [ "underbarrel", 1 ] ], "magazine_well": 1, - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "57", [ "fn57mag" ] ] ] }, { @@ -69,7 +69,7 @@ [ "underbarrel", 1 ] ], "magazine_well": 2, - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "57", [ "fnp90mag" ] ] ] } ] diff --git a/data/json/items/gun/762x25.json b/data/json/items/gun/762x25.json index aefaba094d9ab..5390e997bf5e0 100644 --- a/data/json/items/gun/762x25.json +++ b/data/json/items/gun/762x25.json @@ -35,7 +35,7 @@ [ "underbarrel", 1 ], [ "rail mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "762x25", [ "ppshmag", "ppshdrum" ] ] ] }, { diff --git a/data/json/items/gun/9mm.json b/data/json/items/gun/9mm.json index bd43e897144ab..542d29cd3ea68 100644 --- a/data/json/items/gun/9mm.json +++ b/data/json/items/gun/9mm.json @@ -36,7 +36,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "9mm", [ "calicomag" ] ] ] }, @@ -76,7 +76,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "9mm", [ "m9bigmag", "m9mag" ] ] ] }, @@ -139,7 +139,7 @@ [ "sling", 1 ], [ "stock", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "9mm", [ "mp5mag", "mp5bigmag" ] ] ] }, { @@ -271,7 +271,7 @@ [ "sights", 1 ], [ "sling", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "9mm", [ "glockmag", "glockbigmag", "glock17_17", "glock17_22", "glock_drum_50rd", "glock_drum_100rd" ] ] ] }, @@ -390,7 +390,7 @@ [ "sights mount", 1 ], [ "underbarrel mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "flags": [ "RELOAD_EJECT" ] }, { @@ -463,7 +463,7 @@ [ "sights mount", 1 ], [ "underbarrel mount", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazines": [ [ "9mm", [ "stenmag", "survivor9mm_mag" ] ] ] }, { @@ -501,7 +501,7 @@ [ "stock", 1 ], [ "underbarrel", 1 ] ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged", "fault_gun_chamber_spent" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt", "fault_gun_chamber_spent" ], "magazine_well": 1, "magazines": [ [ "9mm", [ "tec9mag" ] ] ] }, diff --git a/data/json/items/gun/faults_gun.json b/data/json/items/gun/faults_gun.json index a9a8c0a24bf07..dc0702a162798 100644 --- a/data/json/items/gun/faults_gun.json +++ b/data/json/items/gun/faults_gun.json @@ -4,7 +4,7 @@ "type": "fault", "name": "Blackpowder fouling", "description": "Firing blackpowder loads from a gun fouls it, which reduces reliability and, if left uncleaned, leads to rust.", - "time": "50 s", + "time": "50 m", "skills": [ [ "mechanics", 1 ] ], "requirements": { "qualities": [ { "id": "SCREW", "level": 1 } ], @@ -21,11 +21,11 @@ "requirements": { } }, { - "id": "fault_gun_clogged", + "id": "fault_gun_dirt", "type": "fault", - "name": "Clogging", - "description": "Clogging is usually caused by firing many blackpowder loads without cleaning; it prevents firing the gun until cleaned. Some guns are more resistant to this than others.", - "time": "5 m", + "name": "fouling", + "description": "Fouling is caused by firing gunpowder loads repeatedly, which reduces reliability and can eventually cause damage to the gun.", + "time": "50 m", "skills": [ [ "mechanics", 1 ] ], "requirements": { "qualities": [ { "id": "SCREW", "level": 1 } ], diff --git a/data/json/items/ranged.json b/data/json/items/ranged.json index 245ebc6b4de98..369fc707dba70 100644 --- a/data/json/items/ranged.json +++ b/data/json/items/ranged.json @@ -284,7 +284,7 @@ "loudness": 25, "barrel_length": 2, "built_in_mods": [ "combination_gun_shotgun_pipe" ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "valid_mod_locations": [ [ "muzzle", 1 ], [ "sling", 1 ], @@ -613,7 +613,7 @@ "loudness": 25, "barrel_length": 2, "built_in_mods": [ "combination_gun_shotgun" ], - "faults": [ "fault_gun_blackpowder", "fault_gun_clogged" ], + "faults": [ "fault_gun_blackpowder", "fault_gun_dirt" ], "valid_mod_locations": [ [ "accessories", 4 ], [ "barrel", 1 ], diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 6bde5c9d42a36..d71939e2d00ae 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -2498,6 +2498,9 @@ void activity_handlers::mend_item_finish( player_activity *act, player *p ) p->invalidate_crafting_inventory(); target->faults.erase( *f ); + if( act->name == "fault_gun_blackpowder" || act->name == "fault_gun_dirt" ) { + target->set_var( "dirt", 0 ); + } add_msg( m_good, _( "You successfully mended the %s." ), target->tname() ); } diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index e6a659ee0a572..7801f940d9541 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -61,8 +61,6 @@ static const efftype_id effect_stunned( "stunned" ); static const efftype_id effect_ridden( "ridden" ); static const efftype_id effect_harnessed( "harnessed" ); -static const fault_id fault_gun_clogged( "fault_gun_clogged" ); - bool avatar_action::move( avatar &you, map &m, int dx, int dy, int dz ) { if( ( !g->check_safe_mode_allowed() ) || you.has_active_mutation( trait_SHELL2 ) ) { @@ -634,11 +632,6 @@ bool avatar_action::fire_check( avatar &you, const map &m, const targeting_data return false; } - if( weapon.faults.count( fault_gun_clogged ) ) { - add_msg( m_info, _( "Your %s is too clogged with blackpowder fouling to fire." ), gun->tname() ); - return false; - } - if( gun->has_flag( "FIRE_TWOHAND" ) && ( !you.has_two_arms() || you.worn_with_flag( "RESTRICT_HANDS" ) ) ) { add_msg( m_info, _( "You need two free hands to fire your %s." ), gun->tname() ); diff --git a/src/item.cpp b/src/item.cpp index 003458e335519..6adfbee0fff08 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -114,6 +114,7 @@ const efftype_id effect_weed_high( "weed_high" ); const material_id mat_leather( "leather" ); const material_id mat_kevlar( "kevlar" ); +const fault_id fault_gun_dirt( "fault_gun_dirt" ); const fault_id fault_gun_blackpowder( "fault_gun_blackpowder" ); const trait_id trait_small2( "SMALL2" ); diff --git a/src/ranged.cpp b/src/ranged.cpp index 94d7a5a85ba0d..2589541b9543d 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -78,7 +78,7 @@ static const trait_id trait_PYROMANIA( "PYROMANIA" ); const trap_str_id tr_practice_target( "tr_practice_target" ); static const fault_id fault_gun_blackpowder( "fault_gun_blackpowder" ); -static const fault_id fault_gun_clogged( "fault_gun_clogged" ); +static const fault_id fault_gun_dirt( "fault_gun_dirt" ); static const fault_id fault_gun_chamber_spent( "fault_gun_chamber_spent" ); static projectile make_gun_projectile( const item &gun ); @@ -167,18 +167,30 @@ bool player::handle_gun_damage( item &it ) return false; } - if( it.faults.count( fault_gun_chamber_spent ) || it.faults.count( fault_gun_clogged ) ) { + int dirt = it.get_var( "dirt", 0 ); + int dirtreducer = 0; + int dirtadder = 0; + if( it.faults.count( fault_gun_chamber_spent ) ) { return false; } const auto &curammo_effects = it.ammo_effects(); const cata::optional &firing = it.type->gun; + if( !it.has_flag( "NEVER_JAMS" ) && + x_in_y( 1, ( ( 35000 - dirt ) / ( dirt + 1 ) ) ) ) { + add_msg_player_or_npc( _( "Your %s misfires with a muffled click!" ), + _( "'s %s misfires with a muffled click!" ), + it.tname() ); + return false; + } + // Here we check if we're underwater and whether we should misfire. // As a result this causes no damage to the firearm, note that some guns are waterproof // and so are immune to this effect, note also that WATERPROOF_GUN status does not // mean the gun will actually be accurate underwater. int effective_durability = firing->durability; - if( it.faults.count( fault_gun_blackpowder ) && effective_durability > 2 ) { + if( ( it.faults.count( fault_gun_dirt ) || it.faults.count( fault_gun_blackpowder ) ) && + effective_durability > 2 ) { effective_durability -= 1; } if( is_underwater() && !it.has_flag( "WATERPROOF_GUN" ) && one_in( effective_durability ) ) { @@ -189,24 +201,16 @@ bool player::handle_gun_damage( item &it ) // Here we check for a chance for the weapon to suffer a mechanical malfunction. // Note that some weapons never jam up 'NEVER_JAMS' and thus are immune to this // effect as current guns have a durability between 5 and 9 this results in - // a chance of mechanical failure between 1/64 and 1/1024 on any given shot. - // the malfunction may cause damage, but never enough to push the weapon beyond 'shattered' - } else if( ( one_in( 2 << effective_durability ) ) && !it.has_flag( "NEVER_JAMS" ) ) { + // a chance of mechanical failure between 1/(64*3) and 1/(1024*3) on any given shot. + // the malfunction can't cause damage + } else if( ( one_in( ( 2 << effective_durability ) * 3 ) ) && !it.has_flag( "NEVER_JAMS" ) ) { add_msg_player_or_npc( _( "Your %s malfunctions!" ), _( "'s %s malfunctions!" ), it.tname() ); - if( it.damage() < it.max_damage() && one_in( 4 * effective_durability ) ) { - add_msg_player_or_npc( m_bad, _( "Your %s is damaged by the mechanical malfunction!" ), - _( "'s %s is damaged by the mechanical malfunction!" ), - it.tname() ); - // Don't increment until after the message - it.inc_damage(); - } return false; // Here we check for a chance for the weapon to suffer a misfire due to // using OEM bullets. Note that these misfires cause no damage to the weapon and // some types of ammunition are immune to this effect via the NEVER_MISFIRES effect. - } else if( !curammo_effects.count( "NEVER_MISFIRES" ) && one_in( 1728 ) ) { add_msg_player_or_npc( _( "Your %s misfires with a dry click!" ), _( "'s %s misfires with a dry click!" ), it.tname() ); @@ -219,13 +223,6 @@ bool player::handle_gun_damage( item &it ) add_msg_player_or_npc( _( "Your %s misfires with a muffled click!" ), _( "'s %s misfires with a muffled click!" ), it.tname() ); - if( it.damage() < it.max_damage() && one_in( effective_durability ) ) { - add_msg_player_or_npc( m_bad, _( "Your %s is damaged by the misfired round!" ), - _( "'s %s is damaged by the misfired round!" ), - it.tname() ); - // Don't increment until after the message - it.inc_damage(); - } return false; // Here we check for a chance for attached mods to get damaged if they are flagged as 'CONSUMABLE'. // This is mostly for crappy handmade expedient stuff or things that rarely receive damage during normal usage. @@ -278,15 +275,38 @@ bool player::handle_gun_damage( item &it ) it.faults.insert( fault_gun_chamber_spent ); // Don't return false in this case; this shot happens, follow-up ones won't. } - if( one_in( firing->blackpowder_tolerance ) && - it.faults_potential().count( fault_gun_clogged ) ) { - add_msg_player_or_npc( m_bad, _( "Your %s is clogged up with blackpowder fouling!" ), - _( "'s %s is clogged up with blackpowder fouling!" ), - it.tname() ); - it.faults.insert( fault_gun_clogged ); - // Don't return false in this case; this shot happens, follow-up ones won't. + } + // These are the dirtying/fouling mechanics + if( it.has_flag( "NEVER_JAMS" ) ) { + int dirtreducer = 1; + } + if( dirt < 10000 ) { + dirtadder = curammo_effects.count( "BLACKPOWDER" ) * ( 200 - ( firing->blackpowder_tolerance * + 2 ) ); + if( dirtadder < 0 ) { + dirtadder = 0; + } + it.set_var( "dirt", ( dirt + dirtadder + 1 ) ); + if( dirt > 10000 ) { + it.set_var( "dirt", 10000 ); } } + if( dirt > 0 && !it.faults.count( fault_gun_blackpowder ) ) { + it.faults.insert( fault_gun_dirt ); + } + if( curammo_effects.count( "BLACKPOWDER" ) ) { + it.faults.erase( fault_gun_dirt ); + it.faults.insert( fault_gun_blackpowder ); + } + // end fouling mechanics + if( it.damage() < it.max_damage() && + dirt > 3000 && x_in_y( 1, ( ( 150000 - dirt ) / ( dirt + 1 ) ) ) ) { + add_msg_player_or_npc( m_bad, _( "Your %s is damaged by the high pressure!" ), + _( "'s %s is damaged by the high pressure!" ), + it.tname() ); + // Don't increment until after the message + it.inc_damage(); + } return true; } From 72fc290cce62e27f5a323c4280bfc9482102d72a Mon Sep 17 00:00:00 2001 From: misterprimus Date: Thu, 26 Sep 2019 03:56:39 -0400 Subject: [PATCH 03/38] Update ranged.cpp --- src/ranged.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index 2589541b9543d..060ef87bc7092 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -287,9 +287,10 @@ bool player::handle_gun_damage( item &it ) dirtadder = 0; } it.set_var( "dirt", ( dirt + dirtadder + 1 ) ); - if( dirt > 10000 ) { - it.set_var( "dirt", 10000 ); - } + } + if( dirt > 10000 ) { + it.set_var( "dirt", 10000 ); + } if( dirt > 0 && !it.faults.count( fault_gun_blackpowder ) ) { it.faults.insert( fault_gun_dirt ); From 68cecb0b4f13ef58eaf386c39301a224deebcc53 Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Thu, 26 Sep 2019 08:40:10 -0400 Subject: [PATCH 04/38] Update src/ranged.cpp Co-Authored-By: BevapDin --- src/ranged.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index 060ef87bc7092..309db1589a0f4 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -63,7 +63,7 @@ #include "type_id.h" #include "point.h" -const skill_id skill_throw( "throwx" ); +const skill_id skill_throw( "throw" ); const skill_id skill_gun( "gun" ); const skill_id skill_driving( "driving" ); const skill_id skill_dodge( "dodge" ); From 1bba8ebd84c88daf1ed8a8c4ac51f45d5fd95e12 Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Thu, 26 Sep 2019 08:41:31 -0400 Subject: [PATCH 05/38] Update ranged.cpp --- src/ranged.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index 309db1589a0f4..0fbad68694a08 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -168,7 +168,6 @@ bool player::handle_gun_damage( item &it ) } int dirt = it.get_var( "dirt", 0 ); - int dirtreducer = 0; int dirtadder = 0; if( it.faults.count( fault_gun_chamber_spent ) ) { return false; @@ -277,9 +276,6 @@ bool player::handle_gun_damage( item &it ) } } // These are the dirtying/fouling mechanics - if( it.has_flag( "NEVER_JAMS" ) ) { - int dirtreducer = 1; - } if( dirt < 10000 ) { dirtadder = curammo_effects.count( "BLACKPOWDER" ) * ( 200 - ( firing->blackpowder_tolerance * 2 ) ); From b20aa5f40b938a0c8d0128edc597973afc3b8607 Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Thu, 26 Sep 2019 10:59:47 -0400 Subject: [PATCH 06/38] Update data/json/items/gun/faults_gun.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Jianxiang Wang (王健翔) --- data/json/items/gun/faults_gun.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/items/gun/faults_gun.json b/data/json/items/gun/faults_gun.json index dc0702a162798..650ca3ace77e3 100644 --- a/data/json/items/gun/faults_gun.json +++ b/data/json/items/gun/faults_gun.json @@ -23,7 +23,7 @@ { "id": "fault_gun_dirt", "type": "fault", - "name": "fouling", + "name": "Fouling", "description": "Fouling is caused by firing gunpowder loads repeatedly, which reduces reliability and can eventually cause damage to the gun.", "time": "50 m", "skills": [ [ "mechanics", 1 ] ], From 4ad4ed2e38d0be2d41cdb3734a2a3c7cd08564c3 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Thu, 26 Sep 2019 20:42:07 -0400 Subject: [PATCH 07/38] adjust for old saves and fix integer/double conversion --- data/json/obsolete.json | 7 +++++++ src/ranged.cpp | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/data/json/obsolete.json b/data/json/obsolete.json index ef13b0a7997aa..da957c6b9909d 100644 --- a/data/json/obsolete.json +++ b/data/json/obsolete.json @@ -375,5 +375,12 @@ "symbol": ",", "color": "white", "use_action": "WASH_HARD_ITEMS" + }, + { + "id": "fault_gun_clogged", + "type": "fault", + "name": "Dusty", + "description": "It's dusty. Has no effect - obsolete fault.", + "time": "1 s" } ] diff --git a/src/ranged.cpp b/src/ranged.cpp index 0fbad68694a08..38e3d997d3906 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -167,8 +167,8 @@ bool player::handle_gun_damage( item &it ) return false; } - int dirt = it.get_var( "dirt", 0 ); - int dirtadder = 0; + double dirt = it.get_var( "dirt", 0 ); + double dirtadder = 0; if( it.faults.count( fault_gun_chamber_spent ) ) { return false; } @@ -176,7 +176,7 @@ bool player::handle_gun_damage( item &it ) const auto &curammo_effects = it.ammo_effects(); const cata::optional &firing = it.type->gun; if( !it.has_flag( "NEVER_JAMS" ) && - x_in_y( 1, ( ( 35000 - dirt ) / ( dirt + 1 ) ) ) ) { + x_in_y( 1.0, ( ( 35000.0 - dirt ) / ( dirt + 1.0 ) ) ) ) { add_msg_player_or_npc( _( "Your %s misfires with a muffled click!" ), _( "'s %s misfires with a muffled click!" ), it.tname() ); @@ -297,7 +297,7 @@ bool player::handle_gun_damage( item &it ) } // end fouling mechanics if( it.damage() < it.max_damage() && - dirt > 3000 && x_in_y( 1, ( ( 150000 - dirt ) / ( dirt + 1 ) ) ) ) { + dirt > 3000 && x_in_y( 1.0, ( ( 150000.0 - dirt ) / ( dirt + 1.0 ) ) ) ) { add_msg_player_or_npc( m_bad, _( "Your %s is damaged by the high pressure!" ), _( "'s %s is damaged by the high pressure!" ), it.tname() ); From 29d67b65c29e4c3406467994576723deed9bb553 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Thu, 26 Sep 2019 22:21:39 -0400 Subject: [PATCH 08/38] flintlock fixes and math adjustments --- data/json/items/ammo/flintlock.json | 4 ++-- data/json/items/gun/flintlock.json | 2 ++ src/ranged.cpp | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/data/json/items/ammo/flintlock.json b/data/json/items/ammo/flintlock.json index a39ee42632498..93e6293996b35 100644 --- a/data/json/items/ammo/flintlock.json +++ b/data/json/items/ammo/flintlock.json @@ -19,7 +19,7 @@ "dispersion": 90, "recoil": 1500, "loudness": 70, - "effects": [ "COOKOFF", "MUZZLE_SMOKE" ] + "effects": [ "COOKOFF", "MUZZLE_SMOKE", "BLACKPOWDER" ] }, { "id": "flintlock_shot", @@ -41,6 +41,6 @@ "dispersion": 20, "recoil": 1500, "loudness": 90, - "effects": [ "COOKOFF", "MUZZLE_SMOKE", "SHOT" ] + "effects": [ "COOKOFF", "MUZZLE_SMOKE", "SHOT", "BLACKPOWDER" ] } ] diff --git a/data/json/items/gun/flintlock.json b/data/json/items/gun/flintlock.json index 0b42d0d1992ba..8a8c2a8ed0295 100644 --- a/data/json/items/gun/flintlock.json +++ b/data/json/items/gun/flintlock.json @@ -48,6 +48,7 @@ "ranged_damage": 2, "dispersion": 620, "durability": 6, + "blackpowder_tolerance": 96, "clip_size": 1, "reload": 600, "valid_mod_locations": [ @@ -80,6 +81,7 @@ "ranged_damage": 10, "dispersion": 180, "durability": 6, + "blackpowder_tolerance": 96, "clip_size": 1, "reload": 1200, "valid_mod_locations": [ diff --git a/src/ranged.cpp b/src/ranged.cpp index 38e3d997d3906..56f04201c829b 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -176,7 +176,7 @@ bool player::handle_gun_damage( item &it ) const auto &curammo_effects = it.ammo_effects(); const cata::optional &firing = it.type->gun; if( !it.has_flag( "NEVER_JAMS" ) && - x_in_y( 1.0, ( ( 35000.0 - dirt ) / ( dirt + 1.0 ) ) ) ) { + x_in_y( ( dirt * dirt * dirt * dirt ), ( ( dirt * 1000000000000 ) + 1 ) ) ) { add_msg_player_or_npc( _( "Your %s misfires with a muffled click!" ), _( "'s %s misfires with a muffled click!" ), it.tname() ); @@ -296,8 +296,7 @@ bool player::handle_gun_damage( item &it ) it.faults.insert( fault_gun_blackpowder ); } // end fouling mechanics - if( it.damage() < it.max_damage() && - dirt > 3000 && x_in_y( 1.0, ( ( 150000.0 - dirt ) / ( dirt + 1.0 ) ) ) ) { + if( dirt > 5000 && x_in_y( ( dirt * dirt * dirt * dirt ), ( ( dirt * 5555555555555 ) + 1 ) ) ) { add_msg_player_or_npc( m_bad, _( "Your %s is damaged by the high pressure!" ), _( "'s %s is damaged by the high pressure!" ), it.tname() ); From 4b64df4d284249122230f6864654d737e83b8aae Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 00:54:36 -0400 Subject: [PATCH 09/38] finishing touches - fixed some bp shells not having bp tag. - removed redundant code from ranged.cpp - made the fouling malfunctions more "silent." - zed guns now spawn dirty as well as damaged. --- data/json/items/ammo/shot.json | 10 ++++----- data/json/monsterdrops/zombie_cop.json | 2 +- src/item.cpp | 31 +++++++++++++++++++++++++- src/item_factory.cpp | 1 + src/item_group.cpp | 6 +++++ src/item_group.h | 1 + src/ranged.cpp | 6 +---- 7 files changed, 45 insertions(+), 12 deletions(-) diff --git a/data/json/items/ammo/shot.json b/data/json/items/ammo/shot.json index 59ed21ea86d93..4e1d1cc3fc359 100644 --- a/data/json/items/ammo/shot.json +++ b/data/json/items/ammo/shot.json @@ -50,7 +50,7 @@ "type": "AMMO", "name": "blackpowder birdshot", "proportional": { "price": 0.6, "damage": 0.8, "dispersion": 1.2 }, - "extend": { "effects": [ "RECYCLED", "MUZZLE_SMOKE" ] }, + "extend": { "effects": [ "RECYCLED", "MUZZLE_SMOKE", "BLACKPOWDER" ] }, "delete": { "effects": [ "NEVER_MISFIRES" ] } }, { @@ -59,7 +59,7 @@ "type": "AMMO", "name": "blackpowder dragon's breath shell", "proportional": { "price": 0.6, "damage": 0.8, "dispersion": 1.2 }, - "extend": { "effects": [ "RECYCLED", "MUZZLE_SMOKE" ] }, + "extend": { "effects": [ "RECYCLED", "MUZZLE_SMOKE", "BLACKPOWDER" ] }, "delete": { "effects": [ "NEVER_MISFIRES" ] } }, { @@ -67,7 +67,7 @@ "copy-from": "shot_00", "type": "AMMO", "name": "blackpowder 00 shot", - "extend": { "effects": [ "RECYCLED", "MUZZLE_SMOKE" ] }, + "extend": { "effects": [ "RECYCLED", "MUZZLE_SMOKE", "BLACKPOWDER" ] }, "delete": { "effects": [ "NEVER_MISFIRES" ] } }, { @@ -76,7 +76,7 @@ "type": "AMMO", "name": "blackpowder flechette shell", "proportional": { "price": 0.6, "damage": 0.8, "dispersion": 1.2 }, - "extend": { "effects": [ "RECYCLED", "MUZZLE_SMOKE" ] }, + "extend": { "effects": [ "RECYCLED", "MUZZLE_SMOKE", "BLACKPOWDER" ] }, "delete": { "effects": [ "NEVER_MISFIRES" ] } }, { @@ -85,7 +85,7 @@ "type": "AMMO", "name": "blackpowder shotgun slug", "proportional": { "price": 0.6, "damage": 0.8, "dispersion": 1.2 }, - "extend": { "effects": [ "RECYCLED", "MUZZLE_SMOKE" ] }, + "extend": { "effects": [ "RECYCLED", "MUZZLE_SMOKE", "BLACKPOWDER" ] }, "delete": { "effects": [ "NEVER_MISFIRES" ] } }, { diff --git a/data/json/monsterdrops/zombie_cop.json b/data/json/monsterdrops/zombie_cop.json index 19bd98445ce59..f218af802abe5 100644 --- a/data/json/monsterdrops/zombie_cop.json +++ b/data/json/monsterdrops/zombie_cop.json @@ -12,7 +12,7 @@ { "group": "cop_pants", "damage": [ 1, 4 ] }, { "group": "cop_shoes", "damage": [ 1, 4 ] }, { "group": "cop_torso", "damage": [ 1, 4 ] }, - { "group": "cop_weapons", "prob": 50, "damage": [ 0, 1 ] }, + { "group": "cop_weapons", "prob": 50, "damage": [ 0, 1 ], "dirt": [ 1500, 6000] }, { "group": "underwear", "damage": [ 1, 4 ] }, { "group": "clothing_glasses", "prob": 5 }, { "group": "clothing_watch", "prob": 5 }, diff --git a/src/item.cpp b/src/item.cpp index 6adfbee0fff08..a88eb1b0ee989 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -3374,7 +3374,31 @@ std::string item::tname( unsigned int quantity, bool with_prefix, unsigned int t { std::stringstream ret; + int dirt_level = static_cast( get_var( "dirt", 0 ) / 2000 ); + std::string dirt_symbol; // TODO: MATERIALS put this in json + switch( dirt_level ) { + case 0: + dirt_symbol = ""; + break; + case 1: + dirt_symbol = "\u2581"; + break; + case 2: + dirt_symbol = "\u2583"; + break; + case 3: + dirt_symbol = "\u2585"; + break; + case 4: + dirt_symbol = "\u2587"; + break; + case 5: + dirt_symbol = "\u2588"; + break; + default: + dirt_symbol = ""; + } std::string damtext; // for portions of string that have 0 ) { + new_item.set_var( "dirt", random_dirt ); + new_item.faults.emplace( "fault_gun_dirt" ); + } int ch = ( charges.first == charges.second ) ? charges.first : rng( charges.first, charges.second ); diff --git a/src/item_group.h b/src/item_group.h index 9c7f6c676303f..c2be082a8706d 100644 --- a/src/item_group.h +++ b/src/item_group.h @@ -155,6 +155,7 @@ class Item_modifier * Charges to spawn the item with, if this turns out to * be negative, the default charges are used. */ + std::pair dirt; std::pair charges; /** * Ammo for guns. If NULL the gun spawns without ammo. diff --git a/src/ranged.cpp b/src/ranged.cpp index 56f04201c829b..49b02a267fb00 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -262,10 +262,6 @@ bool player::handle_gun_damage( item &it ) } } if( curammo_effects.count( "BLACKPOWDER" ) ) { - if( !it.faults.count( fault_gun_blackpowder ) && - it.faults_potential().count( fault_gun_blackpowder ) ) { - it.faults.insert( fault_gun_blackpowder ); - } if( ( it.ammo_data()->ammo->recoil < firing->min_cycle_recoil ) && it.faults_potential().count( fault_gun_chamber_spent ) ) { add_msg_player_or_npc( m_bad, _( "Your %s fails to cycle!" ), @@ -288,7 +284,7 @@ bool player::handle_gun_damage( item &it ) it.set_var( "dirt", 10000 ); } - if( dirt > 0 && !it.faults.count( fault_gun_blackpowder ) ) { + if( dirt > -1 && !it.faults.count( fault_gun_blackpowder ) ) { it.faults.insert( fault_gun_dirt ); } if( curammo_effects.count( "BLACKPOWDER" ) ) { From 65ccb9aeddb998d00617110282e5dc48ad077804 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 01:03:32 -0400 Subject: [PATCH 10/38] Update zombie_cop.json --- data/json/monsterdrops/zombie_cop.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/monsterdrops/zombie_cop.json b/data/json/monsterdrops/zombie_cop.json index f218af802abe5..354bffdec1b22 100644 --- a/data/json/monsterdrops/zombie_cop.json +++ b/data/json/monsterdrops/zombie_cop.json @@ -12,7 +12,7 @@ { "group": "cop_pants", "damage": [ 1, 4 ] }, { "group": "cop_shoes", "damage": [ 1, 4 ] }, { "group": "cop_torso", "damage": [ 1, 4 ] }, - { "group": "cop_weapons", "prob": 50, "damage": [ 0, 1 ], "dirt": [ 1500, 6000] }, + { "group": "cop_weapons", "prob": 50, "damage": [ 0, 1 ], "dirt": [ 1500, 6000 ] }, { "group": "underwear", "damage": [ 1, 4 ] }, { "group": "clothing_glasses", "prob": 5 }, { "group": "clothing_watch", "prob": 5 }, From 1a7a109637c48dc0221da14d1986e1765f5b620d Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 01:20:37 -0400 Subject: [PATCH 11/38] Update zombie_cop.json --- data/json/monsterdrops/zombie_cop.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/monsterdrops/zombie_cop.json b/data/json/monsterdrops/zombie_cop.json index 354bffdec1b22..efb0207ab8e06 100644 --- a/data/json/monsterdrops/zombie_cop.json +++ b/data/json/monsterdrops/zombie_cop.json @@ -12,7 +12,7 @@ { "group": "cop_pants", "damage": [ 1, 4 ] }, { "group": "cop_shoes", "damage": [ 1, 4 ] }, { "group": "cop_torso", "damage": [ 1, 4 ] }, - { "group": "cop_weapons", "prob": 50, "damage": [ 0, 1 ], "dirt": [ 1500, 6000 ] }, + { "group": "cop_weapons", "prob": 50, "damage": [ 0, 1 ], "dirt": [ 1500, 7000 ] }, { "group": "underwear", "damage": [ 1, 4 ] }, { "group": "clothing_glasses", "prob": 5 }, { "group": "clothing_watch", "prob": 5 }, From 532cbed59d135af094899cd2be3787e4f6ad4e1b Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 01:41:07 -0400 Subject: [PATCH 12/38] qrox --- src/item.cpp | 7 +++++-- src/ranged.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/item.cpp b/src/item.cpp index a88eb1b0ee989..56cc39d763539 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -3377,6 +3377,9 @@ std::string item::tname( unsigned int quantity, bool with_prefix, unsigned int t int dirt_level = static_cast( get_var( "dirt", 0 ) / 2000 ); std::string dirt_symbol; // TODO: MATERIALS put this in json + + // these symbols are a rough estimation of fouling in a gun. This appears instead of "faulty" + // since most guns will have some level of fouling in them, and usually it is not a big deal. switch( dirt_level ) { case 0: dirt_symbol = ""; @@ -3414,9 +3417,9 @@ std::string item::tname( unsigned int quantity, bool with_prefix, unsigned int t if( !faults.empty() ) { if( ( item::has_fault( fault_gun_blackpowder ) || item::has_fault( fault_gun_dirt ) ) && faults.size() == 1 ) { - damtext.insert( 0, _( dirt_symbol ) ); + damtext.insert( 0, dirt_symbol ); } else { - damtext.insert( 0, _( "faulty " + dirt_symbol ) ); + damtext.insert( 0, _( "faulty " ) + dirt_symbol ); } } diff --git a/src/ranged.cpp b/src/ranged.cpp index 49b02a267fb00..ab1e47033aa8b 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -284,7 +284,7 @@ bool player::handle_gun_damage( item &it ) it.set_var( "dirt", 10000 ); } - if( dirt > -1 && !it.faults.count( fault_gun_blackpowder ) ) { + if( dirt >= 0 && !it.faults.count( fault_gun_blackpowder ) ) { it.faults.insert( fault_gun_dirt ); } if( curammo_effects.count( "BLACKPOWDER" ) ) { From 2b694ec29ed9028160222ee342f7d52307670e5b Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 01:51:06 -0400 Subject: [PATCH 13/38] Update item_group.h --- src/item_group.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item_group.h b/src/item_group.h index c2be082a8706d..bdec52908e419 100644 --- a/src/item_group.h +++ b/src/item_group.h @@ -155,7 +155,7 @@ class Item_modifier * Charges to spawn the item with, if this turns out to * be negative, the default charges are used. */ - std::pair dirt; + std::pair dirt; std::pair charges; /** * Ammo for guns. If NULL the gun spawns without ammo. From 815a76f8deb2699838b319c20637ddf35704a854 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 02:34:12 -0400 Subject: [PATCH 14/38] Update item_group.cpp --- src/item_group.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item_group.cpp b/src/item_group.cpp index cf3f7fd6b1356..cdeeb84d70e85 100644 --- a/src/item_group.cpp +++ b/src/item_group.cpp @@ -208,7 +208,7 @@ void Item_modifier::modify( item &new_item ) const return; } - new_item.set_damage( rng( damage.first, damage.second ) ); + new_item.set_damage( rng( static_cast( damage.first ), static_cast( damage.second ) ) ); double random_dirt = rng( dirt.first, dirt.second ); if( new_item.is_gun() && random_dirt > 0 ) { new_item.set_var( "dirt", random_dirt ); From 7229517fbc39415fe0857883ebef5bc58f34ac63 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 02:35:19 -0400 Subject: [PATCH 15/38] Update item_group.cpp --- src/item_group.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/item_group.cpp b/src/item_group.cpp index cdeeb84d70e85..d15ca40ca1a0a 100644 --- a/src/item_group.cpp +++ b/src/item_group.cpp @@ -208,8 +208,9 @@ void Item_modifier::modify( item &new_item ) const return; } - new_item.set_damage( rng( static_cast( damage.first ), static_cast( damage.second ) ) ); - double random_dirt = rng( dirt.first, dirt.second ); + new_item.set_damage( rng( damage.first, damage.second ) ); + double random_dirt = static_cast( rng( static_cast( dirt.first ), + static_cast( dirt.second ) ) ); if( new_item.is_gun() && random_dirt > 0 ) { new_item.set_var( "dirt", random_dirt ); new_item.faults.emplace( "fault_gun_dirt" ); From 60cf1424754791fffa8b00edb6b6702521c750d2 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 02:44:57 -0400 Subject: [PATCH 16/38] Update ranged.cpp --- src/ranged.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index ab1e47033aa8b..4ced8af2dc8d9 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -263,7 +263,7 @@ bool player::handle_gun_damage( item &it ) } if( curammo_effects.count( "BLACKPOWDER" ) ) { if( ( it.ammo_data()->ammo->recoil < firing->min_cycle_recoil ) && - it.faults_potential().count( fault_gun_chamber_spent ) ) { + it.faults_potential().count( fault_gun_chamber_spent ) && ( it.type->gun->ups_charges < 1 ) ) { add_msg_player_or_npc( m_bad, _( "Your %s fails to cycle!" ), _( "'s %s fails to cycle!" ), it.tname() ); From 6688fe64917e1f9a2a99d13802bd3b455320e9b1 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 03:07:06 -0400 Subject: [PATCH 17/38] Update item.cpp --- src/item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item.cpp b/src/item.cpp index 56cc39d763539..f15e2c764ed6d 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -3374,7 +3374,7 @@ std::string item::tname( unsigned int quantity, bool with_prefix, unsigned int t { std::stringstream ret; - int dirt_level = static_cast( get_var( "dirt", 0 ) / 2000 ); + int dirt_level = static_cast( get_var( "dirt", 0 ) / 2000 ); std::string dirt_symbol; // TODO: MATERIALS put this in json From 019284e3c8fad5ecc854fda0ca1ff0f5c906f353 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 03:17:16 -0400 Subject: [PATCH 18/38] fix errors --- src/item_group.cpp | 3 +-- src/ranged.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/item_group.cpp b/src/item_group.cpp index d15ca40ca1a0a..685a2d1ad4399 100644 --- a/src/item_group.cpp +++ b/src/item_group.cpp @@ -209,8 +209,7 @@ void Item_modifier::modify( item &new_item ) const } new_item.set_damage( rng( damage.first, damage.second ) ); - double random_dirt = static_cast( rng( static_cast( dirt.first ), - static_cast( dirt.second ) ) ); + int random_dirt = rng( dirt.first, dirt.second ); if( new_item.is_gun() && random_dirt > 0 ) { new_item.set_var( "dirt", random_dirt ); new_item.faults.emplace( "fault_gun_dirt" ); diff --git a/src/ranged.cpp b/src/ranged.cpp index 4ced8af2dc8d9..fb1a22f2bf66a 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -167,8 +167,9 @@ bool player::handle_gun_damage( item &it ) return false; } - double dirt = it.get_var( "dirt", 0 ); - double dirtadder = 0; + int dirt = it.get_var( "dirt", 0 ); + int dirtadder = 0; + double dirt_dbl = static_cast( dirt ); if( it.faults.count( fault_gun_chamber_spent ) ) { return false; } @@ -176,7 +177,7 @@ bool player::handle_gun_damage( item &it ) const auto &curammo_effects = it.ammo_effects(); const cata::optional &firing = it.type->gun; if( !it.has_flag( "NEVER_JAMS" ) && - x_in_y( ( dirt * dirt * dirt * dirt ), ( ( dirt * 1000000000000 ) + 1 ) ) ) { + x_in_y( ( dirt_dbl * dirt_dbl * dirt_dbl * dirt_dbl ), ( ( dirt_dbl * 1000000000000 ) + 1 ) ) ) { add_msg_player_or_npc( _( "Your %s misfires with a muffled click!" ), _( "'s %s misfires with a muffled click!" ), it.tname() ); @@ -292,7 +293,8 @@ bool player::handle_gun_damage( item &it ) it.faults.insert( fault_gun_blackpowder ); } // end fouling mechanics - if( dirt > 5000 && x_in_y( ( dirt * dirt * dirt * dirt ), ( ( dirt * 5555555555555 ) + 1 ) ) ) { + if( dirt_dbl > 5000 && + x_in_y( ( dirt_dbl * dirt_dbl * dirt_dbl * dirt_dbl ), ( ( dirt_dbl * 5555555555555 ) + 1 ) ) ) { add_msg_player_or_npc( m_bad, _( "Your %s is damaged by the high pressure!" ), _( "'s %s is damaged by the high pressure!" ), it.tname() ); From 2c0397e7c62bea36e2bd0f939c3c7c04a85c5758 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 03:32:23 -0400 Subject: [PATCH 19/38] Update item_group.cpp --- src/item_group.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item_group.cpp b/src/item_group.cpp index 685a2d1ad4399..c2f70f064a11c 100644 --- a/src/item_group.cpp +++ b/src/item_group.cpp @@ -194,10 +194,10 @@ void Single_item_creator::inherit_ammo_mag_chances( const int ammo, const int ma Item_modifier::Item_modifier() : damage( 0, 0 ) , count( 1, 1 ) + , dirt( 100, 9999 ) , charges( -1, -1 ) , with_ammo( 0 ) , with_magazine( 0 ) - , dirt( 100, 9999 ) { } From 2fb20391860615fe993de50d1671e0380d812361 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 10:31:48 -0400 Subject: [PATCH 20/38] Update ranged.cpp --- src/ranged.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index fb1a22f2bf66a..f8e4de6498a33 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -209,13 +209,6 @@ bool player::handle_gun_damage( item &it ) it.tname() ); return false; // Here we check for a chance for the weapon to suffer a misfire due to - // using OEM bullets. Note that these misfires cause no damage to the weapon and - // some types of ammunition are immune to this effect via the NEVER_MISFIRES effect. - add_msg_player_or_npc( _( "Your %s misfires with a dry click!" ), - _( "'s %s misfires with a dry click!" ), - it.tname() ); - return false; - // Here we check for a chance for the weapon to suffer a misfire due to // using player-made 'RECYCLED' bullets. Note that not all forms of // player-made ammunition have this effect the misfire may cause damage, but never // enough to push the weapon beyond 'shattered'. From 79cc95597caa753026e696a9bd5483266330d99f Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 10:40:35 -0400 Subject: [PATCH 21/38] Update ranged.cpp --- src/ranged.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index f8e4de6498a33..9bfc5ac7a89fc 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -177,7 +177,7 @@ bool player::handle_gun_damage( item &it ) const auto &curammo_effects = it.ammo_effects(); const cata::optional &firing = it.type->gun; if( !it.has_flag( "NEVER_JAMS" ) && - x_in_y( ( dirt_dbl * dirt_dbl * dirt_dbl * dirt_dbl ), ( ( dirt_dbl * 1000000000000 ) + 1 ) ) ) { + x_in_y( dirt_dbl * dirt_dbl * dirt_dbl, 1000000000000.0 ) ) { add_msg_player_or_npc( _( "Your %s misfires with a muffled click!" ), _( "'s %s misfires with a muffled click!" ), it.tname() ); @@ -287,7 +287,7 @@ bool player::handle_gun_damage( item &it ) } // end fouling mechanics if( dirt_dbl > 5000 && - x_in_y( ( dirt_dbl * dirt_dbl * dirt_dbl * dirt_dbl ), ( ( dirt_dbl * 5555555555555 ) + 1 ) ) ) { + x_in_y( dirt_dbl * dirt_dbl * dirt_dbl, 5555555555555 ) ) { add_msg_player_or_npc( m_bad, _( "Your %s is damaged by the high pressure!" ), _( "'s %s is damaged by the high pressure!" ), it.tname() ); From 4f72d8a95ad558e857bb29861581025e8296717a Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Sat, 28 Sep 2019 10:42:02 -0400 Subject: [PATCH 22/38] Update src/item_group.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Jianxiang Wang (王健翔) --- src/item_group.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item_group.h b/src/item_group.h index bdec52908e419..c2be082a8706d 100644 --- a/src/item_group.h +++ b/src/item_group.h @@ -155,7 +155,7 @@ class Item_modifier * Charges to spawn the item with, if this turns out to * be negative, the default charges are used. */ - std::pair dirt; + std::pair dirt; std::pair charges; /** * Ammo for guns. If NULL the gun spawns without ammo. From 9c82c8584cee72539763b457deec9fa620cdad75 Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Sat, 28 Sep 2019 10:42:49 -0400 Subject: [PATCH 23/38] Update src/ranged.cpp Co-Authored-By: BevapDin --- src/ranged.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index 9bfc5ac7a89fc..e4fd528308d04 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -272,7 +272,7 @@ bool player::handle_gun_damage( item &it ) if( dirtadder < 0 ) { dirtadder = 0; } - it.set_var( "dirt", ( dirt + dirtadder + 1 ) ); + it.set_var( "dirt", dirt + dirtadder + 1 ); } if( dirt > 10000 ) { it.set_var( "dirt", 10000 ); From 2f2ac886b65e916c0f8de514d6037c23f8c64092 Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Sat, 28 Sep 2019 10:43:08 -0400 Subject: [PATCH 24/38] Update src/item.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Jianxiang Wang (王健翔) --- src/item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item.cpp b/src/item.cpp index f15e2c764ed6d..00c0fdab3137a 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -3374,7 +3374,7 @@ std::string item::tname( unsigned int quantity, bool with_prefix, unsigned int t { std::stringstream ret; - int dirt_level = static_cast( get_var( "dirt", 0 ) / 2000 ); + int dirt_level = get_var( "dirt", 0 ) / 2000; std::string dirt_symbol; // TODO: MATERIALS put this in json From f55fa052802b50895f41acf01e1586d8a6806389 Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Sat, 28 Sep 2019 10:43:26 -0400 Subject: [PATCH 25/38] Update src/item.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Jianxiang Wang (王健翔) --- src/item.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/item.cpp b/src/item.cpp index 00c0fdab3137a..7c8c9ed9c8235 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -3378,7 +3378,8 @@ std::string item::tname( unsigned int quantity, bool with_prefix, unsigned int t std::string dirt_symbol; // TODO: MATERIALS put this in json - // these symbols are a rough estimation of fouling in a gun. This appears instead of "faulty" + // these symbols are unicode square characeters of different heights, representing a rough + // estimation of fouling in a gun. This appears instead of "faulty" // since most guns will have some level of fouling in them, and usually it is not a big deal. switch( dirt_level ) { case 0: From dc5c43cdb1f20631033abfad8d23c938fbbcd5ef Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 11:01:44 -0400 Subject: [PATCH 26/38] Update faults_gun.json --- data/json/items/gun/faults_gun.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/items/gun/faults_gun.json b/data/json/items/gun/faults_gun.json index 650ca3ace77e3..e8ca62649d7b6 100644 --- a/data/json/items/gun/faults_gun.json +++ b/data/json/items/gun/faults_gun.json @@ -24,7 +24,7 @@ "id": "fault_gun_dirt", "type": "fault", "name": "Fouling", - "description": "Fouling is caused by firing gunpowder loads repeatedly, which reduces reliability and can eventually cause damage to the gun.", + "description": "Fouling is caused by firing gunpowder loads repeatedly, which reduces reliability and can eventually cause damage to the gun. Fouling accumulates slowly (unless blackpowder is used) due to the design of modern smokeless powder found in the vast majority of retail cartridges and it is not a significant problem until high levels of fouling are reached due to firing thousands of rounds without cleaning your firearm.", "time": "50 m", "skills": [ [ "mechanics", 1 ] ], "requirements": { From 066152d431f4735110ce3e83c10025f14fa647e1 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 11:03:48 -0400 Subject: [PATCH 27/38] Update faults_gun.json --- data/json/items/gun/faults_gun.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/items/gun/faults_gun.json b/data/json/items/gun/faults_gun.json index e8ca62649d7b6..4c483f4cfb25d 100644 --- a/data/json/items/gun/faults_gun.json +++ b/data/json/items/gun/faults_gun.json @@ -3,7 +3,7 @@ "id": "fault_gun_blackpowder", "type": "fault", "name": "Blackpowder fouling", - "description": "Firing blackpowder loads from a gun fouls it, which reduces reliability and, if left uncleaned, leads to rust.", + "description": "Firing blackpowder loads from a gun fouls it, which reduces reliability and, if left uncleaned, leads to rust. It fouls the gun much faster than the use of modern smokeless powder cartridges. Fouling is only a significant impact on reliability at high levels, but black powder fouling accumulates quickly.", "time": "50 m", "skills": [ [ "mechanics", 1 ] ], "requirements": { From 313fece3f35f0bb77b5a650fed183244ce67c96e Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 11:07:13 -0400 Subject: [PATCH 28/38] Update ranged.cpp --- src/ranged.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index e4fd528308d04..4875453236291 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -189,10 +189,6 @@ bool player::handle_gun_damage( item &it ) // and so are immune to this effect, note also that WATERPROOF_GUN status does not // mean the gun will actually be accurate underwater. int effective_durability = firing->durability; - if( ( it.faults.count( fault_gun_dirt ) || it.faults.count( fault_gun_blackpowder ) ) && - effective_durability > 2 ) { - effective_durability -= 1; - } if( is_underwater() && !it.has_flag( "WATERPROOF_GUN" ) && one_in( effective_durability ) ) { add_msg_player_or_npc( _( "Your %s misfires with a wet click!" ), _( "'s %s misfires with a wet click!" ), From 4a4f9c400b6a9e1e1cfa55e9a81bb2a06b703b6d Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 11:09:39 -0400 Subject: [PATCH 29/38] Update ranged.cpp --- src/ranged.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index 4875453236291..d6ee3b418420d 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -268,11 +268,7 @@ bool player::handle_gun_damage( item &it ) if( dirtadder < 0 ) { dirtadder = 0; } - it.set_var( "dirt", dirt + dirtadder + 1 ); - } - if( dirt > 10000 ) { - it.set_var( "dirt", 10000 ); - + it.set_var( "dirt", std::min( 10000, dirt + dirtadder + 1 ) ); } if( dirt >= 0 && !it.faults.count( fault_gun_blackpowder ) ) { it.faults.insert( fault_gun_dirt ); From 1ca0e49e003d48a90e7c4668bbc17f1cc8e4553f Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Sat, 28 Sep 2019 11:17:16 -0400 Subject: [PATCH 30/38] Update src/ranged.cpp Co-Authored-By: BevapDin --- src/ranged.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index d6ee3b418420d..f78de9bc4800d 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -199,7 +199,7 @@ bool player::handle_gun_damage( item &it ) // effect as current guns have a durability between 5 and 9 this results in // a chance of mechanical failure between 1/(64*3) and 1/(1024*3) on any given shot. // the malfunction can't cause damage - } else if( ( one_in( ( 2 << effective_durability ) * 3 ) ) && !it.has_flag( "NEVER_JAMS" ) ) { + } else if( one_in( ( 2 << effective_durability ) * 3 ) && !it.has_flag( "NEVER_JAMS" ) ) { add_msg_player_or_npc( _( "Your %s malfunctions!" ), _( "'s %s malfunctions!" ), it.tname() ); From 520b4594a213e6800747935545ba2b4ac9aa204f Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 11:19:16 -0400 Subject: [PATCH 31/38] Update ranged.cpp --- src/ranged.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index f78de9bc4800d..0d10f5ddeb6c3 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -206,8 +206,7 @@ bool player::handle_gun_damage( item &it ) return false; // Here we check for a chance for the weapon to suffer a misfire due to // using player-made 'RECYCLED' bullets. Note that not all forms of - // player-made ammunition have this effect the misfire may cause damage, but never - // enough to push the weapon beyond 'shattered'. + // player-made ammunition have this effect. } else if( curammo_effects.count( "RECYCLED" ) && one_in( 256 ) ) { add_msg_player_or_npc( _( "Your %s misfires with a muffled click!" ), _( "'s %s misfires with a muffled click!" ), From 6614a3279952dbf2e298aa285edd4b48f7f15f31 Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Sat, 28 Sep 2019 11:23:50 -0400 Subject: [PATCH 32/38] Update src/ranged.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Jianxiang Wang (王健翔) --- src/ranged.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index 0d10f5ddeb6c3..509a2396224d1 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -269,7 +269,9 @@ bool player::handle_gun_damage( item &it ) } it.set_var( "dirt", std::min( 10000, dirt + dirtadder + 1 ) ); } - if( dirt >= 0 && !it.faults.count( fault_gun_blackpowder ) ) { + dirt = it.get_var( "dirt", 0 ); + dirt_dbl = static_cast( dirt ); + if( dirt > 0 && !it.faults.count( fault_gun_blackpowder ) ) { it.faults.insert( fault_gun_dirt ); } if( curammo_effects.count( "BLACKPOWDER" ) ) { From a1ff163b840c81b31c8183e2bde2092cd40a86fa Mon Sep 17 00:00:00 2001 From: misterprimus <45959491+misterprimus@users.noreply.github.com> Date: Sat, 28 Sep 2019 11:24:43 -0400 Subject: [PATCH 33/38] Update src/ranged.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Jianxiang Wang (王健翔) --- src/ranged.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ranged.cpp b/src/ranged.cpp index 509a2396224d1..f1f1918a4d9d1 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -274,7 +274,7 @@ bool player::handle_gun_damage( item &it ) if( dirt > 0 && !it.faults.count( fault_gun_blackpowder ) ) { it.faults.insert( fault_gun_dirt ); } - if( curammo_effects.count( "BLACKPOWDER" ) ) { + if( dirt > 0 && curammo_effects.count( "BLACKPOWDER" ) ) { it.faults.erase( fault_gun_dirt ); it.faults.insert( fault_gun_blackpowder ); } From 1d6a2b9320528b17ef225efd49be65cff4c54a70 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 14:06:20 -0400 Subject: [PATCH 34/38] Update zombie_cop.json --- data/json/monsterdrops/zombie_cop.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/monsterdrops/zombie_cop.json b/data/json/monsterdrops/zombie_cop.json index efb0207ab8e06..c11e4d966c046 100644 --- a/data/json/monsterdrops/zombie_cop.json +++ b/data/json/monsterdrops/zombie_cop.json @@ -12,7 +12,7 @@ { "group": "cop_pants", "damage": [ 1, 4 ] }, { "group": "cop_shoes", "damage": [ 1, 4 ] }, { "group": "cop_torso", "damage": [ 1, 4 ] }, - { "group": "cop_weapons", "prob": 50, "damage": [ 0, 1 ], "dirt": [ 1500, 7000 ] }, + { "group": "cop_weapons", "prob": 50, "damage": [ 0, 1 ], "dirt": [ 1500, 7100 ] }, { "group": "underwear", "damage": [ 1, 4 ] }, { "group": "clothing_glasses", "prob": 5 }, { "group": "clothing_watch", "prob": 5 }, From 247b48ff047f4c313b627f624d91da155bb0b148 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sat, 28 Sep 2019 16:49:19 -0400 Subject: [PATCH 35/38] Update zombie_cop.json --- data/json/monsterdrops/zombie_cop.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/monsterdrops/zombie_cop.json b/data/json/monsterdrops/zombie_cop.json index c11e4d966c046..2ace5aae10dfb 100644 --- a/data/json/monsterdrops/zombie_cop.json +++ b/data/json/monsterdrops/zombie_cop.json @@ -12,7 +12,7 @@ { "group": "cop_pants", "damage": [ 1, 4 ] }, { "group": "cop_shoes", "damage": [ 1, 4 ] }, { "group": "cop_torso", "damage": [ 1, 4 ] }, - { "group": "cop_weapons", "prob": 50, "damage": [ 0, 1 ], "dirt": [ 1500, 7100 ] }, + { "group": "cop_weapons", "prob": 50, "damage": [ 0, 1 ], "dirt": [ 1500, 7050 ] }, { "group": "underwear", "damage": [ 1, 4 ] }, { "group": "clothing_glasses", "prob": 5 }, { "group": "clothing_watch", "prob": 5 }, From ce9efc75979ea7de44a33dd99709adab55d58eed Mon Sep 17 00:00:00 2001 From: misterprimus Date: Sun, 29 Sep 2019 04:36:21 -0400 Subject: [PATCH 36/38] various Rail-runner's suggestion on removing UPS_CHARGES check in deciding to fail to cycle or not. Appears to have worked with the minigun. Added check to see if non-fouling parameter was in the current ammo effects. Purpose was to get rid of fouling in guns like the rail rifle, which don't even use gunpowder. These fouled without this change, but now seem to be working properly. --- data/json/items/ammo/metal_rail.json | 4 +- src/ranged.cpp | 60 ++++++++++++++-------------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/data/json/items/ammo/metal_rail.json b/data/json/items/ammo/metal_rail.json index 4e1d99cf27335..64a7289cb2c7f 100644 --- a/data/json/items/ammo/metal_rail.json +++ b/data/json/items/ammo/metal_rail.json @@ -20,7 +20,7 @@ "damage": 70, "pierce": 25, "dispersion": 150, - "effects": [ "RECYCLED" ] + "effects": [ "RECYCLED", "NON-FOULING" ] }, { "id": "steel_rail", @@ -36,7 +36,7 @@ "material": [ "steel" ], "color": "light_gray", "dispersion": 0, - "effects": [ "NEVER_MISFIRES" ], + "effects": [ "NEVER_MISFIRES", "NON-FOULING" ], "relative": { "range": 10, "damage": -5, "pierce": 15 } } ] diff --git a/src/ranged.cpp b/src/ranged.cpp index f1f1918a4d9d1..b71a5b0cd1187 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -250,35 +250,37 @@ bool player::handle_gun_damage( item &it ) } } } - if( curammo_effects.count( "BLACKPOWDER" ) ) { - if( ( it.ammo_data()->ammo->recoil < firing->min_cycle_recoil ) && - it.faults_potential().count( fault_gun_chamber_spent ) && ( it.type->gun->ups_charges < 1 ) ) { - add_msg_player_or_npc( m_bad, _( "Your %s fails to cycle!" ), - _( "'s %s fails to cycle!" ), - it.tname() ); - it.faults.insert( fault_gun_chamber_spent ); - // Don't return false in this case; this shot happens, follow-up ones won't. - } - } - // These are the dirtying/fouling mechanics - if( dirt < 10000 ) { - dirtadder = curammo_effects.count( "BLACKPOWDER" ) * ( 200 - ( firing->blackpowder_tolerance * - 2 ) ); - if( dirtadder < 0 ) { - dirtadder = 0; - } - it.set_var( "dirt", std::min( 10000, dirt + dirtadder + 1 ) ); - } - dirt = it.get_var( "dirt", 0 ); - dirt_dbl = static_cast( dirt ); - if( dirt > 0 && !it.faults.count( fault_gun_blackpowder ) ) { - it.faults.insert( fault_gun_dirt ); - } - if( dirt > 0 && curammo_effects.count( "BLACKPOWDER" ) ) { - it.faults.erase( fault_gun_dirt ); - it.faults.insert( fault_gun_blackpowder ); - } - // end fouling mechanics + if( !curammo_effects.count( "NON-FOULING" ) ) { + if( curammo_effects.count( "BLACKPOWDER" ) ) { + if( ( it.ammo_data()->ammo->recoil < firing->min_cycle_recoil ) && + it.faults_potential().count( fault_gun_chamber_spent ) ) { + add_msg_player_or_npc( m_bad, _( "Your %s fails to cycle!" ), + _( "'s %s fails to cycle!" ), + it.tname() ); + it.faults.insert( fault_gun_chamber_spent ); + // Don't return false in this case; this shot happens, follow-up ones won't. + } + } + // These are the dirtying/fouling mechanics + if( dirt < 10000 ) { + dirtadder = curammo_effects.count( "BLACKPOWDER" ) * ( 200 - ( firing->blackpowder_tolerance * + 2 ) ); + if( dirtadder < 0 ) { + dirtadder = 0; + } + it.set_var( "dirt", std::min( 10000, dirt + dirtadder + 1 ) ); + } + dirt = it.get_var( "dirt", 0 ); + dirt_dbl = static_cast( dirt ); + if( dirt > 0 && !it.faults.count( fault_gun_blackpowder ) ) { + it.faults.insert( fault_gun_dirt ); + } + if( dirt > 0 && curammo_effects.count( "BLACKPOWDER" ) ) { + it.faults.erase( fault_gun_dirt ); + it.faults.insert( fault_gun_blackpowder ); + } + // end fouling mechanics + } if( dirt_dbl > 5000 && x_in_y( dirt_dbl * dirt_dbl * dirt_dbl, 5555555555555 ) ) { add_msg_player_or_npc( m_bad, _( "Your %s is damaged by the high pressure!" ), From 036d299442c84db8b7573363f9a1855e09864a81 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Tue, 1 Oct 2019 17:54:41 -0400 Subject: [PATCH 37/38] pneumatic guns should not foul adds ability to mark a gun, in addition to ammo, as non-fouling. --- data/json/items/ammo.json | 6 +++--- data/json/items/ranged.json | 6 +++--- src/ranged.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/json/items/ammo.json b/data/json/items/ammo.json index 0ad101a1fb855..5e7981c4ac925 100644 --- a/data/json/items/ammo.json +++ b/data/json/items/ammo.json @@ -273,7 +273,7 @@ "dispersion": 14, "loudness": 0, "count": 10, - "effects": [ "NEVER_MISFIRES" ] + "effects": [ "NEVER_MISFIRES", "NON-FOULING" ] }, { "type": "AMMO", @@ -332,7 +332,7 @@ "dispersion": 14, "loudness": 0, "count": 50, - "effects": [ "NEVER_MISFIRES" ] + "effects": [ "NEVER_MISFIRES", "NON-FOULING" ] }, { "type": "AMMO", @@ -351,7 +351,7 @@ "count": 500, "stack_size": 200, "loudness": 9, - "effects": [ "NOGIB", "NEVER_MISFIRES" ] + "effects": [ "NOGIB", "NEVER_MISFIRES", "NON-FOULING" ] }, { "type": "AMMO", diff --git a/data/json/items/ranged.json b/data/json/items/ranged.json index 369fc707dba70..7d4824f38da5e 100644 --- a/data/json/items/ranged.json +++ b/data/json/items/ranged.json @@ -305,7 +305,7 @@ "description": "A multistroke pneumatic rifle handcrafted from scrap. It is very quiet and deadly.", "price": 240000, "material": [ "steel", "wood" ], - "flags": [ "STR_RELOAD", "RELOAD_ONE" ], + "flags": [ "STR_RELOAD", "RELOAD_ONE", "NON-FOULING" ], "skill": "rifle", "ammo": "pebble", "weight": "4211 g", @@ -341,7 +341,7 @@ "description": "An eight-shot, revolving barrel, pneumatic bolt driver handcrafted from scrap. It is very quiet and deadly.", "price": 290000, "material": [ "steel", "wood" ], - "flags": [ "RELOAD_ONE", "STR_RELOAD" ], + "flags": [ "RELOAD_ONE", "STR_RELOAD", "NON-FOULING" ], "skill": "rifle", "ammo": "bolt", "weight": "3110 g", @@ -377,7 +377,7 @@ "description": "A double-barreled pneumatic air shotgun handcrafted from scrap. Though it's firepower is lacking compared to more conventional shotguns, this thing can still pack quite a punch. That is, if your target is directly in front of you.", "price": 220000, "material": [ "steel", "wood" ], - "flags": [ "RELOAD_ONE", "STR_RELOAD" ], + "flags": [ "RELOAD_ONE", "STR_RELOAD", "NON-FOULING" ], "skill": "shotgun", "ammo": "shotcanister", "weight": "3410 g", diff --git a/src/ranged.cpp b/src/ranged.cpp index b71a5b0cd1187..08c3af3062cd9 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -250,7 +250,7 @@ bool player::handle_gun_damage( item &it ) } } } - if( !curammo_effects.count( "NON-FOULING" ) ) { + if( !curammo_effects.count( "NON-FOULING" ) && !it.has_flag( "NON-FOULING" ) ) { if( curammo_effects.count( "BLACKPOWDER" ) ) { if( ( it.ammo_data()->ammo->recoil < firing->min_cycle_recoil ) && it.faults_potential().count( fault_gun_chamber_spent ) ) { From 176b61d0d8dc31c0d2ad958ed1e1fc70308d4510 Mon Sep 17 00:00:00 2001 From: misterprimus Date: Tue, 1 Oct 2019 19:55:03 -0400 Subject: [PATCH 38/38] nails do not foul --- data/json/items/ammo/nail.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/json/items/ammo/nail.json b/data/json/items/ammo/nail.json index a2054549af5bf..e488465e5d62f 100644 --- a/data/json/items/ammo/nail.json +++ b/data/json/items/ammo/nail.json @@ -29,6 +29,7 @@ "range": 3, "damage": 4, "pierce": 3, - "dispersion": 120 + "dispersion": 120, + "effects": [ "NON-FOULING" ] } ]