1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.wizard.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.wizard.c,v 1.3 1999/11/16 02:57:14 billf Exp $ */
4 /* $DragonFly: src/games/hack/hack.wizard.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */
6 /* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
9 extern struct permonst pm_wizard
;
11 #define WIZSHOT 6 /* one chance in WIZSHOT that wizard will try magic */
12 #define BOLT_LIM 8 /* from this distance D and 1 will try to hit you */
14 char wizapp
[] = "@DNPTUVXcemntx";
16 static void aggravate(void);
17 static void clonewiz(struct monst
*);
19 /* If he has found the Amulet, make the wizard appear after some time */
26 if (!flags
.made_amulet
|| !flags
.no_of_wizards
)
28 /* find wizard, and wake him if necessary */
29 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
30 if (mtmp
->data
->mlet
== '1' && mtmp
->msleep
&& !rn2(40))
31 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
32 if (otmp
->olet
== AMULET_SYM
&& !otmp
->spe
) {
34 if (dist(mtmp
->mx
, mtmp
->my
) > 2)
35 pline("You get the creepy feeling that somebody noticed your taking the Amulet.");
41 wiz_hit(struct monst
*mtmp
)
43 /* if we have stolen or found the amulet, we disappear */
44 if (mtmp
->minvent
&& mtmp
->minvent
->olet
== AMULET_SYM
&&
45 mtmp
->minvent
->spe
== 0) {
46 /* vanish -- very primitive */
51 /* if it is lying around someplace, we teleport to it */
52 if (!carrying(AMULET_OF_YENDOR
)) {
55 for (otmp
= fobj
; otmp
; otmp
= otmp
->nobj
)
56 if (otmp
->olet
== AMULET_SYM
&& !otmp
->spe
) {
57 if ((u
.ux
!= otmp
->ox
|| u
.uy
!= otmp
->oy
) &&
58 !m_at(otmp
->ox
, otmp
->oy
)) {
59 /* teleport to it and pick it up */
69 return (0); /* we don't know where it is */
72 if (rn2(2)) { /* hit - perhaps steal */
74 * if hit 1/20 chance of stealing amulet & vanish
75 * - amulet is on level 26 again.
77 if (hitu(mtmp
, d(mtmp
->data
->damn
, mtmp
->data
->damd
))
78 && !rn2(20) && stealamulet(mtmp
))
81 inrange(mtmp
); /* try magic */
86 inrange(struct monst
*mtmp
)
90 /* do nothing if cancelled (but make '1' say something) */
91 if (mtmp
->data
->mlet
!= '1' && mtmp
->mcan
)
94 /* spit fire only when both in a room or both in a corridor */
95 if (inroom(u
.ux
, u
.uy
) != inroom(mtmp
->mx
, mtmp
->my
))
99 if ((!tx
&& abs(ty
) < BOLT_LIM
) || (!ty
&& abs(tx
) < BOLT_LIM
)
100 || (abs(tx
) == abs(ty
) && abs(tx
) < BOLT_LIM
)) {
101 switch (mtmp
->data
->mlet
) {
103 /* spit fire in the direction of @ (not nec. hitting) */
104 buzz(-1, mtmp
->mx
, mtmp
->my
, sgn(tx
), sgn(ty
));
110 * if you zapped wizard with wand of cancellation, he
111 * has to shake off the effects before he can throw
112 * spells successfully. 1/2 the time they fail anyway
114 if (mtmp
->mcan
|| rn2(2)) {
116 pline("%s makes a gesture, then curses.",
119 pline("You hear mumbled cursing.");
127 if (canseemon(mtmp
)) {
128 if (!rn2(6) && !Invis
) {
129 pline("%s hypnotizes you.", Monnam(mtmp
));
133 pline("%s chants an incantation.",
136 pline("You hear a mumbled incantation.");
137 switch (rn2(Invis
? 5 : 6)) {
139 /* create a nasty monster from a deep level */
140 /* (for the moment, 'nasty' is not implemented) */
141 makemon(NULL
, u
.ux
, u
.uy
);
144 pline("\"Destroy the thief, my pets!\"");
145 aggravate(); /* aggravate all the monsters */
146 /* fall into next case */
148 if (flags
.no_of_wizards
== 1 && rnd(5) == 0)
149 /* if only 1 wizard, clone himself */
153 if (mtmp
->mspeed
== MSLOW
)
156 mtmp
->mspeed
= MFAST
;
162 /* Only if not Invisible */
163 pline("You hear a clap of thunder!");
164 /* shoot a bolt of fire or cold, or a sleep ray */
165 buzz(-rnd(3), mtmp
->mx
, mtmp
->my
, sgn(tx
), sgn(ty
));
180 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
182 if (mtmp
->mfroz
&& !rn2(5))
188 clonewiz(struct monst
*mtmp
)
192 if ((mtmp2
= makemon(PM_WIZARD
, mtmp
->mx
, mtmp
->my
)) != NULL
) {
193 flags
.no_of_wizards
= 2;
195 mtmp2
->mappearance
= wizapp
[rn2(sizeof(wizapp
) - 1)];