diff --git a/data-otservbr-global/lib/core/storages.lua b/data-otservbr-global/lib/core/storages.lua index db7ab08090d..4e63d0d6bc5 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -1174,6 +1174,7 @@ Storage = { Questline = 51538, MiningHelmet = 51539, }, + -- TowerDefenceQuest: when there is space, bring this quest that is in update 8.1 to Tibia Tales }, TheShatteredIsles = { -- Reserved storage from 51540 - 51589 @@ -2081,8 +2082,10 @@ Storage = { Mission06 = 41396, Mission07 = 41397, }, - ToOutfoxAFox = {}, - TowerDefence = {}, + TowerDefenceQuest = { + Questline = 41398, + Door = 41399, + }, Waterfall = {}, WhatAFoolish = {}, }, diff --git a/data-otservbr-global/monster/humanoids/goblin_leader.lua b/data-otservbr-global/monster/humanoids/goblin_leader.lua index 0f6f5d62a44..a442d25574b 100644 --- a/data-otservbr-global/monster/humanoids/goblin_leader.lua +++ b/data-otservbr-global/monster/humanoids/goblin_leader.lua @@ -42,6 +42,10 @@ monster.strategiesTarget = { nearest = 100, } +monster.events = { + "GoblinLeaderDeath", +} + monster.flags = { summonable = true, attackable = true, diff --git a/data-otservbr-global/npc/bunny_bonecrusher.lua b/data-otservbr-global/npc/bunny_bonecrusher.lua index 6a926df382a..43869dd9b5d 100644 --- a/data-otservbr-global/npc/bunny_bonecrusher.lua +++ b/data-otservbr-global/npc/bunny_bonecrusher.lua @@ -50,6 +50,45 @@ 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() + + -- Check if NPC can interact with the creature + if not npcHandler:checkInteraction(npc, creature) then + return false + end + + -- Check if the message contains "mission" + if MsgContains(message, "mission") then + if player:getStorageValue(Storage.Quest.U8_1.TowerDefenceQuest.Questline) < 1 then + npcHandler:say({ + "Normally we don't assign missions to civilians - and particularly to MALE civilians - but in this case I think we can make an exception. ...", + "I need a courier to deliver a parcel to the watchtower in Femor Hills. You think you can handle that??", + }, npc, creature) + npcHandler:setTopic(playerId, 1) + elseif player:getStorageValue(Storage.Quest.U8_1.TowerDefenceQuest.Questline) == 4 then + npcHandler:say("Alright, you delivered the parcel. So what is the password Thanita told you?", npc, creature) + npcHandler:setTopic(playerId, 2) + end + elseif npcHandler:getTopic(playerId) == 1 and MsgContains(message, "yes") then + npcHandler:say("I am not sure if I should be glad now or not but anyway ... you will get a password so I will know if you just threw it away or actually delivered it. Here is the parcel. See you ....or not.", npc, creature) + player:addItem(140, 1) + player:setStorageValue(Storage.Quest.U8_1.TowerDefenceQuest.Questline, 1) + npcHandler:setTopic(playerId, 0) + elseif npcHandler:getTopic(playerId) == 2 and MsgContains(message, "password*") then + npcHandler:say("That's right. Here is your reward some elementary arrows. You did pretty well on your mission!", npc, creature) + player:addItem(762, 50) + player:addItem(774, 50) + player:addItem(763, 50) + player:addItem(761, 50) + player:setStorageValue(Storage.Quest.U8_1.TowerDefenceQuest.Questline, 5) + npcHandler:setTopic(playerId, 0) + end + + return true +end + keywordHandler:addKeyword({ "hail general" }, StdModule.say, { npcHandler = npcHandler, text = "Salutations, commoner |PLAYERNAME|!" }) keywordHandler:addKeyword({ "how", "are", "you" }, StdModule.say, { npcHandler = npcHandler, text = "We are in constant training and in perfect health." }) keywordHandler:addKeyword({ "job" }, StdModule.say, { npcHandler = npcHandler, text = "I am the general of the queen's army. I don't have time to explain this concept to you." }) @@ -67,6 +106,13 @@ keywordHandler:addKeyword({ "green ferrets" }, StdModule.say, { npcHandler = npc keywordHandler:addKeyword({ "join" }, StdModule.say, { npcHandler = npcHandler, text = "Join what?" }) keywordHandler:addKeyword({ "join army" }, StdModule.say, { npcHandler = npcHandler, text = "Sorry, we don't recruit foreigners. Maybe you can join if you prove yourself in a mission for the queen." }) + +npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) + +npcHandler:setMessage(MESSAGE_GREET, "Address me properly |PLAYERNAME|!") +npcHandler:setMessage(MESSAGE_WALKAWAY, "LONG LIVE THE QUEEN!") +npcHandler:setMessage(MESSAGE_FAREWELL, "LONG LIVE THE QUEEN!") + npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true) -- npcType registering the npcConfig table diff --git a/data-otservbr-global/npc/thanita.lua b/data-otservbr-global/npc/thanita.lua index 43a61f8e0d7..452313c79ee 100644 --- a/data-otservbr-global/npc/thanita.lua +++ b/data-otservbr-global/npc/thanita.lua @@ -50,6 +50,43 @@ 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() + + -- Check if NPC can interact with the creature + if not npcHandler:checkInteraction(npc, creature) then + return false + end + + -- Check if the message contains "mission" + if MsgContains(message, "mission") then + if player:getStorageValue(Storage.Quest.U8_1.TowerDefenceQuest.Questline) == 1 and player:removeItem(140, 1) then + npcHandler:say({ + "Oh great! Supplies from Carlin! Let me see ......ahh, nothing meaningful at all, like always. Well, before I give you the password for the delivery, you have to help me! ...", + "I have massive problems with the goblin tribe that lives here. You look strong enough to face their leader but you need to be smart to lure him out. ...", + "I heard they don't like fire very much, maybe that's worth a try. Their beds are mostly made of straw which is known as easily inflammable. ...", + "The entrance to their cave is at the pond south east of here.", + }, npc, creature) + player:setStorageValue(Storage.Quest.U8_1.TowerDefenceQuest.Questline, 2) + player:setStorageValue(Storage.Quest.U8_1.TowerDefenceQuest.Door, 2) + npcHandler:setTopic(playerId, 0) + elseif player:getStorageValue(Storage.Quest.U8_1.TowerDefenceQuest.Questline) == 3 then + npcHandler:say("Impressive!! I could need someone like you here at the watchtower! Okay, the password you need to tell Bunny is ' password* '. Come back and visit me if you like to!", npc, creature) + player:setStorageValue(Storage.Quest.U8_1.TowerDefenceQuest.Questline, 4) + npcHandler:setTopic(playerId, 0) + end + end + + return true +end + +npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) + +npcHandler:setMessage(MESSAGE_GREET, "How could you sneak up on me like this? I thought you were one of THEM! Well, since you are not, what brings you to this wilderness?") +npcHandler:setMessage(MESSAGE_WALKAWAY, "Take good care of yourself traveller. Would be a shame to lose such a courageous wanderer to those green monsters.") +npcHandler:setMessage(MESSAGE_FAREWELL, "Take good care of yourself traveller. Would be a shame to lose such a courageous wanderer to those green monsters.") + npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true) -- npcType registering the npcConfig table diff --git a/data-otservbr-global/scripts/quests/tower_defence_quest/creaturescripts_goblin_leader_kill.lua b/data-otservbr-global/scripts/quests/tower_defence_quest/creaturescripts_goblin_leader_kill.lua new file mode 100644 index 00000000000..15358e22fb8 --- /dev/null +++ b/data-otservbr-global/scripts/quests/tower_defence_quest/creaturescripts_goblin_leader_kill.lua @@ -0,0 +1,13 @@ +local creaturescripts_goblin_leader_kill = CreatureEvent("GoblinLeaderDeath") + +function creaturescripts_goblin_leader_kill.onDeath(creature) + onDeathForDamagingPlayers(creature, function(creature, player) + if player:getStorageValue(Storage.Quest.U8_1.TowerDefenceQuest.Questline) == 2 then + player:setStorageValue(Storage.Quest.U8_1.TowerDefenceQuest.Questline, 3) + end + end) + + return true +end + +creaturescripts_goblin_leader_kill:register() diff --git a/data-otservbr-global/startup/tables/door_quest.lua b/data-otservbr-global/startup/tables/door_quest.lua index 9d70115026f..d3642d0e862 100644 --- a/data-otservbr-global/startup/tables/door_quest.lua +++ b/data-otservbr-global/startup/tables/door_quest.lua @@ -927,6 +927,12 @@ QuestDoorAction = { { x = 32204, y = 31022, z = 14 }, }, }, + [Storage.Quest.U8_1.TowerDefenceQuest.Door] = { + itemId = 6258, + itemPos = { + { x = 32600, y = 31758, z = 9 }, + }, + }, } QuestDoorUnique = {