diff --git a/doc/MAGIC.md b/doc/MAGIC.md index e7486a851b94c..06ca89ec98476 100644 --- a/doc/MAGIC.md +++ b/doc/MAGIC.md @@ -878,6 +878,7 @@ Character status value | Description `POWER_TRICKLE` | Generates this amount of millijoules each second. Default value is zero, so better to use `add` `RANGE` | Modifies your characters range with firearms `RANGED_DAMAGE` | Adds damage to ranged attacks. +`RANGE_DODGE` | Chance to dodge projectile attack, no matter of it's speed; Consumes dodges similarly to melee dodges, and fails, if character has no dodges left. `add` and `multiply` behave equally. `add: 0.5` would result in 50% chance to avoid projectile `READING_EXP` | Changes the minimum you learn from each reading increment. `READING_SPEED_MULTIPLIER` | Changes how fast you can read books; Lesser value means faster book reading, with cap of 1 second. `RECOIL_MODIFIER` | Affects recoil when shooting a gun. Positive value increase the dispersion, negative decrease one. diff --git a/src/creature.cpp b/src/creature.cpp index 440b023756b80..b00c36879488a 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -1243,6 +1243,12 @@ void Creature::deal_projectile_attack( Creature *source, dealt_projectile_attack on_try_dodge(); // There's a dodge roll in accuracy_projectile_attack() } + // Supernatural dodges + double range_dodge_chance = enchantment_cache->modify_value( enchant_vals::mod::RANGE_DODGE, 1 ) - 1.0f; + if ( x_in_y( range_dodge_chance, 1.0f ) ) { + on_try_dodge(); + } + if( goodhit >= 1.0 && !magic ) { attack.missed_by = 1.0; // Arbitrary value if( !print_messages ) { diff --git a/src/magic_enchantment.cpp b/src/magic_enchantment.cpp index 5baf8e186c28f..0b13714a8279a 100644 --- a/src/magic_enchantment.cpp +++ b/src/magic_enchantment.cpp @@ -76,6 +76,7 @@ namespace io case enchant_vals::mod::REGEN_HP: return "REGEN_HP"; case enchant_vals::mod::REGEN_HP_AWAKE: return "REGEN_HP_AWAKE"; case enchant_vals::mod::MUT_INSTABILITY_MOD: return "MUT_INSTABILITY_MOD"; + case enchant_vals::mod::RANGE_DODGE: return "RANGE_DODGE"; case enchant_vals::mod::HUNGER: return "HUNGER"; case enchant_vals::mod::THIRST: return "THIRST"; case enchant_vals::mod::SLEEPINESS: return "SLEEPINESS"; diff --git a/src/magic_enchantment.h b/src/magic_enchantment.h index bf6bd747e3dda..a9cb95f5d88af 100644 --- a/src/magic_enchantment.h +++ b/src/magic_enchantment.h @@ -49,6 +49,7 @@ enum class mod : int { FAT_TO_MAX_HP, CARDIO_MULTIPLIER, MUT_INSTABILITY_MOD, + RANGE_DODGE, MAX_HP, // for all limbs! use with caution REGEN_HP, REGEN_HP_AWAKE,