# 2.11BSD#431 - /usr/src/games/battlestar/com7.c

##### Functions

    fight             X

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

#### Defined functions

fight defined in line 13; used 5 times

- in /usr/src/games/battlestar/com1.c line 109, 117, 125
- in /usr/src/games/battlestar/com2.c line 253
- in /usr/src/games/battlestar/com5.c line 133

#### Defined variables

sccsid defined in line 8; never used

Last modified: 1996-10-27 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1300 |