For Addon Devs with Custom Items: Take Note. Updated!
Posted: Wed Feb 24, 2016 11:36 am
Due to the way that Ember of Rage adds Steamtech items to the Last Hope Merchant's Artifact crafting list, we need to change our way of adding items to that list or we will overwrite the Steamtech options.
New code is:
Replace Arcanum with your own addon's name and change the list of items being added.
This replaces the Chat:Add hook, the maker_list code and the chat.last_hope_merchant stuff from your hook/load.lua.
New code is:
Code: Select all
class:bindHook("Chat:load", function(self, data)
if self.name ~= "last-hope-lost-merchant" then return end
if not self:get("make") then return end
local bases = {
"voratun ritual blade",
"marble wardstone",
}
local l = self:get("make").answers
table.insert(l, {"Arcanum", action=function(npc, player)
local l = {{"I've changed my mind.", jump = "welcome"}}
self:addChat{ id="makereal",
text = [[Which kind of item would you like ?]],
answers = l,
}
for i, name in ipairs(bases) do
local dname = nil
if type(name) == "table" then name, dname = name[1], name[2] end
local not_ps, force_themes
not_ps = game.state:attrPowers(player) -- make sure randart is compatible with player
if not_ps.arcane then force_themes = {'antimagic'} end
local o, ok
local tries = 100
repeat
o = game.zone:makeEntity(game.level, "object", {name=name, ignore_material_restriction=true, no_tome_drops=true, ego_filter={keep_egos=true, ego_chance=-1000}}, nil, true)
if o then ok = true end
if o and not game.state:checkPowers(player, o, nil, "antimagic_only") then
ok = false o = nil
end
tries = tries - 1
until ok or tries < 0
if o then
if not dname then dname = o:getName{force_id=true, do_color=true, no_count=true}
else dname = "#B4B4B4#"..o:getDisplayString()..dname.."#LAST#" end
l[#l+1] = {dname, action=function(npc, player)
local art, ok
local nb = 0
repeat
art = game.state:generateRandart{base=o, lev=70, egos=4, force_themes=force_themes, forbid_power_source=not_ps}
if art then ok = true end
if art and not game.state:checkPowers(player, art, nil, "antimagic_only") then
ok = false
end
nb = nb + 1
if nb == 40 then break end
until ok
if art and nb < 40 then
art:identify(true)
player:addObject(player.INVEN_INVEN, art)
player:incMoney(-4000)
-- clear chrono worlds and their various effects
if game._chronoworlds then
game.log("#CRIMSON#Your timetravel has no effect on pre-determined outcomes such as this.")
game._chronoworlds = nil
end
if not config.settings.cheat then game:saveGame() end
self:addChat{ id="naming",
text = "Do you want to name your item?\n"..tostring(art:getTextualDesc()),
answers = {
{"Yes, please.", action=function(npc, player)
local d = require("engine.dialogs.GetText").new("Name your item", "Name", 2, 40, function(txt)
art.name = txt:removeColorCodes():gsub("#", " ")
game.log("#LIGHT_BLUE#The merchant carefully hands you: %s", art:getName{do_color=true})
end, function() game.log("#LIGHT_BLUE#The merchant carefully hands you: %s", art:getName{do_color=true}) end)
game:registerDialog(d)
end},
{"No thanks.", action=function() game.log("#LIGHT_BLUE#The merchant carefully hands you: %s", art:getName{do_color=true}) end},
},
}
return "naming"
else
self:addChat{ id="oups",
text = "Oh I am sorry, it seems we could not make the item your require.",
answers = {
{"Oh, let's try something else then.", jump="make"},
{"Oh well, maybe later then."},
},
}
return "oups"
end
end}
end
end
return "makereal"
end})
end)
This replaces the Chat:Add hook, the maker_list code and the chat.last_hope_merchant stuff from your hook/load.lua.