Hello everyone! It's been awhile since I posted something, I found this laying on my backup HDD. Thought it could bring some use to you guys! This script was paid for by me, tested on TFS 1.2 10.99 and OTX 4.
What is it?
This is based off of Svargrond Arena, with some slight differences and easy configuration! This only has 2 modes, Unreal and Amateur. This also comes with map, and monsters if you choose to use them.
Let's get started...
data/actions/action.xml
data/actions/scripts/deatharena.lua
data/creaturescripts/creaturescripts.xml
data/creaturescripts/scripts/deatharena.lua
data/lib/lib.lua
data/lib/deatharena.lua
data/movements/movements.xml
data/movements/scripts/deatharena.lua
What is it?
This is based off of Svargrond Arena, with some slight differences and easy configuration! This only has 2 modes, Unreal and Amateur. This also comes with map, and monsters if you choose to use them.
Let's get started...
data/actions/action.xml
XML:
<!-- Death Arena - Reward room doors -->
<action uniqueid="65534" script="deatharena.lua" />
<action uniqueid="65535" script="deatharena.lua" />
data/actions/scripts/deatharena.lua
Lua:
local doors_to_arena = {
[65534] = 2,
[65535] = 3
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local v = doors_to_arena[item:getUniqueId()]
if player:getStorageValue(deatharena.current_arena) ~= v then
player:sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, not possible.")
return true
end
local toPos = item:getPosition()
if player:getPosition().y > item:getPosition().y then
toPos.y = toPos.y - 1
else
toPos.y = toPos.y + 1
end
player:teleportTo(toPos)
return true
end
data/creaturescripts/creaturescripts.xml
XML:
<!-- Death Arena -->
<event type="kill" name="arenaKill" script="deatharena.lua"/>
<event type="preparedeath" name="arenaDeath" script="deatharena.lua"/>
data/creaturescripts/scripts/deatharena.lua
Lua:
dofile("data/lib/deatharena.lua")
function onKill(creature, target)
local PIT = creature:getStorageValue(deatharena.current_pit)
local ARENA = creature:getStorageValue(deatharena.current_arena)
if target:isPlayer() or (PIT < 1) or (PIT > 10) or (ARENA < 1) then
return true
end
if isInArray(deatharena.arena[ARENA].creatures, target:getName()) then
local pillar = Tile(Position(deatharena.pits[PIT].pillar)):getTopTopItem()
if (pillar ~= nil) and (pillar:getId() == deatharena.stonepillar) then
transformDeathPillar(PIT)
else
print("[DeathArena::CreatureEvent] Cannot remove stone pillar on position X: " .. deatharena.pits[PIT].pillar.x .. ", Y: " .. deatharena.pits[PIT].pillar.y .. ", Z: " .. deatharena.pits[PIT].pillar.z .. ".")
end
setGlobalExhaust("DEATH_ARENA_EXHAUST", 60)
creature:setStorageValue(deatharena.current_pit, PIT + 1)
creature:say("Victory! Head through the teleporter into the next room.", TALKTYPE_MONSTER_YELL)
end
return true
end
function onPrepareDeath(creature, killer)
creature:teleportTo(deatharena.kick)
creature:setStorageValue(deatharena.current_pit, 0)
creature:addHealth(creature:getMaxHealth())
creature:addMana(creature:getMaxMana())
local condition = 1
creature:removeCondition(condition)
for n = 1, 27 do
condition = condition * 2
creature:removeCondition(condition)
end
creature:sendTextMessage(MESSAGE_INFO_DESCR, "You have lost...")
creature:unregisterEvent("arenaKill")
creature:unregisterEvent("arenaDeath")
setGlobalExhaust("DEATH_ARENA_EXHAUST", 60)
return false
end
data/lib/lib.lua
Lua:
dofile('data/lib/deatharena.lua')
data/lib/deatharena.lua
Lua:
function checkGlobalExhaust(key)
local val = getGlobalStorageValue(key)
if not tonumber(val) then
return false
end
return val >= os.time()
end
function getGlobalExhaust(key)
local exhaust = getGlobalStorageValue(key)
if(exhaust > 0) then
local left = exhaust - os.time()
if(left >= 0) then
return left
end
end
return false
end
function setGlobalExhaust(key, seconds)
return setGlobalStorageValue(key, os.time() + seconds)
end
--positions of first pit
death_arena_base = {
fromPos = {x = 10106, y = 10058, z = 8},
toPos = {x = 10116, y = 10068, z = 8},
center = {x = 10111, y = 10063, z = 8},
pillar = {x = 10111, y = 10058, z = 8},
summon = {x = 10111, y = 10060, z = 8},
timer = {x = 10107, y = 10063, z = 8},
radius = 5,
}
deatharena = {
timePerPit = 5 * 60, --seconds
timePerWin = 1 * 60, --seconds
action_tp = 1002, --actionid set to teleport to advance next pit
firetimer = {1500, 1501, 1502},
stonepillar = 1354,
noerase = {1500, 1501, 1502, 1354, 1526, 1524, 1530}, --Not erasable items when pit is reset
--player storages
current_arena = 1,
current_pit = 2,
exhaust = 3,
trophy_taken = 5,
--positions
reward_area_center = Position(10128, 9911, 8),
reward_teleport = Position(10116, 9920, 8),
kick = {x = 10108, y = 10084, z = 8},
pits = {
[1] = {
fromPos = death_arena_base.fromPos,
toPos = death_arena_base.toPos,
center = death_arena_base.center,
pillar = death_arena_base.pillar,
summon = death_arena_base.summon,
timer = death_arena_base.timer,
radius = death_arena_base.radius
},
[2] = {
fromPos = {x = death_arena_base.fromPos.x, y = death_arena_base.fromPos.y - 12, z = death_arena_base.fromPos.z},
toPos = {x = death_arena_base.toPos.x, y = death_arena_base.toPos.y - 12, z = death_arena_base.toPos.z},
center = {x = death_arena_base.center.x, y = death_arena_base.center.y - 12, z = death_arena_base.center.z},
pillar = {x = death_arena_base.pillar.x, y = death_arena_base.pillar.y - 12, z = death_arena_base.pillar.z},
summon = {x = death_arena_base.summon.x, y = death_arena_base.summon.y - 12, z = death_arena_base.summon.z},
timer = {x = death_arena_base.timer.x, y = death_arena_base.timer.y - 12, z = death_arena_base.timer.z},
radius = death_arena_base.radius
},
[3] = {
fromPos = {x = death_arena_base.fromPos.x, y = death_arena_base.fromPos.y - 24, z = death_arena_base.fromPos.z},
toPos = {x = death_arena_base.toPos.x, y = death_arena_base.toPos.y - 24, z = death_arena_base.toPos.z},
center = {x = death_arena_base.center.x, y = death_arena_base.center.y - 24, z = death_arena_base.center.z},
pillar = {x = death_arena_base.pillar.x, y = death_arena_base.pillar.y - 24, z = death_arena_base.pillar.z},
summon = {x = death_arena_base.summon.x, y = death_arena_base.summon.y - 24, z = death_arena_base.summon.z},
timer = {x = death_arena_base.timer.x, y = death_arena_base.timer.y - 24, z = death_arena_base.timer.z},
radius = death_arena_base.radius
},
[4] = {
fromPos = {x = death_arena_base.fromPos.x, y = death_arena_base.fromPos.y - 36, z = death_arena_base.fromPos.z},
toPos = {x = death_arena_base.toPos.x, y = death_arena_base.toPos.y - 36, z = death_arena_base.toPos.z},
center = {x = death_arena_base.center.x, y = death_arena_base.center.y - 36, z = death_arena_base.center.z},
pillar = {x = death_arena_base.pillar.x, y = death_arena_base.pillar.y - 36, z = death_arena_base.pillar.z},
summon = {x = death_arena_base.summon.x, y = death_arena_base.summon.y - 36, z = death_arena_base.summon.z},
timer = {x = death_arena_base.timer.x, y = death_arena_base.timer.y - 36, z = death_arena_base.timer.z},
radius = death_arena_base.radius
},
[5] = {
fromPos = {x = death_arena_base.fromPos.x, y = death_arena_base.fromPos.y - 48, z = death_arena_base.fromPos.z},
toPos = {x = death_arena_base.toPos.x, y = death_arena_base.toPos.y - 48, z = death_arena_base.toPos.z},
center = {x = death_arena_base.center.x, y = death_arena_base.center.y - 48, z = death_arena_base.center.z},
pillar = {x = death_arena_base.pillar.x, y = death_arena_base.pillar.y - 48, z = death_arena_base.pillar.z},
summon = {x = death_arena_base.summon.x, y = death_arena_base.summon.y - 48, z = death_arena_base.summon.z},
timer = {x = death_arena_base.timer.x, y = death_arena_base.timer.y - 48, z = death_arena_base.timer.z},
radius = death_arena_base.radius
},
[6] = {
fromPos = {x = death_arena_base.fromPos.x, y = death_arena_base.fromPos.y - 60, z = death_arena_base.fromPos.z},
toPos = {x = death_arena_base.toPos.x, y = death_arena_base.toPos.y - 60, z = death_arena_base.toPos.z},
center = {x = death_arena_base.center.x, y = death_arena_base.center.y - 60, z = death_arena_base.center.z},
pillar = {x = death_arena_base.pillar.x, y = death_arena_base.pillar.y - 60, z = death_arena_base.pillar.z},
summon = {x = death_arena_base.summon.x, y = death_arena_base.summon.y - 60, z = death_arena_base.summon.z},
timer = {x = death_arena_base.timer.x, y = death_arena_base.timer.y - 60, z = death_arena_base.timer.z},
radius = death_arena_base.radius
},
[7] = {
fromPos = {x = death_arena_base.fromPos.x, y = death_arena_base.fromPos.y - 72, z = death_arena_base.fromPos.z},
toPos = {x = death_arena_base.toPos.x, y = death_arena_base.toPos.y - 72, z = death_arena_base.toPos.z},
center = {x = death_arena_base.center.x, y = death_arena_base.center.y - 72, z = death_arena_base.center.z},
pillar = {x = death_arena_base.pillar.x, y = death_arena_base.pillar.y - 72, z = death_arena_base.pillar.z},
summon = {x = death_arena_base.summon.x, y = death_arena_base.summon.y - 72, z = death_arena_base.summon.z},
timer = {x = death_arena_base.timer.x, y = death_arena_base.timer.y - 72, z = death_arena_base.timer.z},
radius = death_arena_base.radius
},
[8] = {
fromPos = {x = death_arena_base.fromPos.x, y = death_arena_base.fromPos.y - 84, z = death_arena_base.fromPos.z},
toPos = {x = death_arena_base.toPos.x, y = death_arena_base.toPos.y - 84, z = death_arena_base.toPos.z},
center = {x = death_arena_base.center.x, y = death_arena_base.center.y - 84, z = death_arena_base.center.z},
pillar = {x = death_arena_base.pillar.x, y = death_arena_base.pillar.y - 84, z = death_arena_base.pillar.z},
summon = {x = death_arena_base.summon.x, y = death_arena_base.summon.y - 84, z = death_arena_base.summon.z},
timer = {x = death_arena_base.timer.x, y = death_arena_base.timer.y - 84, z = death_arena_base.timer.z},
radius = death_arena_base.radius
},
[9] = {
fromPos = {x = death_arena_base.fromPos.x, y = death_arena_base.fromPos.y - 96, z = death_arena_base.fromPos.z},
toPos = {x = death_arena_base.toPos.x, y = death_arena_base.toPos.y - 96, z = death_arena_base.toPos.z},
center = {x = death_arena_base.center.x, y = death_arena_base.center.y - 96, z = death_arena_base.center.z},
pillar = {x = death_arena_base.pillar.x, y = death_arena_base.pillar.y - 96, z = death_arena_base.pillar.z},
summon = {x = death_arena_base.summon.x, y = death_arena_base.summon.y - 96, z = death_arena_base.summon.z},
timer = {x = death_arena_base.timer.x, y = death_arena_base.timer.y - 96, z = death_arena_base.timer.z},
radius = death_arena_base.radius
},
[10] = {
fromPos = {x = 10104, y = 9946, z = 8},
toPos = {x = 10118, y = 9960, z = 8},
center = {x = 10111, y = 9953, z = 8},
pillar = {x = 10111, y = 9946, z = 8},
summon = {x = 10111, y = 9948, z = 8},
timer = {x = 10105, y = 9953, z = 8},
radius = 7
},
},
arena = {
[1] = {
name = "Amateur",
reqLevel = 250,
price = 100000,
creatures = {
[1] = "askarak",
[2] = "sasi",
[3] = "viscount",
[4] = "palee",
[5] = "carl",
[6] = "disgu",
[7] = "Abyss",
[8] = "lavos",
[9] = "feasti",
[10] = "ruetama"
}
},
[2] = {
name = "Unreal",
reqLevel = 350,
price = 150000,
creatures = {
[1] = "abomination",
[2] = "warmaster",
[3] = "Krillo",
[4] = "spidy",
[5] = "pye",
[6] = "fever",
[7] = "guilty eye",
[8] = "sleepy",
[9] = "shocker",
[10] = "ultimate gaz"
}
}
}
}
function isDeathArenaFree()
local specs = getSpectators(deatharena.reward_area_center, 16, 16, false, true)
if specs ~= nil then
return false
end
for i = 1, 10 do
local v = deatharena.pits[i]
specs = getSpectators(v.center, v.radius, v.radius, false, true)
if specs ~= nil then
return false
end
end
return true
end
function getCreaturesOnPit(id)
local t, v = {}, deatharena.pits[id]
local specs = getSpectators(v.center, v.radius, v.radius, false)
if specs ~= nil then
for _, uid in ipairs(specs) do
table.insert(t, Creature(uid))
end
end
return t
end
function resetDeathPit(id)
local v = deatharena.pits[id]
if v then
for x = v.fromPos.x, v.toPos.x do
for y = v.fromPos.y, v.toPos.y do
local tile = Tile(Position(x, y, v.fromPos.z))
local thing = tile:getTopTopItem()
if (thing ~= nil) and not isInArray(deatharena.noerase, thing:getId()) and isMoveable(thing:getUniqueId()) then
thing:remove()
end
thing = tile:getTopCreature()
if (thing ~= nil) and thing:isMonster() and (thing:getMaster() == nil) then
thing:remove()
end
end
end
end
return true
end
function restoreDeathPillar(id)
local v = getTileItemById(deatharena.pits[id].pillar, 1387)
if v.uid > 0 then
v = Item(v.uid)
v:transform(deatharena.stonepillar)
v:setActionId(0)
local pit = deatharena.pits[id]
local specs = getSpectators(pit.center, pit.radius, pit.radius, false)
if specs ~= nil then
for _, uid in ipairs(specs) do
local creature = Creature(uid)
if creature:isPlayer() then
creature:teleportTo(deatharena.kick)
creature:sendTextMessage(MESSAGE_INFO_DESCR, "Time out.")
creature:setStorageValue(deatharena.current_pit, 0)
creature:unregisterEvent("arenaKill")
creature:unregisterEvent("arenaDeath")
elseif creature:isMonster() and (creature:getMaster() == nil) then
creature:remove()
end
end
end
setGlobalExhaust("DEATH_ARENA_EXHAUST", 60)
end
end
function transformDeathPillar(id)
local field = Tile(deatharena.pits[id].timer):getFieldItem()
if field ~= nil then
field:remove()
end
local v = getTileItemById(deatharena.pits[id].pillar, deatharena.stonepillar)
if v.uid > 0 then
v = Item(v.uid)
v:transform(1387)
v:setActionId(deatharena.action_tp)
addEvent(restoreDeathPillar, deatharena.timePerWin * 1000, id)
end
end
function startDeathTimer(id)
local v = Tile(Position(deatharena.pits[id].timer)):getTopTopItem()
if v ~= nil then
v:remove()
end
doCreateItem(deatharena.firetimer[1], 1, deatharena.pits[id].timer)
addEvent(decayDeathTimer, (deatharena.timePerPit / table.maxn(deatharena.firetimer)) * 1000, id)
end
function decayDeathTimer(pitid)
local field = Tile(deatharena.pits[pitid].timer):getFieldItem()
if field ~= nil then
if field:getId() == deatharena.firetimer[3] then
field:remove()
local pit = deatharena.pits[pitid]
local specs = getSpectators(pit.center, pit.radius, pit.radius, false)
if specs ~= nil then
for _, uid in ipairs(specs) do
local creature = Creature(uid)
if creature:isPlayer() then
setGlobalExhaust("DEATH_ARENA_EXHAUST", 60)
creature:teleportTo(deatharena.kick)
creature:sendTextMessage(MESSAGE_INFO_DESCR, "Time out.")
creature:setStorageValue(deatharena.current_pit, 0)
creature:unregisterEvent("arenaKill")
creature:unregisterEvent("arenaDeath")
elseif creature:isMonster() and (creature:getMaster() == nil) then
creature:remove()
end
end
end
return true
elseif isInArray(deatharena.firetimer, field:getId()) then
field:transform(field:getId() == deatharena.firetimer[1] and deatharena.firetimer[2] or deatharena.firetimer[3])
addEvent(decayDeathTimer, (deatharena.timePerPit / table.maxn(deatharena.firetimer)) * 1000, pitid)
end
end
return true
end
data/movements/movements.xml
XML:
<!-- Death Arena -->
<movevent event="StepIn" actionid="1002" script="deatharena.lua" />
<!-- Reward Room - Trophy tiles -->
<movevent event="StepIn" uniqueid="40000" script="deatharena.lua" />
<movevent event="StepIn" uniqueid="40001" script="deatharena.lua" />
data/movements/scripts/deatharena.lua
Lua:
dofile("data/lib/deatharena.lua")
local arena_trophy = {
[40000] = {
value = 2,
trophy = 5807,
descr = "A brave trainer that finished the Death Arena Amateur mode. Awarded to %s.",
},
[40001] = {
value = 3,
trophy = 5806,
descr = "A brave trainer that finished the Death Arena Unreal mode. Awarded to %s.",
},
}
function onStepIn(creature, item, position, fromPosition)
if not creature:isPlayer() then
return false
end
local ARENA = creature:getStorageValue(deatharena.current_arena)
if arena_trophy[item:getUniqueId()] then
local v = arena_trophy[item:getUniqueId()]
if ARENA ~= v.value then
creature:sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, not possible.")
return creature:teleportTo(fromPosition, true)
end
if creature:getStorageValue(deatharena.trophy_taken) ~= 0 then
return creature:sendTextMessage(MESSAGE_INFO_DESCR, "You have already obtained this trophy.")
end
local pos = creature:getPosition()
pos.x = pos.x - 1
local trophy = Game.createItem(v.trophy, 1, pos)
if trophy ~= nil then
trophy:setDescription(string.format(v.descr, creature:getName()))
end
creature:setStorageValue(deatharena.trophy_taken, 1)
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
return true
end
local oldPit = creature:getStorageValue(deatharena.current_pit) - 1
local newPit = creature:getStorageValue(deatharena.current_pit)
if newPit < 1 then
creature:sendTextMessage(MESSAGE_INFO_DESCR, "Something is wrong, please contact a gamemaster.")
return creature:teleportTo(fromPosition, true)
end
if newPit > 10 then
creature:setStorageValue(deatharena.current_pit, 0)
creature:setStorageValue(deatharena.trophy_taken, 0)
creature:setStorageValue(deatharena.current_arena, ARENA + 1)
creature:addAchievement(creature:getStorageValue(deatharena.current_arena) == 2 and 331 or 332)
creature:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You completed the " .. deatharena.arena[ARENA].name .. " arena, you should take your reward now.")
creature:say(cid, ARENA == 1 and "Congratulations, brave warrior!" or "Respect and honour to you, champion!", TALKTYPE_MONSTER_YELL)
creature:teleportTo(deatharena.reward_teleport)
creature:getPosition():sendMagicEffect(ARENA == 1 and CONST_ME_FIREWORK_BLUE or CONST_ME_FIREWORK_RED)
return setGlobalExhaust("DEATH_ARENA_EXHAUST", 60)
end
local k, v = deatharena.pits[newPit], deatharena.arena[ARENA]
resetDeathPit(newPit)
setGlobalExhaust("DEATH_ARENA_EXHAUST", 60)
creature:teleportTo(k.center)
Game.createMonster(v.creatures[newPit], k.summon)
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
creature:say("FIGHT!", TALKTYPE_MONSTER_YELL)
local pillar = Tile(k.pillar):getTopTopItem()
if (pillar ~= nil) and (pillar:getId() ~= deatharena.stonepillar) then
doCreateItem(deatharena.stonepillar, k.pillar)
end
local field = Tile(k.timer):getTopTopItem()
if (field ~= nil) and isInArray(ITEM_FIREFIELD_TIMER, field:getId()) then
field:remove()
end
startDeathTimer(newPit)
return true
end
Attachments
-
DeathArena 1.2 map + monsters.rar26.7 KB · Views: 27 · VirusTotal
Last edited: