Skip to content

Commit

Permalink
JSONize AEP_SMOKE and add emitters to enchantments (#38260)
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT authored and ZhilkinSerg committed Mar 15, 2020
1 parent 3c1451b commit 144d032
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions data/json/emit.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions data/json/legacy_artifact_passive.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/magic_enchantment.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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" );
Expand Down Expand Up @@ -250,6 +252,9 @@ void enchantment::serialize( JsonOut &jsout ) const

jsout.member( "has", io::enum_to_string<has>( active_conditions.first ) );
jsout.member( "condition", io::enum_to_string<condition>( active_conditions.second ) );
if( emitter ) {
jsout.member( "emitter", emitter );
}

if( !hit_you_effect.empty() ) {
jsout.member( "hit_you_effect", hit_you_effect );
Expand Down Expand Up @@ -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<const time_duration, std::vector<fake_spell>> &activation :
intermittent_activation ) {
// a random approximation!
Expand Down
1 change: 1 addition & 0 deletions src/magic_enchantment.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class enchantment
// casts all the hit_me_effects on self
void cast_hit_me( Character &caster ) const;
private:
cata::optional<emit_id> emitter;
// values that add to the base value
std::map<mod, int> values_add;
// values that get multiplied to the base value
Expand Down

0 comments on commit 144d032

Please sign in to comment.