Skip to content

Commit

Permalink
Ritual Circles Work (#72128)
Browse files Browse the repository at this point in the history
Uses components and qualities at your location to cast spells
LetterShapedGlyphs authored Mar 3, 2024
1 parent 63fdf33 commit 3257bc0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/magic.cpp
Original file line number Diff line number Diff line change
@@ -1216,11 +1216,8 @@ bool spell::can_cast( const Character &guy ) const
return false;
}

// only required because crafting_inventory always rebuilds the cache. maybe a const version doesn't write to cache.
Character &guy_inv = const_cast<Character &>( guy );

if( !type->spell_components.is_empty() &&
!type->spell_components->can_make_with_inventory( guy_inv.crafting_inventory( guy.pos(), 0 ),
!type->spell_components->can_make_with_inventory( guy.crafting_inventory( guy.pos(), 0, false ),
return_true<item> ) ) {
return false;
}
@@ -1236,6 +1233,7 @@ void spell::use_components( Character &guy ) const
const requirement_data &spell_components = type->spell_components.obj();
// if we're here, we're assuming the Character has the correct components (using can_cast())
inventory map_inv;
map_inv.form_from_map( guy.pos(), 0, &guy, true, false );
for( const std::vector<item_comp> &comp_vec : spell_components.get_components() ) {
guy.consume_items( guy.select_item_component( comp_vec, 1, map_inv ), 1 );
}
@@ -2777,13 +2775,13 @@ void spellcasting_callback::spell_info_text( const spell &sp, int width )
if( sp.has_components() ) {
if( !sp.components().get_components().empty() ) {
for( const std::string &line : sp.components().get_folded_components_list(
width - 2, c_light_gray, pc.crafting_inventory(), return_true<item> ) ) {
width - 2, c_light_gray, pc.crafting_inventory( pc.pos(), 0, false ), return_true<item> ) ) {
info_txt.emplace_back( line );
}
}
if( !( sp.components().get_tools().empty() && sp.components().get_qualities().empty() ) ) {
for( const std::string &line : sp.components().get_folded_tools_list(
width - 2, c_light_gray, pc.crafting_inventory() ) ) {
width - 2, c_light_gray, pc.crafting_inventory( pc.pos(), 0, false ) ) ) {
info_txt.emplace_back( line );
}
}

0 comments on commit 3257bc0

Please sign in to comment.