From 40630b86afafa47e78072ceef54420f9d0adb452 Mon Sep 17 00:00:00 2001
From: GuiValladao <guilherme.vrsantana@gmail.com>
Date: Wed, 24 Jan 2024 22:41:26 -0300
Subject: [PATCH 1/6] feat: Galthen's Satchel and Artefact Box

---
 data-otservbr-global/npc/an_idol.lua          | 67 +++++++++++++++++++
 .../quests/adventures_of_galthen/an_idol.lua  | 19 ++++++
 .../adventures_of_galthen/gathenstree.lua     | 19 ++++++
 data-otservbr-global/world/otservbr-npc.xml   |  3 +
 4 files changed, 108 insertions(+)
 create mode 100644 data-otservbr-global/npc/an_idol.lua
 create mode 100644 data-otservbr-global/scripts/actions/quests/adventures_of_galthen/an_idol.lua
 create mode 100644 data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.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..b97b0b45046
--- /dev/null
+++ b/data-otservbr-global/npc/an_idol.lua
@@ -0,0 +1,67 @@
+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)
+	local playerId = player:getId()
+
+	if not npcHandler:checkInteraction(npc, creature) then
+		return false
+	end
+
+	if MsgContains(message, "VBOX") or MsgContains(message, "XBOX") 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
+	end
+
+npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
+npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)
+
+-- npcType registering the npcConfig table
+npcType:register(npcConfig)
diff --git a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/an_idol.lua b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/an_idol.lua
new file mode 100644
index 00000000000..c5ecf5bd4ca
--- /dev/null
+++ b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/an_idol.lua
@@ -0,0 +1,19 @@
+local idol = {
+	{ clickPos = { x = 32398, y = 32509, z = 7 }, destination = Position(32366, 32531, 8) },
+}
+
+local anidol = Action()
+function anidol.onUse(player, item, fromPosition, target, toPosition, isHotkey)
+	for i = 1, #idol do
+		if item:getPosition() == Position(idol[i].clickPos) then
+			player:teleportTo(idol[i].destination)
+			player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
+			return true
+		end
+	end
+end
+
+for j = 1, #idol do
+	anidol:position(idol[j].clickPos)
+end
+anidol:register()
diff --git a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.lua b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.lua
new file mode 100644
index 00000000000..963e07e9762
--- /dev/null
+++ b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.lua
@@ -0,0 +1,19 @@
+local galthensTree = Action()
+function galthensTree.onUse(player, item, fromPosition, target, toPosition, isHotkey)
+		local hasExhaustion = player:kv():get("galthens-satchel") or 0
+			if hasExhaustion < os.time() then
+			local container = player:addItem(36813)
+			container:addItem(36810, 1)
+			player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a galthens satchel.")
+			player:teleportTo(Position(32396, 32520, 7))
+			player:getPosition():sendMagicEffect(CONST_ME_WATERSPLASH)
+			player:kv():set("galthens-satchel", os.time () + 30 * 24 * 60 * 60)
+		else
+			player:teleportTo(Position(32396, 32520, 7))
+			player:getPosition():sendMagicEffect(CONST_ME_WATERSPLASH)
+			player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Empty.")
+		end
+	end
+
+galthensTree:uid(14044)
+galthensTree:register()
diff --git a/data-otservbr-global/world/otservbr-npc.xml b/data-otservbr-global/world/otservbr-npc.xml
index e707a58c248..04edea89a54 100644
--- a/data-otservbr-global/world/otservbr-npc.xml
+++ b/data-otservbr-global/world/otservbr-npc.xml
@@ -2986,4 +2986,7 @@
 	<npc centerx="33710" centery="32602" centerz="6" radius="1">
 		<npc name="Hawkhurst Ingol" x="0" y="0" z="15" spawntime="60" />
 	</npc>
+		<npc centerx="32398" centery="32509" centerz="7" radius="1">
+		<npc name="An Idol" x="0" y="0" z="15" spawntime="60" />
+	</npc>
 </npcs>

From ec1be1e5ee6e69a62bc36994f6c86fe869b7fcf7 Mon Sep 17 00:00:00 2001
From: GitHub Actions <github-actions[bot]@users.noreply.github.com>
Date: Sun, 4 Feb 2024 13:30:34 +0000
Subject: [PATCH 2/6] Lua code format - (Stylua)

---
 data-otservbr-global/npc/an_idol.lua          |  2 +-
 .../adventures_of_galthen/gathenstree.lua     | 26 +++++++++----------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/data-otservbr-global/npc/an_idol.lua b/data-otservbr-global/npc/an_idol.lua
