Mercurial > hg > early-roguelike
diff arogue5/monsters.c @ 63:0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
| author | elwin |
|---|---|
| date | Thu, 09 Aug 2012 22:58:48 +0000 |
| parents | |
| children | 56e748983fa8 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/arogue5/monsters.c Thu Aug 09 22:58:48 2012 +0000 @@ -0,0 +1,1034 @@ +/* + * File with various monster functions in it + * + * Advanced Rogue + * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T + * All rights reserved. + * + * Based on "Rogue: Exploring the Dungeons of Doom" + * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include "curses.h" +#include "rogue.h" +#include <ctype.h> +#include <string.h> + + +/* + * Check_residue takes care of any effect of the monster + */ +check_residue(tp) +register struct thing *tp; +{ + /* + * Take care of special abilities + */ + if (on(*tp, DIDHOLD) && (--hold_count == 0)) turn_off(player, ISHELD); + + /* If it has lowered player, give him back a level */ + if (on(*tp, DIDDRAIN)) raise_level(FALSE); + + /* If frightened of this monster, stop */ + if (on(player, ISFLEE) && + player.t_dest == &tp->t_pos) turn_off(player, ISFLEE); + + /* If monster was suffocating player, stop it */ + if (on(*tp, DIDSUFFOCATE)) extinguish(suffocate); + + /* If something with fire, may darken */ + if (on(*tp, HASFIRE)) { + register struct room *rp=roomin(&tp->t_pos); + register struct linked_list *fire_item; + + if (rp) { + for (fire_item = rp->r_fires; fire_item != NULL; + fire_item = next(fire_item)) { + if (THINGPTR(fire_item) == tp) { + detach(rp->r_fires, fire_item); + destroy_item(fire_item); + if (rp->r_fires == NULL) { + rp->r_flags &= ~HASFIRE; + if (cansee(tp->t_pos.y, tp->t_pos.x)) light(&hero); + } + break; + } + } + } + } +} + +/* + * Creat_mons creates the specified monster -- any if 0 + */ + +bool +creat_mons(person, monster, report) +struct thing *person; /* Where to create next to */ +short monster; +bool report; +{ + struct linked_list *nitem; + register struct thing *tp; + struct room *rp; + coord *mp; + + if (levtype == POSTLEV) + return(FALSE); + if ((mp = fallpos(&(person->t_pos), FALSE, 2)) != NULL) { + nitem = new_item(sizeof (struct thing)); + new_monster(nitem, + monster == 0 ? randmonster(FALSE, FALSE) + : monster, + mp, + TRUE); + tp = THINGPTR(nitem); + runto(tp, &hero); + tp->t_no_move = 1; /* since it just got here, it is disoriented */ + carry_obj(tp, monsters[tp->t_index].m_carry/2); /* only half chance */ + if (on(*tp, HASFIRE)) { + rp = roomin(&tp->t_pos); + if (rp) { + register struct linked_list *fire_item; + + /* Put the new fellow in the room list */ + fire_item = creat_item(); + ldata(fire_item) = (char *) tp; + attach(rp->r_fires, fire_item); + + rp->r_flags |= HASFIRE; + } + } + + /* + * If we can see this monster, set oldch to ' ' to make light() + * think the creature used to be invisible (ie. not seen here) + */ + if (cansee(tp->t_pos.y, tp->t_pos.x)) tp->t_oldch = ' '; + return(TRUE); + } + if (report) msg("You hear a faint cry of anguish in the distance."); + return(FALSE); +} + +/* + * Genmonsters: + * Generate at least 'least' monsters for this single room level. + * 'Treas' indicates whether this is a "treasure" level. + */ + +void +genmonsters(least, treas) +register int least; +bool treas; +{ + reg int i; + reg struct room *rp = &rooms[0]; + reg struct linked_list *item; + reg struct thing *mp; + coord tp; + + for (i = 0; i < level + least; i++) {
