diff --git a/dat/themerms.lua b/dat/themerms.lua index 06fa0a1ca..78d90eb42 100644 --- a/dat/themerms.lua +++ b/dat/themerms.lua @@ -634,14 +634,26 @@ xx|.....|xx -- Guarantee an escape item inside one of the chests, to prevent the hero -- falling in from above and becoming permanently stuck -- [cf. generate_way_out_method(sp_lev.c)]. + -- If the escape item is made of glass or crystal, make sure that the + -- chest isn't locked so that kicking it to gain access to its contents + -- won't be necessary; otherwise retain lock state from random creation. -- "pick-axe", "dwarvish mattock" could be included in the list of escape -- items but don't normally generate in containers. local escape_items = { "scroll of teleportation", "ring of teleportation", "wand of teleportation", "wand of digging" }; - local box = des.object({ id = "chest", coord = chest_spots[1] }) - box:addcontent(obj.new(escape_items[math.random(#escape_items)])); + local itm = obj.new(escape_items[math.random(#escape_items)]); + local itmcls = itm:class() + local lckd; + if itmcls[ "material" ] == 19 then -- GLASS==19 + lckd = false; -- for glass item, force box to be unlocked + else + lckd = itm.locked; -- else keep random lock state from box's creation + end; + local box = des.object({ id = "chest", coord = chest_spots[1], + locked = lckd }); + box:addcontent(itm); for i = 2, #chest_spots do des.object({ id = "chest", coord = chest_spots[i] }); diff --git a/src/nhlobj.c b/src/nhlobj.c index 9463efcfc..8e65aa239 100644 --- a/src/nhlobj.c +++ b/src/nhlobj.c @@ -188,6 +188,7 @@ l_obj_objects_to_table(lua_State *L) if (otyp == -1) { nhl_error(L, "l_obj_objects_to_table: Wrong args"); + /*NOTREACHED*/ return 0; } @@ -489,7 +490,6 @@ l_obj_timer_has(lua_State *L) return 0; } - /* peek at an object timer. return the turn when timer triggers. returns 0 if no such timer attached to the object. */ /* local timeout = o:peek_timer("hatch-egg"); */