Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow spells to spawn items with their containers #40097

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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