diff --git a/data/json/bionics.json b/data/json/bionics.json index a778f404f7a9d..20bc493c432e3 100644 --- a/data/json/bionics.json +++ b/data/json/bionics.json @@ -396,7 +396,29 @@ "name": "Telescopic Eyes", "description": "Much of the material in your inner eye has been surgically removed and replaced with an array of high-powered, auto-focusing lenses. They function as integrated binoculars, letting you see much farther than before, and any vision problems you might have had are now gone.", "occupied_bodyparts": [ [ "EYES", 2 ] ], - "canceled_mutations": [ "HYPEROPIC", "MYOPIC" ] + "canceled_mutations": [ + "HYPEROPIC", + "MYOPIC", + "URSINE_EYE", + "NIGHTVISION3", + "NIGHTVISION2", + "NIGHTVISION", + "BIRD_EYE", + "COMPOUND_EYES", + "LIZ_IR", + "EAGLEEYED", + "CEPH_VISION", + "CEPH_EYES", + "ELFA_FNV", + "ELFA_NV", + "ELFAEYES", + "FEL_NV", + "FEL_EYE", + "INFRARED", + "LIZ_EYE", + "EYEBULGE", + "SEESLEEP" + ] }, { "id": "bio_face_mask", diff --git a/src/mutation.cpp b/src/mutation.cpp index 01013a305999b..3992cd011923c 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -25,6 +25,7 @@ #include "rng.h" #include "string_id.h" #include "enums.h" +#include "bionics.h" #include "cata_string_consts.h" namespace io @@ -580,6 +581,15 @@ bool Character::mutation_ok( const trait_id &mutation, bool force_good, bool for // We already have this mutation or something that replaces it. return false; } + + for( const bionic_id &bid : get_bionics() ) { + for( const trait_id &mid : bid->canceled_mutations ) { + if( mid == mutation ) { + return false; + } + } + } + const mutation_branch &mdata = mutation.obj(); if( force_bad && mdata.points > 0 ) { // This is a good mutation, and we're due for a bad one. diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 3b1dc7374986d..7f1f039f315d1 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -93,16 +93,13 @@ #include "requirements.h" #include "stats_tracker.h" #include "vpart_position.h" +#include "cata_string_consts.h" struct oter_type_t; struct mutation_branch; #define dbg(x) DebugLog((DebugLevel)(x),D_GAME) << __FILE__ << ":" << __LINE__ << ": " -static const trait_id trait_HYPEROPIC( "HYPEROPIC" ); -static const trait_id trait_MYOPIC( "MYOPIC" ); -static const efftype_id effect_riding( "riding" ); - static const std::array obj_type_name = { { "OBJECT_NONE", "OBJECT_ITEM", "OBJECT_ACTOR", "OBJECT_PLAYER", "OBJECT_NPC", "OBJECT_MONSTER", "OBJECT_VEHICLE", "OBJECT_TRAP", "OBJECT_FIELD", "OBJECT_TERRAIN", "OBJECT_FURNITURE" @@ -923,13 +920,13 @@ void player::load( const JsonObject &data ) add_bionic( bionic_id( "bio_blindfold" ) ); } - // Fixes bugged characters for telescopic eyes CBM. - if( has_bionic( bionic_id( "bio_eye_optic" ) ) && has_trait( trait_HYPEROPIC ) ) { - remove_mutation( trait_HYPEROPIC ); - } - - if( has_bionic( bionic_id( "bio_eye_optic" ) ) && has_trait( trait_MYOPIC ) ) { - remove_mutation( trait_MYOPIC ); + // Fixes bugged characters for CBM's preventing mutations. + for( const bionic_id &bid : get_bionics() ) { + for( const trait_id &mid : bid->canceled_mutations ) { + if( has_trait( mid ) ) { + remove_mutation( mid ); + } + } } if( data.has_array( "faction_warnings" ) ) {