Themerooms: Engraving hints the location of buried treasure
Add two new themeroom functions that are called when generating the level: pre_themerooms_generate and post_themerooms_generate, calles before and after themerooms_generate. Allow the buried treasure -themeroom to put down an engraving anywhere on the level, hinting at the location of the treasure. des.object contents function now gets the generated object passed to it as a parameter.
This commit is contained in:
16
src/mklev.c
16
src/mklev.c
@@ -289,6 +289,13 @@ makerooms(void)
|
||||
|
||||
if (themes) {
|
||||
create_des_coder();
|
||||
iflags.in_lua = g.in_mk_themerooms = TRUE;
|
||||
g.themeroom_failed = FALSE;
|
||||
lua_getglobal(themes, "pre_themerooms_generate");
|
||||
if ( nhl_pcall(themes, 0, 0)){
|
||||
impossible("Lua error: %s", lua_tostring(themes, -1));
|
||||
}
|
||||
iflags.in_lua = g.in_mk_themerooms = FALSE;
|
||||
}
|
||||
|
||||
/* make rooms until satisfied */
|
||||
@@ -321,6 +328,15 @@ makerooms(void)
|
||||
}
|
||||
}
|
||||
if (themes) {
|
||||
reset_xystart_size();
|
||||
iflags.in_lua = g.in_mk_themerooms = TRUE;
|
||||
g.themeroom_failed = FALSE;
|
||||
lua_getglobal(themes, "post_themerooms_generate");
|
||||
if ( nhl_pcall(themes, 0, 0)){
|
||||
impossible("Lua error: %s", lua_tostring(themes, -1));
|
||||
}
|
||||
iflags.in_lua = g.in_mk_themerooms = FALSE;
|
||||
|
||||
wallification(1, 0, COLNO - 1, ROWNO - 1);
|
||||
free(g.coder);
|
||||
g.coder = NULL;
|
||||
|
||||
19
src/sp_lev.c
19
src/sp_lev.c
@@ -55,7 +55,7 @@ static boolean m_bad_boulder_spot(coordxy, coordxy);
|
||||
static int pm_to_humidity(struct permonst *);
|
||||
static unsigned int sp_amask_to_amask(unsigned int sp_amask);
|
||||
static void create_monster(monster *, struct mkroom *);
|
||||
static void create_object(object *, struct mkroom *);
|
||||
static struct obj *create_object(object *, struct mkroom *);
|
||||
static void create_altar(altar *, struct mkroom *);
|
||||
static boolean search_door(struct mkroom *, coordxy *, coordxy *, xint16, int);
|
||||
static void create_corridor(corridor *);
|
||||
@@ -2125,7 +2125,7 @@ create_monster(monster* m, struct mkroom* croom)
|
||||
/*
|
||||
* Create an object in a room.
|
||||
*/
|
||||
static void
|
||||
static struct obj *
|
||||
create_object(object* o, struct mkroom* croom)
|
||||
{
|
||||
struct obj *otmp;
|
||||
@@ -2267,7 +2267,7 @@ create_object(object* o, struct mkroom* croom)
|
||||
artifact_exists(otmp, safe_oname(otmp), FALSE,
|
||||
ONAME_NO_FLAGS); /* flags don't matter */
|
||||
obfree(otmp, NULL);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2359,11 +2359,14 @@ create_object(object* o, struct mkroom* croom)
|
||||
boolean dealloced;
|
||||
|
||||
(void) bury_an_obj(otmp, &dealloced);
|
||||
if (dealloced && container_idx) {
|
||||
container_obj[container_idx - 1] = NULL;
|
||||
if (dealloced) {
|
||||
if (container_idx)
|
||||
container_obj[container_idx - 1] = NULL;
|
||||
otmp = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return otmp;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3461,6 +3464,7 @@ lspo_object(lua_State *L)
|
||||
lua_Integer ox = -1, oy = -1;
|
||||
int argc = lua_gettop(L);
|
||||
int maybe_contents = 0;
|
||||
struct obj *otmp = NULL;
|
||||
|
||||
create_des_coder();
|
||||
|
||||
@@ -3601,14 +3605,15 @@ lspo_object(lua_State *L)
|
||||
}
|
||||
|
||||
do {
|
||||
create_object(&tmpobj, g.coder->croom);
|
||||
otmp = create_object(&tmpobj, g.coder->croom);
|
||||
quancnt--;
|
||||
} while ((quancnt > 0) && ((tmpobj.id > STRANGE_OBJECT)
|
||||
&& !objects[tmpobj.id].oc_merge));
|
||||
|
||||
if (lua_type(L, -1) == LUA_TFUNCTION) {
|
||||
lua_remove(L, -2);
|
||||
if (nhl_pcall(L, 0, 0)){
|
||||
nhl_push_obj(L, otmp);
|
||||
if (nhl_pcall(L, 1, 0)){
|
||||
impossible("Lua error: %s", lua_tostring(L, -1));
|
||||
}
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user