From 3842e43083b10aa129a9d77f9220da22367f6e76 Mon Sep 17 00:00:00 2001 From: valdzera <146901121+valdzera@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:48:51 -0300 Subject: [PATCH 1/3] feat: specific meal purchase option for hireling This update introduces a new feature for the hireling NPC, allowing players to choose specific meals for 90000 gold, aligning with the latest global updates. The NPC now prompts players with options for a "specific" or "surprise" meal, guiding them through the selection process. If "specific" is chosen, players are presented with a list of available dishes. --- data-otservbr-global/npc/hireling.lua | 52 +++++++++++++++------------ 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/data-otservbr-global/npc/hireling.lua b/data-otservbr-global/npc/hireling.lua index ce5c6737e02..9c8f3676c64 100644 --- a/data-otservbr-global/npc/hireling.lua +++ b/data-otservbr-global/npc/hireling.lua @@ -424,9 +424,10 @@ function createHirelingType(HirelingName) local GREETINGS = { BANK = "Alright! What can I do for you and your bank business, |PLAYERNAME|?", - FOOD = "Hmm, yes! A variety of fine food awaits! However, a small expense of 15000 gold is expected to make these delicious masterpieces happen. Shall I?", + FOOD = [[Hmm, yes! A variety of fine food awaits! However, a small expense of 15000 gold is expected to make these delicious masterpieces happen. + For 90000 gold I will also serve you a specific dish. Just tell me what it shall be: a {specific} meal or a little {surprise}.]], STASH = "Of course, here is your stash! Well-maintained and neatly sorted for your convenience!", - } + } local function getHirelingSkills() local skills = {} @@ -513,7 +514,7 @@ function createHirelingType(HirelingName) return message end - local function deliverFood(npc, creature, food_id) + local function deliverFood(npc, creature, food_id, cost) local playerId = creature:getId() local player = Player(creature) local itType = ItemType(food_id) @@ -523,8 +524,8 @@ function createHirelingType(HirelingName) npcHandler:say("Sorry, but you don't have enough capacity.", npc, creature) elseif not inbox or #inboxItems >= inbox:getMaxCapacity() then player:getPosition():sendMagicEffect(CONST_ME_POFF) - npcHandler:say("Sorry, you don't have enough room on your inbox", npc, creature) - elseif not player:removeMoneyBank(15000) then + npcHandler:say("Sorry, you don't have enough room on your inbox.", npc, creature) + elseif not player:removeMoneyBank(cost) then npcHandler:say("Sorry, you don't have enough money.", npc, creature) else local message = getDeliveredMessageByFoodId(food_id) @@ -534,36 +535,43 @@ function createHirelingType(HirelingName) npcHandler:setTopic(playerId, TOPIC.SERVICES) end - local function cookFood(npc, creature) + local function cookFood(npc, creature, specificRequest) local playerId = creature:getId() - local random = math.random(6) - if random == 6 then - -- ask for preferred skill + if specificRequest then + npcHandler:say("Very well. You may choose one of the following: {chilli con carniphila}, {svargrond salmon filet}, {carrion casserole}, {consecrated beef}, {roasted wyvern wings}, {carrot pie}, {tropical marinated tiger}, or {delicatessen salad}.", npc, creature) npcHandler:setTopic(playerId, TOPIC_FOOD.SKILL_CHOOSE) - npcHandler:say("Yay! I have the ingredients to make a skill boost dish. Would you rather like to boost your {magic}, {melee}, {shielding} or {distance} skill?", npc, creature) - else -- deliver the random generated index - deliverFood(npc, creature, HIRELING_FOODS_IDS[random]) + else + npcHandler:say("Alright, let me astonish you. Shall I?", npc, creature) + deliverFood(npc, creature, HIRELING_FOODS_IDS[math.random(#HIRELING_FOODS_IDS)], 15000) end end local function handleFoodActions(npc, creature, message) local playerId = creature:getId() if npcHandler:getTopic(playerId) == TOPIC.FOOD then - if MsgContains(message, "yes") then - cookFood(npc, creature) + if MsgContains(message, "specific") then + cookFood(npc, creature, true) + elseif MsgContains(message, "surprise") then + cookFood(npc, creature, false) + elseif MsgContains(message, "yes") then + deliverFood(npc, creature, HIRELING_FOODS_IDS[math.random(#HIRELING_FOODS_IDS)], 15000) elseif MsgContains(message, "no") then npcHandler:setTopic(playerId, TOPIC.SERVICES) npcHandler:say("Alright then, ask me for other {services}, if you want.", npc, creature) end elseif npcHandler:getTopic(playerId) == TOPIC_FOOD.SKILL_CHOOSE then - if MsgContains(message, "magic") then - deliverFood(npc, creature, HIRELING_FOODS_BOOST.MAGIC) - elseif MsgContains(message, "melee") then - deliverFood(npc, creature, HIRELING_FOODS_BOOST.MELEE) - elseif MsgContains(message, "shielding") then - deliverFood(npc, creature, HIRELING_FOODS_BOOST.SHIELDING) - elseif MsgContains(message, "distance") then - deliverFood(npc, creature, HIRELING_FOODS_BOOST.DISTANCE) + local foodOptions = { + ["chilli con carniphila"] = 29412, + ["svargrond salmon filet"] = 29413, + ["carrion casserole"] = 29414, + ["consecrated beef"] = 29415, + ["roasted wyvern wings"] = 29408, + ["carrot pie"] = 29409, + ["tropical marinated tiger"] = 29410, + ["delicatessen salad"] = 29411 + } + if foodOptions[message:lower()] then + deliverFood(npc, creature, foodOptions[message:lower()], 90000) else npcHandler:say("Sorry, but you must choose a valid skill class. Would you like to boost your {magic}, {melee}, {shielding} or {distance} skill?", npc, creature) end From 55e1c60cda3ec03ff935f60d3efe9dedb343357e Mon Sep 17 00:00:00 2001 From: valdzera <146901121+valdzera@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:53:40 -0300 Subject: [PATCH 2/3] fix: add option for random skill food selection in surprise choice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Players couldn’t be randomly chosen to select skill-boosting foods. this fix reintroduces the chance to choose a skill dish if selected as a surprise. --- data-otservbr-global/npc/hireling.lua | 40 +++++++++++++++++++++------ 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/data-otservbr-global/npc/hireling.lua b/data-otservbr-global/npc/hireling.lua index 9c8f3676c64..4759931c5b3 100644 --- a/data-otservbr-global/npc/hireling.lua +++ b/data-otservbr-global/npc/hireling.lua @@ -420,6 +420,7 @@ function createHirelingType(HirelingName) local TOPIC_FOOD = { SKILL_CHOOSE = 1301, + SKILL_SURPRISE = 1302, } local GREETINGS = { @@ -548,19 +549,41 @@ function createHirelingType(HirelingName) local function handleFoodActions(npc, creature, message) local playerId = creature:getId() + if npcHandler:getTopic(playerId) == TOPIC.FOOD then if MsgContains(message, "specific") then - cookFood(npc, creature, true) + npcHandler:setTopic(playerId, TOPIC_FOOD.SPECIFIC) + npcHandler:say("Which specific meal would you like? Choices are: {chilli con carniphila}, {svargrond salmon filet}, {carrion casserole}, {consecrated beef}, {roasted wyvern wings}, {carrot pie}, {tropical marinated tiger}, or {delicatessen salad}.", npc, creature) elseif MsgContains(message, "surprise") then - cookFood(npc, creature, false) + local random = math.random(6) + if random == 6 then + npcHandler:setTopic(playerId, TOPIC_FOOD.SKILL_CHOOSE) + npcHandler:say("Yay! I have the ingredients to make a skill boost dish. Would you rather like to boost your {magic}, {melee}, {shielding}, or {distance} skill?", npc, creature) + else + deliverFood(npc, creature, HIRELING_FOODS_IDS[random], 15000) + end elseif MsgContains(message, "yes") then deliverFood(npc, creature, HIRELING_FOODS_IDS[math.random(#HIRELING_FOODS_IDS)], 15000) elseif MsgContains(message, "no") then npcHandler:setTopic(playerId, TOPIC.SERVICES) npcHandler:say("Alright then, ask me for other {services}, if you want.", npc, creature) end + elseif npcHandler:getTopic(playerId) == TOPIC_FOOD.SKILL_CHOOSE then - local foodOptions = { + if MsgContains(message, "magic") then + deliverFood(npc, creature, HIRELING_FOODS_BOOST.MAGIC, 15000) + elseif MsgContains(message, "melee") then + deliverFood(npc, creature, HIRELING_FOODS_BOOST.MELEE, 15000) + elseif MsgContains(message, "shielding") then + deliverFood(npc, creature, HIRELING_FOODS_BOOST.SHIELDING, 15000) + elseif MsgContains(message, "distance") then + deliverFood(npc, creature, HIRELING_FOODS_BOOST.DISTANCE, 15000) + else + npcHandler:say("Sorry, but you must choose a valid skill class. Would you like to boost your {magic}, {melee}, {shielding}, or {distance} skill?", npc, creature) + end + + elseif npcHandler:getTopic(playerId) == TOPIC_FOOD.SPECIFIC then + local specificFoodOptions = { ["chilli con carniphila"] = 29412, ["svargrond salmon filet"] = 29413, ["carrion casserole"] = 29414, @@ -570,10 +593,11 @@ function createHirelingType(HirelingName) ["tropical marinated tiger"] = 29410, ["delicatessen salad"] = 29411 } - if foodOptions[message:lower()] then - deliverFood(npc, creature, foodOptions[message:lower()], 90000) + + if specificFoodOptions[message:lower()] then + deliverFood(npc, creature, specificFoodOptions[message:lower()], 90000) else - npcHandler:say("Sorry, but you must choose a valid skill class. Would you like to boost your {magic}, {melee}, {shielding} or {distance} skill?", npc, creature) + npcHandler:say("I'm sorry, but that's not a valid food option. Please choose from: {chilli con carniphila}, {svargrond salmon filet}, {carrion casserole}, {consecrated beef}, {roasted wyvern wings}, {carrot pie}, {tropical marinated tiger}, or {delicatessen salad}.", npc, creature) end end end @@ -664,7 +688,7 @@ function createHirelingType(HirelingName) end elseif npcHandler:getTopic(playerId) == TOPIC.BANK then enableBankSystem[playerId] = true - elseif npcHandler:getTopic(playerId) == TOPIC.FOOD or npcHandler:getTopic(playerId) == TOPIC_FOOD.SKILL_CHOOSE then + elseif npcHandler:getTopic(playerId) == TOPIC.FOOD or npcHandler:getTopic(playerId) == TOPIC_FOOD.SKILL_CHOOSE or npcHandler:getTopic(playerId) == TOPIC_FOOD.SPECIFIC then handleFoodActions(npc, creature, message) elseif npcHandler:getTopic(playerId) == TOPIC.GOODS then -- Ensures players cannot access other shop categories @@ -709,4 +733,4 @@ function createHirelingType(HirelingName) npcType:register(npcConfig) end -createHirelingType("Hireling") +createHirelingType("Hireling") \ No newline at end of file From fe99a3a60ea02d028196095691e9b7e9796760d4 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 19 Nov 2024 15:44:44 +0000 Subject: [PATCH 3/3] Lua code format - (Stylua) --- data-otservbr-global/npc/hireling.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/data-otservbr-global/npc/hireling.lua b/data-otservbr-global/npc/hireling.lua index 4759931c5b3..bfc9000ca0f 100644 --- a/data-otservbr-global/npc/hireling.lua +++ b/data-otservbr-global/npc/hireling.lua @@ -428,7 +428,7 @@ function createHirelingType(HirelingName) FOOD = [[Hmm, yes! A variety of fine food awaits! However, a small expense of 15000 gold is expected to make these delicious masterpieces happen. For 90000 gold I will also serve you a specific dish. Just tell me what it shall be: a {specific} meal or a little {surprise}.]], STASH = "Of course, here is your stash! Well-maintained and neatly sorted for your convenience!", - } + } local function getHirelingSkills() local skills = {} @@ -549,7 +549,7 @@ function createHirelingType(HirelingName) local function handleFoodActions(npc, creature, message) local playerId = creature:getId() - + if npcHandler:getTopic(playerId) == TOPIC.FOOD then if MsgContains(message, "specific") then npcHandler:setTopic(playerId, TOPIC_FOOD.SPECIFIC) @@ -568,7 +568,6 @@ function createHirelingType(HirelingName) npcHandler:setTopic(playerId, TOPIC.SERVICES) npcHandler:say("Alright then, ask me for other {services}, if you want.", npc, creature) end - elseif npcHandler:getTopic(playerId) == TOPIC_FOOD.SKILL_CHOOSE then if MsgContains(message, "magic") then deliverFood(npc, creature, HIRELING_FOODS_BOOST.MAGIC, 15000) @@ -581,7 +580,6 @@ function createHirelingType(HirelingName) else npcHandler:say("Sorry, but you must choose a valid skill class. Would you like to boost your {magic}, {melee}, {shielding}, or {distance} skill?", npc, creature) end - elseif npcHandler:getTopic(playerId) == TOPIC_FOOD.SPECIFIC then local specificFoodOptions = { ["chilli con carniphila"] = 29412, @@ -591,9 +589,9 @@ function createHirelingType(HirelingName) ["roasted wyvern wings"] = 29408, ["carrot pie"] = 29409, ["tropical marinated tiger"] = 29410, - ["delicatessen salad"] = 29411 + ["delicatessen salad"] = 29411, } - + if specificFoodOptions[message:lower()] then deliverFood(npc, creature, specificFoodOptions[message:lower()], 90000) else @@ -733,4 +731,4 @@ function createHirelingType(HirelingName) npcType:register(npcConfig) end -createHirelingType("Hireling") \ No newline at end of file +createHirelingType("Hireling")