Skip to content

Commit

Permalink
Hunting for Tokens Quest
Browse files Browse the repository at this point in the history
  • Loading branch information
htc16 committed Aug 27, 2024
1 parent 06c6a67 commit 8823429
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 70 deletions.
145 changes: 81 additions & 64 deletions data-otservbr-global/npc/jorge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,69 +49,6 @@ npcType.onCloseChannel = function(npc, creature)
npcHandler:onCloseChannel(npc, creature)
end

local items = {
[1] = { name = "Abacus", id = 19151 },
[2] = { name = "Assassin Doll", id = 28897 },
[3] = { name = "Bag of Oriental Spices", id = 10817 },
[4] = { name = "Bookworm Doll", id = 18343 },
[5] = { name = "Cateroides Doll", id = 22151 },
[6] = { name = "Doll of Durin the Almighty", id = 14764 },
[7] = { name = "Dragon Eye", id = 22027 },
[8] = { name = "Dragon Goblet", id = 31265 },
[9] = { name = "Draken Doll", id = 12043 },
[10] = { name = "Encyclopedia", id = 8149 },
[11] = { name = "Friendship Amulet", id = 19153 },
[12] = { name = "Frozen Heart", id = 19156 },
[13] = { name = "Golden Falcon", id = 28896 },
[14] = { name = "Golden Newspaper", id = 8153 },
[15] = { name = "Hand Puppets", id = 9189 },
[16] = { name = "Imortus", id = 12811 },
[17] = { name = "Jade Amulet", id = 31268 },
[18] = { name = "Key of Numerous Locks", id = 19152 },
[19] = { name = "Loremaster Doll", id = 31267 },
[20] = { name = "Mathmaster Shield", id = 14760 },
[21] = { name = "Medusa Skull", id = 14762 },
[22] = { name = "Music Box", id = 12045 },
[23] = { name = "Noble Sword", id = 16276 },
[24] = { name = "Norsemal Doll", id = 19150 },
[25] = { name = "Old Radio", id = 12813 },
[26] = { name = "Orcs Jaw Shredder", id = 19155 },
[27] = { name = "Pigeon Trophy", id = 31266 },
[28] = { name = "Phoenix Statue", id = 22026 },
[29] = { name = "The Mexcalibur", id = 19154 },
[30] = { name = "TibiaHispano Emblem", id = 25980 },
[31] = { name = "Goromaphone", id = 34210 },
}

local function greetCallback(npc, creature)
local playerId = creature:getId()
return true
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 message then
for i = 1, #items do
if MsgContains(message, items[i].name) then
if getPlayerItemCount(creature, 19083) >= 20 then
doPlayerRemoveItem(creature, 19083, 20)
doPlayerAddItem(creature, items[i].id, 1)
selfSay("You just swapped 20 silver raid tokens for 1 " .. getItemName(items[i].name) .. ".", npc, creature)
else
selfSay("You need 20 silver raid tokens.", npc, creature)
end
end
end
end
return true
end

local function onAddFocus(npc, creature)
local playerId = creature:getId()
end
Expand All @@ -120,10 +57,90 @@ local function onReleaseFocus(npc, creature)
local playerId = creature:getId()
end

local items = {
[1] = { name = "Abacus", id = 19151 },
[2] = { name = "Assassin Doll", id = 28897 },
[3] = { name = "Bag of Oriental Spices", id = 23682 },
[4] = { name = "Bookworm Doll", id = 28895 },
[5] = { name = "Citizen Doll", id = 43511 },
[6] = { name = "Crimson Doll", id = 25981 },
[7] = { name = "Doll of Durin the Almighty", id = 23679 },
[8] = { name = "Dragon Eye", id = 22027 },
[9] = { name = "Dragon Goblet", id = 31265 },
[10] = { name = "Draken Doll", id = 25979 },
[11] = { name = "Emblem", id = 25980 },
[12] = { name = "Encyclopedia", id = 23678 },
[13] = { name = "Friendship Amulet", id = 19153 },
[14] = { name = "Frozen Heart", id = 19156 },
[15] = { name = "Golden Falcon", id = 28896 },
[16] = { name = "Golden Newspaper", id = 23681 },
[17] = { name = "Goromaphone", id = 34210 },
[18] = { name = "Hand Puppets", id = 23676 },
[19] = { name = "Imortus", id = 23683 },
[20] = { name = "Jade Amulet", id = 31268 },
[21] = { name = "Key of Numerous Locks", id = 19152 },
[22] = { name = "Little Adventurer Doll", id = 37058 },
[23] = { name = "Loremaster Doll", id = 31267 },
[24] = { name = "Lucky Clover Amulet", id = 37059 },
[25] = { name = "Mathmaster Shield", id = 25982 },
[26] = { name = "Medusa Skull", id = 23680 },
[27] = { name = "Music Box", id = 23677 },
[28] = { name = "Noble Sword", id = 22028 },
[29] = { name = "Norseman Doll", id = 19150 },
[30] = { name = "Old Radio", id = 28894 },
[31] = { name = "Orc's Jaw Shredder", id = 19155 },
[32] = { name = "Phoenix Statue", id = 22026 },
[33] = { name = "Pigeon Trophy", id = 31266 },
[34] = { name = "Shield of Destiny", id = 43517 },
[35] = { name = "Shield of Endless Search", id = 37060 },
[36] = { name = "The Mexcalibur", id = 19154 },
[37] = { name = "Tibiora's Box", id = 43510 },
}

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

