Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Fix: resolves #1579, #1531 #1582

Merged
merged 6 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 41 additions & 48 deletions data/actions/scripts/farmine/oberon_lever.lua
Original file line number Diff line number Diff line change
@@ -1,60 +1,53 @@
local setting = {
timeToFightAgain = 20,
clearRoomTime = 60, -- In hour
centerRoom = {x = 33364, y = 31318, z = 9},
range = 10,
storage = Storage.TheSecretLibrary.TheOrderOfTheFalcon.OberonTimer,
clearRoomStorage = GlobalStorage.OberonEventTime,
bossName = "grand master oberon",
bossPosition = {x = 33364, y = 31317, z = 9}
Pillar1pos = {x = 33361, y = 31316, z = 9},
bossPosition = {x = 33364, y = 31317, z = 9},
kickPosition = {x = 33300, y = 31289, z = 9},
playerTeleport = {x = 33364, y = 31322, z = 9}
}

local playerPositions = {
{fromPos = {x = 33364, y = 31344, z = 9}, toPos = {x = 33364, y = 31321, z = 9}},
{fromPos = {x = 33363, y = 31344, z = 9}, toPos = {x = 33363, y = 31321, z = 9}},
{fromPos = {x = 33365, y = 31344, z = 9}, toPos = {x = 33365, y = 31321, z = 9}},
{fromPos = {x = 33362, y = 31344, z = 9}, toPos = {x = 33362, y = 31321, z = 9}},
{fromPos = {x = 33366, y = 31344, z = 9}, toPos = {x = 33366, y = 31321, z = 9}}
}

-- Start Script
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
function onUse(creature, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 1945 and item.actionid == 57605 then
for i = 1, #playerPositions do
local creature = Tile(playerPositions[i].fromPos):getTopCreature()
if not creature then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need 5 players to fight with this boss.")
return true
end
local clearOberonRoom = Game.getSpectators(Position(setting.centerRoom), false, false, 10, 10, 10, 10)
for index, spectatorcheckface in ipairs(clearOberonRoom) do
if spectatorcheckface:isPlayer() then
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting against the boss! You need wait awhile.")
return false
end

if roomIsOccupied(setting.centerRoom, setting.range, setting.range)
or Game.getStorageValue(setting.clearRoomStorage) == 1 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting against the boss! You need wait awhile.")
return true
end
for index, removeOberon in ipairs(clearOberonRoom) do
if (removeOberon:isMonster()) then
removeOberon:remove()
end

for i = 1, #playerPositions do
local creature = Tile(playerPositions[i].fromPos):getTopCreature()
if creature and creature:isPlayer() then
if not creature:getStorageValue(setting.storage) >= os.time() then
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have faced this boss in the last " .. setting.timeToFightAgain .. " hours.")
return true
end
if creature:getStorageValue(setting.storage) < os.time() then
creature:setStorageValue(setting.storage, os.time() + setting.timeToFightAgain * 60 * 60)
creature:teleportTo(playerPositions[i].toPos)
creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
end
else
return false
end
end
Game.createMonster("Grand Master Oberon", setting.bossPosition, false, true)
Game.createMonster("Oberon's Bile", Position({x = setting.Pillar1pos.x, y = setting.Pillar1pos.y, z = setting.Pillar1pos.z}), false, true)
Game.createMonster("Oberon's Hate", Position({x = setting.Pillar1pos.x + 6, y = setting.Pillar1pos.y, z = setting.Pillar1pos.z}), false, true)
Game.createMonster("Oberon's Spite", Position({x = setting.Pillar1pos.x, y = setting.Pillar1pos.y + 4, z = setting.Pillar1pos.z}), false, true)
Game.createMonster("Oberon's Ire", Position({x = setting.Pillar1pos.x + 6, y = setting.Pillar1pos.y + 4, z = setting.Pillar1pos.z}), false, true)
local players = {}
for i = 0, 4 do
local player1 = Tile({x = (Position(item:getPosition()).x - 2) + i, y = Position(item:getPosition()).y + 1, z = Position(item:getPosition()).z}):getTopCreature()
players[#players+1] = player1
end
for i, player in ipairs(players) do
player:getPosition():sendMagicEffect(CONST_ME_POFF)
player:teleportTo(Position(setting.playerTeleport), false)
doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
setPlayerStorageValue(player,setting.storage, os.time() + 20 * 60 * 60)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have 20 minute(s) to defeat the boss.')
addEvent(function()
local spectatorsOberon = Game.getSpectators(Position(setting.centerRoom), false, false, 10, 10, 10, 10)
for i = 1, #spectatorsOberon, 1 do
majestyotbr marked this conversation as resolved.
Show resolved Hide resolved
if spectatorsOberon[i]:isPlayer() and (spectatorsOberon[i]:getName() == player:getName()) then
player:teleportTo(Position(setting.kickPosition))
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Time is over.')
end
end
end, 20 * 60 * 1000)
end
-- One hour for clean the room and other time goto again
addEvent(clearRoom, setting.clearRoomTime * 60 * 1000, setting.centerRoom,
setting.range, setting.range, setting.clearRoomStorage)
Game.createMonster(setting.bossName, setting.bossPosition)
Game.setStorageValue(setting.clearRoomStorage, 1)
end
return true
end
28 changes: 18 additions & 10 deletions data/movements/scripts/teleport/falcon_castle.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
local config = {
[3255] = Position(33349, 31346, 8),
[57602] = Position(33329, 31332, 9),
[57604] = Position(33363, 31342, 9),
[57699] = Position(33308, 31325, 8)
[3255] = {position = Position(33349, 31346, 8)},
[57602] = {position = Position(33329, 31332, 9)},
[57604] = {position = Position(33363, 31342, 9)},
[57699] = {position = Position(33308, 31325, 8)}
}

function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return false
end

local teleport = config[item.actionid]
if teleport then
player:teleportTo(teleport)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
teleport:sendMagicEffect(CONST_ME_TELEPORT)
for index, value in pairs(config) do
if item.actionid == index then
if(item.actionid == 57604)then
if(player:getStorageValue(Storage.TheSecretLibrary.TheOrderOfTheFalcon.OberonTimer) > os.time())then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have faced this boss in the last 20 hours.")
player:teleportTo(fromPosition, true)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return false
end
end
doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
player:teleportTo(value.position)
doSendMagicEffect(value.position, CONST_ME_TELEPORT)
end
end
end