Skip to content
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

Merged
merged 6 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
},
{
Expand Down
1 change: 1 addition & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
67 changes: 16 additions & 51 deletions src/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" );
Expand All @@ -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" );
Expand Down Expand Up @@ -1782,44 +1762,32 @@ 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 {
KEEP_HANDS_FREE = 0,
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" );

Expand Down Expand Up @@ -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<avatar &>( you );
style_selected->remove_all_buffs( u );
Expand Down
1 change: 1 addition & 0 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 2 additions & 0 deletions src/bionics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down