1 1.6 dholland /* $NetBSD: regen.c,v 1.6 2012/06/19 05:30:44 dholland Exp $ */ 2 1.5 christos 3 1.5 christos /* regen.c Larn is copyrighted 1986 by Noah Morgan. */ 4 1.5 christos #include <sys/cdefs.h> 5 1.2 mycroft #ifndef lint 6 1.6 dholland __RCSID("$NetBSD: regen.c,v 1.6 2012/06/19 05:30:44 dholland Exp $"); 7 1.5 christos #endif /* not lint */ 8 1.2 mycroft 9 1.1 cgd #include "header.h" 10 1.5 christos #include "extern.h" 11 1.1 cgd /* 12 1.1 cgd ******* 13 1.1 cgd REGEN() 14 1.1 cgd ******* 15 1.1 cgd regen() 16 1.1 cgd 17 1.1 cgd subroutine to regenerate player hp and spells 18 1.1 cgd */ 19 1.5 christos void 20 1.6 dholland regen(void) 21 1.5 christos { 22 1.5 christos int i, flag; 23 1.5 christos long *d; 24 1.1 cgd d = c; 25 1.1 cgd #ifdef EXTRA 26 1.1 cgd d[MOVESMADE]++; 27 1.1 cgd #endif 28 1.5 christos if (d[TIMESTOP]) { 29 1.5 christos if (--d[TIMESTOP] <= 0) 30 1.5 christos bottomline(); 31 1.5 christos return; 32 1.5 christos } /* for stop time spell */ 33 1.5 christos flag = 0; 34 1.5 christos 35 1.5 christos if (d[STRENGTH] < 3) { 36 1.5 christos d[STRENGTH] = 3; 37 1.5 christos flag = 1; 38 1.5 christos } 39 1.5 christos if ((d[HASTESELF] == 0) || ((d[HASTESELF] & 1) == 0)) 40 1.4 christos gltime++; 41 1.1 cgd 42 1.1 cgd if (d[HP] != d[HPMAX]) 43 1.5 christos if (d[REGENCOUNTER]-- <= 0) { /* regenerate hit points */ 44 1.5 christos d[REGENCOUNTER] = 22 + (d[HARDGAME] << 1) - d[LEVEL]; 45 1.5 christos if ((d[HP] += d[REGEN]) > d[HPMAX]) 46 1.5 christos d[HP] = d[HPMAX]; 47 1.1 cgd bottomhp(); 48 1.5 christos } 49 1.5 christos if (d[SPELLS] < d[SPELLMAX]) /* regenerate spells */ 50 1.5 christos if (d[ECOUNTER]-- <= 0) { 51 1.5 christos d[ECOUNTER] = 100 + 4 * (d[HARDGAME] - d[LEVEL] - d[ENERGY]); 52 1.5 christos d[SPELLS]++; 53 1.5 christos bottomspell(); 54 1.5 christos } 55 1.5 christos if (d[HERO]) 56 1.5 christos if (--d[HERO] <= 0) { 57 1.5 christos for (i = 0; i < 6; i++) 58 1.5 christos d[i] -= 10; 59 1.5 christos flag = 1; 60 1.5 christos } 61 1.5 christos if (d[ALTPRO]) 62 1.5 christos if (--d[ALTPRO] <= 0) { 63 1.5 christos d[MOREDEFENSES] -= 3; 64 1.5 christos flag = 1; 65 1.5 christos } 66 1.5 christos if (d[PROTECTIONTIME]) 67 1.5 christos if (--d[PROTECTIONTIME] <= 0) { 68 1.5 christos d[MOREDEFENSES] -= 2; 69 1.5 christos flag = 1; 70 1.5 christos } 71 1.5 christos if (d[DEXCOUNT]) 72 1.5 christos if (--d[DEXCOUNT] <= 0) { 73 1.5 christos d[DEXTERITY] -= 3; 74 1.5 christos flag = 1; 75 1.5 christos } 76 1.5 christos if (d[STRCOUNT]) 77 1.5 christos if (--d[STRCOUNT] <= 0) { 78 1.5 christos d[STREXTRA] -= 3; 79 1.5 christos flag = 1; 80 1.5 christos } 81 1.5 christos if (d[BLINDCOUNT]) 82 1.5 christos if (--d[BLINDCOUNT] <= 0) { 83 1.5 christos cursors(); 84 1.5 christos lprcat("\nThe blindness lifts "); 85 1.5 christos beep(); 86 1.5 christos } 87 1.5 christos if (d[CONFUSE]) 88 1.5 christos if (--d[CONFUSE] <= 0) { 89 1.5 christos cursors(); 90 1.5 christos lprcat("\nYou regain your senses"); 91 1.5 christos beep(); 92 1.5 christos } 93 1.5 christos if (d[GIANTSTR]) 94 1.5 christos if (--d[GIANTSTR] <= 0) { 95 1.5 christos d[STREXTRA] -= 20; 96 1.5 christos flag = 1; 97 1.5 christos } 98 1.5 christos if (d[CHARMCOUNT]) 99 1.5 christos if ((--d[CHARMCOUNT]) <= 0) 100 1.5 christos flag = 1; 101 1.5 christos if (d[INVISIBILITY]) 102 1.5 christos if ((--d[INVISIBILITY]) <= 0) 103 1.5 christos flag = 1; 104 1.5 christos if (d[CANCELLATION]) 105 1.5 christos if ((--d[CANCELLATION]) <= 0) 106 1.5 christos flag = 1; 107 1.5 christos if (d[WTW]) 108 1.5 christos if ((--d[WTW]) <= 0) 109 1.5 christos flag = 1; 110 1.5 christos if (d[HASTESELF]) 111 1.5 christos if ((--d[HASTESELF]) <= 0) 112 1.5 christos flag = 1; 113 1.5 christos if (d[AGGRAVATE]) 114 1.5 christos --d[AGGRAVATE]; 115 1.5 christos if (d[SCAREMONST]) 116 1.5 christos if ((--d[SCAREMONST]) <= 0) 117 1.5 christos flag = 1; 118 1.5 christos if (d[STEALTH]) 119 1.5 christos if ((--d[STEALTH]) <= 0) 120 1.5 christos flag = 1; 121 1.5 christos if (d[AWARENESS]) 122 1.5 christos --d[AWARENESS]; 123 1.5 christos if (d[HOLDMONST]) 124 1.5 christos if ((--d[HOLDMONST]) <= 0) 125 1.5 christos flag = 1; 126 1.5 christos if (d[HASTEMONST]) 127 1.5 christos --d[HASTEMONST]; 128 1.5 christos if (d[FIRERESISTANCE]) 129 1.5 christos if ((--d[FIRERESISTANCE]) <= 0) 130 1.5 christos flag = 1; 131 1.5 christos if (d[GLOBE]) 132 1.5 christos if (--d[GLOBE] <= 0) { 133 1.5 christos d[MOREDEFENSES] -= 10; 134 1.5 christos flag = 1; 135 1.5 christos } 136 1.5 christos if (d[SPIRITPRO]) 137 1.5 christos if (--d[SPIRITPRO] <= 0) 138 1.5 christos flag = 1; 139 1.5 christos if (d[UNDEADPRO]) 140 1.5 christos if (--d[UNDEADPRO] <= 0) 141 1.5 christos flag = 1; 142 1.5 christos if (d[HALFDAM]) 143 1.5 christos if (--d[HALFDAM] <= 0) { 144 1.5 christos cursors(); 145 1.5 christos lprcat("\nYou now feel better "); 146 1.5 christos beep(); 147 1.5 christos } 148 1.1 cgd if (d[SEEINVISIBLE]) 149 1.5 christos if (--d[SEEINVISIBLE] <= 0) { 150 1.5 christos monstnamelist[INVISIBLESTALKER] = ' '; 151 1.5 christos cursors(); 152 1.5 christos lprcat("\nYou feel your vision return to normal"); 153 1.5 christos beep(); 154 1.5 christos } 155 1.5 christos if (d[ITCHING]) { 156 1.5 christos if (d[ITCHING] > 1) 157 1.5 christos if ((d[WEAR] != -1) || (d[SHIELD] != -1)) 158 1.5 christos if (rnd(100) < 50) { 159 1.5 christos d[WEAR] = d[SHIELD] = -1; 160 1.5 christos cursors(); 161 1.5 christos lprcat("\nThe hysteria of itching forces you to remove your armor!"); 162 1.5 christos beep(); 163 1.5 christos recalc(); 164 1.5 christos bottomline(); 165 1.5 christos } 166 1.5 christos if (--d[ITCHING] <= 0) { 167 1.5 christos cursors(); 168 1.5 christos lprcat("\nYou now feel the irritation subside!"); 169 1.5 christos beep(); 170 1.1 cgd } 171 1.5 christos } 172 1.5 christos if (d[CLUMSINESS]) { 173 1.1 cgd if (d[WIELD] != -1) 174 1.5 christos if (d[CLUMSINESS] > 1) 175 1.5 christos if (item[playerx][playery] == 0) /* only if nothing there */ 176 1.5 christos if (rnd(100) < 33) /* drop your weapon due 177 1.5 christos * to clumsiness */ 178 1.5 christos drop_object((int) d[WIELD]); 179 1.5 christos if (--d[CLUMSINESS] <= 0) { 180 1.5 christos cursors(); 181 1.5 christos lprcat("\nYou now feel less awkward!"); 182 1.5 christos beep(); 183 1.1 cgd } 184 1.1 cgd } 185 1.5 christos if (flag) 186 1.5 christos bottomline(); 187 1.5 christos } 188