diff --git a/game/engine/Object.lua b/game/engine/Object.lua index 442d32949c2e2ac7ce1d7ba6e4145ec43ff1fa06..23316ccc152ae6e75898bcb7308a6d8cfad30d74 100644 --- a/game/engine/Object.lua +++ b/game/engine/Object.lua @@ -15,13 +15,13 @@ end --- Resolves the object -- This will call the entities resolver and then add to the game entities list -function _M:resolve(t) - engine.Entity.resolve(self, t) +function _M:resolve(t, last) + engine.Entity.resolve(self, t, last) - if not t then + if not t and last then -- Stackable property is the name by default if self.stacking and type(self.stacking) == "boolean" then - self.stacking = self.name + self.stacking = self:getName{no_count=true, force_id=true} end -- Auto add all objects to the game, if they can act diff --git a/game/engine/Zone.lua b/game/engine/Zone.lua index 236173103128f281f8de57f68f6c050ff6559b7c..e1d9f17091137adf18f6f7bd376058ecf9b3c13b 100644 --- a/game/engine/Zone.lua +++ b/game/engine/Zone.lua @@ -183,6 +183,7 @@ function _M:finishEntity(level, type, e, ego_chance) print("ego", ego.__CLASSNAME, ego.name, getmetatable(ego)) ego = ego:clone() ego:resolve() + ego:resolve(nil, true) local newname if ego.prefix then newname = ego.name .. e.name diff --git a/game/modules/tome/class/Object.lua b/game/modules/tome/class/Object.lua index d6a5bc06e61b39d1873998119bedaff4129a2cf5..211fcac3f96cdbf3a52fe54ff882d2f6b3706943 100644 --- a/game/modules/tome/class/Object.lua +++ b/game/modules/tome/class/Object.lua @@ -88,7 +88,7 @@ function _M:getName(t) local qty = self:getNumber() local name = self.name - if not self:isIdentified() and self:getUnidentifiedName() then name = self:getUnidentifiedName() end + if not self:isIdentified() and not t.force_id and self:getUnidentifiedName() then name = self:getUnidentifiedName() end -- To extend later name = name:gsub("~", ""):gsub("&", "a"):gsub("#([^#]+)#", function(attr) diff --git a/game/modules/tome/class/Store.lua b/game/modules/tome/class/Store.lua new file mode 100644 index 0000000000000000000000000000000000000000..7d2efaa001f74a44fb671dc8783e9e87ec4e34ac --- /dev/null +++ b/game/modules/tome/class/Store.lua @@ -0,0 +1,37 @@ +require "engine.class" +local Entity = require "engine.Entity" +local Inventory = require "engine.interface.ActorInventory" + +module(..., package.seeall, class.inherit(Entity)) + +_M.stores_def = {} + +function _M:init(t, no_default) + t = t or {} + + t.body = {INVEN=10000} + + Entity.init(self, t, no_default) + Inventory.init(self, t, no_default) +end + +--- Fill the store with goods +function _M:loadup(level, zone) + local s = self.store + if not s then error("Store without a store field") end + if self.last_filled and game.turn and self.last_filled >= game.turn - s.restock_after then + print("[STORE] not restocking yet", game.turn, s.restock_after, self.last_filled) + return + end + local inven = self:getInven("INVEN") + + for i = 1, rng.range(s.min_fill, s.max_fill) - #inven do + local filter = rng.table(s.filters) + local e = zone:makeEntity(level, "object", filter) + if e then + self:addObject(inven, e) + print("[STORE] stocking up: ", e.name) + end + end + self.last_filled = game.turn +end diff --git a/game/modules/tome/data/birth/descriptors.lua b/game/modules/tome/data/birth/descriptors.lua index 70682e5ef1b0b6056952343ff57a5b252f879ace..e67ae3374f550272b96b54daeaf5d16c6cc18372 100644 --- a/game/modules/tome/data/birth/descriptors.lua +++ b/game/modules/tome/data/birth/descriptors.lua @@ -13,9 +13,9 @@ newBirthDescriptor{ {type="lite", subtype="lite", name="brass lantern"}, }, resolvers.inventory{ id=true, - {type="potion", subtype="potion", name="potion of lesser healing"}, - {type="potion", subtype="potion", name="potion of lesser healing"}, - {type="potion", subtype="potion", name="potion of lesser healing"}, + {type="potion", subtype="potion", name="potion of lesser healing", ego_chance=-1000}, + {type="potion", subtype="potion", name="potion of lesser healing", ego_chance=-1000}, + {type="potion", subtype="potion", name="potion of lesser healing", ego_chance=-1000}, }, resolvers.generic(function(e) e.hotkey[9] = {"inventory", "potion of lesser healing"} diff --git a/game/modules/tome/data/birth/mage.lua b/game/modules/tome/data/birth/mage.lua index ed14d425cb9f4f6a2a6acaed09e39017a498ad9b..b4365c78088f62641bdc2bc1e7b0f274609aa52c 100644 --- a/game/modules/tome/data/birth/mage.lua +++ b/game/modules/tome/data/birth/mage.lua @@ -59,8 +59,8 @@ newBirthDescriptor{ {type="armor", subtype="cloth", name="robe", autoreq=true} }, resolvers.inventory{ id=true, - {type="potion", subtype="potion", name="potion of lesser mana"}, - {type="potion", subtype="potion", name="potion of lesser mana"}, + {type="potion", subtype="potion", name="potion of lesser mana", ego_chance=-1000}, + {type="potion", subtype="potion", name="potion of lesser mana", ego_chance=-1000}, }, }, } diff --git a/game/modules/tome/data/general/npcs/jelly.lua b/game/modules/tome/data/general/npcs/jelly.lua index f33b58850387ebfb7e5a65cc6e3a323d8cd0d443..16e2e835c1398d0c244c2f6892a2b1699ce8c1fb 100644 --- a/game/modules/tome/data/general/npcs/jelly.lua +++ b/game/modules/tome/data/general/npcs/jelly.lua @@ -15,6 +15,8 @@ newEntity{ combat_armor = 1, combat_def = 1, never_move = 1, + drops = resolvers.drops{chance=60, nb=1, {{type="money"}} }, + resists = { [DamageType.LIGHT] = -50 }, } diff --git a/game/modules/tome/data/general/npcs/minotaur.lua b/game/modules/tome/data/general/npcs/minotaur.lua index 08a98e2714881053b3c548d4e51ebd1cccb8a258..b11d10e4e4c00fbd5407b8f51e1583bccedcf40a 100644 --- a/game/modules/tome/data/general/npcs/minotaur.lua +++ b/game/modules/tome/data/general/npcs/minotaur.lua @@ -8,7 +8,8 @@ newEntity{ display = "H", color=colors.WHITE, body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 }, - drops = resolvers.drops{chance=20, nb=1, {} }, + resolvers.drops{chance=20, nb=1, {} }, + resolvers.drops{chance=40, nb=1, {{type="money"}} }, max_stamina = 100, life_rating = 13, diff --git a/game/modules/tome/data/general/npcs/ooze.lua b/game/modules/tome/data/general/npcs/ooze.lua index 34711456ed18c93d50e59e5afda1339213ee12aa..1ca494d2ef29b34f14628d80e8bfd002fa09b8f8 100644 --- a/game/modules/tome/data/general/npcs/ooze.lua +++ b/game/modules/tome/data/general/npcs/ooze.lua @@ -14,7 +14,8 @@ newEntity{ energy = { mod=0.7 }, combat_armor = 1, combat_def = 1, - drops = resolvers.drops{chance=90, nb=1, {} }, + resolvers.drops{chance=90, nb=1, {} }, + resolvers.drops{chance=60, nb=1, {{type="money"}} }, resists = { [DamageType.LIGHT] = -50 }, } diff --git a/game/modules/tome/data/general/npcs/skeleton.lua b/game/modules/tome/data/general/npcs/skeleton.lua index 612435c9e2ff24ba0604a7ff24d7e87273059b88..d993af1a86ce4a8e114e992b1627a2ae20fdee18 100644 --- a/game/modules/tome/data/general/npcs/skeleton.lua +++ b/game/modules/tome/data/general/npcs/skeleton.lua @@ -9,7 +9,8 @@ newEntity{ body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 }, equipment = resolvers.equip{ {type="weapon", subtype="greatsword"} }, - drops = resolvers.drops{chance=20, nb=1, {} }, + resolvers.drops{chance=20, nb=1, {} }, + resolvers.drops{chance=60, nb=1, {{type="money"}} }, autolevel = "warrior", ai = "dumb_talented_simple", ai_state = { talent_in=4, }, diff --git a/game/modules/tome/data/general/npcs/thieve.lua b/game/modules/tome/data/general/npcs/thieve.lua index f75af2920243b1f85524369cf2533d0d959b5ed7..b2fc04da43d1e51aedfaa492ca1ef01d7bcc93e0 100644 --- a/game/modules/tome/data/general/npcs/thieve.lua +++ b/game/modules/tome/data/general/npcs/thieve.lua @@ -10,6 +10,7 @@ newEntity{ body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 }, drops = resolvers.drops{chance=20, nb=1, {} }, equipment = resolvers.equip{ {type="weapon", subtype="dagger"}, {type="weapon", subtype="dagger"}, {type="armor", subtype="light"} }, + resolvers.drops{chance=100, nb=2, {{type="money"}} }, max_stamina = 100, diff --git a/game/modules/tome/data/general/npcs/troll.lua b/game/modules/tome/data/general/npcs/troll.lua index 84555ba7d070198a153028b8d4e10e6c6a653ecc..faee75651cb582ecac908a12a06ff7ab5930bca9 100644 --- a/game/modules/tome/data/general/npcs/troll.lua +++ b/game/modules/tome/data/general/npcs/troll.lua @@ -8,7 +8,8 @@ newEntity{ combat = { dam=resolvers.rngavg(15,20), atk=2, apr=6, physspeed=2 }, body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 }, - drops = resolvers.drops{chance=20, nb=1, {} }, + resolvers.drops{chance=20, nb=1, {} }, + resolvers.drops{chance=60, nb=1, {{type="money"}} }, life_rating = 15, life_regen = 2, diff --git a/game/modules/tome/data/general/stores/basic.lua b/game/modules/tome/data/general/stores/basic.lua new file mode 100644 index 0000000000000000000000000000000000000000..ef321574bd4655685d4550ec252e42aae53f0e8f --- /dev/null +++ b/game/modules/tome/data/general/stores/basic.lua @@ -0,0 +1,17 @@ +newEntity{ + define_as = "GENERAL_STORE", + name = "general store", + display = '1', color=colors.LIGHT_UMBER, + store = { + restock_after = 200, + buy_percent = 10, + min_fill = 10, + max_fill = 20, + filters = { + {type="potion"}, + {type="scroll"}, + }, +-- fixed = { +-- }, + }, +} diff --git a/game/modules/tome/data/talents/techniques/bow.lua b/game/modules/tome/data/talents/techniques/bow.lua index a5d731b85506fbf9db2acd3be4863da65b9d874f..1a26a0268d9d49ec08276b9b0123059b94392a75 100644 --- a/game/modules/tome/data/talents/techniques/bow.lua +++ b/game/modules/tome/data/talents/techniques/bow.lua @@ -24,7 +24,7 @@ newTalent{ return true end, info = function(self, t) - return ([[You fire an arrow that cuts right throught anything, piercing multiple tagerts if possible with near infinite armor penetration, doing %d%% damage.]]):format(100 * (1.2 + self:getTalentLevel(t) / 7)) + return ([[You fire an arrow that cuts right throught anything, piercing multiple targets if possible with near infinite armor penetration, doing %d%% damage.]]):format(100 * (1.2 + self:getTalentLevel(t) / 7)) end, } diff --git a/game/modules/tome/data/talents/techniques/combat-training.lua b/game/modules/tome/data/talents/techniques/combat-training.lua index 361a1aa3ff6312374fb05a0017374984de1d9d38..7ecfa652b3a12f5c3bcc2ada654b6bdfb419e143 100644 --- a/game/modules/tome/data/talents/techniques/combat-training.lua +++ b/game/modules/tome/data/talents/techniques/combat-training.lua @@ -46,7 +46,7 @@ newTalent{ require = { level=function(level) return (level - 1) * 2 end }, mode = "passive", info = function(self, t) - return [[Increases chances to hit with melee weapons.]] + return [[Increases chances to hit with melee and ranged weapons.]] end, } diff --git a/game/modules/tome/resolvers.lua b/game/modules/tome/resolvers.lua index 0eb2d17786eaef4679d8a6e6fee665280d9c8383..04f0843556e6e645103e4558288a95578ca9a42e 100644 --- a/game/modules/tome/resolvers.lua +++ b/game/modules/tome/resolvers.lua @@ -17,9 +17,9 @@ function resolvers.calc.equip(t, e) print("Zone made us an equipment according to filter!", o:getName()) -- Auto alloc some stats to be able to wear it - if filter.autoreq and o.require and o.require.stat then + if filter.autoreq and rawget(o, "require") and rawget(o, "require").stat then print("Autorequire stats") - for s, v in pairs(o.require.stat) do + for s, v in pairs(rawget(o, "require").stat) do print(s,v) if e:getStat(s) < v then e.unused_stats = e.unused_stats - (v - e:getStat(s))