Skip to content

Commit

Permalink
Update actions_razzagorn.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
htc16 committed Oct 23, 2024
1 parent c432996 commit d7d1e7c
Showing 1 changed file with 30 additions and 99 deletions.
Original file line number Diff line number Diff line change
@@ -1,119 +1,50 @@
local config = {
boss = {
name = "Razzagorn",
position = Position(33422, 32467, 14),
},
timeToDefeat = 17 * 60, -- 17 minutes in seconds
playerPositions = {
{ pos = Position(33386, 32455, 14), teleport = Position(33419, 32467, 14), effect = CONST_ME_TELEPORT },
{ pos = Position(33387, 32455, 14), teleport = Position(33419, 32467, 14), effect = CONST_ME_TELEPORT },
{ pos = Position(33388, 32455, 14), teleport = Position(33419, 32467, 14), effect = CONST_ME_TELEPORT },
{ pos = Position(33389, 32455, 14), teleport = Position(33419, 32467, 14), effect = CONST_ME_TELEPORT },
{ pos = Position(33390, 32455, 14), teleport = Position(33419, 32467, 14), effect = CONST_ME_TELEPORT },
},
specPos = {
from = Position(33407, 32453, 14),
to = Position(33439, 32481, 14),
},
exit = Position(33319, 32318, 13),
centerRoom = Position(33422, 32467, 14),
BossPosition = Position(33422, 32467, 14),
newPosition = Position(33419, 32467, 14)
}

local leverRazzagorn = Action()

function leverRazzagorn.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 .. ".")
if item.itemid == 8911 then
if player:getPosition() ~= Position(33386, 32455, 14) then
item:transform(8912)
return true
end

local cooldownTime = creature:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.RazzagornTime)
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.")
end
if item.itemid == 8911 then
if Game.getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.RazzagornTimer) >= 1 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait a while, recently someone challenge Razzagorn.")
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
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 Razzagorn.")
return true
end
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)
return true
Game.createMonster("Razzagorn", config.BossPosition, true, true)
for x = 33386, 33390 do
local playerTile = Tile(Position(x, 32455, 14)):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.RazzagornTimer, os.time() + 60 * 60 * 2 * 24)
end
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)

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

if item.itemid == 8911 then
Game.setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.RazzagornTimer, 1)
addEvent(clearForgotten, 30 * 60 * 1000, Position(33408, 32454, 14), Position(33440, 32480, 14), Position(33319, 32318, 13), Storage.Quest.U10_90.FerumbrasAscension.RazzagornTimer)
item:transform(8912)
else
elseif item.itemid == 8912 then
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
end
end
end
end
return monstersRemoved
end

leverRazzagorn:uid(1024)
leverRazzagorn:register()
leverRazzagorn:register()

0 comments on commit d7d1e7c

Please sign in to comment.