Spoiler print('initialising...')
dofile('sys/lua/wrapper.lua')
math.randomseed(os.time())
dir = 'sys/lua/cs2dtibia/'
dofile(dir .. 'config.lua')
dofile(dir .. 'admin.lua')
EXPTABLE = {}
for level = 1, 500 do
EXPTABLE[level] = CONFIG.EXP.CALC(level)
end
EXPTABLE.__index = function(t, k)
t[k] = CONFIG.EXP.CALC(k)
return t[k]
end
setmetatable(EXPTABLE, EXPTABLE)
GROUNDITEMS = {}
TILEZONE = {}
for y = 0, map'ysize' do
GROUNDITEMS[y], TILEZONE[y] = {}, {}
for x = 0, map'xsize' do
GROUNDITEMS[y][x], TILEZONE[y][x] = {}, {}
for i, v in ipairs(SAFEZONE) do
TILEZONE[y][x].SAFE = (x >= v[1][1] and x <= v[2][1] and y >= v[1][2] and y <= v[2][2])
if TILEZONE[y][x].SAFE then break end
end
for i, v in ipairs(PVPZONE) do
TILEZONE[y][x].PVP = (x >= v[1][1] and x <= v[2][1] and y >= v[1][2] and y <= v[2][2]) and i or nil
if TILEZONE[y][x].PVP then
TILEZONE[y][x].SAFE = false
break
end
end
for i, v in ipairs(HOUSES) do
TILEZONE[y][x].HOUSE = (x >= v.pos1[1] and x <= v.pos2[1] and y >= v.pos1[2] and y <= v.pos2[2]) and i or nil
TILEZONE[y][x].HOUSEDOOR = (x == v.door[1] and y == v.door[2]) and i or nil
TILEZONE[y][x].HOUSEENT = (x == v.ent[1] and y == v.ent[2]) and i or nil
if TILEZONE[y][x].HOUSE or TILEZONE[y][x].HOUSEDOOR or TILEZONE[y][x].HOUSEENT then break end
end
end
end
PLAYERS = {}
PLAYERCACHE = {}
HUDImage = image('gfx/weiwen/1x1.png', 565, 407+#CONFIG.STATS*CONFIG.PIXELS/2, 2)
imagescale(HUDImage, 130,CONFIG.PIXELS+#CONFIG.STATS*CONFIG.PIXELS)
imagealpha(HUDImage, 0.5)
SKY = image('gfx/weiwen/1x1.png',320,240,2)
imagescale(SKY,640,480)
imagecolor(SKY,0,0,32)
MINUTES = 0
GLOBAL = {}
GLOBAL.TIME = 0
GLOBAL.RAIN = 0
dofile(dir .. 'functions.lua')
dofile(dir .. 'commands.lua')
dofile(dir .. 'items.lua')
dofile(dir .. 'npcs.lua')
if CONFIG.MAXMONSTERS > 0 then
dofile(dir .. 'monsters.lua')
end
dofile(dir .. 'hooks.lua')
HUDRadar = image("gfx/weiwen/pokeball.png", 53, 53, 2)
TMPGROUNDITEMS = {}
TMPHOUSES = {}
local file = io.open(dir .. "saves/" .. map'name' .. ".lua")
if file then
io.close(file)
dofile(dir .. "saves/" .. map'name' .. ".lua")
for y = 0, map'ysize' do
if TMPGROUNDITEMS[y] then
for x = 0, map'xsize' do
if TMPGROUNDITEMS[y][x] then
for _, j in ipairs(TMPGROUNDITEMS[y][x]) do
if j < 0 then
spawnitem(1337, x, y, -j)
else
spawnitem(j, x, y)
end
end
end
end
end
end
for i, v in pairs(TMPHOUSES) do
for k, l in pairs(v) do
HOUSES[i][k] = l
end
end
TMPGROUNDITEMS = nil
TMPHOUSES = nil
end
local file = io.open(dir .. "saves/players.lua")
if file then
io.close(file)
dofile(dir .. "saves/players.lua")
end
file = nil
parse("mp_infammo 1")
parse("mp_deathdrop 4")
parse("sv_password " .. CONFIG.PASSWORD)
print('initialisation comleted!')