Skip to content

Commit

Permalink
Fix invalid NPC items on trade (otland#3782)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgrizante authored and Znote committed Jan 30, 2022
1 parent 73885c4 commit 04761a4
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions data/npc/lib/npcsystem/modules.lua
Original file line number Diff line number Diff line change
Expand Up @@ -812,15 +812,17 @@ if Modules == nil then
if itemSubType == nil then
itemSubType = 1
end

local shopItem = self:getShopItem(itemid, itemSubType)
if shopItem == nil then
self.npcHandler.shopItems[#self.npcHandler.shopItems + 1] = {id = itemid, buy = cost, sell = -1, subType = itemSubType, name = realName or ItemType(itemid):getName()}
else
if cost < shopItem.sell then
print("[Warning : " .. Npc():getName() .. "] NpcSystem: Buy price lower than sell price: (".. shopItem.name ..")")
local it = ItemType(itemid)
if it:getId() ~= 0 then
local shopItem = self:getShopItem(itemid, itemSubType)
if shopItem == nil then
self.npcHandler.shopItems[#self.npcHandler.shopItems + 1] = {id = itemid, buy = cost, sell = -1, subType = itemSubType, name = realName or ItemType(itemid):getName()}
else
if cost < shopItem.sell then
print("[Warning : " .. Npc():getName() .. "] NpcSystem: Buy price lower than sell price: (".. shopItem.name ..")")
end
shopItem.buy = cost
end
shopItem.buy = cost
end
end

Expand Down Expand Up @@ -910,15 +912,17 @@ if Modules == nil then
if itemSubType == nil then
itemSubType = 0
end

local shopItem = self:getShopItem(itemid, itemSubType)
if shopItem == nil then
self.npcHandler.shopItems[#self.npcHandler.shopItems + 1] = {id = itemid, buy = -1, sell = cost, subType = itemSubType, name = realName or ItemType(itemid):getName()}
else
if shopItem.buy > -1 and cost > shopItem.buy then
print("[Warning : " .. Npc():getName() .. "] NpcSystem: Sell price higher than buy price: (".. shopItem.name ..")")
local it = ItemType(itemid)
if it:getId() ~= 0 then
local shopItem = self:getShopItem(itemid, itemSubType)
if shopItem == nil then
self.npcHandler.shopItems[#self.npcHandler.shopItems + 1] = {id = itemid, buy = -1, sell = cost, subType = itemSubType, name = realName or ItemType(itemid):getName()}
else
if shopItem.buy > -1 and cost > shopItem.buy then
print("[Warning : " .. Npc():getName() .. "] NpcSystem: Sell price higher than buy price: (".. shopItem.name ..")")
end
shopItem.sell = cost
end
shopItem.sell = cost
end
end

Expand Down

0 comments on commit 04761a4

Please sign in to comment.