Author Topic: JSONizing mapgen_basement_junk gun safe items, any advice?  (Read 78 times)

Offline BorkBorkGoesTheCode

  • Survivor
  • ***
  • Posts: 794
  • What could possibly go wrong....
    • View Profile
JSONizing mapgen_basement_junk gun safe items, any advice?
« on: September 10, 2017, 08:04:35 PM »
Modifying this bit of code in src/mapgen_functions.cpp mapgen_basement_junk:

Code: [Select]
        if( one_in( 1600 ) ) {
            m->furn_set( p, furn_str_id( "f_gun_safe_el" ) );
            if( one_in( 2 ) ) {
                m->spawn_item( p, "9mm", 2 );
                m->spawn_item( p, "usp_9mm" );
                m->spawn_item( p, "suppressor" );
                m->spawn_item( p, "cash_card", 2 );
            } else {
                m->place_items( "ammo", 96,  p.x,  p.y, p.x,  p.y, false, 0 );
                m->place_items( "guns_survival", 90,  p.x,  p.y, p.x,  p.y, false, 0 );
            }
        }
So far it looks like this:


Code: [Select]
        if( one_in( 1600 ) ) {
            m->furn_set( p, furn_str_id( "f_gun_safe_el" ) );
            if( one_in( 2 ) ) {
                m->place_items( "basement_op_guns", 96,  p.x,  p.y, p.x,  p.y, false, 0 );
            } else {
                m->place_items( "ammo", 90,  p.x,  p.y, p.x,  p.y, false, 0 );
            }
        }
With the new itemgroup in /itemgroups/locations.json:

Code: [Select]
  {
    "id": "basement_op_guns",
    "type": "item_group",
    "//": "Hardcoded gunsafe itemgroup for basement_junk in mapgen_functions.cpp .",
    "magazine": 100,
    "items": [
      {
        "distribution": [
          {
            "collection": [
              { "item": "usp_9mm" },
              { "item": "usp9mag" },
              { "item": "9mmP", "charges-min": 24, "charges-max": 50 },
              { "item": "suppressor" },
              { "item": "holster" }
            ], "prob": 20
          },
          {
            "collection": [
              { "item": "usp_9mm" },
              { "item": "9mm", "charges-min": 50, "charges-max": 50 },
              { "item": "suppressor" },
              { "item": "cash_card" }
            ], "prob": 50
          },
          {
            "collection": [
              { "group": "guns_pistol_milspec" },
              { "item": "holster" }
            ], "prob": 50
          },
              { "group": "guns_survival", "prob": 50 },
              { "group": "ammo", "prob": 50 }
        ]
      }
    ]
  },
Have I done anything gamebreaking?
« Last Edit: September 10, 2017, 08:06:08 PM by BorkBorkGoesTheCode »
The hollow earth and the Dyson sphere share an origin? Do some research