index b97b0b45046..9765d7a74f9 100644
--- a/data-otservbr-global/npc/an_idol.lua
+++ b/data-otservbr-global/npc/an_idol.lua
@@ -58,7 +58,7 @@ local function creatureSayCallback(npc, creature, type, message)
 		player:teleportTo(Position(32366, 32531, 8), false)
 		player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
 	end
-	end
+end
 
 npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)
diff --git a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.lua b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.lua
index 963e07e9762..26e3c53f7fc 100644
--- a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.lua
+++ b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.lua
@@ -1,19 +1,19 @@
 local galthensTree = Action()
 function galthensTree.onUse(player, item, fromPosition, target, toPosition, isHotkey)
-		local hasExhaustion = player:kv():get("galthens-satchel") or 0
-			if hasExhaustion < os.time() then
-			local container = player:addItem(36813)
-			container:addItem(36810, 1)
-			player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a galthens satchel.")
-			player:teleportTo(Position(32396, 32520, 7))
-			player:getPosition():sendMagicEffect(CONST_ME_WATERSPLASH)
-			player:kv():set("galthens-satchel", os.time () + 30 * 24 * 60 * 60)
-		else
-			player:teleportTo(Position(32396, 32520, 7))
-			player:getPosition():sendMagicEffect(CONST_ME_WATERSPLASH)
-			player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Empty.")
-		end
+	local hasExhaustion = player:kv():get("galthens-satchel") or 0
+	if hasExhaustion < os.time() then
+		local container = player:addItem(36813)
+		container:addItem(36810, 1)
+		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a galthens satchel.")
+		player:teleportTo(Position(32396, 32520, 7))
+		player:getPosition():sendMagicEffect(CONST_ME_WATERSPLASH)
+		player:kv():set("galthens-satchel", os.time() + 30 * 24 * 60 * 60)
+	else
+		player:teleportTo(Position(32396, 32520, 7))
+		player:getPosition():sendMagicEffect(CONST_ME_WATERSPLASH)
+		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Empty.")
 	end
+end
 
 galthensTree:uid(14044)
 galthensTree:register()

From 1ddf1e068d1eb5bfdb0926b06eb55608ebe0897a Mon Sep 17 00:00:00 2001
From: Elson Costa <elsongabriel@hotmail.com>
Date: Mon, 4 Mar 2024 12:00:01 -0300
Subject: [PATCH 3/6] improvements.

---
 data-otservbr-global/npc/an_idol.lua          |  7 ++++---
 .../quests/adventures_of_galthen/an_idol.lua  | 13 +++++++------
 .../adventures_of_galthen/galthenstree.lua    | 19 +++++++++++++++++++
 .../adventures_of_galthen/gathenstree.lua     | 19 -------------------
 4 files changed, 30 insertions(+), 28 deletions(-)
 create mode 100644 data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthenstree.lua
 delete mode 100644 data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.lua

diff --git a/data-otservbr-global/npc/an_idol.lua b/data-otservbr-global/npc/an_idol.lua
index 9765d7a74f9..69977dc81ec 100644
--- a/data-otservbr-global/npc/an_idol.lua
+++ b/data-otservbr-global/npc/an_idol.lua
@@ -47,21 +47,22 @@ end
 
 local function creatureSayCallback(npc, creature, type, message)
 	local player = Player(creature)
-	local playerId = player:getId()
 
 	if not npcHandler:checkInteraction(npc, creature) then
 		return false
 	end
 
-	if MsgContains(message, "VBOX") or MsgContains(message, "XBOX") then
+	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, true)
+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/an_idol.lua b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/an_idol.lua
index c5ecf5bd4ca..03d78eb3f5d 100644
--- a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/an_idol.lua
+++ b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/an_idol.lua
@@ -1,19 +1,20 @@
 local idol = {
-	{ clickPos = { x = 32398, y = 32509, z = 7 }, destination = Position(32366, 32531, 8) },
+	{ clickPos = Position(32398, 32509, 7), destination = Position(32366, 32531, 8) },
 }
 
-local anidol = Action()
-function anidol.onUse(player, item, fromPosition, target, toPosition, isHotkey)
+local anIdolStatue = Action()
+function anIdolStatue.onUse(player, item, fromPosition, target, toPosition, isHotkey)
 	for i = 1, #idol do
 		if item:getPosition() == Position(idol[i].clickPos) then
 			player:teleportTo(idol[i].destination)
 			player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
