Mercurial > hg > early-roguelike
view arogue5/util.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 | e52a8a7ad4c5 |
| children |
line wrap: on
line source
/* * all sorts of miscellaneous routines * * 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> /* * aggravate: * aggravate all the monsters on this level */ void aggravate(void) { register struct linked_list *mi; for (mi = mlist; mi != NULL; mi = next(mi)) runto(THINGPTR(mi), &hero); } /* * cansee: * returns true if the hero can see a certain coordinate. */ bool cansee(int y, int x) { register struct room *rer; register int radius; coord tp; if (on(player, ISBLIND)) return FALSE; tp.y = y; tp.x = x; rer = roomin(&tp); /* How far can we see? */ if (levtype == OUTSIDE) { if (daytime) radius = 36; else if (lit_room(rer)) radius = 9; else radius = 3; } else radius = 3; /* * We can only see if the hero in the same room as * the coordinate and the room is lit or if it is close. */ return ((rer != NULL && levtype != OUTSIDE && (levtype != MAZELEV || /* Maze level needs direct line */ maze_view(tp.y, tp.x)) && rer == roomin(&hero) && lit_room(rer)) || DISTANCE(y, x, hero.y, hero.x) < radius); } /* * check_level: * Check to see if the guy has gone up a level. * * Return points needed to obtain next level. * * These are the beginning experience levels for all players. * All further experience levels are computed by muliplying by 2 * up through MAXDOUBLE. */ #define MAXDOUBLE 14 /* Maximum number of times score is doubled */ static struct { long base; /* What it starts out at for doubling */ long cap; /* The maximum before doubling stops */ } e_levels[4] = { /* You must change MAXDOUBLE if you change the cap figure */ { 90L, 1474560L }, /* Fighter */ { 130L, 2129920L }, /* Magician */ { 110L, 1802240L }, /* cleric */ { 75L, 1228800L } /* Thief */ }; long check_level(bool get_spells) { register int i, j, add = 0; register unsigned long exp; long retval; /* Return value */ int nsides = 0; /* See if we are past the doubling stage */ exp = e_levels[player.t_ctype].cap; if (pstats.s_exp >= exp) { i = pstats.s_exp/exp; /* First get amount above doubling area */ retval = exp + i * exp; /* Compute next higher boundary */ i += MAXDOUBLE; /* Add in the previous doubled levels */ } else { i = 0; exp = e_levels[player.t_ctype].base; while (exp <= pstats.s_exp) { i++; exp <<= 1; } retval = exp; } if (++i > pstats.s_lvl) { switch (player.t_ctype) { case C_FIGHTER: nsides = 10; when C_MAGICIAN: nsides = 4; when C_CLERIC: nsides = 8; when C_THIEF: nsides = 6; } /* Take care of multi-level jumps */ for (j=0; j < (i-pstats.s_lvl); j++) add += max(1, roll(1,nsides) + const_bonus()); max_stats.s_hpt += add; if ((pstats.s_hpt += add) > max_stats.s_hpt) pstats.s_hpt = max_stats.s_hpt; sprintf(outstring,"Welcome, %s, to level %d", cnames[player.t_ctype][min(i-1, 10)], i); msg(outstring); if (get_spells) { pray_time = 0; /* A new round of prayers */ spell_power = 0; /* A new round of spells */ } } pstats.s_lvl = i; return(retval); } /* * Used to modify the playes strength * it keeps track of the highest it has been, just in case */ void chg_str(int amt) { register int ring_str; /* ring strengths */ register struct stats *ptr; /* for speed */ ptr = &pstats; ring_str = ring_value(R_ADDSTR); ptr->s_str -= ring_str; ptr->s_str += amt; if (ptr->s_str > 25) ptr->s_str = 25; if (ptr->s_str > max_stats.s_str) max_stats.s_str = ptr->s_str; ptr->s_str += ring_str; if (ptr->s_str <= 0) death(D_STRENGTH); updpack(TRUE); } /* * this routine computes the players current AC without dex bonus's */ int ac_compute(void) { register int ac; ac = cur_armor != NULL ? cur_armor->o_ac : pstats.s_arm;
