Skip to content

Commit

Permalink
Unhardcode bio_memory, add several enchantments (#47656)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramza13 authored Jul 10, 2021
1 parent 81fba63 commit 43466bd
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 44 deletions.
14 changes: 13 additions & 1 deletion data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -1002,10 +1002,22 @@
"description": "Your memory has been enhanced with small quantum storage drives. While active, you learn - both through reading and practice - more quickly. Additionally, you can't forget skills you've already learned, and the layout of terrain you've explored will remain in your memory for an incredibly long time.",
"occupied_bodyparts": [ [ "head", 3 ] ],
"flags": [ "BIONIC_TOGGLED", "BIONIC_SLEEP_FRIENDLY" ],
"active_flags": [ "CBQ_LEARN_BONUS" ],
"act_cost": "2 J",
"react_cost": "2 J",
"trigger_cost": "25 J",
"time": 1
"time": 1,
"enchantments": [
{
"condition": "ACTIVE",
"values": [
{ "value": "MAP_MEMORY", "add": 49 },
{ "value": "READING_EXP", "add": 2 },
{ "value": "SKILL_RUST_RESIST", "add": 20 },
{ "value": "LEARNING_FOCUS", "add": 10 }
]
}
]
},
{
"id": "bio_metabolics",
Expand Down
14 changes: 8 additions & 6 deletions data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@
"description": "You have a flexible mind, allowing you to learn skills much faster than others. Note that this only applies to real-world experience, not to skill gain from other sources like books.",
"starting_trait": true,
"valid": false,
"cancels": [ "SLOWLEARNER" ]
"cancels": [ "SLOWLEARNER" ],
"enchantments": [ { "condition": "ALWAYS", "values": [ { "value": "LEARNING_FOCUS", "add": 15 } ] } ]
},
{
"type": "mutation",
Expand Down Expand Up @@ -488,11 +489,11 @@
"name": { "str": "Good Memory" },
"points": 3,
"description": "You have an exceptional memory, and find it easy to remember things. Your skills will erode slightly slower than usual, and you can remember more terrain.",
"map_memory_capacity_multiplier": 2,
"skill_rust_multiplier": 1.33,
"starting_trait": true,
"valid": false,
"cancels": [ "FORGETFUL" ]
"cancels": [ "FORGETFUL" ],
"enchantments": [ { "condition": "ALWAYS", "values": [ { "value": "MAP_MEMORY", "multiply": 1 } ] } ]
},
{
"type": "mutation",
Expand Down Expand Up @@ -1051,7 +1052,8 @@
"description": "You are slow to grasp new ideas, and thus learn things more slowly than others. Note that this only applies to real-world experience, not to skill gain from other sources like books.",
"starting_trait": true,
"valid": false,
"cancels": [ "FASTLEARNER" ]
"cancels": [ "FASTLEARNER" ],
"enchantments": [ { "condition": "ALWAYS", "values": [ { "value": "LEARNING_FOCUS", "add": -15 } ] } ]
},
{
"type": "mutation",
Expand Down Expand Up @@ -1195,11 +1197,11 @@
"points": -3,
"description": "You have a hard time remembering things. Your skills will erode slightly faster than usual, and you can remember less terrain.",
"social_modifiers": { "lie": -5 },
"map_memory_capacity_multiplier": 0.5,
"skill_rust_multiplier": 0.66,
"starting_trait": true,
"category": [ "BEAST", "MEDICAL", "CHIMERA", "MOUSE", "INSECT" ],
"cancels": [ "GOODMEMORY" ]
"cancels": [ "GOODMEMORY" ],
"enchantments": [ { "condition": "ALWAYS", "values": [ { "value": "MAP_MEMORY", "multiply": -0.5 } ] } ]
},
{
"type": "mutation",
Expand Down
2 changes: 1 addition & 1 deletion doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1532,4 +1532,4 @@ Gun fault flags:
- ```CLIMATE_CONTROL``` You are resistant to extreme temperatures.
- ```HEATSINK``` You are resistant to extreme heat.
- ```THERMOMETER``` You always know what temperature it is.
- ```CBQ_LEARN_BONUS``` You learn CBQ from the bionic bio_cqb faster.
4 changes: 4 additions & 0 deletions doc/MAGIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,10 @@ Effects for the character that has the enchantment:
* EFFECTIVE_HEALTH_MOD : If this is anything other than zero(which it defaults to) you will use it instead of your actual health mod
* 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
* MAP_MEMORY : How many map tiles you can remember.
* READING_EXP : Changes the minimum you learn from each reading increment.
* SKILL_RUST_RESIST : Chance out of 100 to resist skill rust.
* LEARNING_FOCUS : Amount of bonus focus you have for learning purposes.
* ARMOR_BASH
* ARMOR_CUT
* ARMOR_STAB
Expand Down
6 changes: 2 additions & 4 deletions src/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "iuse.h"
#include "kill_tracker.h"
#include "make_static.h"
#include "magic_enchantment.h"
#include "map.h"
#include "map_memory.h"
#include "martialarts.h"
Expand Down Expand Up @@ -76,7 +77,6 @@
static const activity_id ACT_READ( "ACT_READ" );

static const bionic_id bio_cloak( "bio_cloak" );
static const bionic_id bio_memory( "bio_memory" );

static const efftype_id effect_alarm_clock( "alarm_clock" );
static const efftype_id effect_boomered( "boomered" );
Expand Down Expand Up @@ -649,9 +649,7 @@ void avatar::do_read( item &book )
// Enhanced Memory Banks modestly boosts experience
int min_ex = std::max( 1, reading->time / 10 + learner->get_int() / 4 );
int max_ex = reading->time / 5 + learner->get_int() / 2 - originalSkillLevel;
if( has_active_bionic( bio_memory ) ) {
min_ex += 2;
}
min_ex = enchantment_cache->modify_value( enchant_vals::mod::READING_EXP, min_ex );

min_ex = adjust_for_focus( min_ex ) / 100;
max_ex = adjust_for_focus( max_ex ) / 100;
Expand Down
19 changes: 4 additions & 15 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ static const trait_id trait_DOWN( "DOWN" );
static const trait_id trait_ELECTRORECEPTORS( "ELECTRORECEPTORS" );
static const trait_id trait_ELFA_FNV( "ELFA_FNV" );
static const trait_id trait_ELFA_NV( "ELFA_NV" );
static const trait_id trait_FASTLEARNER( "FASTLEARNER" );
static const trait_id trait_FAST_REFLEXES( "FAST_REFLEXES" );
static const trait_id trait_FEL_NV( "FEL_NV" );
static const trait_id trait_GILLS( "GILLS" );
Expand Down Expand Up @@ -351,7 +350,6 @@ static const trait_id trait_SHOUT2( "SHOUT2" );
static const trait_id trait_SHOUT3( "SHOUT3" );
static const trait_id trait_SLIMESPAWNER( "SLIMESPAWNER" );
static const trait_id trait_SLIMY( "SLIMY" );
static const trait_id trait_SLOWLEARNER( "SLOWLEARNER" );
static const trait_id trait_STRONGSTOMACH( "STRONGSTOMACH" );
static const trait_id trait_THRESH_CEPHALOPOD( "THRESH_CEPHALOPOD" );
static const trait_id trait_THRESH_INSECT( "THRESH_INSECT" );
Expand Down Expand Up @@ -4356,10 +4354,9 @@ void Character::do_skill_rust()
continue;
}

