[
  {
    "type": "effect_on_condition",
    "id": "EOC_INVENTOR_RESEARCH_BASE_1",
    "//": "Check, do player has enough processed sparks to beat the difficulty. If true, substract difficulty from vitamin, increase difficulty for 5, roll_remainder recipe, process sparks, print success message. If false, give 1 processed spark, process sparks, print a fail message.",
    "condition": { "math": [ "u_vitamin('creative_spark_research')", ">=", "base_difficulty_1" ] },
    "effect": [
      { "math": [ "u_vitamin('creative_spark_research')", "-=", "base_difficulty_1" ] },
      { "math": [ "base_difficulty_1", "+=", "2" ] },
      {
        "u_roll_remainder": [
          "inventor_leg_weight",
          "inventor_jump_boots",
          "inventor_sniper",
          "inventor_shotgun",
          "inventor_pistol",
          "megachette",
          "software_math_inventor",
          "software_electronics_reference_inventor",
          "combatsaw_spear_off",
          "inventor_research_base_2"
        ],
        "type": "recipe",
        "true_eocs": [ "EOC_INVENTOR_MESSAGE_GOOD" ],
        "false_eocs": {
          "id": "EOC_REMOVE_RESEARCH_BASE_1",
          "effect": [
            { "u_forget_recipe": "inventor_research_base_1" },
            {
              "u_message": "You reach the limit of what can be done at this level.  It is time to move forward.",
              "type": "info"
            }
          ]
        }
      },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" }
    ],
    "false_effect": [
      { "u_message": "inventor_fail", "snippet": true, "type": "bad" },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" },
      { "math": [ "u_vitamin('creative_spark_research')", "+=", "1" ] }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_INVENTOR_RESEARCH_BASE_2",
    "condition": { "math": [ "u_vitamin('creative_spark_research')", ">=", "base_difficulty_2" ] },
    "effect": [
      { "math": [ "u_vitamin('creative_spark_research')", "-=", "base_difficulty_2" ] },
      { "math": [ "base_difficulty_2", "+=", "3" ] },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" },
      {
        "u_roll_remainder": [
          "helmet_inventor",
          "inventor_fists",
          "wolf_mask",
          "magnetic_holster",
          "binary_sword",
          "bio_launcher",
          "bio_warhead",
          "trinket_damage",
          "trinket_range",
          "trinket_sound",
          "choke_wideshot",
          "mod_inv_pistol_booster",
          "inventor_research_base_3",
          "inventor_research_energy_1",
          "software_AI"
        ],
        "type": "recipe",
        "true_eocs": [ "EOC_INVENTOR_MESSAGE_GOOD" ],
        "false_eocs": {
          "id": "EOC_REMOVE_RESEARCH_BASE_2",
          "effect": [
            { "u_forget_recipe": "inventor_research_base_2" },
            {
              "u_message": "You reach the limit of what can be done at this level.  It is time to move forward.",
              "type": "info"
            }
          ]
        }
      }
    ],
    "false_effect": [
      { "u_message": "inventor_fail", "snippet": true, "type": "bad" },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" },
      { "math": [ "u_vitamin('creative_spark_research')", "+=", "2" ] }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_INVENTOR_RESEARCH_BASE_3",
    "condition": { "math": [ "u_vitamin('creative_spark_research')", ">=", "base_difficulty_3" ] },
    "effect": [
      { "math": [ "u_vitamin('creative_spark_research')", "-=", "base_difficulty_3" ] },
      { "math": [ "base_difficulty_3", "+=", "4" ] },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" },
      {
        "u_roll_remainder": [
          "inventor_backpack",
          "vision_halo",
          "sonic_gun",
          "mace_magic",
          "inventor_fists_plus",
          "inventor_plasma_axe_off",
          "inventor_research_energy_1"
        ],
        "type": "recipe",
        "true_eocs": [ "EOC_INVENTOR_MESSAGE_GOOD" ],
        "false_eocs": {
          "id": "EOC_REMOVE_RESEARCH_BASE_3",
          "effect": [
            { "u_forget_recipe": "inventor_research_base_3" },
            {
              "u_message": "You reach the limit of what can be done at this level.  It is time to move forward.",
              "type": "info"
            }
          ]
        }
      }
    ],
    "false_effect": [
      { "u_message": "inventor_fail", "snippet": true, "type": "bad" },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" },
      { "math": [ "u_vitamin('creative_spark_research')", "+=", "3" ] }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_INVENTOR_RESEARCH_ENERGY_1",
    "condition": { "math": [ "u_vitamin('creative_spark_research')", ">=", "energy_difficulty_1" ] },
    "effect": [
      { "math": [ "u_vitamin('creative_spark_research')", "-=", "energy_difficulty_1" ] },
      { "math": [ "energy_difficulty_1", "+=", "2" ] },
      {
        "u_roll_remainder": [
          "battery_gun",
          "ray_gun",
          "inventor_light_minus_cell",
          "inventor_light_cell",
          "inventor_medium_cell",
          "inventor_heavy_cell",
          "inventor_welder",
          "heater_tool",
          "inventor_electric_fist",
          "inventor_research_energy_2"
        ],
        "type": "recipe",
        "true_eocs": [ "EOC_INVENTOR_MESSAGE_GOOD" ],
        "false_eocs": {
          "id": "EOC_REMOVE_RESEARCH_ENERGY_1",
          "effect": [
            { "u_forget_recipe": "inventor_research_energy_1" },
            {
              "u_message": "You reach the limit of what can be done at this level.  It is time to move forward.",
              "type": "info"
            }
          ]
        }
      },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" }
    ],
    "false_effect": [
      { "u_message": "inventor_fail", "snippet": true, "type": "bad" },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" },
      { "math": [ "u_vitamin('creative_spark_research')", "+=", "1" ] }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_INVENTOR_RESEARCH_ENERGY_2",
    "condition": { "math": [ "u_vitamin('creative_spark_research')", ">=", "energy_difficulty_2" ] },
    "effect": [
      { "math": [ "u_vitamin('creative_spark_research')", "-=", "energy_difficulty_2" ] },
      { "math": [ "energy_difficulty_2", "+=", "3" ] },
      {
        "u_roll_remainder": [
          "aura_force",
          "ray_rifle",
          "ion_gun",
          "accelerator_gun",
          "inventor_grenade_noise_expl",
          "inventor_grenade_noise_emp",
          "inventor_grenade_noise_fire",
          "heater_gun",
          "inventor_lasmod_close_range",
          "inventor_lasmod_long_range",
          "inventor_lasmod_capasitor",
          "inventor_lasmod_energy_safe",
          "inventor_lasmod_adv_cooler",
          "inventor_lasmod_radiator",
          "inventor_lasmod_chonky_radiator",
          "inventor_lasmod_spooky_heat_sink",
          "inventor_research_energy_3"
        ],
        "type": "recipe",
        "true_eocs": [ "EOC_INVENTOR_MESSAGE_GOOD" ],
        "false_eocs": {
          "id": "EOC_REMOVE_RESEARCH_ENERGY_2",
          "effect": [
            { "u_forget_recipe": "inventor_research_energy_2" },
            {
              "u_message": "You reach the limit of what can be done at this level.  It is time to move forward.",
              "type": "info"
            }
          ]
        }
      },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" }
    ],
    "false_effect": [
      { "u_message": "inventor_fail", "snippet": true, "type": "bad" },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" },
      { "math": [ "u_vitamin('creative_spark_research')", "+=", "2" ] }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_INVENTOR_RESEARCH_ENERGY_3",
    "condition": { "math": [ "u_vitamin('creative_spark_research')", ">=", "energy_difficulty_3" ] },
    "effect": [
      { "math": [ "u_vitamin('creative_spark_research')", "-=", "energy_difficulty_3" ] },
      { "math": [ "energy_difficulty_3", "+=", "4" ] },
      {
        "u_roll_remainder": [
          "inventor_glauncher",
          "inventor_glauncher_fire",
          "inventor_glauncher_elec",
          "inventor_glauncher_direct",
          "death_ray",
          "inventor_lasmod_mega_capasitor",
          "inventor_lasmod_adv_adv_cooler",
          "inventor_lasmod_recuperator",
          "inventor_lasmod_mega_everything",
          "inventor_lasmod_more_capacitors",
          "inventor_research_ai_1"
        ],
        "type": "recipe",
        "true_eocs": [ "EOC_INVENTOR_MESSAGE_GOOD" ],
        "false_eocs": {
          "id": "EOC_REMOVE_RESEARCH_ENERGY_3",
          "effect": [
            { "u_forget_recipe": "inventor_research_energy_3" },
            {
              "u_message": "You reach the limit of what can be done at this level.  It is time to move forward.",
              "type": "info"
            }
          ]
        }
      },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" }
    ],
    "false_effect": [
      { "u_message": "inventor_fail", "snippet": true, "type": "bad" },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" },
      { "math": [ "u_vitamin('creative_spark_research')", "+=", "3" ] }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_INVENTOR_RESEARCH_AI_1",
    "condition": {
      "and": [
        { "math": [ "u_vitamin('creative_spark_research')", ">=", "base_difficulty_3" ] },
        { "math": [ "AI_sparks", ">=", "AI_difficulty_1" ] }
      ]
    },
    "effect": [
      { "math": [ "u_vitamin('creative_spark_research')", "-=", "base_difficulty_3" ] },
      { "math": [ "AI_sparks", "+=", "AI_difficulty_1" ] },
      { "math": [ "base_difficulty_3", "+=", "5" ] },
      { "math": [ "AI_difficulty_1", "+=", "5" ] },
      { "run_eocs": "EOC_INVENTOR_PROCESS_SPARKS" },
      {
        "u_roll_remainder": [ "bot_sniperbot", "bot_shotgunbot", "bot_meleebot" ],
        "type": "recipe",
        "true_eocs": [ "EOC_INVENTOR_MESSAGE_GOOD" ],
        "false_eocs": {
          "id": "EOC_REMOVE_RESEARCH_AI_1",
          "effect": [
            { "u_forget_recipe": "inventor_research_ai_1" },
            {
              "u_message": "You reach the limit of what can be done at this level.  It is time to move forward.",
              "type": "info"
            }
          ]
        }
      }
    ],
    "false_effect": [
      { "u_message": "inventor_fail", "snippet": true, "type": "bad" },
      { "math": [ "u_vitamin('creative_spark_research')", "+=", "4" ] },
      { "math": [ "AI_sparks", "+=", "4" ] }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_INVENTOR_PROCESS_SPARKS",
    "condition": { "math": [ "u_vitamin('creative_spark')", ">", "0" ] },
    "effect": [
      {
        "math": [
          "u_vitamin('creative_spark_research')",
          "+=",
          "u_vitamin('creative_spark') * floor( (base_difficulty_1 + base_difficulty_2 + base_difficulty_3 + energy_difficulty_1 + energy_difficulty_2 + energy_difficulty_3 + AI_difficulty_1 + dimension_difficulty_1) / 8 )"
        ]
      },
      { "math": [ "u_vitamin('creative_spark')", "=", "0" ] },
      {
        "u_message": "creative_spark_research = <u_val:creative_spark_research>,\n base_difficulty_1 = <u_val:base_difficulty_1>,\n base_difficulty_2 = <u_val:base_difficulty_2>,\n base_difficulty_3 = <u_val:base_difficulty_3>,\n energy_difficulty_1 = <u_val:energy_difficulty_1>,\n energy_difficulty_2 = <u_val:energy_difficulty_2>,\n energy_difficulty_3 = <u_val:energy_difficulty_3>,\n dimension_sparks = <u_val:dimension_sparks>,\n dimension_difficulty_1 = <u_val:dimension_difficulty_1>.",
        "type": "debug"
      }
    ],
    "false_effect": [
      {
        "u_message": "creative_spark_research = <u_val:creative_spark_research>,\n base_difficulty_1 = <u_val:base_difficulty_1>,\n base_difficulty_2 = <u_val:base_difficulty_2>,\n base_difficulty_3 = <u_val:base_difficulty_3>,\n energy_difficulty_1 = <u_val:energy_difficulty_1>,\n energy_difficulty_2 = <u_val:energy_difficulty_2>,\n energy_difficulty_3 = <u_val:energy_difficulty_3>,\n dimension_sparks = <u_val:dimension_sparks>,\n dimension_difficulty_1 = <u_val:dimension_difficulty_1>.",
        "type": "debug"
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_INVENTOR_MESSAGE_GOOD",
    "effect": { "u_message": "inventor_success", "snippet": true, "type": "good" }
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_INVENTOR_CRAFTED_DEGRADATION",
    "recurrence": [ "1 d", "2 d" ],
    "global": true,
    "run_for_npcs": true,
    "condition": { "not": { "u_has_trait": "INVENTOR" } },
    "effect": {
      "u_run_inv_eocs": "all",
      "search_data": [ { "flags": [ "INVENTOR_CRAFTED" ] } ],
      "true_eocs": [
        {
          "id": "EOC_RUST_INVENTOR_ITEMS",
          "effect": [
            { "math": [ "n_hp('ALL')", "-=", "2" ] },
            { "message": "You hear a sudden crack!" },
            {
              "u_message": "Your lack of an inventor's aura makes items created by their fevered mind rapidly degrade!"
            },
            { "npc_message": "My items are falling apart!  It isn't me!" }
          ]
        }
      ]
    }
  }
]
