File: wield.lua

package info (click to toggle)
crawl 2%3A0.7.1-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 30,420 kB
  • ctags: 23,018
  • sloc: cpp: 244,317; ansic: 16,144; perl: 2,214; makefile: 984; python: 488; objc: 250; ruby: 200; sh: 140
file content (55 lines) | stat: -rw-r--r-- 1,331 bytes parent folder | download
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
---------------------------------------------------------------------------
-- wield.lua
-- Selects extra items to wield.
--
-- To use this, add this line to your init.txt:
--   lua_file = lua/wield.lua
---------------------------------------------------------------------------

function make_hash(ls)
    local h = { }
    for _, i in ipairs(ls) do
        h[i] = true
    end
    return h
end

function ch_item_wieldable(it)
    -- We only need to check for unusual cases - basic matching is handled
    -- by Crawl itself.
    local spells = make_hash( you.spells() )

    if spells["Bone Shards"]
            and string.find( it.name("a"), " skeleton" )
    then
        return true
    end

    if (spells["Sublimation of Blood"] or spells["Simulacrum"])
            and food.ischunk(it)
    then
        return true
    end

    if spells["Sublimation of Blood"]
            and string.find( it.name("a"), " potions? of blood")
    then
        return true
    end

    if spells["Sandblast"]
            and it.class(true) == "missile"
            and string.find( it.name("a"), " stones?" )
    then
        return true
    end

    if spells["Sticks to Snakes"]
            and it.class(true) == "missile"
            and string.find( it.name("a"), " arrows?" )
    then
        return true
    end

    return false
end