From 0b97f1a213764316845be95b26cb936ca79962db 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 467ecd29dddba..158a700ee854e 100644 --- a/data/json/legacy_artifact_active.json +++ b/data/json/legacy_artifact_active.json @@ -112,5 +112,30 @@ "effect": "vomit", "base_casting_time": 100, "message": "A wave of nausea passes through you!" + }, + { + "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 c90b2d89a5c17..34e6bfd7f53e4 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. + ##### For Spells that have an attack type, these are the available damage types: * "fire" * "acid" diff --git a/src/magic.cpp b/src/magic.cpp index 9bbf563437d4d..7fed9fece001a 100644 --- a/src/magic.cpp +++ b/src/magic.cpp @@ -205,6 +205,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 5bbdc80ba51d7..59ff256d682c0 100644 --- a/src/magic.h +++ b/src/magic.h @@ -480,6 +480,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 );