Dungeon Dilettante
Posts: 3
Joined: Friday, 29th July 2016, 08:04
Problems running or configuring the software, commands & options, compiling, different platforms, using the interface, documentation, etc.
Dungeon Dilettante
Posts: 3
Joined: Friday, 29th July 2016, 08:04
Slime Squisher
Posts: 352
Joined: Monday, 14th December 2015, 00:43
Slime Squisher
Posts: 352
Joined: Monday, 14th December 2015, 00:43
{
-- line of sight radius
LOS = 7
-- add more prompt if a monster's threat level is equal or above this. 0 = very low/dark grey, 1 = low/grey, 2 = high/yellow, 3 = very high/red
THREAT_NOTIFICATION = 3
local threat_array = {}
-- switch to true if you want to see a debug message spam
local debug_messages = false
function debug_print(msg, condition)
if debug_messages then
if condition ~= nil and not condition then
return
else
crawl.mpr(msg == nil and "nil" or msg)
end
end
end
function array_dump(array, for_options)
local separator = for_options and "|" or ", "
return table.concat(array, separator)
end
function array_find(array, item)
for k,v in pairs(array) do
if v == item then
return k
end
end
return 0
end
function init_threat_array()
if c_persist.threat_array == nil then
c_persist.threat_array = {}
end
debug_print("Old pattern: " .. array_dump(c_persist.threat_array, false))
threat_array = c_persist.threat_array
end
function check_threat(mons)
local name = mons:name()
local threat = mons:threat()
local index = array_find(threat_array, name)
debug_print(name .. ", threat: " .. threat)
if threat >= THREAT_NOTIFICATION then
if index < 1 then -- if not found in threat list
table.insert(threat_array, name)
debug_print("added " .. name .. " to threats")
crawl.more() -- force more if the monster has just been added to threats
end
elseif threat < THREAT_NOTIFICATION then
if index > 0 then
table.remove(threat_array, index)
debug_print("removed " .. name .. " from threats")
end
end
end
function check_monsters_in_sight()
local x, y
local mons
for x = -LOS, LOS do
for y = -LOS, LOS do
mons = monster.get_monster_at(x, y)
if mons ~= nil then
check_threat(mons)
end
end
end
end
function adjust_force_more()
crawl.setopt("force_more_message -= (" .. array_dump(c_persist.threat_array, true) .. ").*into view")
if (#threat_array > 0) then
crawl.setopt("force_more_message += (" .. array_dump(threat_array, true) .. ").*into view")
end
c_persist.threat_array = threat_array
debug_print("New pattern: " .. array_dump(c_persist.threat_array))
end
function ready()
init_threat_array()
check_monsters_in_sight()
adjust_force_more()
end
}
Dungeon Dilettante
Posts: 3
Joined: Friday, 29th July 2016, 08:04
Users browsing this forum: No registered users and 8 guests