<
if not randtile_options then
randtile_options = {
-- Change the tile every N turns
turns_change = 1,
-- Which setting for tile_player_tile to use when disabling RandomTiles
-- with toggle_random_tile(). Can set to e.g. "normal", "playermons",
-- or a fixed mons/tile.
disabled_setting = "normal"
}
end
-- Begin player_tiles array
if not player_tiles then
player_tiles = {
{ mons = "kraken simulacrum tentacle end",
tile = "MONS_KRAKEN_SIMULACRUM_TENTACLE_WATER",
weapon_offsets = "32,32", shield_offsets = "32,32" },
{ mons = "kraken simulacrum tentacle end",
tile = "MONS_KRAKEN_SIMULACRUM_TENTACLE_WATER_2",
weapon_offsets = "32,32", shield_offsets = "32,32" },
{ mons = "kraken simulacrum tentacle end",
tile = "MONS_KRAKEN_SIMULACRUM_TENTACLE_WATER_3",
weapon_offsets = "32,32", shield_offsets = "32,32" },
{ mons = "kraken simulacrum tentacle end",
tile = "MONS_KRAKEN_SIMULACRUM_TENTACLE_WATER_4",
weapon_offsets = "32,32", shield_offsets = "32,32" },
{ mons = "kraken simulacrum tentacle end",
tile = "MONS_KRAKEN_SIMULACRUM_TENTACLE_WATER_5",
weapon_offsets = "32,32", shield_offsets = "32,32" },
{ mons = "kraken simulacrum tentacle end",
tile = "MONS_KRAKEN_SIMULACRUM_TENTACLE_WATER_6",
weapon_offsets = "32,32", shield_offsets = "32,32" },
} -- end player_tiles array
end
-- Note: No further configuration past this point.
-- A list of tiles that are valid and compatible with our version.
valid_tiles = {}
rtdat = nil
-- 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
-- Populate valid_tiles
function init_random_tiles(tiles)
local version = tonumber(crawl.version("major"))
for i,v in ipairs(player_tiles) do
if v.mons
and (not v.min_version or version >= tonumber(v.min_version))
and (not v.max_version or version <= tonumber(v.max_version)) then
valid_tiles[#valid_tiles + 1] = v
end
end
-- state data
local default_state = { index = 1 + crawl.random2(#valid_tiles),
last_index_change = you.turns(),
last_variant = -1,
forward_direction = true,
last_xl = tonumber(you.xl()),
enabled = true,
timer_enabled = true }
if not c_persist.randomtile_state then
c_persist.randomtile_state = {}
end
rtdat = c_persist.randomtile_state
for key,val in pairs(default_state) do
if rtdat[key] == nil then
rtdat[key] = val
end
end
if rtdat.enabled then
enable_random_tile(true)
else
disable_random_tile(true)
end
end
-- Print a message about a tile set change
function tile_change_message()
if not randtile_options.god_message then
return
end
local god = you.god()
if god == "No God" then
god = randtile_options.default_god
end
if randtile_options.god_speech[god] then
msg_template = randtile_options.god_speech[god]
else
msg_template = randtile_options.god_speech["default"]
end
local msg = msg_template:gsub("%%g", god)
local amons = crawl.grammar(valid_tiles[rtdat.index].mons, "A")
local mons = valid_tiles[rtdat.index].mons
msg = msg:gsub("%%am", amons)
mons = mons:gsub("^[tT][hH][eE] ", "")
mons = mons:gsub("^[aA][nN]? ", "")
msg = msg:gsub("%%m", mons)
mpr(msg, randtile_options.message_colour)
end
function get_terrain()
local feat = view.feature_at(0,0)
-- Set to "air" when flying so water and lava features under the
-- player don't cause spurious matches.
if you.status():find("flying") then
feat = "air"
end
return feat
end
function get_percent_hp()
local hp, mhp = you.hp()
return hp / mhp
end
if not var_functions then
var_functions = {
["percent_hp"] = get_percent_hp,
["status"] = you.status,
["terrain"] = get_terrain,
["xl"] = you.xl,
}
end
-- Change the current tile using the tileset entry with the given index in
-- valid_tiles. This will update the randtile state as necessary.
function change_tile(index, force)
local tileopt = nil
local change_index = force or index ~= rtdat.index
local entry = valid_tiles[index]
local num_var = entry.num_var
if not num_var and entry.tileset then
num_var = table.getn(entry.tileset)
end
if num_var then
local var_type = entry.var_type
if not var_type then
var_type = "random"
end
local variant = 1
if var_type == "random" or var_type == "fixed" then
variant = crawl.random2(num_var) + 1
-- Iterate the sequence variant if we have valid state for it.
elseif var_type == "sequence"
and not change_index
and rtdat.last_variant >= 1
and rtdat.last_variant < num_var then
variant = rtdat.last_variant + 1
elseif var_type == "oscillate"
and not change_index
and rtdat.last_variant >= 1 then
if rtdat.forward_direction and rtdat.last_variant == num_var then
rtdat.forward_direction = false
elseif not rtdat.forward_direction and rtdat.last_variant == 1 then
rtdat.forward_direction = true
end
variant = rtdat.last_variant + (rtdat.forward_direction and 1 or -1)
elseif var_functions[var_type] ~= nil then
local comp_value = var_functions[var_type]()
local comp_string = true
if type(comp_value) == "number" then
comp_string = false
end
for i, v in pairs(entry.tileset) do
if i > 1
and (comp_string and comp_value:find(v[1])
or not comp_string and comp_value <= v[1]) then
variant = i
-- For string values, take the first match
if comp_string then
break
end
end
end
end
rtdat.last_variant = variant
-- custom-defined tilesets or an variant set defined by crawl itself.
if entry.tileset then
-- For var_type values that use var_functions
if type(entry.tileset[variant]) == "table" then
tileopt = entry.tileset[variant][2]
else
tileopt = entry.tileset[variant]
end
elseif entry.tile then
local var_suf
if variant == 1 then
var_suf = ""
else
var_suf = "_" .. variant - 1
end
tileopt = entry.tile .. var_suf
end
tileopt = "tile:" .. tileopt
elseif entry.tile then
tileopt = "tile:" .. entry.tile
elseif entry.mons then
tileopt = "mons:" .. entry.mons
end
if not tileopt then
return
end
if change_index then
rtdat.index = index
rtdat.last_index_change = you.turns()
end
crawl.setopt("tile_player_tile = " .. tileopt)
if valid_tiles[index].weapon_offsets then
crawl.setopt("tile_weapon_offsets = "
.. valid_tiles[index].weapon_offsets)
else
crawl.setopt("tile_weapon_offsets = reset")
end
if valid_tiles[index].shield_offsets then
crawl.setopt("tile_shield_offsets = "
.. valid_tiles[index].shield_offsets)
else
crawl.setopt("tile_shield_offsets = reset")
end
if change_index then
tile_change_message()
end
end
-- Change the tile by partial match of name to the mons entries in
-- valid_tiles. Reads name from input if it's not given as an argument.
function set_tile_by_name(name)
if name == nil then
crawl.formatted_mpr("Enter a tile name search string: ", "prompt")
name = crawl.c_input_line()
if not name then
return
end
end
local first_match = nil
name = name:lower()
for i,v in ipairs(valid_tiles) do
local mname = v.mons:lower()
if mname == name then
first_match = i
break
elseif mname:find(name) and not first_match then
first_match = i
end
end
if first_match then
change_tile(first_match, true)
else
mpr("Unable to match a player_tile mons value with " .. name, "lightred")
end
end
-- Checks the randtile state, changing the tile when necessary. A change of the
-- tile index will cause a tile change message to be displayed. The tile may be
-- changed to a new tileset variant even if the index is unchanged, depending
-- on the definition of the current tileset. If force_change is true, the tile
-- index will always be changed.
function random_tile(force_change)
if not valid_tiles or not rtdat.enabled then
return
end
local num_tiles = #valid_tiles
local xl_changed = tonumber(you.xl()) ~= rtdat.last_xl
if xl_changed then
rtdat.last_xl = tonumber(you.xl())
end
local turns_passed = tonumber(you.turns()) - randtile_options.turns_change
local change_index = force_change or rtdat.timer_enabled
and (xl_changed or turns_passed >= rtdat.last_index_change)
local index
if change_index then
index = 1 + crawl.random2(num_tiles)
else
index = rtdat.index
end
local entry = valid_tiles[index]
local var_type = "random"
if (entry.num_var or entry.tileset) and entry.var_type then
var_type = entry.var_type
end
if not change_index and var_type == "fixed" then
return
end
-- We're changing the player tile because of an index change or because we
-- are using a variant tileset that changes with every UI input.
change_tile(index)
end
-- Force a tile change
function new_random_tile()
random_tile(true)
end
-- Toggle the turn/xl timer to disable/enable index changing.
function toggle_tile_timer()
if rtdat.timer_enabled then
mpr("Disabling tile changes by turn or XL.")
else
mpr("Enabling tile changes by turn and XL.")
end
rtdat.timer_enabled = not rtdat.timer_enabled
end
function enable_random_tile(quiet)
if not quiet then
mpr("Enabling RandomTiles.")
end
rtdat.enabled = true
-- Don't attempt to load an invalid index
if rtdat.index == nil or rtdat.index > #valid_tiles then
rtdat.index = 1 + crawl.random2(#valid_tiles)
end
change_tile(rtdat.index, true)
end
function disable_random_tile(quiet)
rtdat.enabled = false
crawl.setopt("tile_player_tile = " .. randtile_options.disabled_setting)
crawl.setopt("tile_weapon_offsets = reset")
crawl.setopt("tile_shield_offsets = reset")
if not quiet then
mpr("Disabling RandomTiles.")
end
end
-- Toggle RandomTiles, setting it tile_player_tile to default setting if we're
-- disabling.
function toggle_random_tile()
if rtdat.enabled then
disable_random_tile()
else
enable_random_tile()
end
end
-- Initialize the tileset, removing any invalid tile entries.
init_random_tiles(player_tiles)
>
{
function ready()
random_tile()
end
}
댓글 영역
획득법
① NFT 발행
작성한 게시물을 NFT로 발행하면 일주일 동안 사용할 수 있습니다. (최초 1회)
② NFT 구매
다른 이용자의 NFT를 구매하면 한 달 동안 사용할 수 있습니다. (구매 시마다 갱신)
사용법
디시콘에서지갑연결시 바로 사용 가능합니다.