CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.65k stars 4.18k forks source link

Gas masks don't work #40894

Closed ektoplazm closed 4 years ago

ektoplazm commented 4 years ago

Describe the bug

The problem described in #40765 still persists, it's not possible to reload gas masks with cartridges (tested on gas mask, survivor gas mask, light survivor gas mask, XL gas mask), thus rendering them impossible to activate. However, testing it on a gas mask which I had loaded and activated beforehand (in build 10614), I found out that this mask stays activated and works in gas clouds without any charges loaded.

Steps To Reproduce

  1. Spawn a gas mask
  2. Spawn gas mask cartridges
  3. Try to reload the mask
  4. Get the "you can' reload the mask" message in the log.
  5. Get an activated gas mask (with no charges)
  6. Spawn a bloated zombie
  7. Walk into a gas cloud while wearing this activated gas mask with no charges, gas poisoning does not happen, no messages about "inhaling toxic gas" appear in the log.

Expected behavior

Gas masks can be reloaded with cartridges and consume them as charges when activated and used.

Screenshots

image

Versions and configuration

Additional context

this error occurs when trying to activate an empty light survivor mask -

DEBUG    : can't set ammo null as it is not an ammo
FUNCTION : item& item::ammo_set(const itype_id&, int)
FILE     : src/item.cpp
LINE     : 583
anothersimulacrum commented 4 years ago

Just needs pocket data updating (but it's not finding the filter...) Here a JSON patch:

diff --git a/data/json/items/tool_armor.json b/data/json/items/tool_armor.json
index e4c6123184..9ba28764c2 100644
--- a/data/json/items/tool_armor.json
+++ b/data/json/items/tool_armor.json
@@ -363,10 +363,10 @@
     "covers": [ "TORSO", "HEAD", "ARMS", "LEGS" ],
     "coverage": 65,
     "encumbrance": 10,
-    "max_charges": 1000,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "plutonium": 1000 } } ],
+    "ammo": "plutonium",
     "initial_charges": 500,
     "charges_per_use": 25,
-    "ammo": "plutonium",
     "warmth": 10,
     "material_thickness": 1,
     "environmental_protection": 4,
@@ -876,9 +876,9 @@
     "weight": "6820 g",
     "volume": "9 L",
     "to_hit": -3,
-    "max_charges": 5000,
-    "charges_per_use": 5,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "plutonium": 5000 } } ],
     "ammo": "plutonium",
+    "charges_per_use": 5,
     "use_action": "RM13ARMOR_OFF",
     "covers": [ "HEAD", "MOUTH", "EYES", "TORSO", "ARMS", "HANDS", "LEGS", "FEET" ],
     "warmth": 30,
@@ -931,8 +931,8 @@
     "material": [ "ceramic", "kevlar" ],
     "weight": "1250 g",
     "volume": "4500 ml",
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "plutonium": 1000 } } ],
     "ammo": "plutonium",
-    "max_charges": 1000,
     "initial_charges": 1000,
     "use_action": {
       "type": "transform",
@@ -982,8 +982,8 @@
     "material": [ "carbide" ],
     "weight": "1250 g",
     "volume": "4500 ml",
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "plutonium": 2500 } } ],
     "ammo": "plutonium",
-    "max_charges": 2500,
     "initial_charges": 1000,
     "use_action": {
       "type": "transform",
@@ -1062,10 +1062,10 @@
     "weight": "720 g",
     "volume": "500 ml",
     "to_hit": -3,
-    "max_charges": 60,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "rebreather_filter": 60 } } ],
+    "ammo": "rebreather_filter",
     "initial_charges": 60,
     "charges_per_use": 1,
-    "ammo": "rebreather_filter",
     "use_action": {
       "type": "transform",
       "msg": "You activate your %s.",
@@ -1110,10 +1110,10 @@
     "weight": "960 g",
     "volume": "1250 ml",
     "to_hit": -3,
-    "max_charges": 60,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "rebreather_filter": 60 } } ],
+    "ammo": "rebreather_filter",
     "initial_charges": 60,
     "charges_per_use": 1,
-    "ammo": "rebreather_filter",
     "use_action": {
       "type": "transform",
       "msg": "You activate your %s.",
@@ -1165,9 +1165,9 @@
     "material_thickness": 2,
     "environmental_protection": 1,
     "environmental_protection_with_filter": 7,
-    "max_charges": 100,
-    "initial_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_s": 100 } } ],
     "ammo": "gasfilter_s",
