Skip to content
Snippets Groups Projects
Commit b74b3254 authored by dg's avatar dg
Browse files

Fixed artifact ring creation with the pearl or the resonating gem in your inventory

Stores wont ID things when trying to sell


git-svn-id: http://svn.net-core.org/repos/t-engine4@1438 51575b47-30f0-44d4-a5cc-537603b46e54
parent 05cf1fe9
No related branches found
No related tags found
No related merge requests found
......@@ -102,6 +102,7 @@ function _M:doBuy(who, o, item, nb, store_dialog)
nb = self:tryBuy(who, o, item, nb)
if nb then
Dialog:yesnoPopup("Buy", ("Buy %d %s"):format(nb, o:getName{do_color=true, no_count=true}), function(ok) if ok then
self:onBuy(who, o, item, nb, true)
local store, inven = self:getInven("INVEN"), who:getInven("INVEN")
for i = 1, nb do
local o = self:removeObject(store, item)
......@@ -111,7 +112,7 @@ function _M:doBuy(who, o, item, nb, store_dialog)
who:sortInven(inven)
self.changed = true
who.changed = true
self:onBuy(who, o, item, nb)
self:onBuy(who, o, item, nb, false)
if store_dialog then store_dialog:updateStore() end
end end, "Buy", "Cancel")
end
......@@ -123,6 +124,7 @@ function _M:doSell(who, o, item, nb, store_dialog)
nb = self:trySell(who, o, item, nb)
if nb then
Dialog:yesnoPopup("Sell", ("Sell %d %s"):format(nb, o:getName{do_color=true, no_count=true}), function(ok) if ok then
self:onSell(who, o, item, nb, true)
local store, inven = self:getInven("INVEN"), who:getInven("INVEN")
for i = 1, nb do
local o = who:removeObject(inven, item)
......@@ -132,7 +134,7 @@ function _M:doSell(who, o, item, nb, store_dialog)
who:sortInven(inven)
self.changed = true
who.changed = true
self:onSell(who, o, item, nb)
self:onSell(who, o, item, nb, false)
if store_dialog then store_dialog:updateStore() end
end end, "Sell", "Cancel")
end
......@@ -164,7 +166,8 @@ end
-- @param o the object trying to be purchased
-- @param item the index in the inventory
-- @param nb number of items (if stacked) to buy
function _M:onBuy(who, o, item, nb)
-- @param before true if this happens before removing the item
function _M:onBuy(who, o, item, nb, before)
end
--- Called on object sale
......@@ -172,7 +175,8 @@ end
-- @param o the object trying to be sold
-- @param item the index in the inventory
-- @param nb number of items (if stacked) to sell
function _M:onSell(who, o, item, nb)
-- @param before true if this happens before removing the item
function _M:onSell(who, o, item, nb, before)
end
--- Called to describe an object, being to sell or to buy
......
......@@ -61,8 +61,6 @@ end
function _M:trySell(who, o, item, nb)
local price = o:getPrice() * self.buy_percent / 100
if price <= 0 or nb <= 0 then return end
-- Id all
o:identify(true)
return nb
end
......@@ -71,8 +69,10 @@ end
-- @param o the object trying to be purchased
-- @param item the index in the inventory
-- @param nb number of items (if stacked) to buy
-- @param before true if this happens before removing the item
-- @return true if allowed to buy
function _M:onBuy(who, o, item, nb)
function _M:onBuy(who, o, item, nb, before)
if before then return end
local price = o:getPrice() * self.sell_percent / 100
if who.money >= price * nb then
who:incMoney(- price * nb)
......@@ -84,12 +84,14 @@ end
-- @param o the object trying to be sold
-- @param item the index in the inventory
-- @param nb number of items (if stacked) to sell
-- @param before true if this happens before removing the item
-- @return true if allowed to sell
function _M:onSell(who, o, item, nb)
function _M:onSell(who, o, item, nb, before)
if before then o:identify(true) return end
local price = o:getPrice() * self.buy_percent / 100
if price <= 0 or nb <= 0 then return end
who:incMoney(price * nb)
o:identify(true)
end
--- Called to describe an object, being to sell or to buy
......
......@@ -25,6 +25,7 @@ newChat{ id="welcome",
{"Go away; I do not care for the weak.", action=function(npc, player)
npc:disappear()
npc:removed()
player:hasQuest(npc.quest_id).abandoned = true
player:setQuestStatus(npc.quest_id, engine.Quest.FAILED)
end},
},
......
......@@ -19,7 +19,7 @@
local imbue_ring = function(npc, player)
player:showInventory("Imbue which ring?", player:getInven("INVEN"), function(o) return o.type == "jewelry" and o.subtype == "ring" and not o.egoed and not o.unique end, function(ring, ring_item)
player:showInventory("Use which gem?", player:getInven("INVEN"), function(gem) return gem.type == "gem" and gem.material_level <= ring.material_level end, function(gem, gem_item)
player:showInventory("Use which gem?", player:getInven("INVEN"), function(gem) return gem.type == "gem" and (gem.material_level or 99) <= ring.material_level end, function(gem, gem_item)
local price = 10 + gem.material_level * 5 + ring.material_level * 7
if price > player.money then require("engine.ui.Dialog"):simplePopup("Not enough money", "This costs "..price.." gold, you need more gold.") return end
......@@ -39,8 +39,8 @@ end
local artifact_imbue_ring = function(npc, player)
player:showInventory("Imbue which ring?", player:getInven("INVEN"), function(o) return o.type == "jewelry" and o.subtype == "ring" and not o.egoed and not o.unique end, function(ring, ring_item)
player:showInventory("Use which first gem?", player:getInven("INVEN"), function(gem1) return gem1.type == "gem" and gem1.material_level <= ring.material_level end, function(gem1, gem1_item)
player:showInventory("Use which second gem?", player:getInven("INVEN"), function(gem2) return gem2.type == "gem" and gem2.material_level <= ring.material_level and gem1.name ~= gem2.name end, function(gem2, gem2_item)
player:showInventory("Use which first gem?", player:getInven("INVEN"), function(gem1) return gem1.type == "gem" and (gem1.material_level or 99) <= ring.material_level end, function(gem1, gem1_item)
player:showInventory("Use which second gem?", player:getInven("INVEN"), function(gem2) return gem2.type == "gem" and (gem2.material_level or 99) <= ring.material_level and gem1.name ~= gem2.name end, function(gem2, gem2_item)
local price = 390
if price > player.money then require("engine.ui.Dialog"):simplePopup("Not enough money", "Limmir needs more gold for the magical plating.") return end
......
......@@ -36,5 +36,5 @@ newLore{
category = "history of the Sunwall",
name = "Loremaster Verutir's note",
lore = [[And boy were all the rumors about unreliable adventurers true. I'd heard that many, many escorted people die when their adventurer flees and protects himself. It is TRUE. Once I got an escort, I headed off in the right direction immediately. However, for some reason, he did not immediately follow, let alone lead. Didn't he know the way to go? Foolish man. Why am I offering my special trainings to someone who doesn't even know where the local portals are! Fortunately I survived, but no thanks to him. I won't even mention his snoring...
This Thanchir guy really really needs to find a more urban spot with accessible public transportation (no adventurers please!) However, once I could get him to talk, he does know quite a bit. Apparently, he claims some distant kinship to the first elf in these parts. They arrived by boat from some legendary land called \u201cMiddle Earth.\u201d He says that it definitely exists, but could provide no real evidence. This should be investigated further]],
This Thanchir guy really really needs to find a more urban spot with accessible public transportation (no adventurers please!) However, once I could get him to talk, he does know quite a bit. Apparently, he claims some distant kinship to the first elf in these parts. They arrived by boat from some legendary land called "Middle Earth". He says that it definitely exists, but could provide no real evidence. This should be investigated further]],
}
......@@ -247,7 +247,11 @@ desc = function(self, who)
desc[#desc+1] = ("As a reward you %s."):format(self.reward_message)
end
elseif self:isStatus(engine.Quest.FAILED) then
desc[#desc+1] = "You failed to protect the "..self.kind.name.." from death by "..self.killing_npc.."."
if self.abandoned then
desc[#desc+1] = "You abandonned "..self.kind.name.." to death."
else
desc[#desc+1] = "You failed to protect the "..self.kind.name.." from death by "..self.killing_npc.."."
end
else
desc[#desc+1] = "Escort the "..self.kind.name.." to the recall portal on level "..self.level_name.."."
end
......
......@@ -69,7 +69,7 @@ start_search = function(self, who)
game.logPlayer(game.player, "Limmir points the entrance to a cave on your map, this is supposed to be the way to the valley.")
local o = game.zone:makeEntityByName(game.level, "object", "JEWELER_SUMMON")
who:addObject(who:getInven("INVEN"), o)
if o then who:addObject(who:getInven("INVEN"), o) end
end
summon_limmir = function(self, who)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment