From 4a34788fa0b1a40429de537e1fa199366877c52f Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Fri, 13 Aug 2010 08:59:02 +0000 Subject: [PATCH] Objects can have a "carrier" table field, just like "wielder", that adds properties when carried Added five new world artifacts git-svn-id: http://svn.net-core.org/repos/t-engine4@1015 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engine/interface/ActorInventory.lua | 21 ++- game/modules/tome/class/Game.lua | 16 +- .../data/general/objects/world-artifacts.lua | 141 ++++++++++++++++++ .../tome/data/zones/trollshaws/objects.lua | 1 + 4 files changed, 173 insertions(+), 6 deletions(-) diff --git a/game/engine/interface/ActorInventory.lua b/game/engine/interface/ActorInventory.lua index cd93501518..e960d57752 100644 --- a/game/engine/interface/ActorInventory.lua +++ b/game/engine/interface/ActorInventory.lua @@ -105,10 +105,6 @@ function _M:addObject(inven_id, o) return true end ---- Called upon adding an object -function _M:onAddObject(o) -end - --- Rerturns the position of an item in the given inventory, or nil function _M:itemPosition(inven, o) inven = self:getInven(inven) @@ -176,8 +172,25 @@ function _M:removeObject(inven, item, no_unstack) return o, finish end +--- Called upon adding an object +function _M:onAddObject(o) + -- Apply carrier properties + if o.carrier then + o.carried = {} + for k, e in pairs(o.carrier) do + o.carried[k] = self:addTemporaryValue(k, e) + end + end +end + --- Called upon removing an object function _M:onRemoveObject(o) + if o.carried then + for k, id in pairs(o.carried) do + self:removeTemporaryValue(k, id) + end + end + o.carried = nil end --- Drop an object on the floor diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index a210930e70..64d9da091f 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -483,6 +483,18 @@ function _M:setupCommands() -- self.player:grantQuest("escort-duty") end end, + [{"_f","ctrl"}] = function() + if config.settings.tome.cheat then + for i, e in ipairs(self.zone.object_list) do + if e.unique and e.rarity then + local a = self.zone:finishEntity(self.level, "object", e) + a:identify(true) + self.zone:addEntity(self.level, a, "object", self.player.x, self.player.y) + end + end + self.logPlayer(self.player, "All world artifacts created.") + end + end, } self.key:addBinds { @@ -555,8 +567,8 @@ function _M:setupCommands() if self.player:attr("never_move") then self.log("You can not currently leave the level.") return end local stop = {} - for eff_id, p in pairs(game.player.tmp) do - local e = game.player.tempeffect_def[eff_id] + for eff_id, p in pairs(self.player.tmp) do + local e = self.player.tempeffect_def[eff_id] if e.status == "detrimental" then stop[#stop+1] = e.desc end end diff --git a/game/modules/tome/data/general/objects/world-artifacts.lua b/game/modules/tome/data/general/objects/world-artifacts.lua index c85d8bbd8f..1aea25624c 100644 --- a/game/modules/tome/data/general/objects/world-artifacts.lua +++ b/game/modules/tome/data/general/objects/world-artifacts.lua @@ -18,6 +18,7 @@ -- darkgod@te4.org local Stats = require "engine.interface.ActorStats" +local Talents = require "engine.interface.ActorTalents" -- This file describes artifacts not bound to a special location, they can be found anywhere newEntity{ base = "BASE_STAFF", @@ -244,6 +245,27 @@ newEntity{ base = "BASE_LONGBOW", }, } +newEntity{ base = "BASE_SLING", + unique = true, + name = "Gift to the Shire", + unided_name = "well-made sling", + desc = [[A sling with an inscription on its handle 'Given in honour of the Friendship between the King of Men and the Mayor of the Shire, and token of the alliance shared thencefrom.']], + level_range = {15, 25}, + rarity = 200, + require = { stat = { dex=26 }, }, + cost = 350, + material_level = 3, + combat = { + range = 18, + physspeed = 0.7, + }, + wielder = { + inc_stats = { [Stats.STAT_DEX] = 4, [Stats.STAT_CUN] = 3, }, + inc_damage={ [DamageType.PHYSICAL] = 15 }, + talent_cd_reduction={[Talents.T_STEADY_SHOT]=1, [Talents.T_EYE_SHOT]=2}, + }, +} + newEntity{ base = "BASE_LONGSWORD", unique = true, name = "Glamdring, the Long Sword 'Foe-Hammer'", @@ -275,3 +297,122 @@ newEntity{ base = "BASE_LONGSWORD", esp = {["humanoid/orc"]=1}, }, } + +newEntity{ base = "BASE_LEATHER_BOOT", + unique = true, + name = "Boots of Tom Bombadil", + uided_name = "pair of yellow boots", + desc = [[Old Tom Bombadil is a merry fellow. +Bright blue his jacket is, and his boots are yellow.]], + color = colors.YELLOW, + level_range = {1, 20}, + rarity = 200, + cost = 100, + material_level = 2, + wielder = { + combat_armor = 1, + combat_def = 2, + fatigue = 2, + talents_types_mastery = { ["cunning/survival"] = 0.2 }, + inc_stats = { [Stats.STAT_CUN] = 3, }, + }, + + max_power = 50, power_regen = 1, + use_power = { name = "speed boost", power = 50, + use = function(self, who) + who:setEffect(who.EFF_SPEED, 8, {power=0.20 + who:getCun() / 80}) + game.logSeen(who, "%s speeds up!", who.name:capitalize()) + end + }, +} + +newEntity{ base = "BASE_SHIELD", + unique = true, + name = "Dragon Shield of Smaug", + unided_name = "dragon shield", + desc = [[This large shield was made using scales of the dragon Smaug, killed in the Third Age by Bard I of Esgaroth.]], + color = colors.LIGHT_RED, + metallic = false, + level_range = {27, 35}, + rarity = 300, + require = { stat = { str=28 }, }, + cost = 350, + material_level = 5, + special_combat = { + dam = 58, + physcrit = 4.5, + dammod = {str=1}, + damtype = DamageType.FIRE, + }, + wielder = { + resists={[DamageType.FIRE] = 35}, + on_melee_hit={[DamageType.FIRE] = 17}, + combat_armor = 4, + combat_def = 16, + combat_def_ranged = 15, + fatigue = 20, + }, +} + +newEntity{ base = "BASE_LIGHT_ARMOR", + unique = true, + name = "Leather Armour of Eowen Nazgul-bane", + unided_name = "blackened leather armour", + level_range = {25, 40}, + rarity = 270, + cost = 200, + require = { stat = { str=22 }, }, + material_level = 4, + wielder = { + combat_def = 6, + combat_armor = 7, + fatigue = 7, + stun_immune = 0.7, + knockback_immune = 0.7, + inc_stats = { [Stats.STAT_WIL] = 5, [Stats.STAT_CON] = 4, }, + resists={[DamageType.BLIGHT] = 35}, + }, +} + +newEntity{ + unique = true, + type = "misc", subtype="egg", + unided_name = "dark egg", + name = "Mummified Egg-sac of Ungoliant", + level_range = {20, 35}, + rarity = 190, + display = "*", color=colors.DARK_GREY, image = "object/bloodstone.png", + encumber = 2, + desc = [[By what strange fate this survived, you cannot imagine. Dry and dusty to the touch, it still seems to retain some of its foul mother's unending hunger.]], + + carrier = { + lite = -2, + }, + max_power = 100, power_regen = 1, + use_power = { name = "summon spiders", power = 80, use = function(self, who) + local NPC = require "mod.class.NPC" + local list = NPC:loadList("/data/general/npcs/spider.lua") + + for i = 1, 2 do + -- Find space + local x, y = util.findFreeGrid(who.x, who.y, 5, true, {[engine.Map.ACTOR]=true}) + if not x then break end + + local e + repeat e = rng.tableRemove(list) + until not e.unique and e.rarity + + local spider = game.zone:finishEntity(game.level, "actor", e) + spider.faction = who.faction + spider.ai = "summoned" + spider.ai_real = "dumb_talented_simple" + spider.summoner = who + spider.summon_time = 10 + + game.zone:addEntity(game.level, spider, "actor", x, y) + game.level.map:particleEmitter(x, y, 1, "slime") + + game:playSoundNear(who, "talents/slime") + end + end }, +} diff --git a/game/modules/tome/data/zones/trollshaws/objects.lua b/game/modules/tome/data/zones/trollshaws/objects.lua index aa836bbfc4..ffee2c398b 100644 --- a/game/modules/tome/data/zones/trollshaws/objects.lua +++ b/game/modules/tome/data/zones/trollshaws/objects.lua @@ -26,6 +26,7 @@ newEntity{ base = "BASE_GREATMAUL", name = "Bill's Tree Trunk", unique=true, desc = [[This is a big nasty looking tree trunk that Bill was using as a weapon. It could still serve this purpose, should you be strong enough to wield it!]], require = { stat = { str=25 }, }, + rarity = false, cost = 5, combat = { dam = 30, -- GitLab