CleverRaven / Cataclysm-DDA

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

Item Group cannot spawn directly through mapgen, cannot be debug item group tested. #31092

Closed John-Candlebury closed 5 years ago

John-Candlebury commented 5 years ago

Describe the bug

A given item group cannot spawn directly, but if it is added as an entry of secondary item group, the items from the first list can spawn.

Steps To Reproduce

  1. Start game and go to the test item group debug option
  2. Search robofac_basic_trade item group and try to test it. Notice how nothing happens
  3. Search NC_ROBOFAC_INTERCOM_trade item group and test it. Notice that it does work, even though NC_ROBOFAC_ITERCOM_trade is just an indirect call for robofac_basic_trade.

Expected behavior

robofac_basic_trade works as an independent item group.

Night-Pryanik commented 5 years ago

This is a very strange bug. I changed the contents of NC_ROBOFAC_ITERCOM_trade item group to contain some other item group, say, default_zombie_clothes,

{
    "type": "item_group",
    "id": "NC_ROBOFAC_INTERCOM_trade",
    "entries": [ { "group": "default_zombie_clothes", "repeat": [ 15, 25 ] } ]
}

and yet while debug-testing NC_ROBOFAC_INTERCOM_trade item group I still got contents of robofac_basic_trade item group like I didn't change anything.

ralreegorganon commented 5 years ago

The NC_ROBOFAC_INTERCOM_trade group is defined twice, here and here and the robofac_basic_trade and NC_ROBOFAC_INTERCOM_trade groups don't have the subtypes set.

Subtype is optional, per the docs, but if you do so, it uses the "old" format. I'd suggest explicitly specifying it.

subtype is optional. It can be collection or distribution. If unspecified, it defaults to old, which denotes that this item group uses the old format (which is technically a distribution).

I did something like this and it works (adjust accordingly per your intent):

diff --git a/data/json/npcs/robofac/NC_ROBOFAC_INTERCOM.json b/data/json/npcs/robofac/NC_ROBOFAC_INTERCOM.json
index ec86cc2ae4..14cb84bb88 100644
--- a/data/json/npcs/robofac/NC_ROBOFAC_INTERCOM.json
+++ b/data/json/npcs/robofac/NC_ROBOFAC_INTERCOM.json
@@ -2,6 +2,7 @@
   {
     "type": "item_group",
     "id": "NC_ROBOFAC_INTERCOM_trade",
+    "subtype": "collection",
     "entries": [ { "group": "robofac_basic_trade", "repeat": [ 15, 25 ] } ]
   },
   {
@@ -13,6 +14,7 @@
   {
     "type": "item_group",
     "id": "robofac_basic_trade",
+    "subtype": "distribution",
     "entries": [
       { "group": "bionics_common", "prob": 100 },
       { "group": "textbooks", "prob": 100 },
diff --git a/data/json/npcs/robofac/classes.json b/data/json/npcs/robofac/classes.json
index 3cbc3a2f3a..8e6e863ac0 100644
--- a/data/json/npcs/robofac/classes.json
+++ b/data/json/npcs/robofac/classes.json
@@ -1,18 +1,4 @@
 [
-  {
-    "type": "item_group",
-    "id": "NC_ROBOFAC_INTERCOM_trade",
-    "subtype": "distribution",
-    "entries": [
-      { "group": "bionics_common", "prob": 100 },
-      { "group": "textbooks", "prob": 100 },
-      { "group": "electronics", "prob": 100 },
-      { "group": "science", "prob": 100 },
-      { "group": "robofac_basic_robots", "prob": 100 },
-      { "group": "cop_armory", "prob": 100 },
-      { "group": "ammo_any_batteries_full", "prob": 100 }
-    ]
-  },
   {
     "type": "item_group",
     "id": "NC_ROBOFAC_INTERCOM_worn",
John-Candlebury commented 5 years ago

Thanks for the solution @ralreegorganon!

NC_ROBOFAC_FREE_MERCHANT_misc suffered from this very same silent failing bug. But the solution above did not actually help.

There might be something else worth investigating?

ralreegorganon commented 5 years ago

You can't use arrays in an entries list like you're doing here. Everything from trenchcoat on down needs to be converted to an object instead.

{
    "type": "item_group",
    "sub-type": "collection",
    "id": "NC_ROBOFAC_FREE_MERCHANT_misc",
    "entries": [
      { "item": "FMCNote", "count-min": 50, "count-max": 300, "prob": 100 },
      { "group": "produce", "count-min": 10, "count-max": 20, "prob": 100 },
      { "group": "bunker_basement_food", "count-min": 5, "count-max": 10, "prob": 100 },
      { "item": "jerky", "count-min": 10, "count-max": 25, "prob": 100 },
      { "item": "FMCNote", "count-min": 50, "count-max": 300, "prob": 100 },
      [ "trenchcoat", 25 ],
      [ "trenchcoat_leather", 20 ],
      [ "trenchcoat_fur", 10 ],
      [ "jacket_leather", 25 ],
      [ "jacket_jean", 15 ],
      [ "jacket_flannel", 15 ],
      [ "pants_cargo", 40 ],
      [ "shorts_cargo", 25 ],
      [ "pants_leather", 15 ],
      [ "gloves_fingerless", 30 ],
      [ "gloves_fur", 5 ],
      [ "gloves_leather", 35 ],
      [ "boots", 20 ],
      [ "boots_hiking", 30 ],
      [ "hood_rain", 15 ],
      [ "runner_bag", 20 ],
      [ "sunglasses", 15 ],
      [ "goggles_ski", 5 ],
      [ "wristwatch", 30 ],
      [ "bandana", 20 ],
      [ "scarf", 15 ],
      [ "fungicide", 20 ],
      [ "antifungal", 20 ],
      [ "antiparasitic", 20 ],
      [ "grapnel", 5 ]
    ]
  },
Night-Pryanik commented 5 years ago

Could be closed?