diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index f2d7b568bf66174f42b00d6a49346e4c54522596..2ca548fc070fd6382d316f2c6a1ae95ce62be1e8 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -2056,6 +2056,12 @@ function _M:die(src, death_note) p.all_kills[self.name] = p.all_kills[self.name] + 1 end + -- Ingredients + if src and self.ingredient_on_death then + local rsrc = src.resolveSource and src:resolveSource() or src + if game.party:hasMember(rsrc) then game.party:collectIngredient(self.ingredient_on_death) end + end + if self.sound_die and (self.unique or rng.chance(5)) then game:playSoundNear(self, self.sound_die) end return true diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index ffdf7a7b54d6b4c331ea8c687cc753fc42e63b8c..3d600e93a81bb1c92c970a0176ab507df35ae1e8 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -1115,12 +1115,7 @@ function _M:setupCommands() end end end end, [{"_g","ctrl"}] = function() if config.settings.cheat then - local l = {} - for tt, d in pairs(mod.class.Actor.talents_types_def) do - if d.generic and type(tt) == "string" and not tt:find("other") and not tt:find("race/") and not tt:find("undead/") then l[#l+1] = tt end - end - table.sort(l) - for i, tt in ipairs(l) do print(tt) end + for id, _ in pairs(game.party.__ingredients_def) do game.party:collectIngredient(id, rng.range(1, 3)) end end end, [{"_f","ctrl"}] = function() if config.settings.cheat then self.player.quests["love-melinda"] = nil @@ -1363,6 +1358,7 @@ function _M:setupCommands() "resume", "achievements", { "Show known Lore", function() self:unregisterDialog(menu) self:registerDialog(require("mod.dialogs.ShowLore").new("Tales of Maj'Eyal Lore", self.player)) end }, + { "Show ingredients", function() self:unregisterDialog(menu) self:registerDialog(require("mod.dialogs.ShowIngredients").new(self.party)) end }, "highscores", { "Inventory", function() self:unregisterDialog(menu) self.key:triggerVirtual("SHOW_INVENTORY") end }, { "Character Sheet", function() self:unregisterDialog(menu) self.key:triggerVirtual("SHOW_CHARACTER_SHEET") end }, diff --git a/game/modules/tome/class/Party.lua b/game/modules/tome/class/Party.lua index cc8bb400de98d6f42f79ee8b19a34d647545764b..51cd508f3e5dd6ed9a34d3244a0caeb4d2929ae2 100644 --- a/game/modules/tome/class/Party.lua +++ b/game/modules/tome/class/Party.lua @@ -23,15 +23,17 @@ local Map = require "engine.Map" local Dialog = require "engine.ui.Dialog" local GetQuantity = require "engine.dialogs.GetQuantity" local PartyOrder = require "mod.dialogs.PartyOrder" +local PartyIngredients = require "mod.class.interface.PartyIngredients" local PartyRewardSelector = require "mod.dialogs.PartyRewardSelector" module(..., package.seeall, class.inherit( - engine.Entity + engine.Entity, PartyIngredients )) function _M:init(t, no_default) t.name = t.name or "party" engine.Entity.init(self, t, no_default) + PartyIngredients.init(self, t) self.members = {} self.m_list = {} diff --git a/game/modules/tome/class/interface/Combat.lua b/game/modules/tome/class/interface/Combat.lua index 94738bdd049f8ead7e7cea74f82513408acba0db..725ab325f88972bfed7aa9df14fe74496d80dc40 100644 --- a/game/modules/tome/class/interface/Combat.lua +++ b/game/modules/tome/class/interface/Combat.lua @@ -1527,12 +1527,12 @@ function _M:hasPsiblades(main, off) if main then if not self:getInven("MAINHAND") then return end weapon = self:getInven("MAINHAND")[1] - if not weapon.combat or not weapon.psiblade_active then return nil, "unactivated psiblade" end + if not weapon or not weapon.combat or not weapon.psiblade_active then return nil, "unactivated psiblade" end end if off then if not self:getInven("OFFHAND") then return end offweapon = self:getInven("OFFHAND")[1] - if not offweapon.combat or not offweapon.psiblade_active then return nil, "unactivated psiblade" end + if not offweapon or not offweapon.combat or not offweapon.psiblade_active then return nil, "unactivated psiblade" end end return weapon, offweapon end diff --git a/game/modules/tome/class/interface/PartyIngredients.lua b/game/modules/tome/class/interface/PartyIngredients.lua new file mode 100644 index 0000000000000000000000000000000000000000..196ce50124aba45e17fb3643e6518041f279db2b --- /dev/null +++ b/game/modules/tome/class/interface/PartyIngredients.lua @@ -0,0 +1,109 @@ +-- ToME - Tales of Maj'Eyal +-- Copyright (C) 2009, 2010, 2011, 2012 Nicolas Casalini +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. +-- +-- Nicolas Casalini "DarkGod" +-- darkgod@te4.org + +require "engine.class" + +local Entity = require "engine.Entity" + +module(..., package.seeall, class.make) + +_M.__ingredients_def = {} + +local INFINITY = -1 + +--- Defines actor talents +-- Static! +function _M:loadDefinition(file, env) + local f, err = util.loadfilemods(file, setmetatable(env or { + INFINITY = INFINITY, + newIngredient = function(t) self:newIngredient(t) end, + load = function(f) self:loadDefinition(f, getfenv(2)) end + }, {__index=_G})) + if not f and err then error(err) end + f() +end + +--- Defines a new ingredient +-- Static! +function _M:newIngredient(t) + assert(t.id, "no ingredient id") + assert(t.name, "no ingredient name") + assert(t.desc, "no ingredient desc") + assert(t.icon, "no ingredient icon") + assert(t.max, "no ingredient max") + assert(t.min, "no ingredient min") + + t.display_entity = Entity.new{image=t.icon, is_ingredient=true} + + _M.__ingredients_def[t.id] = t +end + + +function _M:init(t) + self.ingredients = {} +end + +function _M:getIngredient(id) + if not self.__ingredients_def[id] then return end + return self.__ingredients_def[id] +end + +function _M:collectIngredient(id, nb, silent) + if not self.__ingredients_def[id] then return end + local d = self.__ingredients_def[id] + nb = nb or 1 + + if self.ingredients[id] == INFINITY then return end + + if d.min == INFINITY then + self.ingredients[id] = INFINITY + else + self.ingredients[id] = math.max((self.ingredients[id] or 0) + nb, d.min) + if d.max ~= INFINITY then + self.ingredients[id] = math.min(self.ingredients[id], d.max) + end + + game.log("You collect a new ingredient: #LIGHT_GREEN#%s%s#WHITE#.", d.display_entity:getDisplayString(), d.name) + end +end + +function _M:hasIngredient(id, nb) + if not self.__ingredients_def[id] then return false end + local d = self.__ingredients_def[id] + nb = nb or 1 + + if not self.ingredients[id] then return false end + if self.ingredients[id] == INFINITY then return true end + if self.ingredients[id] >= nb then return true end + return false +end + +function _M:useIngredient(id, nb) + if not self.__ingredients_def[id] then return false end + local d = self.__ingredients_def[id] + nb = nb or 1 + + if self.ingredients[id] == INFINITY then return true end + if self.ingredients[id] >= nb then + self.ingredients[id] = math.max(self.ingredients[id] - nb, d.min) + if self.ingredients[id] <= 0 then self.ingredients[id] = nil end + return true + end + return false +end diff --git a/game/modules/tome/data/chats/alchemist-derth.lua b/game/modules/tome/data/chats/alchemist-derth.lua index 336a37910b3998c290e4cbd457e4c7dce73fa3c0..7b1a97c8f5eb451a7d51a791771011aaab2ca602 100644 --- a/game/modules/tome/data/chats/alchemist-derth.lua +++ b/game/modules/tome/data/chats/alchemist-derth.lua @@ -18,7 +18,6 @@ -- darkgod@te4.org local art_list = mod.class.Object:loadList("/data/general/objects/brotherhood-artifacts.lua") -local ing_list = mod.class.Object:loadList("/data/general/objects/elixir-ingredients.lua") local alchemist_num = 1 local other_alchemist_nums = {2, 3, 4} local q = game.player:hasQuest("brotherhood-of-alchemists") diff --git a/game/modules/tome/data/chats/alchemist-elvala.lua b/game/modules/tome/data/chats/alchemist-elvala.lua index cb0c23a2baf6d029a655e4df7d9ab947f9e74a80..505a010f0f49a046a9bd178697241f3989588e40 100644 --- a/game/modules/tome/data/chats/alchemist-elvala.lua +++ b/game/modules/tome/data/chats/alchemist-elvala.lua @@ -18,7 +18,6 @@ -- darkgod@te4.org local art_list = mod.class.Object:loadList("/data/general/objects/brotherhood-artifacts.lua") -local ing_list = mod.class.Object:loadList("/data/general/objects/elixir-ingredients.lua") local alchemist_num = 2 local other_alchemist_nums = {1, 3, 4} local q = game.player:hasQuest("brotherhood-of-alchemists") diff --git a/game/modules/tome/data/chats/alchemist-hermit.lua b/game/modules/tome/data/chats/alchemist-hermit.lua index 24754a5b67580190a281cb0f84821c1a8d43d524..929b4eae4cecff01b51d2e40cf5372cc351b89c4 100644 --- a/game/modules/tome/data/chats/alchemist-hermit.lua +++ b/game/modules/tome/data/chats/alchemist-hermit.lua @@ -18,7 +18,6 @@ -- darkgod@te4.org local art_list = mod.class.Object:loadList("/data/general/objects/brotherhood-artifacts.lua") -local ing_list = mod.class.Object:loadList("/data/general/objects/elixir-ingredients.lua") local alchemist_num = 3 local other_alchemist_nums = {1, 2, 4} local q = game.player:hasQuest("brotherhood-of-alchemists") diff --git a/game/modules/tome/data/chats/alchemist-last-hope.lua b/game/modules/tome/data/chats/alchemist-last-hope.lua index 95184f0ff417d4b963809ef091d22d95c322cb1b..a69fb8d0c59f162ca5bf97c916016b851517b3b1 100644 --- a/game/modules/tome/data/chats/alchemist-last-hope.lua +++ b/game/modules/tome/data/chats/alchemist-last-hope.lua @@ -18,7 +18,6 @@ -- darkgod@te4.org local art_list = mod.class.Object:loadList("/data/general/objects/brotherhood-artifacts.lua") -local ing_list = mod.class.Object:loadList("/data/general/objects/elixir-ingredients.lua") local alchemist_num = 4 local other_alchemist_nums = {1, 2, 3} local q = game.player:hasQuest("brotherhood-of-alchemists") diff --git a/game/modules/tome/data/general/encounters/maj-eyal-npcs.lua b/game/modules/tome/data/general/encounters/maj-eyal-npcs.lua index e5e673f582b501b774443260f3a490f94bba4939..7ef9c1562c103045a17dc0fb65bdba557060c114 100644 --- a/game/modules/tome/data/general/encounters/maj-eyal-npcs.lua +++ b/game/modules/tome/data/general/encounters/maj-eyal-npcs.lua @@ -65,12 +65,10 @@ newEntity{ loot_quantity = 1, no_loot_randart = true, on_die = function(self, src) -- When they die they have a chance to drop an alchemist ingredient - local q = game.player:hasQuest("brotherhood-of-alchemists") - if q and rng.percent(30) then - local ing = rng.table(q.needed_ingredients) - if ing then - q:need_part(src, ing.define_as, self) - end + if rng.percent(30) then + local list = {} + for id, d in pairs(game.party.__ingredients_def) do if d.type == "organic" then list[#list+1] = id end end + if #list > 0 then game.party:collectIngredient(rng.table(list)) end end end }}} diff --git a/game/modules/tome/data/general/npcs/ant.lua b/game/modules/tome/data/general/npcs/ant.lua index eb7e2ae5ca65ffad7890ccddf8994ef6cb8ed6bc..b728f5163f6e3ae5b0dcea99906e2c4e4b3dc498 100644 --- a/game/modules/tome/data/general/npcs/ant.lua +++ b/game/modules/tome/data/general/npcs/ant.lua @@ -124,12 +124,7 @@ newEntity{ base = "BASE_NPC_ANT", combat = { damtype=DamageType.ICE }, combat_armor = 5, combat_def = 5, on_melee_hit = {[DamageType.ICE]=5}, - on_die = function(self, who) - local part = "FROST_ANT_STINGER" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "FROST_ANT_STINGER", } newEntity{ base = "BASE_NPC_ANT", diff --git a/game/modules/tome/data/general/npcs/aquatic_critter.lua b/game/modules/tome/data/general/npcs/aquatic_critter.lua index 907c1ed2d03466907b240393166c10d17d6a018a..f6e3add3be6c50705fcb8985322ba2317b37caec 100644 --- a/game/modules/tome/data/general/npcs/aquatic_critter.lua +++ b/game/modules/tome/data/general/npcs/aquatic_critter.lua @@ -56,12 +56,7 @@ newEntity{ base = "BASE_NPC_AQUATIC_CRITTER", autolevel = "warriormage", combat = {damtype=DamageType.LIGHTNING}, resolvers.talents{ [Talents.T_CHAIN_LIGHTNING]=3, [Talents.T_LIGHTNING]=3 }, - on_die = function(self, who) - local part = "ELECTRIC_EEL_TAIL" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "ELECTRIC_EEL_TAIL", } newEntity{ base = "BASE_NPC_AQUATIC_CRITTER", @@ -94,12 +89,7 @@ newEntity{ base = "BASE_NPC_AQUATIC_CRITTER", level_range = {1, nil}, exp_worth = 1, rarity = 1, resolvers.talents{ [Talents.T_GRAB]=3, }, - on_die = function(self, who) - local part = "SQUID_INK" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "SQUID_INK", } newEntity{ base = "BASE_NPC_AQUATIC_CRITTER", @@ -109,10 +99,5 @@ newEntity{ base = "BASE_NPC_AQUATIC_CRITTER", rarity = 2, stats = { mag=30, }, resolvers.talents{ [Talents.T_GRAB]=3, [Talents.T_BLINDING_INK]=3, }, - on_die = function(self, who) - local part = "SQUID_INK" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "SQUID_INK", } diff --git a/game/modules/tome/data/general/npcs/bear.lua b/game/modules/tome/data/general/npcs/bear.lua index 579e1dfb35397f86bb35bb2384dede72e3ce76d5..17678054f4accf0b43f5bb7d1b772d98bc1408de 100644 --- a/game/modules/tome/data/general/npcs/bear.lua +++ b/game/modules/tome/data/general/npcs/bear.lua @@ -46,12 +46,7 @@ newEntity{ resolvers.tmasteries{ ["technique/other"]=0.25 }, resists = { [DamageType.FIRE] = 20, [DamageType.COLD] = 20, [DamageType.NATURE] = 20 }, - on_die = function(self, who) - local part = "BEAR_PAW" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "BEAR_PAW", not_power_source = {arcane=true}, } diff --git a/game/modules/tome/data/general/npcs/bone-giant.lua b/game/modules/tome/data/general/npcs/bone-giant.lua index 574f21630ea7e823bc548a2bf35aa4d56bf7a7ed..1f52f1c88b5bbbda54dc1fde70e17cce93ed8240 100644 --- a/game/modules/tome/data/general/npcs/bone-giant.lua +++ b/game/modules/tome/data/general/npcs/bone-giant.lua @@ -50,12 +50,7 @@ newEntity{ stun_immune = 1, see_invisible = resolvers.mbonus(15, 5), undead = 1, - on_die = function(self, who) - local part = "BONE_GOLEM_DUST" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "BONE_GOLEM_DUST", not_power_source = {nature=true}, } diff --git a/game/modules/tome/data/general/npcs/canine.lua b/game/modules/tome/data/general/npcs/canine.lua index 4337cab3a8baa93360dc75ed50bc3423f7b4653a..6477a670eed99dd0b56ea5d18812d1df1c7e77bd 100644 --- a/game/modules/tome/data/general/npcs/canine.lua +++ b/game/modules/tome/data/general/npcs/canine.lua @@ -98,12 +98,7 @@ newEntity{ base = "BASE_NPC_CANINE", combat_armor = 5, combat_def = 7, combat = { dam=resolvers.levelup(10, 1, 1), atk=10, apr=5 }, resolvers.talents{ [Talents.T_HOWL]=3, }, - on_die = function(self, who) - local part = "WARG_CLAW" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "WARG_CLAW", } newEntity{ base = "BASE_NPC_CANINE", diff --git a/game/modules/tome/data/general/npcs/cold-drake.lua b/game/modules/tome/data/general/npcs/cold-drake.lua index 3b6e41a4005de1fe463f72a1304c6c27cf9abacf..85b877c9006e319da4adec2b60be357aa7c5c296 100644 --- a/game/modules/tome/data/general/npcs/cold-drake.lua +++ b/game/modules/tome/data/general/npcs/cold-drake.lua @@ -107,10 +107,5 @@ newEntity{ base = "BASE_NPC_COLD_DRAKE", [Talents.T_ICY_SKIN]={base=3, every=5}, [Talents.T_ICE_BREATH]={base=5, every=4}, }, - on_die = function(self, who) - local part = "ICE_WYRM_TOOTH" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "ICE_WYRM_TOOTH", } diff --git a/game/modules/tome/data/general/npcs/crystal.lua b/game/modules/tome/data/general/npcs/crystal.lua index 3486e20486581ae318353748ef7a5b9c8727148e..a4b561d05883ccb3a87beab9ae2e9f0642128995 100644 --- a/game/modules/tome/data/general/npcs/crystal.lua +++ b/game/modules/tome/data/general/npcs/crystal.lua @@ -80,12 +80,7 @@ newEntity{ base = "BASE_NPC_CRYSTAL", resolvers.talents{ [Talents.T_FLAME]={base=1, every=7, max=5}, }, - on_die = function(self, who) - local part = "RED_CRYSTAL_SHARD" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "RED_CRYSTAL_SHARD", } newEntity{ base = "BASE_NPC_CRYSTAL", diff --git a/game/modules/tome/data/general/npcs/faeros.lua b/game/modules/tome/data/general/npcs/faeros.lua index cb793fc67db28e0303ee072751567cc15ff82061..39e875f91794be3fdd357c5d4fb03b7ab2d7b92c 100644 --- a/game/modules/tome/data/general/npcs/faeros.lua +++ b/game/modules/tome/data/general/npcs/faeros.lua @@ -49,12 +49,7 @@ newEntity{ blind_immune = 1, knockback_immune = 1, confusion_immune = 1, - on_die = function(self, who) - local part = "FAEROS_ASH" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "FAEROS_ASH", } newEntity{ base = "BASE_NPC_FAEROS", diff --git a/game/modules/tome/data/general/npcs/fire-drake.lua b/game/modules/tome/data/general/npcs/fire-drake.lua index 42c4da609bb29b4bfaa777f410a3243e13617e28..164f2cf60be090e46953f2ac27e8deacfa9c8324 100644 --- a/game/modules/tome/data/general/npcs/fire-drake.lua +++ b/game/modules/tome/data/general/npcs/fire-drake.lua @@ -111,10 +111,5 @@ newEntity{ base = "BASE_NPC_FIRE_DRAKE", [Talents.T_FIRE_BREATH]={base=5, every=4}, [Talents.T_DEVOURING_FLAME]={base=5, every=6}, }, - on_die = function(self, who) - local part = "FIRE_WYRM_SALIVA" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "FIRE_WYRM_SALIVA", } diff --git a/game/modules/tome/data/general/npcs/ghoul.lua b/game/modules/tome/data/general/npcs/ghoul.lua index acc9608f186e7f68769704e9eca34ce4a9eea7ca..eb184cd8ea2786c583d1d9511fbc4f452164da98 100644 --- a/game/modules/tome/data/general/npcs/ghoul.lua +++ b/game/modules/tome/data/general/npcs/ghoul.lua @@ -43,12 +43,7 @@ newEntity{ blind_immune = 1, see_invisible = 2, undead = 1, - on_die = function(self, who) - local part = "GHOUL_FLESH" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "GHOUL_FLESH", not_power_source = {nature=true}, } diff --git a/game/modules/tome/data/general/npcs/horror.lua b/game/modules/tome/data/general/npcs/horror.lua index b5effd866af10b4a2f5cde09fcf622b98fc37667..c1610dc158c4583d13e830604b89a959b4977266 100644 --- a/game/modules/tome/data/general/npcs/horror.lua +++ b/game/modules/tome/data/general/npcs/horror.lua @@ -138,12 +138,7 @@ newEntity{ base = "BASE_NPC_HORROR", resolvers.inscriptions(1, {"shielding rune"}), resolvers.sustains_at_birth(), - on_die = function(self, who) - local part = "BLOATED_HORROR_HEART" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "BLOATED_HORROR_HEART", } newEntity{ base = "BASE_NPC_HORROR", @@ -434,12 +429,7 @@ newEntity{ base = "BASE_NPC_HORROR", make_escort = { {type="horror", subtype="eldritch", name="luminous horror", number=2, no_subescort=true}, }, - on_die = function(self, who) - local part = "LUMINOUS_HORROR_DUST" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "LUMINOUS_HORROR_DUST", } newEntity{ base = "BASE_NPC_HORROR", diff --git a/game/modules/tome/data/general/npcs/major-demon.lua b/game/modules/tome/data/general/npcs/major-demon.lua index 9b5c890926ad5d9bedfe9f8f27f004ba58c23dd7..48c89a3dc72a431f18e2627e9a63d02c5825b9f5 100644 --- a/game/modules/tome/data/general/npcs/major-demon.lua +++ b/game/modules/tome/data/general/npcs/major-demon.lua @@ -44,12 +44,7 @@ newEntity{ random_name_def = "demon", resolvers.inscriptions(1, "rune"), - on_die = function(self, who) - local part = "GREATER_DEMON_BILE" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "GREATER_DEMON_BILE", } newEntity{ base = "BASE_NPC_MAJOR_DEMON", diff --git a/game/modules/tome/data/general/npcs/minor-demon.lua b/game/modules/tome/data/general/npcs/minor-demon.lua index daefa781d89ba8d53550f7efbb31297c90d85c3f..bbf94dc6a5fda74a7bba0b64ec12dfdb6d410450 100644 --- a/game/modules/tome/data/general/npcs/minor-demon.lua +++ b/game/modules/tome/data/general/npcs/minor-demon.lua @@ -85,12 +85,7 @@ newEntity{ base = "BASE_NPC_DEMON", make_escort = { {type="demon", subtype="minor", name="wretchling", number=rng.range(1, 4), no_subescort=true}, }, - on_die = function(self, who) - local part = "WRETCHLING_EYE" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "WRETCHLING_EYE", } newEntity{ base = "BASE_NPC_DEMON", diff --git a/game/modules/tome/data/general/npcs/minotaur.lua b/game/modules/tome/data/general/npcs/minotaur.lua index d0f5a684763e672caf62802568908aee98965e16..324d5cc3253fd1c823f238dcee748adb9457f4de 100644 --- a/game/modules/tome/data/general/npcs/minotaur.lua +++ b/game/modules/tome/data/general/npcs/minotaur.lua @@ -49,12 +49,7 @@ newEntity{ stats = { str=15, dex=12, mag=6, cun=12, con=15 }, resolvers.tmasteries{ ["technique/2hweapon-offense"]=0.3, ["technique/2hweapon-cripple"]=0.3, ["technique/combat-training"]=0.3, }, - on_die = function(self, who) - local part = "MINOTAUR_NOSE" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "MINOTAUR_NOSE", } newEntity{ base = "BASE_NPC_MINOTAUR", diff --git a/game/modules/tome/data/general/npcs/multihued-drake.lua b/game/modules/tome/data/general/npcs/multihued-drake.lua index 478e5898c83dd5f49df0297296741f38b0dde2e7..35575d18fe9e9d1bf28c9059eaf0079c428f33fe 100644 --- a/game/modules/tome/data/general/npcs/multihued-drake.lua +++ b/game/modules/tome/data/general/npcs/multihued-drake.lua @@ -133,12 +133,7 @@ newEntity{ base = "BASE_NPC_MULTIHUED_DRAKE", define_as = "GREATER_MULTI_HUED_WY [Talents.T_LIGHTNING_BREATH]={base=9, every=4}, [Talents.T_ACID_BREATH]={base=9, every=4}, }, - on_die = function(self, who) - local part = "MULTIHUED_WYRM_SCALE" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "MULTIHUED_WYRM_SCALE", } newEntity{ base = "BASE_NPC_MULTIHUED_DRAKE", diff --git a/game/modules/tome/data/general/npcs/mummy.lua b/game/modules/tome/data/general/npcs/mummy.lua index e9c1386ee690722f33e9d8f108b6f937e8a34f09..1221b67de07defc4c4fc182599db7a9324270c18 100644 --- a/game/modules/tome/data/general/npcs/mummy.lua +++ b/game/modules/tome/data/general/npcs/mummy.lua @@ -46,11 +46,6 @@ newEntity{ blind_immune = 1, see_invisible = 4, undead = 1, - on_die = function(self, who) - local part = "MUMMY_BONE" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "MUMMY_BONE", not_power_source = {nature=true}, } diff --git a/game/modules/tome/data/general/npcs/naga.lua b/game/modules/tome/data/general/npcs/naga.lua index ae89771e5d8e2a4a3f8d52f27647d291e23afdd2..cc68f3e17d69226f64c039fa54b256992973424c 100644 --- a/game/modules/tome/data/general/npcs/naga.lua +++ b/game/modules/tome/data/general/npcs/naga.lua @@ -46,12 +46,7 @@ newEntity{ ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=1, }, global_speed_base = 1.2, stats = { str=15, dex=15, mag=15, con=10 }, - on_die = function(self, who) - local part = "NAGA_TONGUE" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "NAGA_TONGUE", } newEntity{ base = "BASE_NPC_NAGA", diff --git a/game/modules/tome/data/general/npcs/orc-gorbat.lua b/game/modules/tome/data/general/npcs/orc-gorbat.lua index 0fca0712bf869dd39b23ebc8f7719a2a8d08eb61..a9dc4faa232d4a88adc00482b131ad33dfc75ad1 100644 --- a/game/modules/tome/data/general/npcs/orc-gorbat.lua +++ b/game/modules/tome/data/general/npcs/orc-gorbat.lua @@ -47,12 +47,7 @@ newEntity{ autolevel = "warrior", ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, }, stats = { str=20, dex=8, mag=6, con=16 }, - on_die = function(self, who) - local part = "ORC_HEART" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "ORC_HEART", } newEntity{ base = "BASE_NPC_ORC_GORBAT", diff --git a/game/modules/tome/data/general/npcs/orc-grushnak.lua b/game/modules/tome/data/general/npcs/orc-grushnak.lua index ede68775d5cf561f57f289aadc276e964a07fc21..f01b7ad1318e70805612b565cbfcda09e56869ad 100644 --- a/game/modules/tome/data/general/npcs/orc-grushnak.lua +++ b/game/modules/tome/data/general/npcs/orc-grushnak.lua @@ -46,12 +46,7 @@ newEntity{ autolevel = "warrior", ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, }, stats = { str=20, dex=8, mag=6, con=16 }, - on_die = function(self, who) - local part = "ORC_HEART" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "ORC_HEART", } newEntity{ base = "BASE_NPC_ORC_GRUSHNAK", diff --git a/game/modules/tome/data/general/npcs/orc-rak-shor.lua b/game/modules/tome/data/general/npcs/orc-rak-shor.lua index a3feacd4bf9c803ec163dc4bad1f465be4f47635..34946b1b2a4a612c16fb27562d2514c9623f6af7 100644 --- a/game/modules/tome/data/general/npcs/orc-rak-shor.lua +++ b/game/modules/tome/data/general/npcs/orc-rak-shor.lua @@ -45,12 +45,7 @@ newEntity{ autolevel = "caster", ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=1, }, stats = { str=20, dex=8, mag=6, con=16 }, - on_die = function(self, who) - local part = "ORC_HEART" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "ORC_HEART", } newEntity{ base = "BASE_NPC_ORC_RAK_SHOR", diff --git a/game/modules/tome/data/general/npcs/orc-vor.lua b/game/modules/tome/data/general/npcs/orc-vor.lua index 191fd2ff2bd6bf7fa61c63917d3ed26129061141..8b0d034cfbb05f1d6583aa28e483d9e6f8a76f5d 100644 --- a/game/modules/tome/data/general/npcs/orc-vor.lua +++ b/game/modules/tome/data/general/npcs/orc-vor.lua @@ -47,12 +47,7 @@ newEntity{ autolevel = "caster", ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=1, }, stats = { str=10, dex=8, mag=20, con=16 }, - on_die = function(self, who) - local part = "ORC_HEART" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "ORC_HEART", } newEntity{ base = "BASE_NPC_ORC_VOR", diff --git a/game/modules/tome/data/general/npcs/orc.lua b/game/modules/tome/data/general/npcs/orc.lua index ee3395e03b6ebe4d5fa0d29dcf5b5c45afb85837..1cdd26edb51c321a0b02725c6a8972a757f6b115 100644 --- a/game/modules/tome/data/general/npcs/orc.lua +++ b/game/modules/tome/data/general/npcs/orc.lua @@ -43,12 +43,7 @@ newEntity{ ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, }, stats = { str=20, dex=8, mag=6, con=16 }, resolvers.talents{ [Talents.T_WEAPON_COMBAT]={base=1, every=5, max=10}, }, - on_die = function(self, who) - local part = "ORC_HEART" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "ORC_HEART", } newEntity{ base = "BASE_NPC_ORC", diff --git a/game/modules/tome/data/general/npcs/plant.lua b/game/modules/tome/data/general/npcs/plant.lua index 58b90fc99e14b07995ca0b713bf8793258b0d558..e58948579edd4fd66f11e80ce1a2df5df7046da5 100644 --- a/game/modules/tome/data/general/npcs/plant.lua +++ b/game/modules/tome/data/general/npcs/plant.lua @@ -102,10 +102,5 @@ newEntity{ base = "BASE_NPC_PLANT", }, resolvers.talents{ [Talents.T_SUMMON]=1 }, - on_die = function(self, who) - local part = "HONEY_TREE_ROOT" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "HONEY_TREE_ROOT", } diff --git a/game/modules/tome/data/general/npcs/ritch.lua b/game/modules/tome/data/general/npcs/ritch.lua index 40e24bf162925f132fabe3a38e00c3cc50eb2a48..83d238034ddab96e489d4fb69b1880cb5634d105 100644 --- a/game/modules/tome/data/general/npcs/ritch.lua +++ b/game/modules/tome/data/general/npcs/ritch.lua @@ -43,12 +43,7 @@ Vicious predators, they inject corrupting diseases into their foes, and their sh poison_immune = 0.5, disease_immune = 0.5, resists = { [DamageType.BLIGHT] = 20, [DamageType.FIRE] = 100 }, - on_die = function(self, who) - local part = "RITCH_STINGER" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "RITCH_STINGER", not_power_source = {arcane=true}, } diff --git a/game/modules/tome/data/general/npcs/sandworm.lua b/game/modules/tome/data/general/npcs/sandworm.lua index 19eb7832809e7846f8811053e9d6fec7e2b54151..ca836c40485dd7abd1fef6311906a6b36c814a1d 100644 --- a/game/modules/tome/data/general/npcs/sandworm.lua +++ b/game/modules/tome/data/general/npcs/sandworm.lua @@ -43,12 +43,7 @@ newEntity{ ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, }, stats = { str=15, dex=7, mag=3, con=3 }, combat_armor = 1, combat_def = 1, - on_die = function(self, who) - local part = "SANDWORM_TOOTH" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "SANDWORM_TOOTH", not_power_source = {arcane=true}, } diff --git a/game/modules/tome/data/general/npcs/skeleton.lua b/game/modules/tome/data/general/npcs/skeleton.lua index e699d78e67e560749020414935ff7ad327e15f0f..9397d1d19d089d8ecc187008dcb9e7342c407b30 100644 --- a/game/modules/tome/data/general/npcs/skeleton.lua +++ b/game/modules/tome/data/general/npcs/skeleton.lua @@ -89,12 +89,7 @@ newEntity{ base = "BASE_NPC_SKELETON", autolevel = "caster", ai = "dumb_talented_simple", ai_state = { talent_in=3, }, - on_die = function(self, who) - local part = "SKELETON_MAGE_SKULL" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "SKELETON_MAGE_SKULL", } newEntity{ base = "BASE_NPC_SKELETON", diff --git a/game/modules/tome/data/general/npcs/snake.lua b/game/modules/tome/data/general/npcs/snake.lua index 96d9d9d7d2eaac1d879c8eee9049d4c4efe824d2..59b63ea8591073003524bc9c32cc14e2ac29ebe1 100644 --- a/game/modules/tome/data/general/npcs/snake.lua +++ b/game/modules/tome/data/general/npcs/snake.lua @@ -109,12 +109,7 @@ newEntity{ base = "BASE_NPC_SNAKE", combat = { dam=resolvers.levelup(10, 1, 0.7), atk=10, apr=10 }, resolvers.talents{ [Talents.T_BITE_POISON]=3 }, - on_die = function(self, who) - local part = "BLACK_MAMBA_HEAD" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "BLACK_MAMBA_HEAD", } newEntity{ base = "BASE_NPC_SNAKE", diff --git a/game/modules/tome/data/general/npcs/snow-giant.lua b/game/modules/tome/data/general/npcs/snow-giant.lua index ecc46ee058c73a56a9c7435577cdd92b44b35db7..8137e28bf2195cea200182687985255bd1987182 100644 --- a/game/modules/tome/data/general/npcs/snow-giant.lua +++ b/game/modules/tome/data/general/npcs/snow-giant.lua @@ -46,12 +46,7 @@ newEntity{ no_breath = 1, confusion_immune = 1, poison_immune = 1, - on_die = function(self, who) - local part = "SNOW_GIANT_KIDNEY" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "SNOW_GIANT_KIDNEY", } newEntity{ base = "BASE_NPC_SNOW_GIANT", diff --git a/game/modules/tome/data/general/npcs/spider.lua b/game/modules/tome/data/general/npcs/spider.lua index cf0848778a14685da88a8f2dd0e53541ebdedfe1..04fb9025550c41c3c8ecb6b47b999db5eb490230 100644 --- a/game/modules/tome/data/general/npcs/spider.lua +++ b/game/modules/tome/data/general/npcs/spider.lua @@ -61,12 +61,7 @@ newEntity{ base = "BASE_NPC_SPIDER", [Talents.T_SPIDER_WEB]={base=1, every=10, max=5}, [Talents.T_LAY_WEB]={base=1, every=10, max=5}, }, - on_die = function(self, who) - local part = "SPIDER_SPINNERET" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "SPIDER_SPINNERET", } newEntity{ base = "BASE_NPC_SPIDER", @@ -181,13 +176,7 @@ newEntity{ base = "BASE_NPC_SPIDER", [Talents.T_DISRUPTION_SHIELD]={base=3, every=6, max=6}, [Talents.T_ARCANE_POWER]={base=3, every=6, max=6}, }, - on_die = function(self, who) - local part = "FAERLHING_FANG" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, - + ingredient_on_death = "FAERLHING_FANG", } -- the brethren of Ungoliant :D tough and deadly, probably too tough, but meh <evil laughter> diff --git a/game/modules/tome/data/general/npcs/storm-drake.lua b/game/modules/tome/data/general/npcs/storm-drake.lua index 963c225ef7463e55dbf52be1cd206fd567a2c7e3..a535734b429b087b1e78ffe286662cfd23d83d7f 100644 --- a/game/modules/tome/data/general/npcs/storm-drake.lua +++ b/game/modules/tome/data/general/npcs/storm-drake.lua @@ -111,10 +111,5 @@ newEntity{ base = "BASE_NPC_STORM_DRAKE", [Talents.T_STATIC_FIELD]={base=3, every=10}, [Talents.T_TORNADO]={base=5, every=4}, }, - on_die = function(self, who) - local part = "STORM_WYRM_CLAW" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "STORM_WYRM_CLAW", } diff --git a/game/modules/tome/data/general/npcs/swarm.lua b/game/modules/tome/data/general/npcs/swarm.lua index 07748eb847d76637336a910d5441bffa2cdd2a51..dec4aecf7b38d98b291148eeb938852fb28dd774 100644 --- a/game/modules/tome/data/general/npcs/swarm.lua +++ b/game/modules/tome/data/general/npcs/swarm.lua @@ -89,10 +89,5 @@ newEntity{ base = "BASE_NPC_INSECT", can_multiply = 4, resolvers.talents{ [Talents.T_BITE_POISON]={base=3, every=10, max=8} }, - on_die = function(self, who) - local part = "HUMMERHORN_WING" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "HUMMERHORN_WING", } diff --git a/game/modules/tome/data/general/npcs/troll.lua b/game/modules/tome/data/general/npcs/troll.lua index 4bb6f5934aa5bf5f33e6adf052f5846de73ca0fd..7ae8d4ad2b6ff6d6e6c3812ac68ecd6d0d2f7870 100644 --- a/game/modules/tome/data/general/npcs/troll.lua +++ b/game/modules/tome/data/general/npcs/troll.lua @@ -50,12 +50,7 @@ newEntity{ resists = { [DamageType.FIRE] = -50 }, fear_immune = 1, - on_die = function(self, who) - local part = "TROLL_INTESTINE" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "TROLL_INTESTINE", } newEntity{ base = "BASE_NPC_TROLL", diff --git a/game/modules/tome/data/general/npcs/vampire.lua b/game/modules/tome/data/general/npcs/vampire.lua index 22fbdb37dcf11200f544d64bc67837303c9bdd7b..25d0e2181d4347fea16a2c1f61a4265cffdc4e02 100644 --- a/game/modules/tome/data/general/npcs/vampire.lua +++ b/game/modules/tome/data/general/npcs/vampire.lua @@ -127,12 +127,7 @@ It can summon the very shades of its victims from beyond the grave to come ensla [Talents.T_ROTTING_DISEASE]={base=3, every=7, max=7}, [Talents.T_FORGERY_OF_HAZE]={base=2, every=7, max=5}, }, - on_die = function(self, who) - local part = "ELDER_VAMPIRE_BLOOD" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "ELDER_VAMPIRE_BLOOD", } newEntity{ base = "BASE_NPC_VAMPIRE", @@ -158,12 +153,7 @@ newEntity{ base = "BASE_NPC_VAMPIRE", make_escort = { {type="undead", number=resolvers.mbonus(2, 2)}, }, - on_die = function(self, who) - local part = "VAMPIRE_LORD_FANG" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "VAMPIRE_LORD_FANG", } -- Arch Zephyr, Vampiric Storm Lord. Wields a bow and lightning magic with equal effectiveness, and moves quickly. diff --git a/game/modules/tome/data/general/npcs/vermin.lua b/game/modules/tome/data/general/npcs/vermin.lua index 03a5142235c24495d743fff6a2904d72996cc7a5..55a60fce5709a8e4fa01c9d5e569d9d462f14da1 100644 --- a/game/modules/tome/data/general/npcs/vermin.lua +++ b/game/modules/tome/data/general/npcs/vermin.lua @@ -60,12 +60,7 @@ newEntity{ base = "BASE_NPC_WORM", combat = { dam=1, atk=3, apr=100 }, resolvers.talents{ [Talents.T_CRAWL_ACID]=2, [Talents.T_MULTIPLY]=1 }, - on_die = function(self, who) - local part = "GREEN_WORM" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "GREEN_WORM", } newEntity{ base = "BASE_NPC_WORM", define_as = "CARRION_WORM_MASS", diff --git a/game/modules/tome/data/general/npcs/wight.lua b/game/modules/tome/data/general/npcs/wight.lua index d6e33306ed773d89e455ac4acfac15eb351d7d06..713ac801334845b84e8ccaa572127302b242997b 100644 --- a/game/modules/tome/data/general/npcs/wight.lua +++ b/game/modules/tome/data/general/npcs/wight.lua @@ -57,12 +57,7 @@ newEntity{ undead = 1, -- free_action = 1, -- sleep_immune = 1, - on_die = function(self, who) - local part = "WIGHT_ECTOPLASM" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "WIGHT_ECTOPLASM", not_power_source = {nature=true}, } diff --git a/game/modules/tome/data/general/npcs/xorn.lua b/game/modules/tome/data/general/npcs/xorn.lua index 75ab096ac41c1665691a0953b9e8a19cd19ef4b8..c2e05dfa637de89c2a7322751bb9dab0b18261e0 100644 --- a/game/modules/tome/data/general/npcs/xorn.lua +++ b/game/modules/tome/data/general/npcs/xorn.lua @@ -51,12 +51,7 @@ newEntity{ confusion_immune = 1, poison_immune = 1, stone_immune = 1, - on_die = function(self, who) - local part = "XORN_FRAGMENT" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "XORN_FRAGMENT", not_power_source = {arcane=true}, } diff --git a/game/modules/tome/data/ingredients.lua b/game/modules/tome/data/ingredients.lua new file mode 100644 index 0000000000000000000000000000000000000000..01c727c6f2c50e8292e44c31a3d94e12d7b3de72 --- /dev/null +++ b/game/modules/tome/data/ingredients.lua @@ -0,0 +1,342 @@ +-- ToME - Tales of Maj'Eyal +-- Copyright (C) 2009, 2010, 2011, 2012 Nicolas Casalini +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. +-- +-- Nicolas Casalini "DarkGod" +-- darkgod@te4.org + +newIngredient{ id = "TROLL_INTESTINE", + type = "organic", + icon = "object/troll_intestine.png", + name = "length of troll intestine", + desc = [[A length of troll intestines. Fortunately, the troll appears to have eaten nothing in some time.]], + min = 0, max = INFINITY, + alchemy_text = "Kindly empty it before returning.", +} + +newIngredient{ id = "SKELETON_MAGE_SKULL", + type = "organic", + icon = "object/skeleton_mage_skull.png", + name = "skeleton mage skull", + desc = [[The skull of a skeleton mage. The eyes have stopped glowing... for now.]], + min = 0, max = INFINITY, + alchemy_text = "If the eyes are still glowing, please bash it around a bit until they fade. I'll not have another one of those coming alive and wreaking havoc in my lab.", +} + +newIngredient{ id = "RITCH_STINGER", + type = "organic", + icon = "object/ritch_stinger.png", + name = "ritch stinger", + desc = [[A ritch stinger, still glistening with venom.]], + min = 0, max = INFINITY, + alchemy_text = "Keep as much venom in it as possible.", +} + +newIngredient{ id = "ORC_HEART", + type = "organic", + icon = "object/orc_heart.png", + name = "orc heart", + desc = [[The heart of an orc. Perhaps surprisingly, it isn't green.]], + min = 0, max = INFINITY, + alchemy_text = "If you can fetch me a still-beating orc heart, that would be even better. But you don't look like a master necromancer to me.", +} + +newIngredient{ id = "NAGA_TONGUE", + type = "organic", + icon = "object/naga_tongue.png", + name = "naga tongue", + desc = [[A severed naga tongue. It reeks of brine.]], + min = 0, max = INFINITY, + alchemy_text = "Best results occur with tongues never tainted by profanity, so if you happen to know any saintly nagas...", +} + +newIngredient{ id = "GREATER_DEMON_BILE", + type = "organic", + icon = "object/phial_demon_blood.png", + name = "vial of greater demon bile", + desc = [[A vial of greater demon bile. It hurts your sinuses even with the vial's stopper firmly in place.]], + min = 0, max = INFINITY, + alchemy_text = "Don't drink it, even if it tells you to.", +} + +newIngredient{ id = "BONE_GOLEM_DUST", + type = "organic", + icon = "object/pouch_bone_giant_dust.png", + name = "pouch of bone giant dust", + desc = [[Once the magics animating the bone giant fled, its remains crumbled to dust. It might be your imagination, but it looks like the dust occasionally stirs on its own.]], + min = 0, max = INFINITY, + alchemy_text = "Never, ever to be confused with garlic powder. Trust me.", +} + +newIngredient{ id = "FROST_ANT_STINGER", + type = "organic", + icon = "object/ice_ant_stinger.png", + name = "ice ant stinger", + desc = [[Wickedly sharp and still freezing cold.]], + min = 0, max = INFINITY, + alchemy_text = "If you've the means to eliminate the little venom problem, these make miraculous instant drink-chilling straws.", +} + +newIngredient{ id = "MINOTAUR_NOSE", + type = "organic", + icon = "object/minotaur_nose.png", + name = "minotaur nose", + desc = [[The severed front half of a minotaur snout, ring and all.]], + min = 0, max = INFINITY, + alchemy_text = "You'll need to find one with a ring, preferably an expensive one.", +} + +newIngredient{ id = "ELDER_VAMPIRE_BLOOD", + type = "organic", + icon = "object/vial_elder_vampire_blood.png", + name = "vial of elder vampire blood", + desc = [[Thick, clotted, and foul. The vial is cold to the touch.]], + min = 0, max = INFINITY, + alchemy_text = "Once you've gotten it, cross some moving water on your way back.", +} + +newIngredient{ id = "MULTIHUED_WYRM_SCALE", + type = "organic", + icon = "object/dragon_scale_multihued.png", + name = "multi-hued wyrm scale", + desc = [[Beautiful and nearly impregnable. Separating it from the dragon must have been hard work.]], + min = 0, max = INFINITY, + alchemy_text = "If you think collecting one of these is hard, try liquefying one.", +} + +newIngredient{ id = "SPIDER_SPINNERET", + type = "organic", + icon = "object/spider_spinnarets.png", + name = "giant spider spinneret", + desc = [[An ugly, ripped-out chunk of giant spider. Bits of silk protrude from an orifice.]], + min = 0, max = INFINITY, + alchemy_text = "The spiders in your barn won't do. You'll know a giant spider when you see one, though they're rare in Maj'Eyal.", +} + +newIngredient{ id = "HONEY_TREE_ROOT", + type = "organic", + icon = "object/honey_tree_root.png", + name = "honey tree root", + desc = [[The severed end of one of a honey tree's roots. It wriggles around occasionally, seemingly unwilling to admit that it's dead... and a *plant*.]], + min = 0, max = INFINITY, + alchemy_text = "Keep a firm grip on it. These things will dig themselves right back into the ground if you drop them.", +} + +newIngredient{ id = "BLOATED_HORROR_HEART", + type = "organic", + icon = "object/bloated_horror_heart.png", + name = "bloated horror heart", + desc = [[Diseased-looking and reeking. It seems to be decaying as you watch.]], + min = 0, max = INFINITY, + alchemy_text = "Don't worry if it dissolves. Just don't get any on you.", +} + +newIngredient{ id = "ELECTRIC_EEL_TAIL", + type = "organic", + icon = "object/electric_eel_tail.png", + name = "electric eel tail", + desc = [[Slimy, wriggling, and crackling with electricity.]], + min = 0, max = INFINITY, + alchemy_text = "I know, I know. Where does the eel stop and the tail start? It doesn't much matter. The last ten inches or so should do nicely.", +} + +newIngredient{ id = "SQUID_INK", + type = "organic", + icon = "object/vial_squid_ink.png", + name = "vial of squid ink", + desc = [[Thick, black and opaque.]], + min = 0, max = INFINITY, + alchemy_text = "However annoying this will be for you to gather, I promise that the reek it produces in my lab will prove even more annoying.", +} + +newIngredient{ id = "BEAR_PAW", + type = "organic", + icon = "object/bear_paw.png", + name = "bear paw", + desc = [[Large and hairy with flesh-rending claws. It smells slightly of fish.]], + min = 0, max = INFINITY, + alchemy_text = "You'd think I could get one of these from a local hunter, but they've had no luck. Don't get eaten.", +} + +newIngredient{ id = "ICE_WYRM_TOOTH", + type = "organic", + icon = "object/frost_wyrm_tooth.png", + name = "ice wyrm tooth", + desc = [[This tooth has been blunted with age, but still looks more than capable of doing its job.]], + min = 0, max = INFINITY, + alchemy_text = "Ice Wyrms lose teeth fairly often, so you might get lucky and not have to do battle with one. But dress warm just in case.", +} + +newIngredient{ id = "RED_CRYSTAL_SHARD", + type = "organic", + icon = "object/red_crystal_shard.png", + name = "red crystal shard", + desc = [[Tiny flames still dance etherally inside this transparent crystal, though its heat seems to have faded... you hope.]], + min = 0, max = INFINITY, + alchemy_text = "I hear these can be found in a cave near Elvala. I also hear that they can cause you to spontaneously combust, so no need to explain if you come back hideously scarred.", +} + +newIngredient{ id = "FIRE_WYRM_SALIVA", + type = "organic", + icon = "object/vial_fire_wyrm_saliva.png", + name = "vial of fire wyrm saliva", + desc = [[Clear and slightly thicker than water. It froths when shaken.]], + min = 0, max = INFINITY, + alchemy_text = "Keep this stuff well away from your campfire unless you want me to have to find a new, more alive adventurer.", +} + +newIngredient{ id = "GHOUL_FLESH", + type = "organic", + icon = "object/ghoul_flesh.png", + name = "chunk of ghoul flesh", + desc = [[Rotten and reeking. It still twitches occasionally.]], + min = 0, max = INFINITY, + alchemy_text = "Unfortunately for you, the chunks that regularly fall off ghouls won't do. I need one freshly carved off.", +} + +newIngredient{ id = "MUMMY_BONE", + type = "organic", + icon = "object/mummified_bone.png", + name = "mummified bone", + desc = [[Bits of dry flesh still cling to this ancient bone.]], + min = 0, max = INFINITY, + alchemy_text = "That is, a bone from a corpse that's undergone mummification. Actually, any bit of the body would do, but the bones are the only parts you're certain to find when you kick a mummy apart. I recommend finding one that doesn't apply curses.", +} + +newIngredient{ id = "SANDWORM_TOOTH", + type = "organic", + icon = "object/sandworm_tooth.png", + name = "sandworm tooth", + desc = [[Tiny, dark grey, and wickedly sharp. It looks more like rock than bone.]], + min = 0, max = INFINITY, + alchemy_text = "Yes, sandworms have teeth. They're just very small and well back from where you're ever likely to see them and live.", +} + +newIngredient{ id = "BLACK_MAMBA_HEAD", + type = "organic", + icon = "object/black_mamba_head.png", + name = "black mamba head", + desc = [[Unlike the rest of the black mamba, the severed head isn't moving.]], + min = 0, max = INFINITY, + alchemy_text = "If you get bitten, I can save your life if you still manage to bring back the head... and if it happens within about a minute from my door. Good luck.", +} + +newIngredient{ id = "SNOW_GIANT_KIDNEY", + type = "organic", + icon = "object/snow_giant_kidney.png", + name = "snow giant kidney", + desc = [[As unpleasant-looking as any exposed organ.]], + min = 0, max = INFINITY, + alchemy_text = "I suggest not killing the snow giant by impaling it through the kidneys. You'll just have to find another.", +} + +newIngredient{ id = "STORM_WYRM_CLAW", + type = "organic", + icon = "object/storm_wyrm_claw.png", + name = "storm wyrm claw", + desc = [[Bluish and wickedly sharp. It makes your arm hair stand on end.]], + min = 0, max = INFINITY, + alchemy_text = "I recommend severing one of dewclaws. They're smaller and easier to remove, but they've never been blunted by use, so be careful you don't poke yourself. Oh yes, and don't get eaten.", +} + +newIngredient{ id = "GREEN_WORM", + type = "organic", + icon = "object/green_worm.png", + name = "green worm", + desc = [[A dead green worm, painstakingly separated from its tangle of companions.]], + min = 0, max = INFINITY, + alchemy_text = "Try to get any knots out before returning. Wear gloves.", +} + +newIngredient{ id = "WIGHT_ECTOPLASM", + type = "organic", + icon = "object/vial_wight_ectoplasm.png", + name = "vial of wight ectoplasm", + desc = [[Cloudy and thick. Only by bottling it can you prevent it from evaporating within minutes.]], + min = 0, max = INFINITY, + alchemy_text = "If you ingest any of this, never mind coming back here. Please.", +} + +newIngredient{ id = "XORN_FRAGMENT", + type = "organic", + icon = "object/xorn_fragment.png", + name = "xorn fragment", + desc = [[Looks much like any other rock, though this one was recently sentient and trying to murder you.]], + min = 0, max = INFINITY, + alchemy_text = "Avoid fragments that contained the xorn's eyes. You've no idea how unpleasant it is being watched by your ingredients.", +} + +newIngredient{ id = "WARG_CLAW", + type = "organic", + icon = "object/warg_claw.png", + name = "warg claw", + desc = [[Unpleasantly large and sharp for a canine's claw.]], + min = 0, max = INFINITY, + alchemy_text = "My usual ingredient gatherers draw the line at hunting wargs. Feel free to mock them on your way back.", +} + +newIngredient{ id = "FAEROS_ASH", + type = "organic", + icon = "object/pharao_ash.png", + name = "pouch of faeros ash", + desc = [[Unremarkable grey ash.]], + min = 0, max = INFINITY, + alchemy_text = "They're creatures of pure flame, and likely of extraplanar origin, but the ash of objects consumed by their fire has remarkable properties.", +} + +newIngredient{ id = "WRETCHLING_EYE", + type = "organic", + icon = "object/wretchling_eyeball.png", + name = "wretchling eyeball", + desc = [[Small and bloodshot. Its dead gaze still burns your skin.]], + min = 0, max = INFINITY, + alchemy_text = "Evil little things, wretchlings. Feel free to kill as many as you can, though I just need the one intact eyeball.", +} + +newIngredient{ id = "FAERLHING_FANG", + type = "organic", + icon = "object/faerlhing_fang.png", + name = "faerlhing fang", + desc = [[It still drips venom and crackles with magical energy.]], + min = 0, max = INFINITY, + alchemy_text = "I've lost a number of adventurers to this one, but I'm sure you'll be fine.", +} + +newIngredient{ id = "VAMPIRE_LORD_FANG", + type = "organic", + icon = "object/vampire_lord_fang.png", + name = "vampire lord fang", + desc = [[Brilliantly white, but surrounded by blackest magic.]], + min = 0, max = INFINITY, + alchemy_text = "You should definitely consider not pricking yourself with it.", +} + +newIngredient{ id = "HUMMERHORN_WING", + type = "organic", + icon = "object/hummerhorn_wing.png", + name = "hummerhorn wing", + desc = [[Translucent and delicate-looking, but surprisingly durable.]], + min = 0, max = INFINITY, + alchemy_text = "If you've not encountered hummerhorns before, they're like wasps, only gigantic and lethal.", +} + +newIngredient{ id = "LUMINOUS_HORROR_DUST", + type = "organic", + icon = "object/pouch_luminous_horror_dust.png", + name = "pouch of luminous horror dust", + desc = [[Weightless and glowing; not your usual dust.]], + min = 0, max = INFINITY, + alchemy_text = "Not to be confused with radiant horrors. If you encounter the latter, then I suppose there are always more adventurers.", +} diff --git a/game/modules/tome/data/quests/brotherhood-of-alchemists.lua b/game/modules/tome/data/quests/brotherhood-of-alchemists.lua index 5f1812c8dbd8f01f0eb8bb5d22106cc908aeeee7..3152ec2c608a49851f6960ed3a563728a86e1e60 100644 --- a/game/modules/tome/data/quests/brotherhood-of-alchemists.lua +++ b/game/modules/tome/data/quests/brotherhood-of-alchemists.lua @@ -40,17 +40,17 @@ desc = function(self, player, who) elseif self:isCompleted(self.e[i][j].start) and not self:isCompleted(self.e[i][j].full) then desc[#desc+1] = ""..self.e[i][j].alchemist.." needs your help making an "..self.e[i][j].name..". He has given you some notes on the ingredients:" if not self:check_i(player, self.e[i][j].ingredients[1]) then - desc[#desc+1] = "#SLATE# * 'Needed: one "..self.e[i][j].ingredients[1].name..". "..self.e[i][j].ingredients[1].alch.."'#WHITE#" + desc[#desc+1] = "#SLATE# * 'Needed: one "..self.e[i][j].ingredients[1].name..". "..game.party:getIngredient(self.e[i][j].ingredients[1].id).alchemy_text.."'#WHITE#" else desc[#desc+1] = "#LIGHT_GREEN# * You've found the needed "..self.e[i][j].ingredients[1].name..".#WHITE#" end if not self:check_i(player, self.e[i][j].ingredients[2]) then - desc[#desc+1] = "#SLATE# * 'Needed: one "..self.e[i][j].ingredients[2].name..". "..self.e[i][j].ingredients[2].alch.."'#WHITE#" + desc[#desc+1] = "#SLATE# * 'Needed: one "..self.e[i][j].ingredients[2].name..". "..game.party:getIngredient(self.e[i][j].ingredients[2].id).alchemy_text.."'#WHITE#" else desc[#desc+1] = "#LIGHT_GREEN# * You've found the needed "..self.e[i][j].ingredients[2].name..".#WHITE#" end if not self:check_i(player, self.e[i][j].ingredients[3]) then - desc[#desc+1] = "#SLATE# * 'Needed: one "..self.e[i][j].ingredients[3].name..". "..self.e[i][j].ingredients[3].alch.."'#WHITE#" + desc[#desc+1] = "#SLATE# * 'Needed: one "..self.e[i][j].ingredients[3].name..". "..game.party:getIngredient(self.e[i][j].ingredients[3].id).alchemy_text.."'#WHITE#" else desc[#desc+1] = "#LIGHT_GREEN# * You've found the needed "..self.e[i][j].ingredients[3].name..".#WHITE#" end @@ -62,8 +62,10 @@ end on_grant = function(self, who) self.cookbook, self.elixirs, self.alchemists, self.e = self:recipes() + self.recipes = nil self.needed_ingredients = {} self.player_loses = false + game.log("#VIOLET#You can check the ingredients you possess by pressing Escape and selecting 'Show ingredients'.") end -- called whenever getting the task for or turning in an elixir. Wipes the shopping list and rewrites it. @@ -90,50 +92,23 @@ end --only used in the desc function check_i = function(self, player, ingredient) - local ing_list = mod.class.Object:loadList("/data/general/objects/elixir-ingredients.lua") - --local ing = ing_list[ingredient] - local o, item, inven_id = player:findInAllInventories(ingredient.name) - return o + return game.party:hasIngredient(ingredient.id) end --called in various chat cond functions check_ingredients = function(self, player, elixir, n) local o = {self.cookbook[elixir][1], self.cookbook[elixir][2], self.cookbook[elixir][3]} - local first_o, first_item, first_inven_id = player:findInAllInventories(o[1].name) - local second_o, second_item, second_inven_id = player:findInAllInventories(o[2].name) - local third_o, third_item, third_inven_id = player:findInAllInventories(o[3].name) + local first_o = game.party:hasIngredient(o[1].id) + local second_o = game.party:hasIngredient(o[2].id) + local third_o = game.party:hasIngredient(o[3].id) return first_o and second_o and third_o end ---called in the on_die functions of ingredient-dropping monsters to determine if they should really drop their ingredient -need_part = function(self, player, ingredient, monster) - if not player then return end - if self:isEnded() then return end - local oplayer = player - if player.resolveSource then player = player:resolveSource() end - if not player or not game.party:hasMember(player) or oplayer.suppress_alchemist_drops then return end - local list = self.needed_ingredients - local needed = false - local ing_list = mod.class.Object:loadList("/data/general/objects/elixir-ingredients.lua") - local ing = ing_list[ingredient]:clone() - ing:resolve() - ing:resolve(nil, true) - for i = 1, #list do - if list[i].name == ing.name then needed = true end - end - local o, item, inven_id = player:findInAllInventories(ing.name) - if needed and not o then - game.zone:addEntity(game.level, ing, "object", monster.x, monster.y) - end -end - --called in various chat cond functions remove_ingredients = function(self, player, elixir, n) local o = {self.cookbook[elixir][1], self.cookbook[elixir][2], self.cookbook[elixir][3]} for i = 1, 3 do - local object, item, inven_id = player:findInAllInventories(o[i].name) - player:removeObject(inven_id, item, false) - object:removed() + game.party:useIngredient(o[i].id, 1) end end @@ -224,14 +199,9 @@ winner_is = function(self, player, alchemist_num) self.player_won = true end ---list of object definitions used to randomly generate ingredients for the elixirs in the table e in the recipes function. -monster_parts = { "TROLL_INTESTINE", "SKELETON_MAGE_SKULL", "RITCH_STINGER", "ORC_HEART", "NAGA_TONGUE", "GREATER_DEMON_BILE", "BONE_GOLEM_DUST", "FROST_ANT_STINGER", "MINOTAUR_NOSE", - "ELDER_VAMPIRE_BLOOD", "MULTIHUED_WYRM_SCALE", "SPIDER_SPINNERET", "HONEY_TREE_ROOT", "BLOATED_HORROR_HEART", "ELECTRIC_EEL_TAIL", "SQUID_INK", "BEAR_PAW", "ICE_WYRM_TOOTH", - "RED_CRYSTAL_SHARD", "FIRE_WYRM_SALIVA", "GHOUL_FLESH", "MUMMY_BONE", "SANDWORM_TOOTH", "BLACK_MAMBA_HEAD", "SNOW_GIANT_KIDNEY", "STORM_WYRM_CLAW", "GREEN_WORM", - "WIGHT_ECTOPLASM", "XORN_FRAGMENT", "WARG_CLAW", "FAEROS_ASH", "WRETCHLING_EYE", "FAERLHING_FANG", "VAMPIRE_LORD_FANG", "HUMMERHORN_WING", "LUMINOUS_HORROR_DUST" } - recipes = function(self) - local ing_list = mod.class.Object:loadList("/data/general/objects/elixir-ingredients.lua") + local ing_list = {} + for id, d in pairs(game.party.__ingredients_def) do if d.alchemy_text then ing_list[#ing_list+1] = {id=id, name=d.name} end end local e = { { { @@ -246,9 +216,9 @@ recipes = function(self) poached = "fox_poached", alchemist = "Stire of Derth", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, { @@ -263,9 +233,9 @@ recipes = function(self) poached = "avoidance_poached", alchemist = "Stire of Derth", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, { @@ -280,9 +250,9 @@ recipes = function(self) poached = "precision_poached", alchemist = "Stire of Derth", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, }, @@ -299,9 +269,9 @@ recipes = function(self) poached = "mysticism_poached", alchemist = "Marus of Elvala", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, { @@ -316,9 +286,9 @@ recipes = function(self) poached = "savior_poached", alchemist = "Marus of Elvala", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, { @@ -333,9 +303,9 @@ recipes = function(self) poached = "mastery_poached", alchemist = "Marus of Elvala", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, }, @@ -352,9 +322,9 @@ recipes = function(self) poached = "force_poached", alchemist = "Agrimley the hermit", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, { @@ -369,9 +339,9 @@ recipes = function(self) poached = "serendipity_poached", alchemist = "Agrimley the hermit", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, { @@ -386,9 +356,9 @@ recipes = function(self) poached = "focus_poached", alchemist = "Agrimley the hermit", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, }, @@ -405,9 +375,9 @@ recipes = function(self) poached = "brawn_poached", alchemist = "Ungrol of Last Hope", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, { @@ -422,9 +392,9 @@ recipes = function(self) poached = "stoneskin_poached", alchemist = "Ungrol of Last Hope", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, { @@ -439,9 +409,9 @@ recipes = function(self) poached = "foundations_poached", alchemist = "Ungrol of Last Hope", ingredients = { - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], - ing_list[rng.tableRemove(self.monster_parts)], + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), + rng.tableRemove(ing_list), }, }, }, diff --git a/game/modules/tome/data/zones/slazish-fen/npcs.lua b/game/modules/tome/data/zones/slazish-fen/npcs.lua index 40c7f9d7149a5878ab86adfabece689a4bf47501..085f0246a48a6dc62f0b187435a07a555c7d2657 100644 --- a/game/modules/tome/data/zones/slazish-fen/npcs.lua +++ b/game/modules/tome/data/zones/slazish-fen/npcs.lua @@ -55,12 +55,7 @@ newEntity{ autolevel = "warrior", ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, }, stats = { str=15, dex=15, mag=15, con=10 }, - on_die = function(self, who) - local part = "NAGA_TONGUE" - if game.player:hasQuest("brotherhood-of-alchemists") then - game.player:hasQuest("brotherhood-of-alchemists"):need_part(who, part, self) - end - end, + ingredient_on_death = "NAGA_TONGUE", } newEntity{ base = "BASE_NPC_NAGA", define_as = "NAGA_TIDEWARDEN", diff --git a/game/modules/tome/dialogs/ShowIngredients.lua b/game/modules/tome/dialogs/ShowIngredients.lua new file mode 100644 index 0000000000000000000000000000000000000000..16580683399a1e74b2842f72bcee53d7ab142fdc --- /dev/null +++ b/game/modules/tome/dialogs/ShowIngredients.lua @@ -0,0 +1,76 @@ +-- ToME - Tales of Maj'Eyal +-- Copyright (C) 2009, 2010, 2011, 2012 Nicolas Casalini +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. +-- +-- Nicolas Casalini "DarkGod" +-- darkgod@te4.org + +require "engine.class" +local Dialog = require "engine.ui.Dialog" +local ListColumns = require "engine.ui.ListColumns" +local TextzoneList = require "engine.ui.TextzoneList" +local Separator = require "engine.ui.Separator" +local Image = require "engine.ui.Image" + +module(..., package.seeall, class.inherit(Dialog)) + +function _M:init(party) + self.party = party + + Dialog.init(self, "Ingredients collected", game.w * 0.8, game.h * 0.8) + + self.c_desc = TextzoneList.new{width=math.floor(self.iw / 2 - 10), scrollbar=true, height=self.ih} + + self:generateList() + + self.c_list = ListColumns.new{width=math.floor(self.iw / 2 - 10), height=self.ih - 10, scrollbar=true, sortable=true, columns={ + {name="Ingredient", width=50, display_prop="name", sort="name"}, + {name="Category", width=30, display_prop="cat", sort="cat"}, + {name="Quantity", width=20, display_prop="nb", sort="nb"}, + }, list=self.list, fct=function(item) end, select=function(item, sel) self:select(item) end} + + self:loadUI{ + {left=0, top=0, ui=self.c_list}, + {right=0, top=0, ui=self.c_desc}, + {hcenter=0, top=5, ui=Separator.new{dir="horizontal", size=self.ih - 10}}, + } + self:setFocus(self.c_list) + self:setupUI() + self:select(self.list[1]) + + self.key:addBinds{ + EXIT = function() game:unregisterDialog(self) end, + } +end + +function _M:generateList() + -- Makes up the list + local list = {} + local i = 0 + for id, nb in pairs(self.party.ingredients) do + local d = self.party:getIngredient(id) + list[#list+1] = { dname=d.name, name=d.display_entity:getDisplayString(true):add(d.name), desc=util.getval(d.desc), cat=d.type, nb=nb==-1 and "inf" or tostring(nb) } + i = i + 1 + end + -- Add known artifacts + table.sort(list, function(a, b) return a.dname < b.dname end) + self.list = list +end + +function _M:select(item) + if item then + self.c_desc:switchItem(item, ("#GOLD#Category:#AQUAMARINE# %s\n#GOLD#Ingredient:#0080FF# %s\n#GOLD#Quantity:#0080FF# %s\n#GOLD#Text:#ANTIQUE_WHITE# %s"):format(item.cat, item.name:toString(), item.nb, item.desc)) + end +end diff --git a/game/modules/tome/load.lua b/game/modules/tome/load.lua index 87e58448bcdb1745d88aa0054cf67104435c9d00..f3deb93d97118bdef8d007772f5f0a90eb27fb93 100644 --- a/game/modules/tome/load.lua +++ b/game/modules/tome/load.lua @@ -42,6 +42,7 @@ local Birther = require "engine.Birther" local Store = require "mod.class.Store" local WorldAchievements = require "mod.class.interface.WorldAchievements" local PlayerLore = require "mod.class.interface.PlayerLore" +local PartyIngredients = require "mod.class.interface.PartyIngredients" local PlayerHotkeys = require "engine.interface.PlayerHotkeys" local Quest = require "engine.Quest" local UIBase = require "engine.ui.Base" @@ -187,6 +188,9 @@ ActorInventory.equipdolls = { }}, } +-- Ingredients +PartyIngredients:loadDefinition("/data/ingredients.lua") + -- Damage types DamageType:loadDefinition("/data/damage_types.lua") diff --git a/ideas/todo b/ideas/todo index d99951a5a3f2de7042909071651bfc63041f658f..4d48d3abf9527aba44ec3f7d64ee2474b80b76d5 100644 --- a/ideas/todo +++ b/ideas/todo @@ -1,7 +1,6 @@ * RSS feed of events in a character's life, exportable to FB * PIC TALENTS AT LVL 45 FOR HIGH STAT, CLASS DEPENDANT * redo shops -* random elites wandering the levels * make low level more fun * "automatic" storage of various ingredients, replace alch quest * auto-leveling for beginners/lazy