Mercurial > hg > early-roguelike
view arogue5/fight.c @ 317:aab761616489 default tip
Rearrange some Autoconf files.
Autoconf was failing to detect install-sh at the top level and needed
some explicit directions. It also wants config.guess and config.sub to
be provided too.
A few other macros have also been updated.
| author | John "Elwin" Edwards |
|---|---|
| date | Tue, 05 Sep 2023 20:05:24 -0400 |
| parents | 0990adf580ee |
| children |
line wrap: on
line source
/* * All the fighting gets done here * * 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 <stdlib.h> #include <ctype.h> #include <string.h> #include "rogue.h" bool roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, bool hurl, struct object *cur_weapon, bool back_stab); void hit(struct object *weapon, struct thing *tp, const char *er, const char *ee, bool back_stab); void miss(struct object *weapon, struct thing *tp, const char *er, const char *ee); int dext_plus(int dexterity); int str_plus(short str); int add_dam(short str); int hung_dam(void); void thunk(struct object *weap, struct thing *tp, const char *mname); void m_thunk(struct object *weap, struct thing *tp, const char *mname); void bounce(struct object *weap, struct thing *tp, const char *mname); void m_bounce(struct object *weap, struct thing *tp, const char *mname); struct object *wield_weap(struct object *thrown, struct thing *mp); void explode(struct thing *tp); #define CONF_DAMAGE -1 #define PARAL_DAMAGE -2 #define DEST_DAMAGE -3 static const struct matrix att_mat[5] = { /* Base Max_lvl, Factor, Offset, Range */ { 10, 25, 2, 1, 2 }, { 9, 18, 2, 1, 5 }, { 10, 19, 2, 1, 3 }, { 10, 21, 2, 1, 4 }, { 7, 25, 1, 0, 2 } }; /* * fight: * The player attacks the monster. */ bool fight(coord *mp, struct object *weap, bool thrown) { register struct thing *tp; register struct linked_list *item; register bool did_hit = TRUE; bool back_stab = FALSE; /* * Find the monster we want to fight */ if ((item = find_mons(mp->y, mp->x)) == NULL) { return(FALSE); /* must have killed him already */ } tp = THINGPTR(item); /* * Since we are fighting, things are not quiet so no healing takes * place. */ player.t_quiet = 0; tp->t_quiet = 0; /* * if its in the wall, we can't hit it */ if (on(*tp, ISINWALL) && off(player, CANINWALL)) return(FALSE); /* * Let him know it was really a mimic (if it was one). */ if (on(*tp, ISDISGUISE) && (tp->t_type != tp->t_disguise) && off(player, ISBLIND)) { msg("Wait! That's a %s!", monsters[tp->t_index].m_name); turn_off(*tp, ISDISGUISE); did_hit = thrown; } if (on(*tp, CANSURPRISE) && off(player, ISBLIND) && !ISWEARING(R_ALERT)) { msg("Wait! There's a %s!", monsters[tp->t_index].m_name); turn_off(*tp, CANSURPRISE); did_hit = thrown; } /* * if he's a thief and the creature is asleep then he gets a chance * for a backstab */ if (player.t_ctype == C_THIEF && (!on(*tp, ISRUN) || on(*tp, ISHELD) || tp->t_no_move > 0)&& !on(*tp, NOSTAB)) back_stab = TRUE; runto(tp, &hero); if (did_hit) { register const char *mname; did_hit = FALSE; mname = (on(player, ISBLIND)) ? "it" : monsters[tp->t_index].m_name; if (!can_blink(tp) && ( ((weap != NULL) && (weap->o_type == RELIC)) || ((off(*tp, MAGICHIT) || ((weap != NULL) && (weap->o_hplus > 0 || weap->o_dplus > 0)) ) && (off(*tp, BMAGICHIT) || ((weap != NULL) && (weap->o_hplus > 1 || weap->o_dplus > 1)) ) && (off(*tp, CMAGICHIT) || ((weap != NULL) && (weap->o_hplus > 2 || weap->o_dplus > 2)) ) ) ) && roll_em(&player, tp, weap, thrown, cur_weapon, back_stab)) { did_hit = TRUE; if (on(*tp, NOMETAL) && weap != NULL && weap->o_type != RELIC && weap->o_flags & ISMETAL) { sprintf(outstring,"Your %s passes right through the %s!", weaps[weap->o_which].w_name, mname); msg(outstring); } else if (thrown) { tp->t_wasshot = TRUE; thunk(weap, tp, mname); } else hit(weap, tp, NULL, mname, back_stab); /* If the player hit a rust monster, he better have a + weapon */ if (on(*tp, CANRUST) && !thrown && (weap != NULL) && weap->o_type != RELIC && (weap->o_flags & ISMETAL) && !(weap->o_flags & ISPROT) && (weap->o_hplus < 1) && (weap->o_dplus < 1)) { if (rnd(100) < 50) weap->o_hplus--; else weap->o_dplus--; msg(terse ? "Your %s weakens!" : "Your %s appears to be weaker now!", weaps[weap->o_which].w_name); } /* If the player hit something that shrieks, wake the dungeon */ if (on(*tp, CANSHRIEK)) { turn_off(*tp, CANSHRIEK); msg("The %s emits a piercing shriek.", mname); aggravate(); } /* If the player hit something that can surprise, it can't now */ if (on(*tp, CANSURPRISE)) turn_off(*tp, CANSURPRISE);
