diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-04-02 22:10:00 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-04-07 15:28:25 +0200 |
commit | 9ed872694d590996117dd936318e917f55ff6da0 (patch) | |
tree | 18222f88340d69a767f6aaa34d345931ab5f463f /src | |
parent | 3215bb6521aca21af4d48f0598e1322ef8d8773c (diff) |
Lua: Move "Library" quest monster placement code to C
Diffstat (limited to 'src')
-rw-r--r-- | src/plots.c | 3 | ||||
-rw-r--r-- | src/plots.h | 3 | ||||
-rw-r--r-- | src/q_library.c | 53 | ||||
-rw-r--r-- | src/util.pkg | 2 |
4 files changed, 61 insertions, 0 deletions
diff --git a/src/plots.c b/src/plots.c index 2fb1cbb1..b26d1e20 100644 --- a/src/plots.c +++ b/src/plots.c @@ -474,3 +474,6 @@ bool_ quest_null_hook(int q) /*************************** Bounty Quest *************************/ #include "q_bounty.c" + +/************************** Library Quest *************************/ +#include "q_library.c" diff --git a/src/plots.h b/src/plots.h index 903ffcef..2d78ee02 100644 --- a/src/plots.h +++ b/src/plots.h @@ -52,3 +52,6 @@ extern bool_ quest_bounty_init_hook(int q_idx); extern bool_ quest_bounty_drop_item(); extern bool_ quest_bounty_get_item(); extern bool_ quest_bounty_describe(FILE *fff); + +/******* Plot Library Quest *******/ +extern void quest_library_gen_hook(); diff --git a/src/q_library.c b/src/q_library.c new file mode 100644 index 00000000..edb1698f --- /dev/null +++ b/src/q_library.c @@ -0,0 +1,53 @@ +#undef cquest + +#define MONSTER_LICH 518 +#define MONSTER_MONASTIC_LICH 611 +#define MONSTER_FLESH_GOLEM 256 +#define MONSTER_CLAY_GOLEM 261 +#define MONSTER_IRON_GOLEM 367 +#define MONSTER_MITHRIL_GOLEM 464 + +static s16b library_quest_place_random(int minY, int minX, int maxY, int maxX, int r_idx) +{ + int y = randint(maxY - minY + 1) + minY; + int x = randint(maxX - minX + 1) + minX; + return place_monster_one(y, x, r_idx, 0, TRUE, MSTATUS_ENEMY); +} + +static void library_quest_place_nrandom(int minY, int minX, int maxY, int maxX, int r_idx, int n) +{ + while(n > 0) + { + if (0 < library_quest_place_random(minY, minX, maxY, maxX, r_idx)) + { + n--; + } + } +} + +void quest_library_gen_hook() +{ + library_quest_place_nrandom( + 4, 4, 14, 37, MONSTER_LICH, damroll(4,2)); + + library_quest_place_nrandom( + 14, 34, 37, 67, MONSTER_MONASTIC_LICH, damroll(1, 2)); + + library_quest_place_nrandom( + 4, 34, 14, 67, MONSTER_MONASTIC_LICH, damroll(1, 2) - 1); + + library_quest_place_nrandom( + 14, 4, 37, 34, MONSTER_MONASTIC_LICH, damroll(1, 2) - 1); + + library_quest_place_nrandom( + 10, 10, 37, 67, MONSTER_FLESH_GOLEM, 2); + + library_quest_place_nrandom( + 10, 10, 37, 67, MONSTER_CLAY_GOLEM, 2); + + library_quest_place_nrandom( + 10, 10, 37, 67, MONSTER_IRON_GOLEM, 2); + + library_quest_place_nrandom( + 10, 10, 37, 67, MONSTER_MITHRIL_GOLEM, 1); +} diff --git a/src/util.pkg b/src/util.pkg index 39f70b40..d13f74e6 100644 --- a/src/util.pkg +++ b/src/util.pkg @@ -2681,3 +2681,5 @@ extern void lite_spot(int y, int x); extern bool drop_text_left(byte c, cptr s, int y, int o); extern bool drop_text_right(byte c, cptr s, int y, int o); + +extern void quest_library_gen_hook(); |