From 8d68fab094c5dfb521e7d9b41c74fa588c6ccf5c Mon Sep 17 00:00:00 2001 From: KorGgenT Date: Thu, 20 Feb 2020 20:18:52 -0500 Subject: [PATCH] JSONize AEP_EVIL and implement intermittent artifact effects (#38221) --- data/json/legacy_artifact_passive.json | 16 ++++++++++++++++ src/magic_enchantment.cpp | 12 +++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/data/json/legacy_artifact_passive.json b/data/json/legacy_artifact_passive.json index 20924033ff565..f7ab1028403f8 100644 --- a/data/json/legacy_artifact_passive.json +++ b/data/json/legacy_artifact_passive.json @@ -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" } ] } ] } } ] diff --git a/src/magic_enchantment.cpp b/src/magic_enchantment.cpp index e095fdd84644d..d2b222fdd70bd 100644 --- a/src/magic_enchantment.cpp +++ b/src/magic_enchantment.cpp @@ -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( *effect_obj.get_raw( "frequency" ), time_duration::units ); if( effect_obj.has_array( "spell_effects" ) ) { @@ -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> &activation : + intermittent_activation ) { + // a random approximation! + if( one_in( to_seconds( 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