From 0f8929d614cae30270f43c090a76421a513220cd Mon Sep 17 00:00:00 2001 From: Majesty <32709570+majestyotbr@users.noreply.github.com> Date: Thu, 29 Aug 2024 08:55:41 -0300 Subject: [PATCH 1/4] fix: price mismatch between NPCs and typo in the rent house message (#2830) Monitoring feature to alert whenever there's a price mismatch between NPCs for item transactions. This ensures any instance where an item is sold for less than its purchase price, or vice versa, is promptly identified and reported. Co-authored-by: Leilani A. <168607226+kaleohanopahala@users.noreply.github.com> --- data-otservbr-global/npc/arito.lua | 3 - data-otservbr-global/npc/armenius.lua | 2 - data-otservbr-global/npc/bolfona.lua | 1 - data-otservbr-global/npc/boozer.lua | 2 - data-otservbr-global/npc/clyde.lua | 3 - data-otservbr-global/npc/dane.lua | 2 - data-otservbr-global/npc/maria.lua | 2 - data-otservbr-global/npc/mirabell.lua | 3 - data-otservbr-global/npc/miraia.lua | 2 - data-otservbr-global/npc/norma.lua | 3 - data-otservbr-global/npc/pugwah.lua | 3 - data-otservbr-global/npc/ramina.lua | 4 +- data-otservbr-global/npc/red_lilly.lua | 2 +- data-otservbr-global/npc/swolt.lua | 2 - data-otservbr-global/npc/tanaro.lua | 2 - data-otservbr-global/npc/urkalio.lua | 3 - data/scripts/lib/register_npc_type.lua | 76 ++++++++++++++++++-------- src/map/house/house.cpp | 2 +- 18 files changed, 57 insertions(+), 60 deletions(-) diff --git a/data-otservbr-global/npc/arito.lua b/data-otservbr-global/npc/arito.lua index caa33f8348f..1eab9a186c3 100644 --- a/data-otservbr-global/npc/arito.lua +++ b/data-otservbr-global/npc/arito.lua @@ -134,9 +134,6 @@ npcConfig.shop = { { itemName = "mug of lemonade", clientId = 2880, buy = 2, count = 12 }, { itemName = "mug of water", clientId = 2880, buy = 1, count = 1 }, { itemName = "mug of wine", clientId = 2880, buy = 3, count = 2 }, - { itemName = "vial of beer", clientId = 2874, buy = 2, count = 1, subType = 3 }, - { itemName = "vial of wine", clientId = 2874, buy = 3, count = 1, subType = 2 }, - { itemName = "vial of water", clientId = 2874, buy = 1, count = 1 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/armenius.lua b/data-otservbr-global/npc/armenius.lua index 8b24dc1d419..9164a78240e 100644 --- a/data-otservbr-global/npc/armenius.lua +++ b/data-otservbr-global/npc/armenius.lua @@ -97,8 +97,6 @@ npcConfig.shop = { { itemName = "mug of rum", clientId = 2880, buy = 10, count = 13 }, { itemName = "mug of wine", clientId = 2880, buy = 4, count = 2 }, { itemName = "tomato", clientId = 3596, buy = 3 }, - { itemName = "vial of beer", clientId = 2874, buy = 3, count = 1, subType = 3 }, - { itemName = "vial of wine", clientId = 2874, buy = 4, count = 1, subType = 2 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/bolfona.lua b/data-otservbr-global/npc/bolfona.lua index 83ee91f7ac9..adf900568ff 100644 --- a/data-otservbr-global/npc/bolfona.lua +++ b/data-otservbr-global/npc/bolfona.lua @@ -103,7 +103,6 @@ npcConfig.shop = { { itemName = "ham", clientId = 3582, buy = 8 }, { itemName = "meat", clientId = 3577, buy = 5 }, { itemName = "mug of beer", clientId = 2880, buy = 2, count = 3 }, - { itemName = "vial of beer", clientId = 2874, buy = 2, count = 1, subType = 3 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/boozer.lua b/data-otservbr-global/npc/boozer.lua index a2eaa22d179..b63fa7620fb 100644 --- a/data-otservbr-global/npc/boozer.lua +++ b/data-otservbr-global/npc/boozer.lua @@ -98,8 +98,6 @@ npcConfig.shop = { { itemName = "mug of lemonade", clientId = 2880, buy = 2, count = 12 }, { itemName = "mug of water", clientId = 2880, buy = 2, count = 1 }, { itemName = "mug of wine", clientId = 2880, buy = 3, count = 2 }, - { itemName = "vial of beer", clientId = 2874, buy = 2, count = 1, subType = 3 }, - { itemName = "vial of wine", clientId = 2874, buy = 3, count = 1, subType = 2 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/clyde.lua b/data-otservbr-global/npc/clyde.lua index 4142cee2cbc..fcaf9ea011a 100644 --- a/data-otservbr-global/npc/clyde.lua +++ b/data-otservbr-global/npc/clyde.lua @@ -64,9 +64,6 @@ npcConfig.shop = { { itemName = "mug of water", clientId = 2880, buy = 2, count = 1 }, { itemName = "mug of wine", clientId = 2880, buy = 3, count = 2 }, { itemName = "tomato", clientId = 3596, buy = 3 }, - { itemName = "vial of beer", clientId = 2874, buy = 2, count = 1, subType = 3 }, - { itemName = "vial of wine", clientId = 2874, buy = 3, count = 1, subType = 2 }, - { itemName = "vial of water", clientId = 2874, buy = 1, count = 1 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/dane.lua b/data-otservbr-global/npc/dane.lua index f2dd71762c0..c2e3c612414 100644 --- a/data-otservbr-global/npc/dane.lua +++ b/data-otservbr-global/npc/dane.lua @@ -67,8 +67,6 @@ npcConfig.shop = { { itemName = "bottle of lemonade", clientId = 2875, buy = 12, count = 12 }, { itemName = "bottle of milk", clientId = 2875, buy = 4, count = 9 }, { itemName = "bottle of water", clientId = 2875, buy = 2, count = 1 }, - { itemName = "vial of milk", clientId = 2874, buy = 4, count = 1, subType = 9 }, - { itemName = "vial of water", clientId = 2874, buy = 2, count = 1 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/maria.lua b/data-otservbr-global/npc/maria.lua index 74780e4a85a..7c63e11ac02 100644 --- a/data-otservbr-global/npc/maria.lua +++ b/data-otservbr-global/npc/maria.lua @@ -65,8 +65,6 @@ npcConfig.shop = { { itemName = "mug of wine", clientId = 2880, buy = 3, count = 2 }, { itemName = "tomato", clientId = 3596, buy = 5 }, { itemName = "valentine's cake", clientId = 6392, buy = 100 }, - { itemName = "vial of beer", clientId = 2874, buy = 2, count = 1, subType = 3 }, - { itemName = "vial of wine", clientId = 2874, buy = 3, count = 1, subType = 2 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/mirabell.lua b/data-otservbr-global/npc/mirabell.lua index 06362976254..db5f256ccd4 100644 --- a/data-otservbr-global/npc/mirabell.lua +++ b/data-otservbr-global/npc/mirabell.lua @@ -134,9 +134,6 @@ npcConfig.shop = { { itemName = "mug of lemonade", clientId = 2880, buy = 2, count = 12 }, { itemName = "mug of water", clientId = 2880, buy = 1, count = 1 }, { itemName = "mug of wine", clientId = 2880, buy = 3, count = 2 }, - { itemName = "vial of beer", clientId = 2874, buy = 2, count = 1, subType = 3 }, - { itemName = "vial of wine", clientId = 2874, buy = 3, count = 1, subType = 2 }, - { itemName = "vial of water", clientId = 2874, buy = 1, count = 1 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/miraia.lua b/data-otservbr-global/npc/miraia.lua index ad74b08040e..d8fbf586f2a 100644 --- a/data-otservbr-global/npc/miraia.lua +++ b/data-otservbr-global/npc/miraia.lua @@ -200,8 +200,6 @@ npcConfig.shop = { { itemName = "mug of milk", clientId = 2880, buy = 5, count = 9 }, { itemName = "mug of water", clientId = 2880, buy = 2, count = 1 }, { itemName = "scarab cheese", clientId = 169, buy = 100 }, - { itemName = "vial of milk", clientId = 2874, buy = 5, count = 1, subType = 9 }, - { itemName = "vial of water", clientId = 2874, buy = 2, count = 1 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/norma.lua b/data-otservbr-global/npc/norma.lua index 769bf7b7b3f..693dc7fadbb 100644 --- a/data-otservbr-global/npc/norma.lua +++ b/data-otservbr-global/npc/norma.lua @@ -200,9 +200,6 @@ npcConfig.shop = { { itemName = "mug of milk", clientId = 2880, buy = 2, count = 6 }, { itemName = "mug of wine", clientId = 2880, buy = 3, count = 2 }, { itemName = "party cake", clientId = 6279, buy = 50 }, - { itemName = "vial of beer", clientId = 2874, buy = 3, count = 1, subType = 3 }, - { itemName = "vial of wine", clientId = 2874, buy = 3, count = 1, subType = 2 }, - { itemName = "vial of milk", clientId = 2874, buy = 2, count = 1, subType = 9 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/pugwah.lua b/data-otservbr-global/npc/pugwah.lua index e9c0874d5aa..9e9007a7667 100644 --- a/data-otservbr-global/npc/pugwah.lua +++ b/data-otservbr-global/npc/pugwah.lua @@ -61,9 +61,6 @@ npcConfig.shop = { { itemName = "mug of lemonade", clientId = 2880, buy = 2, count = 12 }, { itemName = "mug of milk", clientId = 2880, buy = 2, count = 6 }, { itemName = "mug of wine", clientId = 2880, buy = 3, count = 2 }, - { itemName = "vial of beer", clientId = 2874, buy = 3, count = 1, subType = 3 }, - { itemName = "vial of wine", clientId = 2874, buy = 4, count = 1, subType = 2 }, - { itemName = "vial of water", clientId = 2874, buy = 2, count = 1 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/ramina.lua b/data-otservbr-global/npc/ramina.lua index d88b305aaeb..f9b253c477e 100644 --- a/data-otservbr-global/npc/ramina.lua +++ b/data-otservbr-global/npc/ramina.lua @@ -64,9 +64,7 @@ npcConfig.shop = { { itemName = "mug of wine", clientId = 2880, buy = 15, count = 2 }, { itemName = "orange", clientId = 3586, buy = 12 }, { itemName = "peas", clientId = 11683, buy = 5 }, - { itemName = "vial of fruit juice", clientId = 2874, buy = 10, count = 14 }, - { itemName = "vial of water", clientId = 2874, buy = 2, count = 1 }, - { itemName = "vial of wine", clientId = 2874, buy = 15, count = 1, subType = 2 }, + { itemName = "vial of water", clientId = 2874, buy = 10, count = 1 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/red_lilly.lua b/data-otservbr-global/npc/red_lilly.lua index 357cb02775b..b744fae905d 100644 --- a/data-otservbr-global/npc/red_lilly.lua +++ b/data-otservbr-global/npc/red_lilly.lua @@ -85,7 +85,7 @@ npcConfig.shop = { { itemName = "torch", clientId = 2920, buy = 2 }, { itemName = "vial", clientId = 2874, sell = 5 }, { itemName = "vial of oil", clientId = 2874, buy = 20, count = 7 }, - { itemName = "vial of water", clientId = 2874, buy = 10, count = 1 }, + { itemName = "vial of water", clientId = 2874, buy = 20, count = 1 }, { itemName = "watch", clientId = 2906, buy = 20, sell = 6 }, { itemName = "waterskin of water", clientId = 2901, buy = 10, count = 1 }, { itemName = "wooden hammer", clientId = 3459, sell = 15 }, diff --git a/data-otservbr-global/npc/swolt.lua b/data-otservbr-global/npc/swolt.lua index 7caa8aa4160..5d8a7b48830 100644 --- a/data-otservbr-global/npc/swolt.lua +++ b/data-otservbr-global/npc/swolt.lua @@ -86,8 +86,6 @@ npcConfig.shop = { { itemName = "mug of beer", clientId = 2880, buy = 2, count = 3 }, { itemName = "mug of water", clientId = 2880, buy = 1, count = 1 }, { itemName = "terramite eggs", clientId = 10453, sell = 50 }, - { itemName = "vial of beer", clientId = 2874, buy = 2, count = 1, subType = 3 }, - { itemName = "vial of water", clientId = 2874, buy = 1, count = 1 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/tanaro.lua b/data-otservbr-global/npc/tanaro.lua index 467b70989ae..bf43db15d79 100644 --- a/data-otservbr-global/npc/tanaro.lua +++ b/data-otservbr-global/npc/tanaro.lua @@ -67,8 +67,6 @@ npcConfig.shop = { { itemName = "salmon", clientId = 3579, buy = 6 }, { itemName = "valentine's cake", clientId = 6392, buy = 100 }, { itemName = "white mushroom", clientId = 3723, buy = 6 }, - { itemName = "vial of wine", clientId = 2874, buy = 3, count = 1, subType = 2 }, - { itemName = "vial of water", clientId = 2874, buy = 2, count = 1 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data-otservbr-global/npc/urkalio.lua b/data-otservbr-global/npc/urkalio.lua index 5919a42d761..dbcbbc238b1 100644 --- a/data-otservbr-global/npc/urkalio.lua +++ b/data-otservbr-global/npc/urkalio.lua @@ -62,9 +62,6 @@ npcConfig.shop = { { itemName = "mug of lemonade", clientId = 2880, buy = 2, count = 12 }, { itemName = "mug of water", clientId = 2880, buy = 1, count = 1 }, { itemName = "mug of wine", clientId = 2880, buy = 3, count = 2 }, - { itemName = "vial of beer", clientId = 2874, buy = 2, count = 1, subType = 3 }, - { itemName = "vial of wine", clientId = 2874, buy = 3, count = 1, subType = 2 }, - { itemName = "vial of water", clientId = 2874, buy = 1, count = 1 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) diff --git a/data/scripts/lib/register_npc_type.lua b/data/scripts/lib/register_npc_type.lua index 53a5d525e59..e191bbbe240 100644 --- a/data/scripts/lib/register_npc_type.lua +++ b/data/scripts/lib/register_npc_type.lua @@ -141,25 +141,57 @@ registerNpcType.events = function(npcType, mask) end end +-- Global item tracker to track buy and sell prices across all NPCs +NpcPriceChecker = NpcPriceChecker or {} + registerNpcType.shop = function(npcType, mask) if type(mask.shop) == "table" then for _, shopItems in pairs(mask.shop) do local parent = Shop() - if shopItems.itemName or shopItems.itemname then - parent:setNameItem(shopItems.itemName or shopItems.itemname) + local itemName = shopItems.itemName or shopItems.itemname + local clientId = shopItems.clientId or shopItems.clientid + local buyPrice = shopItems.buy + local sellPrice = shopItems.sell + local npcName = npcType:getName() -- Assuming `npcType` has a `getName` method to get the NPC's name + + if itemName then + parent:setNameItem(itemName) end - if shopItems.clientId or shopItems.clientid then - parent:setId(shopItems.clientId or shopItems.clientid) + if clientId then + parent:setId(clientId) end if shopItems.subType or shopItems.subtype or shopItems.count then parent:setCount(shopItems.subType or shopItems.subtype or shopItems.count) end - if shopItems.buy then - parent:setBuyPrice(shopItems.buy) + if buyPrice then + parent:setBuyPrice(buyPrice) + end + if sellPrice then + parent:setSellPrice(sellPrice) end - if shopItems.sell then - parent:setSellPrice(shopItems.sell) + + if clientId then + if not NpcPriceChecker[clientId] then + NpcPriceChecker[clientId] = { buy = nil, sell = nil, buyNpc = nil, sellNpc = nil } + end + + if buyPrice then + NpcPriceChecker[clientId].buy = buyPrice + NpcPriceChecker[clientId].buyNpc = npcName + end + + if sellPrice then + NpcPriceChecker[clientId].sell = sellPrice + NpcPriceChecker[clientId].sellNpc = npcName + end + + if NpcPriceChecker[clientId].buy and NpcPriceChecker[clientId].sell then + if NpcPriceChecker[clientId].sell > NpcPriceChecker[clientId].buy then + logger.warn("The item {} ({}) is being sold for a value greater than the value it is purchased for by the NPCs. Buy NPC: {}, Sell NPC: {}", itemName, clientId, NpcPriceChecker[clientId].buyNpc, NpcPriceChecker[clientId].sellNpc) + end + end end + if shopItems.storageKey or shopItems.storagekey then parent:setStorageKey(shopItems.storageKey or shopItems.storagekey) end @@ -169,26 +201,26 @@ registerNpcType.shop = function(npcType, mask) if shopItems.child then for _, children in pairs(shopItems.child) do local child = Shop() - if shopItems.itemName or shopItems.itemname then - child:setNameItem(shopItems.itemName or shopItems.itemname) + if children.itemName or children.itemname then + child:setNameItem(children.itemName or children.itemname) end - if shopItems.clientId or shopItems.clientid then - child:setId(shopItems.clientId or shopItems.clientid) + if children.clientId or children.clientid then + child:setId(children.clientId or children.clientid) end - if shopItems.subType or shopItems.subtype or shopItems.count then - child:setCount(shopItems.subType or shopItems.subtype or shopItems.count) + if children.subType or children.subtype or children.count then + child:setCount(children.subType or children.subtype or children.count) end - if shopItems.buy then - child:setBuyPrice(shopItems.buy) + if children.buy then + child:setBuyPrice(children.buy) end - if shopItems.sell then - child:setSellPrice(shopItems.sell) + if children.sell then + child:setSellPrice(children.sell) end - if shopItems.storageKey or shopItems.storagekey then - child:setStorageKey(shopItems.storageKey or shopItems.storagekey) + if children.storageKey or children.storagekey then + child:setStorageKey(children.storageKey or children.storagekey) end - if shopItems.storageValue or shopItems.storagevalue then - child:setStorageValue(shopItems.storageValue or shopItems.storagevalue) + if children.storageValue or children.storagevalue then + child:setStorageValue(children.storageValue or children.storagevalue) end parent:addChildShop(child) end diff --git a/src/map/house/house.cpp b/src/map/house/house.cpp index 261147fff40..f2cb26114bf 100644 --- a/src/map/house/house.cpp +++ b/src/map/house/house.cpp @@ -871,7 +871,7 @@ void Houses::payHouses(RentPeriod_t rentPeriod) const { } std::ostringstream ss; - ss << "Warning! \nThe " << period << " rent of " << house->getRent() << " gold for your house \"" << house->getName() << "\" is payable. Have it within " << daysLeft << " days or you will lose static_self_cast() house."; + ss << "Warning! \nThe " << period << " rent of " << house->getRent() << " gold for your house \"" << house->getName() << "\" is payable. Have it within " << daysLeft << " days or you will lose this house."; letter->setAttribute(ItemAttribute_t::TEXT, ss.str()); g_game().internalAddItem(player->getInbox(), letter, INDEX_WHEREEVER, FLAG_NOLIMIT); house->setPayRentWarnings(house->getPayRentWarnings() + 1); From 0d924e8b251d8840e07022900ee83e57c11080ab Mon Sep 17 00:00:00 2001 From: Majesty <32709570+majestyotbr@users.noreply.github.com> Date: Thu, 29 Aug 2024 08:59:22 -0300 Subject: [PATCH 2/4] feat: Nimmersatt's monsters (#2831) Add Nimmersatt's monsters: - Dragolisk, - Wardragon, - Mega Dragon. - Step in Teleport. Co-authored-by: hecmo94 <63259115+hecmo94@users.noreply.github.com> --- .../monster/dragons/dragolisk.lua | 122 ++++++++++++++++ .../monster/dragons/mega_dragon.lua | 126 +++++++++++++++++ .../monster/dragons/war_dragon.lua | 125 +++++++++++++++++ .../movements/teleport/dragolisk_teleport.lua | 26 ++++ data/items/items.xml | 132 ++++++++++++++++++ 5 files changed, 531 insertions(+) create mode 100644 data-otservbr-global/monster/dragons/dragolisk.lua create mode 100644 data-otservbr-global/monster/dragons/mega_dragon.lua create mode 100644 data-otservbr-global/monster/dragons/war_dragon.lua create mode 100644 data-otservbr-global/scripts/movements/teleport/dragolisk_teleport.lua diff --git a/data-otservbr-global/monster/dragons/dragolisk.lua b/data-otservbr-global/monster/dragons/dragolisk.lua new file mode 100644 index 00000000000..26cf05df8ec --- /dev/null +++ b/data-otservbr-global/monster/dragons/dragolisk.lua @@ -0,0 +1,122 @@ +local mType = Game.createMonsterType("Dragolisk") +local monster = {} + +monster.description = "a dragolisk" +monster.experience = 5050 +monster.outfit = { + lookType = 1707, + lookHead = 0, + lookBody = 0, + lookLegs = 0, + lookFeet = 0, + lookAddons = 0, + lookMount = 0, +} + +monster.raceId = 2456 +monster.Bestiary = { + class = "Dragon", + race = BESTY_RACE_DRAGON, + toKill = 2500, + FirstUnlock = 100, + SecondUnlock = 1000, + CharmsPoints = 50, + Stars = 5, + Occurrence = 0, + Locations = "Nimmersatt's Breeding Ground", +} + +monster.health = 6180 +monster.maxHealth = 6180 +monster.race = "blood" +monster.corpse = 44654 +monster.speed = 165 +monster.manaCost = 0 + +monster.changeTarget = { + interval = 4000, + chance = 10, +} + +monster.strategiesTarget = { + nearest = 100, +} + +monster.flags = { + summonable = false, + attackable = true, + hostile = true, + convinceable = false, + pushable = false, + rewardBoss = false, + illusionable = false, + canPushItems = true, + canPushCreatures = true, + staticAttackChance = 90, + targetDistance = 1, + runHealth = 0, + healthHidden = false, + isBlockable = false, + canWalkOnEnergy = true, + canWalkOnFire = true, + canWalkOnPoison = true, +} + +monster.light = { + level = 0, + color = 0, +} + +monster.voices = { + interval = 5000, + chance = 10, + { text = "Just Look at me!", yell = false }, + { text = "I'll stare you down", yell = false }, + { text = "Let me have a look", yell = false }, +} + +monster.loot = { + { name = "Platinum Coin", chance = 52610, minCount = 1, maxCount = 46 }, + { name = "Dragolisk Poison Gland", chance = 12600 }, + { name = "Nimmersatt's Seal", chance = 8320 }, + { id = 282, chance = 7580 }, + { name = "Dragolisk Eye", chance = 5510 }, + { name = "Green Gem", chance = 8260 }, + { name = "Dragon's Tail", chance = 1003 }, + { name = "Dragon Shield", chance = 400 }, +} + +monster.attacks = { + { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -200 }, + { name = "combat", interval = 3000, chance = 27, type = COMBAT_PHYSICALDAMAGE, minDamage = -220, maxDamage = -250, length = 7, spread = 0, effect = CONST_ME_EXPLOSIONAREA, target = false }, + { name = "combat", interval = 2500, chance = 25, type = COMBAT_PHYSICALDAMAGE, minDamage = -200, maxDamage = -250, radius = 4, effect = CONST_ME_POFF, target = true }, + { name = "death chain", interval = 2500, chance = 20, minDamage = -250, maxDamage = -300, range = 7 }, +} + +monster.defenses = { + defense = 86, + armor = 86, + mitigation = 2.11, +} + +monster.elements = { + { type = COMBAT_PHYSICALDAMAGE, percent = 15 }, + { type = COMBAT_ENERGYDAMAGE, percent = 0 }, + { type = COMBAT_EARTHDAMAGE, percent = -10 }, + { type = COMBAT_FIREDAMAGE, percent = 0 }, + { type = COMBAT_LIFEDRAIN, percent = 0 }, + { type = COMBAT_MANADRAIN, percent = 0 }, + { type = COMBAT_DROWNDAMAGE, percent = 0 }, + { type = COMBAT_ICEDAMAGE, percent = -5 }, + { type = COMBAT_HOLYDAMAGE, percent = -15 }, + { type = COMBAT_DEATHDAMAGE, percent = -10 }, +} + +monster.immunities = { + { type = "paralyze", condition = true }, + { type = "outfit", condition = false }, + { type = "invisible", condition = true }, + { type = "bleed", condition = false }, +} + +mType:register(monster) diff --git a/data-otservbr-global/monster/dragons/mega_dragon.lua b/data-otservbr-global/monster/dragons/mega_dragon.lua new file mode 100644 index 00000000000..66696435486 --- /dev/null +++ b/data-otservbr-global/monster/dragons/mega_dragon.lua @@ -0,0 +1,126 @@ +local mType = Game.createMonsterType("Mega Dragon") +local monster = {} + +monster.description = "a mega dragon" +monster.experience = 7810 +monster.outfit = { + lookType = 1712, + lookHead = 0, + lookBody = 0, + lookLegs = 0, + lookFeet = 0, + lookAddons = 0, + lookMount = 0, +} + +monster.raceId = 2459 +monster.Bestiary = { + class = "Dragon", + race = BESTY_RACE_DRAGON, + toKill = 2500, + FirstUnlock = 100, + SecondUnlock = 1000, + CharmsPoints = 50, + Stars = 5, + Occurrence = 0, + Locations = "Nimmersatt's Breeding Ground", +} + +monster.health = 7920 +monster.maxHealth = 7920 +monster.race = "blood" +monster.corpse = 44663 +monster.speed = 170 +monster.manaCost = 0 + +monster.changeTarget = { + interval = 4000, + chance = 10, +} + +monster.strategiesTarget = { + nearest = 100, +} + +monster.flags = { + summonable = false, + attackable = true, + hostile = true, + convinceable = false, + pushable = false, + rewardBoss = false, + illusionable = false, + canPushItems = true, + canPushCreatures = true, + staticAttackChance = 90, + targetDistance = 1, + runHealth = 0, + healthHidden = false, + isBlockable = false, + canWalkOnEnergy = true, + canWalkOnFire = true, + canWalkOnPoison = true, +} + +monster.light = { + level = 0, + color = 0, +} + +monster.voices = { + interval = 5000, + chance = 10, + { text = "Just Look at me!", yell = false }, + { text = "I'll stare you down", yell = false }, + { text = "Let me have a look", yell = false }, +} + +monster.loot = { + { name = "Platinum Coin", chance = 50780, minCount = 1, maxCount = 48 }, + { name = "Nimmersatt's Seal", chance = 8670 }, + { id = 3039, chance = 10090 }, + { name = "Molten Dragon Essence", chance = 4720 }, + { name = "Prismatic Quartz", chance = 4460 }, + { name = "Rainbow Quartz", chance = 4430, minCount = 1, maxCount = 2 }, + { id = 3041, chance = 6790 }, + { name = "Mega Dragon Heart", chance = 1850 }, + { name = "Violet Gem", chance = 1470 }, + { name = "Dragon Slayer", chance = 130 }, +} + +monster.attacks = { + { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -450 }, + { name = "combat", interval = 2500, chance = 15, type = COMBAT_PHYSICALDAMAGE, minDamage = -250, maxDamage = -350, range = 2, effect = CONST_ME_BIG_SCRATCH, target = true }, + { name = "combat", interval = 2500, chance = 20, type = COMBAT_FIREDAMAGE, minDamage = -250, maxDamage = -300, length = 8, spread = 4, effect = CONST_ME_EXPLOSIONHIT, target = false }, + { name = "combat", interval = 2500, chance = 15, type = COMBAT_FIREDAMAGE, minDamage = -200, maxDamage = -300, range = 7, radius = 4, shootEffect = CONST_ANI_FIRE, effect = CONST_ME_FIREAREA, target = true }, + { name = "combat", interval = 3000, chance = 5, type = COMBAT_PHYSICALDAMAGE, minDamage = -200, maxDamage = -350, radius = 4, effect = CONST_ME_POFF, target = true }, + { name = "death chain", interval = 2500, chance = 15, minDamage = -200, maxDamage = -350, range = 7 }, +} + +monster.defenses = { + defense = 76, + armor = 76, + mitigation = 1.96, +} + +monster.elements = { + { type = COMBAT_PHYSICALDAMAGE, percent = 0 }, + { type = COMBAT_ENERGYDAMAGE, percent = -10 }, + { type = COMBAT_EARTHDAMAGE, percent = -10 }, + { type = COMBAT_FIREDAMAGE, percent = 0 }, + { type = COMBAT_LIFEDRAIN, percent = 0 }, + { type = COMBAT_MANADRAIN, percent = 0 }, + { type = COMBAT_DROWNDAMAGE, percent = 0 }, + { type = COMBAT_ICEDAMAGE, percent = 0 }, + { type = COMBAT_HOLYDAMAGE, percent = -10 }, + { type = COMBAT_DEATHDAMAGE, percent = 0 }, +} + +monster.immunities = { + { type = "paralyze", condition = true }, + { type = "outfit", condition = false }, + { type = "invisible", condition = true }, + { type = "bleed", condition = false }, +} + +mType:register(monster) diff --git a/data-otservbr-global/monster/dragons/war_dragon.lua b/data-otservbr-global/monster/dragons/war_dragon.lua new file mode 100644 index 00000000000..79d04bb2c0c --- /dev/null +++ b/data-otservbr-global/monster/dragons/war_dragon.lua @@ -0,0 +1,125 @@ +local mType = Game.createMonsterType("Wardragon") +local monster = {} + +monster.description = "a wardragon" +monster.experience = 5810 +monster.outfit = { + lookType = 1708, + lookHead = 0, + lookBody = 0, + lookLegs = 0, + lookFeet = 0, + lookAddons = 0, + lookMount = 0, +} + +monster.raceId = 2458 +monster.Bestiary = { + class = "Dragon", + race = BESTY_RACE_DRAGON, + toKill = 2500, + FirstUnlock = 100, + SecondUnlock = 1000, + CharmsPoints = 50, + Stars = 5, + Occurrence = 0, + Locations = "Nimmersatt's Breeding Ground", +} + +monster.health = 6960 +monster.maxHealth = 6960 +monster.race = "blood" +monster.corpse = 44656 +monster.speed = 165 +monster.manaCost = 0 + +monster.changeTarget = { + interval = 4000, + chance = 10, +} + +monster.strategiesTarget = { + nearest = 100, +} + +monster.flags = { + summonable = false, + attackable = true, + hostile = true, + convinceable = false, + pushable = false, + rewardBoss = false, + illusionable = false, + canPushItems = true, + canPushCreatures = true, + staticAttackChance = 90, + targetDistance = 1, + runHealth = 0, + healthHidden = false, + isBlockable = false, + canWalkOnEnergy = true, + canWalkOnFire = true, + canWalkOnPoison = true, +} + +monster.light = { + level = 0, + color = 0, +} + +monster.voices = { + interval = 5000, + chance = 10, + { text = "Just Look at me!", yell = false }, + { text = "I'll stare you down", yell = false }, + { text = "Let me have a look", yell = false }, +} + +monster.loot = { + { name = "Platinum Coin", chance = 52560, minCount = 1, maxCount = 45 }, + { name = "Wardragon Claw", chance = 14420 }, + { name = "Nimmersatt's Seal", chance = 10620 }, + { name = "Dragon Tongue", chance = 8450 }, + { name = "Wardragon Tooth", chance = 6330 }, + { name = "Gold Ingot", chance = 6007 }, + { name = "Onyx Chip", chance = 4650, minCount = 1, maxCount = 2 }, + { name = "Black Pearl", chance = 4000 }, + { name = "White Gem", chance = 1000 }, + { name = "Dragonbone Staff", chance = 740 }, +} + +monster.attacks = { + { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -450 }, + { name = "combat", interval = 2500, chance = 20, type = COMBAT_DEATHDAMAGE, minDamage = -250, maxDamage = -400, radius = 4, effect = CONST_ME_MORTAREA, target = true }, + { name = "combat", interval = 3000, chance = 25, type = COMBAT_FIREDAMAGE, minDamage = -300, maxDamage = -400, length = 8, spread = 4, effect = CONST_ME_EXPLOSIONHIT, target = false }, + { name = "combat", interval = 3000, chance = 20, type = COMBAT_PHYSICALDAMAGE, minDamage = -275, maxDamage = -400, radius = 4, effect = CONST_ME_POFF, target = true }, + { name = "combat", interval = 3000, chance = 15, type = COMBAT_PHYSICALDAMAGE, minDamage = -250, maxDamage = -300, range = 2, effect = CONST_ME_BIG_SCRATCH, target = true }, +} + +monster.defenses = { + defense = 80, + armor = 80, + mitigation = 2.19, +} + +monster.elements = { + { type = COMBAT_PHYSICALDAMAGE, percent = 0 }, + { type = COMBAT_ENERGYDAMAGE, percent = -5 }, + { type = COMBAT_EARTHDAMAGE, percent = -10 }, + { type = COMBAT_FIREDAMAGE, percent = 0 }, + { type = COMBAT_LIFEDRAIN, percent = 0 }, + { type = COMBAT_MANADRAIN, percent = 0 }, + { type = COMBAT_DROWNDAMAGE, percent = 0 }, + { type = COMBAT_ICEDAMAGE, percent = -10 }, + { type = COMBAT_HOLYDAMAGE, percent = -5 }, + { type = COMBAT_DEATHDAMAGE, percent = 0 }, +} + +monster.immunities = { + { type = "paralyze", condition = true }, + { type = "outfit", condition = false }, + { type = "invisible", condition = true }, + { type = "bleed", condition = false }, +} + +mType:register(monster) diff --git a/data-otservbr-global/scripts/movements/teleport/dragolisk_teleport.lua b/data-otservbr-global/scripts/movements/teleport/dragolisk_teleport.lua new file mode 100644 index 00000000000..2c04c3f2a39 --- /dev/null +++ b/data-otservbr-global/scripts/movements/teleport/dragolisk_teleport.lua @@ -0,0 +1,26 @@ +local function teleportToDestination(creature, position) + if not creature:isPlayer() then + return true + end + + if position.x == 33216 and position.y == 31126 and position.z == 14 then + creature:teleportTo(Position(33186, 31190, 7)) + creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + return true + elseif position.x == 33187 and position.y == 31190 and position.z == 7 then + creature:teleportTo(Position(33217, 31123, 14)) + creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + return true + else + return false + end +end + +local dragoliskTeleport = MoveEvent() +function dragoliskTeleport.onStepIn(creature, item, position, fromPosition) + return teleportToDestination(creature, position) +end + +dragoliskTeleport:position({ x = 33216, y = 31126, z = 14 }) +dragoliskTeleport:position({ x = 33187, y = 31190, z = 7 }) +dragoliskTeleport:register() diff --git a/data/items/items.xml b/data/items/items.xml index 4978cf0bdc4..860a148fda2 100644 --- a/data/items/items.xml +++ b/data/items/items.xml @@ -76112,5 +76112,137 @@ Granted by TibiaGoals.com"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a15477386a542ebb6b8c15fa742d4efc31fb5196 Mon Sep 17 00:00:00 2001 From: Majesty <32709570+majestyotbr@users.noreply.github.com> Date: Thu, 29 Aug 2024 09:00:26 -0300 Subject: [PATCH 3/4] fix: data-canary errors and warnings (#2844) --- data-canary/monster/magicals/guzzlemaw.lua | 71 +++++++++--------- .../spells/monster/fury_skill_reducer.lua | 27 +++++++ data-canary/world/canary-house.xml | 2 +- data-canary/world/canary-zones.xml | 2 + data-canary/world/canary.otbm | Bin 19718929 -> 19718948 bytes 5 files changed, 65 insertions(+), 37 deletions(-) create mode 100644 data-canary/scripts/spells/monster/fury_skill_reducer.lua create mode 100644 data-canary/world/canary-zones.xml diff --git a/data-canary/monster/magicals/guzzlemaw.lua b/data-canary/monster/magicals/guzzlemaw.lua index 8e38d459779..391a85118bc 100644 --- a/data-canary/monster/magicals/guzzlemaw.lua +++ b/data-canary/monster/magicals/guzzlemaw.lua @@ -23,8 +23,7 @@ monster.Bestiary = { CharmsPoints = 50, Stars = 4, Occurrence = 0, - Locations = "Guzzlemaw Valley, and a single spawn in a tower in Upper Roshamuul \z - (south of the Depot and west of the entrance to Roshamuul Prison).", + Locations = "Guzzlemaw Valley, and a single spawn in a tower in Upper Roshamuul (south of the Depot and west of the entrance to Roshamuul Prison).", } monster.health = 6400 @@ -64,7 +63,6 @@ monster.flags = { canWalkOnEnergy = true, canWalkOnFire = true, canWalkOnPoison = true, - pet = false, } monster.light = { @@ -78,63 +76,64 @@ monster.voices = { } monster.loot = { - { id = 3031, chance = 100000, maxCount = 100 }, -- gold coin - { id = 3035, chance = 100000, maxCount = 7 }, -- platinum coin - { id = 3104, chance = 10700 }, -- banana skin - { id = 3110, chance = 10500 }, -- piece of iron - { id = 3111, chance = 9500 }, -- fishbone + { name = "gold coin", chance = 100000, maxCount = 100 }, + { name = "platinum coin", chance = 100000, maxCount = 7 }, + { name = "banana skin", chance = 10700 }, + { name = "piece of iron", chance = 10500 }, + { name = "fishbone", chance = 9500 }, { id = 3114, chance = 10400 }, -- skull { id = 3115, chance = 9200 }, -- bone { id = 3116, chance = 4500 }, -- big bone - { id = 3265, chance = 2700 }, -- two handed sword + { name = "two handed sword", chance = 2700 }, { id = 3578, chance = 7000, maxCount = 3 }, -- fish - { id = 3582, chance = 10000 }, -- ham - { id = 5880, chance = 3000 }, -- iron ore - { id = 5895, chance = 5000 }, -- fish fin - { id = 5925, chance = 5700 }, -- hardened bone + { name = "ham", chance = 10000 }, + { name = "iron ore", chance = 3000 }, + { name = "fish fin", chance = 5000 }, + { name = "hardened bone", chance = 5700 }, { id = 5951, chance = 9400 }, -- fish tail - { id = 7404, chance = 1000 }, -- assassin dagger - { id = 7407, chance = 2000 }, -- haunted blade - { id = 7418, chance = 380 }, -- nightmare blade - { id = 238, chance = 17000, maxCount = 3 }, -- great mana potion - { id = 239, chance = 18500, maxCount = 2 }, -- great health potion - { id = 10389, chance = 1200 }, -- sai - { id = 16120, chance = 3000 }, -- violet crystal shard - { id = 16123, chance = 12000, maxCount = 2 }, -- brown crystal splinter - { id = 16126, chance = 7600 }, -- red crystal fragment + { name = "assassin dagger", chance = 1000 }, + { name = "haunted blade", chance = 2000 }, + { name = "nightmare blade", chance = 380 }, + { name = "great mana potion", chance = 17000, maxCount = 3 }, + { name = "great health potion", chance = 18500, maxCount = 2 }, + { name = "sai", chance = 1200 }, + { name = "violet crystal shard", chance = 3000 }, + { name = "brown crystal splinter", chance = 12000, maxCount = 2 }, + { name = "red crystal fragment", chance = 7600 }, { id = 16279, chance = 12000 }, -- crystal rubbish - { id = 20062, chance = 920 }, -- cluster of solace - { id = 20198, chance = 15000 }, -- frazzle tongue - { id = 20199, chance = 14000 }, -- frazzle skin + { name = "cluster of solace", chance = 8920 }, + { name = "frazzle tongue", chance = 15000 }, + { name = "frazzle skin", chance = 14000 }, } monster.attacks = { { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -499 }, -- bleed - { name = "condition", type = CONDITION_BLEEDING, interval = 2000, chance = 10, minDamage = -500, maxDamage = -1000, radius = 3, target = false }, - { name = "combat", interval = 2000, chance = 10, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -900, length = 8, spread = 3, effect = CONST_ME_EXPLOSIONAREA, target = false }, + { name = "condition", type = CONDITION_BLEEDING, interval = 2000, chance = 10, minDamage = -500, maxDamage = -1000, radius = 3, effect = CONST_ME_DRAWBLOOD, target = false }, + { name = "combat", interval = 2000, chance = 10, type = COMBAT_LIFEDRAIN, minDamage = 0, maxDamage = -900, length = 8, spread = 0, effect = CONST_ME_EXPLOSIONAREA, target = false }, { name = "combat", interval = 2000, chance = 20, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -500, radius = 2, shootEffect = CONST_ANI_LARGEROCK, effect = CONST_ME_STONES, target = true }, - { name = "speed", interval = 2000, chance = 15, speedChange = -100, radius = 6, effect = CONST_ME_MAGIC_RED, target = false, duration = 15000 }, - { name = "combat", interval = 2000, chance = 10, type = COMBAT_LIFEDRAIN, minDamage = 0, maxDamage = -800, length = 8, spread = 3, effect = CONST_ME_MAGIC_RED, target = false }, + { name = "speed", interval = 2000, chance = 15, speedChange = -800, radius = 6, effect = CONST_ME_MAGIC_RED, target = false, duration = 15000 }, + { name = "combat", interval = 2000, chance = 10, type = COMBAT_LIFEDRAIN, minDamage = 0, maxDamage = -800, length = 8, spread = 0, effect = CONST_ME_MAGIC_RED, target = false }, } monster.defenses = { defense = 50, - armor = 50, + armor = 74, + mitigation = 2.31, { name = "combat", interval = 2000, chance = 20, type = COMBAT_HEALING, minDamage = 250, maxDamage = 425, effect = CONST_ME_HITBYPOISON, target = false }, } monster.elements = { - { type = COMBAT_PHYSICALDAMAGE, percent = 10 }, - { type = COMBAT_ENERGYDAMAGE, percent = 5 }, - { type = COMBAT_EARTHDAMAGE, percent = 15 }, - { type = COMBAT_FIREDAMAGE, percent = 5 }, + { type = COMBAT_PHYSICALDAMAGE, percent = 5 }, + { type = COMBAT_ENERGYDAMAGE, percent = 15 }, + { type = COMBAT_EARTHDAMAGE, percent = 20 }, + { type = COMBAT_FIREDAMAGE, percent = 10 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, { type = COMBAT_ICEDAMAGE, percent = 5 }, - { type = COMBAT_HOLYDAMAGE, percent = 0 }, - { type = COMBAT_DEATHDAMAGE, percent = 5 }, + { type = COMBAT_HOLYDAMAGE, percent = -5 }, + { type = COMBAT_DEATHDAMAGE, percent = 10 }, } monster.immunities = { diff --git a/data-canary/scripts/spells/monster/fury_skill_reducer.lua b/data-canary/scripts/spells/monster/fury_skill_reducer.lua new file mode 100644 index 00000000000..1e8acd0ae7a --- /dev/null +++ b/data-canary/scripts/spells/monster/fury_skill_reducer.lua @@ -0,0 +1,27 @@ +local combat = {} + +for i = 65, 80 do + combat[i] = Combat() + combat[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_SOUND_YELLOW) + + local condition = Condition(CONDITION_ATTRIBUTES) + condition:setParameter(CONDITION_PARAM_TICKS, 5000) + condition:setParameter(CONDITION_PARAM_SKILL_DEFENSEPERCENT, i) + + local area = createCombatArea(AREA_CIRCLE3X3) + combat[i]:setArea(area) + combat[i]:addCondition(condition) +end + +local spell = Spell("instant") + +function spell.onCastSpell(creature, var) + return combat[math.random(65, 80)]:execute(creature, var) +end + +spell:name("fury skill reducer") +spell:words("###2") +spell:isAggressive(true) +spell:blockWalls(true) +spell:needLearn(true) +spell:register() diff --git a/data-canary/world/canary-house.xml b/data-canary/world/canary-house.xml index adaa1a1c8f2..43d8e80d11e 100644 --- a/data-canary/world/canary-house.xml +++ b/data-canary/world/canary-house.xml @@ -1,4 +1,4 @@ - + diff --git a/data-canary/world/canary-zones.xml b/data-canary/world/canary-zones.xml new file mode 100644 index 00000000000..a9224bd3c2d --- /dev/null +++ b/data-canary/world/canary-zones.xml @@ -0,0 +1,2 @@ + + diff --git a/data-canary/world/canary.otbm b/data-canary/world/canary.otbm index 280d57a9194069ec839bb8cab86c1ffbb960ccf8..8f787811a5395efb0e0cbbb2ac7f34ec12b9e0be 100644 GIT binary patch delta 1798 zcmYk)c~}%>9KdmAVRu|tg_VI_L6l1ogtE-+rnJKp)3nm=$Sfkm)XcO?p&E}&t#qmA zpbVnI4AUV?L~x-}3%e{jtVFb$?m|)7_50gpdG?Rb_j!Kv&g{E8`>tu)WM7YsHYM5} z6EP#dD1Yw4oJF&XX3i_ID7r-v7DOTnR@k7T7wqT_2l}8d`XL%IaH2nAp&<_OhDC85 z$Wy%uexI#TGt7yuW~&-$4NhC9x(;fpB{=C71unQT00~IMKqO%h1|u0MNJSdbF$6=A zfnmr*7KS4mIXDHUVgydZ=@^MKFbZd4G|s}=I0xtAJe-dUkc$g(5yoIFF2*Ie6qjKf zF2{JIqF}W`iMRrjjKY%1<$1O}n%to~TPEX5Ou;5N*}?YIL4xD$oA%W$^LS~A+US2p+RrRv=%!ff1wIhc!i zxEJ$r9~R(#EW{!_fCupq9>ybBj3p>W2_D5`c-$ye^(l^=!-;HqNU}PP%yIbrK5NHu zd$r=Tt#!+AE!d0C@HxJ~m-q_%@HM_cE55~d_#QuCKYqkd__;Ev^+0v- z7&m#+^tKe+?!b{Y#_MhCQo9%Q_Nq1rLI+J@`2=Q4#SGn(9&N&BfvOO!9Q> zFh_>27$X|Y1|>9kIvdU6o}qZBxx8lxU(w6FCVs~s_!EEOZ~TLQ@gM$22aezOqKeV*Ummvhd}-iMVF|eaA9Ee3f^v3`UgcE}h2N&Xzpn6U2jy&5oS2$!1B&y*_?q-WI znJsF|6!%`2F-2LFx*|6`@FEdO7>r~L!BC_i6=_I^55q7V85n^~WML$-F$yPOG;(kv zPQnu^10U?y(B zjkpOn;}#U*R@{c$RbT6@x#O(?dAv5I%613t#9g=>vvCjZ#eJBA`|$uC#6x%(kKj=h z<1svrComT!D8-YQhxuxiO(}4US`^Ps_a~8klG%=MIAl3=%wBB@S<5{#96lN{-bSuVUwVCe&jywqPq7unmm}pb5?R2p{7UY{w3?;8T2t zRO* z>t0ZTm7Um&pRo`7@e6)cgO$H^&gl88Jq~TdD&t*d+WpIFwXB{&ZL8Jt96giYS0Ax7 zwO-4OGX9Ze*!@elXiD#pxm7Fc9ax#{w>M~GoceLfu!lKM(R~v7xMKXHcjd>cGaIxO zrrzzbjao_XP~I4Ep~w}bCZOSW{DA{Fh(GZc{>DG}7l&{dM-aqO9K&&RA%yUPnt*8` zBvBHxBwAvTSS2<|jKnVKD{)9-CH*A*B?BY_B~Hm8Nu0zbiI*fu+!Bw(D@l|jNd`-j oB|{`bB`K0rNtz^G;*$)M43}g`Mo2OxS(1^a%{75+)12i007O(&kpKVy From 8056ca6ee747de90bf5bb053bde6f114f42af1fc Mon Sep 17 00:00:00 2001 From: Majesty <32709570+majestyotbr@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:45:55 -0300 Subject: [PATCH 4/4] fix: datapacks tools actions (#2851) --- .../scripts/actions/tools/kitchen_knife.lua | 8 -- data-canary/scripts/actions/tools/sickle.lua | 8 -- data-canary/scripts/lib/register_actions.lua | 100 ++++++++------- .../scripts/lib/register_actions.lua | 115 ++---------------- .../scripts/actions/tools/sickle.lua | 0 src/canary_server.cpp | 1 + 6 files changed, 67 insertions(+), 165 deletions(-) delete mode 100644 data-canary/scripts/actions/tools/kitchen_knife.lua delete mode 100644 data-canary/scripts/actions/tools/sickle.lua rename {data-otservbr-global => data}/scripts/actions/tools/sickle.lua (100%) diff --git a/data-canary/scripts/actions/tools/kitchen_knife.lua b/data-canary/scripts/actions/tools/kitchen_knife.lua deleted file mode 100644 index 921baf9092d..00000000000 --- a/data-canary/scripts/actions/tools/kitchen_knife.lua +++ /dev/null @@ -1,8 +0,0 @@ -local kitchenKnife = Action() - -function kitchenKnife.onUse(player, item, fromPosition, target, toPosition, isHotkey) - return ActionsLib.useKitchenKnife(player, item, fromPosition, target, toPosition, isHotkey) -end - -kitchenKnife:id(3469) -kitchenKnife:register() diff --git a/data-canary/scripts/actions/tools/sickle.lua b/data-canary/scripts/actions/tools/sickle.lua deleted file mode 100644 index a4e024dde20..00000000000 --- a/data-canary/scripts/actions/tools/sickle.lua +++ /dev/null @@ -1,8 +0,0 @@ -local sickle = Action() - -function sickle.onUse(player, item, fromPosition, target, toPosition, isHotkey) - return ActionsLib.useSickle(player, item, fromPosition, target, toPosition, isHotkey) or ActionsLib.destroyItem(player, target, toPosition) -end - -sickle:id(3293, 3306, 32595) -sickle:register() diff --git a/data-canary/scripts/lib/register_actions.lua b/data-canary/scripts/lib/register_actions.lua index 7c0aa49102e..229d385b0de 100644 --- a/data-canary/scripts/lib/register_actions.lua +++ b/data-canary/scripts/lib/register_actions.lua @@ -1,12 +1,17 @@ -local holeId = { 294, 369, 370, 385, 394, 411, 412, 413, 432, 433, 435, 8709, 594, 595, 615, 609, 610, 615, 1156, 482, 483, 868, 874, 4824, 7768, 433, 432, 413, 7767, 411, 370, 369, 7737, 7755, 7768, 7767, 7515, 7516, 7517, 7518, 7519, 7520, 7521, 7522, 7762, 8144, 8690, 8709, 12203, 12961, 17239, 19220, 23364 } -- usable rope holes, for rope spots see global.lua -local wildGrowth = { 2130, 2130, 2982, 2524, 2030, 2029, 10182 } -- wild growth destroyable by machete -local jungleGrass = { [3696] = 3695, [3702] = 3701, [17153] = 17151 } -- grass destroyable by machete -local groundIds = { 354, 355 } -- pick usable ground +local holeId = { 294, 369, 370, 385, 394, 411, 412, 413, 432, 433, 435, 482, 483, 594, 595, 609, 610, 615, 868, 874, 1156, 4824, 7515, 7516, 7517, 7518, 7519, 7520, 7521, 7522, 7737, 7755, 7762, 7767, 7768, 8144, 8690, 8709, 12203, 12961, 17239, 19220, 23364 } -- usable rope holes, for rope spots see global.lua +local wildGrowth = { 3635, 30224 } -- wild growth destroyable by machete +local jungleGrass = { -- grass destroyable by machete + [3696] = 3695, + [3702] = 3701, + [17153] = 17151, +} +local groundIds = { 354, 355 } -- pick usable grounds local sandIds = { 231 } -- desert sand -local fruits = { 2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2684, 2685, 5097, 8839, 8840, 8841 } -- fruits to make decorated cake with knife +local fruits = { 3584, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3595, 3596, 5096, 8011, 8012, 8013 } -- fruits to make decorated cake with knife local holes = { 593, 606, 608, 867, 21341 } -- holes opened by shovel +local ropeSpots = { 386, 421, 12935, 12936, 14238, 17238, 21501, 21965, 21966, 21967, 21968, 23363 } -function destroyItem(player, target, toPosition) +function destroyItem(player, item, fromPosition, target, toPosition, isHotkey) if type(target) ~= "userdata" or not target:isItem() then return false end @@ -40,10 +45,8 @@ function destroyItem(player, target, toPosition) end end end - target:remove(1) end - toPosition:sendMagicEffect(CONST_ME_POFF) return true end @@ -67,7 +70,7 @@ function onUseMachete(player, item, fromPosition, target, toPosition, isHotkey) player:addAchievementProgress("Nothing Can Stop Me", 100) return true end - return destroyItem(player, target, toPosition) + return destroyItem(player, item, fromPosition, target, toPosition, isHotkey) end function onUsePick(player, item, fromPosition, target, toPosition, isHotkey) @@ -82,7 +85,6 @@ function onUsePick(player, item, fromPosition, target, toPosition, isHotkey) else player:addItem(3028) -- 49% chance of getting small diamond end - player:addAchievementProgress("Petrologist", 100) target:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT) target:remove(1) @@ -99,7 +101,7 @@ function onUsePick(player, item, fromPosition, target, toPosition, isHotkey) return false end - if table.contains(groundIds, ground.itemid) and ground.actionid == actionIds.pickHole then + if table.contains(groundIds, ground.itemid) and (ground:hasAttribute(ITEM_ATTRIBUTE_UNIQUEID) or ground:hasAttribute(ITEM_ATTRIBUTE_ACTIONID)) then ground:transform(394) ground:decay() toPosition:sendMagicEffect(CONST_ME_POFF) @@ -127,41 +129,28 @@ function onUseRope(player, item, fromPosition, target, toPosition, isHotkey) local ground = tile:getGround() if ground and table.contains(ropeSpots, ground:getId()) or tile:getItemById(12935) then - tile = Tile(toPosition:moveUpstairs()) - if not tile then - return false - end - - if tile:hasFlag(TILESTATE_PROTECTIONZONE) and player:isPzLocked() then + if Tile(toPosition:moveUpstairs()):hasFlag(TILESTATE_PROTECTIONZONE) and player:isPzLocked() then player:sendCancelMessage(RETURNVALUE_PLAYERISPZLOCKED) return true end - player:teleportTo(toPosition, false) return true - end - - if table.contains(holeId, target.itemid) then + elseif table.contains(holeId, target.itemid) then toPosition.z = toPosition.z + 1 tile = Tile(toPosition) - if not tile then - return false - end - - local thing = tile:getTopVisibleThing() - if not thing then - return true - end - - if thing:isPlayer() then - if Tile(toPosition:moveUpstairs()):queryAdd(thing) ~= RETURNVALUE_NOERROR then - return false + if tile then + local thing = tile:getTopVisibleThing() + if thing:isPlayer() then + if Tile(toPosition:moveUpstairs()):hasFlag(TILESTATE_PROTECTIONZONE) and thing:isPzLocked() then + return false + end + return thing:teleportTo(toPosition, false) + end + if thing:isItem() and thing:getType():isMovable() then + return thing:moveTo(toPosition:moveUpstairs()) end - - return thing:teleportTo(toPosition, false) - elseif thing:isItem() and thing:getType():isMovable() then - return thing:moveTo(toPosition:moveUpstairs()) end + player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) return true end return false @@ -182,7 +171,13 @@ function onUseShovel(player, item, fromPosition, target, toPosition, isHotkey) if table.contains(holes, groundId) then ground:transform(groundId + 1) ground:decay() - + toPosition:moveDownstairs() + toPosition.y = toPosition.y - 1 + if Tile(toPosition):hasFlag(TILESTATE_PROTECTIONZONE) and player:isPzLocked() then + player:sendCancelMessage(RETURNVALUE_PLAYERISPZLOCKED) + return true + end + player:teleportTo(toPosition, false) toPosition.z = toPosition.z + 1 tile:relocateTo(toPosition) player:addAchievementProgress("The Undertaker", 500) @@ -192,14 +187,14 @@ function onUseShovel(player, item, fromPosition, target, toPosition, isHotkey) player:addAchievementProgress("The Undertaker", 500) elseif target.itemid == 17950 then -- swamp digging if not player:hasExhaustion("swamp-digging") then - local chance = math.random(100) - if chance >= 1 and chance <= 42 then + local chance = math.random(1, 100) + if chance <= 42 then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dug up a dead snake.") player:addItem(4259) elseif chance >= 43 and chance <= 79 then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dug up a small diamond.") player:addItem(3028) - elseif chance >= 80 then + else player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dug up a leech.") player:addItem(17858) end @@ -209,16 +204,15 @@ function onUseShovel(player, item, fromPosition, target, toPosition, isHotkey) end elseif table.contains(sandIds, groundId) then local randomValue = math.random(1, 100) - if target.actionid == actionIds.sandHole and randomValue <= 20 then + if target.actionid == 100 and randomValue <= 20 then ground:transform(615) ground:decay() elseif randomValue == 1 then - Game.createItem(3042, 1, toPosition) + Game.createItem(3042, 1, toPosition) -- Scarab Coin player:addAchievementProgress("Gold Digger", 100) elseif randomValue > 95 then Game.createMonster("Scarab", toPosition) end - toPosition:sendMagicEffect(CONST_ME_POFF) else return false @@ -238,6 +232,13 @@ function onUseScythe(player, item, fromPosition, target, toPosition, isHotkey) player:addAchievementProgress("Happy Farmer", 200) return true end + return destroyItem(player, item, fromPosition, target, toPosition, isHotkey) +end + +function onUseSickle(player, item, fromPosition, target, toPosition, isHotkey) + if not table.contains({ 3293, 3306 }, item.itemid) then + return false + end if target.itemid == 5464 then -- burning sugar cane target:transform(5463) @@ -246,14 +247,14 @@ function onUseScythe(player, item, fromPosition, target, toPosition, isHotkey) player:addAchievementProgress("Natural Sweetener", 50) return true end - return destroyItem(player, target, toPosition) + return destroyItem(player, item, fromPosition, target, toPosition, isHotkey) end function onUseCrowbar(player, item, fromPosition, target, toPosition, isHotkey) if not table.contains({ 3304, 9598 }, item.itemid) then return false end - return destroyItem(player, target, toPosition) + return destroyItem(player, item, fromPosition, target, toPosition, isHotkey) end function onUseKitchenKnife(player, item, fromPosition, target, toPosition, isHotkey) @@ -269,3 +270,10 @@ function onUseKitchenKnife(player, item, fromPosition, target, toPosition, isHot end return false end + +function onUseSpoon(player, item, fromPosition, target, toPosition, isHotkey) + if not table.contains({ 3468, 3470 }, item.itemid) then + return false + end + return false +end diff --git a/data-otservbr-global/scripts/lib/register_actions.lua b/data-otservbr-global/scripts/lib/register_actions.lua index 6df6b96473a..b696d44c9c6 100644 --- a/data-otservbr-global/scripts/lib/register_actions.lua +++ b/data-otservbr-global/scripts/lib/register_actions.lua @@ -1,106 +1,12 @@ -local holeId = { - 294, - 369, - 370, - 385, - 394, - 411, - 412, - 413, - 432, - 433, - 435, - 8709, - 594, - 595, - 615, - 609, - 610, - 615, - 1156, - 482, - 483, - 868, - 874, - 4824, - 7768, - 433, - 432, - 413, - 7767, - 411, - 370, - 369, - 7737, - 7755, - 7768, - 7767, - 7515, - 7516, - 7517, - 7518, - 7519, - 7520, - 7521, - 7522, - 7762, - 8144, - 8690, - 8709, - 12203, - 12961, - 17239, - 19220, - 23364, -} - -local Itemsgrinder = { +local holeId = { 294, 369, 370, 385, 394, 411, 412, 413, 432, 433, 435, 482, 483, 594, 595, 609, 610, 615, 868, 874, 1156, 4824, 7515, 7516, 7517, 7518, 7519, 7520, 7521, 7522, 7737, 7755, 7762, 7767, 7768, 8144, 8690, 8709, 12203, 12961, 17239, 19220, 23364 } +local itemsGrinder = { [675] = { item_id = 30004, effect = CONST_ME_BLUE_FIREWORKS }, -- Sapphire dust [16122] = { item_id = 21507, effect = CONST_ME_GREENSMOKE }, -- Pinch of crystal dust } - -local holes = { - 593, - 606, - 608, - 867, - 21341, -} - -local JUNGLE_GRASS = { - 3696, - 3702, - 17153, -} -local WILD_GROWTH = { - 2130, - 2130, - 2982, - 2524, - 2030, - 2029, - 10182, -} - -local fruits = { - 3584, - 3585, - 3586, - 3587, - 3588, - 3589, - 3590, - 3591, - 3592, - 3593, - 3595, - 3596, - 5096, - 8011, - 8012, - 8013, -} - +local holes = { 593, 606, 608, 867, 21341 } +local jungleGrass = { 3696, 3702, 17153 } +local wildGrowth = { 3635, 30224 } +local fruits = { 3584, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3595, 3596, 5096, 8011, 8012, 8013 } local lava = { Position(32808, 32336, 11), Position(32809, 32336, 11), @@ -867,13 +773,13 @@ function onUsePick(player, item, fromPosition, target, toPosition, isHotkey) end function onUseMachete(player, item, fromPosition, target, toPosition, isHotkey) - if table.contains(JUNGLE_GRASS, target.itemid) then + if table.contains(jungleGrass, target.itemid) then target:transform(target.itemid == 17153 and 17151 or target.itemid - 1) target:decay() return true end - if table.contains(WILD_GROWTH, target.itemid) then + if table.contains(wildGrowth, target.itemid) then toPosition:sendMagicEffect(CONST_ME_POFF) target:remove() return true @@ -1035,14 +941,17 @@ function onUseScythe(player, item, fromPosition, target, toPosition, isHotkey) target:transform(5463) target:decay() Game.createItem(5466, 1, toPosition) + return true elseif target.itemid == 3653 then -- wheat target:transform(3651) target:decay() Game.createItem(3605, 1, toPosition) + return true elseif target.itemid == 30623 then -- reed target:transform(30624) target:decay() Game.createItem(30975, 1, toPosition) + return true -- The secret library elseif toPosition == Position(32177, 31925, 7) then player:teleportTo({ x = 32515, y = 32535, z = 12 }) @@ -1135,7 +1044,7 @@ function onGrindItem(player, item, fromPosition, target, toPosition) if not (target.itemid == 21573) then return false end - for index, value in pairs(Itemsgrinder) do + for index, value in pairs(itemsGrinder) do if item.itemid == index then local topParent = item:getTopParent() if topParent.isItem and (not topParent:isItem() or topParent.itemid ~= 470) then diff --git a/data-otservbr-global/scripts/actions/tools/sickle.lua b/data/scripts/actions/tools/sickle.lua similarity index 100% rename from data-otservbr-global/scripts/actions/tools/sickle.lua rename to data/scripts/actions/tools/sickle.lua diff --git a/src/canary_server.cpp b/src/canary_server.cpp index e49a86d7d9f..cca280b69fa 100644 --- a/src/canary_server.cpp +++ b/src/canary_server.cpp @@ -367,6 +367,7 @@ void CanaryServer::loadModules() { modulesLoadHelper(g_modules().loadFromXml(), "modules/modules.xml"); logger.debug("Loading datapack scripts on folder: {}/", datapackName); + modulesLoadHelper(g_scripts().loadScripts(datapackFolder + "/scripts/lib", true, false), datapackFolder + "/scripts/libs"); // Load scripts modulesLoadHelper(g_scripts().loadScripts(datapackFolder + "/scripts", false, false), datapackFolder + "/scripts"); // Load monsters