diff --git a/data/mods/BombasticPerks/perkmenu.json b/data/mods/BombasticPerks/perkmenu.json index 97d95907b083e..7eece1ede3517 100644 --- a/data/mods/BombasticPerks/perkmenu.json +++ b/data/mods/BombasticPerks/perkmenu.json @@ -1361,6 +1361,25 @@ ], "topic": "TALK_PERK_MENU_SELECT_PLAYSTYLE" }, + { + "condition": { "not": { "u_has_trait": "revolvers_are_cool" } }, + "text": "Gain []", + "effect": [ + { "set_string_var": "", "target_var": { "context_val": "trait_name" } }, + { + "set_string_var": "", + "target_var": { "context_val": "trait_description" } + }, + { "set_string_var": "revolvers_are_cool", "target_var": { "context_val": "trait_id" } }, + { + "set_string_var": "No Requirements", + "target_var": { "context_val": "trait_requirement_description" }, + "i18n": true + }, + { "set_condition": "perk_condition", "condition": { "math": [ "0", "==", "0" ] } } + ], + "topic": "TALK_PERK_MENU_SELECT_PLAYSTYLE" + }, { "condition": { "not": { "u_has_trait": "perk_empath" } }, "text": "Gain []", diff --git a/data/mods/BombasticPerks/perks.json b/data/mods/BombasticPerks/perks.json index 26d3da1b2caec..235529038d830 100644 --- a/data/mods/BombasticPerks/perks.json +++ b/data/mods/BombasticPerks/perks.json @@ -1178,5 +1178,25 @@ "valid": false, "description": "Exposure to portal storms and related phenomena causes your body change along predictable lines. When out in a portal storm without any protection, you periodically have a chance to mutate.", "category": [ "perk" ] + }, + { + "type": "mutation", + "id": "revolvers_are_cool", + "name": { "str": "Double Action Action" }, + "description": "You always knew nothing can beat the good old six shooters. You have a minor bonus using revolvers.", + "points": 0, + "purifiable": false, + "valid": false, + "category": [ "perk" ], + "enchantments": [ + { + "condition": { "and": [ { "u_has_wielded_with_flag": "RELOAD_ONE" }, { "u_has_wielded_with_skill": "pistol" } ] }, + "values": [ + { "value": "WEAPON_DISPERSION", "multiply": -0.25 }, + { "value": "RANGED_DAMAGE", "add": 6 }, + { "value": "RANGE", "add": 4 } + ] + } + ] } ] diff --git a/doc/EFFECT_ON_CONDITION.md b/doc/EFFECT_ON_CONDITION.md index b1e583f3e731b..66d27a3c46a5d 100644 --- a/doc/EFFECT_ON_CONDITION.md +++ b/doc/EFFECT_ON_CONDITION.md @@ -961,6 +961,24 @@ check do you wield something with `LONG_SWORDS` weapon category { "u_has_wielded_with_weapon_category": "LONG_SWORDS" } ``` +### `u_has_wielded_with_skill`, `npc_has_wielded_with_skill` +- type: string or [variable object](#variable-object) +- return true if alpha or beta talker wield a gun or melee weapon with this skill +- gun skills are delivered from `skill` field +- melee weapon skill is delivered from the highest damage type item has + +#### Valid talkers: + +| Avatar | Character | NPC | Monster | Furniture | Item | +| ------ | --------- | --------- | ---- | ------- | --- | +| ✔️ | ✔️ | ✔️ | ❌ | ❌ | ❌ | + +#### Examples +check do you wield a gun with `pistol` skill +```json +{ "u_has_wielded_with_skill": "pistol" } +``` + ### `u_can_see`, `npc_can_see` - type: simple string - return true if alpha or beta talker can see (not blind) diff --git a/src/condition.cpp b/src/condition.cpp index ff4c9a56a5892..576da19339e17 100644 --- a/src/condition.cpp +++ b/src/condition.cpp @@ -1943,6 +1943,16 @@ conditional_t::func f_has_wielded_with_weapon_category( const JsonObject &jo, }; } +conditional_t::func f_has_wielded_with_skill( const JsonObject &jo, std::string_view member, + bool is_npc ) +{ + str_or_var w_skill = get_str_or_var( jo.get_member( member ), member, true ); + return [w_skill, is_npc]( dialogue const & d ) { + + return d.actor( is_npc )->wielded_with_weapon_skill( skill_id( w_skill.evaluate( d ) ) ); + }; +} + conditional_t::func f_can_see( bool is_npc ) { return [is_npc]( dialogue const & d ) { @@ -2531,6 +2541,7 @@ parsers = { {"u_has_worn_with_flag", "npc_has_worn_with_flag", jarg::member, &conditional_fun::f_has_worn_with_flag }, {"u_has_wielded_with_flag", "npc_has_wielded_with_flag", jarg::member, &conditional_fun::f_has_wielded_with_flag }, {"u_has_wielded_with_weapon_category", "npc_has_wielded_with_weapon_category", jarg::member, &conditional_fun::f_has_wielded_with_weapon_category }, + {"u_has_wielded_with_skill", "npc_has_wielded_with_skill", jarg::member, &conditional_fun::f_has_wielded_with_skill }, {"u_is_on_terrain", "npc_is_on_terrain", jarg::member, &conditional_fun::f_is_on_terrain }, {"u_is_on_terrain_with_flag", "npc_is_on_terrain_with_flag", jarg::member, &conditional_fun::f_is_on_terrain_with_flag }, {"u_is_in_field", "npc_is_in_field", jarg::member, &conditional_fun::f_is_in_field }, diff --git a/src/talker.h b/src/talker.h index 04670483c4db6..d9fcca4cb74a9 100644 --- a/src/talker.h +++ b/src/talker.h @@ -607,6 +607,9 @@ class talker virtual bool wielded_with_weapon_category( const weapon_category_id & ) const { return false; } + virtual bool wielded_with_weapon_skill( const skill_id & ) const { + return false; + } virtual bool has_item_with_flag( const flag_id & ) const { return false; } diff --git a/src/talker_character.cpp b/src/talker_character.cpp index 7d553cbf82056..677f7ff3f2662 100644 --- a/src/talker_character.cpp +++ b/src/talker_character.cpp @@ -780,6 +780,15 @@ bool talker_character_const::wielded_with_weapon_category( const weapon_category me_chr_const->get_wielded_item()->typeId()->weapon_category.count( w_cat ) > 0; } +bool talker_character_const::wielded_with_weapon_skill( const skill_id &w_skill ) const +{ + if( me_chr_const->get_wielded_item() ) { + item *it = me_chr_const->get_wielded_item().get_item(); + skill_id it_skill = it->is_gun() ? it->gun_skill() : it->melee_skill(); + return it_skill == w_skill; + } +} + bool talker_character_const::has_item_with_flag( const flag_id &flag ) const { return me_chr_const->cache_has_item_with( flag ); diff --git a/src/talker_character.h b/src/talker_character.h index 5935abef122b6..0a10f4a1d22e7 100644 --- a/src/talker_character.h +++ b/src/talker_character.h @@ -173,6 +173,7 @@ class talker_character_const: public talker_cloner bool worn_with_flag( const flag_id &flag, const bodypart_id &bp ) const override; bool wielded_with_flag( const flag_id &flag ) const override; bool wielded_with_weapon_category( const weapon_category_id &w_cat ) const override; + bool wielded_with_weapon_skill( const skill_id &w_skill ) const override; bool has_item_with_flag( const flag_id &flag ) const override; int item_rads( const flag_id &flag, aggregate_type agg_func ) const override;