opentibiabr / canary

Canary Server 13.x for OpenTibia community.
https://docs.opentibiabr.com/
GNU General Public License v2.0
374 stars 619 forks source link

Price Discrepancy Issue in NPC Trading. #2702

Closed kaleohanopahala closed 4 months ago

kaleohanopahala commented 4 months ago

Priority

Missing Content

Area

What is missing?

Hello, I noticed that there isn't a check that could be important.

It's possible for an item to be sold at a price lower than its purchase price. Currently, there are no checks for this. Such a flaw may exist in one or more NPCs.

I can buy it for 12. image

I can sell it for 22. image

Code of Conduct

FelipePaluco commented 4 months ago

The problem that you can sell for more than your buy price it's not a problem because it's fully configurable by the developer. But you may want to tell us which NPC is having this behavior if you found one in the datapack.

kaleohanopahala commented 4 months ago

The problem that you can sell for more than your buy price it's not a problem because it's fully configurable by the developer. But you may want to tell us which NPC is having this behavior if you found one in the datapack.

In the event that there is an NPC with an issue among the 1000+, adding a warning would be useful, wouldn't it? Additionally, if someone uses the base to create something custom and mistakenly configures it incorrectly, the same warning would be useful... PS: In the case of the image, I created an example of an error.

luanluciano93 commented 4 months ago

Try replacing this: https://github.com/opentibiabr/canary/blob/main/data/scripts/lib/register_npc_type.lua#L157-L162

that's why:

            if shopItems.buy then
                parent:setBuyPrice(shopItems.buy)
            end
            if shopItems.sell then
                parent:setSellPrice(shopItems.sell)
            end
            if shopItems.buy and shopItems.sell then
                if shopItems.buy <= shopItems.sell then
                    logger.warn("The item {} ({}) is being purchased by the NPC for a value greater than the value of its sale by the same NPC.", shopItems.itemName or shopItems.itemname, shopItems.clientId or shopItems.clientid)
                end
            end
Solkrasm commented 4 months ago

This is the tenth time this nonsensical issue has been opened. This code from [luanluciano93] shows that there are no problems...

Leave and go dance the hula, please. Jajajajaj.