• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

[OTHire] - NPC selling runes individually

cleaso

New Member
Joined
Feb 29, 2020
Messages
2
Reaction score
0
Hello OTLanders!

My objective is to make runes stackable but I'm having trouble with the shop module

I'm using the following npc system: GitHub - peonso/tibialegacyserver: Tibia Legacy Server is a OpenTibia 7.72 real map server. (https://github.com/peonso/tibialegacyserver)

I changed the items.otb file to support stackable runes, also I changed the spells.cpp and recompiled
Also i changed the spells.xml and changed all rune charges value to 1x, so there are no funky errors on stacking 1x and 3x runes

spells.cpp:2271
C++:
int32_t newCount = std::max<int32_t>(0, item->getItemCount() - 1);
g_game.transformItem(item, item->getID(), newCount);

Everything works fine, the runes work as intended, but now, when reaching the NPC to buy a rune:

Example 1:Example 2:
Input:: buy 2 sd
Output:: container shows 1x sd and 2x sd
Input:: buy 3 sd
Output:: container shows 1x sd, 2x sd, 3x sd
sdrune.PNGsdrune2.PNG


Seems that the NPC is selling the items unstacked and referred to the amount typed by the user
Found something at npc/scripts/lib/npcsystem/modules.lua

modules.lua:636
Lua:
    function ShopModule:addBuyableItem(names, itemid, cost, charges, realname)
        for i, name in pairs(names) do
            local parameters = {
                    itemid = itemid,
                    cost = cost,
                    eventType = SHOPMODULE_BUY_ITEM,
                    module = self
                }
            if(realname ~= nil) then
                parameters.realname = realname
            end
            if(isItemRune(itemid) == true or isItemFluidContainer(itemid) == true) then
                parameters.charges = charges
            end
            keywords = {}
            table.insert(keywords, name)
            local node = self.npcHandler.keywordHandler:addKeyword(keywords, ShopModule.tradeItem, parameters)
            node:addChildKeywordNode(self.yesNode)
            node:addChildKeywordNode(self.noNode)
        end
    end

I tried deleting the isItemRune(itemid) condition, but no success, any suggestion?

Help is appreciated, thanks.
 
Top