Skip to content
Snippets Groups Projects
Commit b82892b8 authored by dg's avatar dg
Browse files

added money drops

start stores


git-svn-id: http://svn.net-core.org/repos/t-engine4@373 51575b47-30f0-44d4-a5cc-537603b46e54
parent 1d09ff9d
No related branches found
No related tags found
No related merge requests found
Showing
with 80 additions and 18 deletions
......@@ -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
......
......@@ -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
......
......@@ -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)
......
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
......@@ -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"}
......
......@@ -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},
},
},
}
......
......@@ -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 },
}
......
......@@ -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,
......
......@@ -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 },
}
......
......@@ -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, },
......
......@@ -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,
......
......@@ -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,
......
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 = {
-- },
},
}
......@@ -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,
}
......
......@@ -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,
}
......
......@@ -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))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment