Skip to content

Commit

Permalink
Update actions_ragiaz.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
htc16 committed Oct 23, 2024
1 parent 64ff86d commit 2e48c05
Showing 1 changed file with 40 additions and 112 deletions.
Original file line number Diff line number Diff line change
@@ -1,130 +1,58 @@
local config = {
boss = {
name = "Ragiaz",
position = Position(33481, 32334, 13),
},

timeToDefeat = 17 * 60, -- 17 minutes in seconds
playerPositions = {
{ pos = Position(33456, 32356, 13), teleport = Position(33482, 32339, 13), effect = CONST_ME_TELEPORT },
{ pos = Position(33457, 32356, 13), teleport = Position(33482, 32339, 13), effect = CONST_ME_TELEPORT },
{ pos = Position(33458, 32356, 13), teleport = Position(33482, 32339, 13), effect = CONST_ME_TELEPORT },
{ pos = Position(33459, 32356, 13), teleport = Position(33482, 32339, 13), effect = CONST_ME_TELEPORT },
{ pos = Position(33460, 32356, 13), teleport = Position(33482, 32339, 13), effect = CONST_ME_TELEPORT },
},
monsters = {
{ name = "Death Dragon", pos = Position(33476, 32331, 13) },
{ name = "Death Dragon", pos = Position(33476, 32340, 13) },
{ name = "Death Dragon", pos = Position(33487, 32340, 13) },
{ name = "Death Dragon", pos = Position(33488, 32331, 13) },
},
specPos = {
from = Position(33468, 32319, 13),
to = Position(33495, 32347, 13),
},
exit = Position(33319, 32318, 13),
centerRoom = Position(33481, 32334, 13),
BossPosition = Position(33481, 32334, 13),
newPosition = Position(33482, 32339, 13),
deathDragons = {
Position(33476, 32331, 13),
Position(33476, 32340, 13),
Position(33487, 32340, 13),
Position(33488, 32331, 13)
}
}

local leverRagiaz = Action()

function leverRagiaz.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local players = {}
local spectators = Game.getSpectators(config.specPos.from, false, false, 0, 0, 0, 0, config.specPos.to)

for i = 1, #config.playerPositions do
local pos = config.playerPositions[i].pos
local creature = Tile(pos):getTopCreature()

if not creature or not creature:isPlayer() then
player:sendCancelMessage("You need " .. #config.playerPositions .. " players to challenge " .. config.boss.name .. ".")
return true
end

local cooldownTime = creature:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.RagiazTime)
if cooldownTime > os.time() then
local remainingTime = cooldownTime - os.time()
local hours = math.floor(remainingTime / 3600)
local minutes = math.floor((remainingTime % 3600) / 60)
player:sendCancelMessage(creature:getName() .. " must wait " .. hours .. " hours and " .. minutes .. " minutes to challenge again.")
return true
end

if creature:getLevel() < config.requiredLevel then
player:sendCancelMessage(creature:getName() .. " needs to be at least level " .. config.requiredLevel .. " to challenge " .. config.boss.name .. ".")
return true
end

table.insert(players, creature)
end

for _, spec in pairs(spectators) do
if spec:isPlayer() then
player:say("Someone is already inside the room.", TALKTYPE_MONSTER_SAY)
if item.itemid == 8911 then
if player:getPosition() ~= Position(33456, 32356, 13) then
item:transform(8912)
return true
end
end

if isBossInRoom(config.specPos.from, config.specPos.to, config.boss.name) then
player:say("The room is being cleared. Please wait a moment.", TALKTYPE_MONSTER_SAY)
return true
end

for i = 1, #players do
local playerToTeleport = players[i]
local teleportPos = config.playerPositions[i].teleport
local effect = config.playerPositions[i].effect
playerToTeleport:teleportTo(teleportPos)
teleportPos:sendMagicEffect(effect)
end

Game.createMonster(config.boss.name, config.boss.position)

for i = 1, #config.monsters do
local monsterConfig = config.monsters[i]
Game.createMonster(monsterConfig.name, monsterConfig.pos, true, true)
end

addEvent(clearBossRoom, config.timeToDefeat * 1000, config.specPos.from, config.specPos.to, config.exit)

if item.itemid == 8911 then
item:transform(8912)
else
item:transform(8911)
end

return true
end

function clearBossRoom(fromPos, toPos, exitPos)
local spectators = Game.getSpectators(fromPos, false, false, 0, 0, 0, 0, toPos)
for _, spec in pairs(spectators) do
if spec:isPlayer() then
spec:teleportTo(exitPos)
exitPos:sendMagicEffect(CONST_ME_TELEPORT)
spec:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You took too long, the battle has ended.")
else
spec:remove()
end
end
end

function isBossInRoom(fromPos, toPos, bossName)
local monstersRemoved = false
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
for z = fromPos.z, toPos.z do
local tile = Tile(Position(x, y, z))
if tile then
local creature = tile:getTopCreature()
if creature and creature:isMonster() then
creature:remove()
monstersRemoved = true
end
local playersTable = {}
if player:doCheckBossRoom("Ragiaz", Position(33472, 32323, 13), Position(33493, 32347, 13)) then
local specs, spec = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15)
for i = 1, #specs do
spec = specs[i]
if spec:isPlayer() then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting with Ragiaz.")
return true
end
end
Game.createMonster("Ragiaz", config.BossPosition, true, true)
for d = 1, #config.deathDragons do
Game.createMonster('Death Dragon', config.deathDragons[d], true, true)
end
for x = 33456, 33460 do
local playerTile = Tile(Position(x, 32356, 13)):getTopCreature()
if playerTile and playerTile:isPlayer() then
playerTile:getPosition():sendMagicEffect(CONST_ME_POFF)
playerTile:teleportTo(config.newPosition)
playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
playerTile:setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.RagiazTimer, os.time() + 60 * 60 * 2 * 24)
table.insert(playersTable, playerTile:getId())
end
end
addEvent(kickPlayersAfterTime, 30 * 60 * 1000, playersTable, Position(33472, 32323, 13), Position(33493, 32347, 13), Position(33319, 32318, 13))
item:transform(8912)
end
elseif item.itemid == 8912 then
item:transform(8911)
end
return monstersRemoved

return true
end

leverRagiaz:uid(1023)
Expand Down

0 comments on commit 2e48c05

Please sign in to comment.