Mercurial > hg > early-roguelike
comparison arogue5/rings.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 | c49f7927b0fa | 
   comparison
  equal
  deleted
  inserted
  replaced
| 62:0ef99244acb8 | 63:0ed67132cf10 | 
|---|---|
| 1 /* | |
| 2 * routines dealing specifically with rings | |
| 3 * | |
| 4 * Advanced Rogue | |
| 5 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T | |
| 6 * All rights reserved. | |
| 7 * | |
| 8 * Based on "Rogue: Exploring the Dungeons of Doom" | |
| 9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 13 */ | |
| 14 | |
| 15 #include "curses.h" | |
| 16 #include "rogue.h" | |
| 17 | |
| 18 /* | |
| 19 * how much food does this ring use up? | |
| 20 */ | |
| 21 ring_eat(hand) | |
| 22 register int hand; | |
| 23 { | |
| 24 if (cur_ring[hand] == NULL) | |
| 25 return 0; | |
| 26 switch (cur_ring[hand]->o_which) { | |
| 27 case R_VAMPREGEN: | |
| 28 return 3; | |
| 29 case R_REGEN: | |
| 30 return 2; | |
| 31 case R_HEALTH: | |
| 32 case R_SUSABILITY: | |
| 33 return 1; | |
| 34 case R_SEARCH: | |
| 35 case R_SEEINVIS: | |
| 36 return (rnd(100) < 33); | |
| 37 case R_DIGEST: | |
| 38 if (cur_ring[hand]->o_ac >= 0) | |
| 39 return (-(cur_ring[hand]->o_ac)-1); | |
| 40 else | |
| 41 return (-(cur_ring[hand]->o_ac)); | |
| 42 } | |
| 43 return 0; | |
| 44 } | |
| 45 | |
| 46 ring_on(obj) | |
| 47 register struct object *obj; | |
| 48 { | |
| 49 register int save_max; | |
| 50 char buf[LINELEN]; | |
| 51 | |
| 52 /* | |
| 53 * Calculate the effect it has on the poor guy. | |
| 54 */ | |
| 55 switch (obj->o_which) | |
| 56 { | |
| 57 case R_ADDSTR: | |
| 58 save_max = max_stats.s_str; | |
| 59 chg_str(obj->o_ac); | |
| 60 max_stats.s_str = save_max; | |
| 61 when R_ADDHIT: | |
| 62 pstats.s_dext += obj->o_ac; | |
| 63 when R_ADDINTEL: | |
| 64 pstats.s_intel += obj->o_ac; | |
| 65 when R_ADDWISDOM: | |
| 66 pstats.s_wisdom += obj->o_ac; | |
| 67 when R_SEEINVIS: | |
| 68 turn_on(player, CANSEE); | |
| 69 msg("Your eyes begin to tingle"); | |
| 70 light(&hero); | |
| 71 mvwaddch(cw, hero.y, hero.x, PLAYER); | |
| 72 when R_AGGR: | |
| 73 aggravate(); | |
| 74 when R_WARMTH: | |
| 75 turn_on(player, NOCOLD); | |
| 76 when R_FIRE: | |
| 77 turn_on(player, NOFIRE); | |
| 78 when R_LIGHT: { | |
| 79 if(roomin(&hero) != NULL) { | |
| 80 light(&hero); | |
| 81 mvwaddch(cw, hero.y, hero.x, PLAYER); | |
| 82 } | |
| 83 } | |
| 84 when R_SEARCH: | |
| 85 daemon(ring_search, 0, AFTER); | |
| 86 when R_TELEPORT: | |
| 87 daemon(ring_teleport, 0, AFTER); | |
| 88 } | |
| 89 status(FALSE); | |
| 90 if (r_know[obj->o_which] && r_guess[obj->o_which]) | |
| 91 { | |
| 92 free(r_guess[obj->o_which]); | |
| 93 r_guess[obj->o_which] = NULL; | |
| 94 } | |
| 95 else if (!r_know[obj->o_which] && | |
| 96 askme && | |
| 97 (obj->o_flags & ISKNOW) == 0 && | |
| 98 r_guess[obj->o_which] == NULL) { | |
| 99 msg(terse ? "Call it: " : "What do you want to call it? "); | |
| 100 if (get_str(buf, cw) == NORM) | |
| 101 { | |
| 102 r_guess[obj->o_which] = new((unsigned int) strlen(buf) + 1); | |
| 103 strcpy(r_guess[obj->o_which], buf); | |
| 104 } | |
| 105 msg(""); | |
| 106 } | |
| 107 } | |
| 108 | |
| 109 /* | |
| 110 * print ring bonuses | |
| 111 */ | |
| 112 char * | |
| 113 ring_num(obj) | |
| 114 register struct object *obj; | |
| 115 { | |
| 116 static char buf[5]; | |
| 117 | |
| 118 if (!(obj->o_flags & ISKNOW)) | |
| 119 return ""; | |
| 120 switch (obj->o_which) | |
| 121 { | |
| 122 case R_PROTECT: | |
| 123 case R_ADDSTR: | |
| 124 case R_ADDDAM: | |
| 125 case R_ADDHIT: | |
| 126 case R_ADDINTEL: | |
| 127 case R_ADDWISDOM: | |
| 128 case R_DIGEST: | |
| 129 buf[0] = ' '; | |
| 130 strcpy(&buf[1], num(obj->o_ac, 0)); | |
| 131 when R_AGGR: | |
| 132 case R_LIGHT: | |
| 133 case R_HEAVY: | |
| 134 case R_TELEPORT: | |
| 135 if (obj->o_flags & ISCURSED) | |
| 136 return " cursed"; | |
| 137 else | |
| 138 return ""; | |
| 139 otherwise: | |
| 140 return ""; | |
| 141 } | |
| 142 return buf; | |
| 143 } | |
| 144 | |
| 145 /* | |
| 146 * Return the effect of the specified ring | |
| 147 */ | |
| 148 ring_value(type) | |
| 149 { | |
| 150 int result = 0; | |
| 151 | |
| 152 if (ISRING(LEFT_1, type)) result += cur_ring[LEFT_1]->o_ac; | |
| 153 if (ISRING(LEFT_2, type)) result += cur_ring[LEFT_2]->o_ac; | |
| 154 if (ISRING(LEFT_3, type)) result += cur_ring[LEFT_3]->o_ac; | |
| 155 if (ISRING(LEFT_4, type)) result += cur_ring[LEFT_4]->o_ac; | |
| 156 if (ISRING(RIGHT_1, type)) result += cur_ring[RIGHT_1]->o_ac; | |
| 157 if (ISRING(RIGHT_2, type)) result += cur_ring[RIGHT_2]->o_ac; | |
| 158 if (ISRING(RIGHT_3, type)) result += cur_ring[RIGHT_3]->o_ac; | |
| 159 if (ISRING(RIGHT_4, type)) result += cur_ring[RIGHT_4]->o_ac; | |
| 160 return(result); | |
| 161 } | 
