[
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_UPDATE_BLOOD_SPENT_AMOUNTS",
    "recurrence": 1,
    "condition": { "u_has_trait": "DHAMPIR_TRAIT" },
    "deactivate_condition": { "not": { "u_has_trait": "DHAMPIR_TRAIT" } },
    "effect": [
      { "math": [ "u_dhampir_currently_blood_vitamin_level = u_vitamin('human_blood_vitamin')" ] },
      {
        "if": { "math": [ "u_dhampir_currently_blood_vitamin_level < (u_dhampir_previous_blood_vitamin_level - 1)" ] },
        "then": [
          { "math": [ "_temp_value += (u_dhampir_previous_blood_vitamin_level - u_dhampir_currently_blood_vitamin_level)" ] },
          { "u_message": "This round's blood spent was <context_val:temp_value>", "type": "debug" },
          { "math": [ "u_dhampir_blood_spent_compare_value_for_powers += _temp_value" ] }
        ]
      },
      { "math": [ "u_dhampir_previous_blood_vitamin_level = u_vitamin('human_blood_vitamin')" ] }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_CHECK_FOR_POWER_UPGRADES",
    "recurrence": 3600,
    "condition": { "and": [ { "u_has_trait": "DHAMPIR_TRAIT" }, { "math": [ "u_dhampir_blood_spent_compare_value_for_powers > 0" ] } ] },
    "deactivate_condition": { "not": { "u_has_trait": "DHAMPIR_TRAIT" } },
    "effect": [
      {
        "math": [
          "_target_value = (100000 + ( (vampire_total_tier_one_traits() * 5000) + (vampire_total_tier_two_traits() * 7500) + (vampire_total_tier_three_traits() * 10000) ) )"
        ]
      },
      {
        "u_message": "Odds of gaining a new power are <u_val:dhampir_blood_spent_compare_value_for_powers> in <context_val:target_value>.",
        "type": "debug"
      },
      {
        "if": {
          "and": [
            { "not": { "u_has_effect": "sleep" } },
            {
              "x_in_y_chance": { "x": { "math": [ "u_dhampir_blood_spent_compare_value_for_powers" ] }, "y": { "math": [ "_target_value" ] } }
            }
          ]
        },
        "then": { "run_eocs": "EOC_DHAMPIR_GAIN_NEW_POWER" },
        "else": { "math": [ "u_dhampir_blood_spent_compare_value_for_powers -= (rand(2) + 1)" ] }
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_GAIN_NEW_POWER",
    "condition": { "u_has_trait": "DHAMPIR_TRAIT" },
    "effect": [
      {
        "if": { "math": [ "vampire_total_tier_one_traits() + rand(8) > 15" ] },
        "then": { "run_eocs": "EOC_DHAMPIR_GAIN_NEW_POWER_TIER_2" },
        "else": {
          "u_roll_remainder": [
            "EYEGLEAM",
            "STAMINAFORBLOOD",
            "COMMUNE_NIGHT",
            "VAMPIRIC_STRENGTH",
            "VAMPIRIC_RESILIENCE",
            "VAMPIRE_HEIGHTENED_SENSES",
            "VAMPIRE_SILENT_MOVE",
            "VAMPIRE_HEALTH_BONUS",
            "VAMPIRE_SENSE_CHILDREN_OF_THE_NIGHT",
            "DHAMPIR_REDUCED_COLD_TEMPS"
          ],
          "type": "mutation",
          "true_eocs": [ "EOC_DHAMPIR_GAIN_NEW_POWER_MESSAGE", "EOC_DHAMPIR_GAIN_NEW_POWER_RESET_VALUE" ],
          "false_eocs": [
            {
              "id": "EOC_DHAMPIR_GAIN_NEW_POWER_TIER_2",
              "condition": { "u_has_trait": "DHAMPIR_TRAIT" },
              "effect": [
                {
                  "if": { "math": [ "vampire_total_tier_two_traits() + rand(8) > 16" ] },
                  "then": { "run_eocs": "EOC_DHAMPIR_GAIN_NEW_POWER_TIER_3" },
                  "else": {
                    "u_roll_remainder": [
                      "BLOODHEAL",
                      "COAGULANTWEAVE",
                      "VAMPIRIC_DODGE",
                      "VAMPIRIC_STEALTH_BONUS",
                      "VAMPIRE_FEAR_GAZE",
                      "VAMPIRE_FEIGN_DEATH",
                      "VAMPIRE_SEE_HEAT",
                      "VAMPIRE_BLOOD_TEMPORARY_BOOST",
                      "DHAMPIR_FANGS",
                      "DHAMPIR_SLOWFALL",
                      "DHAMPIR_RESIST_DISEASE_POISON_INFECTION"
                    ],
                    "type": "mutation",
                    "true_eocs": [ "EOC_DHAMPIR_GAIN_NEW_POWER_MESSAGE", "EOC_DHAMPIR_GAIN_NEW_POWER_RESET_VALUE", "EOC_DHAMPIR_GAIN_WEAKNESSES_TIER_2" ],
                    "false_eocs": [
                      {
                        "id": "EOC_DHAMPIR_GAIN_NEW_POWER_TIER_3",
                        "condition": { "u_has_trait": "DHAMPIR_TRAIT" },
                        "effect": [
                          {
                            "u_roll_remainder": [
                              "BLOODHASTE",
                              "MAGICFORBLOOD",
                              "HYPNOTIC_GAZE",
                              "VAMPIRE_COMMAND_BEAST",
                              "VAMPIRE_CARDIO_BONUS",
                              "VAMPIRE_MOTION_ALARM",
                              "VAMPIRE_BONUS_HP",
                              "DHAMPIR_REDUCED_PAIN",
                              "DHAMPIR_MEND_WOUNDS_FASTER",
                              "DHAMPIR_AVOID_EAT_SLEEP_DRINK"
                            ],
                            "type": "mutation",
                            "true_eocs": [ "EOC_DHAMPIR_GAIN_NEW_POWER_MESSAGE", "EOC_DHAMPIR_GAIN_NEW_POWER_RESET_VALUE", "EOC_DHAMPIR_GAIN_WEAKNESSES_TIER_3" ],
                            "false_eocs": [  ]
                          }
                        ]
                      }
                    ]
                  }
                }
              ]
            }
          ]
        }
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_GAIN_NEW_POWER_MESSAGE",
    "effect": [ { "u_message": "You have unlocked a new ability from your use of your tainted blood.", "type": "mixed" } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_GAIN_NEW_WEAKNESS_MESSAGE",
    "effect": [ { "u_message": "You use of your vampiric powers has caused you to gain a new frailty.", "type": "bad" } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_GAIN_NEW_POWER_RESET_VALUE",
    "effect": [ { "math": [ "u_dhampir_blood_spent_compare_value_for_powers = 0" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_GAIN_WEAKNESSES_TIER_2",
    "condition": { "math": [ "u_dhampir_have_tier_2_weakness != 1" ] },
    "effect": [ { "run_eocs": "EOC_DHAMPIR_GAIN_WEAKNESSES" }, { "math": [ "u_dhampir_have_tier_2_weakness = 1" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_GAIN_WEAKNESSES_TIER_3",
    "condition": { "math": [ "u_dhampir_have_tier_3_weakness != 1" ] },
    "effect": [ { "run_eocs": "EOC_DHAMPIR_GAIN_WEAKNESSES" }, { "math": [ "u_dhampir_have_tier_3_weakness = 1" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_GAIN_WEAKNESSES",
    "condition": { "math": [ "u_dhampir_have_ever_drunk_blood == 0" ] },
    "effect": [
      {
        "u_roll_remainder": [
          "DHAMPIR_WEAKNESS_SUN_SENSITIVITY",
          "DHAMPIR_WEAKNESS_SUN_SLEEPINESS",
          "DHAMPIR_WEAKNESS_SLOW_HEALING",
          "DHAMPIR_WEAKNESS_ANIMAL_DISCORD",
          "DHAMPIR_WEAKNESS_WATER_PAIN",
          "DHAMPIR_WEAKNESS_CORPSELIKE_PALLOR"
        ],
        "type": "mutation",
        "true_eocs": [ "EOC_DHAMPIR_GAIN_NEW_WEAKNESS_MESSAGE" ],
        "false_eocs": [  ]
      }
    ],
    "false_effect": [
      {
        "u_roll_remainder": [
          "DHAMPIR_WEAKNESS_SUN_SENSITIVITY",
          "DHAMPIR_WEAKNESS_SUN_SLEEPINESS",
          "DHAMPIR_WEAKNESS_SLOW_HEALING",
          "DHAMPIR_WEAKNESS_ANIMAL_DISCORD",
          "DHAMPIR_WEAKNESS_WATER_PAIN",
          "DHAMPIR_WEAKNESS_CORPSELIKE_PALLOR",
          "DHAMPIR_WEAKNESS_BLOODTHIRST",
          "DHAMPIR_WEAKNESS_OVERWHELMING_ARROGANCE",
          "DHAMPIR_WEAKNESS_SLOWER_BLOOD_GAIN",
          "DHAMPIR_WEAKNESS_LOWER_KCAL_FROM_FOOD"
        ],
        "type": "mutation",
        "true_eocs": [ "EOC_DHAMPIR_GAIN_NEW_WEAKNESS_MESSAGE" ],
        "false_eocs": [  ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_WEAKNESS_BLOODLUST_CHECKS",
    "recurrence": [ 900, 129600 ],
    "condition": { "u_has_trait": "DHAMPIR_WEAKNESS_BLOODTHIRST" },
    "deactivate_condition": { "not": { "u_has_trait": "DHAMPIR_WEAKNESS_BLOODTHIRST" } },
    "effect": [
      {
        "u_add_morale": "morale_craving_human_blood",
        "bonus": -30,
        "max_bonus": -90,
        "duration": "360 m",
        "decay_start": "180 m"
      },
      { "u_add_effect": "effect_dhampir_bloodlust_cravings", "duration": { "math": [ "rng(10800,21600)" ] } },
      { "u_message": "Crimson clouds your vision as you are overcome with an urge to drink blood.", "type": "bad" }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_FANGS_activated",
    "effect": [ { "math": [ "u_spell_level('vampire_drink_blood_with_fangs_spell') = 0" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_FANGS_deactivated",
    "effect": [ { "math": [ "u_spell_level('vampire_drink_blood_with_fangs_spell') = -1" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_AVOID_EAT_SLEEP_DRINK_activated",
    "condition": { "math": [ "u_vitamin('human_blood_vitamin') > 0" ] },
    "effect": [
      { "math": [ "u_dhampir_avoid_eat_sleep_drink_counter = 0" ] },
      { "math": [ "u_dhampir_avoid_eat_sleep_drink_long_counter = 0" ] }
    ],
    "false_effect": [
      { "u_message": "You have not enough power in your blood to sustain yourself.", "type": "bad" },
      { "run_eocs": "EOC_DHAMPIR_AVOID_EAT_SLEEP_DRINK_deactivate_future", "time_in_future": 0 }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_AVOID_EAT_SLEEP_DRINK_deactivate_future",
    "//": "This is necessary because calling u_deactivate_trait from within the trait EoC does not work",
    "effect": { "u_deactivate_trait": "DHAMPIR_AVOID_EAT_SLEEP_DRINK" }
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_AVOID_EAT_SLEEP_DRINK_periodic",
    "effect": [
      { "math": [ "u_dhampir_avoid_eat_sleep_drink_counter", "++" ] },
      { "math": [ "u_dhampir_avoid_eat_sleep_drink_long_counter", "++" ] },
      {
        "if": {
          "and": [
            "u_is_outside",
            "is_day",
            { "or": [ { "is_weather": "sunny" }, { "is_weather": "clear" } ] },
            {
              "or": [
                { "math": [ "(u_dhampir_avoid_eat_sleep_drink_counter / 15) == 1" ] },
                { "math": [ "(u_dhampir_avoid_eat_sleep_drink_counter / 15) == 2" ] },
                { "math": [ "(u_dhampir_avoid_eat_sleep_drink_counter / 15) == 3" ] }
              ]
            }
          ]
        },
        "then": [ { "math": [ "u_vitamin('human_blood_vitamin') --" ] } ]
      },
      {
        "if": { "math": [ "(u_dhampir_avoid_eat_sleep_drink_counter / 60) == 1" ] },
        "then": [
          { "math": [ "u_vitamin('human_blood_vitamin') --" ] },
          { "math": [ "u_dhampir_avoid_eat_sleep_drink_counter = 0" ] },
          { "if": { "math": [ "u_calories()", "<", "118000" ] }, "then": { "math": [ "u_calories()", "+=", "2" ] } },
          { "math": [ "u_val('sleep_deprivation') = 0" ] }
        ]
      },
      {
        "if": { "math": [ "u_vitamin('human_blood_vitamin') <= 0" ] },
        "then": { "run_eocs": "EOC_DHAMPIR_AVOID_EAT_SLEEP_DRINK_deactivate_future", "time_in_future": 0 }
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DHAMPIR_AVOID_EAT_SLEEP_DRINK_deactivated",
    "effect": [
      {
        "u_message": "You feel a wave of tiredness as you allow mortal needs to assert their will once again.",
        "type": "bad"
      },
      { "math": [ "u_val('sleepiness')", "+=", "min( (u_dhampir_avoid_eat_sleep_drink_long_counter / 200), 700)" ] },
      { "math": [ "u_calories()", "-=", "min( (u_dhampir_avoid_eat_sleep_drink_long_counter * 0.06), 10000)" ] },
      {
        "math": [
          "u_calories('dont_affect_weariness': true)",
          "+=",
          "min( (u_dhampir_avoid_eat_sleep_drink_long_counter * 0.06), 10000)"
        ]
      }
    ]
  }
]
