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);