From 487a0fdc409ee983535480ce8abcfe2368061c38 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 13 Apr 2020 11:56:19 +0200 Subject: [PATCH 01/11] transform struct --- src/mutation.h | 16 ++++++++++++++++ src/mutation_data.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/mutation.h b/src/mutation.h index 5ce9fde40dee9..e27d4a7928154 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -76,6 +76,20 @@ struct mut_attack { bool hardcoded_effect = false; }; +struct mut_transform { + + trait_id target; + + /** displayed if player sees transformation with %s replaced by item name */ + translation msg_transform; + /** used to set the active property of the transformed @ref target */ + bool active = false; + /** subtracted from @ref Creature::moves when transformation is successful */ + int moves = 0; + mut_transform(); + bool load( const JsonObject &jsobj, const std::string &member ); +}; + struct mutation_branch { trait_id id; bool was_loaded = false; @@ -151,6 +165,8 @@ struct mutation_branch { cata::optional scent_mask; int bleed_resist = 0; + cata::value_ptr transform; + /**Map of crafting skills modifiers, can be negative*/ std::map craft_skill_bonus; diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index fd2bb857eae97..60551798378bd 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -260,6 +260,20 @@ void mutation_branch::load_trait( const JsonObject &jo, const std::string &src ) trait_factory.load( jo, src ); } +mut_transform::mut_transform() : target(), msg_transform(), active( false ), moves( 0 ) {} + +bool mut_transform::load( const JsonObject &jsobj, const std::string &member ) +{ + JsonObject j = jsobj.get_object( member ); + + assign( j, "target", target ); + assign( j, "msg_transform", msg_transform ); + assign( j, "active", active ); + assign( j, "moves", moves ); + + return true; +} + void mutation_branch::load( const JsonObject &jo, const std::string & ) { mandatory( jo, was_loaded, "id", id ); @@ -293,6 +307,10 @@ void mutation_branch::load( const JsonObject &jo, const std::string & ) optional( si, was_loaded, "type", ranged_mutation ); optional( si, was_loaded, "message", raw_ranged_mutation_message ); } + if( jo.has_object( "transform" ) ) { + transform = cata::make_value(); + transform->load( jo, "transform" ); + } optional( jo, was_loaded, "initial_ma_styles", initial_ma_styles ); if( jo.has_array( "bodytemp_modifiers" ) ) { @@ -535,6 +553,12 @@ void mutation_branch::check_consistency() debugmsg( "mutation %s refers to undefined mutation type %s", mid.c_str(), type ); } } + if( mid->transform ) { + const trait_id tid = mid->transform->target; + if( !tid.is_valid() ) { + debugmsg( "mutation %s transform uses undefined target %s", mid.c_str(), tid.c_str() ); + } + } for( const std::pair elem : an_id ) { if( !elem.first.is_valid() ) { debugmsg( "mutation %s refers to undefined species id %s", mid.c_str(), elem.first.c_str() ); From e2df0dbdd5c603cef1fb7e864734205fc75d5cd2 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 13 Apr 2020 12:29:51 +0200 Subject: [PATCH 02/11] proof of concept --- data/json/mutations/mutations.json | 17 ++++++++++++++--- src/character.h | 2 ++ src/mutation.cpp | 22 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/data/json/mutations/mutations.json b/data/json/mutations/mutations.json index 4994a03663461..b5a7fb2c828eb 100644 --- a/data/json/mutations/mutations.json +++ b/data/json/mutations/mutations.json @@ -18,12 +18,23 @@ "points": 1, "description": "A photophore has grown from your head, you can make it glow softly. This will make you very visible in the dark, ideal to attract a partner during mating season.", "active": true, + "transform": { "target": "BIOLUM1_active", "msg_transform": "You turn your photophore ON.", "active": true, "moves": 100 }, + "encumbrance_covered": [ [ "HEAD", 5 ] ], + "changes_to": [ "BIOLUM2" ], + "category": [ "ELFA", "INSECT", "FISH" ] + }, + { + "type": "mutation", + "id": "BIOLUM1_active", + "name": { "str": "Weak Photophore (active)" }, + "copy-from": "BIOLUM1", + "points": 1, + "description": "Your photophore is glowing softly. This is making you very visible in the dark.", + "active": true, "cost": 1, "time": 810000, "hunger": true, - "encumbrance_covered": [ [ "HEAD", 5 ] ], - "changes_to": [ "BIOLUM2" ], - "category": [ "ELFA", "INSECT", "FISH" ], + "transform": { "target": "BIOLUM1", "msg_transform": "You turn your photophore OFF.", "active": false, "moves": 100 }, "lumination": [ [ "HEAD", 8 ] ] }, { diff --git a/src/character.h b/src/character.h index 031198c5bf304..74f64df13aca9 100644 --- a/src/character.h +++ b/src/character.h @@ -658,6 +658,8 @@ class Character : public Creature, public visitable /** Add or removes a mutation on the player, but does not trigger mutation loss/gain effects. */ void set_mutation( const trait_id &flag ); void unset_mutation( const trait_id &flag ); + /**Unset switched mutation and set target mutation instead*/ + void switch_mutations( const trait_id &switched, const trait_id &target, bool start_powered ); // Trigger and disable mutations that can be so toggled. void activate_mutation( const trait_id &mutation ); diff --git a/src/mutation.cpp b/src/mutation.cpp index 9102b5bf3fe17..25fa1399dad6a 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -161,6 +161,17 @@ void Character::unset_mutation( const trait_id &flag ) reset_encumbrance(); } +void Character::switch_mutations( const trait_id &switched, const trait_id &target, + bool start_powered ) +{ + unset_mutation( switched ); + mutation_loss_effect( switched ); + + set_mutation( target ); + my_mutations[target].powered = start_powered; + mutation_effect( target ); +} + int Character::get_mod( const trait_id &mut, const std::string &arg ) const { auto &mod_data = mut->mods; @@ -484,6 +495,12 @@ void Character::activate_mutation( const trait_id &mut ) recalc_sight_limits(); } + if( mdata.transform ) { + const cata::value_ptr trans = mdata.transform; + switch_mutations( mut, trans->target, trans->active ); + return; + } + if( mut == trait_WEB_WEAVER ) { g->m.add_field( pos(), fd_web, 1 ); add_msg_if_player( _( "You start spinning web with your spinnerets!" ) ); @@ -609,6 +626,11 @@ void Character::deactivate_mutation( const trait_id &mut ) // Handle stat changes from deactivation apply_mods( mut, false ); recalc_sight_limits(); + const mutation_branch &mdata = mut.obj(); + if( mdata.transform ) { + const cata::value_ptr trans = mdata.transform; + switch_mutations( mut, trans->target, trans->active ); + } } trait_id Character::trait_by_invlet( const int ch ) const From 8d3383214b3a97c6e857eb815304e32320c08428 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 13 Apr 2020 14:39:29 +0200 Subject: [PATCH 03/11] Ui and Tweaks --- src/mutation.cpp | 2 ++ src/mutation_ui.cpp | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/mutation.cpp b/src/mutation.cpp index 25fa1399dad6a..2f5553fb5f31b 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -497,6 +497,7 @@ void Character::activate_mutation( const trait_id &mut ) if( mdata.transform ) { const cata::value_ptr trans = mdata.transform; + mod_moves( - trans->moves ); switch_mutations( mut, trans->target, trans->active ); return; } @@ -629,6 +630,7 @@ void Character::deactivate_mutation( const trait_id &mut ) const mutation_branch &mdata = mut.obj(); if( mdata.transform ) { const cata::value_ptr trans = mdata.transform; + mod_moves( -trans->moves ); switch_mutations( mut, trans->target, trans->active ); } } diff --git a/src/mutation_ui.cpp b/src/mutation_ui.cpp index dd8ade146ebd4..1cee2fbfb747d 100644 --- a/src/mutation_ui.cpp +++ b/src/mutation_ui.cpp @@ -70,8 +70,8 @@ void player::power_mutations() std::vector passive; std::vector active; - for( auto &mut : my_mutations ) { - if( !mut.first->activated ) { + for( std::pair &mut : my_mutations ) { + if( !mut.first->activated && ! mut.first->transform ) { passive.push_back( mut.first ); } else { active.push_back( mut.first ); @@ -290,10 +290,15 @@ void player::power_mutations() break; } const auto &mut_data = mut_id.obj(); + const cata::value_ptr &trans = mut_data.transform; if( menu_mode == "activating" ) { - if( mut_data.activated ) { + if( mut_data.activated || trans ) { if( my_mutations[mut_id].powered ) { - add_msg_if_player( m_neutral, _( "You stop using your %s." ), mut_data.name() ); + if( trans && !trans->msg_transform.empty() ) { + add_msg_if_player( m_neutral, trans->msg_transform ); + } else { + add_msg_if_player( m_neutral, _( "You stop using your %s." ), mut_data.name() ); + } deactivate_mutation( mut_id ); // Action done, leave screen @@ -303,7 +308,12 @@ void player::power_mutations() ( !mut_data.fatigue || get_fatigue() <= 400 ) ) { g->draw(); - add_msg_if_player( m_neutral, _( "You activate your %s." ), mut_data.name() ); + if( trans && !trans->msg_transform.empty() ) { + add_msg_if_player( m_neutral, trans->msg_transform ); + } else { + add_msg_if_player( m_neutral, _( "You activate your %s." ), mut_data.name() ); + } + activate_mutation( mut_id ); // Action done, leave screen break; From 772ece056afc25a0097f272077e685165dec4f34 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 13 Apr 2020 15:00:11 +0200 Subject: [PATCH 04/11] Doc and json --- data/json/mutations/mutations.json | 27 +++++++++++++++++---------- doc/JSON_INFO.md | 5 +++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/data/json/mutations/mutations.json b/data/json/mutations/mutations.json index b5a7fb2c828eb..66f3e01e06024 100644 --- a/data/json/mutations/mutations.json +++ b/data/json/mutations/mutations.json @@ -17,8 +17,7 @@ "name": { "str": "Weak Photophore" }, "points": 1, "description": "A photophore has grown from your head, you can make it glow softly. This will make you very visible in the dark, ideal to attract a partner during mating season.", - "active": true, - "transform": { "target": "BIOLUM1_active", "msg_transform": "You turn your photophore ON.", "active": true, "moves": 100 }, + "transform": { "target": "BIOLUM1_active", "msg_transform": "You turn your photophore ON.", "active": true }, "encumbrance_covered": [ [ "HEAD", 5 ] ], "changes_to": [ "BIOLUM2" ], "category": [ "ELFA", "INSECT", "FISH" ] @@ -26,15 +25,14 @@ { "type": "mutation", "id": "BIOLUM1_active", - "name": { "str": "Weak Photophore (active)" }, + "name": { "str": "Weak Photophore" }, "copy-from": "BIOLUM1", - "points": 1, + "valid": false, "description": "Your photophore is glowing softly. This is making you very visible in the dark.", - "active": true, "cost": 1, "time": 810000, "hunger": true, - "transform": { "target": "BIOLUM1", "msg_transform": "You turn your photophore OFF.", "active": false, "moves": 100 }, + "transform": { "target": "BIOLUM1", "msg_transform": "You turn your photophore OFF.", "active": false }, "lumination": [ [ "HEAD", 8 ] ] }, { @@ -43,13 +41,22 @@ "name": { "str": "Photophore" }, "points": 2, "description": "Your can make your photophore glow brightly.", - "active": true, + "transform": { "target": "BIOLUM2_active", "msg_transform": "You turn your photophore ON.", "active": true }, + "encumbrance_covered": [ [ "HEAD", 5 ] ], + "prereqs": [ "BIOLUM1" ], + "category": [ "ELFA", "INSECT", "FISH" ] + }, + { + "type": "mutation", + "id": "BIOLUM2_active", + "name": { "str": "Photophore" }, + "copy-from": "BIOLUM2", + "valid": false, + "description": "Your photophore is glowing brightly.", "cost": 1, "time": 405000, "hunger": true, - "encumbrance_covered": [ [ "HEAD", 5 ] ], - "prereqs": [ "BIOLUM1" ], - "category": [ "ELFA", "INSECT", "FISH" ], + "transform": { "target": "BIOLUM2", "msg_transform": "You turn your photophore OFF.", "active": false }, "lumination": [ [ "HEAD", 20 ] ] }, { diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index 71efc7b44446e..1258ece627135 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -1320,6 +1320,11 @@ an `event_statistic`. For example: "healing_awake": 1.0, // Healing rate per turn while awake. "healing_resting": 0.5, // Healing rate per turn while resting. "mending_modifier": 1.2 // Multiplier on how fast your limbs mend - This value would make your limbs mend 20% faster +"transform": { "target": "BIOLUM1", // Trait_id of the mutation this one will transfomr into + "msg_transform": "You turn your photophore OFF.", // message displayed upon transformation + "active": false , // Will the target mutation start powered ( turn ON ). + "moves": 100 // how many moves this costs. (default: 0) +} ``` ### Vehicle Groups From 11539944878694951fe35a489d087106d6cae6d4 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 13 Apr 2020 15:46:53 +0200 Subject: [PATCH 05/11] Removes NEED_ACTIVE_TO_MELEE Flag And Jsonize piercing damages --- src/melee.cpp | 31 ++++++++----------------------- src/mutation.h | 1 + src/mutation_data.cpp | 1 + 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/melee.cpp b/src/melee.cpp index 8f313e9191862..4a20616fbae0b 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -91,9 +91,6 @@ static const efftype_id effect_narcosis( "narcosis" ); static const efftype_id effect_poison( "poison" ); static const efftype_id effect_stunned( "stunned" ); -static const trait_id trait_CLAWS( "CLAWS" ); -static const trait_id trait_CLAWS_RETRACT( "CLAWS_RETRACT" ); -static const trait_id trait_CLAWS_ST( "CLAWS_ST" ); static const trait_id trait_CLAWS_TENTACLE( "CLAWS_TENTACLE" ); static const trait_id trait_CLUMSY( "CLUMSY" ); static const trait_id trait_DEBUG_NIGHTVISION( "DEBUG_NIGHTVISION" ); @@ -860,9 +857,7 @@ void player::roll_bash_damage( bool crit, damage_instance &di, bool average, if( left_empty || right_empty ) { float per_hand = 0.0f; for( const std::pair< const trait_id, trait_data > &mut : my_mutations ) { - if( mut.first->flags.count( "NEED_ACTIVE_TO_MELEE" ) > 0 && !has_active_mutation( mut.first ) ) { - continue; - } + float unarmed_bonus = 0.0f; const int bash_bonus = mut.first->bash_dmg_bonus; if( mut.first->flags.count( "UNARMED_BONUS" ) > 0 && bash_bonus > 0 ) { @@ -944,9 +939,7 @@ void player::roll_cut_damage( bool crit, damage_instance &di, bool average, cons per_hand += 2; } for( const std::pair< const trait_id, trait_data > &mut : my_mutations ) { - if( mut.first->flags.count( "NEED_ACTIVE_TO_MELEE" ) > 0 && !has_active_mutation( mut.first ) ) { - continue; - } + float unarmed_bonus = 0.0f; const int cut_bonus = mut.first->cut_dmg_bonus; if( mut.first->flags.count( "UNARMED_BONUS" ) > 0 && cut_bonus > 0 ) { @@ -1010,27 +1003,19 @@ void player::roll_stab_damage( bool crit, damage_instance &di, bool /*average*/, weap.is_null(); if( left_empty || right_empty ) { float per_hand = 0.0f; - if( has_trait( trait_CLAWS ) || has_active_mutation( trait_CLAWS_RETRACT ) ) { - per_hand += 3; - } - if( has_trait( trait_NAILS ) ) { - per_hand += .5; - } + for( const std::pair< const trait_id, trait_data > &mut : my_mutations ) { + per_hand += mut.first->pierce_dmg_bonus; - if( has_bionic( bionic_id( "bio_razors" ) ) ) { - per_hand += 2; + if( mut.first->flags.count( "UNARMED_BONUS" ) > 0 && cut_bonus > 0 ) { + per_hand += std::min( unarmed_skill / 2, 4 ); + } } - if( has_trait( trait_THORNS ) ) { + if( has_bionic( bionic_id( "bio_razors" ) ) ) { per_hand += 2; } - if( has_trait( trait_CLAWS_ST ) ) { - /** @EFFECT_UNARMED increases stabbing damage with CLAWS_ST */ - per_hand += 3 + unarmed_skill / 2.0; - } - cut_dam += per_hand; // First hand if( left_empty && right_empty ) { // Second hand diff --git a/src/mutation.h b/src/mutation.h index e27d4a7928154..71ba8e4555fb2 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -145,6 +145,7 @@ struct mutation_branch { float str_modifier = 0.0f; //melee bonuses int cut_dmg_bonus = 0; + float pierce_dmg_bonus = 0.0; std::pair rand_cut_bonus; int bash_dmg_bonus = 0; std::pair rand_bash_bonus; diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index 60551798378bd..40576d7bc3f8a 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -349,6 +349,7 @@ void mutation_branch::load( const JsonObject &jo, const std::string & ) optional( jo, was_loaded, "stealth_modifier", stealth_modifier, 0.0f ); optional( jo, was_loaded, "str_modifier", str_modifier, 0.0f ); optional( jo, was_loaded, "cut_dmg_bonus", cut_dmg_bonus, 0 ); + optional( jo, was_loaded, "pierce_dmg_bonus", pierce_dmg_bonus, 0.0f ); optional( jo, was_loaded, "bash_dmg_bonus", bash_dmg_bonus, 0 ); optional( jo, was_loaded, "dodge_modifier", dodge_modifier, 0.0f ); optional( jo, was_loaded, "speed_modifier", speed_modifier, 1.0f ); From a2225e5075afd912f82ba174825dd9e77bd0d25f Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 13 Apr 2020 15:55:37 +0200 Subject: [PATCH 06/11] fix --- src/melee.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/melee.cpp b/src/melee.cpp index 4a20616fbae0b..6bec20115ab41 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -1004,10 +1004,10 @@ void player::roll_stab_damage( bool crit, damage_instance &di, bool /*average*/, if( left_empty || right_empty ) { float per_hand = 0.0f; - for( const std::pair< const trait_id, trait_data > &mut : my_mutations ) { - per_hand += mut.first->pierce_dmg_bonus; + for( const trait_id &mut : get_mutations() ) { + per_hand += mut->pierce_dmg_bonus; - if( mut.first->flags.count( "UNARMED_BONUS" ) > 0 && cut_bonus > 0 ) { + if( mut->flags.count( "UNARMED_BONUS" ) > 0 && cut_bonus > 0 ) { per_hand += std::min( unarmed_skill / 2, 4 ); } } From 5e3588c14f4c6f847dadfc8e545518aafe816567 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 13 Apr 2020 16:01:00 +0200 Subject: [PATCH 07/11] Jsonize butchering quality --- src/mutation.h | 2 ++ src/mutation_data.cpp | 2 ++ src/visitable.cpp | 9 +++------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mutation.h b/src/mutation.h index 71ba8e4555fb2..c29b4aea58df2 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -166,6 +166,8 @@ struct mutation_branch { cata::optional scent_mask; int bleed_resist = 0; + int butchering_quality = 0; + cata::value_ptr transform; /**Map of crafting skills modifiers, can be negative*/ diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index 40576d7bc3f8a..a0ad00f348720 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -386,6 +386,8 @@ void mutation_branch::load( const JsonObject &jo, const std::string & ) optional( jo, was_loaded, "can_only_heal_with", can_only_heal_with ); optional( jo, was_loaded, "can_heal_with", can_heal_with ); + optional( jo, was_loaded, "butchering_quality", butchering_quality, 0 ); + optional( jo, was_loaded, "allowed_category", allowed_category ); optional( jo, was_loaded, "mana_modifier", mana_modifier, 0 ); diff --git a/src/visitable.cpp b/src/visitable.cpp index aa98f0fadd2bf..0c7ef75e4b603 100644 --- a/src/visitable.cpp +++ b/src/visitable.cpp @@ -10,6 +10,7 @@ #include "active_item_cache.h" #include "bionics.h" +#include "mutation.h" #include "character.h" #include "colony.h" #include "debug.h" @@ -278,12 +279,8 @@ int visitable::max_quality( const quality_id &qual ) const } if( qual == qual_BUTCHER ) { - if( self->has_trait( trait_CLAWS_ST ) ) { - res = std::max( res, 8 ); - } else if( self->has_trait( trait_TALONS ) || self->has_trait( trait_MANDIBLES ) || - self->has_trait( trait_CLAWS ) || self->has_trait( trait_CLAWS_RETRACT ) || - self->has_trait( trait_CLAWS_RAT ) ) { - res = std::max( res, 4 ); + for( const trait_id &mut : self->get_mutations() ) { + res = std::max( res, mut->butchering_quality ); } } From bae128e2d0d1ffa029dc61e09cb49eee9040e657 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 13 Apr 2020 16:01:16 +0200 Subject: [PATCH 08/11] update json and doc --- data/json/mutations/mutations.json | 34 +++++++----------------------- doc/JSON_INFO.md | 1 + 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/data/json/mutations/mutations.json b/data/json/mutations/mutations.json index 66f3e01e06024..4994a03663461 100644 --- a/data/json/mutations/mutations.json +++ b/data/json/mutations/mutations.json @@ -17,22 +17,13 @@ "name": { "str": "Weak Photophore" }, "points": 1, "description": "A photophore has grown from your head, you can make it glow softly. This will make you very visible in the dark, ideal to attract a partner during mating season.", - "transform": { "target": "BIOLUM1_active", "msg_transform": "You turn your photophore ON.", "active": true }, - "encumbrance_covered": [ [ "HEAD", 5 ] ], - "changes_to": [ "BIOLUM2" ], - "category": [ "ELFA", "INSECT", "FISH" ] - }, - { - "type": "mutation", - "id": "BIOLUM1_active", - "name": { "str": "Weak Photophore" }, - "copy-from": "BIOLUM1", - "valid": false, - "description": "Your photophore is glowing softly. This is making you very visible in the dark.", + "active": true, "cost": 1, "time": 810000, "hunger": true, - "transform": { "target": "BIOLUM1", "msg_transform": "You turn your photophore OFF.", "active": false }, + "encumbrance_covered": [ [ "HEAD", 5 ] ], + "changes_to": [ "BIOLUM2" ], + "category": [ "ELFA", "INSECT", "FISH" ], "lumination": [ [ "HEAD", 8 ] ] }, { @@ -41,22 +32,13 @@ "name": { "str": "Photophore" }, "points": 2, "description": "Your can make your photophore glow brightly.", - "transform": { "target": "BIOLUM2_active", "msg_transform": "You turn your photophore ON.", "active": true }, - "encumbrance_covered": [ [ "HEAD", 5 ] ], - "prereqs": [ "BIOLUM1" ], - "category": [ "ELFA", "INSECT", "FISH" ] - }, - { - "type": "mutation", - "id": "BIOLUM2_active", - "name": { "str": "Photophore" }, - "copy-from": "BIOLUM2", - "valid": false, - "description": "Your photophore is glowing brightly.", + "active": true, "cost": 1, "time": 405000, "hunger": true, - "transform": { "target": "BIOLUM2", "msg_transform": "You turn your photophore OFF.", "active": false }, + "encumbrance_covered": [ [ "HEAD", 5 ] ], + "prereqs": [ "BIOLUM1" ], + "category": [ "ELFA", "INSECT", "FISH" ], "lumination": [ [ "HEAD", 20 ] ] }, { diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index 1258ece627135..345062b86562d 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -1239,6 +1239,7 @@ an `event_statistic`. For example: "visibility": 0, // Visibility of the trait for purposes of NPC interaction (default: 0) "ugliness": 0, // Ugliness of the trait for purposes of NPC interaction (default: 0) "cut_dmg_bonus": 3, // Bonus to unarmed cut damage (default: 0) +"pierce_dmg_bonus": 3, // Bonus to unarmed pierce damage (default: 0.0) "bash_dmg_bonus": 3, // Bonus to unarmed bash damage (default: 0) "rand_cut_bonus": { "min": 2, "max": 3 }, // Random bonus to unarmed cut damage between min and max. "rand_bash_bonus": { "min": 2, "max": 3 }, // Random bonus to unarmed bash damage between min and max. From ccbe168b367658d5bab38c6484702d086a98eced Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 13 Apr 2020 16:06:33 +0200 Subject: [PATCH 09/11] json and doc --- data/json/mutations/mutations.json | 28 ++++++++++++++++++++++++---- doc/JSON_FLAGS.md | 1 - doc/JSON_INFO.md | 1 + 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/data/json/mutations/mutations.json b/data/json/mutations/mutations.json index 4994a03663461..463eb6188200e 100644 --- a/data/json/mutations/mutations.json +++ b/data/json/mutations/mutations.json @@ -2262,6 +2262,7 @@ "points": 2, "visibility": 8, "ugliness": 4, + "pierce_dmg_bonus": 2, "description": "Your skin is covered in small, woody thorns. Whenever an unarmed opponent strikes a part of your body that is not covered by clothing, they will receive minor damage. Your punches may also deal extra damage.", "prereqs": [ "BARK" ], "category": [ "PLANT" ] @@ -2449,6 +2450,7 @@ "name": { "str": "Long Fingernails" }, "points": 1, "visibility": 1, + "pierce_dmg_bonus": 0.5, "description": "Your fingernails are long and sharp. If you aren't wearing gloves, your unarmed attacks deal a minor amount of cutting damage.", "types": [ "CLAWS" ], "changes_to": [ "CLAWS", "TALONS" ], @@ -2463,6 +2465,8 @@ "visibility": 3, "ugliness": 2, "cut_dmg_bonus": 3, + "pierce_dmg_bonus": 3, + "butchering_quality": 4, "description": "You have claws on the ends of your fingers. If you aren't wearing gloves, your unarmed attacks deal a minor amount of cutting damage.", "types": [ "CLAWS" ], "prereqs": [ "NAILS" ], @@ -2478,6 +2482,7 @@ "visibility": 3, "ugliness": 4, "cut_dmg_bonus": 1, + "butchering_quality": 4, "flags": [ "UNARMED_BONUS" ], "description": "Your claws have grown tougher and slightly gnarled.", "types": [ "CLAWS" ], @@ -2496,6 +2501,8 @@ "valid": false, "purifiable": false, "cut_dmg_bonus": 1, + "pierce_dmg_bonus": 3, + "butchering_quality": 8, "flags": [ "UNARMED_BONUS" ], "description": "Your paws are bone, muscle, and claw with a thin layer of skin and fur. They might as well be made of stainless steel.", "types": [ "CLAWS" ], @@ -2510,15 +2517,26 @@ "id": "CLAWS_RETRACT", "name": { "str": "Retractable Claws" }, "points": 2, - "ugliness": 1, - "cut_dmg_bonus": 3, - "flags": [ "NEED_ACTIVE_TO_MELEE" ], "description": "You have claws on the ends of your fingers, and can extend or retract them as desired. Gloves will still get in the way, though.", "types": [ "CLAWS" ], "prereqs": [ "CLAWS" ], "cancels": [ "ARM_TENTACLES", "ARM_TENTACLES_4", "ARM_TENTACLES_8" ], "category": [ "FELINE" ], - "active": true, + "transform": { "target": "CLAWS_RETRACT_active", "msg_transform": "You extend your claws.", "active": false, "moves": 10 }, + "cost": 0 + }, + { + "type": "mutation", + "id": "CLAWS_RETRACT_active", + "name": { "str": "Extended Claws" }, + "copy-from": "CLAWS_RETRACT", + "valid": false, + "ugliness": 1, + "cut_dmg_bonus": 3, + "pierce_dmg_bonus": 3, + "butchering_quality": 4, + "description": "Sharp claws are exten from the end of your fingers.", + "transform": { "target": "CLAWS_RETRACT", "msg_transform": "You retract your claws.", "active": false, "moves": 10 }, "cost": 0 }, { @@ -2554,6 +2572,7 @@ "visibility": 4, "ugliness": 3, "cut_dmg_bonus": 3, + "butchering_quality": 4, "flags": [ "UNARMED_BONUS" ], "mixed_effect": true, "restricts_gear": [ "HAND_L", "HAND_R" ], @@ -3632,6 +3651,7 @@ "points": 1, "visibility": 8, "ugliness": 6, + "butchering_quality": 4, "mixed_effect": true, "description": "A set of insect-like mandibles have grown around your mouth. They allow you to eat faster and provide a slicing unarmed attack, but prevent wearing mouthwear. Slightly reduces wet effects.", "types": [ "TEETH", "MUZZLE" ], diff --git a/doc/JSON_FLAGS.md b/doc/JSON_FLAGS.md index bd02887e1824f..574a7f481ea52 100644 --- a/doc/JSON_FLAGS.md +++ b/doc/JSON_FLAGS.md @@ -1089,7 +1089,6 @@ Also see `monster_attacks.json` for more special attacks, for example, impale an #### Flags - ```UNARMED_BONUS``` You get a bonus to unarmed bash and cut damage equal to unarmed_skill/2 up to 4. -- ```NEED_ACTIVE_TO_MELEE``` This mutation gives bonus to unarmed melee only if it's active. - ```NO_DISEASE``` This mutation grants immunity to diseases. - ```NO_THIRST``` Your thirst is not modified by food or drinks. - ```NO_RADIATION``` This mutation grants immunity to radiations. diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index 345062b86562d..a74af528e6197 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -1241,6 +1241,7 @@ an `event_statistic`. For example: "cut_dmg_bonus": 3, // Bonus to unarmed cut damage (default: 0) "pierce_dmg_bonus": 3, // Bonus to unarmed pierce damage (default: 0.0) "bash_dmg_bonus": 3, // Bonus to unarmed bash damage (default: 0) +"butchering_quality": 4, // Butchering quality of this mutations (default: 0) "rand_cut_bonus": { "min": 2, "max": 3 }, // Random bonus to unarmed cut damage between min and max. "rand_bash_bonus": { "min": 2, "max": 3 }, // Random bonus to unarmed bash damage between min and max. "bodytemp_modifiers" : [100, 150], // Range of additional bodytemp units (these units are described in 'weather.h'. First value is used if the person is already overheated, second one if it's not. From b98f4d7a2a9cbb537c31e1490eab779188a5d974 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Wed, 15 Apr 2020 22:24:10 +0200 Subject: [PATCH 10/11] remove redudant initializer --- src/mutation_data.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index a0ad00f348720..33f69b50856e7 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -260,7 +260,7 @@ void mutation_branch::load_trait( const JsonObject &jo, const std::string &src ) trait_factory.load( jo, src ); } -mut_transform::mut_transform() : target(), msg_transform(), active( false ), moves( 0 ) {} +mut_transform::mut_transform() : active( false ), moves( 0 ) {} bool mut_transform::load( const JsonObject &jsobj, const std::string &member ) { From 11489faaccda01faf364e0df1fb3271d842c54c9 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Thu, 16 Apr 2020 09:33:44 +0200 Subject: [PATCH 11/11] astyle --- src/character.h | 2 +- src/melee.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/character.h b/src/character.h index c1d5b1e55ab86..1275eab050214 100644 --- a/src/character.h +++ b/src/character.h @@ -660,7 +660,7 @@ class Character : public Creature, public visitable void unset_mutation( const trait_id & ); /**Unset switched mutation and set target mutation instead*/ void switch_mutations( const trait_id &switched, const trait_id &target, bool start_powered ); - + // Trigger and disable mutations that can be so toggled. void activate_mutation( const trait_id &mutation ); void deactivate_mutation( const trait_id &mut ); diff --git a/src/melee.cpp b/src/melee.cpp index feb19a194fdb1..8961826eddec8 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -940,7 +940,7 @@ void player::roll_cut_damage( bool crit, damage_instance &di, bool average, cons if( has_bionic( bionic_id( "bio_razors" ) ) ) { per_hand += 2; } - + for( const trait_id &mut : get_mutations() ) { if( mut->flags.count( "NEED_ACTIVE_TO_MELEE" ) > 0 && !has_active_mutation( mut ) ) { continue;