]> granicus.if.org Git - nethack/commitdiff
Allow some makemon flags in lua monster creation
authorPasi Kallinen <paxed@alt.org>
Thu, 24 Jun 2021 11:38:01 +0000 (14:38 +0300)
committerPasi Kallinen <paxed@alt.org>
Thu, 24 Jun 2021 11:38:12 +0000 (14:38 +0300)
Also document the des.monster hash parameter values.

doc/lua.adoc
include/sp_lev.h
src/sp_lev.c

index 1acfd2a9a28e0819d6f3ff62de30ab08f43983cf..73b8b1ed1cac5167fbb88af75357d805652d0098 100644 (file)
@@ -458,6 +458,40 @@ Example:
 
 === monster
 
+Create a monster.
+
+The hash parameter accepts the following keys:
+
+[options="header"]
+|===
+| parameter      | type   | description
+| id             | string | specific monster type, eg. "wood nymph"
+| class          | string | monster class, eg "D"
+| x, y           | integers |
+| coord          | table of two integer |
+| peaceful       | 0 or 1 |
+| asleep         | 0 or 1 |
+| name           | string | name of the monster
+| female         | 0 or 1 |
+| invisible      | 0 or 1 |
+| cancelled      | 0 or 1 |
+| revived        | 0 or 1 |
+| avenge         | 0 or 1 |
+| fleeing        | 0 - 127 |
+| blinded        | 0 - 127 |
+| paralyzed      | 0 - 127 |
+| stunned        | 0 or 1 |
+| confused       | 0 or 1 |
+| waiting        | 0 or 1 | monster will wait until hero gets next to it
+| tail           | 0 or 1 | generate worm without a tail?
+| group          | 0 or 1 | generate a group of monsters?
+| adjacentok     | 0 or 1 | is adjacent location ok, if given one is not suitable?
+| ignorewater    | 0 or 1 | ignore water when choosing location for the monster
+| countbirth     | 0 or 1 | do we count this monster as generated
+| appear_as      | string | monster can appear as object, monster, or terrain. Add "obj:", "mon:", or "ter:" prefix to the value. |
+| inventory      | function | objects generated in the function are given to the monster
+|===
+
 Example:
 
  des.monster();
index ff4ee85f45e6e15b1a054190848e996135499001..ae43d767b5fce9df8e48141e4347b5639a1b58dc 100644 (file)
@@ -141,6 +141,7 @@ typedef struct {
         paralyzed, stunned, confused, waiting;
     long seentraps;
     short has_invent;
+    long mm_flags; /* makemon flags */
 } monster;
 
 typedef struct {
index ac07aa6bcd3655f4779c2f7cce33dc84cba9ff66..e80876d58315317783fae87168f864e36e3b8884 100755 (executable)
@@ -1865,7 +1865,7 @@ create_monster(monster* m, struct mkroom* croom)
     else if (PM_ARCHEOLOGIST <= m->id && m->id <= PM_WIZARD)
         mtmp = mk_mplayer(pm, x, y, FALSE);
     else
-        mtmp = makemon(pm, x, y, NO_MM_FLAGS);
+        mtmp = makemon(pm, x, y, m->mm_flags);
 
     if (mtmp) {
         x = mtmp->mx, y = mtmp->my; /* sanity precaution */
@@ -3047,6 +3047,7 @@ lspo_monster(lua_State *L)
     tmpmons.seentraps = 0;
     tmpmons.has_invent = 0;
     tmpmons.waiting = 0;
+    tmpmons.mm_flags = NO_MM_FLAGS;
 
     if (argc == 1 && lua_type(L, 1) == LUA_TSTRING) {
         const char *paramstr = luaL_checkstring(L, 1);
@@ -3114,6 +3115,17 @@ lspo_monster(lua_State *L)
         tmpmons.seentraps = 0; /* TODO: list of trap names to bitfield */
         tmpmons.has_invent = 0;
 
+        if (!get_table_int_opt(L, "tail", 1))
+            tmpmons.mm_flags |= MM_NOTAIL;
+        if (!get_table_int_opt(L, "group", 1))
+            tmpmons.mm_flags |= MM_NOGRP;
+        if (get_table_int_opt(L, "adjacentok", 0))
+            tmpmons.mm_flags |= MM_ADJACENTOK;
+        if (get_table_int_opt(L, "ignorewater", 0))
+            tmpmons.mm_flags |= MM_IGNOREWATER;
+        if (!get_table_int_opt(L, "countbirth", 1))
+            tmpmons.mm_flags |= MM_NOCOUNTBIRTH;
+
         mappear = get_table_str_opt(L, "appear_as", NULL);
         if (mappear) {
             if (!strncmp("obj:", mappear, 4)) {