-
Notifications
You must be signed in to change notification settings - Fork 5
/
force_mores.lua
140 lines (130 loc) · 4.4 KB
/
force_mores.lua
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---------------------------
---- Begin force_mores ----
---------------------------
-- See README.md for documentation.
last_turn = you.turns()
-- Each entry must have a 'name' field with a descriptive name, a 'pattern'
-- field, a 'cond' field giving the condition type, and a 'cutoff' field giving
-- the max value for where the force_more will apply. Possible values for
-- 'cond' are xl and maxhp.
--
-- The 'pattern' field's value can be either a regexp string or array of regexp
-- strings matching the appropriate monster(s). Any values are joined by "|" to
-- make a new force_more of the form:
--
-- ((?!spectral )VALUE1|VALUE2|...)(?! (skeleton|zombie|simularcrum)).*into view".
--
-- To allow derived undead forms of a monster to match, include 'spectral ' at
-- the beginning of and/or ' (skeleton|zombie|simularcrum)' at the end of your
-- pattern for that monster.
fm_patterns = {
-- Fast, early game Dungeon problems for chars with low mhp.
{name = "30mhp", cond = "maxhp", cutoff = 30,
pattern = "adder|hound"},
-- Dungeon monsters that can damage you for close to 50% of your mhp with a
-- ranged attack.
{name = "40mhp", cond = "maxhp", cutoff = 40,
pattern = "orc priest|electric eel"},
{name = "60mhp", cond = "maxhp", cutoff = 60,
pattern = "acid dragon|steam dragon|manticore"},
{name = "70mhp", cond = "maxhp", cutoff = 70,
pattern = "centaur(?! warrior)|meliai|yaktaur(?! captain)"},
{name = "80mhp", cond = "maxhp", cutoff = 80,
pattern = "gargoyle|orc (warlord|knight)"},
{name = "90mhp", cond = "maxhp", cutoff = 90,
pattern = {"centaur warrior", "deep elf archer", "efreet",
"molten gargoyle", "tengu conjurer"} },
{name = "110mhp", cond = "maxhp", cutoff = 110,
pattern = {"centaur warrior", "deep elf (mage|knight)", "cyclops", "efreet",
"molten gargoyle", "tengu conjurer", "yaktaur captain",
"necromancer", "deep troll earth mage", "hell knight",
"stone giant"} },
{name = "160mhp", cond = "maxhp", cutoff = 160,
pattern = {"(fire|ice|quicksilver|shadow|storm) dragon",
"(fire|frost) giant", "war gargoyle",
"draconian (knight|stormcaller"} },
} -- end fm_patterns
active_fm = {}
-- Set to true to get a message when the fm change
notify_fm = false
-- Wrapper of crawl.mpr() that prints text in white by default.
if not mpr then
mpr = function (msg, color)
if not color then
color = "white"
end
crawl.mpr("<" .. color .. ">" .. msg .. "</" .. color .. ">")
end
end
function init_force_mores()
for i,v in ipairs(fm_patterns) do
active_fm[#active_fm + 1] = false
end
end
function update_force_mores()
local activated = {}
local deactivated = {}
local hp, maxhp = you.hp()
for i,v in ipairs(fm_patterns) do
local msg = nil
if type(v.pattern) == "table" then
for j, p in ipairs(v.pattern) do
if msg == nil then
msg = p
else
msg = msg .. "|" .. p
end
end
else
msg = v.pattern
end
msg = "(?<!spectral )(" .. msg .. ")(?! (skeleton|zombie|simulacrum)).*into view"
local action = nil
local fm_name = v.pattern
if v.name then
fm_name = v.name
end
if not v.cond and not active_fm[i] then
action = "+"
elseif v.cond == "xl" then
if active_fm[i] and you.xl() >= v.cutoff then
action = "-"
elseif not active_fm[i] and you.xl() < v.cutoff then
action = "+"
end
elseif v.cond == "maxhp" then
if active_fm[i] and maxhp >= v.cutoff then
action = "-"
elseif not active_fm[i] and maxhp < v.cutoff then
action = "+"
end
end
if action == "+" then
activated[#activated + 1] = fm_name
elseif action == "-" then
deactivated[#deactivated + 1] = fm_name
end
if action ~= nil then
local opt = "force_more_message " .. action .. "= " .. msg
crawl.setopt(opt)
active_fm[i] = not active_fm[i]
end
end
if #activated > 0 and notify_fm then
mpr("Activating force_mores: " .. table.concat(activated, ", "))
end
if #deactivated > 0 and notify_fm then
mpr("Deactivating force_mores: " .. table.concat(deactivated, ", "))
end
end
local last_turn = nil
function force_mores()
if last_turn ~= you.turns() then
update_force_mores()
last_turn = you.turns()
end
end
init_force_mores()
-------------------------
---- End force_mores ----
-------------------------