-- Implementing the "souvenir" message interaction
if MsgContains(message, "souvenir") then
npcHandler:say({
"In this category I can offer you a Norseman doll, an abacus, a key of numerous locks, a friendship amulet, a mexcalibur sword, an orc shredder, a frozen heart, a phoenix statue, a dragon eye and a noble sword. Or: ...",
"A hand puppet, a music box, an encyclopedia, a Durin doll, a medusa skull, a newspaper, a bag of spices or an Exhiti imortus. ...",
"A mathmaster shield, a draken doll, an emblem, a crimson doll, an old radio, a bookworm doll, a golden falcon and an assassin doll. ...",
"A dragon goblet, a pigeon trophy, a loremaster doll and a jade amulet. ...",
"All listed souvenirs are at 20 silver raid tokens each. Which one of them do you want?"
}, npc, creature)
npcHandler:setTopic(playerId, 1)
return true
end

-- Checking if the player responded with an item name after "souvenir"
if npcHandler:getTopic(playerId) == 1 then
for i = 1, #items do
if MsgContains(message, items[i].name) then
if getPlayerItemCount(creature, 19083) >= 20 then
doPlayerRemoveItem(creature, 19083, 20)
doPlayerAddItem(creature, items[i].id, 1)
npcHandler:say("You just swapped 20 silver raid tokens for 1 " .. items[i].name .. ".", npc, creature)
else
npcHandler:say("I'm sorry, I need at least 20 silver tokens for that. Please come back when you have them.", npc, creature)
end
npcHandler:setTopic(playerId, 0) -- Reset topic after processing
return true
end
end
end

return true
end

npcHandler:setCallback(CALLBACK_SET_INTERACTION, onAddFocus)
npcHandler:setCallback(CALLBACK_REMOVE_INTERACTION, onReleaseFocus)

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)

Expand Down
12 changes: 6 additions & 6 deletions data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22650,7 +22650,7 @@
<attribute key="maxtextlen" value="99"/>
<attribute key="weight" value="1000"/>
</item>
<item id="8152" article="the" name="Mexcalibur">
<item id="8152" article="the" name="mexcalibur">
<attribute key="description" value="Your name is carved on this mighty sword"/>
<attribute key="weight" value="1200"/>
</item>
Expand Down Expand Up @@ -39119,7 +39119,7 @@
<attribute key="slot" value="necklace"/>
</attribute>
</item>
<item id="19154" article="the" name="Mexcalibur">
<item id="19154" article="the" name="mexcalibur">
<attribute key="description" value="Souvenir from Thais Museum"/>
<attribute key="weight" value="1200"/>
</item>
Expand Down Expand Up @@ -64849,7 +64849,7 @@ hands of its owner. Granted by TibiaRoyal.com"/>
<attribute key="description" value="A fine but practically ancient wine. It's absolutely not advised to actually drink it"/>
<attribute key="weight" value="100"/>
</item>
<item id="34210" article="a" name="Goromaphone">
<item id="34210" article="a" name="goromaphone">
<attribute key="primarytype" value="fansite items"/>
<attribute key="description" value="Souvenir from Thais Museum"/>
<attribute key="weight" value="6659"/>
Expand Down Expand Up @@ -74817,15 +74817,15 @@ Granted by TibiaGoals.com"/>
<item id="43374" name="vine">
<attribute key="type" value="ladder"/>
</item>
<item id="43510" name="tibiora's box replica">
<item id="43510" name="tibiora's box">
<attribute key="description" value="Souvenir from Thais Museum."/>
<attribute key="weight" value="4200"/>
</item>
<item id="43511" article="a" name="citizen doll replica">
<item id="43511" article="a" name="citizen doll">
<attribute key="description" value="Souvenir from Thais Museum."/>
<attribute key="weight" value="2200"/>
</item>
<item id="43517" article="a" name="shield of destiny replica">
<item id="43517" article="a" name="shield of destiny">
<attribute key="description" value="Souvenir from Thais Museum."/>
<attribute key="weight" value="6800"/>
</item>
Expand Down

0 comments on commit 8823429

Please sign in to comment.