From d2f0059c33544b7657b7893919c1b73fe9f7bbe4 Mon Sep 17 00:00:00 2001 From: Curtis Merrill Date: Thu, 12 Mar 2020 13:05:36 -0400 Subject: [PATCH] JSONize AEP_SMOKE and add emitters to enchantments (#38260) --- data/json/emit.json | 9 +++++++++ data/json/legacy_artifact_passive.json | 5 +++++ src/magic_enchantment.cpp | 8 ++++++++ src/magic_enchantment.h | 1 + 4 files changed, 23 insertions(+) diff --git a/data/json/emit.json b/data/json/emit.json index 6fb5cc798f6d9..f4f15d0f76d2d 100644 --- a/data/json/emit.json +++ b/data/json/emit.json @@ -15,6 +15,15 @@ "intensity": 3, "chance": 2 }, + { + "id": "emit_AEP_SMOKE", + "type": "emit", + "//": "Intermittent smoke from an artifact", + "field": "fd_smoke", + "intensity": 3, + "chance": 5, + "qty": 15 + }, { "id": "emit_smoke_blast", "type": "emit", diff --git a/data/json/legacy_artifact_passive.json b/data/json/legacy_artifact_passive.json index f7ab1028403f8..ed052a7bc71fa 100644 --- a/data/json/legacy_artifact_passive.json +++ b/data/json/legacy_artifact_passive.json @@ -73,6 +73,11 @@ "id": "AEP_SPEED_DOWN", "values": [ { "value": "SPEED", "add": -20 } ] }, + { + "type": "enchantment", + "id": "AEP_SMOKE", + "emitter": "emit_AEP_SMOKE" + }, { "type": "SPELL", "id": "AEP_EVIL_SPELL", diff --git a/src/magic_enchantment.cpp b/src/magic_enchantment.cpp index d2b222fdd70bd..8c6f0f700cb9f 100644 --- a/src/magic_enchantment.cpp +++ b/src/magic_enchantment.cpp @@ -1,6 +1,7 @@ #include "magic_enchantment.h" #include "character.h" +#include "emit.h" #include "enum_conversions.h" #include "game.h" #include "generic_factory.h" @@ -197,6 +198,7 @@ void enchantment::load( const JsonObject &jo, const std::string & ) jo.read( "hit_you_effect", hit_you_effect ); jo.read( "hit_me_effect", hit_me_effect ); + jo.read( "emitter", emitter ); if( jo.has_object( "intermittent_activation" ) ) { JsonObject jobj = jo.get_object( "intermittent_activation" ); @@ -250,6 +252,9 @@ void enchantment::serialize( JsonOut &jsout ) const jsout.member( "has", io::enum_to_string( active_conditions.first ) ); jsout.member( "condition", io::enum_to_string( active_conditions.second ) ); + if( emitter ) { + jsout.member( "emitter", emitter ); + } if( !hit_you_effect.empty() ) { jsout.member( "hit_you_effect", hit_you_effect ); @@ -375,6 +380,9 @@ 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() ) ); + if( emitter ) { + g->m.emit_field( guy.pos(), *emitter ); + } for( const std::pair> &activation : intermittent_activation ) { // a random approximation! diff --git a/src/magic_enchantment.h b/src/magic_enchantment.h index 9fce4e38b0b8f..e8d66b3aa293b 100644 --- a/src/magic_enchantment.h +++ b/src/magic_enchantment.h @@ -138,6 +138,7 @@ class enchantment // casts all the hit_me_effects on self void cast_hit_me( Character &caster ) const; private: + cata::optional emitter; // values that add to the base value std::map values_add; // values that get multiplied to the base value