From 2b3f992da1887180c85867b8cecd840517f2abd3 Mon Sep 17 00:00:00 2001 From: aMegaSloth <102860442+aMegaSloth@users.noreply.github.com> Date: Tue, 31 May 2022 06:17:29 -0700 Subject: [PATCH] Add new martial arts to CQB CBM (#58021) * Add all newer martial arts to CQB CBM. * fix styles. * fix styles. * JSONify the styles based on dseguin's code. * clean up declared value but not used. * Update bionics documentation. Co-authored-by: aMegaSloth --- data/json/bionics.json | 31 +++++++++++++++++++ doc/JSON_INFO.md | 1 + src/avatar.cpp | 67 ++++++++++-------------------------------- src/bionics.cpp | 1 + src/bionics.h | 2 ++ 5 files changed, 51 insertions(+), 51 deletions(-) diff --git a/data/json/bionics.json b/data/json/bionics.json index 26553d0755332..5f4fc47e0277a 100644 --- a/data/json/bionics.json +++ b/data/json/bionics.json @@ -674,6 +674,37 @@ "act_cost": "20 J", "react_cost": "20 J", "time": 1, + "known_ma_styles": [ + "style_aikido", + "style_barbaran", + "style_biojutsu", + "style_boxing", + "style_capoeira", + "style_centipede", + "style_crane", + "style_dragon", + "style_eskrima", + "style_fencing", + "style_judo", + "style_karate", + "style_krav_maga", + "style_leopard", + "style_muay_thai", + "style_ninjutsu", + "style_niten", + "style_pankration", + "style_scorpion", + "style_silat", + "style_snake", + "style_sojutsu", + "style_taekwondo", + "style_tai_chi", + "style_tiger", + "style_toad", + "style_venom_snake", + "style_wingchun", + "style_zui_quan" + ], "flags": [ "BIONIC_TOGGLED" ] }, { diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index f123907657614..97d31a2fa868f 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -975,6 +975,7 @@ mod = min( max, ( limb_score / denominator ) - subtract ); | upgraded_bionic | (_optional_) Bionic that can be upgraded by installing this one. | available_upgrades | (_optional_) Upgrades available for this bionic, i.e. the list of bionics having this one referenced by `upgraded_bionic`. | encumbrance | (_optional_) A list of body parts and how much this bionic encumber them. +| known_ma_styles | (_optional_) A list of martial art styles that are known to the wearer when the bionic is activated | weight_capacity_bonus | (_optional_) Bonus to weight carrying capacity in grams, can be negative. Strings can be used - "5000 g" or "5 kg" (default: `0`) | weight_capacity_modifier | (_optional_) Factor modifying base weight carrying capacity. (default: `1`) | canceled_mutations | (_optional_) A list of mutations/traits that are removed when this bionic is installed (e.g. because it replaces the fault biological part). diff --git a/src/avatar.cpp b/src/avatar.cpp index bda6acd8f6c2d..5c3cadf716464 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -16,6 +16,7 @@ #include "action.h" #include "activity_type.h" #include "activity_actor_definitions.h" +#include "bionics.h" #include "bodypart.h" #include "calendar.h" #include "cata_assert.h" @@ -82,7 +83,6 @@ #include "vpart_position.h" static const bionic_id bio_cloak( "bio_cloak" ); -static const bionic_id bio_cqb( "bio_cqb" ); static const bionic_id bio_soporific( "bio_soporific" ); static const efftype_id effect_alarm_clock( "alarm_clock" ); @@ -107,26 +107,6 @@ static const itype_id itype_mut_longpull( "mut_longpull" ); static const json_character_flag json_flag_ALARMCLOCK( "ALARMCLOCK" ); -static const matype_id style_aikido( "style_aikido" ); -static const matype_id style_biojutsu( "style_biojutsu" ); -static const matype_id style_boxing( "style_boxing" ); -static const matype_id style_capoeira( "style_capoeira" ); -static const matype_id style_crane( "style_crane" ); -static const matype_id style_dragon( "style_dragon" ); -static const matype_id style_judo( "style_judo" ); -static const matype_id style_karate( "style_karate" ); -static const matype_id style_krav_maga( "style_krav_maga" ); -static const matype_id style_leopard( "style_leopard" ); -static const matype_id style_muay_thai( "style_muay_thai" ); -static const matype_id style_ninjutsu( "style_ninjutsu" ); -static const matype_id style_pankration( "style_pankration" ); -static const matype_id style_snake( "style_snake" ); -static const matype_id style_taekwondo( "style_taekwondo" ); -static const matype_id style_tai_chi( "style_tai_chi" ); -static const matype_id style_tiger( "style_tiger" ); -static const matype_id style_wingchun( "style_wingchun" ); -static const matype_id style_zui_quan( "style_zui_quan" ); - static const move_mode_id move_mode_crouch( "crouch" ); static const move_mode_id move_mode_prone( "prone" ); static const move_mode_id move_mode_run( "run" ); @@ -1782,29 +1762,6 @@ void avatar::add_pain_msg( int val, const bodypart_id &bp ) const } } -// ids of martial art styles that are available with the bio_cqb bionic. -static const std::vector bio_cqb_styles{ { - style_aikido, - style_biojutsu, - style_boxing, - style_capoeira, - style_crane, - style_dragon, - style_judo, - style_karate, - style_krav_maga, - style_leopard, - style_muay_thai, - style_ninjutsu, - style_pankration, - style_snake, - style_taekwondo, - style_tai_chi, - style_tiger, - style_wingchun, - style_zui_quan - }}; - bool character_martial_arts::pick_style( const avatar &you ) // Style selection menu { enum style_selection { @@ -1812,14 +1769,25 @@ bool character_martial_arts::pick_style( const avatar &you ) // Style selection STYLE_OFFSET }; + // Check for martial art styles known from active bionics + std::set bio_styles; + for( const bionic &bio : *you.my_bionics ) { + const std::vector &bio_ma_list = bio.id->ma_styles; + if( !bio_ma_list.empty() && you.has_active_bionic( bio.id ) ) { + bio_styles.insert( bio_ma_list.begin(), bio_ma_list.end() ); + } + } + std::vector selectable_styles; + if( bio_styles.empty() ) { + selectable_styles = ma_styles; + } else { + selectable_styles.insert( selectable_styles.begin(), bio_styles.begin(), bio_styles.end() ); + } + // If there are style already, cursor starts there // if no selected styles, cursor starts from no-style // Any other keys quit the menu - const std::vector &selectable_styles = you.has_active_bionic( - bio_cqb ) ? bio_cqb_styles : - ma_styles; - input_context ctxt( "MELEE_STYLE_PICKER", keyboard_mode::keycode ); ctxt.register_action( "SHOW_DESCRIPTION" ); @@ -1859,9 +1827,6 @@ bool character_martial_arts::pick_style( const avatar &you ) // Style selection if( selection >= STYLE_OFFSET ) { // If the currect style is selected, do not change styles - if( style_selected == selectable_styles[selection - STYLE_OFFSET] ) { - return false; - } avatar &u = const_cast( you ); style_selected->remove_all_buffs( u ); diff --git a/src/bionics.cpp b/src/bionics.cpp index 615a8ac79563d..6d46ca58a9874 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -365,6 +365,7 @@ void bionic_data::load( const JsonObject &jsobj, const std::string & ) optional( jsobj, was_loaded, "coverage_power_gen_penalty", coverage_power_gen_penalty ); optional( jsobj, was_loaded, "is_remote_fueled", is_remote_fueled ); + optional( jsobj, was_loaded, "known_ma_styles", ma_styles ); optional( jsobj, was_loaded, "learned_spells", learned_spells ); optional( jsobj, was_loaded, "learned_proficiencies", proficiencies ); optional( jsobj, was_loaded, "canceled_mutations", canceled_mutations ); diff --git a/src/bionics.h b/src/bionics.h index 5a132c40ff6d7..494fccd4c1163 100644 --- a/src/bionics.h +++ b/src/bionics.h @@ -109,6 +109,8 @@ struct bionic_data { std::vector deactivated_eocs; /** bionic enchantments */ std::vector enchantments; + /** kown martial arts styles */ + std::vector ma_styles; cata::value_ptr spell_on_activate;