|
From: <gi...@cr...> - 2025-12-01 18:55:15
|
via 678897748c1905d1a889e96bb51103aabaae6689 (commit)
from 6b0ab13d045b64ae8811222813be4a1f1cc8f9b8 (commit)
-----------------------------------------------------------------------
commit 678897748c1905d1a889e96bb51103aabaae6689
Author: hellmonk <nld...@gm...>
Date: Mon Dec 1 12:49:55 2025 -0600
Improve wizmode parchment handling.
Allow specifying a parchment spell in &o. Default to generating a parchment
rather than the first book containing a spell when providing a spell name.
-----------------------------------------------------------------------
Summary of changes:
crawl-ref/source/items.cc | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index d1b209d190..5db21068a8 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -4570,22 +4570,12 @@ static bool _book_from_spell(const char* specs, item_def &item)
if (type == SPELL_NO_SPELL)
return false;
- for (int i = 0; i < NUM_BOOKS; ++i)
- {
- const auto bt = static_cast<book_type>(i);
- if (!book_exists(bt))
- continue;
- for (spell_type sp : spellbook_template(bt))
- {
- if (sp == type)
- {
- item.sub_type = i;
- return true;
- }
- }
- }
+ if (!is_player_book_spell(type))
+ return false;
- return false;
+ item.sub_type = BOOK_PARCHMENT;
+ item.plus = static_cast<int>(type);
+ return true;
}
bool get_item_by_name(item_def *item, const char* specs,
@@ -4650,7 +4640,7 @@ bool get_item_by_name(item_def *item, const char* specs,
switch (class_wanted)
{
case OBJ_BOOKS:
- // Try if we get a match against a spell.
+ // Make a parchment if we get a match against a spell.
if (_book_from_spell(specs, *item))
type_wanted = item->sub_type;
break;
@@ -4764,6 +4754,16 @@ bool get_item_by_name(item_def *item, const char* specs,
}
item->skill_points = random_range(2000, 3000);
}
+ else if (item->sub_type == BOOK_PARCHMENT)
+ {
+ char buf[80];
+ msgwin_get_line_autohist("What parchment spell? ", buf, sizeof(buf));
+ if (buf[0] != '\0')
+ {
+ if (!_book_from_spell(buf, *item))
+ mpr("That parchment doesn't seem to exist.");
+ }
+ }
else if (type_wanted == BOOK_RANDART_THEME)
build_themed_book(*item, capped_spell_filter(20));
else if (type_wanted == BOOK_RANDART_LEVEL)
--
Dungeon Crawl Stone Soup
|