Skip to content

Commit

Permalink
More enchantments (CleverRaven#71976)
Browse files Browse the repository at this point in the history
* More enchantments

* tweak

* how did i miss it?

* refine doc
  • Loading branch information
GuardianDll authored Feb 27, 2024
1 parent a1a610b commit 2915fb1
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 63 deletions.
3 changes: 2 additions & 1 deletion data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,8 @@
"occupied_bodyparts": [ [ "head", 2 ] ],
"mutation_conflicts": [ "BATEARS" ],
"flags": [ "BIONIC_TOGGLED", "IMMUNE_HEARING_DAMAGE" ],
"active_flags": [ "SUPER_HEARING" ],
"active_flags": [ "SAFECRACK_NO_TOOL" ],
"enchantments": [ { "condition": "ACTIVE", "values": [ { "value": "HEARING_MULT", "multiply": 2.5 } ] } ],
"auto_deactivates": [ "bio_earplugs" ],
"included_bionics": [ "bio_earplugs" ],
"activated_on_install": true
Expand Down
2 changes: 2 additions & 0 deletions data/json/effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@
"desc": [ "You are wearing earphones and can't hear much from outside world." ],
"rating": "bad",
"limb_score_mods": [ { "limb_score": "reaction", "modifier": 0.9 } ],
"enchantments": [ { "values": [ { "value": "HEARING_MULT", "multiply": -0.75 } ] } ],
"flags": [ "EFFECT_LIMB_SCORE_MOD" ]
},
{
Expand Down Expand Up @@ -3333,6 +3334,7 @@
"apply_message": "You feel lightheaded.",
"miss_messages": [ [ "That critter's jumping around like a jitterbug! It needs to mellow out.", 1 ] ],
"base_mods": { "per_mod": [ -1 ] },
"enchantments": [ { "values": [ { "value": "VOMIT_MUL", "multiply": -0.9 } ] } ],
"blood_analysis_description": "Intoxicant: THC"
},
{
Expand Down
7 changes: 6 additions & 1 deletion data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@
"description": "Your broad, pointed ears are like radar dishes. You can hear even the slightest sounds at great distance, and are less likely to be deafened by loud noises.",
"types": [ "HEARING" ],
"//": "Super_hearing multiplies hearing by 3.5 and let you crack safes. A bat mutant is a bit better at hearing overall than someone with GOODHEARING and a CBM.",
"flags": [ "HEARING_PROTECTION", "SUPER_HEARING" ],
"flags": [ "HEARING_PROTECTION", "SAFECRACK_NO_TOOL" ],
"prereqs": [ "GOODHEARING" ],
"category": [ "CHIROPTERAN" ],
"hearing_modifier": 1.8
Expand Down Expand Up @@ -6204,6 +6204,7 @@
"prereqs2": [ "AMORPHOUS" ],
"threshreq": [ "THRESH_SLIME" ],
"category": [ "SLIME" ],
"enchantments": [ { "values": [ { "value": "HEARING_MULT", "multiply": { "math": [ "rng(-0.75, 1)" ] } } ] } ],
"passive_mods": { "per_mod": -8 }
},
{
Expand Down Expand Up @@ -7889,6 +7890,7 @@
"name": { "str": "Shouter" },
"points": -2,
"description": "You occasionally shout uncontrollably.",
"enchantments": [ { "values": [ { "value": "SHOUT_NOISE_BASE", "add": 2 } ] } ],
"changes_to": [ "SHOUT2" ],
"category": [ "RAPTOR", "BEAST", "CHIMERA", "LUPINE" ]
},
Expand All @@ -7898,6 +7900,7 @@
"name": { "str": "Screamer" },
"points": -3,
"description": "You sometimes scream uncontrollably.",
"enchantments": [ { "values": [ { "value": "SHOUT_NOISE_BASE", "add": 5 }, { "value": "SHOUT_NOISE_STR_MULT", "add": 1 } ] } ],
"prereqs": [ "SHOUT1" ],
"changes_to": [ "SHOUT3" ],
"category": [ "BEAST", "CHIMERA", "LUPINE" ]
Expand All @@ -7908,6 +7911,7 @@
"name": { "str": "Howler" },
"points": -4,
"description": "You frequently let out a piercing howl.",
"enchantments": [ { "values": [ { "value": "SHOUT_NOISE_BASE", "add": 10 }, { "value": "SHOUT_NOISE_STR_MULT", "add": 2 } ] } ],
"prereqs": [ "SHOUT2" ],
"category": [ "CHIMERA", "LUPINE" ]
},
Expand Down Expand Up @@ -9437,6 +9441,7 @@
"name": { "str": "Booming Voice" },
"points": 1,
"description": "You know how to project your voice. You are able to shout much louder than the average person.",
"enchantments": [ { "values": [ { "value": "SHOUT_NOISE_BASE", "add": 10 }, { "value": "SHOUT_NOISE_STR_MULT", "add": 1 } ] } ],
"category": [ "BEAST" ]
},
{
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Magiclysm/mutations/fantasy_species.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
"types": [ "HEARING" ],
"category": [ "SPECIES_ELF" ],
"threshreq": [ "THRESH_SPECIES_ELF" ],
"flags": [ "SUPER_HEARING" ],
"flags": [ "SAFECRACK_NO_TOOL" ],
"hearing_modifier": 1.75
},
{
Expand Down
2 changes: 1 addition & 1 deletion data/mods/MindOverMatter/effects/effects_potions.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"max_duration": "30 hours",
"max_intensity": 1,
"base_mods": { "per_mod": [ 4 ] },
"flags": [ "SEESLEEP", "SUPER_HEARING", "IMMUNE_HEARING_DAMAGE" ],
"flags": [ "SEESLEEP", "SAFECRACK_NO_TOOL", "IMMUNE_HEARING_DAMAGE" ],
"enchantments": [ "enchant_clair_potion" ]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"id": "enchant_clair_potion",
"condition": "ALWAYS",
"has": "HELD",
"values": [ { "value": "BONUS_DODGE", "add": 1 } ],
"values": [ { "value": "BONUS_DODGE", "add": 1 }, { "value": "HEARING_MULT", "multiply": 2.5 } ],
"intermittent_activation": { "effects": [ { "frequency": "2 seconds", "spell_effects": [ { "id": "clair_potion_clairvoyance" } ] } ] }
},
{
Expand Down
2 changes: 1 addition & 1 deletion doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ Character flags can be `trait_id`, `json_flag_id` or `flag_id`. Some of these a
- ```STRICT_HUMANITARIAN``` You can eat foodstuffs tagged with `STRICT_HUMANITARIANISM` without morale penalties.
- ```SUNBURN``` TBD, probably related to `ALBINO`.
- ```SUPER_CLAIRVOYANCE``` Gives a super clairvoyance effect (works with multiple z-levels), used for debug purposes.
- ```SUPER_HEARING``` You can hear much better than a normal person.
- ```SAFECRACK_NO_TOOL``` Allows to open safes without stethoscope.
- ```TELEPORT_LOCK``` You cannot teleport. This has none of the protective effects of `DIMENSIONAL_ANCHOR`.
- ```THERMOMETER``` You always know what temperature it is.
- ```TINY``` Changes your size to `creature_size::tiny`. Checked first of the size category flags.
Expand Down
22 changes: 17 additions & 5 deletions doc/MAGIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ Character status value | Description
`FATIGUE` |
`FOOTSTEP_NOISE` |
`FORCEFIELD` | Chance your character reduces incoming damage to 0. From 0.0 (no chance), to 1.0 (100% chance to avoid attacks).
`HUNGER` |
`HUNGER` | Affects how fast you hunger level changes. Do not affect actual calorie burn, `METABOLISM` field respond for this
`KNOCKBACK_RESIST` | The amount knockback effects you, 0 is the regular amount, -100 would be double effect, 100 would be no effect.
`KNOCKDOWN_RESIST` | The amount knockdown effects you, currently *only* having 100 or greater knockdown_resist makes you immune to knockdown.
`LEARNING_FOCUS` | Amount of bonus focus you have for learning purposes.
Expand All @@ -838,14 +838,19 @@ Character status value | Description
`MAX_STAMINA` |
`MELEE_DAMAGE` |
`RANGED_DAMAGE` | Adds damage to ranged attacks.
`METABOLISM` |
`METABOLISM` | Affects your bmr
`MOD_HEALTH` | If this is anything other than zero (which it defaults to) you will to mod your health to a max/min of `MOD_HEALTH_CAP` every half hour.
`MOD_HEALTH_CAP` | If this is anything other than zero (which it defaults to) you will cap your `MOD_HEALTH` gain/loss at this every half hour.
`MOVE_COST` |
`MOVE_COST` | How much moves you spend to move 1 tile (doesn't affect any another actions); default 100; `"add": 100` would make you spend twice as much moves to move 1 tile
`MOVECOST_SWIM_MOD` | How much moves you spend to move 1 tile in water; not shown in UI
`MOVECOST_OBSTACLE_MOD` | How much moves you spend to move 1 tile, if this tile has movecost more than 105 moves; not shown in UI
`MOVECOST_FLATGROUND_MOD`| How much moves you spend to move 1 tile at flat ground; shown in UI
`OVERKILL_DAMAGE` | multiplies or contributes to the damage to an enemy corpse after death. The lower the number, the more damage caused.
`PAIN` | When gaining pain the amount gained will be modified by this much. You will still always gain at least 1 pain.
`PAIN_REMOVE` | When pain naturally decreases every five minutes the chance of pain removal will be modified by this much. You will still always have at least a chance to reduce pain.
`SHOUT_NOISE` |
`SHOUT_NOISE` | Formula for shout noise level is `noise = base + (str_cur * shout_multiplier)`; `SHOUT_NOISE` modifies `noise`, after all calculations are done
`SHOUT_NOISE_BASE` | `SHOUT_NOISE_BASE` modifies `base`
`SHOUT_NOISE_STR_MULT` | `SHOUT_NOISE_STR_MULT` modifies the `shout_multiplier`, that affect how much your strength affects the noise level
`SIGHT_RANGE_ELECTRIC` | How many tiles away is_electric() creatures are visible from.
`SIGHT_RANGE_FAE` | How many tiles away creatures with the FAE_CREATURE monster flag or FAERIECREATURE trait are visible from.
`SIGHT_RANGE_NETHER` | How many tiles away is_nether() creatures are visible from.
Expand All @@ -865,14 +870,21 @@ Character status value | Description
`REGEN_STAMINA` |
`THIRST` |
`WEAPON_DISPERSION` | Positive value increase the dispersion, negative decrease one.
`NIGHT_VIS` | How good you can see in the darkness.
`HEARING_MULT` | How good you can hear. Remember that increased hearing means you would have a bigger "noise" written in UI; default step noise of 6, multiplied 10 times, would show it as 60
`BANDAGE_BONUS` | Affects the `bandages_power` you have when apply the medicine.
`DISINFECTANT_BONUS` | Affects the `disinfectant_power` you have when apply the medicine.
`BLEED_STOP_BONUS` | Affects the `bleed` level when apply the medicine.
`UGLINESS` | Affects your `ugliness` stat, that respond for NPCs opinion about you.
`VOMIT_MUL` | Affects your chances to vomit.
`OVERMAP_SIGHT` | Increases the amount of overmap tiles you can see around.
`STEALTH_MODIFIER` | Same as mutation `stealth_modifier` value, amount to be subtracted from player's visibility range, capped to 60. Negative values work, but are not very effective due to the way vision ranges are capped.
`MENDING_MODIFIER` | Changes the speed of your limb mend. Since it's a percent, using `multiply` is recommended.
`KCAL` | Same as bio_digestion effect, increases the amount of calories obrained from the food.
`VITAMIN_ABSORB_MOD` | Increases amount of vitamins obtained from the food
`READING_SPEED_MULTIPLIER` | Changes how fast you can read books; Lesser value means faster book reading, with cap of 1 second.
`MELEE_STAMINA_CONSUMPTION` | Changes amount of stamina used when swing in melee; stamina consumption is a negative value, so `"add": 100` decreases amount of stamina consumed, when `"add": -100` increases it; `"multiply": 1` increases, `"multiply": -0.5` decreases it. Can't be bigger than -50.
`OBTAIN_COST_MULTIPLIER` | same as `obtain_cost_multiplier`, modifier for pulling an item from a container and storing it back, as a handling penalty. `"add": 100` add 100 additional moves to item wield (1 second)
`OBTAIN_COST_MULTIPLIER` | Same as `obtain_cost_multiplier`, modifier for pulling an item from a container and storing it back, as a handling penalty. `"add": 100` add 100 additional moves to item wield (1 second)
`STOMACH_SIZE_MULTIPLIER` | Same as mutation `stomach_size_multiplier` field, changes how much food you can consume at once. `"add": 1000` adds 1 L to stomach size
`CASTING_TIME_MULTIPLIER` | Same as mutation `casting_time_multiplier` field, changes your casting speed. Since it's a percent, using `multiply` is recommended. `"multiply": 2"` triples the casting speed
`CRAFTING_SPEED_MULTIPLIER` | Same as mutation `crafting_speed_multiplier` field, changes your crafting speed. Since it's a percent, using `multiply` is recommended. Positive values decrease crafting time, negative values increase it.
Expand Down
4 changes: 2 additions & 2 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static const itype_id itype_stick_long( "stick_long" );
static const itype_id itype_water( "water" );
static const itype_id itype_water_clean( "water_clean" );

static const json_character_flag json_flag_SUPER_HEARING( "SUPER_HEARING" );
static const json_character_flag json_flag_SAFECRACK_NO_TOOL( "SAFECRACK_NO_TOOL" );

static const move_mode_id move_mode_prone( "prone" );
static const move_mode_id move_mode_walk( "walk" );
Expand Down Expand Up @@ -3361,7 +3361,7 @@ void safecracking_activity_actor::start( player_activity &act, Character &who )

void safecracking_activity_actor::do_turn( player_activity &act, Character &who )
{
bool can_crack = who.has_flag( json_flag_SUPER_HEARING );
bool can_crack = who.has_flag( json_flag_SAFECRACK_NO_TOOL );
// short-circuit to avoid the more expensive iteration over items
can_crack = can_crack || who.cache_has_item_with( flag_SAFECRACK );

Expand Down
63 changes: 23 additions & 40 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ static const efftype_id effect_disinfected( "disinfected" );
static const efftype_id effect_disrupted_sleep( "disrupted_sleep" );
static const efftype_id effect_downed( "downed" );
static const efftype_id effect_drunk( "drunk" );
static const efftype_id effect_earphones( "earphones" );
static const efftype_id effect_fearparalyze( "fearparalyze" );
static const efftype_id effect_flu( "flu" );
static const efftype_id effect_foodpoison( "foodpoison" );
Expand Down Expand Up @@ -266,7 +265,6 @@ static const efftype_id effect_subaquatic_sonar( "subaquatic_sonar" );
static const efftype_id effect_tapeworm( "tapeworm" );
static const efftype_id effect_tied( "tied" );
static const efftype_id effect_transition_contacts( "transition_contacts" );
static const efftype_id effect_weed_high( "weed_high" );
static const efftype_id effect_winded( "winded" );

static const faction_id faction_no_faction( "no_faction" );
Expand Down Expand Up @@ -329,7 +327,6 @@ static const json_character_flag json_flag_SEESLEEP( "SEESLEEP" );
static const json_character_flag json_flag_STEADY( "STEADY" );
static const json_character_flag json_flag_STOP_SLEEP_DEPRIVATION( "STOP_SLEEP_DEPRIVATION" );
static const json_character_flag json_flag_SUPER_CLAIRVOYANCE( "SUPER_CLAIRVOYANCE" );
static const json_character_flag json_flag_SUPER_HEARING( "SUPER_HEARING" );
static const json_character_flag json_flag_TOUGH_FEET( "TOUGH_FEET" );
static const json_character_flag json_flag_UNCANNY_DODGE( "UNCANNY_DODGE" );
static const json_character_flag json_flag_WALK_UNDERWATER( "WALK_UNDERWATER" );
Expand Down Expand Up @@ -404,7 +401,6 @@ static const trait_id trait_ANTENNAE( "ANTENNAE" );
static const trait_id trait_AQUEOUS( "AQUEOUS" );
static const trait_id trait_BADBACK( "BADBACK" );
static const trait_id trait_BIRD_EYE( "BIRD_EYE" );
static const trait_id trait_BOOMING_VOICE( "BOOMING_VOICE" );
static const trait_id trait_CANNIBAL( "CANNIBAL" );
static const trait_id trait_CENOBITE( "CENOBITE" );
static const trait_id trait_CEPH_VISION( "CEPH_VISION" );
Expand Down Expand Up @@ -1435,8 +1431,10 @@ int Character::swim_speed() const
( usable.test( body_part_hand_r ) ? 0.5f : 0.0f );

// base swim speed.
ret = ( 440 * mutation_value( "movecost_swim_modifier" ) ) + weight_carried() /
( 60_gram / mutation_value( "movecost_swim_modifier" ) ) - 50 * get_skill_level( skill_swimming );
float swim_speed_mult = enchantment_cache->modify_value( enchant_vals::mod::MOVECOST_SWIM_MOD,
mutation_value( "movecost_swim_modifier" ) );
ret = ( 440 * swim_speed_mult ) + weight_carried() /
( 60_gram / swim_speed_mult ) - 50 * get_skill_level( skill_swimming );
/** @EFFECT_STR increases swim speed bonus from PAWS */
if( has_trait( trait_PAWS ) ) {
ret -= hand_bonus_mult * ( 20 + str_cur * 3 );
Expand Down Expand Up @@ -2653,6 +2651,8 @@ float Character::get_vision_threshold( float light_level ) const
range++;
}

range = enchantment_cache->modify_value( enchant_vals::mod::NIGHT_VIS, range );

// Clamp range to 1+, so that we can always see where we are
range = std::max( 1.0f, range * get_limb_score( limb_score_night_vis ) );

Expand Down Expand Up @@ -7538,17 +7538,9 @@ int Character::get_shout_volume() const
int base = 10;
int shout_multiplier = 2;

// Mutations make shouting louder, they also define the default message
if( has_trait( trait_SHOUT3 ) ) {
shout_multiplier = 4;
base = 20;
} else if( has_trait( trait_SHOUT2 ) ) {
base = 15;
shout_multiplier = 3;
}
if( has_trait( trait_BOOMING_VOICE ) ) {
base += 10;
}
base = enchantment_cache->modify_value( enchant_vals::mod::SHOUT_NOISE_BASE, base );
shout_multiplier = enchantment_cache->modify_value( enchant_vals::mod::SHOUT_NOISE_STR_MULT,
shout_multiplier );

// You can't shout without your face
if( has_trait( trait_PROF_FOODP ) && !( is_wearing( itype_foodperson_mask ) ||
Expand Down Expand Up @@ -10421,8 +10413,9 @@ std::vector<run_cost_effect> Character::run_cost_effects( float &movecost ) cons
}

if( movecost > 105 ) {
run_cost_effect_mul( mutation_value( "movecost_obstacle_modifier" ),
_( "Obstacle Muts" ) );
float obstacle_mult = enchantment_cache->modify_value( enchant_vals::mod::MOVECOST_OBSTACLE_MOD,
mutation_value( "movecost_obstacle_modifier" ) );
run_cost_effect_mul( obstacle_mult, _( "Obstacle Muts." ) );

if( has_proficiency( proficiency_prof_parkour ) ) {
run_cost_effect_mul( 0.5, _( "Parkour" ) );
Expand Down Expand Up @@ -10452,8 +10445,9 @@ std::vector<run_cost_effect> Character::run_cost_effects( float &movecost ) cons
run_cost_effect_mul( mutation_value( "movecost_modifier" ), _( "Mutations" ) );

if( flatground ) {
run_cost_effect_mul( mutation_value( "movecost_flatground_modifier" ),
_( "Flat Ground Mut." ) );
float flatground_mult = enchantment_cache->modify_value( enchant_vals::mod::MOVECOST_FLATGROUND_MOD,
mutation_value( "movecost_flatground_modifier" ) );
run_cost_effect_mul( flatground_mult, _( "Flat Ground Mut." ) );
}

if( has_trait( trait_PADDED_FEET ) && is_barefoot() ) {
Expand Down Expand Up @@ -10873,28 +10867,16 @@ float Character::hearing_ability() const
{
float volume_multiplier = 1.0f;

// Mutation/Bionic volume modifiers
if( has_flag( json_flag_SUPER_HEARING ) ) {
volume_multiplier *= 3.5f;
}
if( has_trait( trait_PER_SLIME ) ) {
// Random hearing :-/
// (when it's working at all, see player.cpp)
// changed from 0.5 to fix Mac compiling error
volume_multiplier *= rng( 1, 2 );
}

volume_multiplier *= Character::mutation_value( "hearing_modifier" );

volume_multiplier = enchantment_cache->modify_value( enchant_vals::mod::HEARING_MULT,
volume_multiplier );

if( has_effect( effect_deaf ) ) {
// Scale linearly up to 30 minutes
volume_multiplier *= ( 30_minutes - get_effect_dur( effect_deaf ) ) / 30_minutes;
}

if( has_effect( effect_earphones ) ) {
volume_multiplier *= 0.25f;
}

return volume_multiplier;
}

Expand Down Expand Up @@ -11448,10 +11430,11 @@ void Character::stagger()

double Character::vomit_mod()
{
double mod = mutation_value( "vomit_multiplier" );
if( has_effect( effect_weed_high ) ) {
mod *= .1;
}
double mod = 1;
mod *= mutation_value( "vomit_multiplier" );

mod = enchantment_cache->modify_value( enchant_vals::mod::VOMIT_MUL, mod );

// If you're already nauseous, any food in your stomach greatly
// increases chance of vomiting. Liquids don't provoke vomiting, though.
if( stomach.contains() != 0_ml && has_effect( effect_nausea ) ) {
Expand Down
4 changes: 2 additions & 2 deletions src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static const json_character_flag json_flag_ATTUNEMENT( "ATTUNEMENT" );
static const json_character_flag json_flag_GLIDE( "GLIDE" );
static const json_character_flag json_flag_LEVITATION( "LEVITATION" );
static const json_character_flag json_flag_PAIN_IMMUNE( "PAIN_IMMUNE" );
static const json_character_flag json_flag_SUPER_HEARING( "SUPER_HEARING" );
static const json_character_flag json_flag_SAFECRACK_NO_TOOL( "SAFECRACK_NO_TOOL" );
static const json_character_flag json_flag_WING_GLIDE( "WING_GLIDE" );

static const material_id material_bone( "bone" );
Expand Down Expand Up @@ -1723,7 +1723,7 @@ void iexamine::pit_covered( Character &you, const tripoint &examp )
*/
void iexamine::safe( Character &you, const tripoint &examp )
{
bool has_cracking_tool = you.has_flag( json_flag_SUPER_HEARING );
bool has_cracking_tool = you.has_flag( json_flag_SAFECRACK_NO_TOOL );
// short-circuit to avoid the more expensive iteration over items
has_cracking_tool = has_cracking_tool || you.cache_has_item_with( flag_SAFECRACK );

Expand Down
Loading

0 comments on commit 2915fb1

Please sign in to comment.