|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1983 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that: (1) source distributions retain this entire copyright ! 7: * notice and comment, and (2) distributions including binaries display ! 8: * the following acknowledgement: ``This product includes software ! 9: * developed by the University of California, Berkeley and its contributors'' ! 10: * in the documentation or other materials provided with the distribution ! 11: * and in all advertising materials mentioning features or use of this ! 12: * software. Neither the name of the University nor the names of its ! 13: * contributors may be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: static char sccsid[] = "@(#)com7.c 5.3 (Berkeley) 6/1/90"; ! 22: #endif /* not lint */ ! 23: ! 24: #include "externs.h" ! 25: ! 26: fight(enemy,strength) ! 27: int enemy,strength; ! 28: { ! 29: int lifeline = 0; ! 30: int hurt; ! 31: char auxbuf[LINELENGTH]; ! 32: char *next; ! 33: int i; ! 34: int exhaustion; ! 35: ! 36: fighton: ! 37: time++; ! 38: snooze -= 5; ! 39: if (snooze > time) ! 40: exhaustion = CYCLE/(snooze - time); ! 41: else { ! 42: puts("You collapse exhausted, and he pulverizes your skull."); ! 43: die(); ! 44: } ! 45: if (snooze - time < 20) ! 46: puts("You look tired! I hope you're able to fight."); ! 47: next = getcom(auxbuf, LINELENGTH, "<fight!>-: ", 0); ! 48: for (i=0; next && i < 10; i++) ! 49: next = getword(next, words[i], -1); ! 50: parse(); ! 51: switch(wordvalue[wordnumber]){ ! 52: ! 53: case KILL: ! 54: case SMITE: ! 55: if (testbit(inven,TWO_HANDED)) ! 56: hurt = rnd(70) - 2 * card(injuries,NUMOFINJURIES) - ucard(wear) - exhaustion; ! 57: else if (testbit(inven,SWORD) || testbit(inven, BROAD)) ! 58: hurt = rnd(50)%(WEIGHT-carrying)-card(injuries,NUMOFINJURIES)-encumber - exhaustion; ! 59: else if (testbit(inven,KNIFE) || testbit(inven,MALLET) || testbit(inven,CHAIN) || testbit(inven,MACE) || testbit(inven,HALBERD)) ! 60: hurt = rnd(15) - card(injuries,NUMOFINJURIES) - exhaustion; ! 61: else ! 62: hurt = rnd(7) - encumber; ! 63: if (hurt < 5) ! 64: switch(rnd(3)){ ! 65: ! 66: case 0: ! 67: puts("You swung wide and missed."); ! 68: break; ! 69: case 1: ! 70: puts("He checked your blow. CLASH! CLANG!"); ! 71: break; ! 72: case 2: ! 73: puts("His filthy tunic hangs by one less thread."); ! 74: break; ! 75: } ! 76: else if (hurt < 10){ ! 77: switch(rnd(3)){ ! 78: case 0: ! 79: puts("He's bleeding."); ! 80: break; ! 81: case 1: ! 82: puts("A trickle of blood runs down his face."); ! 83: break; ! 84: case 2: ! 85: puts("A huge purple bruise is forming on the side of his face."); ! 86: break; ! 87: } ! 88: lifeline++; ! 89: } ! 90: else if (hurt < 20){ ! 91: switch(rnd(3)){ ! 92: case 0: ! 93: puts("He staggers back quavering."); ! 94: break; ! 95: case 1: ! 96: puts("He jumps back with his hand over the wound."); ! 97: break; ! 98: case 2: ! 99: puts("His shirt falls open with a swath across the chest."); ! 100: break; ! 101: } ! 102: lifeline += 5; ! 103: } ! 104: else if (hurt < 30){ ! 105: switch(rnd(3)){ ! 106: case 0: ! 107: printf("A bloody gash opens up on his %s side.\n",(rnd(2) ? "left" : "right")); ! 108: break; ! 109: case 1: ! 110: puts("The steel bites home and scrapes along his ribs."); ! 111: break; ! 112: case 2: ! 113: puts("You pierce him, and his breath hisses through clenched teeth."); ! 114: break; ! 115: } ! 116: lifeline += 10; ! 117: } ! 118: else if (hurt < 40){ ! 119: switch(rnd(3)){ ! 120: case 0: ! 121: puts("You smite him to the ground."); ! 122: if (strength - lifeline > 20) ! 123: puts("But in a flurry of steel he regains his feet!"); ! 124: break; ! 125: case 1: ! 126: puts("The force of your blow sends him to his knees."); ! 127: puts("His arm swings lifeless at his side."); ! 128: break; ! 129: case 2: ! 130: puts("Clutching his blood drenched shirt, he collapses stunned."); ! 131: break; ! 132: } ! 133: lifeline += 20; ! 134: } ! 135: else { ! 136: switch(rnd(3)){ ! 137: case 0: ! 138: puts("His ribs crack under your powerful swing, flooding his lungs with blood."); ! 139: break; ! 140: case 1: ! 141: puts("You shatter his upheld arm in a spray of blood. The blade continues deep"); ! 142: puts("into his back, severing the spinal cord."); ! 143: lifeline += 25; ! 144: break; ! 145: case 2: ! 146: puts("With a mighty lunge the steel slides in, and gasping, he falls to the ground."); ! 147: lifeline += 25; ! 148: break; ! 149: } ! 150: lifeline += 30; ! 151: } ! 152: break; ! 153: ! 154: case BACK: ! 155: if (enemy == DARK && lifeline > strength * 0.33){ ! 156: puts("He throws you back against the rock and pummels your face."); ! 157: if (testbit(inven,AMULET) || testbit(wear,AMULET)){ ! 158: printf("Lifting the amulet from you, "); ! 159: if (testbit(inven,MEDALION) || testbit(wear,MEDALION)){ ! 160: puts("his power grows and the walls of\nthe earth tremble."); ! 161: puts("When he touches the medallion, your chest explodes and the foundations of the\nearth collapse."); ! 162: puts("The planet is consumed by darkness."); ! 163: die(); ! 164: } ! 165: if (testbit(inven,AMULET)){ ! 166: clearbit(inven,AMULET); ! 167: carrying -= objwt[AMULET]; ! 168: encumber -= objcumber[AMULET]; ! 169: } ! 170: else ! 171: clearbit(wear,AMULET); ! 172: puts("he flees down the dark caverns."); ! 173: clearbit(location[position].objects,DARK); ! 174: injuries[SKULL] = 1; ! 175: followfight = time; ! 176: return (0); ! 177: } ! 178: else{ ! 179: puts("I'm afraid you have been killed."); ! 180: die(); ! 181: } ! 182: } ! 183: else{ ! 184: puts("You escape stunned and disoriented from the fight."); ! 185: puts("A victorious bellow echoes from the battlescene."); ! 186: if (back && position != back) ! 187: move(back,BACK); ! 188: else if (ahead &&position != ahead) ! 189: move(ahead,AHEAD); ! 190: else if (left && position != left) ! 191: move(left,LEFT); ! 192: else if (right && position != right) ! 193: move(right,RIGHT); ! 194: else ! 195: move(location[position].down,AHEAD); ! 196: return(0); ! 197: } ! 198: ! 199: case SHOOT: ! 200: if (testbit(inven,LASER)){ ! 201: if (strength - lifeline <= 50){ ! 202: printf("The %s took a direct hit!\n",objsht[enemy]); ! 203: lifeline += 50; ! 204: } ! 205: else { ! 206: puts("With his bare hand he deflects the laser blast and whips the pistol from you!"); ! 207: clearbit(inven,LASER); ! 208: setbit(location[position].objects,LASER); ! 209: carrying -= objwt[LASER]; ! 210: encumber -= objcumber[LASER]; ! 211: } ! 212: } ! 213: else ! 214: puts("Unfortunately, you don't have a blaster handy."); ! 215: break; ! 216: ! 217: case DROP: ! 218: case DRAW: ! 219: cypher(); ! 220: time--; ! 221: break; ! 222: ! 223: default: ! 224: puts("You don't have a chance, he is too quick."); ! 225: break; ! 226: ! 227: } ! 228: if (lifeline >= strength){ ! 229: printf("You have killed the %s.\n", objsht[enemy]); ! 230: if (enemy == ELF || enemy == DARK) ! 231: puts("A watery black smoke consumes his body and then vanishes with a peal of thunder!"); ! 232: clearbit(location[position].objects,enemy); ! 233: power += 2; ! 234: notes[JINXED]++; ! 235: return(0); ! 236: } ! 237: puts("He attacks..."); ! 238: /* some embellisments */ ! 239: hurt = rnd(NUMOFINJURIES) - (testbit(inven,SHIELD) != 0) - (testbit(wear,MAIL) != 0) - (testbit(wear,HELM) != 0); ! 240: hurt += (testbit(wear,AMULET) != 0) + (testbit(wear,MEDALION) != 0) + (testbit(wear,TALISMAN) != 0); ! 241: hurt = hurt < 0 ? 0 : hurt; ! 242: hurt = hurt >= NUMOFINJURIES ? NUMOFINJURIES -1 : hurt; ! 243: if (!injuries[hurt]){ ! 244: injuries[hurt] = 1; ! 245: printf("I'm afraid you have suffered %s.\n", ouch[hurt]); ! 246: } ! 247: else ! 248: puts("You emerge unscathed."); ! 249: if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]){ ! 250: puts("I'm afraid you have suffered fatal injuries."); ! 251: die(); ! 252: } ! 253: goto fighton; ! 254: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.