tibia-rme/scripts/spawn_visualizer.lua
Eduardo Dantas ea6b515552
ci: rework build workflows and vcpkg baseline (#176)
New Features:
- Docker support: new container build and .dockerignore to reduce build-context size.
- Automated vcpkg baseline updater.

CI/CD Improvements:
- Introduces consolidated reusable CI with platform build and Docker workflows.
- Adds cache-cleanup and autofix/format workflows; removes several legacy platform-specific CI files.

Chores:
- Reorganized CMake presets and build configuration; updated build scripts and project metadata.

Style:
- Large-scale formatting/whitespace normalization across many scripts and build files.
2026-05-01 19:45:45 -03:00

131 lines
2.5 KiB
Lua

-- @Title: Spawn Visualizer
-- @Description: Draws spawn radius circles as an overlay on the map
-- @Author: VLL Systems
-- @Version: 1.0.0
-- @AutoRun: true
if not app.hasMap() then
return
end
-- Register the overlay
app.mapView.addOverlay("spawn_visualizer", {
enabled = true,
order = 10,
ondraw = function(ctx)
local view = ctx.view
local map = app.map
if not map then
return
end
local z = view.z
-- Scan visible area for spawns
for y = view.y1, view.y2 do
for x = view.x1, view.x2 do
local tile = map:getTile(x, y, z)
if tile and tile.hasSpawn then
local spawn = tile.spawn
local radius = spawn.size
-- Draw spawn radius as a rectangle outline (circle approximation)
ctx.rect({
x = x - radius,
y = y - radius,
z = z,
w = radius * 2 + 1,
h = radius * 2 + 1,
filled = false,
width = 1,
style = "dashed",
color = {
r = 255,
g = 100,
b = 100,
a = 140,
},
})
-- Draw center marker
ctx.rect({
x = x,
y = y,
z = z,
w = 1,
h = 1,
filled = true,
color = {
r = 255,
g = 50,
b = 50,
a = 180,
},
})
-- Draw creature name if present
if tile.hasCreature then
local creature = tile.creature
if creature then
ctx.text({
x = x,
y = y - 1,
z = z,
text = creature.name,
color = {
r = 255,
g = 200,
b = 200,
a = 220,
},
})
end
end
end
end
end
end,
onhover = function(info)
local tile = info.tile
if not tile then
return nil
end
if tile.hasSpawn then
local spawn = tile.spawn
local text = "Spawn (radius: " .. spawn.size .. ")"
if tile.hasCreature then
local creature = tile.creature
text = text .. "\n" .. creature.name .. " (spawn: " .. creature.spawnTime .. "s)"
end
return {
tooltip = text,
highlight = {
x = tile.x - spawn.size,
y = tile.y - spawn.size,
z = tile.z,
w = spawn.size * 2 + 1,
h = spawn.size * 2 + 1,
filled = false,
width = 2,
color = {
r = 255,
g = 255,
b = 0,
a = 180,
},
},
}
end
return nil
end,
})
-- Register toggle in View menu
app.mapView.registerShow("Spawn Radius Overlay", "spawn_visualizer", {
enabled = true,
})
print("[Spawn Visualizer] Overlay registered. Toggle via View menu.")