+    "initial_charges": 100,
     "use_action": "GASMASK"
   },
   {
@@ -1192,9 +1192,9 @@
     "material_thickness": 2,
     "environmental_protection": 1,
     "environmental_protection_with_filter": 16,
-    "max_charges": 100,
-    "initial_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_m": 100 } } ],
     "ammo": "gasfilter_m",
+    "initial_charges": 100,
     "use_action": "GASMASK"
   },
   {
@@ -1218,9 +1218,9 @@
     "material_thickness": 2,
     "environmental_protection": 1,
     "environmental_protection_with_filter": 16,
-    "max_charges": 100,
-    "initial_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_m": 100 } } ],
     "ammo": "gasfilter_m",
+    "initial_charges": 100,
     "use_action": "GASMASK",
     "flags": [ "OVERSIZE", "SLEEP_IGNORE" ]
   },
@@ -1246,9 +1246,9 @@
     "material_thickness": 3,
     "environmental_protection": 1,
     "environmental_protection_with_filter": 15,
-    "max_charges": 100,
-    "initial_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_m": 100 } } ],
     "ammo": "gasfilter_m",
+    "initial_charges": 100,
     "use_action": "GASMASK",
     "flags": [ "VARSIZE", "STURDY", "SUN_GLASSES", "SLEEP_IGNORE" ]
   },
@@ -1274,9 +1274,9 @@
     "material_thickness": 3,
     "environmental_protection": 1,
     "environmental_protection_with_filter": 15,
-    "max_charges": 100,
-    "initial_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_m": 100 } } ],
     "ammo": "gasfilter_m",
+    "initial_charges": 100,
     "use_action": "GASMASK",
     "flags": [ "VARSIZE", "STURDY", "OVERSIZE", "SUN_GLASSES", "SLEEP_IGNORE" ]
   },
@@ -1296,9 +1296,9 @@
     "weight": "1260 g",
     "volume": "1500 ml",
     "to_hit": -3,
-    "max_charges": 100,
-    "initial_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_m": 100 } } ],
     "ammo": "gasfilter_m",
+    "initial_charges": 100,
     "use_action": "GASMASK",
     "covers": [ "MOUTH", "EYES" ],
     "warmth": 30,
@@ -1320,9 +1320,9 @@
     "price": 24000,
     "price_postapoc": 2000,
     "to_hit": -3,
-    "max_charges": 100,
-    "initial_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_m": 100 } } ],
     "ammo": "gasfilter_m",
+    "initial_charges": 100,
     "use_action": "GASMASK",
     "material": [ "kevlar_layered", "steel" ],
     "symbol": "[",
@@ -1348,10 +1348,10 @@
     "price": 24000,
     "price_postapoc": 1500,
     "to_hit": -3,
-    "max_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_m": 100 } } ],
+    "ammo": "gasfilter_m",
     "initial_charges": 100,
     "charges_per_use": 1,
-    "ammo": "gasfilter_m",
     "use_action": "GASMASK",
     "material": [ "kevlar_layered", "cotton" ],
     "symbol": "[",
@@ -1377,9 +1377,9 @@
     "price": 24000,
     "price_postapoc": 1750,
     "to_hit": -3,
-    "max_charges": 100,
-    "initial_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_m": 100 } } ],
     "ammo": "gasfilter_m",
+    "initial_charges": 100,
     "use_action": "GASMASK",
     "material": [ "kevlar_layered", "leather" ],
     "symbol": "[",
@@ -1405,9 +1405,9 @@
     "price": 24000,
     "price_postapoc": 1500,
     "to_hit": -3,
-    "max_charges": 100,
-    "initial_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_m": 100 } } ],
     "ammo": "gasfilter_m",
+    "initial_charges": 100,
     "use_action": "GASMASK",
     "material": [ "kevlar_layered", "plastic" ],
     "symbol": "[",
@@ -1433,9 +1433,9 @@
     "price": 24000,
     "price_postapoc": 1750,
     "to_hit": -3,
-    "max_charges": 100,
-    "initial_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_m": 100 } } ],
     "ammo": "gasfilter_m",
+    "initial_charges": 100,
     "use_action": "GASMASK",
     "material": [ "kevlar_layered", "fur" ],
     "symbol": "[",