-			return true
+			break
 		end
 	end
+	return true
 end
 
 for j = 1, #idol do
-	anidol:position(idol[j].clickPos)
+	anIdolStatue:position(idol[j].clickPos)
 end
-anidol:register()
+anIdolStatue:register()
diff --git a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthenstree.lua b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthenstree.lua
new file mode 100644
index 00000000000..53a081491e0
--- /dev/null
+++ b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthenstree.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:uid(14044)
+galthensTree:register()
diff --git a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.lua b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.lua
deleted file mode 100644
index 26e3c53f7fc..00000000000
--- a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/gathenstree.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-local galthensTree = Action()
-function galthensTree.onUse(player, item, fromPosition, target, toPosition, isHotkey)
-	local hasExhaustion = player:kv():get("galthens-satchel") or 0
-	if hasExhaustion < os.time() then
-		local container = player:addItem(36813)
-		container:addItem(36810, 1)
-		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a galthens satchel.")
-		player:teleportTo(Position(32396, 32520, 7))
-		player:getPosition():sendMagicEffect(CONST_ME_WATERSPLASH)
-		player:kv():set("galthens-satchel", os.time() + 30 * 24 * 60 * 60)
-	else
-		player:teleportTo(Position(32396, 32520, 7))
-		player:getPosition():sendMagicEffect(CONST_ME_WATERSPLASH)
-		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Empty.")
-	end
-end
-
-galthensTree:uid(14044)
-galthensTree:register()

From bb2b4ebe0ecf803893acbc2967a9c03b0096a2ea Mon Sep 17 00:00:00 2001
From: Elson Costa <elsongabriel@hotmail.com>
Date: Mon, 4 Mar 2024 12:06:13 -0300
Subject: [PATCH 4/6] improvements.

---
 .../adventures_of_galthen/{galthenstree.lua => galthens_tree.lua} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename data-otservbr-global/scripts/actions/quests/adventures_of_galthen/{galthenstree.lua => galthens_tree.lua} (100%)

diff --git a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthenstree.lua b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthens_tree.lua
similarity index 100%
rename from data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthenstree.lua
rename to data-otservbr-global/scripts/actions/quests/adventures_of_galthen/galthens_tree.lua

From 9b94464635578c2b5fc5e995f3fc38c8018dd0ab Mon Sep 17 00:00:00 2001
From: Elson Costa <elsongabriel@hotmail.com>
Date: Mon, 4 Mar 2024 16:46:59 -0300
Subject: [PATCH 5/6] changed action uid to position.

---
 .../actions/quests/adventures_of_galthen/galthens_tree.lua      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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
index 53a081491e0..441b91fa345 100644
--- 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
@@ -15,5 +15,5 @@ function galthensTree.onUse(player, item, fromPosition, target, toPosition, isHo
 	return true
 end
 
-galthensTree:uid(14044)
+galthensTree:position(Position(32366, 32542, 8))
 galthensTree:register()

From 78524b2bde080f6cd2fe8c9f0817bde9042c0383 Mon Sep 17 00:00:00 2001
From: Elson Costa <elsongabriel@hotmail.com>
Date: Mon, 4 Mar 2024 17:06:54 -0300
Subject: [PATCH 6/6] removed unnecessary script.

---
 .../quests/adventures_of_galthen/an_idol.lua  | 20 -------------------
 1 file changed, 20 deletions(-)
 delete mode 100644 data-otservbr-global/scripts/actions/quests/adventures_of_galthen/an_idol.lua

diff --git a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/an_idol.lua b/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/an_idol.lua
deleted file mode 100644
index 03d78eb3f5d..00000000000
--- a/data-otservbr-global/scripts/actions/quests/adventures_of_galthen/an_idol.lua
+++ /dev/null
@@ -1,20 +0,0 @@
-local idol = {
-	{ clickPos = Position(32398, 32509, 7), destination = Position(32366, 32531, 8) },
-}
-
-local anIdolStatue = Action()
-function anIdolStatue.onUse(player, item, fromPosition, target, toPosition, isHotkey)
-	for i = 1, #idol do
-		if item:getPosition() == Position(idol[i].clickPos) then
-			player:teleportTo(idol[i].destination)
-			player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
-			break
-		end
-	end
-	return true
-end
-
-for j = 1, #idol do
-	anIdolStatue:position(idol[j].clickPos)
-end
-anIdolStatue:register()