From 73bf033738f4e49ec7adb0072a1dcc71ecccc958 Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 18 Feb 2024 16:22:27 -0300 Subject: [PATCH 1/3] fix: urmahlullu lever mechanism (#2256) --- .../3-urmahlullu-the-immaculate.lua | 95 ++++--------------- 1 file changed, 17 insertions(+), 78 deletions(-) diff --git a/data-otservbr-global/scripts/quests/kilmaresh/1-fafnars-wrath/3-urmahlullu-the-immaculate.lua b/data-otservbr-global/scripts/quests/kilmaresh/1-fafnars-wrath/3-urmahlullu-the-immaculate.lua index 8c87d35deff..612363fecaf 100644 --- a/data-otservbr-global/scripts/quests/kilmaresh/1-fafnars-wrath/3-urmahlullu-the-immaculate.lua +++ b/data-otservbr-global/scripts/quests/kilmaresh/1-fafnars-wrath/3-urmahlullu-the-immaculate.lua @@ -1,84 +1,23 @@ --- lever to urmahlullu room - local config = { + boss = { + name = "Urmahlullu the Immaculate", + position = Position(33918, 31641, 8), + }, requiredLevel = 100, - daily = true, - roomCenterPosition = Position(33919, 31648, 8), playerPositions = { - Position(33918, 31626, 8), - Position(33919, 31626, 8), - Position(33920, 31626, 8), - Position(33921, 31626, 8), - Position(33922, 31626, 8), + { pos = Position(33918, 31626, 8), teleport = Position(33918, 31657, 8), effect = CONST_ME_TELEPORT }, + { pos = Position(33919, 31626, 8), teleport = Position(33918, 31657, 8), effect = CONST_ME_TELEPORT }, + { pos = Position(33920, 31626, 8), teleport = Position(33918, 31657, 8), effect = CONST_ME_TELEPORT }, + { pos = Position(33921, 31626, 8), teleport = Position(33918, 31657, 8), effect = CONST_ME_TELEPORT }, + { pos = Position(33922, 31626, 8), teleport = Position(33918, 31657, 8), effect = CONST_ME_TELEPORT }, }, - teleportPosition = Position(33918, 31657, 8), - bossPosition = Position(33918, 31641, 8), - bossName = "Urmahlullu the Immaculate", + specPos = { + from = Position(33905, 31636, 8), + to = Position(33932, 31667, 8), + }, + exit = Position(33919, 31603, 8), } -local leverboss = Action() - -function leverboss.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if item.itemid == 8911 then - -- Check if the player that pulled the lever is on the correct position - if player:getPosition() ~= config.playerPositions[1] then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can't start the battle.") - return true - end - - local team, participant = {} - - for i = 1, #config.playerPositions do - participant = Tile(config.playerPositions[i]):getTopCreature() - - -- Check there is a participant player - if participant and participant:isPlayer() then - -- Check participant level - if participant:getLevel() < config.requiredLevel then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All the players need to be level " .. config.requiredLevel .. " or higher.") - return true - end - - -- Check participant boss timer - if config.daily and not participant:canFightBoss(config.bossName) then - player:getPosition():sendMagicEffect(CONST_ME_POFF) - player:sendCancelMessage("Not all players are ready yet from last battle.") - return true - end - - team[#team + 1] = participant - end - end - - -- Check if a team currently inside the boss room - local specs, spec = Game.getSpectators(config.roomCenterPosition, false, false, 14, 14, 13, 13) - for i = 1, #specs do - spec = specs[i] - if spec:isPlayer() then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "A team is already inside the boss room.") - return true - end - - spec:remove() - end - - -- Spawn boss - Game.createMonster("Urmahlullu the Immaculate", config.bossPosition) - - -- Teleport team participants - for i = 1, #team do - team[i]:getPosition():sendMagicEffect(CONST_ME_POFF) - team[i]:teleportTo(config.teleportPosition) - -- Assign boss timer - team[i]:setBossCooldown(config.bossName, os.time() + configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN)) -- 20 hours - end - - config.teleportPosition:sendMagicEffect(CONST_ME_ENERGYAREA) - end - - item:transform(8911) - return true -end - -leverboss:uid(9545) -leverboss:register() +local lever = BossLever(config) +lever:uid(9545) +lever:register() From cb8da9c423908b8a5fa0ae0b39bebfe28281f29a Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 18 Feb 2024 16:22:42 -0300 Subject: [PATCH 2/3] fix: brokul lever mechanism (#2255) --- .../quests/secret_library/brokul_lever.lua | 120 +++--------------- 1 file changed, 20 insertions(+), 100 deletions(-) diff --git a/data-otservbr-global/scripts/actions/quests/secret_library/brokul_lever.lua b/data-otservbr-global/scripts/actions/quests/secret_library/brokul_lever.lua index 2f56fcc086a..2cdded463af 100644 --- a/data-otservbr-global/scripts/actions/quests/secret_library/brokul_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/secret_library/brokul_lever.lua @@ -1,103 +1,23 @@ -bossConfig = { - [34000] = { -- ActionID - requiredLevel = 150, - minPlayersRequired = 1, - - boss = "Brokul", - bossGlobalStorage = 35000, - playerStorage = 36000, - teleportPosition = Position(33483, 31445, 15), - centerRoomPosition = Position(33483, 31439, 15), - northRange = 15, - eastRange = 15, - southRange = 15, - westRange = 15, - exit = Position(33522, 31468, 15), - bossPosition = Position(33483, 31434, 15), - time = 15, - - playerPositions = { - [1] = Position(33520, 31465, 15), - [2] = Position(33521, 31465, 15), - [3] = Position(33522, 31465, 15), - [4] = Position(33523, 31465, 15), - [5] = Position(33524, 31465, 15), - }, +local config = { + boss = { + name = "Brokul", + position = Position(33483, 31434, 15), + }, + requiredLevel = 150, + playerPositions = { + { pos = Position(33522, 31465, 15), teleport = Position(33483, 31445, 15), effect = CONST_ME_TELEPORT }, + { pos = Position(33520, 31465, 15), teleport = Position(33483, 31445, 15), effect = CONST_ME_TELEPORT }, + { pos = Position(33521, 31465, 15), teleport = Position(33483, 31445, 15), effect = CONST_ME_TELEPORT }, + { pos = Position(33523, 31465, 15), teleport = Position(33483, 31445, 15), effect = CONST_ME_TELEPORT }, + { pos = Position(33524, 31465, 15), teleport = Position(33483, 31445, 15), effect = CONST_ME_TELEPORT }, }, + specPos = { + from = Position(33469, 31430, 15), + to = Position(33497, 31453, 15), + }, + exit = Position(33522, 31468, 15), } -local function resetBoss(bossConfig, bossId) - local monster = Monster(bossId) - if monster then - monster:remove() - end - local spectators = Game.getSpectators(bossConfig.centerRoomPosition, false, true, bossConfig.westRange, bossConfig.eastRange, bossConfig.northRange, bossConfig.southRange) - for i = 1, #spectators do - spectators[i]:teleportTo(bossConfig.exit) - end -end - -local secretBrokul = Action() -function secretBrokul.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if item.itemid == 2773 then - local bossConfig = bossConfig[item:getActionId()] - if not bossConfig then - return false - end - - if getGlobalStorageValue(bossConfig.bossGlobalStorage) > 0 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There is already a team inside. Please wait.") - return true - end - - local errorMsg - local rPlayers = {} - for index, ipos in pairs(bossConfig.playerPositions) do - local playerTile = Tile(ipos):getTopCreature() - if playerTile then - if playerTile:isPlayer() then - if playerTile:getLevel() >= bossConfig.requiredLevel then - if playerTile:getStorageValue(bossConfig.playerStorage) <= os.time() then - table.insert(rPlayers, playerTile:getId()) - else - errorMsg = "One or more players have already entered in the last 20 hours." - end - else - errorMsg = "All the players need to be level " .. bossConfig.requiredLevel .. " or higher." - end - end - end - end - - if #rPlayers >= bossConfig.minPlayersRequired then - for _, pid in pairs(rPlayers) do - local rplayer = Player(pid) - if rplayer:isPlayer() then - rplayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, ("You have %o minutes before you get kicked out."):format(bossConfig.time)) - bossConfig.playerPositions[_]:sendMagicEffect(CONST_ME_POFF) - rplayer:teleportTo(bossConfig.teleportPosition) - rplayer:setStorageValue(bossConfig.playerStorage, os.time() + (configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN))) - bossConfig.teleportPosition:sendMagicEffect(CONST_ME_ENERGYAREA) - rplayer:setDirection(DIRECTION_NORTH) - end - end - setGlobalStorageValue(bossConfig.bossGlobalStorage, 1) - addEvent(setGlobalStorageValue, bossConfig.time * 60 * 1000, bossConfig.bossGlobalStorage, 0) - local monster = Game.createMonster(bossConfig.boss, bossConfig.bossPosition) - addEvent(resetBoss, bossConfig.time * 60 * 1000, bossConfig, monster and monster.uid or 0) - else - if not errorMsg then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, ("You need %u players."):format(bossConfig.minPlayersRequired)) - else - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, errorMsg) - end - return true - end - end - item:transform(item.itemid == 2773 and 2772 or 2773) - - return true -end - -secretBrokul:aid(34000) -secretBrokul:register() +local lever = BossLever(config) +lever:aid(34000) +lever:register() From 1c4bea7cf7f518af04c4ffd64f87ad64307073f2 Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 18 Feb 2024 16:26:48 -0300 Subject: [PATCH 3/3] chore: move addon items to core (#2254) --- data-otservbr-global/lib/core/storages.lua | 6 -- .../actions/addons/afflicted_outfit.lua | 65 ----------------- .../items/usable_afflicted_outfit_items.lua | 57 +++++++++++++++ .../actions/items/usable_outfit_items.lua | 71 ++++++++++--------- 4 files changed, 95 insertions(+), 104 deletions(-) delete mode 100644 data-otservbr-global/scripts/actions/addons/afflicted_outfit.lua create mode 100644 data/scripts/actions/items/usable_afflicted_outfit_items.lua rename data-otservbr-global/scripts/actions/addons/addons.lua => data/scripts/actions/items/usable_outfit_items.lua (58%) diff --git a/data-otservbr-global/lib/core/storages.lua b/data-otservbr-global/lib/core/storages.lua index 78d2535646f..4cfc904c716 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -817,11 +817,6 @@ Storage = { -- Until all outfit quests are completed DefaultStart = 50960, Ref = 50961, - Afflicted = { - Outfit = 50962, - AddonPlagueMask = 50963, - AddonPlagueBell = 50964, - }, Citizen = { -- Mission storages for temporary questlog entries MissionHat = 50966, @@ -2414,7 +2409,6 @@ Storage = { TheColoursOfMagic = {}, }, U9_1 = { --update 9.1 - Reserved Storages 43351 - 43550 - AfflictedOutfits = {}, AwashWorldChange = {}, DemonWarsWorldChange = {}, ElementalistOutfits = {}, diff --git a/data-otservbr-global/scripts/actions/addons/afflicted_outfit.lua b/data-otservbr-global/scripts/actions/addons/afflicted_outfit.lua deleted file mode 100644 index 179e981451e..00000000000 --- a/data-otservbr-global/scripts/actions/addons/afflicted_outfit.lua +++ /dev/null @@ -1,65 +0,0 @@ -local afflictedOutfit = Action() - -function afflictedOutfit.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local hasOutfit = player:getStorageValue(Storage.OutfitQuest.Afflicted.Outfit) == 1 - -- Plgue Mask - if item.itemid == 12786 then - if not hasOutfit then - return false - end - - if player:getStorageValue(Storage.OutfitQuest.Afflicted.AddonPlagueMask) == 1 then - return false - end - - player:addOutfitAddon(430, 2) - player:addOutfitAddon(431, 2) - player:getPosition():sendMagicEffect(CONST_ME_POFF) - player:setStorageValue(Storage.OutfitQuest.Afflicted.AddonPlagueMask, 1) - player:say("You gained a plague mask for your outfit.", TALKTYPE_MONSTER_SAY, false, player) - item:remove() - - -- Plague Bell - elseif item.itemid == 12787 then - if not hasOutfit then - return false - end - - if player:getStorageValue(Storage.OutfitQuest.Afflicted.AddonPlagueBell) == 1 then - return false - end - - player:addOutfitAddon(430, 1) - player:addOutfitAddon(431, 1) - player:getPosition():sendMagicEffect(CONST_ME_POFF) - player:setStorageValue(Storage.OutfitQuest.Afflicted.AddonPlagueBell, 1) - player:say("You gained a plague bell for your outfit.", TALKTYPE_MONSTER_SAY, false, player) - item:remove() - - -- Outfit - else - if hasOutfit then - return false - end - - for id = 12551, 12556 do - if player:getItemCount(id) < 1 then - return false - end - end - - for id = 12551, 12556 do - player:removeItem(id, 1) - end - - player:addOutfit(430) - player:addOutfit(431) - player:getPosition():sendMagicEffect(CONST_ME_POFF) - player:setStorageValue(Storage.OutfitQuest.Afflicted.Outfit, 1) - player:say("You have restored an outfit.", TALKTYPE_MONSTER_SAY, false, player) - end - return true -end - -afflictedOutfit:id(12551, 12552, 12553, 12554, 12555, 12556, 12786, 12787) -afflictedOutfit:register() diff --git a/data/scripts/actions/items/usable_afflicted_outfit_items.lua b/data/scripts/actions/items/usable_afflicted_outfit_items.lua new file mode 100644 index 00000000000..30c92194655 --- /dev/null +++ b/data/scripts/actions/items/usable_afflicted_outfit_items.lua @@ -0,0 +1,57 @@ +local usableAfflictedOutfitItems = Action() + +function usableAfflictedOutfitItems.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if not player:isPremium() then + player:sendCancelMessage(RETURNVALUE_YOUNEEDPREMIUMACCOUNT) + return true + end + + local outfitId = player:getSex() == PLAYERSEX_FEMALE and 431 or 430 + if item.itemid == 12786 then + if not player:hasOutfit(outfitId) or player:hasOutfit(outfitId, 2) then + return true + end + + player:addOutfitAddon(430, 2) + player:addOutfitAddon(431, 2) + player:say("You gained a plague mask for your outfit.", TALKTYPE_MONSTER_SAY, false, player) + player:getPosition():sendMagicEffect(CONST_ME_POFF) + player:addAchievementProgress("Beak Doctor", 2) + item:remove() + elseif item.itemid == 12787 then + if not player:hasOutfit(outfitId) or player:hasOutfit(outfitId, 1) then + return true + end + + player:addOutfitAddon(430, 1) + player:addOutfitAddon(431, 1) + player:getPosition():sendMagicEffect(CONST_ME_POFF) + player:say("You gained a plague bell for your outfit.", TALKTYPE_MONSTER_SAY, false, player) + player:addAchievementProgress("Beak Doctor", 2) + item:remove() + else + if player:hasOutfit(outfitId) then + return true + end + + local requiredItemIds = { 12551, 12552, 12553, 12554, 12555, 12556 } + for _, itemId in ipairs(requiredItemIds) do + if player:getItemCount(itemId) < 1 then + return true + end + end + + for _, itemId in ipairs(requiredItemIds) do + player:removeItem(itemId, 1) + end + + player:addOutfit(430) + player:addOutfit(431) + player:say("You have restored an outfit.", TALKTYPE_MONSTER_SAY, false, player) + player:getPosition():sendMagicEffect(CONST_ME_POFF) + end + return true +end + +usableAfflictedOutfitItems:id(12551, 12552, 12553, 12554, 12555, 12556, 12786, 12787) +usableAfflictedOutfitItems:register() diff --git a/data-otservbr-global/scripts/actions/addons/addons.lua b/data/scripts/actions/items/usable_outfit_items.lua similarity index 58% rename from data-otservbr-global/scripts/actions/addons/addons.lua rename to data/scripts/actions/items/usable_outfit_items.lua index 0658ab69312..f9e3b5b61dd 100644 --- a/data-otservbr-global/scripts/actions/addons/addons.lua +++ b/data/scripts/actions/items/usable_outfit_items.lua @@ -1,73 +1,78 @@ -local config = { +local outfitConfig = { -- soil guardian [16252] = { female = 514, male = 516, effect = CONST_ME_GREEN_RINGS }, [16253] = { female = 514, male = 516, addon = 1, effect = CONST_ME_GREEN_RINGS, achievement = "Funghitastic" }, [16254] = { female = 514, male = 516, addon = 2, effect = CONST_ME_GREEN_RINGS, achievement = "Funghitastic" }, + -- crystal warlord [16255] = { female = 513, male = 512, effect = CONST_ME_GIANTICE }, [16256] = { female = 513, male = 512, addon = 1, effect = CONST_ME_GIANTICE, achievement = "Crystal Clear" }, [16257] = { female = 513, male = 512, addon = 2, effect = CONST_ME_GIANTICE, achievement = "Crystal Clear" }, + -- makeshift warrior [27655] = { female = 1043, male = 1042 }, [27657] = { female = 1043, male = 1042, addon = 1, achievement = "Cobbled and Patched" }, [27656] = { female = 1043, male = 1042, addon = 2, achievement = "Cobbled and Patched" }, + -- hand of the inquisition [31738] = { female = 1244, male = 1243, addon = 1, effect = CONST_ME_HOLYAREA, achievement = "Inquisition's Arm" }, [31737] = { female = 1244, male = 1243, addon = 2, effect = CONST_ME_HOLYAREA, achievement = "Inquisition's Arm" }, + -- poltergeist [32630] = { female = 1271, male = 1270, addon = 1, effect = CONST_ME_BLUE_GHOST, achievement = "Mainstreet Nightmare" }, [32631] = { female = 1271, male = 1270, addon = 2, effect = CONST_ME_BLUE_GHOST, achievement = "Mainstreet Nightmare" }, + -- rascoohan [35595] = { female = 1372, male = 1371, addon = 1, achievement = "Honorary Rascoohan" }, [35695] = { female = 1372, male = 1371, addon = 2, achievement = "Honorary Rascoohan" }, + -- fire-fighter [39544] = { female = 1569, male = 1568, addon = 1, achievement = "Friendly Fire" }, [39545] = { female = 1569, male = 1568, addon = 2, achievement = "Friendly Fire" }, } -local addons = Action() +local usableOutfitItems = Action() -function addons.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local useItem = config[item.itemid] - if not useItem then +function usableOutfitItems.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if not player:isPremium() then + player:sendCancelMessage(RETURNVALUE_YOUNEEDPREMIUMACCOUNT) return true end - local looktype = player:getSex() == PLAYERSEX_FEMALE and useItem.female or useItem.male - - if useItem.addon then - if not player:isPremium() or not player:hasOutfit(looktype) or player:hasOutfit(looktype, useItem.addon) then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You own no premium account, lack the base outfit or already own this outfit part.") + local outfitInfo = outfitConfig[item.itemid] + local looktype = player:getSex() == PLAYERSEX_FEMALE and outfitInfo.female or outfitInfo.male + if not player:hasOutfit(looktype) then + if outfitInfo.addon then + player:sendCancelMessage("You need the outfit for this part.") return true end - player:addOutfitAddon(useItem.female, useItem.addon) - player:addOutfitAddon(useItem.male, useItem.addon) - player:getPosition():sendMagicEffect(useItem.effect or CONST_ME_GIFT_WRAPS) - if player:hasOutfit(looktype, 3) then - if useItem.achievement then - player:addAchievement(useItem.achievement) - end - end - item:remove() - else - if not player:isPremium() or player:hasOutfit(looktype) then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You own no premium account or already own this outfit part.") - return true - end + player:addOutfit(outfitInfo.female) + player:addOutfit(outfitInfo.male) + player:getPosition():sendMagicEffect(outfitInfo.effect) + item:remove(1) + return true + end + + if player:hasOutfit(looktype, outfitInfo.addon) then + player:sendCancelMessage("You already own this outfit part.") + return true + end - player:addOutfit(useItem.female) - player:addOutfit(useItem.male) - player:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS) - item:remove() + player:addOutfitAddon(outfitInfo.female, outfitInfo.addon) + player:addOutfitAddon(outfitInfo.male, outfitInfo.addon) + player:getPosition():sendMagicEffect(outfitInfo.effect) + + if player:hasOutfit(looktype, 3) then + player:addAchievement(outfitInfo.achievement) end + + item:remove(1) return true end -local ids = {} -for value in pairs(config) do - table.insert(ids, value) +for itemId, _ in pairs(outfitConfig) do + usableOutfitItems:id(itemId) end -addons:id(unpack(ids)) -addons:register() +usableOutfitItems:register()