-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new martial arts to CQB CBM #58021
Add new martial arts to CQB CBM #58021
Conversation
This is the better approach in my opinion. This is an easy thing to JSON-ify, so I went ahead and did the work for you: Diff (click to expand):diff --git a/data/json/bionics.json b/data/json/bionics.json
index 26553d0755..2178112f5e 100644
--- a/data/json/bionics.json
+++ b/data/json/bionics.json
@@ -674,6 +674,39 @@
"act_cost": "20 J",
"react_cost": "20 J",
"time": 1,
+ "known_ma_styles": [
+ "style_aikido",
+ "style_barbaran",
+ "style_biojutsu",
+ "style_bojutsu",
+ "style_boxing",
+ "style_capoeira",
+ "style_centipede",
+ "style_crane",
+ "style_dragon",
+ "style_eskrima",
+ "style_fencing",
+ "style_judo",
+ "style_karate",
+ "style_krav_maga",
+ "style_leopard",
+ "style_lizard",
+ "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/src/avatar.cpp b/src/avatar.cpp
index bda6acd8f6..e302c2c7fd 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"
@@ -107,26 +108,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 +1763,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<matype_id> 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 +1770,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<matype_id> bio_styles;
+ for( const bionic &bio : *you.my_bionics ) {
+ const std::vector<matype_id> &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<matype_id> 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<matype_id> &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" );
diff --git a/src/bionics.cpp b/src/bionics.cpp
index 615a8ac795..09bd7ed5b1 100644
--- a/src/bionics.cpp
+++ b/src/bionics.cpp
@@ -364,7 +364,7 @@ void bionic_data::load( const JsonObject &jsobj, const std::string & )
optional( jsobj, was_loaded, "power_gen_emission", power_gen_emission );
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 5a132c40ff..494fccd4c1 100644
--- a/src/bionics.h
+++ b/src/bionics.h
@@ -109,6 +109,8 @@ struct bionic_data {
std::vector<effect_on_condition_id> deactivated_eocs;
/** bionic enchantments */
std::vector<enchantment_id> enchantments;
+ /** kown martial arts styles */
+ std::vector<matype_id> ma_styles;
cata::value_ptr<fake_spell> spell_on_activate; With this, you can add a list of martial art styles to any active bionic by adding a |
This would be good for grouping styles together and making multiple close combat CQB esque bionics so you don't have one that does them all. Very neat! |
9d7f015
to
26f2d50
Compare
Thanks for the code @dseguin I feel like I was able to port it over fine. It built and ran. |
Cheers, looks good! Might also be a good idea to update the document with the new field:
|
* 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 <[email protected]>
Summary
Bugfixes "Add newer martial arts styles to Close Quarters Battle CBM"
Purpose of change
Updates the hard coded list of styles that can be accessed by the Close Quarters Battle CBM
Describe the solution
Make edits to the avatar.cpp
Describe alternatives you've considered
Not doing anything? Second alternative is probably open an issue ticket so the CQB list isn't hard coded and pulls from actively loaded JSON. That is out of my abilities to do.
Testing
Complied and installed the CBM. Has all the newer styles that weren't present before.
Additional context