Skip to content

Commit

Permalink
AEA_BUGS
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT committed Sep 22, 2019
1 parent 178117c commit e034813
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 8 deletions.
6 changes: 6 additions & 0 deletions data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,12 @@
"context": [ "SPELL" ],
"description": "This spell requires focus to cast. The lower your focus, the higher failure rate to cast."
},
{
"id": "WONDER",
"type": "json_flag",
"context": [ "SPELL" ],
"description": "Chooses a spell at random to cast from extra_effects. See MAGIC.md for details"
},
{
"id": "NON_THRESH",
"type": "json_flag",
Expand Down
96 changes: 96 additions & 0 deletions data/json/legacy_artifact_active.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,101 @@
"effect": "vomit",
"base_casting_time": 100,
"message": "A wave of nausea passes through you!"
},
{
"type": "SPELL",
"id": "art_eff_pet",
"name": "Pet",
"description": "Makes the target a pet",
"valid_targets": [ "ally", "hostile" ],
"effect": "target_attack",
"effect_str": "pet",
"min_aoe": 2,
"max_aoe": 2,
"min_duration": 100,
"max_duration": 100
},
{
"type": "SPELL",
"id": "art_flies_buzz",
"name": "Artifact Flies Buzz",
"description": "Flies buzz around you",
"valid_targets": [ "self", "ground" ],
"message": "Flies buzz around you.",
"effect": "target_attack"
},
{
"type": "SPELL",
"id": "art_summon_flies",
"name": "Artifact Summon Flies",
"description": "Summons some flies",
"valid_targets": [ "ground" ],
"message": "Giant flies appear!",
"effect": "summon",
"effect_str": "mon_fly",
"min_damage": 2,
"max_damage": 4,
"min_aoe": 2,
"max_aoe": 2,
"extra_effects": [ { "id": "art_eff_pet" } ],
"flags": [ "RANDOM_DAMAGE", "PERMANENT" ]
},
{
"type": "SPELL",
"id": "art_summon_bees",
"name": "Artifact Summon Bees",
"description": "Giant bees appear!",
"valid_targets": [ "ground" ],
"message": "Giant bees appear!",
"effect": "summon",
"effect_str": "mon_bee",
"min_damage": 1,
"max_damage": 3,
"min_aoe": 2,
"max_aoe": 2,
"extra_effects": [ { "id": "art_eff_pet" } ],
"flags": [ "RANDOM_DAMAGE", "PERMANENT" ]
},
{
"type": "SPELL",
"id": "art_summon_wasps",
"name": "Artifact Summon Wasps",
"description": "Summons some wasps",
"valid_targets": [ "ground" ],
"min_damage": 1,
"max_damage": 2,
"flags": [ "RANDOM_DAMAGE", "PERMANENT" ],
"effect": "summon",
"effect_str": "mon_wasp",
"min_aoe": 2,
"max_aoe": 2,
"extra_effects": [ { "id": "art_eff_pet" } ],
"message": "Giant wasps appear!"
},
{
"type": "SPELL",
"id": "AEA_BUGS",
"name": "Artifact Bugs",
"description": "Summon some bugs.",
"valid_targets": [ "ground", "self" ],
"effect": "none",
"//": "This is a shell for the spell that actually gets cast.",
"base_casting_time": 100,
"flags": [ "WONDER" ],
"min_damage": 1,
"max_damage": 1,
"message": "",
"extra_effects": [
{ "id": "art_flies_buzz" },
{ "id": "art_flies_buzz" },
{ "id": "art_flies_buzz" },
{ "id": "art_flies_buzz" },
{ "id": "art_summon_flies" },
{ "id": "art_summon_flies" },
{ "id": "art_summon_flies" },
{ "id": "art_summon_bees" },
{ "id": "art_summon_bees" },
{ "id": "art_summon_wasps" }
]
}
]
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.
* "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:
* "fire"
* "acid"
Expand Down
35 changes: 27 additions & 8 deletions src/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ std::string enum_to_string<spell_flag>( spell_flag data )
case spell_flag::RANDOM_AOE: return "RANDOM_AOE";
case spell_flag::RANDOM_DAMAGE: return "RANDOM_DAMAGE";
case spell_flag::RANDOM_DURATION: return "RANDOM_DURATION";
case spell_flag::WONDER: return "WONDER";
case spell_flag::LAST: break;
}
debugmsg( "Invalid spell_flag" );
Expand Down Expand Up @@ -1066,15 +1067,33 @@ void spell::cast_spell_effect( Creature &source, const tripoint &target ) const

void spell::cast_all_effects( Creature &source, const tripoint &target ) const
{
// first call the effect of the main spell
cast_spell_effect( source, target );
for( const fake_spell &extra_spell : type->additional_spells ) {
spell sp = extra_spell.get_spell( extra_spell.level );
if( has_flag( spell_flag::WONDER ) ) {
const auto iter = type->additional_spells.begin();
for( int num_spells = abs( damage() ); num_spells > 0; num_spells-- ) {
const int rand_spell = rng( 0, type->additional_spells.size() - 1 );
spell sp = ( iter + rand_spell )->get_spell( ( iter + rand_spell )->level );

if( extra_spell.self ) {
sp.cast_all_effects( source, source.pos() );
} else {
sp.cast_all_effects( source, target );
// This spell flag makes it so the message of the spell that's cast using this spell will be sent.
// if a message is added to the casting spell, it will be sent as well.
source.add_msg_if_player( sp.message() );

if( ( iter + rand_spell )->self ) {
sp.cast_all_effects( source, source.pos() );
} else {
sp.cast_all_effects( source, target );
}
}
} else {
// first call the effect of the main spell
cast_spell_effect( source, target );
for( const fake_spell &extra_spell : type->additional_spells ) {
spell sp = extra_spell.get_spell( extra_spell.level );

if( extra_spell.self ) {
sp.cast_all_effects( source, source.pos() );
} else {
sp.cast_all_effects( source, target );
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum spell_flag {
RANDOM_AOE, // picks random number between min+increment*level and max instead of normal behavior
RANDOM_DAMAGE, // picks random number between min+increment*level and max instead of normal behavior
RANDOM_DURATION, // picks random number between min+increment*level and max instead of normal behavior
WONDER, // instead of casting each of the extra_spells, it picks N of them and casts them (where N is std::min( damage(), number_of_spells ))
LAST
};

Expand Down

0 comments on commit e034813

Please sign in to comment.