Attached Files |
8461_porridge_is_food.patch [^] (2,609 bytes) 2014-04-29 09:32 [Show Content] [Hide Content]From 4f29378481011237385e5498012257effd83bacf Mon Sep 17 00:00:00 2001
From: Eduardo Gonzalez <ed.gonzalez3@gmail.com>
Date: Tue, 29 Apr 2014 00:16:42 -0700
Subject: [PATCH] Mark potions that are preferred food as food for prefix &
stash search (#8461)
This affects porridge for most races and blood for vampires, though since
everything in the actual food class is usually irrelevant as "food" for
vampires, they're probably better off searching for blood anyways.
Expose is_preferred_food to lua for the stash annotation code.
---
crawl-ref/source/dat/clua/stash.lua | 4 ++++
crawl-ref/source/itemname.cc | 3 +++
crawl-ref/source/l_item.cc | 11 +++++++++++
3 files changed, 18 insertions(+)
diff --git a/crawl-ref/source/dat/clua/stash.lua b/crawl-ref/source/dat/clua/stash.lua
index 9d67f53..cad117d 100644
--- a/crawl-ref/source/dat/clua/stash.lua
+++ b/crawl-ref/source/dat/clua/stash.lua
@@ -60,6 +60,10 @@ function ch_stash_search_annotate_item(it)
annot = annot .. "{" .. it.ego_type_terse .. "} "
end
+ if it.is_preferred_food then
+ annot = annot .. "{food} "
+ end
+
if it.class(true) == "armour" then
annot = annot .. "{" .. it.subtype() .. " "
elseif it.class(true) == "weapon" then
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index dd4c6ea..19fd50b 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -3621,7 +3621,10 @@ string item_prefix(const item_def &item, bool temp)
prefixes.push_back("forbidden");
}
if (is_preferred_food(item))
+ {
prefixes.push_back("preferred");
+ prefixes.push_back("food");
+ }
break;
case OBJ_WEAPONS:
diff --git a/crawl-ref/source/l_item.cc b/crawl-ref/source/l_item.cc
index 8f60996..c093419 100644
--- a/crawl-ref/source/l_item.cc
+++ b/crawl-ref/source/l_item.cc
@@ -572,6 +572,16 @@ IDEF(can_cut_meat)
return 1;
}
+IDEF(is_preferred_food)
+{
+ if (!item || !item->defined())
+ return 0;
+
+ lua_pushboolean(ls, is_preferred_food(*item));
+
+ return 1;
+}
+
IDEF(is_bad_food)
{
if (!item || !item->defined())
@@ -1142,6 +1152,7 @@ static ItemAccessor item_attrs[] =
{ "dropped", l_item_dropped },
{ "is_melded", l_item_is_melded },
{ "can_cut_meat", l_item_can_cut_meat },
+ { "is_preferred_food", l_item_is_preferred_food },
{ "is_bad_food", l_item_is_bad_food },
{ "is_useless", l_item_is_useless },
{ "pluses", l_item_pluses },
--
1.7.10.4
8461_porridge_is_food_fixed1.patch [^] (2,640 bytes) 2014-04-29 09:48 [Show Content] [Hide Content]From 24f78024a6320c23b93144024a37086a12b0d2a7 Mon Sep 17 00:00:00 2001
From: Eduardo Gonzalez <ed.gonzalez3@gmail.com>
Date: Tue, 29 Apr 2014 00:16:42 -0700
Subject: [PATCH] Mark potions that are preferred food as food for prefix &
stash search (#8461)
This affects porridge for most races and blood for vampires, though since
everything in the actual food class is usually irrelevant as "food" for
vampires, they're probably better off searching for blood anyways.
Expose is_preferred_food to lua for the stash annotation code.
---
crawl-ref/source/dat/clua/stash.lua | 4 ++++
crawl-ref/source/itemname.cc | 3 +++
crawl-ref/source/l_item.cc | 11 +++++++++++
3 files changed, 18 insertions(+)
diff --git a/crawl-ref/source/dat/clua/stash.lua b/crawl-ref/source/dat/clua/stash.lua
index 9d67f53..14def0b 100644
--- a/crawl-ref/source/dat/clua/stash.lua
+++ b/crawl-ref/source/dat/clua/stash.lua
@@ -60,6 +60,10 @@ function ch_stash_search_annotate_item(it)
annot = annot .. "{" .. it.ego_type_terse .. "} "
end
+ if it.class(true) == "potion" and it.is_preferred_food then
+ annot = annot .. "{food} "
+ end
+
if it.class(true) == "armour" then
annot = annot .. "{" .. it.subtype() .. " "
elseif it.class(true) == "weapon" then
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index dd4c6ea..19fd50b 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -3621,7 +3621,10 @@ string item_prefix(const item_def &item, bool temp)
prefixes.push_back("forbidden");
}
if (is_preferred_food(item))
+ {
prefixes.push_back("preferred");
+ prefixes.push_back("food");
+ }
break;
case OBJ_WEAPONS:
diff --git a/crawl-ref/source/l_item.cc b/crawl-ref/source/l_item.cc
index 8f60996..c093419 100644
--- a/crawl-ref/source/l_item.cc
+++ b/crawl-ref/source/l_item.cc
@@ -572,6 +572,16 @@ IDEF(can_cut_meat)
return 1;
}
+IDEF(is_preferred_food)
+{
+ if (!item || !item->defined())
+ return 0;
+
+ lua_pushboolean(ls, is_preferred_food(*item));
+
+ return 1;
+}
+
IDEF(is_bad_food)
{
if (!item || !item->defined())
@@ -1142,6 +1152,7 @@ static ItemAccessor item_attrs[] =
{ "dropped", l_item_dropped },
{ "is_melded", l_item_is_melded },
{ "can_cut_meat", l_item_can_cut_meat },
+ { "is_preferred_food", l_item_is_preferred_food },
{ "is_bad_food", l_item_is_bad_food },
{ "is_useless", l_item_is_useless },
{ "pluses", l_item_pluses },
--
1.7.10.4
|