Avoid naming Vlad's entourage if vampires are genocided

This commit is contained in:
Pasi Kallinen
2024-12-05 16:12:59 +02:00
parent b73581b745
commit 4b15085bb1
3 changed files with 40 additions and 3 deletions

View File

@@ -37,9 +37,14 @@ des.monster("V",niches[3])
-- gave them titles rather than (or perhaps in addition to) specific names
-- and we use those titles here. Marking them as 'waiting' forces them to
-- start in vampire form instead of vampshifted into bat/fog/wolf form.
des.monster({ id="Vampire Lady", niches[4], name="Madame", waiting=1 })
des.monster({ id="Vampire Lady", niches[5], name="Marquise", waiting=1 })
des.monster({ id="Vampire Lady", niches[6], name="Countess", waiting=1 })
local Vgenod = nh.is_genocided("vampire");
local Vnames = { nil, nil, nil };
if (not Vgenod) then
Vnames = { "Madame", "Marquise", "Countess" };
end
des.monster({ id="Vampire Lady", niches[4], name=Vnames[1], waiting=1 })
des.monster({ id="Vampire Lady", niches[5], name=Vnames[2], waiting=1 })
des.monster({ id="Vampire Lady", niches[6], name=Vnames[3], waiting=1 })
-- The doors
des.door("closed",08,03)
des.door("closed",10,03)

View File

@@ -249,6 +249,15 @@ Example:
local str = nh.ing_suffix("foo");
=== is_genocided
Is specific monster type genocided? Returns a boolean value.
Example:
local x = nh.is_genocided("vampire");
=== level_difficulty
Returns an integer value describing the level difficulty.

View File

@@ -64,6 +64,7 @@ staticfn int nhl_an(lua_State *);
staticfn int nhl_rn2(lua_State *);
staticfn int nhl_random(lua_State *);
staticfn int nhl_level_difficulty(lua_State *);
staticfn int nhl_is_genocided(lua_State *);
staticfn void init_nhc_data(lua_State *);
staticfn int nhl_push_anything(lua_State *, int, void *);
staticfn int nhl_meta_u_index(lua_State *);
@@ -954,6 +955,27 @@ nhl_level_difficulty(lua_State *L)
return 1;
}
/* local x = nh.is_genocided("vampire") */
staticfn int
nhl_is_genocided(lua_State *L)
{
int argc = lua_gettop(L);
if (argc == 1) {
const char *paramstr = luaL_checkstring(L, 1);
int mgend;
int i = name_to_mon(paramstr, &mgend);
lua_pushboolean(L, (i != NON_PM)
&& (svm.mvitals[i].mvflags & G_GENOD)
? TRUE : FALSE);
} else {
nhl_error(L, "Wrong args");
}
return 1;
}
RESTORE_WARNING_UNREACHABLE_CODE
/* get mandatory integer value from table */
@@ -1722,6 +1744,7 @@ static const struct luaL_Reg nhl_functions[] = {
{ "rn2", nhl_rn2 },
{ "random", nhl_random },
{ "level_difficulty", nhl_level_difficulty },
{ "is_genocided", nhl_is_genocided },
{ "parse_config", nhl_parse_config },
{ "get_config", nhl_get_config },
{ "get_config_errors", l_get_config_errors },