diff --git a/data-otservbr-global/npc/testserver_assistant.lua b/data-otservbr-global/npc/testserver_assistant.lua index 05814590bdd..220dcb1437b 100644 --- a/data-otservbr-global/npc/testserver_assistant.lua +++ b/data-otservbr-global/npc/testserver_assistant.lua @@ -113,7 +113,7 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) -npcHandler:setMessage(MESSAGE_GREET, "Hey |PLAYERNAME|. I'm Testserver Assistant and I can give {money}, {experience} and {blessing} which will be useful for testing on " .. configManager.getString(configKeys.SERVER_NAME) .. " server." .. " You can too to back to level 8 with {reset}.") +npcHandler:setMessage(MESSAGE_GREET, "Hey |PLAYERNAME|. I'm Testserver Assistant and I can give {money}, {experience} and {blessing} which will be useful for testing on " .. SERVER_NAME .. " server." .. " You can too to back to level 8 with {reset}.") npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true) -- npcType registering the npcConfig table diff --git a/data-otservbr-global/scripts/quests/cults_of_tibia/event_on_item_moved.lua b/data-otservbr-global/scripts/quests/cults_of_tibia/event_on_item_moved.lua new file mode 100644 index 00000000000..15fc805c37d --- /dev/null +++ b/data-otservbr-global/scripts/quests/cults_of_tibia/event_on_item_moved.lua @@ -0,0 +1,44 @@ +local callback = EventCallback("CultsOnItemMoved") + +function callback.onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder) + local fromPos = Position(33023, 31904, 14) + local toPos = Position(33052, 31932, 15) + + if player:getPosition():isInRange(fromPos, toPos) and item:getId() == 23729 then + local tile = Tile(toPosition) + if not tile then + return + end + + local tileBoss = tile:getTopCreature() + if not (tileBoss and tileBoss:isMonster()) then + return + end + + local bossName = tileBoss:getName():lower() + if bossName == "the remorseless corruptor" then + tileBoss:addHealth(-17000) + tileBoss:remove() + + local monster = Game.createMonster("The Corruptor of Souls", toPosition) + if not monster then + return + end + + monster:registerEvent("CheckTile") + + local storedHealth = Game.getStorageValue("healthSoul") + if storedHealth > 0 then + monster:addHealth(-(monster:getHealth() - storedHealth)) + end + + Game.setStorageValue("CheckTile", os.time() + 30) + item:remove(1) + elseif bossName == "the corruptor of souls" then + Game.setStorageValue("CheckTile", os.time() + 30) + item:remove(1) + end + end +end + +callback:register() diff --git a/data-otservbr-global/scripts/quests/the_secret_library_quest/event_on_item_moved.lua b/data-otservbr-global/scripts/quests/the_secret_library_quest/event_on_item_moved.lua new file mode 100644 index 00000000000..01bb4ef715e --- /dev/null +++ b/data-otservbr-global/scripts/quests/the_secret_library_quest/event_on_item_moved.lua @@ -0,0 +1,12 @@ +local callback = EventCallback("SecretOnItemMoved") + +function callback.onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder) + if toPosition == Position(32460, 32928, 7) and item.itemid == 3578 then + toPosition:sendMagicEffect(CONST_ME_HEARTS) + player:say("You feed the turtle, now you may pass.", TALKTYPE_MONSTER_SAY) + Game.setStorageValue(Storage.Quest.U11_80.TheSecretLibrary.SmallIslands.Turtle, os.time() + 10 * 60) + item:remove(1) + end +end + +callback:register() diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index c526553132d..a8fe0bfb679 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -371,49 +371,6 @@ function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, end function Player:onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder) - if IsRunningGlobalDatapack() then - -- The Secret Library Quest - if toPosition == Position(32460, 32928, 7) and item.itemid == 3578 then - toPosition:sendMagicEffect(CONST_ME_HEARTS) - self:say("You feed the turtle, now you may pass.", TALKTYPE_MONSTER_SAY) - Game.setStorageValue(Storage.Quest.U11_80.TheSecretLibrary.SmallIslands.Turtle, os.time() + 10 * 60) - item:remove(1) - end - - -- Cults of Tibia begin - local frompos = Position(33023, 31904, 14) - local topos = Position(33052, 31932, 15) - local removeItem = false - if self:getPosition():isInRange(frompos, topos) and item:getId() == 23729 then - local tile = Tile(toPosition) - if tile then - local tileBoss = tile:getTopCreature() - if tileBoss and tileBoss:isMonster() then - if tileBoss:getName():lower() == "the remorseless corruptor" then - tileBoss:addHealth(-17000) - tileBoss:remove() - local monster = Game.createMonster("The Corruptor of Souls", toPosition) - if not monster then - return false - end - removeItem = true - monster:registerEvent("CheckTile") - if Game.getStorageValue("healthSoul") > 0 then - monster:addHealth(-(monster:getHealth() - Game.getStorageValue("healthSoul"))) - end - Game.setStorageValue("CheckTile", os.time() + 30) - elseif tileBoss:getName():lower() == "the corruptor of souls" then - Game.setStorageValue("CheckTile", os.time() + 30) - removeItem = true - end - end - end - if removeItem then - item:remove(1) - end - end - -- Cults of Tibia end - end return true end @@ -426,80 +383,10 @@ function Player:onMoveCreature(creature, fromPosition, toPosition) return true end -local function hasPendingReport(playerGuid, targetName, reportType) - local player = Player(playerGuid) - if not player then - return false - end - local name = player:getName():gsub("%s+", "_") - FS.mkdir_p(string.format("%s/reports/players/%s", CORE_DIRECTORY, name)) - local file = io.open(string.format("%s/reports/players/%s-%s-%d.txt", CORE_DIRECTORY, name, targetName, reportType), "r") - if file then - io.close(file) - return true - end - return false -end - function Player:onReportRuleViolation(targetName, reportType, reportReason, comment, translation) - local name = self:getName() - if hasPendingReport(self:getGuid(), targetName, reportType) then - self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your report is being processed.") - return - end - - local file = io.open(string.format("%s/reports/players/%s-%s-%d.txt", CORE_DIRECTORY, name, targetName, reportType), "a") - if not file then - self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There was an error when processing your report, please contact a gamemaster.") - return - end - - io.output(file) - io.write("------------------------------\n") - io.write("Reported by: " .. name .. "\n") - io.write("Target: " .. targetName .. "\n") - io.write("Type: " .. reportType .. "\n") - io.write("Reason: " .. reportReason .. "\n") - io.write("Comment: " .. comment .. "\n") - if reportType ~= REPORT_TYPE_BOT then - io.write("Translation: " .. translation .. "\n") - end - io.write("------------------------------\n") - io.close(file) - self:sendTextMessage( - MESSAGE_EVENT_ADVANCE, - string.format( - "Thank you for reporting %s. Your report \z - will be processed by %s team as soon as possible.", - targetName, - configManager.getString(configKeys.SERVER_NAME) - ) - ) return end - function Player:onReportBug(message, position, category) - local name = self:getName():gsub("%s+", "_") - FS.mkdir_p(string.format("%s/reports/bugs/%s", CORE_DIRECTORY, name)) - local file = io.open(string.format("%s/reports/bugs/%s/report.txt", CORE_DIRECTORY, name), "a") - - if not file then - self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There was an error when processing your report, please contact a gamemaster.") - return true - end - - io.output(file) - io.write("------------------------------\n") - io.write("Name: " .. name) - if category == BUG_CATEGORY_MAP then - io.write(" [Map position: " .. position.x .. ", " .. position.y .. ", " .. position.z .. "]") - end - local playerPosition = self:getPosition() - io.write(" [Player Position: " .. playerPosition.x .. ", " .. playerPosition.y .. ", " .. playerPosition.z .. "]\n") - io.write("Comment: " .. message .. "\n") - io.close(file) - - self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your report has been sent to " .. configManager.getString(configKeys.SERVER_NAME) .. ".") return true end diff --git a/data/global.lua b/data/global.lua index 85987d559d0..35e3db9c906 100644 --- a/data/global.lua +++ b/data/global.lua @@ -47,11 +47,6 @@ DIRECTIONS_TABLE = { DIRECTION_NORTHEAST, } -SERVER_NAME = configManager.getString(configKeys.SERVER_NAME) -SERVER_MOTD = configManager.getString(configKeys.SERVER_MOTD) - -AUTH_TYPE = configManager.getString(configKeys.AUTH_TYPE) - -- Bestiary charm GLOBAL_CHARM_GUT = 120 -- 20% more chance to get creature products from looting GLOBAL_CHARM_SCAVENGE = 125 -- 25% more chance to get creature products from skinning diff --git a/data/libs/functions/constants.lua b/data/libs/functions/constants.lua index e5b8d9170b0..5c383dcc787 100644 --- a/data/libs/functions/constants.lua +++ b/data/libs/functions/constants.lua @@ -8,3 +8,6 @@ BATHTUB_FILLED_NOTMOVABLE = 26100 BAG_YOU_DESIRE = 34109 PRIMAL_BAG = 39546 BAG_YOU_COVET = 43895 + +SERVER_NAME = configManager.getString(configKeys.SERVER_NAME) +AUTH_TYPE = configManager.getString(configKeys.AUTH_TYPE) diff --git a/data/scripts/eventcallbacks/player/on_report_bug.lua b/data/scripts/eventcallbacks/player/on_report_bug.lua new file mode 100644 index 00000000000..ede9ad0e4ac --- /dev/null +++ b/data/scripts/eventcallbacks/player/on_report_bug.lua @@ -0,0 +1,29 @@ +local callback = EventCallback("PlayerOnReportBug") + +function callback.playerOnReportBug(player, message, position, category) + local name = player:getName() + local filePath = string.format("%s/reports/bugs/%s.txt", CORE_DIRECTORY, name) + local file = io.open(filePath, "a") + + if not file then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There was an error when processing your report, please contact a gamemaster.") + return true + end + + file:write("------------------------------\n") + file:write(string.format("Name: %s", name)) + + if category == BUG_CATEGORY_MAP then + file:write(string.format(" [Map position: %d, %d, %d]", position.x, position.y, position.z)) + end + + local playerPosition = player:getPosition() + file:write(string.format(" [Player Position: %d, %d, %d]\n", playerPosition.x, playerPosition.y, playerPosition.z)) + file:write(string.format("Comment: %s\n", message)) + file:write("------------------------------\n") + file:close() + + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("Your report has been sent to %s.", SERVER_NAME)) +end + +callback:register() diff --git a/data/scripts/eventcallbacks/player/on_report_rule_violation.lua b/data/scripts/eventcallbacks/player/on_report_rule_violation.lua new file mode 100644 index 00000000000..3c1c52424af --- /dev/null +++ b/data/scripts/eventcallbacks/player/on_report_rule_violation.lua @@ -0,0 +1,36 @@ +local callback = EventCallback("PlayerOnReportRuleViolation") + +function callback.playerOnReportRuleViolation(player, targetName, reportType, reportReason, comment, translation) + local name = player:getName() + local filePath = string.format("%s/reports/players/%s-%s-%d.txt", CORE_DIRECTORY, name, targetName, reportType) + local file = io.open(filePath, "r") + if file then + io.close(file) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your report is being processed.") + return + end + + file = io.open(filePath, "a") + if not file then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There was an error when processing your report, please contact a gamemaster.") + return + end + + file:write("------------------------------\n") + file:write(string.format("Reported by: %s\n", name)) + file:write(string.format("Target: %s\n", targetName)) + file:write(string.format("Type: %d\n", reportType)) + file:write(string.format("Reason: %s\n", reportReason)) + file:write(string.format("Comment: %s\n", comment)) + + if reportType ~= REPORT_TYPE_BOT then + file:write(string.format("Translation: %s\n", translation)) + end + + file:write("------------------------------\n") + file:close() + + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("Thank you for reporting %s. Your report will be processed by %s team as soon as possible.", targetName, SERVER_NAME)) +end + +callback:register() diff --git a/data/scripts/talkactions/player/reward.lua b/data/scripts/talkactions/player/reward.lua index a05dab3a933..56dde7499e0 100644 --- a/data/scripts/talkactions/player/reward.lua +++ b/data/scripts/talkactions/player/reward.lua @@ -31,7 +31,7 @@ local function sendExerciseRewardModal(player) if item then item:setActionId(IMMOVABLE_ACTION_ID) item:setAttribute(ITEM_ATTRIBUTE_STORE, systemTime()) - item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, string.format("You won this exercise weapon as a reward to be a %s player. Use it in a dummy!\nHave a nice game..", configManager.getString(configKeys.SERVER_NAME))) + item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, string.format("You won this exercise weapon as a reward to be a %s player. Use it in a dummy!\nHave a nice game..", SERVER_NAME)) else player:sendTextMessage(MESSAGE_LOOK, "You need to have capacity and empty slots to receive.") return