Skip to content

Commit

Permalink
Tower Defence Quest
Browse files Browse the repository at this point in the history
  • Loading branch information
htc16 committed Jul 25, 2024
1 parent 0e0f43a commit 6e365e7
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 2 deletions.
7 changes: 5 additions & 2 deletions data-otservbr-global/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2081,8 +2082,10 @@ Storage = {
Mission06 = 41396,
Mission07 = 41397,
},
ToOutfoxAFox = {},
TowerDefence = {},
TowerDefenceQuest = {
Questline = 41398,
Door = 41399,
},
Waterfall = {},
WhatAFoolish = {},
},
Expand Down
4 changes: 4 additions & 0 deletions data-otservbr-global/monster/humanoids/goblin_leader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ monster.strategiesTarget = {
nearest = 100,
}

monster.events = {
"GoblinLeaderDeath",
}

monster.flags = {
summonable = true,
attackable = true,
Expand Down
46 changes: 46 additions & 0 deletions data-otservbr-global/npc/bunny_bonecrusher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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." })
Expand All @@ -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
Expand Down
37 changes: 37 additions & 0 deletions data-otservbr-global/npc/thanita.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...<she digs into the parcel>...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
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
6 changes: 6 additions & 0 deletions data-otservbr-global/startup/tables/door_quest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 6e365e7

Please sign in to comment.