Skip to content

Commit

Permalink
MA flags (CleverRaven#55403)
Browse files Browse the repository at this point in the history
Co-authored-by: Venera3 <[email protected]>
  • Loading branch information
Venera3 and Venera3 authored Feb 17, 2022
1 parent 5b45ea8 commit 0024b85
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/MARTIALART_JSON.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"forbidden_buffs_all": [ "eskrima_hit_buff" ], // This technique is forbidden if all of the named buffs are active
"req_flags": [ "" ] // List of item flags the used weapon needs to be eligible for the technique
"required_char_flags": [ "" ] // List of "character" (bionic, trait, effect or bodypart) flags the character needs to be able to use this technique
"required_char_flags_all": [ ""] // This technique requires all of the listed character flags to trigger
"forbidden_char_flags": [ "" ] // List of character flags disabling this technique
"crit_tec" : true, // This technique only works on a critical hit
"crit_ok" : true, // This technique works on both normal and critical hits
Expand Down
9 changes: 9 additions & 0 deletions src/martialarts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ void ma_requirements::load( const JsonObject &jo, const std::string & )

optional( jo, was_loaded, "req_flags", req_flags, string_id_reader<::json_flag> {} );
optional( jo, was_loaded, "required_char_flags", req_char_flags );
optional( jo, was_loaded, "required_char_flags_all", req_char_flags_all );
optional( jo, was_loaded, "forbidden_char_flags", forbidden_char_flags );

optional( jo, was_loaded, "skill_requirements", min_skill, ma_skill_reader {} );
Expand Down Expand Up @@ -612,6 +613,14 @@ bool ma_requirements::is_valid_character( const Character &u ) const
}
}

if( !req_char_flags_all.empty() ) {
for( const json_character_flag &flag : req_char_flags_all ) {
if( !u.has_flag( flag ) ) {
return false;
}
}
}

if( !forbidden_char_flags.empty() ) {
bool has_flag = false;
for( const json_character_flag &flag : forbidden_char_flags ) {
Expand Down
3 changes: 2 additions & 1 deletion src/martialarts.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ struct ma_requirements {


std::set<flag_id> req_flags; // any item flags required for this technique
cata::flat_set<json_character_flag> req_char_flags; // Character flags required
cata::flat_set<json_character_flag> req_char_flags; // any listed character flags required
cata::flat_set<json_character_flag> req_char_flags_all; // all listed character flags required
cata::flat_set<json_character_flag> forbidden_char_flags; // Character flags disabling the technique

ma_requirements() {
Expand Down

0 comments on commit 0024b85

Please sign in to comment.