-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraw-svo.burncounter.lua
172 lines (144 loc) · 5.32 KB
/
raw-svo.burncounter.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
-- Svof (c) 2011-2015 by Vadim Peretokin
-- Svof is licensed under a
-- Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
-- You should have received a copy of the license along with this
-- work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>.
bl_list = {}
burn_levels = {
"ablaze",
"severe",
"extreme",
"charred",
"melting"
}
function sk.bl_checkburncounter()
-- make the announces work with a singleprompt
local echof = itf
moveCursor(0, getLineNumber())
-- we'll only ever have one name here so far. Actually add up the hits here and store them
local who, action = next(hittable)
action = action or ""
if not who then
echof("Failed to connect.\n")
end
-- can only add levels if someone is dehydrated
if action == "add level" and (bl_list[who].dehydrate ~= 0 or bl_list[who].level == 0) then
bl_list[who].level = bl_list[who].level + 1
if bl_list[who].level > #burn_levels then bl_list[who].level = #burn_levels end
elseif action == "only ablaze" and bl_list[who].level == 0 then
bl_list[who].level = 1
elseif action == "add to all" then
for person, data in pairs(bl_list) do
if data.dehydrate ~= 0 or data.level == 0 then
data.level = data.level + 1
if data.level > #burn_levels then data.level = #burn_levels end
end
end
-- wipe the 'all' person, as that is not a real person
bl_list.all = nil
elseif action == "remove level" then
bl_list[who].level = bl_list[who].level - 1
if bl_list[who].level < 0 then bl_list[who].level = 0 end
elseif action == "dehydrate" then
if bl_list[who].dehydrate ~= 0 then
killTimer(bl_list[who].dehydrate)
end
bl_list[who].dehydrate = tempTimer(45+getping(), function()
bl_list[who].dehydrate = 0
echof("\n%s's dehydrate wore off.\n", who)
showprompt()
end)
elseif action == "lost dehydrate" then
if bl_list[who].dehydrate ~= 0 then
killTimer(bl_list[who].dehydrate)
bl_list[who].dehydrate = 0
end
elseif action == "remove ablaze only" then
if bl_list[who].level == 1 then
bl_list[who].level = 0
end
else
debugf("bl_checkburncounter: unknown action '%s'", action)
end
raiseEvent("svo burncounter hit", who)
-- if a specific person and they are ablaze
if who ~= "all" and bl_list[who].level > 0 then
echof("%ss burn is %s (%s).%s\n", who, burn_levels[bl_list[who].level], bl_list[who].level, (bl_list[who].dehydrate == 0 and '' or ' They are also dehydrated.'))
-- if a specific person and their ablaze was cured
elseif who ~= "all" and bl_list[who].level == 0 then
echof("%s isn't on fire%s.\n", who, (bl_list[who].dehydrate == 0 and '' or ' (but they are dehydrated)'))
else
local function getburnlevels()
local t = {}
for person, data in pairs(bl_list) do
if data.dehydrate ~= 0 then
t[#t+1] = string.format("%s's burn is %s (%s)%s", person, burn_levels[data.level], data.level, (data.dehydrate == 0 and '' or ' and dehydrated'))
end
end
return concatand(t)
end
local burnsstring = getburnlevels()
if burnsstring ~= "" then
echof("%s.\n", burnsstring)
end
end
-- turn things off
hittable = {}
disableTrigger("svobl Don't register")
signals.after_prompt_processing:block(sk.bl_checkburncounter)
end
function bl_count(who, what)
bl_list[who] = bl_list[who] or {level = 0, dehydrate = 0}
lasthit = who
hittable[who] = what
signals.after_prompt_processing:unblock(sk.bl_checkburncounter)
enableTrigger("svokl Don't register")
end
signals.after_prompt_processing:connect(sk.bl_checkburncounter)
signals.after_prompt_processing:block(sk.bl_checkburncounter)
function bl_ignore()
if not next(hittable) then return end
table.remove(select(2, next(hittable)))
end
function bl_reset(whom, quiet)
if defc.dragonform then return end
if whom then whom = string.title(whom) end
local echof = echof
if quiet then echof = function() end end
if whom == "All" then
bl_list = {}
echof("Reset everyone's burn status.")
elseif not whom and lasthit then
bl_list[lasthit] = {level = 0, dehydrate = 0}
echof("Reset %s's burn status.", lasthit)
elseif t[whom:lower()] then
if not lasthit or not bl_list[lasthit] then
echof("Not keeping track of anyone yet to reset their burn.")
end
elseif whom then
if bl_list[whom] then
bl_list[whom] = nil
echof("Reset %s's burn status.", whom)
else
echof("Weren't keeping track of %s anyway.", whom)
end
else
echof("Not keeping track of anyone to reset them anyway.")
end
raiseEvent("svo burncounter reset")
end
function bl_show()
if not next(bl_list) then echof("burncounter: Not keeping track of anyone yet."); return end
setFgColor(unpack(getDefaultColorNums))
for person, burnt in pairs(bl_list) do
echo("---"..person.." ") fg("a_darkgrey")
echoLink("(reset)", 'svo.bl_reset"'..person..'"', "Reset burn status for "..person, true)
setFgColor(unpack(getDefaultColorNums))
echo(string.rep("-", (92-#person-12))) -- 12 for the 'reset' link
echo"\n"
echo(string.format(" burn level: %s (%s), dehydrated: %s", burn_levels[burnt.level] or 'none', burnt.level, (burnt.dehydrate == 0 and "no" or "yes")))
echo"\n"
end
echo(string.rep("-", 91))
end
echof("Loaded svo Knight burncounter.")