Mercurial > hg > early-roguelike
diff rogue3/fight.c @ 0:527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
| author | edwarj4 |
|---|---|
| date | Tue, 13 Oct 2009 13:33:34 +0000 |
| parents | |
| children | e7aab31362af |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rogue3/fight.c Tue Oct 13 13:33:34 2009 +0000 @@ -0,0 +1,737 @@ +/* + * All the fighting gets done here + * + * @(#)fight.c 3.28 (Berkeley) 6/15/81 + * + * 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 <ctype.h> +#include <string.h> +#include <stdlib.h> +#include "rogue.h" + +int e_levels[] = { + 10,20,40,80,160,320,640,1280,2560,5120,10240,20480, + 40920, 81920, 163840, 327680, 655360, 1310720, 2621440, 0 }; + +/* + * fight: + * The player attacks the monster. + */ + +int +fight(coord *mp, int mn, struct object *weap, int thrown) +{ + struct thing *tp; + struct linked_list *item; + int did_hit = TRUE; + + /* + * Find the monster we want to fight + */ + if ((item = find_mons(mp->y, mp->x)) == NULL) + { + debug("Fight what @ %d,%d", mp->y, mp->x); + return(0); + } + tp = (struct thing *) ldata(item); + /* + * Since we are fighting, things are not quiet so no healing takes + * place. + */ + quiet = 0; + runto(mp, &hero); + /* + * Let him know it was really a mimic (if it was one). + */ + if (tp->t_type == 'M' && tp->t_disguise != 'M' && off(player, ISBLIND)) + { + msg("Wait! That's a mimic!"); + tp->t_disguise = 'M'; + did_hit = thrown; + } + if (did_hit) + { + char *mname; + + did_hit = FALSE; + if (on(player, ISBLIND)) + mname = "it"; + else + mname = monsters[mn-'A'].m_name; + if (roll_em(&pstats, &tp->t_stats, weap, thrown)) + { + did_hit = TRUE; + if (thrown) + thunk(weap, mname); + else + hit(NULL, mname); + if (on(player, CANHUH)) + { + msg("Your hands stop glowing red"); + msg("The %s appears confused.", mname); + tp->t_flags |= ISHUH; + player.t_flags &= ~CANHUH; + } + if (tp->t_stats.s_hpt <= 0) + killed(item, TRUE); + } + else + if (thrown) + bounce(weap, mname); + else + miss(NULL, mname); + } + count = 0; + return did_hit; +} + +/* + * attack: + * The monster attacks the player + */ + +int +attack(struct thing *mp) +{ + char *mname; + + /* + * Since this is an attack, stop running and any healing that was + * going on at the time. + */ + running = FALSE; + quiet = 0; + if (mp->t_type == 'M' && off(player, ISBLIND)) + mp->t_disguise = 'M'; + if (on(player, ISBLIND)) + mname = "it"; + else + mname = monsters[mp->t_type-'A'].m_name; + if (roll_em(&mp->t_stats, &pstats, NULL, FALSE)) + { + if (mp->t_type != 'E') + hit(mname, NULL); + if (pstats.s_hpt <= 0) + death(mp->t_type); /* Bye bye life ... */ + if (off(*mp, ISCANC)) + switch (mp->t_type) + { + case 'R': + /* + * If a rust monster hits, you lose armor + */ + if (cur_armor != NULL && cur_armor->o_ac < 9) + { + if (!terse) + msg("Your armor appears to be weaker now. Oh my!"); + else + msg("Your armor weakens"); + cur_armor->o_ac++; + } + when 'E': + /*
