From 50b4c26a3fcab7fb01130186eb18a196c24e3db4 Mon Sep 17 00:00:00 2001 From: Guilherme Date: Mon, 20 May 2024 16:03:10 -0300 Subject: [PATCH] feat: Galthen's Satchel and Artefact Box (#2149) Fixes from map on pr #2314 --- data-otservbr-global/npc/an_idol.lua | 68 +++++++++++++++++++ .../adventures_of_galthen/galthens_tree.lua | 19 ++++++ data-otservbr-global/world/otservbr-npc.xml | 5 +- 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 data-otservbr-global/npc/an_idol.lua create mode 100644 data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthens_tree.lua diff --git a/data-otservbr-global/npc/an_idol.lua b/data-otservbr-global/npc/an_idol.lua new file mode 100644 index 00000000000..69977dc81ec --- /dev/null +++ b/data-otservbr-global/npc/an_idol.lua @@ -0,0 +1,68 @@ +local internalNpcName = "An Idol" +local npcType = Game.createNpcType(internalNpcName) +local npcConfig = {} + +npcConfig.name = internalNpcName +npcConfig.description = internalNpcName + +npcConfig.health = 100 +npcConfig.maxHealth = npcConfig.health +npcConfig.walkInterval = 0 +npcConfig.walkRadius = 2 + +npcConfig.outfit = { + lookTypeEx = 15894, +} + +npcConfig.flags = { + floorchange = false, +} + +local keywordHandler = KeywordHandler:new() +local npcHandler = NpcHandler:new(keywordHandler) + +npcType.onThink = function(npc, interval) + npcHandler:onThink(npc, interval) +end + +npcType.onAppear = function(npc, creature) + npcHandler:onAppear(npc, creature) +end + +npcType.onDisappear = function(npc, creature) + npcHandler:onDisappear(npc, creature) +end + +npcType.onMove = function(npc, creature, fromPosition, toPosition) + npcHandler:onMove(npc, creature, fromPosition, toPosition) +end + +npcType.onSay = function(npc, creature, type, message) + npcHandler:onSay(npc, creature, type, message) +end + +npcType.onCloseChannel = function(npc, creature) + npcHandler:onCloseChannel(npc, creature) +end + +local function creatureSayCallback(npc, creature, type, message) + local player = Player(creature) + + if not npcHandler:checkInteraction(npc, creature) then + return false + end + + if MsgContains(message, "VBOX") then + npcHandler:say("J-T B^C J^BXT°", npc, creature) + player:teleportTo(Position(32366, 32531, 8), false) + player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + end + + return true +end + +npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) +npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, false) + +-- npcType registering the npcConfig table +npcType:register(npcConfig) diff --git a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthens_tree.lua b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthens_tree.lua new file mode 100644 index 00000000000..441b91fa345 --- /dev/null +++ b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthens_tree.lua @@ -0,0 +1,19 @@ +local galthensTree = Action() +function galthensTree.onUse(player, item, fromPosition, target, toPosition, isHotkey) + local hasExhaustion, message = player:kv():get("galthens-satchel") or 0, "Empty." + if hasExhaustion < os.time() then + local container = player:addItem(36813) + container:addItem(36810, 1) + player:kv():set("galthens-satchel", os.time() + 30 * 24 * 60 * 60) + message = "You have found a galthens satchel." + end + + player:teleportTo(Position(32396, 32520, 7)) + player:getPosition():sendMagicEffect(CONST_ME_WATERSPLASH) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message) + + return true +end + +galthensTree:position(Position(32366, 32542, 8)) +galthensTree:register() diff --git a/data-otservbr-global/world/otservbr-npc.xml b/data-otservbr-global/world/otservbr-npc.xml index 10772902341..f97bc118fdc 100644 --- a/data-otservbr-global/world/otservbr-npc.xml +++ b/data-otservbr-global/world/otservbr-npc.xml @@ -2994,5 +2994,8 @@ - + + + +