diff --git a/game/engines/default/engine/Store.lua b/game/engines/default/engine/Store.lua index 92efcd34f23b7181b395cb175ce62ffec34f4bf5..9e37e55dfab8fb3b7b4fb5b7f76481af22b31c04 100644 --- a/game/engines/default/engine/Store.lua +++ b/game/engines/default/engine/Store.lua @@ -51,7 +51,7 @@ end --- Fill the store with goods -- @param level the level to generate for (instance of type engine.Level) -- @param zone the zone to generate for -function _M:loadup(level, zone) +function _M:loadup(level, zone, force_nb) local s = self.store if not s then error("Store without a store field") end if not self:canRestock() then return end @@ -68,7 +68,7 @@ function _M:loadup(level, zone) end local i = 1 - local rngfill = rng.range(s.min_fill, s.max_fill) - #inven + local rngfill = force_nb or (rng.range(s.min_fill, s.max_fill) - #inven) while i <= rngfill do local filter = util.getval(s.filters) local e diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index d17fee7dadff2340457615ff4a769a34ded178ab..d3ed163aeed9ab87f9510f609399e5815b1ed680 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -906,7 +906,8 @@ function _M:setupCommands() [{"_g","ctrl"}] = function() if config.settings.cheat then -- self.nicer_tiles:postProcessLevelTiles(self.level) -- game:registerDialog(require("mod.dialogs.Donation").new()) - self.state:debugRandomZone() +-- self.state:debugRandomZone() + self.state:storesRestock() end end, } diff --git a/game/modules/tome/class/Store.lua b/game/modules/tome/class/Store.lua index 133d6853033344cdddeabc1663f9763ab1b787ae..1378a7c2201486c89db4c638209c833de87d9459 100644 --- a/game/modules/tome/class/Store.lua +++ b/game/modules/tome/class/Store.lua @@ -32,6 +32,7 @@ end function _M:init(t, no_default) t.store.buy_percent = t.store.buy_percent or function(self, o) if o.type == "gem" then return 40 else return 5 end end t.store.sell_percent = t.store.sell_percent or function(self, o) return 120 + 3 * (o.__store_level or 0) end -- Stores prices goes up with item level + t.store.nb_fill = t.store.nb_fill or 10 t.store.purse = t.store.purse or 20 Store.init(self, t, no_default) @@ -63,7 +64,7 @@ end -- @param level the level to generate for (instance of type engine.Level) -- @param zone the zone to generate for function _M:loadup(level, zone) - if Store.loadup(self, level, zone) then + if Store.loadup(self, level, zone, self.store.nb_fill) then self.last_filled = game.state.stores_restock end end diff --git a/game/modules/tome/data/general/stores/basic.lua b/game/modules/tome/data/general/stores/basic.lua index 2afa11483599d444aae9b748bc6b2055474d8943..4cdadb2e12a54d74d32bd41bce987fb36b150667 100644 --- a/game/modules/tome/data/general/stores/basic.lua +++ b/game/modules/tome/data/general/stores/basic.lua @@ -19,7 +19,7 @@ newEntity{ define_as = "ARMOR", - name = "armour smith", + name = "heavy armour smith", display = '2', color=colors.UMBER, store = { purse = 25, @@ -27,7 +27,38 @@ newEntity{ min_fill = 10, max_fill = 20, filters = function() - return {type="armor", id=true, tome_drops="store"} + return {type="armor", subtype="heavy", id=true, tome_drops="store"} + return {type="armor", subtype="massive", id=true, tome_drops="store"} + end, + }, +} + +newEntity{ + define_as = "ARMOR", + name = "tanner", + display = '2', color=colors.LIGHT_UMBER, + store = { + purse = 25, + empty_before_restock = false, + min_fill = 10, + max_fill = 20, + filters = function() + return {type="armor", subtype="light", id=true, tome_drops="store"} + end, + }, +} + +newEntity{ + define_as = "ARMOR", + name = "tailor", + display = '2', color=colors.WHITE, + store = { + purse = 25, + empty_before_restock = false, + min_fill = 10, + max_fill = 20, + filters = function() + return {type="armor", subtype="cloth", id=true, tome_drops="store"} end, }, } @@ -42,7 +73,7 @@ newEntity{ min_fill = 10, max_fill = 20, filters = function() - return {type="weapon", id=true, tome_drops="store"} + return {type="weapon", subtype="sword", id=true, tome_drops="store"} end, }, } diff --git a/src/dmnd_square.c b/src/dmnd_square.c index af78a48ed8e399e7c9c9e35b382339f1c6da9196..d8c21043aef4559269adef257a3798cd6cb85320 100644 --- a/src/dmnd_square.c +++ b/src/dmnd_square.c @@ -486,7 +486,6 @@ void freeFractArray (float *fa) } - static int dmnd_2d(lua_State *L) { int size = luaL_checknumber(L, 1); @@ -503,7 +502,7 @@ static int dmnd_2d(lua_State *L) lua_createtable(L, size, 0); for (i = 0; i < size; i++) { - lua_pushnumber(L, fa[j * size + j]); + lua_pushnumber(L, fa[j * size + i]); lua_rawseti(L, -2, i + 1); } lua_rawseti(L, -2, j + 1); @@ -513,8 +512,30 @@ static int dmnd_2d(lua_State *L) return 1; } +static int dmnd_1d(lua_State *L) +{ + int size = luaL_checknumber(L, 1); + float heightScale = luaL_checknumber(L, 2); + float h = luaL_checknumber(L, 3); + + float *fa = alloc1DFractArray(size); + fill1DFractArray(fa, size, heightScale, h); + + int i; + lua_createtable(L, size, 0); + for (i = 0; i < size; i++) + { + lua_pushnumber(L, fa[i]); + lua_rawseti(L, -2, i + 1); + } + + freeFractArray(fa); + return 1; +} + static const struct luaL_reg dmndlib[] = { + {"get1D", dmnd_1d}, {"get2D", dmnd_2d}, {NULL, NULL}, };