Skip to content

Commit

Permalink
JSONize AEP_EVIL and implement intermittent artifact effects (#38221)
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT authored and ZhilkinSerg committed Apr 2, 2020
1 parent 2245f80 commit 09b9b99
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
16 changes: 16 additions & 0 deletions data/json/legacy_artifact_passive.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,21 @@
"type": "enchantment",
"id": "AEP_SPEED_DOWN",
"values": [ { "value": "SPEED", "add": -20 } ]
},
{
"type": "SPELL",
"id": "AEP_EVIL_SPELL",
"name": "EEEEEEVVVVVIIIIILLLL!",
"description": "You debugged in this spell! It makes you evil for 30 minutes.",
"valid_targets": [ "hostile", "ally", "self" ],
"effect": "target_attack",
"effect_str": "evil",
"min_duration": 180000,
"max_duration": 180000
},
{
"type": "enchantment",
"id": "AEP_EVIL",
"intermittent_activation": { "effects": [ { "frequency": "15 minutes", "spell_effects": [ { "id": "AEP_EVIL_SPELL" } ] } ] }
}
]
12 changes: 11 additions & 1 deletion src/magic_enchantment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void enchantment::load( const JsonObject &jo, const std::string & )

if( jo.has_object( "intermittent_activation" ) ) {
JsonObject jobj = jo.get_object( "intermittent_activation" );
for( const JsonObject effect_obj : jo.get_array( "effects" ) ) {
for( const JsonObject effect_obj : jobj.get_array( "effects" ) ) {
time_duration dur = read_from_json_string<time_duration>( *effect_obj.get_raw( "frequency" ),
time_duration::units );
if( effect_obj.has_array( "spell_effects" ) ) {
Expand Down Expand Up @@ -374,6 +374,16 @@ void enchantment::activate_passive( Character &guy ) const

guy.mod_num_dodges_bonus( get_value_add( mod::BONUS_DODGE ) );
guy.mod_num_dodges_bonus( mult_bonus( mod::BONUS_DODGE, guy.get_num_dodges_base() ) );

for( const std::pair<const time_duration, std::vector<fake_spell>> &activation :
intermittent_activation ) {
// a random approximation!
if( one_in( to_seconds<int>( activation.first ) ) ) {
for( const fake_spell &fake : activation.second ) {
fake.get_spell( 0 ).cast_all_effects( guy, guy.pos() );
}
}
}
}

void enchantment::cast_hit_you( Character &caster, const tripoint &target ) const
Expand Down

0 comments on commit 09b9b99

Please sign in to comment.