1 #ifndef lint 2 static char rcsid[] = "$NetBSD: regen.c,v 1.4 1997/07/13 20:21:39 christos Exp $"; 3 #endif /* not lint */ 4 5 /* regen.c Larn is copyrighted 1986 by Noah Morgan. */ 6 #include "header.h" 7 /* 8 ******* 9 REGEN() 10 ******* 11 regen() 12 13 subroutine to regenerate player hp and spells 14 */ 15 regen() 16 { 17 register int i,flag; 18 register long *d; 19 d = c; 20 #ifdef EXTRA 21 d[MOVESMADE]++; 22 #endif 23 if (d[TIMESTOP]) { if(--d[TIMESTOP]<=0) bottomline(); return; } /* for stop time spell */ 24 flag=0; 25 26 if (d[STRENGTH]<3) { d[STRENGTH]=3; flag=1; } 27 if ((d[HASTESELF]==0) || ((d[HASTESELF] & 1) == 0)) 28 gltime++; 29 30 if (d[HP] != d[HPMAX]) 31 if (d[REGENCOUNTER]-- <= 0) /* regenerate hit points */ 32 { 33 d[REGENCOUNTER] = 22 + (d[HARDGAME]<<1) - d[LEVEL]; 34 if ((d[HP] += d[REGEN]) > d[HPMAX]) d[HP] = d[HPMAX]; 35 bottomhp(); 36 } 37 38 if (d[SPELLS] < d[SPELLMAX]) /* regenerate spells */ 39 if (d[ECOUNTER]-- <= 0) 40 { 41 d[ECOUNTER] = 100+4*(d[HARDGAME]-d[LEVEL]-d[ENERGY]); 42 d[SPELLS]++; bottomspell(); 43 } 44 45 if (d[HERO]) if (--d[HERO]<=0) { for (i=0; i<6; i++) d[i] -= 10; flag=1; } 46 if (d[ALTPRO]) if (--d[ALTPRO]<=0) { d[MOREDEFENSES]-=3; flag=1; } 47 if (d[PROTECTIONTIME]) if (--d[PROTECTIONTIME]<=0) { d[MOREDEFENSES]-=2; flag=1; } 48 if (d[DEXCOUNT]) if (--d[DEXCOUNT]<=0) { d[DEXTERITY]-=3; flag=1; } 49 if (d[STRCOUNT]) if (--d[STRCOUNT]<=0) { d[STREXTRA]-=3; flag=1; } 50 if (d[BLINDCOUNT]) if (--d[BLINDCOUNT]<=0) { cursors(); lprcat("\nThe blindness lifts "); beep(); } 51 if (d[CONFUSE]) if (--d[CONFUSE]<=0) { cursors(); lprcat("\nYou regain your senses"); beep(); } 52 if (d[GIANTSTR]) if (--d[GIANTSTR]<=0) { d[STREXTRA] -= 20; flag=1; } 53 if (d[CHARMCOUNT]) if ((--d[CHARMCOUNT]) <= 0) flag=1; 54 if (d[INVISIBILITY]) if ((--d[INVISIBILITY]) <= 0) flag=1; 55 if (d[CANCELLATION]) if ((--d[CANCELLATION]) <= 0) flag=1; 56 if (d[WTW]) if ((--d[WTW]) <= 0) flag=1; 57 if (d[HASTESELF]) if ((--d[HASTESELF]) <= 0) flag=1; 58 if (d[AGGRAVATE]) --d[AGGRAVATE]; 59 if (d[SCAREMONST]) if ((--d[SCAREMONST]) <= 0) flag=1; 60 if (d[STEALTH]) if ((--d[STEALTH]) <= 0) flag=1; 61 if (d[AWARENESS]) --d[AWARENESS]; 62 if (d[HOLDMONST]) if ((--d[HOLDMONST]) <= 0) flag=1; 63 if (d[HASTEMONST]) --d[HASTEMONST]; 64 if (d[FIRERESISTANCE]) if ((--d[FIRERESISTANCE]) <= 0) flag=1; 65 if (d[GLOBE]) if (--d[GLOBE]<=0) { d[MOREDEFENSES]-=10; flag=1; } 66 if (d[SPIRITPRO]) if (--d[SPIRITPRO] <= 0) flag=1; 67 if (d[UNDEADPRO]) if (--d[UNDEADPRO] <= 0) flag=1; 68 if (d[HALFDAM]) if (--d[HALFDAM]<=0) { cursors(); lprcat("\nYou now feel better "); beep(); } 69 if (d[SEEINVISIBLE]) 70 if (--d[SEEINVISIBLE]<=0) 71 { monstnamelist[INVISIBLESTALKER] = ' '; 72 cursors(); lprcat("\nYou feel your vision return to normal"); beep(); } 73 if (d[ITCHING]) 74 { 75 if (d[ITCHING]>1) 76 if ((d[WEAR]!= -1) || (d[SHIELD]!= -1)) 77 if (rnd(100)<50) 78 { 79 d[WEAR]=d[SHIELD]= -1; cursors(); 80 lprcat("\nThe hysteria of itching forces you to remove your armor!"); 81 beep(); recalc(); bottomline(); 82 } 83 if (--d[ITCHING]<=0) { cursors(); lprcat("\nYou now feel the irritation subside!"); beep(); } 84 } 85 if (d[CLUMSINESS]) 86 { 87 if (d[WIELD] != -1) 88 if (d[CLUMSINESS]>1) 89 if (item[playerx][playery]==0) /* only if nothing there */ 90 if (rnd(100)<33) /* drop your weapon due to clumsiness */ 91 drop_object((int)d[WIELD]); 92 if (--d[CLUMSINESS]<=0) { cursors(); lprcat("\nYou now feel less awkward!"); beep(); } 93 } 94 if (flag) bottomline(); 95 } 96 97