Hi! I tried to solve the problem based on the information I found on otland, but unfortunately I ultimately failed :/
I have a problem with the scripts and I don't know where.
When I click on the door, it says I can't enter, and when I enter TP it gives me an error in cmd:
I will be grateful if someone smarter tells me how to deal with it
TFS 1.4.2
data\actions\actions.xml:
<!-- Svargrond Arena Quest -->
<action uniqueid="31078" script="svargrondArenaQuest/arenaDoor.lua" />
<action uniqueid="31079" script="svargrondArenaQuest/arenaDoor.lua" />
<action uniqueid="31080" script="svargrondArenaQuest/arenaDoor.lua" />
arenaDoor.lua (data\actions\scripts\svargrondArenaQuest\arenaDoor.lua)
data\creaturescripts\creaturescripts.xml
<!-- Svargrond Arena Quest -->
<event type="kill" name="SvargrondArenaKill" script="svargrondArenaQuest/arenaKill.lua"/>
</creaturescripts>
arenaKill.lua: (data\creaturescripts\scripts\svargrondArenaQuest\arenaKill.lua)
data\lib\svargrondArenaQuest.lua
data\movements\movements.xml
<!-- Svargrond Arena Quest -->
<movevent event="StepIn" actionid="30006" script="svargrondArenaQuest/arenaEnter.lua"/>
<movevent event="StepIn" actionid="30007" script="svargrondArenaQuest/arenaPit.lua"/>
<movevent event="StepIn" actionid="30008" script="svargrondArenaQuest/arenaPit.lua"/>
<movevent event="StepIn" fromuid="31075" touid="31077" script="svargrondArenaQuest/arenaTrophy.lua"/>
data\movements\scripts\svargrondArenaQuest
Halvar
I have a problem with the scripts and I don't know where.
When I click on the door, it says I can't enter, and when I enter TP it gives me an error in cmd:
Lua Script Error: [Scripts Interface]
C:\test\OTS Pendr\forgottenserver-1.4.2\data\scripts\movements\svargrond_arena\arena_enter.lua:callback
...2\data\scripts\movements\svargrond_arena\arena_enter.lua:9: attempt to index field 'SvargrondArena' (a nil value)
stack traceback:
[C]: in function '__index'
...2\data\scripts\movements\svargrond_arena\arena_enter.lua:9: in function <...2\data\scripts\movements\svargrond_arena\arena_enter.lua:3>
I will be grateful if someone smarter tells me how to deal with it
TFS 1.4.2
data\actions\actions.xml:
<!-- Svargrond Arena Quest -->
<action uniqueid="31078" script="svargrondArenaQuest/arenaDoor.lua" />
<action uniqueid="31079" script="svargrondArenaQuest/arenaDoor.lua" />
<action uniqueid="31080" script="svargrondArenaQuest/arenaDoor.lua" />
arenaDoor.lua (data\actions\scripts\svargrondArenaQuest\arenaDoor.lua)
SvargrondArena = SvargrondArena or {}
-- Załadowanie pliku svargrondArenaQuest.lua
dofile('data/lib/svargrondArenaQuest.lua')
-- Logowanie do konsoli, aby upewnić się, że plik został załadowany poprawnie
print("SvargrondArena loaded:", SvargrondArena)
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
local pitId = player:getStorageValue(1009)
if pitId < 1 or pitId > 10 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You cannot enter without Halvar\'s permission.')
player:teleportTo(fromPosition)
return true
end
-- Sprawdzenie, czy SvargrondArena jest poprawnie zainicjalizowane
if not SvargrondArena then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'Arena system is not properly configured.')
player:teleportTo(fromPosition)
return true
end
local arenaId = player:getStorageValue(1008)
if not (PITS[pitId] and ARENA[arenaId]) then
player:teleportTo(fromPosition)
return true
end
local occupant = SvargrondArena.getPitOccupant(pitId, player)
if occupant then
player:sendTextMessage(MESSAGE_INFO_DESCR, occupant:getName() .. ' is currently in the next arena pit. Please wait until ' .. (occupant:getSex() == 0 and 's' or '') .. 'he is done fighting.')
player:teleportTo(fromPosition)
return true
end
SvargrondArena.resetPit(pitId)
SvargrondArena.scheduleKickPlayer(player.uid, pitId)
Game.createMonster(ARENA[arenaId].creatures[pitId], PITS[pitId].summon, false, true)
player:teleportTo(PITS[pitId].center)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
player:say('FIGHT!', TALKTYPE_MONSTER_SAY)
return true
end
-- Załadowanie pliku svargrondArenaQuest.lua
dofile('data/lib/svargrondArenaQuest.lua')
-- Logowanie do konsoli, aby upewnić się, że plik został załadowany poprawnie
print("SvargrondArena loaded:", SvargrondArena)
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
local pitId = player:getStorageValue(1009)
if pitId < 1 or pitId > 10 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You cannot enter without Halvar\'s permission.')
player:teleportTo(fromPosition)
return true
end
-- Sprawdzenie, czy SvargrondArena jest poprawnie zainicjalizowane
if not SvargrondArena then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'Arena system is not properly configured.')
player:teleportTo(fromPosition)
return true
end
local arenaId = player:getStorageValue(1008)
if not (PITS[pitId] and ARENA[arenaId]) then
player:teleportTo(fromPosition)
return true
end
local occupant = SvargrondArena.getPitOccupant(pitId, player)
if occupant then
player:sendTextMessage(MESSAGE_INFO_DESCR, occupant:getName() .. ' is currently in the next arena pit. Please wait until ' .. (occupant:getSex() == 0 and 's' or '') .. 'he is done fighting.')
player:teleportTo(fromPosition)
return true
end
SvargrondArena.resetPit(pitId)
SvargrondArena.scheduleKickPlayer(player.uid, pitId)
Game.createMonster(ARENA[arenaId].creatures[pitId], PITS[pitId].summon, false, true)
player:teleportTo(PITS[pitId].center)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
player:say('FIGHT!', TALKTYPE_MONSTER_SAY)
return true
end
data\creaturescripts\creaturescripts.xml
<!-- Svargrond Arena Quest -->
<event type="kill" name="SvargrondArenaKill" script="svargrondArenaQuest/arenaKill.lua"/>
</creaturescripts>
arenaKill.lua: (data\creaturescripts\scripts\svargrondArenaQuest\arenaKill.lua)
dofile('data/lib/svargrondArenaQuest.lua')
function onKill(creature, target)
if not target:isMonster() then
return true
end
local pit = creature:getStorageValue(1009)
if pit < 1 or pit > 10 then
return true
end
local arena = creature:getStorageValue(1008)
if arena < 1 then
return true
end
if not isInArray(ARENA[arena].creatures, target:getName():lower()) then
return true
end
-- Remove pillar and create teleport
local pillarTile = Tile(PITS[pit].pillar)
if pillarTile then
local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
if pillarItem then
pillarItem:remove()
local teleportItem = Game.createItem(SvargrondArena.itemTeleport, 1, PITS[pit].tp)
if teleportItem then
teleportItem:setActionId(30007)
end
SvargrondArena.sendPillarEffect(pit)
end
end
creature:setStorageValue(1009, pit + 1)
creature:say('Victory! Head through the new teleporter into the next room.', TALKTYPE_MONSTER_SAY)
return true
end
function onKill(creature, target)
if not target:isMonster() then
return true
end
local pit = creature:getStorageValue(1009)
if pit < 1 or pit > 10 then
return true
end
local arena = creature:getStorageValue(1008)
if arena < 1 then
return true
end
if not isInArray(ARENA[arena].creatures, target:getName():lower()) then
return true
end
-- Remove pillar and create teleport
local pillarTile = Tile(PITS[pit].pillar)
if pillarTile then
local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
if pillarItem then
pillarItem:remove()
local teleportItem = Game.createItem(SvargrondArena.itemTeleport, 1, PITS[pit].tp)
if teleportItem then
teleportItem:setActionId(30007)
end
SvargrondArena.sendPillarEffect(pit)
end
end
creature:setStorageValue(1009, pit + 1)
creature:say('Victory! Head through the new teleporter into the next room.', TALKTYPE_MONSTER_SAY)
return true
end
data\lib\svargrondArenaQuest.lua
SvargrondArena = {
-- action ids have to be equal to action id of reward doors
actionGreenhorn = 31078,
actionScrapper = 31079,
actionWarlord = 31080,
-- kick time in seconds (10 minutes)
kickTime = 600,
kickPosition = Position(32251, 31098, 6),
rewardPosition = Position(32222, 31080, 6),
-- used to store event ids
kickEvents = {},
timerEvents = {},
effectPositionCache = {},
-- item ids used by the script
itemTimer = 7473,
itemPillar = 1354,
itemTeleport = 5023,
itemsNotErasable = {7473, 1354, 1543, 1544, 1545},
}
-- Script automatically derives other pit positions from this one
local firstPit = {
fromPos = {x = 32205, y = 31094, z = 7},
toPos = {x = 32214, y = 31103, z = 7},
center = {x = 32210, y = 31098, z = 7},
pillar = {x = 32204, y = 31098, z = 7},
tp = {x = 32204, y = 31098, z = 7},
summon = {x = 32210, y = 31100, z = 7}
}
PITS = {
[1] = {
fromPos = firstPit.fromPos,
toPos = firstPit.toPos,
center = firstPit.center,
pillar = firstPit.pillar,
tp = firstPit.tp,
summon = firstPit.summon
},
[2] = {
fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 14, y = firstPit.center.y, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y, z = firstPit.summon.z}
},
[3] = {
fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 28, y = firstPit.center.y, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y, z = firstPit.summon.z}
},
[4] = {
fromPos = {x = firstPit.fromPos.x - 42, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 42, y = firstPit.toPos.y, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 42, y = firstPit.center.y, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 42, y = firstPit.pillar.y, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 42, y = firstPit.tp.y, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 42, y = firstPit.summon.y, z = firstPit.summon.z}
},
[5] = {
fromPos = {x = firstPit.fromPos.x - 35, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 35, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 35, y = firstPit.center.y - 14, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 35, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 35, y = firstPit.tp.y - 14, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 35, y = firstPit.summon.y - 14, z = firstPit.summon.z}
},
[6] = {
fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 21, y = firstPit.center.y - 14, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 14, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 14, z = firstPit.summon.z}
},
[7] = {
fromPos = {x = firstPit.fromPos.x - 7, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 7, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 7, y = firstPit.center.y - 14, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 7, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 7, y = firstPit.tp.y - 14, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 7, y = firstPit.summon.y - 14, z = firstPit.summon.z}
},
[8] = {
fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 14, y = firstPit.center.y - 28, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y - 28, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y - 28, z = firstPit.summon.z}
},
[9] = {
fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 28, y = firstPit.center.y - 28, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y - 28, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y - 28, z = firstPit.summon.z}
},
[10] = {
fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 42, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 42, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 21, y = firstPit.center.y - 41, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 41, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 41, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 41, z = firstPit.summon.z}
}
}
ARENA = {
[1] = {
name = 'Greenhorn',
price = 1000,
questLog = 1016,
creatures = {
[1] = 'frostfur',
[2] = 'bloodpaw',
[3] = 'bovinus',
[4] = 'achad',
[5] = 'colerian the barbarian',
[6] = 'the hairy one',
[7] = 'axeitus headbanger',
[8] = 'rocky',
[9] = 'cursed gladiator',
[10] = 'orcus the cruel'
},
reward = {
storage = 1010,
trophy = 5807,
trophyStorage = 1013,
desc = 'A brave warrior that finished the Greenhorn mode. Awarded to %s.'
}
},
[2] = {
name = 'Scrapper',
price = 5000,
questLog = 1017,
creatures = {
[1] = 'avalanche',
[2] = 'kreebosh the exile',
[3] = 'the dark dancer',
[4] = 'the hag',
[5] = 'slim',
[6] = 'grimgor guteater',
[7] = 'drasilla',
[8] = 'spirit of earth',
[9] = 'spirit of water',
[10] = 'spirit of fire'
},
reward = {
storage = 1011,
trophy = 5806,
trophyStorage = 1014,
desc = 'A brave warrior that finished the Scrapper mode. Awarded to %s.'
}
},
[3] = {
name = 'Warlord',
price = 10000,
questLog = 1018,
creatures = {
[1] = 'webster',
[2] = 'darakan the executioner',
[3] = 'norgle glacierbeard',
[4] = 'the pit lord',
[5] = 'svoren the mad',
[6] = 'the masked marauder',
[7] = 'gnorre chyllson',
[8] = 'fallen mooh\'tah master ghar',
[9] = 'deathbringer',
[10] = 'the obliverator'
},
reward = {
storage = 1012,
trophy = 5805,
trophyStorage = 1015,
desc = 'A brave warrior that finished the Warlord mode. Awarded to %s.'
}
}
}
function SvargrondArena.getActionIdByArena(arenaId)
if arenaId == 1 then
return SvargrondArena.actionGreenhorn
elseif arenaId == 2 then
return SvargrondArena.actionScrapper
elseif arenaId == 3 then
return SvargrondArena.actionWarlord
else
print('SvargronArena::getActionIdByArena invalid arenaId')
end
end
function SvargrondArena.getPitCreatures(pitId)
if not PITS[pitId] then
return {}
end
local ret = {}
local specs = Game.getSpectators(PITS[pitId].center, false, false, 5, 5, 5, 5)
for i = 1, #specs do
ret[#ret + 1] = specs
end
return ret
end
function SvargrondArena.resetPit(pitId)
if not PITS[pitId] then
return
end
local tile
for x = PITS[pitId].fromPos.x, PITS[pitId].toPos.x do
for y = PITS[pitId].fromPos.y, PITS[pitId].toPos.y do
for z = PITS[pitId].fromPos.z, PITS[pitId].toPos.z do
tile = Tile({x=x, y=y, z=z})
if tile then
local moveableItem = tile:getThing(STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE)
if moveableItem and moveableItem:isItem() then
local itemType = ItemType(moveableItem:getId())
if itemType and itemType:isMovable() and not isInArray(SvargrondArena.itemsNotErasable, moveableItem:getId()) then
moveableItem:remove()
end
end
local creature = tile:getTopCreature()
if creature and creature:isMonster() then
creature:remove()
end
end
end
end
end
local pillarTile = Tile(PITS[pitId].pillar)
if pillarTile then
local teleportItem = pillarTile:getItemById(SvargrondArena.itemTeleport)
if teleportItem then
teleportItem:remove()
end
local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
if not pillarItem then
Game.createItem(SvargrondArena.itemPillar, 1, PITS[pitId].pillar)
end
end
end
function SvargrondArena.getPitOccupant(pitId, ignorePlayer)
local creatures = SvargrondArena.getPitCreatures(pitId)
for i = 1, #creatures do
if creatures:isPlayer() and creatures:getId() ~= ignorePlayer:getId() then
return creatures
end
end
return nil
end
function SvargrondArena.kickPlayer(cid, hideMessage)
SvargrondArena.cancelEvents(cid)
local player = Player(cid)
if not player then
return
end
if player:getStorageValue(1009) > 0 then
player:teleportTo(SvargrondArena.kickPosition)
SvargrondArena.kickPosition:sendMagicEffect(CONST_ME_TELEPORT)
player:setStorageValue(1009, 0)
if not hideMessage then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'Your time ran out!')
end
end
end
function SvargrondArena.cancelEvents(cid)
local kickEvent = SvargrondArena.kickEvents[cid]
if kickEvent then
SvargrondArena.removeTimer(kickEvent.pitId)
stopEvent(kickEvent.eventId)
end
SvargrondArena.kickEvents[cid] = nil
end
function SvargrondArena.scheduleKickPlayer(cid, pitId)
SvargrondArena.cancelEvents(cid)
SvargrondArena.startTimer(pitId)
local eventId = addEvent(SvargrondArena.kickPlayer, SvargrondArena.kickTime * 1000, cid)
SvargrondArena.kickEvents[cid] = {eventId = eventId, pitId = pitId}
end
function SvargrondArena.startTimer(pitId)
local tile = Tile(PITS[pitId].fromPos)
if not tile then
return
end
local timerItem = tile:getItemById(SvargrondArena.itemTimer)
if timerItem then
timerItem:remove()
end
timerItem = Game.createItem(SvargrondArena.itemTimer, 1, PITS[pitId].fromPos)
if timerItem then
timerItem:decay()
end
if SvargrondArena.timerEvents[pitId] then
stopEvent(SvargrondArena.timerEvents[pitId])
end
SvargrondArena.timerEvents[pitId] = addEvent(SvargrondArena.removeTimer, SvargrondArena.kickTime * 1000, pitId)
end
function SvargrondArena.removeTimer(pitId)
local tile = Tile(PITS[pitId].fromPos)
if not tile then
return
end
local timerItem = tile:getItemById(SvargrondArena.itemTimer)
if timerItem then
timerItem:remove()
end
SvargrondArena.timerEvents[pitId] = nil
end
function SvargrondArena.sendPillarEffect(pitId)
local positions = SvargrondArena.effectPositionCache[pitId]
if not positions then
local position = PITS[pitId].pillar
local effectPositions = {
Position(position.x - 1, position.y, position.z),
Position(position.x + 1, position.y, position.z),
Position(position.x + 1, position.y - 1, position.z),
Position(position.x + 1, position.y + 1, position.z),
Position(position.x, position.y, position.z)
}
SvargrondArena.effectPositionCache[pitId] = effectPositions
positions = effectPositions
end
for i = 1, #positions do
positions:sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
end
-- action ids have to be equal to action id of reward doors
actionGreenhorn = 31078,
actionScrapper = 31079,
actionWarlord = 31080,
-- kick time in seconds (10 minutes)
kickTime = 600,
kickPosition = Position(32251, 31098, 6),
rewardPosition = Position(32222, 31080, 6),
-- used to store event ids
kickEvents = {},
timerEvents = {},
effectPositionCache = {},
-- item ids used by the script
itemTimer = 7473,
itemPillar = 1354,
itemTeleport = 5023,
itemsNotErasable = {7473, 1354, 1543, 1544, 1545},
}
-- Script automatically derives other pit positions from this one
local firstPit = {
fromPos = {x = 32205, y = 31094, z = 7},
toPos = {x = 32214, y = 31103, z = 7},
center = {x = 32210, y = 31098, z = 7},
pillar = {x = 32204, y = 31098, z = 7},
tp = {x = 32204, y = 31098, z = 7},
summon = {x = 32210, y = 31100, z = 7}
}
PITS = {
[1] = {
fromPos = firstPit.fromPos,
toPos = firstPit.toPos,
center = firstPit.center,
pillar = firstPit.pillar,
tp = firstPit.tp,
summon = firstPit.summon
},
[2] = {
fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 14, y = firstPit.center.y, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y, z = firstPit.summon.z}
},
[3] = {
fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 28, y = firstPit.center.y, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y, z = firstPit.summon.z}
},
[4] = {
fromPos = {x = firstPit.fromPos.x - 42, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 42, y = firstPit.toPos.y, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 42, y = firstPit.center.y, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 42, y = firstPit.pillar.y, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 42, y = firstPit.tp.y, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 42, y = firstPit.summon.y, z = firstPit.summon.z}
},
[5] = {
fromPos = {x = firstPit.fromPos.x - 35, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 35, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 35, y = firstPit.center.y - 14, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 35, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 35, y = firstPit.tp.y - 14, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 35, y = firstPit.summon.y - 14, z = firstPit.summon.z}
},
[6] = {
fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 21, y = firstPit.center.y - 14, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 14, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 14, z = firstPit.summon.z}
},
[7] = {
fromPos = {x = firstPit.fromPos.x - 7, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 7, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 7, y = firstPit.center.y - 14, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 7, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 7, y = firstPit.tp.y - 14, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 7, y = firstPit.summon.y - 14, z = firstPit.summon.z}
},
[8] = {
fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 14, y = firstPit.center.y - 28, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y - 28, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y - 28, z = firstPit.summon.z}
},
[9] = {
fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 28, y = firstPit.center.y - 28, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y - 28, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y - 28, z = firstPit.summon.z}
},
[10] = {
fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 42, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 42, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 21, y = firstPit.center.y - 41, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 41, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 41, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 41, z = firstPit.summon.z}
}
}
ARENA = {
[1] = {
name = 'Greenhorn',
price = 1000,
questLog = 1016,
creatures = {
[1] = 'frostfur',
[2] = 'bloodpaw',
[3] = 'bovinus',
[4] = 'achad',
[5] = 'colerian the barbarian',
[6] = 'the hairy one',
[7] = 'axeitus headbanger',
[8] = 'rocky',
[9] = 'cursed gladiator',
[10] = 'orcus the cruel'
},
reward = {
storage = 1010,
trophy = 5807,
trophyStorage = 1013,
desc = 'A brave warrior that finished the Greenhorn mode. Awarded to %s.'
}
},
[2] = {
name = 'Scrapper',
price = 5000,
questLog = 1017,
creatures = {
[1] = 'avalanche',
[2] = 'kreebosh the exile',
[3] = 'the dark dancer',
[4] = 'the hag',
[5] = 'slim',
[6] = 'grimgor guteater',
[7] = 'drasilla',
[8] = 'spirit of earth',
[9] = 'spirit of water',
[10] = 'spirit of fire'
},
reward = {
storage = 1011,
trophy = 5806,
trophyStorage = 1014,
desc = 'A brave warrior that finished the Scrapper mode. Awarded to %s.'
}
},
[3] = {
name = 'Warlord',
price = 10000,
questLog = 1018,
creatures = {
[1] = 'webster',
[2] = 'darakan the executioner',
[3] = 'norgle glacierbeard',
[4] = 'the pit lord',
[5] = 'svoren the mad',
[6] = 'the masked marauder',
[7] = 'gnorre chyllson',
[8] = 'fallen mooh\'tah master ghar',
[9] = 'deathbringer',
[10] = 'the obliverator'
},
reward = {
storage = 1012,
trophy = 5805,
trophyStorage = 1015,
desc = 'A brave warrior that finished the Warlord mode. Awarded to %s.'
}
}
}
function SvargrondArena.getActionIdByArena(arenaId)
if arenaId == 1 then
return SvargrondArena.actionGreenhorn
elseif arenaId == 2 then
return SvargrondArena.actionScrapper
elseif arenaId == 3 then
return SvargrondArena.actionWarlord
else
print('SvargronArena::getActionIdByArena invalid arenaId')
end
end
function SvargrondArena.getPitCreatures(pitId)
if not PITS[pitId] then
return {}
end
local ret = {}
local specs = Game.getSpectators(PITS[pitId].center, false, false, 5, 5, 5, 5)
for i = 1, #specs do
ret[#ret + 1] = specs
end
return ret
end
function SvargrondArena.resetPit(pitId)
if not PITS[pitId] then
return
end
local tile
for x = PITS[pitId].fromPos.x, PITS[pitId].toPos.x do
for y = PITS[pitId].fromPos.y, PITS[pitId].toPos.y do
for z = PITS[pitId].fromPos.z, PITS[pitId].toPos.z do
tile = Tile({x=x, y=y, z=z})
if tile then
local moveableItem = tile:getThing(STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE)
if moveableItem and moveableItem:isItem() then
local itemType = ItemType(moveableItem:getId())
if itemType and itemType:isMovable() and not isInArray(SvargrondArena.itemsNotErasable, moveableItem:getId()) then
moveableItem:remove()
end
end
local creature = tile:getTopCreature()
if creature and creature:isMonster() then
creature:remove()
end
end
end
end
end
local pillarTile = Tile(PITS[pitId].pillar)
if pillarTile then
local teleportItem = pillarTile:getItemById(SvargrondArena.itemTeleport)
if teleportItem then
teleportItem:remove()
end
local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
if not pillarItem then
Game.createItem(SvargrondArena.itemPillar, 1, PITS[pitId].pillar)
end
end
end
function SvargrondArena.getPitOccupant(pitId, ignorePlayer)
local creatures = SvargrondArena.getPitCreatures(pitId)
for i = 1, #creatures do
if creatures:isPlayer() and creatures:getId() ~= ignorePlayer:getId() then
return creatures
end
end
return nil
end
function SvargrondArena.kickPlayer(cid, hideMessage)
SvargrondArena.cancelEvents(cid)
local player = Player(cid)
if not player then
return
end
if player:getStorageValue(1009) > 0 then
player:teleportTo(SvargrondArena.kickPosition)
SvargrondArena.kickPosition:sendMagicEffect(CONST_ME_TELEPORT)
player:setStorageValue(1009, 0)
if not hideMessage then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'Your time ran out!')
end
end
end
function SvargrondArena.cancelEvents(cid)
local kickEvent = SvargrondArena.kickEvents[cid]
if kickEvent then
SvargrondArena.removeTimer(kickEvent.pitId)
stopEvent(kickEvent.eventId)
end
SvargrondArena.kickEvents[cid] = nil
end
function SvargrondArena.scheduleKickPlayer(cid, pitId)
SvargrondArena.cancelEvents(cid)
SvargrondArena.startTimer(pitId)
local eventId = addEvent(SvargrondArena.kickPlayer, SvargrondArena.kickTime * 1000, cid)
SvargrondArena.kickEvents[cid] = {eventId = eventId, pitId = pitId}
end
function SvargrondArena.startTimer(pitId)
local tile = Tile(PITS[pitId].fromPos)
if not tile then
return
end
local timerItem = tile:getItemById(SvargrondArena.itemTimer)
if timerItem then
timerItem:remove()
end
timerItem = Game.createItem(SvargrondArena.itemTimer, 1, PITS[pitId].fromPos)
if timerItem then
timerItem:decay()
end
if SvargrondArena.timerEvents[pitId] then
stopEvent(SvargrondArena.timerEvents[pitId])
end
SvargrondArena.timerEvents[pitId] = addEvent(SvargrondArena.removeTimer, SvargrondArena.kickTime * 1000, pitId)
end
function SvargrondArena.removeTimer(pitId)
local tile = Tile(PITS[pitId].fromPos)
if not tile then
return
end
local timerItem = tile:getItemById(SvargrondArena.itemTimer)
if timerItem then
timerItem:remove()
end
SvargrondArena.timerEvents[pitId] = nil
end
function SvargrondArena.sendPillarEffect(pitId)
local positions = SvargrondArena.effectPositionCache[pitId]
if not positions then
local position = PITS[pitId].pillar
local effectPositions = {
Position(position.x - 1, position.y, position.z),
Position(position.x + 1, position.y, position.z),
Position(position.x + 1, position.y - 1, position.z),
Position(position.x + 1, position.y + 1, position.z),
Position(position.x, position.y, position.z)
}
SvargrondArena.effectPositionCache[pitId] = effectPositions
positions = effectPositions
end
for i = 1, #positions do
positions:sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
end
data\movements\movements.xml
<!-- Svargrond Arena Quest -->
<movevent event="StepIn" actionid="30006" script="svargrondArenaQuest/arenaEnter.lua"/>
<movevent event="StepIn" actionid="30007" script="svargrondArenaQuest/arenaPit.lua"/>
<movevent event="StepIn" actionid="30008" script="svargrondArenaQuest/arenaPit.lua"/>
<movevent event="StepIn" fromuid="31075" touid="31077" script="svargrondArenaQuest/arenaTrophy.lua"/>
data\movements\scripts\svargrondArenaQuest
-- Inicjalizacja zmiennej SvargrondArena
SvargrondArena = SvargrondArena or {}
-- Załadowanie pliku z definicjami areny
dofile('data/lib/svargrondArenaQuest.lua')
-- Sprawdzanie, czy plik został załadowany poprawnie
print("SvargrondArena loaded:", SvargrondArena)
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
local pitId = player:getStorageValue(1009)
if pitId < 1 or pitId > 10 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You cannot enter without Halvar\'s permission.')
player:teleportTo(fromPosition)
return true
end
if not SvargrondArena then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'Arena system is not properly configured.')
player:teleportTo(fromPosition)
return true
end
local arenaId = player:getStorageValue(1008)
if not (PITS[pitId] and ARENA[arenaId]) then
player:teleportTo(fromPosition)
return true
end
local occupant = SvargrondArena.getPitOccupant(pitId, player)
if occupant then
player:sendTextMessage(MESSAGE_INFO_DESCR, occupant:getName() .. ' is currently in the next arena pit. Please wait until ' .. (occupant:getSex() == 0 and 's' or '') .. 'he is done fighting.')
player:teleportTo(fromPosition)
return true
end
SvargrondArena.resetPit(pitId)
SvargrondArena.scheduleKickPlayer(player.uid, pitId)
Game.createMonster(ARENA[arenaId].creatures[pitId], PITS[pitId].summon, false, true)
player:teleportTo(PITS[pitId].center)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
player:say('FIGHT!', TALKTYPE_MONSTER_SAY)
return true
end
SvargrondArena = SvargrondArena or {}
-- Załadowanie pliku z definicjami areny
dofile('data/lib/svargrondArenaQuest.lua')
-- Sprawdzanie, czy plik został załadowany poprawnie
print("SvargrondArena loaded:", SvargrondArena)
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
local pitId = player:getStorageValue(1009)
if pitId < 1 or pitId > 10 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You cannot enter without Halvar\'s permission.')
player:teleportTo(fromPosition)
return true
end
if not SvargrondArena then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'Arena system is not properly configured.')
player:teleportTo(fromPosition)
return true
end
local arenaId = player:getStorageValue(1008)
if not (PITS[pitId] and ARENA[arenaId]) then
player:teleportTo(fromPosition)
return true
end
local occupant = SvargrondArena.getPitOccupant(pitId, player)
if occupant then
player:sendTextMessage(MESSAGE_INFO_DESCR, occupant:getName() .. ' is currently in the next arena pit. Please wait until ' .. (occupant:getSex() == 0 and 's' or '') .. 'he is done fighting.')
player:teleportTo(fromPosition)
return true
end
SvargrondArena.resetPit(pitId)
SvargrondArena.scheduleKickPlayer(player.uid, pitId)
Game.createMonster(ARENA[arenaId].creatures[pitId], PITS[pitId].summon, false, true)
player:teleportTo(PITS[pitId].center)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
player:say('FIGHT!', TALKTYPE_MONSTER_SAY)
return true
end
dofile('data/lib/svargrondArenaQuest.lua')
local condition = Condition(CONDITION_OUTFIT, CONDITIONID_COMBAT)
condition:setTicks(120000)
condition:setOutfit({lookType = 111})
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
if item.actionid == 30008 then
player:addCondition(condition)
SvargrondArena.cancelEvents(player.uid)
player:setStorageValue(1009, 0)
player:teleportTo(SvargrondArena.kickPosition)
player:say('Coward!', TALKTYPE_MONSTER_SAY)
return true
end
local pitId = player:getStorageValue(1009)
local arenaId = player:getStorageValue(1008)
if pitId > 10 then
player:teleportTo(SvargrondArena.rewardPosition)
player:getPosition():sendMagicEffect(arenaId == 1 and CONST_ME_FIREWORK_BLUE or arenaId == 2 and CONST_ME_FIREWORK_YELLOW or CONST_ME_FIREWORK_RED)
player:setStorageValue(1009, 0)
player:setStorageValue(SvargrondArena.getActionIdByArena(arenaId), 1)
player:setStorageValue(1008, player:getStorageValue(1008) + 1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You completed ' .. ARENA[arenaId].name .. ' arena, you should take your reward now.')
player:say(arenaId == 1 and 'Welcome back, little hero!' or arenaId == 2 and 'Congratulations, brave warrior!' or 'Respect and honour to you, champion!', TALKTYPE_MONSTER_SAY)
player:setStorageValue(ARENA[arenaId].questLog, 2)
SvargrondArena.cancelEvents(player.uid)
return true
end
local occupant = SvargrondArena.getPitOccupant(pitId, player)
if occupant then
player:sendTextMessage(MESSAGE_INFO_DESCR, occupant:getName() .. ' is currently in the next arena pit. Please wait until ' .. (occupant:getSex() == 0 and 's' or '') .. 'he is done fighting.')
player:teleportTo(fromPosition)
return true
end
SvargrondArena.cancelEvents(player.uid)
SvargrondArena.resetPit(pitId)
SvargrondArena.scheduleKickPlayer(player.uid, pitId)
Game.createMonster(ARENA[arenaId].creatures[pitId], PITS[pitId].summon, false, true)
player:teleportTo(PITS[pitId].center)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
player:say('Fight!', TALKTYPE_MONSTER_SAY)
return true
end
local condition = Condition(CONDITION_OUTFIT, CONDITIONID_COMBAT)
condition:setTicks(120000)
condition:setOutfit({lookType = 111})
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
if item.actionid == 30008 then
player:addCondition(condition)
SvargrondArena.cancelEvents(player.uid)
player:setStorageValue(1009, 0)
player:teleportTo(SvargrondArena.kickPosition)
player:say('Coward!', TALKTYPE_MONSTER_SAY)
return true
end
local pitId = player:getStorageValue(1009)
local arenaId = player:getStorageValue(1008)
if pitId > 10 then
player:teleportTo(SvargrondArena.rewardPosition)
player:getPosition():sendMagicEffect(arenaId == 1 and CONST_ME_FIREWORK_BLUE or arenaId == 2 and CONST_ME_FIREWORK_YELLOW or CONST_ME_FIREWORK_RED)
player:setStorageValue(1009, 0)
player:setStorageValue(SvargrondArena.getActionIdByArena(arenaId), 1)
player:setStorageValue(1008, player:getStorageValue(1008) + 1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You completed ' .. ARENA[arenaId].name .. ' arena, you should take your reward now.')
player:say(arenaId == 1 and 'Welcome back, little hero!' or arenaId == 2 and 'Congratulations, brave warrior!' or 'Respect and honour to you, champion!', TALKTYPE_MONSTER_SAY)
player:setStorageValue(ARENA[arenaId].questLog, 2)
SvargrondArena.cancelEvents(player.uid)
return true
end
local occupant = SvargrondArena.getPitOccupant(pitId, player)
if occupant then
player:sendTextMessage(MESSAGE_INFO_DESCR, occupant:getName() .. ' is currently in the next arena pit. Please wait until ' .. (occupant:getSex() == 0 and 's' or '') .. 'he is done fighting.')
player:teleportTo(fromPosition)
return true
end
SvargrondArena.cancelEvents(player.uid)
SvargrondArena.resetPit(pitId)
SvargrondArena.scheduleKickPlayer(player.uid, pitId)
Game.createMonster(ARENA[arenaId].creatures[pitId], PITS[pitId].summon, false, true)
player:teleportTo(PITS[pitId].center)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
player:say('Fight!', TALKTYPE_MONSTER_SAY)
return true
end
dofile('data/lib/svargrondArenaQuest.lua')
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
local arenaId = player:getStorageValue(1008) - 1
if player:getStorageValue(ARENA[arenaId].reward.trophyStorage) ~= 1 then
local rewardPosition = player:getPosition()
rewardPosition.y = rewardPosition.y - 1
local rewardItem = Game.createItem(ARENA[arenaId].reward.trophy, 1, rewardPosition)
if rewardItem then
rewardItem:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, string.format(ARENA[arenaId].reward.desc, player:getName()))
end
player:setStorageValue(ARENA[arenaId].reward.trophyStorage, 1)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
end
item:transform(425)
return true
end
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
local arenaId = player:getStorageValue(1008) - 1
if player:getStorageValue(ARENA[arenaId].reward.trophyStorage) ~= 1 then
local rewardPosition = player:getPosition()
rewardPosition.y = rewardPosition.y - 1
local rewardItem = Game.createItem(ARENA[arenaId].reward.trophy, 1, rewardPosition)
if rewardItem then
rewardItem:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, string.format(ARENA[arenaId].reward.desc, player:getName()))
end
player:setStorageValue(ARENA[arenaId].reward.trophyStorage, 1)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
end
item:transform(425)
return true
end
Post automatically merged:
Halvar
Attachments
-
Halvar.lua5.5 KB · Views: 5 · VirusTotal
-
arenaDoor.lua1.9 KB · Views: 2 · VirusTotal
-
svargrondArenaQuest.lua12 KB · Views: 2 · VirusTotal
-
arenaPit.lua2.2 KB · Views: 3 · VirusTotal
-
arenaEnter.lua1.8 KB · Views: 5 · VirusTotal
Last edited: