summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mods/theme/scpt/init.lua3
-rw-r--r--lib/mods/theme/scpt/joke.lua31
-rw-r--r--lib/scpt/init.lua3
-rw-r--r--lib/scpt/joke.lua31
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/externs.h3
-rw-r--r--src/joke.c34
-rw-r--r--src/modules.c5
8 files changed, 43 insertions, 69 deletions
diff --git a/lib/mods/theme/scpt/init.lua b/lib/mods/theme/scpt/init.lua
index 477a5d90..af299f2c 100644
--- a/lib/mods/theme/scpt/init.lua
+++ b/lib/mods/theme/scpt/init.lua
@@ -10,9 +10,6 @@ init_school_books()
-- Post-spell creation initialization
initialize_bookable_spells()
--- Add joke stuff
-tome_dofile("joke.lua")
-
-- Some tests, if the file is not present, this is fine
tome_dofile_anywhere(ANGBAND_DIR_SCPT, "dg_test.lua", FALSE)
diff --git a/lib/mods/theme/scpt/joke.lua b/lib/mods/theme/scpt/joke.lua
deleted file mode 100644
index 2d87b651..00000000
--- a/lib/mods/theme/scpt/joke.lua
+++ /dev/null
@@ -1,31 +0,0 @@
--- Place a monster in a good spot
-function gen_joke_place_monster(r_idx)
- local try = 1000
- local x
- local y
- while try > 0 do
- x = randint(cur_hgt - 4) + 2
- y = randint(cur_wid - 4) + 2
- if not (0 == place_monster_one(y, x, r_idx, 0, FALSE, MSTATUS_ENEMY)) then
- return
- end
- try = try - 1
- end
-end
-
--- Check if a special joke monster can be generated here
-function gen_joke_monsters()
- if joke_monsters == FALSE then
- return
- end
-
- -- Neil
- if (current_dungeon_idx == 20) and (dun_level == 72) then
- neil = test_monster_name("Neil, the Sorceror")
- m_allow_special[neil + 1] = TRUE
- gen_joke_place_monster(neil)
- m_allow_special[neil + 1] = FALSE
- end
-end
-
-add_hook_script(HOOK_LEVEL_END_GEN, "gen_joke_monsters", "gen_joke_monsters")
diff --git a/lib/scpt/init.lua b/lib/scpt/init.lua
index 8434f6dd..edc82fe1 100644
--- a/lib/scpt/init.lua
+++ b/lib/scpt/init.lua
@@ -10,8 +10,5 @@ init_school_books()
-- Post-spell creation initialization
initialize_bookable_spells()
--- Add joke stuff
-tome_dofile("joke.lua")
-
-- Some tests, if the file is not present, this is fine
tome_dofile_anywhere(ANGBAND_DIR_SCPT, "dg_test.lua", FALSE)
diff --git a/lib/scpt/joke.lua b/lib/scpt/joke.lua
deleted file mode 100644
index 2d87b651..00000000
--- a/lib/scpt/joke.lua
+++ /dev/null
@@ -1,31 +0,0 @@
--- Place a monster in a good spot
-function gen_joke_place_monster(r_idx)
- local try = 1000
- local x
- local y
- while try > 0 do
- x = randint(cur_hgt - 4) + 2
- y = randint(cur_wid - 4) + 2
- if not (0 == place_monster_one(y, x, r_idx, 0, FALSE, MSTATUS_ENEMY)) then
- return
- end
- try = try - 1
- end
-end
-
--- Check if a special joke monster can be generated here
-function gen_joke_monsters()
- if joke_monsters == FALSE then
- return
- end
-
- -- Neil
- if (current_dungeon_idx == 20) and (dun_level == 72) then
- neil = test_monster_name("Neil, the Sorceror")
- m_allow_special[neil + 1] = TRUE
- gen_joke_place_monster(neil)
- m_allow_special[neil + 1] = FALSE
- end
-end
-
-add_hook_script(HOOK_LEVEL_END_GEN, "gen_joke_monsters", "gen_joke_monsters")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d84f94ba..0e1b21da 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,7 +11,7 @@ SET(SRCS
monster1.c monster2.c monster3.c
xtra1.c xtra2.c skills.c powers.c gods.c
spells1.c spells2.c spells3.c spells4.c spells5.c spells6.c
- corrupt.c mimic.c
+ corrupt.c joke.c mimic.c
status.c files.c notes.c loadsave.c string_list.c
cmd1.c cmd2.c cmd3.c cmd4.c cmd5.c cmd6.c cmd7.c
help.c range.c
diff --git a/src/externs.h b/src/externs.h
index 38511e48..dc449cb1 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -990,6 +990,9 @@ extern s16b error_line;
extern u32b fake_name_size;
extern u32b fake_text_size;
+/* joke.c */
+extern bool_ gen_joke_monsters(void *data, void *in, void *out);
+
/* loadsave.c */
extern void register_savefile(int num);
extern bool_ file_exist(char *buf);
diff --git a/src/joke.c b/src/joke.c
new file mode 100644
index 00000000..0ff01557
--- /dev/null
+++ b/src/joke.c
@@ -0,0 +1,34 @@
+#include "angband.h"
+
+static void gen_joke_place_monster(r_idx)
+{
+ int try;
+
+ for (try = 0; try < 1000; try++)
+ {
+ int x = randint(cur_hgt - 4) + 2;
+ int y = randint(cur_wid - 4) + 2;
+
+ if (place_monster_one(y, x, r_idx, 0, FALSE, MSTATUS_ENEMY))
+ {
+ return;
+ }
+ }
+}
+
+bool_ gen_joke_monsters(void *data, void *in, void *out)
+{
+ if (joke_monsters)
+ {
+ if ((dungeon_type == 20) &&
+ (dun_level == 72))
+ {
+ int r_idx = test_monster_name("Neil, the Sorceror");
+ m_allow_special[r_idx + 1] = TRUE;
+ gen_joke_place_monster(r_idx);
+ m_allow_special[r_idx + 1] = FALSE;
+ }
+ }
+
+ return FALSE;
+}
diff --git a/src/modules.c b/src/modules.c
index 98839d34..01f1be00 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -1135,6 +1135,11 @@ void init_hooks_module()
"drunk_takes_wine",
NULL);
+ add_hook_new(HOOK_LEVEL_END_GEN,
+ gen_joke_monsters,
+ "gen_joke_monsters",
+ NULL);
+
/*
* Module-specific hooks
*/