]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.wizard.c
1 /* $NetBSD: hack.wizard.c,v 1.4 1997/10/19 16:59:28 christos Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.wizard.c,v 1.4 1997/10/19 16:59:28 christos Exp $");
12 /* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
17 #define WIZSHOT 6 /* one chance in WIZSHOT that wizard will try
19 #define BOLT_LIM 8 /* from this distance D and 1 will try to hit
22 char wizapp
[] = "@DNPTUVXcemntx";
24 /* If he has found the Amulet, make the wizard appear after some time */
31 if (!flags
.made_amulet
|| !flags
.no_of_wizards
)
33 /* find wizard, and wake him if necessary */
34 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
35 if (mtmp
->data
->mlet
== '1' && mtmp
->msleep
&& !rn2(40))
36 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
37 if (otmp
->olet
== AMULET_SYM
&& !otmp
->spe
) {
39 if (dist(mtmp
->mx
, mtmp
->my
) > 2)
41 "You get the creepy feeling that somebody noticed your taking the Amulet."
51 /* if we have stolen or found the amulet, we disappear */
52 if (mtmp
->minvent
&& mtmp
->minvent
->olet
== AMULET_SYM
&&
53 mtmp
->minvent
->spe
== 0) {
54 /* vanish -- very primitive */
58 /* if it is lying around someplace, we teleport to it */
59 if (!carrying(AMULET_OF_YENDOR
)) {
62 for (otmp
= fobj
; otmp
; otmp
= otmp
->nobj
)
63 if (otmp
->olet
== AMULET_SYM
&& !otmp
->spe
) {
64 if ((u
.ux
!= otmp
->ox
|| u
.uy
!= otmp
->oy
) &&
65 !m_at(otmp
->ox
, otmp
->oy
)) {
67 /* teleport to it and pick it up */
77 return (0); /* we don't know where it is */
80 if (rn2(2)) { /* hit - perhaps steal */
83 * if hit 1/20 chance of stealing amulet & vanish - amulet is
86 if (hitu(mtmp
, d(mtmp
->data
->damn
, mtmp
->data
->damd
))
87 && !rn2(20) && stealamulet(mtmp
));
89 inrange(mtmp
); /* try magic */
99 /* do nothing if cancelled (but make '1' say something) */
100 if (mtmp
->data
->mlet
!= '1' && mtmp
->mcan
)
103 /* spit fire only when both in a room or both in a corridor */
104 if (inroom(u
.ux
, u
.uy
) != inroom(mtmp
->mx
, mtmp
->my
))
106 tx
= u
.ux
- mtmp
->mx
;
107 ty
= u
.uy
- mtmp
->my
;
108 if ((!tx
&& abs(ty
) < BOLT_LIM
) || (!ty
&& abs(tx
) < BOLT_LIM
)
109 || (abs(tx
) == abs(ty
) && abs(tx
) < BOLT_LIM
)) {
110 switch (mtmp
->data
->mlet
) {
112 /* spit fire in the direction of @ (not nec. hitting) */
113 buzz(-1, mtmp
->mx
, mtmp
->my
, sgn(tx
), sgn(ty
));
119 * if you zapped wizard with wand of cancellation, he
120 * has to shake off the effects before he can throw
121 * spells successfully. 1/2 the time they fail
124 if (mtmp
->mcan
|| rn2(2)) {
126 pline("%s makes a gesture, then curses.",
129 pline("You hear mumbled cursing.");
137 if (canseemon(mtmp
)) {
138 if (!rn2(6) && !Invis
) {
139 pline("%s hypnotizes you.", Monnam(mtmp
));
143 pline("%s chants an incantation.",
146 pline("You hear a mumbled incantation.");
147 switch (rn2(Invis
? 5 : 6)) {
150 * create a nasty monster from a deep
154 * (for the moment, 'nasty' is not
157 (void) makemon((struct permonst
*) 0, u
.ux
, u
.uy
);
160 pline("\"Destroy the thief, my pets!\"");
161 aggravate(); /* aggravate all the
163 /* fall into next case */
165 if (flags
.no_of_wizards
== 1 && rnd(5) == 0)
167 * if only 1 wizard, clone
173 if (mtmp
->mspeed
== MSLOW
)
176 mtmp
->mspeed
= MFAST
;
182 /* Only if not Invisible */
183 pline("You hear a clap of thunder!");
185 * shoot a bolt of fire or cold, or a
188 buzz(-rnd(3), mtmp
->mx
, mtmp
->my
, sgn(tx
), sgn(ty
));
203 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
205 if (mtmp
->mfroz
&& !rn2(5))
216 if ((mtmp2
= makemon(PM_WIZARD
, mtmp
->mx
, mtmp
->my
)) != NULL
) {
217 flags
.no_of_wizards
= 2;
219 mtmp2
->mappearance
= wizapp
[rn2(sizeof(wizapp
) - 1)];