blob: 452ef0b9650a73a5b9c81af5e7a8b7475f6da12a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
---------------------------------------------------------------------------
-- pickup.lua:
-- Smarter autopickup handling that takes into account the item type
-- in combination with your character's race, religion, knowledge,
-- and eating habits.
--
-- To use this, add this line to your init.txt:
-- lua_file = lua/pickup.lua
--
-- Notes:
-- * This script only handles items of classes with autopickup on.
-- * Any result can still be overridden using autopickup_exceptions.
---------------------------------------------------------------------------
function make_hash(ls)
local h = { }
for _, i in ipairs(ls) do
h[i] = true
end
return h
end
function you_undead()
return you.race() == "Mummy" or you.race() == "Ghoul" or you.race() == "Vampire"
end
-- not identified
function unknown_potion(type)
return type == 0
end
function good_potion(type)
return type == 1
end
function bad_potion(it)
return type == 2
end
-- special cases
function spec_potion(it)
return type == 3
end
function ch_autopickup(it)
local spells = make_hash( you.spells() )
if item.class(it) == "Potions" then
local type = item.potion_type(it)
-- "bad" potions only for Evaporate
if spells["Evaporate"] and bad_potion(type) then
return true
end
-- no potions for Mummies, also: no bad potions for anyone else
if you.race() == "Mummy" or bad_potion(type) then
return false
end
-- pickup "good" and unID'd potions
if good_potion(type) or unknown_potion(type) then
return true
end
-- special handling
if spec_potion(type) then
-- undead cannot use berserk
if item.subtype(it) == "berserk" then
if you_undead() then
return false
else
return true
end
end
-- special cases for blood, water, and porridge
if item.subtype(it) == "blood" or item.subtype(it) == "water"
or item.subtype(it) == "porridge" then
return food.can_eat(it, false)
end
end
-- anything not handled until here can be picked up
return true
end
if item.class(it) == "Carrion" or item.class(it) == "Comestibles" then
return food.can_eat(it, false)
end
if item.class(it) == "Books" and you.god() == "Trog" then
return false
end
if item.class(it) == "Jewellery" then
if item.subtype == "hunger" or item.subtype == "inaccuracy" then
return false
end
if you_undead() and
(item.subtype(it) == "regeneration" or item.subtype(it) == "rage") then
return false
end
end
-- we only get here if class autopickup ON
return true
end
|