Skip to content

Commit

Permalink
add enchantment for range dodges
Browse files Browse the repository at this point in the history
  • Loading branch information
GuardianDll authored Aug 26, 2024
1 parent a0579c0 commit ab5a6df
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/MAGIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check failure on line 1247 in src/creature.cpp

View workflow job for this annotation

GitHub Actions / Basic Build and Test (Clang 10, Ubuntu, Curses)

use of undeclared identifier 'enchantment_cache'
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 ) {
Expand Down
1 change: 1 addition & 0 deletions src/magic_enchantment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions src/magic_enchantment.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ab5a6df

Please sign in to comment.