Skip to content

Commit 5ce5333

Browse files
committed
Allow EOCs to read artifact resonance
1 parent 0473ef4 commit 5ce5333

File tree

7 files changed

+30
-0
lines changed

7 files changed

+30
-0
lines changed

doc/JSON/NPCs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,7 @@ _some functions support array arguments or kwargs, denoted with square brackets
14021402
| climate_control_str_heat() ||| u, n | return amount of heat climate control that character currently has (character feels better in warm places with it), in warmth points; default 0, affected by CLIMATE_CONTROL_HEAT enchantment.<br/><br/>Example:<br/>`"condition": { "math": [ "u_climate_control_str_heat() < 0" ] }`|
14031403
| climate_control_str_chill() ||| u, n | return amount of chill climate control that character currently has (character feels better in cold places with it), in warmth points; default 0, affected by CLIMATE_CONTROL_HEAT enchantment.<br/><br/>Example:<br/>`"condition": { "math": [ "n_climate_control_str_chill() < 0" ] }`|
14041404
| calories() ||| u, n | Return amount of calories character has. If used on item, return amount of calories this item gives when consumed (not affected by enchantments or mutations). Optional kwargs:<br/>`format`: `s`/`v` - return the value in specific format. Can be `percent` (return percent to the healthy amount of calories, `100` being the target, bmi 25, or 110000 kcal) or `raw`. If now used, `raw` is used by default.<br/>`dont_affect_weariness`: `true`/`false` (default false) When assigning value, whether the gained/spent calories should be tracked by weariness.<br/><br/>Example:<br/>`"condition": { "math": [ "u_calories() < 0" ] }`<br/>`"condition": { "math": [ "u_calories('format': 'percent') > 0" ] }`<br/>`"condition": { "math": [ "u_calories() = 110000" ] }`|
1405+
| artifact_resonance() ||| u, n | Return amount of total artifact resonance character has. If used on item, return resonance of that item only. <br/><br/>Example:<br/>`"condition": { "math": [ "u_artifact_resonance() > 0" ] }`<br/>|
14051406
| get_calories_daily() ||| g | Return amount of calories character consumed before, up to 30 days, in kcal. Calorie diary is something only character has, so it can't be used with NPCs. Optional kwargs:<br/>`day`: `d/v` - picks the date the value would be pulled from, from 0 to 30. Default 0, meaning amount of calories you consumed today.<br/>`type`: `s/v` - picks the data that would be pulled. Possible values are: `spent` - how much calories character spent in different activities throughout the day; `gained` - how much calories character ate that day; `ingested` - how much calories character processed that day; `total` - `gained` minus `spent`. Default is `total`;<br/><br/>Example:<br/>`"condition": { "math": [ "get_calories_daily() > 1000" ] }`<br/> `{ "math": [ "foo = get_calories_daily('type':'gained', 'day':'1')" ] }`|
14061407
| quality( `s` / `v` ) | ✅ | ❌ | u, n | Return the level of a specified item tool quality. Only usable on item talkers.<br/>Argument is the quality ID. Returns the lowest integer value if the item lacks the specified quality.<br/>Optional kwargs:<br/>`strict`: `true` / `false` (default false) When true the item must be empty to have the boiling quality.<br/><br/>Example<br/>`"condition: { "math": [ " u_quality('HACK') > 0 " ] }`<br/>`{ "math": [ "_cut_quality = u_quality('CUT') " ] }`<br/>`condition: { "math": [ " u_quality('BOIL', 'strict': true ) > 0" ] }`
14071408

src/math_parser_diag.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ double distance_eval( const_dialogue const &d, char /* scope */,
200200
return rl_dist( get_pos( params[0] ), get_pos( params[1] ) );
201201
}
202202

203+
double artifact_resonance_eval( const_dialogue const &d, char scope,
204+
std::vector<diag_value> const & /* params */,
205+
diag_kwargs const & /* kwargs */ )
206+
{
207+
return d.const_actor( is_beta( scope ) )->get_artifact_resonance();
208+
}
209+
203210
double damage_level_eval( const_dialogue const &d, char scope,
204211
std::vector<diag_value> const & /* params */,
205212
diag_kwargs const & /* kwargs */ )
@@ -1657,6 +1664,7 @@ std::map<std::string_view, dialogue_func> const dialogue_funcs{
16571664
{ "addiction_intensity", { "un", 1, addiction_intensity_eval } },
16581665
{ "addiction_turns", { "un", 1, addiction_turns_eval, addiction_turns_ass } },
16591666
{ "armor", { "un", 2, armor_eval } },
1667+
{ "artifact_resonance", { "un", 0, artifact_resonance_eval } },
16601668
{ "attack_speed", { "un", 0, attack_speed_eval } },
16611669
{ "speed", { "un", 0, move_speed_eval } },
16621670
{ "characters_nearby", { "ung", 0, characters_nearby_eval, {}, { "radius", "attitude", "location" } } },

src/talker.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ class const_talker
152152
return false;
153153
}
154154
// stats, skills, traits, bionics, and magic
155+
virtual int get_artifact_resonance() const {
156+
return 0;
157+
}
155158
virtual int str_cur() const {
156159
return 0;
157160
}

src/talker_character.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "item_location.h"
2929
#include "itype.h"
3030
#include "magic.h"
31+
#include "magic_enchantment.h"
3132
#include "map.h"
3233
#include "martialarts.h"
3334
#include "math_parser_diag_value.h"
@@ -123,6 +124,11 @@ units::temperature talker_character_const::get_cur_part_temp( const bodypart_id
123124
return me_chr_const->get_part_temp_conv( bp );
124125
}
125126

127+
int talker_character_const::get_artifact_resonance() const
128+
{
129+
return me_chr_const->enchantment_cache->get_value_add( enchant_vals::mod::ARTIFACT_RESONANCE );
130+
}
131+
126132
int talker_character_const::str_cur() const
127133
{
128134
return me_chr_const->str_cur;

src/talker_character.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class talker_character_const: virtual public const_talker
5151
units::temperature get_cur_part_temp( const bodypart_id &bp ) const override;
5252

5353
// stats, skills, traits, bionics, and magic
54+
int get_artifact_resonance() const override;
5455
int str_cur() const override;
5556
int dex_cur() const override;
5657
int int_cur() const override;

src/talker_item.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "item.h"
1111
#include "item_location.h"
1212
#include "itype.h"
13+
#include "magic_enchantment.h"
1314
#include "math_parser_diag_value.h"
1415
#include "messages.h"
1516
#include "units.h"
@@ -106,6 +107,15 @@ units::energy talker_item_const::power_max() const
106107
return 1_mJ * me_it_const->get_item()->ammo_capacity( ammo_battery );
107108
}
108109

110+
int talker_item_const::get_artifact_resonance() const
111+
{
112+
int ret = 0;
113+
for( enchant_cache &this_ench : me_it_const->get_item()->get_proc_enchantments() ) {
114+
ret += this_ench.get_value_add( enchant_vals::mod::ARTIFACT_RESONANCE );
115+
}
116+
return ret;
117+
}
118+
109119
int talker_item_const::get_count() const
110120
{
111121
return me_it_const->get_item()->count();

src/talker_item.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class talker_item_const: public const_talker_cloner<talker_item_const>
5252
int get_hp_max( const bodypart_id & ) const override;
5353
units::energy power_cur() const override;
5454
units::energy power_max() const override;
55+
int get_artifact_resonance() const override;
5556

5657
int get_count() const override;
5758
int coverage_at( bodypart_id & ) const override;

0 commit comments

Comments
 (0)