summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/core/init.lua3
-rw-r--r--lib/core/stores.lua32
-rw-r--r--lib/mods/theme/core/init.lua3
-rw-r--r--lib/mods/theme/core/stores.lua32
-rw-r--r--lib/mods/theme/scpt/init.lua3
-rw-r--r--lib/mods/theme/scpt/stores.lua134
-rw-r--r--lib/scpt/init.lua3
-rw-r--r--lib/scpt/stores.lua105
-rw-r--r--src/defines.h9
-rw-r--r--src/store.c211
-rw-r--r--src/util.pkg18
11 files changed, 206 insertions, 347 deletions
diff --git a/lib/core/init.lua b/lib/core/init.lua
index 23c76461..c87f9a20 100644
--- a/lib/core/init.lua
+++ b/lib/core/init.lua
@@ -20,9 +20,6 @@ tome_dofile_anywhere(ANGBAND_DIR_CORE, "dungeon.lua")
-- Load the ingame contextual help
tome_dofile_anywhere(ANGBAND_DIR_CORE, "help.lua")
--- let the store specific stuff happen!
-tome_dofile_anywhere(ANGBAND_DIR_CORE, "stores.lua")
-
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
diff --git a/lib/core/stores.lua b/lib/core/stores.lua
deleted file mode 100644
index d4a63168..00000000
--- a/lib/core/stores.lua
+++ /dev/null
@@ -1,32 +0,0 @@
--- Take care of all concerning stores
-function store_buy_list(t)
- assert(type(t) == "table", "store_buy_list got no table")
- add_hooks
- {
- [HOOK_STORE_BUY] = function (index, name, obj)
- local tbl = %t
- local elt = tbl[index]
- if not elt then
- elt = tbl[name]
- end
- if elt then
- if elt then
- if type(elt) == "function" then
- return TRUE, elt(obj)
- elseif type(elt) == "table" then
- local k, e
- for k, e in elt do
- if type(e) == "number" then
- if obj.tval == e then return TRUE, TRUE end
- else
- if (obj.tval == e[1]) and (obj.sval >= e[2]) and (obj.sval <= e[3]) then return TRUE, TRUE end
- end
- end
- elseif elt == -1 then
- return TRUE, FALSE
- end
- end
- end
- end,
- }
-end
diff --git a/lib/mods/theme/core/init.lua b/lib/mods/theme/core/init.lua
index 23c76461..c87f9a20 100644
--- a/lib/mods/theme/core/init.lua
+++ b/lib/mods/theme/core/init.lua
@@ -20,9 +20,6 @@ tome_dofile_anywhere(ANGBAND_DIR_CORE, "dungeon.lua")
-- Load the ingame contextual help
tome_dofile_anywhere(ANGBAND_DIR_CORE, "help.lua")
--- let the store specific stuff happen!
-tome_dofile_anywhere(ANGBAND_DIR_CORE, "stores.lua")
-
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
diff --git a/lib/mods/theme/core/stores.lua b/lib/mods/theme/core/stores.lua
deleted file mode 100644
index d4a63168..00000000
--- a/lib/mods/theme/core/stores.lua
+++ /dev/null
@@ -1,32 +0,0 @@
--- Take care of all concerning stores
-function store_buy_list(t)
- assert(type(t) == "table", "store_buy_list got no table")
- add_hooks
- {
- [HOOK_STORE_BUY] = function (index, name, obj)
- local tbl = %t
- local elt = tbl[index]
- if not elt then
- elt = tbl[name]
- end
- if elt then
- if elt then
- if type(elt) == "function" then
- return TRUE, elt(obj)
- elseif type(elt) == "table" then
- local k, e
- for k, e in elt do
- if type(e) == "number" then
- if obj.tval == e then return TRUE, TRUE end
- else
- if (obj.tval == e[1]) and (obj.sval >= e[2]) and (obj.sval <= e[3]) then return TRUE, TRUE end
- end
- end
- elseif elt == -1 then
- return TRUE, FALSE
- end
- end
- end
- end,
- }
-end
diff --git a/lib/mods/theme/scpt/init.lua b/lib/mods/theme/scpt/init.lua
index af4ba3d9..64b1c6a5 100644
--- a/lib/mods/theme/scpt/init.lua
+++ b/lib/mods/theme/scpt/init.lua
@@ -8,9 +8,6 @@ tome_dofile("player.lua")
-- Load the ingame contextual help
tome_dofile("help.lua")
--- let the store specific stuff happen!
-tome_dofile("stores.lua")
-
-- Add the mkey activations
tome_dofile("mkeys.lua")
diff --git a/lib/mods/theme/scpt/stores.lua b/lib/mods/theme/scpt/stores.lua
deleted file mode 100644
index 61a97f5a..00000000
--- a/lib/mods/theme/scpt/stores.lua
+++ /dev/null
@@ -1,134 +0,0 @@
--- Whats shops can buy what
-store_buy_list
-{
- ["General Store"] =
- {
- TV_CORPSE,
- TV_FOOD,
- TV_LITE,
- TV_FLASK,
- TV_SPIKE,
- TV_SHOT,
- TV_ARROW,
- TV_BOLT,
- TV_DIGGING,
- TV_CLOAK,
- TV_BOTTLE,
- },
- ["Armoury"] =
- {
- TV_BOOTS,
- TV_GLOVES,
- TV_CROWN,
- TV_HELM,
- TV_SHIELD,
- TV_CLOAK,
- TV_SOFT_ARMOR,
- TV_HARD_ARMOR,
- TV_DRAG_ARMOR,
- },
- ["Weaponsmith"] =
- {
- TV_SHOT,
- TV_BOLT,
- TV_ARROW,
- TV_BOOMERANG,
- TV_BOW,
- TV_DIGGING,
- TV_HAFTED,
- TV_POLEARM,
- TV_SWORD,
- TV_AXE,
- TV_MSTAFF,
- },
- -- We use a function because we want to restrict to blessed weapons and god spells
- ["Temple"] = function (obj)
- if obj.tval == TV_DRUID_BOOK then return TRUE
- elseif obj.tval == TV_BOOK and obj.sval == 255 and (can_spell_random(obj.pval) == SKILL_SPIRITUALITY) then return TRUE
- elseif obj.tval == TV_SCROLL then return TRUE
- elseif obj.tval == TV_POTION2 then return TRUE
- elseif obj.tval == TV_POTION then return TRUE
- elseif obj.tval == TV_HAFTED then return TRUE
- elseif obj.tval == TV_POLEARM and is_blessed(obj) == TRUE then return TRUE
- elseif obj.tval == TV_SWORD and is_blessed(obj) == TRUE then return TRUE
- elseif obj.tval == TV_AXE and is_blessed(obj) == TRUE then return TRUE
- elseif obj.tval == TV_BOOMERANG and is_blessed(obj) == TRUE then return TRUE
- end
- end,
- ["Alchemy shop"] =
- {
- TV_SCROLL,
- TV_POTION2,
- TV_POTION,
- TV_BATERIE,
- TV_BOTTLE,
- },
- -- We use a function because we dont want god spells
- ["Magic shop"] = function (obj)
- local buy =
- {
- [TV_SYMBIOTIC_BOOK] = TRUE,
- [TV_AMULET] = TRUE,
- [TV_RING] = TRUE,
- [TV_STAFF] = TRUE,
- [TV_WAND] = TRUE,
- [TV_ROD] = TRUE,
- [TV_ROD_MAIN] = TRUE,
- [TV_SCROLL] = TRUE,
- [TV_POTION2] = TRUE,
- [TV_POTION] = TRUE,
- [TV_MSTAFF] = TRUE,
- [TV_RANDART] = TRUE,
- }
-
- if obj.tval == TV_BOOK and obj.sval == 255 and (can_spell_random(obj.pval) == SKILL_MAGIC) then return TRUE
- elseif obj.tval == TV_BOOK and obj.sval ~= 255 then return TRUE
- elseif buy[obj.tval] == TRUE then return TRUE
- end
- end,
- -- Black markets wants ALL!
- ["Black Market"] = function (obj)
- return TRUE
- end,
- ["Book Store"] =
- {
- TV_BOOK,
- TV_SYMBIOTIC_BOOK,
- TV_MUSIC_BOOK,
- TV_DAEMON_BOOK,
- TV_DRUID_BOOK,
- },
- ["Pet Shop"] =
- {
- TV_EGG,
- },
--- Theme stores
-
- ["Hunting Supply Store"] =
- {
- TV_TRAPKIT,
- TV_BOOMERANG,
- TV_SHOT,
- TV_BOLT,
- TV_ARROW,
- TV_BOW,
- TV_POTION2,
- },
-
- ["Runic Magic Shop"] =
- {
- TV_RUNE1,
- TV_RUNE2,
- },
-
- ["Construction Supply Store"] =
- {
- TV_LITE,
- TV_DIGGING,
- },
-
- ["Music Store"] =
- {
- TV_INSTRUMENT,
- },
-}
diff --git a/lib/scpt/init.lua b/lib/scpt/init.lua
index 69fca70d..079d064d 100644
--- a/lib/scpt/init.lua
+++ b/lib/scpt/init.lua
@@ -8,9 +8,6 @@ tome_dofile("player.lua")
-- Load the ingame contextual help
tome_dofile("help.lua")
--- let the store specific stuff happen!
-tome_dofile("stores.lua")
-
-- Add the mkey activations
tome_dofile("mkeys.lua")
diff --git a/lib/scpt/stores.lua b/lib/scpt/stores.lua
deleted file mode 100644
index d10ee5ad..00000000
--- a/lib/scpt/stores.lua
+++ /dev/null
@@ -1,105 +0,0 @@
--- Whats shops can buy what
-store_buy_list
-{
- ["General Store"] =
- {
- TV_CORPSE,
- TV_FOOD,
- TV_LITE,
- TV_FLASK,
- TV_SPIKE,
- TV_SHOT,
- TV_ARROW,
- TV_BOLT,
- TV_DIGGING,
- TV_CLOAK,
- TV_BOTTLE,
- },
- ["Armoury"] =
- {
- TV_BOOTS,
- TV_GLOVES,
- TV_CROWN,
- TV_HELM,
- TV_SHIELD,
- TV_CLOAK,
- TV_SOFT_ARMOR,
- TV_HARD_ARMOR,
- TV_DRAG_ARMOR,
- },
- ["Weaponsmith"] =
- {
- TV_SHOT,
- TV_BOLT,
- TV_ARROW,
- TV_BOOMERANG,
- TV_BOW,
- TV_DIGGING,
- TV_HAFTED,
- TV_POLEARM,
- TV_SWORD,
- TV_AXE,
- TV_MSTAFF,
- },
- -- We use a function because we want to restrict to blessed weapons and god spells
- ["Temple"] = function (obj)
- if obj.tval == TV_DRUID_BOOK then return TRUE
- elseif obj.tval == TV_BOOK and obj.sval == 255 and (can_spell_random(obj.pval) == SKILL_SPIRITUALITY) then return TRUE
- elseif obj.tval == TV_SCROLL then return TRUE
- elseif obj.tval == TV_POTION2 then return TRUE
- elseif obj.tval == TV_POTION then return TRUE
- elseif obj.tval == TV_HAFTED then return TRUE
- elseif obj.tval == TV_POLEARM and is_blessed(obj) == TRUE then return TRUE
- elseif obj.tval == TV_SWORD and is_blessed(obj) == TRUE then return TRUE
- elseif obj.tval == TV_AXE and is_blessed(obj) == TRUE then return TRUE
- elseif obj.tval == TV_BOOMERANG and is_blessed(obj) == TRUE then return TRUE
- end
- end,
- ["Alchemy shop"] =
- {
- TV_SCROLL,
- TV_POTION2,
- TV_POTION,
- TV_BATERIE,
- TV_BOTTLE,
- },
- -- We use a function because we dont want god spells
- ["Magic shop"] = function (obj)
- local buy =
- {
- [TV_SYMBIOTIC_BOOK] = TRUE,
- [TV_AMULET] = TRUE,
- [TV_RING] = TRUE,
- [TV_STAFF] = TRUE,
- [TV_WAND] = TRUE,
- [TV_ROD] = TRUE,
- [TV_ROD_MAIN] = TRUE,
- [TV_SCROLL] = TRUE,
- [TV_POTION2] = TRUE,
- [TV_POTION] = TRUE,
- [TV_MSTAFF] = TRUE,
- [TV_RANDART] = TRUE,
- }
-
- if obj.tval == TV_BOOK and obj.sval == 255 and (can_spell_random(obj.pval) == SKILL_MAGIC) then return TRUE
- elseif obj.tval == TV_BOOK and obj.sval ~= 255 then return TRUE
- elseif buy[obj.tval] == TRUE then return TRUE
- end
- end,
- -- Black markets wants ALL!
- ["Black Market"] = function (obj)
- return TRUE
- end,
- ["Book Store"] =
- {
- TV_BOOK,
- TV_SYMBIOTIC_BOOK,
- TV_MUSIC_BOOK,
- TV_DAEMON_BOOK,
- TV_DRUID_BOOK,
- },
- ["Pet Shop"] =
- {
- TV_EGG,
- },
-}
diff --git a/src/defines.h b/src/defines.h
index 9b0a512a..9c0ba654 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -142,15 +142,7 @@
* Total number of stores (see "store.c", etc)
*/
#define STORE_GENERAL 0
-#define STORE_ARMOURY 1
-#define STORE_WEAPON 2
-#define STORE_TEMPLE 3
-#define STORE_ALCHEMIST 4
-#define STORE_MAGIC 5
-#define STORE_BLACK 6
#define STORE_HOME 7
-#define STORE_BOOK 8
-#define STORE_PET 9
/*
* Maximum number of player "sex" types (see "table.c", etc)
@@ -4505,7 +4497,6 @@
#define HOOK_BUILDING_ACTION 44
#define HOOK_WIELD_SLOT 46
#define HOOK_STORE_STOCK 47
-#define HOOK_STORE_BUY 48
#define HOOK_GEN_LEVEL_BEGIN 49
#define HOOK_GET 50
#define HOOK_REDRAW 51
diff --git a/src/store.c b/src/store.c
index d290785a..e62701d9 100644
--- a/src/store.c
+++ b/src/store.c
@@ -12,6 +12,19 @@
#include "angband.h"
+#define STORE_GENERAL_STORE "General Store"
+#define STORE_ARMOURY "Armoury"
+#define STORE_WEAPONSMITH "Weaponsmith"
+#define STORE_TEMPLE "Temple"
+#define STORE_ALCHEMY "Alchemy shop"
+#define STORE_MAGIC "Magic shop"
+#define STORE_BLACK_MARKET "Black Market"
+#define STORE_BOOKS "Book Store"
+#define STORE_PETS "Pet Shop"
+#define STORE_HUNTING_SUPPLIES "Hunting Supply Store"
+#define STORE_RUNIC_MAGIC "Runic Magic Shop"
+#define STORE_CONSTRUCTION_SUPPLIES "Construction Supply Store"
+#define STORE_MUSIC "Music Store"
#define RUMOR_CHANCE 8
@@ -742,6 +755,8 @@ bool_ is_blessed(object_type *o_ptr)
*/
static bool_ store_will_buy(object_type *o_ptr)
{
+ cptr store_name = st_info[st_ptr->st_idx].name + st_name;
+
/* Hack -- The Home is simple */
if (cur_store_num == 7) return (TRUE);
@@ -750,10 +765,196 @@ static bool_ store_will_buy(object_type *o_ptr)
/* XXX XXX XXX Ignore "worthless" items */
if (object_value(o_ptr) <= 0) return (FALSE);
- /* Lua can define things to buy */
- if (process_hooks_ret(HOOK_STORE_BUY, "d", "(d,s,O)", st_ptr->st_idx, st_info[st_ptr->st_idx].name + st_name, o_ptr))
+ /* What do stores buy? */
+ if (streq(store_name, STORE_GENERAL_STORE))
+ {
+ switch (o_ptr->tval)
+ {
+ case TV_CORPSE:
+ case TV_FOOD:
+ case TV_LITE:
+ case TV_FLASK:
+ case TV_SPIKE:
+ case TV_SHOT:
+ case TV_ARROW:
+ case TV_BOLT:
+ case TV_DIGGING:
+ case TV_CLOAK:
+ case TV_BOTTLE:
+ return TRUE;
+ }
+ }
+ else if (streq(store_name, STORE_ARMOURY))
+ {
+ switch (o_ptr->tval)
+ {
+ case TV_BOOTS:
+ case TV_GLOVES:
+ case TV_CROWN:
+ case TV_HELM:
+ case TV_SHIELD:
+ case TV_CLOAK:
+ case TV_SOFT_ARMOR:
+ case TV_HARD_ARMOR:
+ case TV_DRAG_ARMOR:
+ return TRUE;
+ }
+ }
+ else if (streq(store_name, STORE_WEAPONSMITH))
+ {
+ switch (o_ptr->tval)
+ {
+ case TV_SHOT:
+ case TV_BOLT:
+ case TV_ARROW:
+ case TV_BOOMERANG:
+ case TV_BOW:
+ case TV_DIGGING:
+ case TV_HAFTED:
+ case TV_POLEARM:
+ case TV_SWORD:
+ case TV_AXE:
+ case TV_MSTAFF:
+ return TRUE;
+ }
+ }
+ else if (streq(store_name, STORE_TEMPLE))
+ {
+ switch (o_ptr->tval)
+ {
+ case TV_DRUID_BOOK:
+ case TV_SCROLL:
+ case TV_POTION2:
+ case TV_POTION:
+ case TV_HAFTED:
+ return TRUE;
+ }
+
+ if ((o_ptr->tval == TV_BOOK) &&
+ (o_ptr->sval == BOOK_RANDOM) &&
+ (can_spell_random(o_ptr->pval) == SKILL_SPIRITUALITY))
+ {
+ return TRUE;
+ }
+ else if ((o_ptr->tval == TV_POLEARM) &&
+ is_blessed(o_ptr))
+ {
+ return TRUE;
+ }
+ else if ((o_ptr->tval == TV_SWORD) &&
+ is_blessed(o_ptr))
+ {
+ return TRUE;
+ }
+ else if ((o_ptr->tval == TV_AXE) &&
+ is_blessed(o_ptr))
+ {
+ return TRUE;
+ }
+ else if ((o_ptr->tval == TV_BOOMERANG) &&
+ is_blessed(o_ptr))
+ {
+ return TRUE;
+ }
+ }
+ else if (streq(store_name, STORE_ALCHEMY))
+ {
+ switch (o_ptr->tval)
+ {
+ case TV_SCROLL:
+ case TV_POTION2:
+ case TV_POTION:
+ case TV_BATERIE:
+ case TV_BOTTLE:
+ return TRUE;
+ }
+ }
+ else if (streq(store_name, STORE_MAGIC))
+ {
+ switch (o_ptr->tval)
+ {
+ case TV_SYMBIOTIC_BOOK:
+ case TV_AMULET:
+ case TV_RING:
+ case TV_STAFF:
+ case TV_WAND:
+ case TV_ROD:
+ case TV_ROD_MAIN:
+ case TV_SCROLL:
+ case TV_POTION2:
+ case TV_POTION:
+ case TV_MSTAFF:
+ case TV_RANDART:
+ return TRUE;
+ }
+
+ if ((o_ptr->tval == TV_BOOK) &&
+ (o_ptr->sval == BOOK_RANDOM) &&
+ (can_spell_random(o_ptr->pval) == SKILL_MAGIC))
+ {
+ return TRUE;
+ }
+ else if ((o_ptr->tval == TV_BOOK) &&
+ (o_ptr->sval != BOOK_RANDOM))
+ {
+ return TRUE;
+ }
+ }
+ else if (streq(store_name, STORE_BLACK_MARKET))
+ {
+ return TRUE;
+ }
+ else if (streq(store_name, STORE_BOOKS))
+ {
+ switch (o_ptr->tval)
+ {
+ case TV_BOOK:
+ case TV_SYMBIOTIC_BOOK:
+ case TV_MUSIC_BOOK:
+ case TV_DAEMON_BOOK:
+ case TV_DRUID_BOOK:
+ return TRUE;
+ }
+ }
+ else if (streq(store_name, STORE_PETS))
+ {
+ return (o_ptr->tval == TV_EGG);
+ }
+ else if (streq(store_name, STORE_HUNTING_SUPPLIES))
+ {
+ switch (o_ptr->tval)
+ {
+ case TV_TRAPKIT:
+ case TV_BOOMERANG:
+ case TV_SHOT:
+ case TV_BOLT:
+ case TV_ARROW:
+ case TV_BOW:
+ case TV_POTION2:
+ return TRUE;
+ }
+ }
+ else if (streq(store_name, STORE_RUNIC_MAGIC))
+ {
+ switch (o_ptr->tval)
+ {
+ case TV_RUNE1:
+ case TV_RUNE2:
+ return TRUE;
+ }
+ }
+ else if (streq(store_name, STORE_CONSTRUCTION_SUPPLIES))
+ {
+ switch (o_ptr->tval)
+ {
+ case TV_LITE:
+ case TV_DIGGING:
+ return TRUE;
+ }
+ }
+ else if (streq(store_name, STORE_MUSIC))
{
- return process_hooks_return[0].num;
+ return (o_ptr->tval == TV_INSTRUMENT);
}
/* Assume not okay */
@@ -1165,7 +1366,7 @@ static void store_create(void)
}
/* Magic Shop */
- else if (streq(st_info[st_ptr->st_idx].name + st_name, "Magic shop") &&
+ else if (streq(st_info[st_ptr->st_idx].name + st_name, STORE_MAGIC) &&
magik(20))
{
s16b spell;
@@ -1181,7 +1382,7 @@ static void store_create(void)
}
/* Temple */
- else if (streq(st_info[st_ptr->st_idx].name + st_name, "Temple") &&
+ else if (streq(st_info[st_ptr->st_idx].name + st_name, STORE_TEMPLE) &&
magik(20))
{
s16b spell;
diff --git a/src/util.pkg b/src/util.pkg
index a32ef927..cb49a3e3 100644
--- a/src/util.pkg
+++ b/src/util.pkg
@@ -556,24 +556,6 @@ typedef unsigned int u32b;
*/
#define HOOK_STORE_STOCK 47
-/** @def HOOK_STORE_BUY
- * @brief Store buys an item.\n
- * @param Number st_idx \n the index of the store in st_info array.
- * @brief Store index
- * @param String name \n the name of the store.
- * @brief Store name
- * @param Object o_ptr \n the object to buy.
- * @brief Object
- * @return Boolean \n TRUE if the hook has processed the object, otherwise
- * FALSE.
- * @return Number buy \n TRUE if the store will buy the object, otherwise
- * FALSE.
- * @note
- * If the hook returns TRUE, store_will_buy() will return "buy".
- * @note (see file store.c)
- */
-#define HOOK_STORE_BUY 48
-
/** @def HOOK_GEN_LEVEL_BEGIN
* @brief Generate a random dungeon level.
* @note (see file generate.c)