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 $ */
5 /* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
8 extern struct permonst pm_wizard;
9 extern struct monst *makemon();
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 /* If he has found the Amulet, make the wizard appear after some time */
21 if(!flags.made_amulet || !flags.no_of_wizards)
23 /* find wizard, and wake him if necessary */
24 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
25 if(mtmp->data->mlet == '1' && mtmp->msleep && !rn2(40))
26 for(otmp = invent; otmp; otmp = otmp->nobj)
27 if(otmp->olet == AMULET_SYM && !otmp->spe) {
29 if(dist(mtmp->mx,mtmp->my) > 2)
31 "You get the creepy feeling that somebody noticed your taking the Amulet."
40 /* if we have stolen or found the amulet, we disappear */
41 if(mtmp->minvent && mtmp->minvent->olet == AMULET_SYM &&
42 mtmp->minvent->spe == 0) {
43 /* vanish -- very primitive */
48 /* if it is lying around someplace, we teleport to it */
49 if(!carrying(AMULET_OF_YENDOR)) {
52 for(otmp = fobj; otmp; otmp = otmp->nobj)
53 if(otmp->olet == AMULET_SYM && !otmp->spe) {
54 if((u.ux != otmp->ox || u.uy != otmp->oy) &&
55 !m_at(otmp->ox, otmp->oy)) {
57 /* teleport to it and pick it up */
67 return(0); /* we don't know where it is */
70 if(rn2(2)) { /* hit - perhaps steal */
72 /* if hit 1/20 chance of stealing amulet & vanish
73 - amulet is on level 26 again. */
74 if(hitu(mtmp, d(mtmp->data->damn,mtmp->data->damd))
75 && !rn2(20) && stealamulet(mtmp))
79 inrange(mtmp); /* try magic */
88 /* do nothing if cancelled (but make '1' say something) */
89 if(mtmp->data->mlet != '1' && mtmp->mcan)
92 /* spit fire only when both in a room or both in a corridor */
93 if(inroom(u.ux,u.uy) != inroom(mtmp->mx,mtmp->my)) return;
96 if((!tx && abs(ty) < BOLT_LIM) || (!ty && abs(tx) < BOLT_LIM)
97 || (abs(tx) == abs(ty) && abs(tx) < BOLT_LIM)){
98 switch(mtmp->data->mlet) {
100 /* spit fire in the direction of @ (not nec. hitting) */
101 buzz(-1,mtmp->mx,mtmp->my,sgn(tx),sgn(ty));
104 if(rn2(WIZSHOT)) break;
105 /* if you zapped wizard with wand of cancellation,
106 he has to shake off the effects before he can throw
107 spells successfully. 1/2 the time they fail anyway */
108 if(mtmp->mcan || rn2(2)) {
110 pline("%s makes a gesture, then curses.",
113 pline("You hear mumbled cursing.");
122 if(!rn2(6) && !Invis) {
123 pline("%s hypnotizes you.", Monnam(mtmp));
127 pline("%s chants an incantation.",
130 pline("You hear a mumbled incantation.");
131 switch(rn2(Invis ? 5 : 6)) {
133 /* create a nasty monster from a deep level */
134 /* (for the moment, 'nasty' is not implemented) */
135 (void) makemon((struct permonst *)0, u.ux, u.uy);
138 pline("\"Destroy the thief, my pets!\"");
139 aggravate(); /* aggravate all the monsters */
140 /* fall into next case */
142 if (flags.no_of_wizards == 1 && rnd(5) == 0)
143 /* if only 1 wizard, clone himself */
147 if(mtmp->mspeed == MSLOW)
150 mtmp->mspeed = MFAST;
156 /* Only if not Invisible */
157 pline("You hear a clap of thunder!");
158 /* shoot a bolt of fire or cold, or a sleep ray */
159 buzz(-rnd(3),mtmp->mx,mtmp->my,sgn(tx),sgn(ty));
164 if(u.uhp < 1) done_in_by(mtmp);
172 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
174 if(mtmp->mfroz && !rn2(5))
184 if(mtmp2 = makemon(PM_WIZARD, mtmp->mx, mtmp->my)) {
185 flags.no_of_wizards = 2;
187 mtmp2->mappearance = wizapp[rn2(sizeof(wizapp)-1)];