Skip to content

Commit

Permalink
[Magiclysm] Allow spells to spawn items with their containers (#40097)
Browse files Browse the repository at this point in the history
* Allow spells to spawn items with their containers

Add a "WITH_CONTAINER" flag for spells to spawn items with containers.

* Update flags.json

Add description about flag "WITH_CONTAINER"
  • Loading branch information
RedShakespeare authored May 3, 2020
1 parent ecc602c commit b546c20
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,12 @@
"context": [ "SPELL" ],
"//": "pain altering spells can't be resisted (like with the deadened trait)"
},
{
"id": "WITH_CONTAINER",
"type": "json_flag",
"context": [ "SPELL" ],
"//": "items spawned by spells are put in their containers."
},
{
"id": "NON_THRESH",
"type": "json_flag",
Expand Down
1 change: 1 addition & 0 deletions src/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ std::string enum_to_string<spell_flag>( spell_flag data )
case spell_flag::RANDOM_TARGET: return "RANDOM_TARGET";
case spell_flag::MUTATE_TRAIT: return "MUTATE_TRAIT";
case spell_flag::PAIN_NORESIST: return "PAIN_NORESIST";
case spell_flag::WITH_CONTAINER: return "WITH_CONTAINER";
case spell_flag::WONDER: return "WONDER";
case spell_flag::LAST: break;
}
Expand Down
1 change: 1 addition & 0 deletions src/magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum spell_flag {
MUTATE_TRAIT, // overrides the mutate spell_effect to use a specific trait_id instead of a category
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 ))
PAIN_NORESIST, // pain altering spells can't be resisted (like with the deadened trait)
WITH_CONTAINER, // items spawned with container
LAST
};

Expand Down
3 changes: 3 additions & 0 deletions src/magic_spell_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,9 @@ void spell_effect::spawn_ethereal_item( const spell &sp, Creature &caster, const
if( granted.count_by_charges() && sp.damage() > 0 ) {
granted.charges = sp.damage();
}
if( sp.has_flag( spell_flag::WITH_CONTAINER ) ) {
granted = granted.in_its_container();
}
if( g->u.can_wear( granted ).success() ) {
granted.set_flag( "FIT" );
g->u.wear_item( granted, false );
Expand Down

0 comments on commit b546c20

Please sign in to comment.