@@ -1461,9 +1461,9 @@
     "price": 24000,
     "price_postapoc": 1500,
     "to_hit": -3,
-    "max_charges": 100,
-    "initial_charges": 100,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "gasfilter_m": 100 } } ],
     "ammo": "gasfilter_m",
+    "initial_charges": 100,
     "use_action": "GASMASK",
     "material": [ "kevlar_layered", "fur" ],
     "symbol": "[",
@@ -1620,9 +1620,8 @@
     "flags": [ "OVERSIZE" ],
     "weight": "364 g",
     "volume": "750 ml",
-    "max_charges": 2,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "ampoule": 2 } } ],
     "charges_per_use": 1,
-    "ammo": "ampoule",
     "use_action": "JET_INJECTOR",
     "material_thickness": 3
   },
@@ -1640,10 +1639,10 @@
     "flags": [ "OVERSIZE" ],
     "weight": "212 g",
     "volume": "750 ml",
-    "max_charges": 5,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "stimpack_ammo": 5 } } ],
+    "ammo": "stimpack_ammo",
     "initial_charges": 5,
     "charges_per_use": 1,
-    "ammo": "stimpack_ammo",
     "use_action": "STIMPACK",
     "material_thickness": 3
   },
@@ -1662,9 +1661,9 @@
     "weight": "982 g",
     "volume": "1500 ml",
     "to_hit": -3,
-    "max_charges": 120,
-    "charges_per_use": 1,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "rebreather_filter": 120 } } ],
     "ammo": "rebreather_filter",
+    "charges_per_use": 1,
     "use_action": {
       "type": "transform",
       "msg": "You activate your %s.",
@@ -1710,9 +1709,9 @@
     "weight": "1302 g",
     "volume": "2 L",
     "to_hit": -3,
-    "max_charges": 120,
-    "charges_per_use": 1,
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "rebreather_filter": 120 } } ],
     "ammo": "rebreather_filter",
+    "charges_per_use": 1,
     "use_action": {
       "type": "transform",
       "msg": "You activate your %s.",
@@ -2975,8 +2974,8 @@
     "symbol": ";",
     "color": "light_gray",
     "initial_charges": 60,
-    "max_charges": 60,
     "ammo": "nitrox",
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "nitrox": 60 } } ],
     "covers": [ "TORSO" ],
     "flags": [ "WATER_FRIENDLY", "BELTED", "ONLY_ONE", "STURDY", "NO_UNLOAD" ],
     "environmental_protection": 1,
@@ -3003,10 +3002,10 @@
     "material": [ "steel", "plastic" ],
     "symbol": ";",
     "color": "light_gray",
-    "max_charges": 60,
+    "ammo": "nitrox",
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "nitrox": 60 } } ],
     "charges_per_use": 1,
     "turns_per_charge": 60,
-    "ammo": "nitrox",
     "covers": [ "TORSO", "MOUTH" ],
     "flags": [ "WATER_FRIENDLY", "BELTED", "ONLY_ONE", "STURDY", "NO_UNLOAD" ],
     "environmental_protection": 1,
@@ -3032,9 +3031,9 @@
     "material": [ "aluminum", "plastic" ],
     "symbol": ";",
     "color": "light_gray",
-    "initial_charges": 20,
-    "max_charges": 20,
     "ammo": "nitrox",
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "nitrox": 20 } } ],
+    "max_charges": 20,
     "covers": [ "TORSO" ],
     "flags": [ "WATER_FRIENDLY", "BELTED", "ONLY_ONE", "STURDY", "NO_UNLOAD" ],
     "environmental_protection": 1,
@@ -3061,10 +3060,10 @@
     "material": [ "aluminum", "plastic" ],
     "symbol": ";",
     "color": "light_gray",
-    "max_charges": 20,
+    "ammo": "nitrox",
+    "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "nitrox": 20 } } ],
     "charges_per_use": 1,
     "turns_per_charge": 60,
-    "ammo": "nitrox",
     "covers": [ "TORSO", "MOUTH" ],
     "flags": [ "WATER_FRIENDLY", "BELTED", "ONLY_ONE", "STURDY", "NO_UNLOAD" ],
     "environmental_protection": 1,
wapcaplet commented 4 years ago

This is fixed in #40997