/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* hack.wizard.c - version 1.0.3 */
/* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
extern struct permonst pm_wizard
;
extern struct monst
*makemon();
#define WIZSHOT 6 /* one chance in WIZSHOT that wizard will try magic */
#define BOLT_LIM 8 /* from this distance D and 1 will try to hit you */
char wizapp
[] = "@DNPTUVXcemntx";
/* If he has found the Amulet, make the wizard appear after some time */
register struct obj
*otmp
;
register struct monst
*mtmp
;
if(!flags
.made_amulet
|| !flags
.no_of_wizards
)
/* find wizard, and wake him if necessary */
for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
if(mtmp
->data
->mlet
== '1' && mtmp
->msleep
&& !rn2(40))
for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
if(otmp
->olet
== AMULET_SYM
&& !otmp
->spe
) {
if(dist(mtmp
->mx
,mtmp
->my
) > 2)
"You get the creepy feeling that somebody noticed your taking the Amulet."
register struct monst
*mtmp
;
/* if we have stolen or found the amulet, we disappear */
if(mtmp
->minvent
&& mtmp
->minvent
->olet
== AMULET_SYM
&&
mtmp
->minvent
->spe
== 0) {
/* vanish -- very primitive */
/* if it is lying around someplace, we teleport to it */
if(!carrying(AMULET_OF_YENDOR
)) {
register struct obj
*otmp
;
for(otmp
= fobj
; otmp
; otmp
= otmp
->nobj
)
if(otmp
->olet
== AMULET_SYM
&& !otmp
->spe
) {
if((u
.ux
!= otmp
->ox
|| u
.uy
!= otmp
->oy
) &&
!m_at(otmp
->ox
, otmp
->oy
)) {
/* teleport to it and pick it up */
return(0); /* we don't know where it is */
if(rn2(2)) { /* hit - perhaps steal */
/* if hit 1/20 chance of stealing amulet & vanish
- amulet is on level 26 again. */
if(hitu(mtmp
, d(mtmp
->data
->damn
,mtmp
->data
->damd
))
&& !rn2(20) && stealamulet(mtmp
))
inrange(mtmp
); /* try magic */
register struct monst
*mtmp
;
/* do nothing if cancelled (but make '1' say something) */
if(mtmp
->data
->mlet
!= '1' && mtmp
->mcan
)
/* spit fire only when both in a room or both in a corridor */
if(inroom(u
.ux
,u
.uy
) != inroom(mtmp
->mx
,mtmp
->my
)) return;
if((!tx
&& abs(ty
) < BOLT_LIM
) || (!ty
&& abs(tx
) < BOLT_LIM
)
|| (abs(tx
) == abs(ty
) && abs(tx
) < BOLT_LIM
)){
switch(mtmp
->data
->mlet
) {
/* spit fire in the direction of @ (not nec. hitting) */
buzz(-1,mtmp
->mx
,mtmp
->my
,sgn(tx
),sgn(ty
));
/* if you zapped wizard with wand of cancellation,
he has to shake off the effects before he can throw
spells successfully. 1/2 the time they fail anyway */
if(mtmp
->mcan
|| rn2(2)) {
pline("%s makes a gesture, then curses.",
pline("You hear mumbled cursing.");
pline("%s hypnotizes you.", Monnam(mtmp
));
pline("%s chants an incantation.",
pline("You hear a mumbled incantation.");
switch(rn2(Invis
? 5 : 6)) {
/* create a nasty monster from a deep level */
/* (for the moment, 'nasty' is not implemented) */
(void) makemon((struct permonst
*)0, u
.ux
, u
.uy
);
pline("\"Destroy the thief, my pets!\"");
aggravate(); /* aggravate all the monsters */
/* fall into next case */
if (flags
.no_of_wizards
== 1 && rnd(5) == 0)
/* if only 1 wizard, clone himself */
if(mtmp
->mspeed
== MSLOW
)
/* Only if not Invisible */
pline("You hear a clap of thunder!");
/* shoot a bolt of fire or cold, or a sleep ray */
buzz(-rnd(3),mtmp
->mx
,mtmp
->my
,sgn(tx
),sgn(ty
));
if(u
.uhp
< 1) done_in_by(mtmp
);
register struct monst
*mtmp
;
for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
if(mtmp
->mfroz
&& !rn2(5))
register struct monst
*mtmp
;
register struct monst
*mtmp2
;
if(mtmp2
= makemon(PM_WIZARD
, mtmp
->mx
, mtmp
->my
)) {
mtmp2
->mappearance
= wizapp
[rn2(sizeof(wizapp
)-1)];