From e12a5b19df0e622852f557dd02834ded19b0dc92 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Thu, 3 Jan 2013 09:43:52 +0000 Subject: [PATCH] Slaves in the Ring of Blood will have all status effects removed when freed git-svn-id: http://svn.net-core.org/repos/t-engine4@6316 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engines/default/engine/Zone.lua | 2 +- game/engines/default/engine/class.lua | 10 +++++++++- game/modules/tome/class/Actor.lua | 8 ++++++++ game/modules/tome/class/Game.lua | 4 ++-- game/modules/tome/data/zones/ring-of-blood/npcs.lua | 1 + game/modules/tome/resolvers.lua | 13 +++++++++++-- 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/game/engines/default/engine/Zone.lua b/game/engines/default/engine/Zone.lua index 0e1ac8d59d..08a4ab6319 100644 --- a/game/engines/default/engine/Zone.lua +++ b/game/engines/default/engine/Zone.lua @@ -333,7 +333,7 @@ function _M:makeEntityByName(level, type, name, force_unique) resolvers.current_level = self.base_level + level.level - 1 local e - if _G.type(type) == "table" then e = type[name] + if _G.type(type) == "table" then e = type[name] type = type.__real_type or type elseif type == "actor" then e = self.npc_list[name] elseif type == "object" then e = self.object_list[name] elseif type == "grid" or type == "terrain" then e = self.grid_list[name] diff --git a/game/engines/default/engine/class.lua b/game/engines/default/engine/class.lua index af0dd5dd6e..20d5ba360e 100644 --- a/game/engines/default/engine/class.lua +++ b/game/engines/default/engine/class.lua @@ -42,6 +42,7 @@ function make(c) return c end +local skip_key = {init=true, _NAME=true, _M=true, _PACKAGE=true, new=true, _BASES=true, castAs=true} function inherit(...) local bases = {...} return function(c) @@ -49,7 +50,6 @@ function inherit(...) -- Recursive inheritance caching -- Inheritance proceeds from the first to last argument, so if the first and last base classes share a key the value will match the last base class if #bases > 1 then - local skip_key = {init=true, _NAME=true, _M=true, _PACKAGE=true, new=true, _BASES=true, castAs=true} local completed_bases = {} -- local inheritance_mapper = {} local cache_inheritance @@ -114,6 +114,14 @@ function inherit(...) end end +function _M:importInterface(base) + for k, e in pairs(base) do + if not skip_key[k] and (base[k] ~= nil) then + self[k] = base[k] + end + end +end + function _M:getClassName() return self.__CLASSNAME end diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index 0a8088e4b4..b7dd4f620d 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -4585,3 +4585,11 @@ function _M:transmoGetNumberItems() for i, o in ipairs(inven) do if o.__transmo then nb = nb + 1 end end return nb end + +function _M:transmoHelpPopup() + Dialog:simplePopup("Transmogrification Chest", "When you close the inventory window, all items in the chest will be transmogrified.") +end + +function _M:transmoGetName() + return "Transmogrification Chest" +end diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index a9fe21673a..6966f3e509 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -580,7 +580,7 @@ function _M:changeLevel(lev, zone, params) local p = self:getPlayer(true) if not params.direct_switch and p:attr("has_transmo") and p:transmoGetNumberItems() > 0 and not game.player.no_inventory_access then local d - local titleupdator = self.player:getEncumberTitleUpdator("Transmogrification Chest") + local titleupdator = self.player:getEncumberTitleUpdator(p:transmoGetName()) d = self.player:showEquipInven(titleupdator(), nil, function(o, inven, item, button, event) if not o then return end local ud = require("mod.dialogs.UseItemDialog").new(event == "button", self.player, o, item, inven, function(_, _, _, stop) @@ -604,7 +604,7 @@ function _M:changeLevel(lev, zone, params) -- Select the chest tab d.c_inven.dont_update_last_tabs = true d.c_inven:switchTab{kind="transmo"} - d:simplePopup("Transmogrification Chest", "When you close the inventory window, all items in the chest will be transmogrified.") + p:transmoHelpPopup() else self:changeLevelReal(lev, zone, params) end diff --git a/game/modules/tome/data/zones/ring-of-blood/npcs.lua b/game/modules/tome/data/zones/ring-of-blood/npcs.lua index 6c1ad5757d..dbc6dee496 100644 --- a/game/modules/tome/data/zones/ring-of-blood/npcs.lua +++ b/game/modules/tome/data/zones/ring-of-blood/npcs.lua @@ -192,6 +192,7 @@ newEntity{ base = "BASE_NPC_SLAVER", m.on_act = function(self) if self.master and self.master:attr("dead") then self.faction = "neutral" + self:removeAllEffects() self:doEmote(rng.table{"I am free!", "At last, freedom!", "Thanks for this!", "The mental hold is gone!"}, 60) self.on_act = nil self.master = nil diff --git a/game/modules/tome/resolvers.lua b/game/modules/tome/resolvers.lua index 4e93f99ebf..4ba10e241c 100644 --- a/game/modules/tome/resolvers.lua +++ b/game/modules/tome/resolvers.lua @@ -90,12 +90,21 @@ end function resolvers.calc.inventory(t, e) -- Iterate of object requests, try to create them and equip them for i, filter in ipairs(t[1]) do --- print("Inventory resolver", e.name, filter.type, filter.subtype) + print("Inventory resolver", e.name, e.filter, filter.type, filter.subtype) local o if not filter.defined then o = game.zone:makeEntity(game.level, "object", filter, nil, true) else - o = game.zone:makeEntityByName(game.level, "object", filter.defined) + if filter.base_list then + local _, _, class, file = filter.base_list:find("(.*):(.*)") + if class and file then + local base_list = require(class):loadList(file) + base_list.__real_type = "object" + o = game.zone:makeEntityByName(game.level, base_list, filter.defined) + end + else + o = game.zone:makeEntityByName(game.level, "object", filter.defined) + end end if o then -- print("Zone made us an inventory according to filter!", o:getName()) -- GitLab