annotate rogue5/monsters.c @ 88:07c4d4883ef2

rogue3: begin porting to autoconf. Rogue V3 can now be built with './configure && make'. This is preliminary: 'make install' does not work yet.
author John "Elwin" Edwards
date Sat, 24 Aug 2013 13:36:13 -0700
parents f502bf60e6e4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
1 /*
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
2 * File with various monster functions in it
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
3 *
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
4 * @(#)monsters.c 4.46 (Berkeley) 02/05/99
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
5 *
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
6 * Rogue: Exploring the Dungeons of Doom
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
7 * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
8 * All rights reserved.
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
9 *
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
10 * See the file LICENSE.TXT for full copyright and licensing information.
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
11 */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
12
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
13 #include <curses.h>
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
14 #include <string.h>
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
15 #include "rogue.h"
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
16 #include <ctype.h>
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
17
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
18 /*
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
19 * List of monsters in rough order of vorpalness
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
20 */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
21 static const int lvl_mons[] = {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
22 'K', 'E', 'B', 'S', 'H', 'I', 'R', 'O', 'Z', 'L', 'C', 'Q', 'A',
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
23 'N', 'Y', 'F', 'T', 'W', 'P', 'X', 'U', 'M', 'V', 'G', 'J', 'D'
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
24 };
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
25
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
26 static const int wand_mons[] = {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
27 'K', 'E', 'B', 'S', 'H', 0, 'R', 'O', 'Z', 0, 'C', 'Q', 'A',
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
28 0, 'Y', 0, 'T', 'W', 'P', 0, 'U', 'M', 'V', 'G', 'J', 0
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
29 };
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
30
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
31 /*
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
32 * randmonster:
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
33 * Pick a monster to show up. The lower the level,
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
34 * the meaner the monster.
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
35 */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
36 int
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
37 randmonster(int wander)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
38 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
39 int d;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
40 const int *mons;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
41
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
42 mons = (wander ? wand_mons : lvl_mons);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
43 do
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
44 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
45 d = level + (rnd(10) - 6);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
46 if (d < 0)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
47 d = rnd(5);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
48 if (d > 25)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
49 d = rnd(5) + 21;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
50 } while (mons[d] == 0);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
51 return mons[d];
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
52 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
53
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
54 /*
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
55 * new_monster:
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
56 * Pick a new monster and add it to the list
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
57 */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
58
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
59 void
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
60 new_monster(THING *tp, int type, const coord *cp)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
61 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
62 struct monster *mp;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
63 int lev_add;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
64
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
65 if ((lev_add = level - AMULETLEVEL) < 0)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
66 lev_add = 0;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
67 attach(mlist, tp);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
68 tp->t_type = type;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
69 tp->t_disguise = type;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
70 tp->t_pos = *cp;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
71 move(cp->y, cp->x);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
72 tp->t_oldch = CCHAR( inch() );
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
73 tp->t_room = roomin(cp);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
74 moat(cp->y, cp->x) = tp;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
75 mp = &monsters[tp->t_type-'A'];
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
76 tp->t_stats.s_lvl = mp->m_stats.s_lvl + lev_add;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
77 tp->t_stats.s_maxhp = tp->t_stats.s_hpt = roll(tp->t_stats.s_lvl, 8);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
78 tp->t_stats.s_arm = mp->m_stats.s_arm - lev_add;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
79 strcpy(tp->t_stats.s_dmg,mp->m_stats.s_dmg);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
80 tp->t_stats.s_str = mp->m_stats.s_str;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
81 tp->t_stats.s_exp = mp->m_stats.s_exp + lev_add * 10 + exp_add(tp);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
82 tp->t_flags = mp->m_flags;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
83 if (level > 29)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
84 tp->t_flags |= ISHASTE;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
85 tp->t_turn = TRUE;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
86 tp->t_pack = NULL;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
87 if (ISWEARING(R_AGGR))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
88 runto(cp);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
89 if (type == 'X')
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
90 tp->t_disguise = rnd_thing();
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
91 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
92
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
93 /*
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
94 * expadd:
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
95 * Experience to add for this monster's level/hit points
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
96 */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
97 int
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
98 exp_add(const THING *tp)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
99 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
100 int mod;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
101
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
102 if (tp->t_stats.s_lvl == 1)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
103 mod = tp->t_stats.s_maxhp / 8;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
104 else
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
105 mod = tp->t_stats.s_maxhp / 6;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
106 if (tp->t_stats.s_lvl > 9)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff