[
  {
    "id": "TALK_BULLET_EXCHANGE_INFO",
    "type": "talk_topic",
    "dynamic_line": [
      "You hit the nail on the head.  You bring me bullets - 5.56, 7.62, 5.45, or .300 - and I'll convert between 'em.  I take a 10% cut, just so you know."
    ],
    "responses": [
      { "text": "Thanks for filling me in.", "topic": "TALK_GUNSMITH_SERVICES" },
      { "text": "Can we do that now?", "topic": "TALK_BULLET_EXCHANGE" }
    ]
  },
  {
    "id": "TALK_BULLET_EXCHANGE",
    "//": "this is all the dialogue related to converting bullets with Jay",
    "type": "talk_topic",
    "dynamic_line": [
      "Yup, what would you like to convert?  As a reminder, I do 5.56, 7.62, 5.45, or .300.  You want anything else, we can just trade 'em directly over the counter."
    ],
    "responses": [
      { "text": "Nothing for now.", "topic": "TALK_GUNSMITH_SERVICES" },
      {
        "text": "Let's see what you have in stock right now.",
        "topic": "TALK_GUNSMITH_SERVICES",
        "effect": "start_trade"
      },
      {
        "text": "[1 day] 200 rounds.",
        "effect": [ { "math": [ "u_number_artisans_gunsmith_ammo_amount", "=", "200" ] } ],
        "topic": "TALK_GUNSMITH_CONVERT_FROM_TYPE"
      },
      {
        "text": "[5 days] 800 rounds.",
        "effect": [ { "math": [ "u_number_artisans_gunsmith_ammo_amount", "=", "800" ] } ],
        "topic": "TALK_GUNSMITH_CONVERT_FROM_TYPE"
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_gunsmith_take_source_succeed",
    "effect": { "math": [ "u_number_artisans_failed_to_convert_ammo", "=", "0" ] }
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_gunsmith_failed_to_provide",
    "effect": { "math": [ "u_number_artisans_failed_to_convert_ammo", "=", "1" ] }
  },
  {
    "id": "EOC_gunsmith_set_source_type",
    "type": "effect_on_condition",
    "effect": [
      { "math": [ "u_number_artisans_gunsmith_ammo_from", "=", "_key1" ] },
      {
        "switch": { "math": [ "_key1" ] },
        "cases": [
          {
            "case": 300,
            "effect": [
              { "set_string_var": "300 BLK", "target_var": { "u_val": "artisans_gunsmith_ammo_source_name" } },
              { "set_string_var": "300blk", "target_var": { "u_val": "artisans_gunsmith_ammo_source_item" } }
            ]
          },
          {
            "case": 545,
            "effect": [
              { "set_string_var": "5.45x39", "target_var": { "u_val": "artisans_gunsmith_ammo_source_name" } },
              { "set_string_var": "545", "target_var": { "u_val": "artisans_gunsmith_ammo_source_item" } }
            ]
          },
          {
            "case": 556,
            "effect": [
              { "set_string_var": "5.56x45", "target_var": { "u_val": "artisans_gunsmith_ammo_source_name" } },
              { "set_string_var": "556", "target_var": { "u_val": "artisans_gunsmith_ammo_source_item" } }
            ]
          },
          {
            "case": 76239,
            "effect": [
              { "set_string_var": "7.62x39", "target_var": { "u_val": "artisans_gunsmith_ammo_source_name" } },
              { "set_string_var": "762_m87", "target_var": { "u_val": "artisans_gunsmith_ammo_source_item" } }
            ]
          },
          {
            "case": 76251,
            "effect": [
              { "set_string_var": "7.62x51", "target_var": { "u_val": "artisans_gunsmith_ammo_source_name" } },
              { "set_string_var": "762_51", "target_var": { "u_val": "artisans_gunsmith_ammo_source_item" } }
            ]
          }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_gunsmith_take_source",
    "effect": {
      "u_sell_item": { "u_val": "artisans_gunsmith_ammo_source_item" },
      "count": { "u_val": "number_artisans_gunsmith_ammo_amount" },
      "true_eocs": [ "EOC_gunsmith_take_source_succeed" ],
      "false_eocs": "EOC_gunsmith_failed_to_provide"
    }
  },
  {
    "id": "TALK_GUNSMITH_CONVERT_FROM_TYPE",
    "type": "talk_topic",
    "dynamic_line": "Alright, <u_val:number_artisans_gunsmith_ammo_amount> rounds.  First off, what are you looking to give me?",
    "responses": [
      {
        "text": "5.56x45.",
        "condition": { "u_has_items": { "item": "556", "count": { "u_val": "number_artisans_gunsmith_ammo_amount" } } },
        "effect": [
          { "run_eoc_with": "EOC_gunsmith_set_source_type", "variables": { "key1": "556" } },
          { "run_eocs": "EOC_gunsmith_take_source" }
        ],
        "topic": "TALK_GUNSMITH_CONVERT_TO_TYPE"
      },
      {
        "text": "7.62x51.",
        "condition": { "u_has_items": { "item": "762_51", "count": { "u_val": "number_artisans_gunsmith_ammo_amount" } } },
        "effect": [
          { "run_eoc_with": "EOC_gunsmith_set_source_type", "variables": { "key1": "76251" } },
          { "run_eocs": "EOC_gunsmith_take_source" }
        ],
        "topic": "TALK_GUNSMITH_CONVERT_TO_TYPE"
      },
      {
        "text": "7.62x39.",
        "condition": { "u_has_items": { "item": "762_m87", "count": { "u_val": "number_artisans_gunsmith_ammo_amount" } } },
        "effect": [
          { "run_eoc_with": "EOC_gunsmith_set_source_type", "variables": { "key1": "76239" } },
          { "run_eocs": "EOC_gunsmith_take_source" }
        ],
        "topic": "TALK_GUNSMITH_CONVERT_TO_TYPE"
      },
      {
        "text": "5.45x39.",
        "condition": { "u_has_items": { "item": "545", "count": { "u_val": "number_artisans_gunsmith_ammo_amount" } } },
        "effect": [
          { "run_eoc_with": "EOC_gunsmith_set_source_type", "variables": { "key1": "545" } },
          { "run_eocs": "EOC_gunsmith_take_source" }
        ],
        "topic": "TALK_GUNSMITH_CONVERT_TO_TYPE"
      },
      {
        "text": ".300 AAC.",
        "condition": { "u_has_items": { "item": "300blk", "count": { "u_val": "number_artisans_gunsmith_ammo_amount" } } },
        "effect": [
          { "run_eoc_with": "EOC_gunsmith_set_source_type", "variables": { "key1": "300" } },
          { "run_eocs": "EOC_gunsmith_take_source" }
        ],
        "topic": "TALK_GUNSMITH_CONVERT_TO_TYPE"
      },
      { "text": "Forget it.", "topic": "TALK_GUNSMITH_SERVICES" }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_gunsmith_set_convert_target",
    "effect": [
      { "math": [ "u_number_artisans_gunsmith_ammo_to", "=", "_key1" ] },
      { "u_add_var": "gunsmith_has_rounds_ordered", "type": "dialogue", "context": "artisans", "value": "yes" },
      { "u_add_var": "u_waiting_on_rounds", "type": "timer", "context": "artisans", "time": true }
    ]
  },
  {
    "id": "TALK_GUNSMITH_CONVERT_TO_TYPE",
    "type": "talk_topic",
    "dynamic_line": "Sure, <u_val:artisans_gunsmith_ammo_source_name> to what?",
    "responses": [
      {
        "text": "5.56x45.",
        "condition": {
          "and": [
            { "not": { "u_compare_var": "gunsmith_ammo_from", "type": "number", "context": "artisans", "op": "==", "value": 556 } },
            { "math": [ "u_number_artisans_failed_to_convert_ammo", "==", "0" ] }
          ]
        },
        "effect": { "run_eoc_with": "EOC_gunsmith_set_convert_target", "variables": { "key1": "556" } },
        "topic": "TALK_GUNSMITH_CONVERT_CONFIRM"
      },
      {
        "text": "7.62x51.",
        "condition": {
          "and": [
            {
              "not": { "u_compare_var": "gunsmith_ammo_from", "type": "number", "context": "artisans", "op": "==", "value": 76251 }
            },
            { "math": [ "u_number_artisans_failed_to_convert_ammo", "==", "0" ] }
          ]
        },
        "effect": { "run_eoc_with": "EOC_gunsmith_set_convert_target", "variables": { "key1": "76251" } },
        "topic": "TALK_GUNSMITH_CONVERT_CONFIRM"
      },
      {
        "text": "7.62x39.",
        "condition": {
          "and": [
            {
              "not": { "u_compare_var": "gunsmith_ammo_from", "type": "number", "context": "artisans", "op": "==", "value": 76239 }
            },
            { "math": [ "u_number_artisans_failed_to_convert_ammo", "==", "0" ] }
          ]
        },
        "effect": { "run_eoc_with": "EOC_gunsmith_set_convert_target", "variables": { "key1": "76239" } },
        "topic": "TALK_GUNSMITH_CONVERT_CONFIRM"
      },
      {
        "text": "5.45x39.",
        "condition": {
          "and": [
            { "not": { "u_compare_var": "gunsmith_ammo_from", "type": "number", "context": "artisans", "op": "==", "value": 545 } },
            { "math": [ "u_number_artisans_failed_to_convert_ammo", "==", "0" ] }
          ]
        },
        "effect": { "run_eoc_with": "EOC_gunsmith_set_convert_target", "variables": { "key1": "545" } },
        "topic": "TALK_GUNSMITH_CONVERT_CONFIRM"
      },
      {
        "text": ".300 AAC.",
        "condition": {
          "and": [
            { "not": { "u_compare_var": "gunsmith_ammo_from", "type": "number", "context": "artisans", "op": "==", "value": 300 } },
            { "math": [ "u_number_artisans_failed_to_convert_ammo", "==", "0" ] }
          ]
        },
        "effect": { "run_eoc_with": "EOC_gunsmith_set_convert_target", "variables": { "key1": "300" } },
        "topic": "TALK_GUNSMITH_CONVERT_CONFIRM"
      },
      {
        "text": "See you then.",
        "topic": "TALK_DONE",
        "condition": { "math": [ "u_number_artisans_failed_to_convert_ammo", "==", "1" ] }
      }
    ]
  },
  {
    "id": "TALK_GUNSMITH_CONVERT_CONFIRM",
    "type": "talk_topic",
    "dynamic_line": {
      "u_compare_var": "gunsmith_ammo_amount",
      "type": "number",
      "context": "artisans",
      "op": "==",
      "value": 200,
      "yes": "Alright, that's 200 rounds minus the 10% service fee.  They'll be converted in a day.",
      "no": "Alright, that's 800 rounds minus the 10% service fee.  They'll be converted in 5 days."
    },
    "responses": [
      { "text": "See you then.", "topic": "TALK_DONE" },
      { "text": "There's something else I'd like to talk about.", "topic": "TALK_GUNSMITH_SERVICES" }
    ]
  },
  {
    "id": "TALK_GUNSMITH_BULLET_PICKUP_NOT_YET",
    "type": "talk_topic",
    "dynamic_line": "Sorry, it isn't ready yet.",
    "responses": [
      { "text": "See you then.", "topic": "TALK_DONE" },
      { "text": "There's something else I'd like to talk about.", "topic": "TALK_GUNSMITH_SERVICES" }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_gunsmith_get_convert_coeff",
    "effect": {
      "switch": { "math": [ "u_number_artisans_gunsmith_ammo_from" ] },
      "cases": [
        {
          "case": 300,
          "effect": {
            "switch": { "math": [ "u_number_artisans_gunsmith_ammo_to" ] },
            "cases": [
              { "case": 545, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "180" ] } },
              { "case": 556, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "270" ] } },
              { "case": 76239, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "135" ] } },
              { "case": 76251, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "135" ] } }
            ]
          }
        },
        {
          "case": 545,
          "effect": {
            "switch": { "math": [ "u_number_artisans_gunsmith_ammo_to" ] },
            "cases": [
              { "case": 300, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "180" ] } },
              { "case": 556, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "270" ] } },
              { "case": 76239, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "135" ] } },
              { "case": 76251, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "135" ] } }
            ]
          }
        },
        {
          "case": 556,
          "effect": {
            "switch": { "math": [ "u_number_artisans_gunsmith_ammo_to" ] },
            "cases": [
              { "case": 300, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "120" ] } },
              { "case": 545, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "120" ] } },
              { "case": 76239, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "90" ] } },
              { "case": 76251, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "90" ] } }
            ]
          }
        },
        {
          "case": 76239,
          "effect": {
            "switch": { "math": [ "u_number_artisans_gunsmith_ammo_to" ] },
            "cases": [
              { "case": 300, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "240" ] } },
              { "case": 545, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "240" ] } },
              { "case": 556, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "360" ] } },
              { "case": 76251, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "180" ] } }
            ]
          }
        },
        {
          "case": 76251,
          "effect": {
            "switch": { "math": [ "u_number_artisans_gunsmith_ammo_to" ] },
            "cases": [
              { "case": 300, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "240" ] } },
              { "case": 545, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "240" ] } },
              { "case": 556, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "360" ] } },
              { "case": 76239, "effect": { "math": [ "u_number_artisans_gunsmith_ammo_convert_coeff", "=", "180" ] } }
            ]
          }
        }
      ]
    }
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_gunsmith_get_convert_target_item",
    "effect": {
      "switch": { "math": [ "u_number_artisans_gunsmith_ammo_to" ] },
      "cases": [
        {
          "case": 300,
          "effect": { "set_string_var": "300blk", "target_var": { "u_val": "artisans_gunsmith_ammo_convert_target" } }
        },
        {
          "case": 545,
          "effect": { "set_string_var": "545", "target_var": { "u_val": "artisans_gunsmith_ammo_convert_target" } }
        },
        {
          "case": 556,
          "effect": { "set_string_var": "556", "target_var": { "u_val": "artisans_gunsmith_ammo_convert_target" } }
        },
        {
          "case": 76239,
          "effect": { "set_string_var": "762_m87", "target_var": { "u_val": "artisans_gunsmith_ammo_convert_target" } }
        },
        {
          "case": 76251,
          "effect": { "set_string_var": "762_51", "target_var": { "u_val": "artisans_gunsmith_ammo_convert_target" } }
        }
      ]
    }
  },
  {
    "type": "var_migration",
    "from": "npctalk_var_number_artisans_gunsmith_ammo_ammount",
    "to": "npctalk_var_number_artisans_gunsmith_ammo_amount"
  },
  {
    "id": "TALK_GUNSMITH_BULLET_PICKUP",
    "type": "talk_topic",
    "dynamic_line": "The transaction is complete, here are your items.",
    "responses": [
      {
        "text": "[Take your new ammo.] Thanks.",
        "effect": [
          { "run_eocs": [ "EOC_gunsmith_get_convert_coeff", "EOC_gunsmith_get_convert_target_item" ] },
          {
            "math": [
              "u_number_artisans_gunsmith_ammo_convert_result",
              "=",
              "u_number_artisans_gunsmith_ammo_convert_coeff * u_number_artisans_gunsmith_ammo_amount / 200"
            ]
          },
          {
            "u_spawn_item": { "u_val": "artisans_gunsmith_ammo_convert_target" },
            "count": { "u_val": "number_artisans_gunsmith_ammo_convert_result", "default": 200 }
          },
          { "u_add_var": "gunsmith_has_rounds_ordered", "type": "dialogue", "context": "artisans", "value": "no" }
        ],
        "topic": "TALK_DONE"
      },
      { "text": "There's something else I'd like to talk about.", "topic": "TALK_GUNSMITH_SERVICES" }
    ]
  }
]
