From 2c23de4587733795be4573705ce40315d74d18b8 Mon Sep 17 00:00:00 2001 From: KorGgenT Date: Fri, 20 Sep 2019 23:48:53 -0400 Subject: [PATCH] AEA_DIM and AEA_LIGHT --- data/json/legacy_artifact_active.json | 25 ++++++++++++++++++++++++ doc/MAGIC.md | 2 ++ src/magic.cpp | 1 + src/magic.h | 2 ++ src/magic_spell_effect.cpp | 28 +++++++++++++++++++++++++++ 5 files changed, 58 insertions(+) diff --git a/data/json/legacy_artifact_active.json b/data/json/legacy_artifact_active.json index 3d51d0e278fcf..8d2c357794a3d 100644 --- a/data/json/legacy_artifact_active.json +++ b/data/json/legacy_artifact_active.json @@ -208,5 +208,30 @@ { "id": "art_summon_bees" }, { "id": "art_summon_wasps" } ] + }, + { + "type": "SPELL", + "id": "AEA_LIGHT", + "name": "Artifact Light", + "description": "Makes some light.", + "valid_targets": [ "self" ], + "effect": "timed_event", + "effect_str": "artifact_light", + "base_casting_time": 100, + "min_duration": 18000, + "max_duration": 18000, + "message": "You glow brightly!" + }, + { + "type": "SPELL", + "id": "AEA_DIM", + "name": "Artifact Dim", + "description": "Darkens the sky.", + "valid_targets": [ "self" ], + "effect": "timed_event", + "effect_str": "dim", + "min_duration": 30000, + "max_duration": 30000, + "message": "The sky starts to dim." } ] diff --git a/doc/MAGIC.md b/doc/MAGIC.md index 65771faaec58b..c57b6430206f0 100644 --- a/doc/MAGIC.md +++ b/doc/MAGIC.md @@ -92,6 +92,8 @@ Any aoe will manifest as a circular area centered on the target, and will only d * "vomit" - any creature within its area of effect will instantly vomit, if it's able to do so. +* "timed_event" - adds a timed event to the player only. valid timed events: "help", "wanted", "robot_attack", "spawn_wyrms", "amigara", "roots_die", "temple_open", "temple_flood", "temple_spawn", "dim", "artifact_light" NOTE: This was added only for artifact active effects. support is limited, use at your own risk. + * "WONDER" - Unlike the above, this is not an "effect" but a "flag". This alters the behavior of the parent spell drastically: The spell itself doesn't cast, but its damage and range information is used in order to cast the extra_effects. N of the extra_effects will be chosen at random to be cast, where N is the current damage of the spell (stacks with RANDOM_DAMAGE flag) and the message of the spell cast by this spell will also be displayed. If this spell's message is not wanted to be displayed, make sure the message is an empty string. ##### For Spells that have an attack type, these are the available damage types: diff --git a/src/magic.cpp b/src/magic.cpp index a6bf85318ce0b..026f5d8b0978f 100644 --- a/src/magic.cpp +++ b/src/magic.cpp @@ -206,6 +206,7 @@ void spell_type::load( JsonObject &jo, const std::string & ) { "translocate", spell_effect::translocate }, { "area_pull", spell_effect::area_pull }, { "area_push", spell_effect::area_push }, + { "timed_event", spell_effect::timed_event }, { "ter_transform", spell_effect::transform_blast }, { "vomit", spell_effect::vomit }, { "none", spell_effect::none } diff --git a/src/magic.h b/src/magic.h index 69fa0d870dfde..0372984e7f3ca 100644 --- a/src/magic.h +++ b/src/magic.h @@ -482,6 +482,8 @@ void spawn_ethereal_item( const spell &sp, Creature &, const tripoint & ); void recover_energy( const spell &sp, Creature &, const tripoint &target ); void spawn_summoned_monster( const spell &sp, Creature &caster, const tripoint &target ); void translocate( const spell &sp, Creature &caster, const tripoint &target ); +// adds a timed event to the caster only +void timed_event( const spell &sp, Creature &caster, const tripoint & ); void transform_blast( const spell &sp, Creature &caster, const tripoint &target ); void vomit( const spell &sp, Creature &caster, const tripoint &target ); void none( const spell &sp, Creature &, const tripoint &target ); diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 4d30c9e0311fd..52d41c74e1fbd 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -40,6 +40,7 @@ #include "ret_val.h" #include "rng.h" #include "translations.h" +#include "timed_event.h" static tripoint random_point( int min_distance, int max_distance, const tripoint &player_pos ) { @@ -611,6 +612,33 @@ void spell_effect::recover_energy( const spell &sp, Creature &caster, const trip sp.make_sound( caster.pos() ); } +void spell_effect::timed_event( const spell &sp, Creature &caster, const tripoint & ) +{ + const std::map timed_event_map{ + { "help", timed_event_type::TIMED_EVENT_HELP }, + { "wanted", timed_event_type::TIMED_EVENT_WANTED }, + { "robot_attack", timed_event_type::TIMED_EVENT_ROBOT_ATTACK }, + { "spawn_wyrms", timed_event_type::TIMED_EVENT_SPAWN_WYRMS }, + { "amigara", timed_event_type::TIMED_EVENT_AMIGARA }, + { "roots_die", timed_event_type::TIMED_EVENT_ROOTS_DIE }, + { "temple_open", timed_event_type::TIMED_EVENT_TEMPLE_OPEN }, + { "temple_flood", timed_event_type::TIMED_EVENT_TEMPLE_FLOOD }, + { "temple_spawn", timed_event_type::TIMED_EVENT_TEMPLE_SPAWN }, + { "dim", timed_event_type::TIMED_EVENT_DIM }, + { "artifact_light", timed_event_type::TIMED_EVENT_ARTIFACT_LIGHT } + }; + + timed_event_type spell_event = timed_event_type::TIMED_EVENT_NULL; + + const auto iter = timed_event_map.find( sp.effect_data() ); + if( iter != timed_event_map.cend() ) { + spell_event = iter->second; + } + + sp.make_sound( caster.pos() ); + g->timed_events.add( spell_event, calendar::turn + sp.duration_turns() ); +} + static bool is_summon_friendly( const spell &sp ) { const bool hostile = sp.has_flag( spell_flag::HOSTILE_SUMMON );