Skip to content

Commit

Permalink
Merge pull request #34140 from KorGgenT/AEA_DIM
Browse files Browse the repository at this point in the history
AEA_DIM and AEA_LIGHT
  • Loading branch information
ZhilkinSerg authored Sep 23, 2019
2 parents fe55636 + 2c23de4 commit e8cb375
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
25 changes: 25 additions & 0 deletions data/json/legacy_artifact_active.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
]
2 changes: 2 additions & 0 deletions doc/MAGIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 2 additions & 0 deletions src/magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
28 changes: 28 additions & 0 deletions src/magic_spell_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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<std::string, timed_event_type> 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 );
Expand Down

0 comments on commit e8cb375

Please sign in to comment.