const bool charged_bio_mem = get_power_level() > bio_memory->power_trigger &&
has_active_bionic( bio_memory );
const int rust_resist = enchantment_cache->modify_value( enchant_vals::mod::READING_EXP, 0 );
const int oldSkillLevel = skill_level_obj.level();
if( skill_level_obj.rust( charged_bio_mem, rust_rate_tmp ) ) {
if( skill_level_obj.rust( rust_resist, rust_rate_tmp ) ) {
add_msg_if_player( m_warning,
_( "Your knowledge of %s begins to fade, but your memory banks retain it!" ), aSkill.name() );
mod_power_level( -bio_memory->power_trigger );
Expand Down Expand Up @@ -8107,7 +8104,6 @@ mutation_value_map = {
{ "noise_modifier", calc_mutation_value_multiplicative<&mutation_branch::noise_modifier> },
{ "overmap_sight", calc_mutation_value_additive<&mutation_branch::overmap_sight> },
{ "overmap_multiplier", calc_mutation_value_multiplicative<&mutation_branch::overmap_multiplier> },
{ "map_memory_capacity_multiplier", calc_mutation_value_multiplicative<&mutation_branch::map_memory_capacity_multiplier> },
{ "reading_speed_multiplier", calc_mutation_value_multiplicative<&mutation_branch::reading_speed_multiplier> },
{ "skill_rust_multiplier", calc_mutation_value_multiplicative<&mutation_branch::skill_rust_multiplier> },
{ "crafting_speed_multiplier", calc_mutation_value_multiplicative<&mutation_branch::crafting_speed_multiplier> },
Expand Down Expand Up @@ -11719,15 +11715,8 @@ bool Character::has_opposite_trait( const trait_id &flag ) const
int Character::adjust_for_focus( int amount ) const
{
int effective_focus = get_focus();
if( has_trait( trait_FASTLEARNER ) ) {
effective_focus += 15;
}
if( has_active_bionic( bio_memory ) ) {
effective_focus += 10;
}
if( has_trait( trait_SLOWLEARNER ) ) {
effective_focus -= 15;
}
effective_focus = enchantment_cache->modify_value( enchant_vals::mod::LEARNING_FOCUS,
effective_focus );
effective_focus += ( get_int() - get_option<int>( "INT_BASED_LEARNING_BASE_VALUE" ) ) *
get_option<int>( "INT_BASED_LEARNING_FOCUS_ADJUSTMENT" );
effective_focus = std::max( effective_focus, 1 );
Expand Down
4 changes: 4 additions & 0 deletions src/magic_enchantment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ namespace io
case enchant_vals::mod::EFFECTIVE_HEALTH_MOD: return "EFFECTIVE_HEALTH_MOD";
case enchant_vals::mod::MOD_HEALTH: return "MOD_HEALTH";
case enchant_vals::mod::MOD_HEALTH_CAP: return "MOD_HEALTH_CAP";
case enchant_vals::mod::MAP_MEMORY: return "MAP_MEMORY";
case enchant_vals::mod::READING_EXP: return "READING_EXP";
case enchant_vals::mod::SKILL_RUST_RESIST: return "SKILL_RUST_RESIST";
case enchant_vals::mod::LEARNING_FOCUS: return "LEARNING_FOCUS";
case enchant_vals::mod::ARMOR_ACID: return "ARMOR_ACID";
case enchant_vals::mod::ARMOR_BASH: return "ARMOR_BASH";
case enchant_vals::mod::ARMOR_BIO: return "ARMOR_BIO";
Expand Down
4 changes: 4 additions & 0 deletions src/magic_enchantment.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ enum class mod : int {
EFFECTIVE_HEALTH_MOD,
MOD_HEALTH,
MOD_HEALTH_CAP,
MAP_MEMORY,
READING_EXP,
SKILL_RUST_RESIST,
LEARNING_FOCUS,
ARMOR_BASH,
ARMOR_CUT,
ARMOR_STAB,
Expand Down
6 changes: 3 additions & 3 deletions src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
#include "weighted_list.h"

static const bionic_id bio_cqb( "bio_cqb" );
static const bionic_id bio_memory( "bio_memory" );

static const itype_id itype_fur( "fur" );
static const itype_id itype_leather( "leather" );
Expand Down Expand Up @@ -104,6 +103,7 @@ static const efftype_id effect_venom_weaken( "venom_weaken" );
static const efftype_id effect_venom_player1( "venom_player1" );
static const efftype_id effect_venom_player2( "venom_player2" );

static const json_character_flag json_flag_CBQ_LEARN_BONUS( "CBQ_LEARN_BONUS" );
static const json_character_flag json_flag_NEED_ACTIVE_TO_MELEE( "NEED_ACTIVE_TO_MELEE" );
static const json_character_flag json_flag_UNARMED_BONUS( "UNARMED_BONUS" );

Expand Down Expand Up @@ -673,8 +673,8 @@ bool Character::melee_attack_abstract( Creature &t, bool allow_special,
if( has_active_bionic( bio_cqb ) && !martial_arts_data->knows_selected_style() ) {
/** @EFFECT_INT slightly increases chance to learn techniques when using CQB bionic */
// Enhanced Memory Banks bionic doubles chance to learn martial art
const int bionic_boost = has_active_bionic( bionic_id( bio_memory ) ) ? 2 : 1;
if( one_in( ( 1400 - ( get_int() * 50 ) ) / bionic_boost ) ) {
const int learn_boost = has_flag( json_flag_CBQ_LEARN_BONUS ) ? 2 : 1;
if( one_in( ( 1400 - ( get_int() * 50 ) ) / learn_boost ) ) {
martial_arts_data->learn_current_style_CQB( is_player() );
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/mutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,6 @@ struct mutation_branch {
// Multiplier for sight range, defaulting to 1.
cata::optional<float> overmap_multiplier = cata::nullopt;

// Multiplier for map memory capacity, defaulting to 1.
cata::optional<float> map_memory_capacity_multiplier = cata::nullopt;

// Multiplier for reading speed, defaulting to 1.
cata::optional<float> reading_speed_multiplier = cata::nullopt;

Expand Down
2 changes: 0 additions & 2 deletions src/mutation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,6 @@ void mutation_branch::load( const JsonObject &jo, const std::string & )
optional( jo, was_loaded, "vomit_multiplier", vomit_multiplier, cata::nullopt );
optional( jo, was_loaded, "overmap_sight", overmap_sight, cata::nullopt );
optional( jo, was_loaded, "overmap_multiplier", overmap_multiplier, cata::nullopt );
optional( jo, was_loaded, "map_memory_capacity_multiplier", map_memory_capacity_multiplier,
cata::nullopt );
optional( jo, was_loaded, "reading_speed_multiplier", reading_speed_multiplier, cata::nullopt );
optional( jo, was_loaded, "skill_rust_multiplier", skill_rust_multiplier, cata::nullopt );
optional( jo, was_loaded, "consume_time_modifier", consume_time_modifier, cata::nullopt );
Expand Down
7 changes: 2 additions & 5 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ static const skill_id skill_speech( "speech" );
static const skill_id skill_stabbing( "stabbing" );
static const skill_id skill_throw( "throw" );

static const bionic_id bio_memory( "bio_memory" );

static const trait_id trait_BEE( "BEE" );
static const trait_id trait_CANNIBAL( "CANNIBAL" );
static const trait_id trait_DEBUG_MIND_CONTROL( "DEBUG_MIND_CONTROL" );
Expand Down Expand Up @@ -969,9 +967,8 @@ void npc::finish_read( item &book )
// Enhanced Memory Banks modestly boosts experience
int min_ex = std::max( 1, reading->time / 10 + get_int() / 4 );
int max_ex = reading->time / 5 + get_int() / 2 - originalSkillLevel;
if( has_active_bionic( bio_memory ) ) {
min_ex += 2;
}
min_ex = enchantment_cache->modify_value( enchant_vals::mod::READING_EXP, min_ex );

if( max_ex < 2 ) {
max_ex = 2;
}
Expand Down
6 changes: 3 additions & 3 deletions src/skill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ bool SkillLevel::isRusting() const
calendar::turn - _lastPracticed > rustRate( _level );
}

bool SkillLevel::rust( bool charged_bio_mem, int character_rate )
bool SkillLevel::rust( int rust_resist, int character_rate )
{
const time_duration delta = calendar::turn - _lastPracticed;
const float char_rate = character_rate / 100.0f;
Expand All @@ -259,8 +259,8 @@ bool SkillLevel::rust( bool charged_bio_mem, int character_rate )
return false;
}

if( charged_bio_mem ) {
return one_in( 5 );
if( rust_resist > 0 ) {
return x_in_y( rust_resist, 100 );
}

_exercise -= _level * 100;
Expand Down
2 changes: 1 addition & 1 deletion src/skill.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class SkillLevel

void train( int amount, bool skip_scaling = false );
bool isRusting() const;
bool rust( bool charged_bio_mem, int character_rate );
bool rust( int rust_resist, int character_rate );
void practice();
bool can_train() const;

Expand Down

0 comments on commit 43466bd

Please sign in to comment.