Skip to content

Commit

Permalink
add revolver perk
Browse files Browse the repository at this point in the history
  • Loading branch information
GuardianDll committed Sep 16, 2024
1 parent 3197800 commit eb7bfb1
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 0 deletions.
19 changes: 19 additions & 0 deletions data/mods/BombasticPerks/perkmenu.json
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,25 @@
],
"topic": "TALK_PERK_MENU_SELECT_PLAYSTYLE"
},
{
"condition": { "not": { "u_has_trait": "revolvers_are_cool" } },
"text": "Gain [<trait_name:revolvers_are_cool>]",
"effect": [
{ "set_string_var": "<trait_name:revolvers_are_cool>", "target_var": { "context_val": "trait_name" } },
{
"set_string_var": "<trait_description:revolvers_are_cool>",
"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 [<trait_name:perk_empath>]",
Expand Down
20 changes: 20 additions & 0 deletions data/mods/BombasticPerks/perks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
]
}
]
}
]
18 changes: 18 additions & 0 deletions doc/EFFECT_ON_CONDITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions src/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 },
Expand Down
3 changes: 3 additions & 0 deletions src/talker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions src/talker_character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions src/talker_character.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class talker_character_const: public talker_cloner<talker_character_const>
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;

Check failure on line 176 in src/talker_character.h

View workflow job for this annotation

GitHub Actions / build (src)

'wielded_with_weapon_skill' overrides a member function but is not marked 'override' [clang-diagnostic-inconsistent-missing-override,-warnings-as-errors]

Check failure on line 176 in src/talker_character.h

View workflow job for this annotation

GitHub Actions / build (src)

annotate this function with 'override' or (rarely) 'final' [modernize-use-override,-warnings-as-errors]

Check failure on line 176 in src/talker_character.h

View workflow job for this annotation

GitHub Actions / Basic Build and Test (Clang 10, Ubuntu, Curses)

'wielded_with_weapon_skill' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-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;

Expand Down

0 comments on commit eb7bfb1

Please sign in to comment.