LCOV - code coverage report
Current view: top level - omega-rpg-0.90-pa9 - command3.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 156 755 20.7 %
Date: 2017-09-08 22:00:26 Functions: 6 18 33.3 %
Branches: 59 426 13.8 %

           Branch data     Line data    Source code
       1                 :            : /* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
       2                 :            : /* command3.c */
       3                 :            : 
       4                 :            : /* This file contains some more top level command functions
       5                 :            :    called from command1.c */
       6                 :            : 
       7                 :            : #ifndef MSDOS_SUPPORTED_ANTIQUE
       8                 :            : #include <pwd.h>
       9                 :            : #include <unistd.h>
      10                 :            : #endif
      11                 :            : 
      12                 :            : #include "glob.h"
      13                 :            : 
      14                 :            : /* look at some spot */
      15                 :          4 : void examine(void)
      16                 :            : {
      17                 :            :   pol ol;
      18                 :          4 :   int x=Player.x,y=Player.y,drewmenu=FALSE;
      19                 :            : 
      20                 :          4 :   clearmsg();
      21                 :            :   
      22                 :            :   /* WDT HACK: I'm not sure I buy that one shouldn't be able to examine
      23                 :            :    * when one is blind.  However, the 'right' way to do it is certainly
      24                 :            :    * too difficult (I would expect to be able to examine only the items
      25                 :            :    * I actually recall).  So, for now I'll use David Given's compromise.
      26                 :            :    * 12/30/98
      27                 :            :    */
      28         [ -  + ]:          4 :   if (Player.status[BLINDED] > 0)
      29                 :            :   {
      30                 :          0 :     mprint("You're blind - you can't examine things.");
      31                 :          0 :     return;
      32                 :            :   }
      33                 :          4 :   setgamestatus(SKIP_MONSTERS);
      34                 :          4 :   mprint("Examine --");
      35                 :          4 :   setspot(&x,&y);
      36         [ +  - ]:          4 :   if (inbounds(x,y)) {
      37                 :          4 :     clearmsg();
      38         [ -  + ]:          4 :     if (Current_Environment == E_COUNTRYSIDE) {
      39         [ #  # ]:          0 :       if (! c_statusp(x, y, SEEN))
      40                 :          0 :         print3("How should I know what that is?");
      41                 :            :       else {
      42                 :          0 :         mprint("That terrain is:");
      43                 :          0 :         mprint(countryid(Country[x][y].current_terrain_type));
      44                 :            :       }
      45                 :            :     } 
      46         [ -  + ]:          4 :     else if (! view_los_p(Player.x,Player.y,x,y))
      47                 :          0 :       print3("I refuse to examine something I can't see.");
      48                 :            :     else {
      49                 :          4 :       clearmsg();
      50         [ +  - ]:          4 :       if (Level->site[x][y].creature != NULL) 
      51                 :          4 :         mprint(mstatus_string(Level->site[x][y].creature));
      52 [ #  # ][ #  # ]:          0 :       else if ((Player.x == x) && (Player.y ==y)) 
      53                 :          0 :         describe_player();
      54         [ -  + ]:          4 :       if (loc_statusp(x,y,SECRET))
      55                 :          0 :         print2("An age-worn stone wall.");
      56                 :            :       else
      57   [ -  -  -  +  :          4 :         switch (Level->site[x][y].locchar) {
          -  +  -  -  -  
          -  -  -  -  +  
          -  -  -  -  -  
                -  -  - ]
      58                 :          0 :         case SPACE: print2("An infinite void."); break;
      59                 :          0 :         case PORTCULLIS: print2("A heavy steel portcullis"); break;
      60                 :          0 :         case ABYSS: print2("An entrance to the infinite abyss"); break;
      61                 :            :         case FLOOR:
      62         [ -  + ]:          2 :           if (Current_Dungeon == Current_Environment)
      63                 :          0 :             print2("A dirty stone floor.");
      64                 :          2 :           else print2("The ground.");
      65                 :          2 :           break;
      66                 :            :         case WALL:
      67         [ #  # ]:          0 :           if (Level->site[x][y].aux == 0)
      68                 :          0 :             print2("A totally impervious wall.");
      69         [ #  # ]:          0 :           else if (Level->site[x][y].aux < 10)
      70                 :          0 :             print2("A pitted concrete wall.");
      71         [ #  # ]:          0 :           else if (Level->site[x][y].aux < 30)
      72                 :          0 :             print2("An age-worn sandstone wall.");
      73         [ #  # ]:          0 :           else if (Level->site[x][y].aux < 50)
      74                 :          0 :             print2("A smooth basalt wall.");
      75         [ #  # ]:          0 :           else if (Level->site[x][y].aux < 70)
      76                 :          0 :             print2("A solid granite wall.");
      77         [ #  # ]:          0 :           else if (Level->site[x][y].aux < 90)
      78                 :          0 :             print2("A wall of steel.");
      79         [ #  # ]:          0 :           else if (Level->site[x][y].aux < 210) {
      80         [ #  # ]:          0 :             if (Current_Environment == E_CITY)
      81                 :          0 :               print2("A thick wall of Rampart bluestone");
      82                 :          0 :             else print2("A magically reinforced wall.");
      83                 :            :           }
      84                 :          0 :           else print2("An almost totally impervious wall.");
      85                 :          0 :           break;
      86                 :          1 :         case RUBBLE:print2("A dangerous-looking pile of rubble."); break;
      87                 :          0 :         case SAFE:print2("A steel safe inset into the floor."); break;
      88                 :          0 :         case CLOSED_DOOR:print2("A solid oaken door, now closed."); break;
      89                 :          0 :         case OPEN_DOOR:print2("A solid oaken door, now open."); break;
      90                 :          0 :         case STATUE:print2("A strange-looking statue."); break;
      91                 :          0 :         case STAIRS_UP:print2("A stairway leading up."); break;
      92                 :          0 :         case STAIRS_DOWN:print2("A stairway leading down...."); break;
      93                 :          0 :         case TRAP:print2(trapid(Level->site[x][y].p_locf)); break;
      94                 :            :         case HEDGE:
      95         [ -  + ]:          1 :           if (Level->site[x][y].p_locf == L_EARTH_STATION)
      96                 :          0 :             print2("A weird fibrillation of oozing tendrils.");
      97                 :          1 :           else print2("A brambly, thorny hedge."); 
      98                 :          1 :           break;
      99                 :          0 :         case LAVA:print2("A bubbling pool of lava."); break;
     100                 :          0 :         case LIFT:print2("A strange glowing disk."); break;
     101                 :          0 :         case ALTAR:print2("An (un?)holy altar."); break;
     102                 :          0 :         case CHAIR:print2("A chair."); break;
     103                 :          0 :         case WHIRLWIND:print2("A strange cyclonic electrical storm."); break;
     104                 :            :         case WATER: 
     105         [ #  # ]:          0 :           if (Level->site[x][y].p_locf == L_WATER)
     106                 :          0 :             print2("A deep pool of water.");
     107         [ #  # ]:          0 :           else if (Level->site[x][y].p_locf == L_CHAOS)
     108                 :          0 :             print2("A pool of primal chaos.");
     109         [ #  # ]:          0 :           else if (Level->site[x][y].p_locf == L_WATER_STATION)
     110                 :          0 :             print2("A bubbling pool of acid.");
     111                 :          0 :           else print2("An eerie pool of water.");
     112                 :          0 :           break;
     113                 :          0 :         case FIRE:print2("A curtain of fire."); break;
     114                 :          0 :         default:print2("Wow, I haven't the faintest idea!"); break;
     115                 :            :         }
     116 [ -  + ][ #  # ]:          4 :       if ((ol = Level->site[x][y].things) != NULL && !loc_statusp(x,y,SECRET)) {
     117         [ #  # ]:          0 :         if (ol->next == NULL)
     118                 :          0 :           print3(itemid(ol->thing));
     119                 :            :         else {
     120                 :          0 :           drewmenu = TRUE;
     121                 :          0 :           menuclear();
     122                 :          0 :           menuprint("Things on floor:\n");
     123         [ #  # ]:          0 :           while (ol != NULL) {
     124                 :          0 :             menuprint("\n");
     125                 :          0 :             menuprint(itemid(ol->thing));
     126                 :          0 :             ol = ol->next;
     127                 :            :           }
     128                 :          0 :           showmenu();
     129                 :            :         }
     130                 :            :       }
     131                 :          4 :       morewait();
     132                 :          4 :       sign_print(x,y,TRUE);
     133                 :            :     }
     134                 :            :   }
     135         [ -  + ]:          4 :   if (drewmenu) xredraw();
     136                 :            : }
     137                 :            : 
     138                 :          4 : void help(void)
     139                 :            : {
     140                 :            :   char c;
     141                 :            :   char filestr[80];
     142                 :            :   FILE *in, *out;
     143                 :            :   int n;
     144                 :            : 
     145                 :          4 :   clearmsg();
     146                 :          4 :   print1("Please enter the letter indicating what topic you want help on.");
     147                 :          4 :   menuclear();
     148                 :          4 :   menuprint("a: Overview\n");
     149                 :          4 :   menuprint("b: Characters\n");
     150                 :          4 :   menuprint("c: Inventories\n");
     151                 :          4 :   menuprint("d: Movement\n");
     152                 :          4 :   menuprint("e: Combat\n");
     153                 :          4 :   menuprint("f: Bugs\n");
     154                 :          4 :   menuprint("g: Magic\n");
     155                 :          4 :   menuprint("h: The Countryside\n");
     156                 :          4 :   menuprint("i: The Screen Display\n");
     157                 :          4 :   menuprint("j: Saving and Restoring\n");
     158                 :          4 :   menuprint("k: Options Settings\n");
     159                 :          4 :   menuprint("l: Dungeon/City/Other Command List\n");
     160                 :          4 :   menuprint("m: Countryside Command List\n");
     161                 :            : #if !defined(MSDOS) && !defined(AMIGA)
     162                 :          4 :   menuprint("n: Everything\n");
     163                 :            : #endif
     164                 :          4 :   menuprint("ESCAPE: Forget the whole thing.");
     165                 :          4 :   showmenu();
     166                 :            :   do 
     167                 :          4 :     c = (char) mcigetc();
     168                 :            : #if defined(MSDOS) || defined(AMIGA)
     169                 :            :   while ((c < 'a' || c > 'm') && c != ESCAPE);
     170                 :            :   if (c != ESCAPE) {
     171                 :            :     sprintf(filestr, "%shelp%d.txt", Omegalib, c+1-'a');
     172                 :            :     displayfile(filestr);
     173                 :            :   }
     174                 :            : #else
     175 [ +  + ][ -  + ]:          4 :   while ((c < 'a' || c > 'n') && c != ESCAPE);
                 [ -  + ]
     176         [ -  + ]:          4 :   if (c == 'n') {
     177         [ #  # ]:          0 :     if (cinema_confirm("I'm about to copy all help files into 'omega.doc'.")=='y') {
     178                 :          0 :       change_to_user_perms();
     179                 :          0 :       out = checkfopen("omega.doc", "w");
     180                 :          0 :       print2("Copying");
     181         [ #  # ]:          0 :       for (n = 1; n <= 13; n++)
     182                 :            :       {
     183                 :          0 :         nprint2(".");
     184                 :          0 :         sprintf(Str1, "%shelp%d.txt", Omegalib, n);
     185                 :          0 :         in = checkfopen(Str1, "r");
     186         [ #  # ]:          0 :         while (fgets(Str1, STRING_LEN, in))
     187                 :          0 :           fputs(Str1, out);
     188                 :          0 :         fclose(in);
     189                 :            :       }
     190                 :          0 :       fclose(out);
     191                 :          0 :       change_to_game_perms();
     192                 :          0 :       nprint2(" Done.");
     193                 :            :     }
     194                 :            :   }
     195         [ +  + ]:          4 :   else if (c != ESCAPE) {
     196                 :          3 :     sprintf(filestr, "%shelp%d.txt", Omegalib, c+1-'a');
     197                 :          3 :     print1("Display help file, or Copy help file to file in wd. [dc] ");
     198                 :            :     do 
     199                 :          3 :       c = (char) mcigetc();
     200 [ -  + ][ #  # ]:          3 :     while ((c != 'd') && (c != 'c')&& (c!=ESCAPE));
                 [ #  # ]
     201         [ +  - ]:          3 :     if (c == 'd')
     202                 :          3 :       displayfile(filestr);
     203         [ #  # ]:          0 :     else if (c == 'c') copyfile(filestr);
     204                 :            :   }
     205                 :            : #endif
     206                 :          4 :   xredraw();
     207                 :          4 : }
     208                 :            : 
     209                 :          0 : void version(void)
     210                 :            : {
     211                 :          0 :   setgamestatus(SKIP_MONSTERS);
     212                 :          0 :   print3(VERSIONSTRING);
     213                 :          0 :   nprint3(":");
     214                 :          0 :   nprint3(" build date: ");
     215                 :          0 :   nprint3(__DATE__" "__TIME__);
     216                 :          0 : }
     217                 :            : 
     218                 :          0 : void fire(void)
     219                 :            : {
     220                 :            :   int index,x1,y1,x2,y2;
     221                 :            :   pob obj;
     222                 :            :   struct monster *m;
     223                 :            : 
     224                 :          0 :   clearmsg();
     225                 :            : 
     226                 :          0 :   print1("Fire/Throw --");
     227                 :          0 :   index = getitem(NULL_ITEM);
     228         [ #  # ]:          0 :   if (index == ABORT)
     229                 :          0 :     setgamestatus(SKIP_MONSTERS);
     230         [ #  # ]:          0 :   else if (index == CASHVALUE) print3("Can't fire money at something!");
     231 [ #  # ][ #  # ]:          0 :   else if (cursed(Player.possessions[index]) && 
     232                 :          0 :            Player.possessions[index]->used)
     233                 :          0 :     print3("You can't seem to get rid of it!");
     234                 :            :   /* load a crossbow */
     235 [ #  # ][ #  # ]:          0 :   else if ((Player.possessions[O_WEAPON_HAND] != NULL) &&  
     236         [ #  # ]:          0 :            (Player.possessions[O_WEAPON_HAND]->id == OB_CROSSBOW) && 
     237         [ #  # ]:          0 :            (Player.possessions[O_WEAPON_HAND]->aux != LOADED) &&
     238                 :          0 :            (Player.possessions[index]->id == OB_BOLT)) {
     239                 :            :              /* WDT: how much time? */
     240                 :          0 :              mprint("You crank back the crossbow and load a bolt.");
     241                 :          0 :              Player.possessions[O_WEAPON_HAND]->aux = LOADED;
     242                 :            :            }
     243                 :            :   else {
     244         [ #  # ]:          0 :     if (Player.possessions[index]->used) {
     245                 :          0 :       Player.possessions[index]->used = FALSE;
     246                 :          0 :       item_use(Player.possessions[index]);
     247                 :            :     }
     248                 :          0 :     obj = Player.possessions[index];
     249                 :          0 :     x1 = x2 = Player.x;
     250                 :          0 :     y1 = y2 = Player.y;
     251                 :          0 :     setspot(&x2,&y2);
     252 [ #  # ][ #  # ]:          0 :     if ((x2 == Player.x) && (y2 == Player.y)) 
     253                 :          0 :       mprint("You practice juggling for a moment or two.");
     254                 :            :     else {
     255                 :          0 :       do_object_los(obj->objchar,&x1,&y1,x2,y2);
     256         [ #  # ]:          0 :       if ((m=Level->site[x1][y1].creature) != NULL) {
     257         [ #  # ]:          0 :         if (obj->dmg == 0) {
     258         [ #  # ]:          0 :           if (m->treasure > 0) { /* the monster can have treasure/objects */
     259                 :          0 :             mprint("Your gift is caught!");
     260                 :          0 :             givemonster(m,split_item(1,obj));
     261                 :          0 :             conform_lost_objects(1,obj);
     262                 :            :           }
     263                 :            :           else {
     264                 :          0 :             mprint("Your thrown offering is ignored.");
     265                 :          0 :             setgamestatus(SUPPRESS_PRINTING);
     266                 :          0 :             p_drop_at(x1,y1,1,obj);
     267                 :          0 :             resetgamestatus(SUPPRESS_PRINTING);
     268                 :          0 :             conform_lost_objects(1,obj);
     269                 :            :           }
     270                 :            :         }
     271         [ #  # ]:          0 :         else if (obj->aux == I_SCYTHE) {
     272                 :          0 :           mprint("It isn't very aerodynamic... you miss.");
     273                 :          0 :           setgamestatus(SUPPRESS_PRINTING);
     274                 :          0 :           p_drop_at(x1,y1,1,obj);
     275                 :          0 :           resetgamestatus(SUPPRESS_PRINTING);
     276                 :          0 :           conform_lost_objects(1,obj);
     277                 :            :         }
     278         [ #  # ]:          0 :         else if (hitp(Player.hit,m->ac)) {/* ok already, hit the damn thing */
     279                 :          0 :           weapon_use(2*statmod(Player.str),obj,m);
     280         [ #  # ]:          0 :           if ((obj->id == OB_ARROW || obj->id == OB_BOLT) &&
           [ #  #  #  # ]
     281                 :          0 :             !random_range(4))
     282                 :          0 :             dispose_lost_objects(1,obj);
     283                 :            :           else {
     284                 :          0 :             setgamestatus(SUPPRESS_PRINTING);
     285                 :          0 :             p_drop_at(x1,y1,1,obj);
     286                 :          0 :             resetgamestatus(SUPPRESS_PRINTING);
     287                 :          0 :             conform_lost_objects(1,obj);
     288                 :            :           }
     289                 :            :         }
     290                 :            :         else {
     291                 :          0 :           mprint("You miss it.");
     292                 :          0 :           setgamestatus(SUPPRESS_PRINTING);
     293                 :          0 :           p_drop_at(x1,y1,1,obj);
     294                 :          0 :           resetgamestatus(SUPPRESS_PRINTING);
     295                 :          0 :           conform_lost_objects(1,obj);
     296                 :            :         }
     297                 :            :       }
     298                 :            :       else {
     299                 :          0 :         setgamestatus(SUPPRESS_PRINTING);
     300                 :          0 :         p_drop_at(x1,y1,1,obj);
     301                 :          0 :         resetgamestatus(SUPPRESS_PRINTING);
     302                 :          0 :         conform_lost_objects(1,obj);
     303                 :          0 :         plotspot(x1,y1,TRUE);
     304                 :            :       }
     305                 :            :     }
     306                 :            :   }
     307                 :          0 : }
     308                 :            : 
     309                 :            : 
     310                 :            : /* WDT: This function is used in interrupt handling, so it has the potential
     311                 :            :  * to mess up the display.  Perhaps I should have a Curses window just for it,
     312                 :            :  * so that I could clean up nicely if the user answers 'no' to its question.
     313                 :            :  */
     314                 :          0 : void quit(void)
     315                 :            : {
     316                 :          0 :   clearmsg();
     317                 :          0 :   change_to_game_perms();
     318                 :          0 :   mprint("Quit: Are you sure? [yn] ");
     319         [ #  # ]:          0 :   if (ynq()=='y') {
     320         [ #  # ]:          0 :     if (Player.rank[ADEPT] == 0) display_quit();
     321                 :          0 :     else display_bigwin();
     322                 :            : #ifdef SAVE_LEVELS
     323                 :            :     kill_all_levels();
     324                 :            : #endif
     325                 :          0 :     endgraf();
     326                 :          0 :     printf("Bye!\n");
     327                 :          0 :     exit(0);
     328                 :            :   }
     329                 :          0 :   else resetgamestatus(SKIP_MONSTERS);
     330                 :          0 : }
     331                 :            : 
     332                 :            : 
     333                 :            : 
     334                 :            : /* rest in 10 second segments so if woken up by monster won't
     335                 :            : die automatically.... */
     336                 :          2 : void nap(void)
     337                 :            : {
     338                 :            :   static int naptime;
     339         [ -  + ]:          2 :   if (gamestatusp(FAST_MOVE)) {
     340         [ #  # ]:          0 :     if (naptime-- < 1) {
     341                 :          0 :       clearmsg();
     342                 :          0 :       mprint("Yawn. You wake up.");
     343                 :          0 :       resetgamestatus(FAST_MOVE);
     344                 :          0 :       drawvision(Player.x,Player.y);
     345                 :            :     }
     346                 :            :   }
     347                 :            :   else {
     348                 :          2 :     clearmsg();
     349                 :          2 :     naptime = (int) parsenum("Rest for how long? (in minutes) ");
     350         [ -  + ]:          2 :     if (naptime > 600) {
     351                 :          0 :       print3("You can only sleep up to 10 hours (600 minutes)");
     352                 :          0 :       naptime = 3600;
     353                 :            :     }
     354                 :          2 :     else naptime *= 6;
     355         [ -  + ]:          2 :     if (naptime > 1) {
     356                 :          0 :       clearmsg();
     357                 :          0 :       setgamestatus(FAST_MOVE);
     358                 :          0 :       mprint("Resting.... ");
     359                 :            :     }
     360                 :            :   }
     361                 :          2 : }
     362                 :            : 
     363                 :            : 
     364                 :          0 : void charid(void)
     365                 :            : {
     366                 :            :   char id;
     367                 :          0 :   int countryside=FALSE;
     368                 :            :   char cstr[80];
     369                 :            : 
     370                 :          0 :   clearmsg();
     371                 :          0 :   mprint("Character to identify: ");
     372                 :          0 :   id = mgetc();
     373         [ #  # ]:          0 :   if (Current_Environment == E_COUNTRYSIDE) {
     374                 :          0 :     countryside = TRUE;
     375                 :          0 :     strcpy(cstr,countryid(id));
     376         [ #  # ]:          0 :     if (strcmp(cstr,"I have no idea.")==0)
     377                 :          0 :       countryside = FALSE;
     378                 :          0 :     else mprint(cstr);
     379                 :            :   }
     380         [ #  # ]:          0 :   if (! countryside) {
     381 [ #  # ][ #  # ]:          0 :     if ((id >= 'a' && id <= 'z') || (id >= 'A' && id <= 'Z') || id == '@')
         [ #  # ][ #  # ]
                 [ #  # ]
     382                 :          0 :       mprint("A monster or NPC -- examine (x) to find out exactly.");
     383   [ #  #  #  #  :          0 :     else switch(id) {
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
     384                 :            :     case (SPACE&0xff):
     385                 :          0 :       mprint(" : An airless void (if seen) or unknown region (if unseen)");
     386                 :          0 :       break;
     387                 :            :     case (WALL&0xff):
     388                 :          0 :       mprint(" : An (impenetrable?) wall");
     389                 :          0 :       break;
     390                 :            :     case (OPEN_DOOR&0xff):
     391                 :          0 :       mprint(" : An open door");
     392                 :          0 :       break;
     393                 :            :     case (CLOSED_DOOR&0xff):
     394                 :          0 :       mprint(" : A closed (possibly locked) door");
     395                 :          0 :       break;
     396                 :            :     case (LAVA&0xff):
     397                 :          0 :       mprint(" : A pool of lava");
     398                 :          0 :       break;
     399                 :            :     case (HEDGE&0xff):
     400                 :          0 :       mprint(" : A dense hedge");
     401                 :          0 :       break;
     402                 :            :     case (WATER&0xff):
     403                 :          0 :       mprint(" : A deep body of water");
     404                 :          0 :       break;
     405                 :            :     case (FIRE&0xff):
     406                 :          0 :       mprint(" : A curtain of fire");
     407                 :          0 :       break;
     408                 :            :     case (TRAP&0xff):
     409                 :          0 :       mprint(" : An uncovered trap");
     410                 :          0 :       break;
     411                 :            :     case (STAIRS_UP&0xff):
     412                 :          0 :       mprint(" : A stairway leading up");
     413                 :          0 :       break;
     414                 :            :     case (STAIRS_DOWN&0xff):
     415                 :          0 :       mprint(" : A stairway leading down");
     416                 :          0 :       break;
     417                 :            :     case (FLOOR&0xff):
     418                 :          0 :       mprint(" : The dungeon floor");
     419                 :          0 :       break;
     420                 :            :     case (PORTCULLIS&0xff):
     421                 :          0 :       mprint(" : A heavy steel portcullis");
     422                 :          0 :       break;
     423                 :            :     case (ABYSS&0xff):
     424                 :          0 :       mprint(" : An entrance to the infinite abyss");
     425                 :          0 :       break;
     426                 :            :     case (PLAYER&0xff):
     427                 :          0 :       mprint(" : You, the player");
     428                 :          0 :       break;
     429                 :            :     case (CORPSE&0xff):
     430                 :          0 :       mprint(" : The remains of some creature");
     431                 :          0 :       break;
     432                 :            :     case (THING&0xff):
     433                 :          0 :       mprint(" : Some random miscellaneous object");
     434                 :          0 :       break;
     435                 :            :     case (SAFE&0xff):
     436                 :          0 :       mprint(" : A steel safe inset into the floor"); 
     437                 :          0 :       break;
     438                 :            :     case (RUBBLE&0xff):
     439                 :          0 :       mprint(" : A dangerous-looking pile of rubble");
     440                 :          0 :       break;
     441                 :            :     case (STATUE&0xff):
     442                 :          0 :       mprint(" : A statue");
     443                 :          0 :       break;
     444                 :            :     case (ALTAR&0xff):
     445                 :          0 :       mprint(" : A (un?)holy altar");
     446                 :          0 :       break;
     447                 :            :     case (CASH&0xff):
     448                 :          0 :       mprint(" : Bills, specie, gems: cash");
     449                 :          0 :       break;
     450                 :            :     case (PILE&0xff):
     451                 :          0 :       mprint(" : A pile of objects");
     452                 :          0 :       break;
     453                 :            :     case (FOOD&0xff):
     454                 :          0 :       mprint(" : Something edible");
     455                 :          0 :       break;
     456                 :            :     case (WEAPON&0xff):
     457                 :          0 :       mprint(" : Some kind of weapon");
     458                 :          0 :       break;
     459                 :            :     case (MISSILEWEAPON&0xff):
     460                 :          0 :       mprint(" : Some kind of missile weapon");
     461                 :          0 :       break;
     462                 :            :     case (SCROLL&0xff):
     463                 :          0 :       mprint(" : Something readable");
     464                 :          0 :       break;
     465                 :            :     case (POTION&0xff):
     466                 :          0 :       mprint(" : Something drinkable");
     467                 :          0 :       break;
     468                 :            :     case (ARMOR&0xff):
     469                 :          0 :       mprint(" : A suit of armor");
     470                 :          0 :       break;
     471                 :            :     case (SHIELD&0xff):
     472                 :          0 :       mprint(" : A shield");
     473                 :          0 :       break;
     474                 :            :     case (CLOAK&0xff):
     475                 :          0 :       mprint(" : A cloak");
     476                 :          0 :       break;
     477                 :            :     case (BOOTS&0xff):
     478                 :          0 :       mprint(" : A pair of boots");
     479                 :          0 :       break;
     480                 :            :     case (STICK&0xff):
     481                 :          0 :       mprint(" : A stick");
     482                 :          0 :       break;
     483                 :            :     case (RING&0xff):
     484                 :          0 :       mprint(" : A ring");
     485                 :          0 :       break;
     486                 :            :     case (ARTIFACT&0xff):
     487                 :          0 :       mprint(" : An artifact");
     488                 :          0 :       break;
     489                 :            :     case (CHAIR&0xff):
     490                 :          0 :       mprint(" : A chair");
     491                 :          0 :       break;
     492                 :            :     case (WHIRLWIND&0xff):
     493                 :          0 :       mprint(" : A whirlwind");
     494                 :          0 :       break;
     495                 :            :     default:
     496                 :          0 :       mprint("That character is unused.");
     497                 :          0 :       break;
     498                 :            :     }
     499                 :            :   }
     500                 :          0 : }
     501                 :            : 
     502                 :            : 
     503                 :          0 : void wizard(void)
     504                 :            : {
     505                 :            :   char *lname;
     506                 :            : #ifndef MSDOS_SUPPORTED_ANTIQUE
     507                 :            :   struct passwd *dastuff;
     508                 :            : #endif
     509                 :            : 
     510                 :          0 :   setgamestatus(SKIP_MONSTERS);
     511         [ #  # ]:          0 :   if (gamestatusp(CHEATED)) mprint("You're already in wizard mode!");
     512                 :            :   else {
     513                 :          0 :     clearmsg();
     514         [ #  # ]:          0 :     if (cinema_confirm("You just asked to enter wizard mode.")=='y') {
     515                 :          0 :        lname = getlogin();
     516                 :            : #ifndef MSDOS_SUPPORTED_ANTIQUE
     517 [ #  # ][ #  # ]:          0 :        if (!lname || strlen(lname) == 0)
     518                 :            :        {
     519                 :          0 :             dastuff = getpwuid(getuid());
     520                 :          0 :             lname = dastuff->pw_name;
     521                 :            :        }
     522                 :            : #endif
     523         [ #  # ]:          0 :        if (strcmp(lname,WIZARD)==0) {
     524                 :          0 :          setgamestatus(CHEATED);
     525                 :          0 :          mprint("Wizard mode set.");
     526                 :            :       }
     527                 :            :       else {
     528                 :          0 :         mprint("There is a shrieking sound, as of reality being distorted.");
     529                 :          0 :         strcpy(Str1,WIZARD);
     530                 :          0 :         strcat(Str1,", the Wizard of Omega appears before you....");
     531 [ #  # ][ #  # ]:          0 :         if (Str1[0] >= 'a' && Str1[0] <= 'z')
     532                 :          0 :             Str1[0] += 'A'-'a'; /* capitalise 1st letter */
     533                 :          0 :         mprint(Str1);
     534                 :          0 :         mprint("'Do not meddle in the affairs of Wizards --");
     535         [ #  # ]:          0 :         if (random_range(2)) mprint("it makes them soggy and hard to light.'");
     536                 :          0 :         else mprint("for they are subtle, and swift to anger!'");
     537                 :            :       }
     538                 :            :     }
     539                 :            :   }
     540                 :          0 : }
     541                 :            : 
     542                 :            : /* Jump, that is */
     543                 :          0 : void vault(void)
     544                 :            : {
     545                 :          0 :   int x=Player.x,y=Player.y,jumper=0;
     546                 :            :   
     547                 :          0 :   clearmsg();
     548                 :            : 
     549         [ #  # ]:          0 :   if (Player.possessions[O_BOOTS] != NULL)
     550         [ #  # ]:          0 :     if (Player.possessions[O_BOOTS]->usef == I_BOOTS_JUMPING)
     551                 :          0 :       jumper = 2;
     552         [ #  # ]:          0 :   if (Player.status[IMMOBILE] > 0) {
     553                 :          0 :     resetgamestatus(FAST_MOVE);
     554                 :          0 :     print3("You are unable to move");
     555                 :            :   }
     556                 :            :   else {
     557                 :          0 :     setgamestatus(SKIP_MONSTERS);
     558                 :          0 :     mprint("Jump where?");
     559                 :          0 :     setspot(&x,&y);
     560         [ #  # ]:          0 :     if (! los_p(Player.x,Player.y,x,y))
     561                 :          0 :       print3("The way is obstructed.");
     562         [ #  # ]:          0 :     else if (Player.itemweight > Player.maxweight) 
     563                 :          0 :       print3("You are too burdened to jump anywhere.");
     564         [ #  # ]:          0 :     else if (distance(x,y,Player.x,Player.y) > 
     565         [ #  # ]:          0 :              max(2,statmod(Player.agi)+2)+jumper)
     566                 :          0 :       print3("The jump is too far for you.");
     567         [ #  # ]:          0 :     else if (Level->site[x][y].creature != NULL)
     568                 :          0 :       print3("You can't jump on another creature.");
     569         [ #  # ]:          0 :     else if (! p_moveable(x,y))
     570                 :          0 :       print3("You can't jump there.");
     571                 :            :     else {
     572                 :          0 :       resetgamestatus(SKIP_MONSTERS);
     573                 :          0 :       Player.x = x;
     574                 :          0 :       Player.y = y;
     575 [ #  # ][ #  # ]:          0 :       if ((! jumper) && (random_range(30) > Player.agi)) {
     576                 :          0 :         mprint("Oops -- took a tumble.");
     577                 :          0 :         setgamestatus(SKIP_PLAYER);
     578                 :          0 :         p_damage((Player.itemweight/250),UNSTOPPABLE,"clumsiness");
     579                 :            :       }
     580                 :          0 :       p_movefunction(Level->site[Player.x][Player.y].p_locf);
     581         [ #  # ]:          0 :       if (Current_Environment != E_COUNTRYSIDE) 
     582 [ #  # ][ #  # ]:          0 :         if ((Level->site[Player.x][Player.y].things != NULL) &&
     583                 :          0 :             (optionp(PICKUP)))
     584                 :          0 :           pickup();
     585                 :            :     }
     586                 :            :   }
     587                 :          0 : }
     588                 :            : 
     589                 :            : 
     590                 :            : /* Sets sequence of combat maneuvers. */
     591                 :          3 : void tacoptions(void)
     592                 :            : {
     593                 :            :   int actionsleft,done,place;
     594                 :            :   char defatt, *attstr, *defstr; /* for the default setting */
     595                 :          3 :   int draw_again = 1;
     596                 :            : 
     597                 :          3 :   setgamestatus(SKIP_MONSTERS);
     598                 :            : 
     599                 :          3 :   done = FALSE;
     600                 :          3 :   actionsleft = maneuvers();
     601                 :          3 :   place = 0;
     602                 :            :   do {
     603         [ +  + ]:         11 :     if (draw_again) {
     604                 :          3 :       menuclear();
     605                 :          3 :       menuprint("Enter a combat maneuvers sequence.\n");
     606                 :          3 :       menuprint("? for help, ! for default, backspace to start again,\n");
     607                 :          3 :       menuprint(" RETURN to save sequence\n");
     608                 :          3 :       showmenu();
     609                 :          3 :       draw_again = 0;
     610                 :            :     }
     611                 :         11 :     clearmsg();
     612                 :         11 :     mprint("Maneuvers Left:");
     613                 :         11 :     mnumprint(actionsleft);
     614   [ -  +  +  -  :         11 :     switch(mgetc()) {
             -  -  -  +  
                      + ]
     615                 :            :     case '?':
     616                 :          0 :       combat_help();
     617                 :          0 :       draw_again = 1;
     618                 :          0 :       break;
     619                 :            :     case 'a': case 'A':
     620         [ -  + ]:          3 :       if (actionsleft < 1) print3("No more maneuvers!");
     621                 :            :       else {
     622         [ -  + ]:          3 :         if (Player.possessions[O_WEAPON_HAND] == NULL) {
     623                 :          0 :           Player.meleestr[place] = 'C';
     624                 :          0 :           menuprint("\nPunch:");
     625                 :            :         }
     626         [ -  + ]:          3 :         else if (Player.possessions[O_WEAPON_HAND]->type == THRUSTING) {
     627                 :          0 :           Player.meleestr[place] = 'T';
     628                 :          0 :           menuprint("\nThrust:");
     629                 :            :         }
     630         [ -  + ]:          3 :         else if (Player.possessions[O_WEAPON_HAND]->type == STRIKING) {
     631                 :          0 :           Player.meleestr[place] = 'C';
     632                 :          0 :           menuprint("\nStrike:");
     633                 :            :         }
     634                 :            :         else {
     635                 :          3 :           menuprint("\nCut:");
     636                 :          3 :           Player.meleestr[place] = 'C';
     637                 :            :         }
     638                 :          3 :         place++;
     639                 :          3 :         Player.meleestr[place]=getlocation();
     640                 :          3 :         place++;
     641                 :          3 :         actionsleft--;
     642                 :            :       }
     643                 :          3 :       break;
     644                 :            :     case 'b': case 'B':
     645         [ -  + ]:          3 :       if (actionsleft<1) print3("No more maneuvers!");
     646                 :            :       else {
     647                 :          3 :         Player.meleestr[place] = 'B';
     648         [ -  + ]:          3 :         if (Player.possessions[O_WEAPON_HAND] == NULL)
     649                 :          0 :           menuprint("\nDodge (from):");
     650         [ -  + ]:          3 :         else if (Player.possessions[O_WEAPON_HAND]->type == THRUSTING) 
     651                 :          0 :           menuprint("\nParry:");
     652                 :          3 :         else menuprint("\nBlock:");
     653                 :          3 :         place++;
     654                 :          3 :         Player.meleestr[place]= getlocation();
     655                 :          3 :         place++;
     656                 :          3 :         actionsleft--;
     657                 :            :       }
     658                 :          3 :       break;
     659                 :            :     case 'l': case 'L':
     660         [ #  # ]:          0 :       if (actionsleft<2) print3("Not enough maneuvers to lunge!");
     661                 :            :       else {
     662         [ #  # ]:          0 :         if (Player.possessions[O_WEAPON_HAND] != NULL) {
     663         [ #  # ]:          0 :           if (Player.possessions[O_WEAPON_HAND]->type != MISSILE) {
     664                 :          0 :             menuprint("\nLunge:");
     665                 :          0 :             Player.meleestr[place] = 'L';
     666                 :          0 :             place++;
     667                 :          0 :             Player.meleestr[place]=getlocation();
     668                 :          0 :             place++;
     669                 :          0 :             actionsleft -= 2;
     670                 :            :           }
     671                 :            :           else {
     672                 :          0 :             print3("Can't lunge with a missile weapon!");
     673                 :          0 :             morewait();
     674                 :            :           }
     675                 :            :         }
     676                 :            :         else {
     677                 :          0 :           print3("Can't lunge without a weapon!");
     678                 :          0 :           morewait();
     679                 :            :         }
     680                 :            :       }
     681                 :          0 :       break;
     682                 :            :     case 'r': case 'R':
     683         [ #  # ]:          0 :       if (actionsleft<2) print3("Not enough maneuvers to riposte!");
     684                 :            :       else {
     685         [ #  # ]:          0 :         if (Player.possessions[O_WEAPON_HAND] != NULL) {
     686         [ #  # ]:          0 :           if (Player.possessions[O_WEAPON_HAND]->type == THRUSTING) {
     687                 :          0 :             Player.meleestr[place++] = 'R';
     688                 :          0 :             menuprint("\nRiposte:");
     689                 :          0 :             Player.meleestr[place++]=getlocation();
     690                 :          0 :             actionsleft -= 2;
     691                 :            :           }
     692                 :            :           else {
     693                 :          0 :             print3("Can't riposte without a thrusting weapon!");
     694                 :          0 :             morewait();
     695                 :            :           }
     696                 :            :         }
     697                 :            :         else {
     698                 :          0 :           print3("Can't riposte without a thrusting weapon!");
     699                 :          0 :           morewait();
     700                 :            :         }
     701                 :            :       }
     702                 :          0 :       break;
     703                 :            :     case BACKSPACE:
     704                 :            :     case DELETE:
     705                 :          0 :       place = 0;
     706                 :          0 :       actionsleft=maneuvers();
     707                 :          0 :       draw_again = 1;
     708                 :          0 :       break;
     709                 :            :     case '!':
     710         [ #  # ]:          0 :       if (Player.possessions[O_WEAPON_HAND] == NULL) {
     711                 :          0 :         defatt = 'C';
     712                 :          0 :         attstr = "Punch";
     713                 :            :       }
     714         [ #  # ]:          0 :       else if (Player.possessions[O_WEAPON_HAND]->type == THRUSTING) {
     715                 :          0 :         defatt = 'T';
     716                 :          0 :         attstr = "Thrust";
     717                 :            :       }
     718         [ #  # ]:          0 :       else if (Player.possessions[O_WEAPON_HAND]->type == STRIKING) {
     719                 :          0 :         defatt = 'C';
     720                 :          0 :         attstr = "Strike";
     721                 :            :       }
     722                 :            :       else {
     723                 :          0 :         defatt = 'C';
     724                 :          0 :         attstr = "Cut";
     725                 :            :       }
     726         [ #  # ]:          0 :       if (Player.possessions[O_WEAPON_HAND] == NULL)
     727                 :          0 :         defstr = "Dodge";
     728         [ #  # ]:          0 :       else if (Player.possessions[O_WEAPON_HAND]->type == THRUSTING) 
     729                 :          0 :         defstr = "Parry";
     730                 :          0 :       else defstr = "Block";
     731                 :          0 :       menuclear();
     732                 :          0 :       menuprint("Enter a combat maneuvers sequence.\n");
     733                 :          0 :       menuprint("? for help, ! for default, backspace to start again,\n");
     734                 :          0 :       menuprint(" RETURN to save sequence\n\n");
     735         [ #  # ]:          0 :       for(place=0;place<maneuvers();place++)
     736         [ #  # ]:          0 :         if (place&1) { /* every 2nd time around */
     737                 :          0 :             Player.meleestr[place*2] = 'B';
     738                 :          0 :             Player.meleestr[(place*2)+1] = 'C';
     739                 :          0 :             menuprint(defstr);
     740                 :          0 :             menuprint(" Center.\n");
     741                 :            :         }
     742                 :            :         else {
     743                 :          0 :             Player.meleestr[place*2] = defatt;
     744                 :          0 :             Player.meleestr[(place*2)+1] = 'C';
     745                 :          0 :             menuprint(attstr);
     746                 :          0 :             menuprint(" Center.\n");
     747                 :            :         }
     748                 :          0 :       actionsleft = 0;
     749                 :          0 :       showmenu();
     750                 :          0 :       Player.meleestr[place*2]='\0';
     751                 :          0 :       break;
     752                 :            :     case RETURN:
     753                 :            :     case LINEFEED:
     754                 :            :     case ESCAPE:
     755                 :          3 :       done = TRUE;
     756                 :          3 :       break;
     757                 :            :     }
     758                 :            : /*    if (actionsleft < 1) morewait(); */ /* FIXED 12/30/98 */
     759         [ +  + ]:         11 :   } while (! done);
     760                 :          3 :   xredraw();
     761                 :          3 :   Player.meleestr[place] = 0;
     762                 :          3 : }
     763                 :            : 
     764                 :            : 
     765                 :            : 
     766                 :            : 
     767                 :            : /* Do the Artful Dodger trick */
     768                 :          0 : void pickpocket(void)
     769                 :            : {
     770                 :          0 :   int dx,dy,index=0;
     771                 :            :   struct monster *m;
     772                 :            : 
     773                 :          0 :   clearmsg();
     774                 :            : 
     775                 :          0 :   mprint("Pickpocketing --");
     776                 :            : 
     777                 :          0 :   index = getdir();
     778                 :            : 
     779         [ #  # ]:          0 :   if (index == ABORT)
     780                 :          0 :     setgamestatus(SKIP_MONSTERS);
     781                 :            :   else {
     782                 :          0 :     dx = Dirs[0][index];
     783                 :          0 :     dy = Dirs[1][index];
     784                 :            :     
     785 [ #  # ][ #  # ]:          0 :     if ((! inbounds(Player.x+dx, Player.y+dy)) ||
     786                 :          0 :         (Level->site[Player.x+dx][Player.y+dy].creature == NULL)) {
     787                 :          0 :       print3("There's nothing there to steal from!!!");
     788                 :          0 :       setgamestatus(SKIP_MONSTERS);
     789                 :            :     }
     790                 :            :     else {
     791                 :          0 :       m = Level->site[Player.x+dx][Player.y+dy].creature;
     792         [ #  # ]:          0 :       if (m->id == GUARD) {
     793                 :          0 :         mprint("Trying to steal from a guardsman, eh?");
     794                 :          0 :         mprint("Not a clever idea.");
     795         [ #  # ]:          0 :         if (Player.cash > 0) {
     796                 :          0 :           mprint("As a punitive fine, the guard takes all your money.");
     797                 :            :           {
     798                 :          0 :             pob o = detach_money(Player.cash);
     799                 :          0 :             m_pickup(m,o);
     800                 :            :           }
     801                 :          0 :           dataprint();
     802                 :            :         }
     803                 :            :         else {
     804                 :          0 :           mprint("The guardsman places you under arrest.");
     805                 :          0 :           morewait();
     806                 :          0 :           send_to_jail();
     807                 :            :         }
     808                 :            :       }
     809         [ #  # ]:          0 :       else if (m->possessions == NULL) {
     810                 :          0 :         mprint("You couldn't find anything worth taking!");
     811                 :          0 :         mprint("But you managed to annoy it...");
     812                 :          0 :         m_status_set(m,HOSTILE);
     813                 :            :       }
     814                 :            :       else 
     815                 :            :       {
     816                 :            :         /* DAG -- code and idea contributed by Ross Presser <ross_presser@imtek.com> */
     817                 :            :         int i,j,k;
     818                 :          0 :         i = Player.dex*5+Player.rank[THIEVES]*20+random_range(100);
     819                 :          0 :         j = random_range(100)+m->level*20;
     820                 :          0 :         k = random_range(j);
     821         [ #  # ]:          0 :         if (i>j) {       
     822                 :          0 :           mprint("You successfully complete your crime!");
     823                 :          0 :           mprint("You stole:");
     824                 :          0 :           mprint(itemid(m->possessions->thing));
     825                 :          0 :           Player.alignment--;
     826                 :          0 :           gain_experience(m->level*m->level);
     827                 :          0 :           gain_item(m->possessions->thing);
     828                 :          0 :           m->possessions = m->possessions->next;
     829                 :            :         } 
     830         [ #  # ]:          0 :         else if (i<k) {
     831                 :          0 :           mprint("No luck ... yet.");
     832                 :            :         }
     833                 :            :         else {
     834                 :          0 :           mprint("You were unsucessful at your crime.");
     835                 :          0 :           mprint("Even worse, you managed to annoy it...");
     836                 :          0 :           m_status_set(m,HOSTILE);
     837                 :            :         }
     838                 :            :       }
     839                 :            :     }
     840                 :            :   }
     841                 :          0 : }
     842                 :            : 
     843                 :            : 
     844                 :          0 : void rename_player(void)
     845                 :            : {
     846                 :          0 :   setgamestatus(SKIP_MONSTERS);
     847                 :          0 :   clearmsg();
     848                 :          0 :   mprint("Rename Character: ");
     849                 :          0 :   strcpy(Str1,msgscanstring());
     850         [ #  # ]:          0 :   if (strlen(Str1) == 0)
     851                 :          0 :     mprint(Player.name);
     852                 :            :   else {
     853 [ #  # ][ #  # ]:          0 :     if (Str1[0] >= 'a' && Str1[0] <= 'z')
     854                 :          0 :       Str1[0] += 'A' - 'a';
     855                 :          0 :     strcpy(Player.name, Str1);
     856                 :            :   }
     857                 :          0 :   sprintf(Str1, "Henceforth, you shall be known as %s", Player.name);
     858                 :          0 :   print2(Str1);
     859                 :          0 : }
     860                 :            : 
     861                 :            : 
     862                 :          0 : void abortshadowform(void)
     863                 :            : {
     864                 :          0 :   setgamestatus(SKIP_MONSTERS);
     865 [ #  # ][ #  # ]:          0 :   if (Player.status[SHADOWFORM] && (Player.status[SHADOWFORM]<1000)) {
     866                 :          0 :     mprint("You abort your spell of Shadow Form.");
     867                 :          0 :     Player.immunity[NORMAL_DAMAGE]--;
     868                 :          0 :     Player.immunity[ACID]--;
     869                 :          0 :     Player.immunity[THEFT]--;
     870                 :          0 :     Player.immunity[INFECTION]--;
     871                 :          0 :     mprint("You feel less shadowy now.");
     872                 :          0 :     Player.status[SHADOWFORM] = 0;
     873                 :            :   }
     874                 :          0 : }
     875                 :            : 
     876                 :          0 : void tunnel(void)
     877                 :            : {
     878                 :            :   int dir,ox,oy,aux;
     879                 :            : 
     880                 :          0 :   clearmsg();
     881                 :          0 :   mprint("Tunnel -- ");
     882                 :          0 :   dir = getdir();
     883         [ #  # ]:          0 :   if (dir == ABORT)
     884                 :          0 :     setgamestatus(SKIP_MONSTERS);
     885                 :            :   else {
     886                 :          0 :     ox = Player.x + Dirs[0][dir];
     887                 :          0 :     oy = Player.y + Dirs[1][dir];
     888         [ #  # ]:          0 :     if (loc_statusp(ox,oy,SECRET))
     889                 :          0 :       mprint("You have no success as yet.");
     890         [ #  # ]:          0 :     else if (Level->site[ox][oy].locchar != WALL) {
     891                 :          0 :       print3("You can't tunnel through that!");
     892                 :          0 :       setgamestatus(SKIP_MONSTERS);
     893                 :            :     }
     894                 :            :     else {
     895                 :          0 :       aux = Level->site[ox][oy].aux;
     896         [ #  # ]:          0 :       if (random_range(20)==1){
     897         [ #  # ]:          0 :         if (Player.possessions[O_WEAPON_HAND] == NULL) {
     898                 :          0 :           mprint("Ouch! broke a fingernail...");
     899                 :          0 :           p_damage(Player.str / 6,UNSTOPPABLE,"a broken fingernail");
     900                 :            :         }
     901 [ #  # ][ #  # ]:          0 :         else if ((Player.possessions[O_WEAPON_HAND]->type == THRUSTING) ||
     902         [ #  # ]:          0 :                  ((Player.possessions[O_WEAPON_HAND]->type != STRIKING) &&
     903                 :          0 :                   (Player.possessions[O_WEAPON_HAND]->fragility < 
     904                 :          0 :                    random_range(20)))) {
     905                 :          0 :           mprint("Clang! Uh oh...");
     906                 :          0 :           (void) damage_item(Player.possessions[O_WEAPON_HAND]);
     907                 :            :         }
     908                 :          0 :         else mprint("Your digging implement shows no sign of breaking.");
     909                 :            :       }
     910         [ #  # ]:          0 :       if (Player.possessions[O_WEAPON_HAND] == NULL) {
     911 [ #  # ][ #  # ]:          0 :         if ((aux > 0) && ((Player.str/3)+random_range(100) > aux)) {
     912                 :          0 :           mprint("You carve a tunnel through the stone!");
     913                 :          0 :           tunnelcheck();
     914                 :          0 :           Level->site[ox][oy].locchar = RUBBLE;
     915                 :          0 :           Level->site[ox][oy].p_locf = L_RUBBLE;
     916                 :          0 :           lset(ox, oy, CHANGED);
     917                 :            :         }
     918                 :          0 :         else mprint("No joy.");
     919                 :            :       }
     920         [ #  # ]:          0 :       else if (Player.possessions[O_WEAPON_HAND]->type == THRUSTING) {
     921   [ #  #  #  # ]:          0 :         if ((aux > 0) && 
     922                 :          0 :             (Player.possessions[O_WEAPON_HAND]->dmg*2+random_range(100) > 
     923                 :            :              aux)) {
     924                 :          0 :           mprint("You carve a tunnel through the stone!");
     925                 :          0 :           tunnelcheck();
     926                 :          0 :           Level->site[ox][oy].locchar = RUBBLE;
     927                 :          0 :           Level->site[ox][oy].p_locf = L_RUBBLE;
     928                 :          0 :           lset(ox, oy, CHANGED);
     929                 :            :         }
     930                 :          0 :         else mprint("No luck.");
     931                 :            :       }
     932   [ #  #  #  # ]:          0 :       else if ((aux > 0) && 
     933                 :          0 :                (Player.possessions[O_WEAPON_HAND]->dmg+random_range(100) 
     934                 :          0 :                 > aux)) {
     935                 :          0 :         mprint("You carve a tunnel through the stone!");
     936                 :          0 :         tunnelcheck();
     937                 :          0 :         Level->site[ox][oy].locchar = RUBBLE;
     938                 :          0 :         Level->site[ox][oy].p_locf = L_RUBBLE;
     939                 :          0 :         lset(ox, oy, CHANGED);
     940                 :            :       }
     941                 :          0 :       else mprint("You have no success as yet.");
     942                 :            :     }
     943                 :            :   }
     944                 :          0 : }
     945                 :            : 
     946                 :          0 : void hunt(Symbol terrain)
     947                 :            : {
     948                 :          0 :   int fertility=0;
     949   [ #  #  #  #  :          0 :   switch(terrain) {
          #  #  #  #  #  
             #  #  #  # ]
     950                 :            :   case SWAMP: 
     951                 :          0 :     mprint("You hesitate to hunt for food in the marshy wasteland.");
     952                 :          0 :     break;
     953                 :            :   case VOLCANO:
     954                 :            :   case CASTLE:
     955                 :            :   case TEMPLE:
     956                 :            :   case CAVES:
     957                 :            :   case STARPEAK:
     958                 :            :   case MAGIC_ISLE:
     959                 :            :   case DRAGONLAIR:
     960                 :          0 :     mprint("There is nothing alive here (or so it seems)");
     961                 :          0 :     break;
     962                 :            :   case VILLAGE:
     963                 :            :   case CITY:
     964                 :          0 :     mprint("You can find no food here; perhaps if you went inside....");
     965                 :          0 :     break;
     966                 :            :   case ROAD:
     967                 :          0 :     mprint("You feel it would be a better idea to hunt off the road.");
     968                 :          0 :     break;
     969                 :            :   case CHAOS_SEA:
     970                 :          0 :     mprint("Food in the Sea of Chaos? Go on!");
     971                 :          0 :     break;
     972                 :            :   case DESERT:
     973                 :          0 :     mprint("You wander off into the trackless desert in search of food...");
     974                 :          0 :     Time += 100;
     975                 :          0 :     hourly_check();  
     976                 :          0 :     fertility = 10;
     977                 :          0 :     break;
     978                 :            :   case PALACE:
     979                 :            :   case JUNGLE:
     980                 :          0 :     mprint("You search the lush and verdant jungle for game....");
     981                 :          0 :     Time += 100;
     982                 :          0 :     hourly_check();
     983                 :          0 :     fertility = 80;
     984                 :          0 :     break;
     985                 :            :   case PLAINS:
     986                 :          0 :     mprint("You set off through the tall grass; the game is afoot.");
     987                 :          0 :     Time += 100;
     988                 :          0 :     hourly_check();
     989                 :          0 :     fertility = 50;
     990                 :          0 :     break;
     991                 :            :   case TUNDRA:
     992                 :          0 :     mprint("You blaze a trail through the frozen wasteland....");
     993                 :          0 :     Time += 100;
     994                 :          0 :     hourly_check();
     995                 :          0 :     fertility = 30;
     996                 :          0 :     break;
     997                 :            :   case FOREST:
     998                 :          0 :     mprint("You try to follow the many tracks through the forest loam....");
     999                 :          0 :     Time += 100;
    1000                 :          0 :     hourly_check();
    1001                 :          0 :     fertility = 70;
    1002                 :          0 :     break;
    1003                 :            :   case MOUNTAINS: case PASS:
    1004                 :          0 :     mprint("You search the cliff walls looking for something to eat....");
    1005                 :          0 :     Time += 100;
    1006                 :          0 :     hourly_check();  
    1007                 :          0 :     fertility = 30;
    1008                 :          0 :     break;
    1009                 :            :   case RIVER:
    1010                 :          0 :     mprint("The halcyon river is your hopeful food source...");
    1011                 :          0 :     Time += 100;
    1012                 :          0 :     hourly_check();  
    1013                 :          0 :     fertility = 80;
    1014                 :          0 :     break;
    1015                 :            :   }
    1016 [ #  # ][ #  # ]:          0 :   if (((Date % 360 < 60) || (Date % 360 > 300)) && 
                 [ #  # ]
    1017         [ #  # ]:          0 :       (terrain != DESERT) &&
    1018                 :            :       (terrain != JUNGLE)) {
    1019                 :          0 :     mprint("The cold weather impedes your hunt....");
    1020                 :          0 :     fertility = fertility / 2;
    1021                 :            :   }
    1022         [ #  # ]:          0 :   if (fertility > random_range(100)) {
    1023                 :          0 :     mprint("You have an encounter...");
    1024                 :          0 :     change_environment(E_TACTICAL_MAP);
    1025                 :            :   }
    1026                 :          0 :   else mprint("Your hunt is fruitless.");
    1027                 :          0 : }
    1028                 :            : 
    1029                 :          1 : void dismount_steed(void)
    1030                 :            : {
    1031                 :            :   pml ml;
    1032         [ -  + ]:          1 :   if (! gamestatusp(MOUNTED))
    1033                 :          0 :     print3("You're on foot already!");
    1034         [ -  + ]:          1 :   else if (Current_Environment == E_COUNTRYSIDE) {
    1035         [ #  # ]:          0 :     if (cinema_confirm("If you leave your steed here he will wander away!")=='y')
    1036                 :          0 :       resetgamestatus(MOUNTED);
    1037                 :            :   }
    1038                 :            :   else {
    1039                 :          1 :     resetgamestatus(MOUNTED);;
    1040                 :          1 :     ml = ((pml) checkmalloc(sizeof(mltype)));
    1041                 :          1 :     ml->m = ((pmt) checkmalloc(sizeof(montype)));
    1042                 :          1 :     *(ml->m) = Monsters[HORSE];
    1043                 :          1 :     ml->m->x = Player.x;
    1044                 :          1 :     ml->m->y = Player.y;
    1045                 :          1 :     ml->m->status = MOBILE+SWIMMING;
    1046                 :          1 :     ml->next = Level->mlist;
    1047                 :          1 :     Level->site[Player.x][Player.y].creature = ml->m;
    1048                 :          1 :     Level->mlist = ml;
    1049                 :            :   }
    1050                 :          1 :   calc_melee();
    1051                 :          1 : }
    1052                 :            : 
    1053                 :            : 
    1054                 :          3 : void city_move(void)
    1055                 :            : {
    1056                 :          3 :   int site,x=Player.x,y=Player.y,toggle=FALSE;
    1057                 :          3 :   clearmsg();
    1058         [ -  + ]:          3 :   if (Current_Environment != E_CITY) {
    1059                 :          0 :     print3("This command only works in the city!");
    1060                 :          0 :     setgamestatus(SKIP_MONSTERS);
    1061                 :            :   }
    1062         [ -  + ]:          3 :   else if (Player.status[IMMOBILE] > 0) 
    1063                 :          0 :     print3("You can't even move!");
    1064         [ -  + ]:          3 :   else if (hostilemonstersnear()) {
    1065                 :          0 :     setgamestatus(SKIP_MONSTERS);
    1066                 :          0 :     print3("You can't move this way with hostile monsters around!");
    1067                 :            :   }
    1068         [ -  + ]:          3 :   else if (Level->site[Player.x][Player.y].aux == NOCITYMOVE)
    1069                 :          0 :     print3("You can't use the 'M' command from this location.");
    1070                 :            :   else {
    1071                 :          3 :     print1("Move to which establishment [? for help, ESCAPE to quit]");
    1072                 :          3 :     site = parsecitysite();
    1073         [ +  - ]:          3 :     if (site != ABORT) {
    1074                 :          3 :       mprint("You're on your way...");
    1075                 :          3 :       morewait();
    1076 [ +  + ][ +  + ]:         78 :       while ((x != CitySiteList[site][1]) || (y != CitySiteList[site][2])) {
    1077                 :         75 :         toggle = ! toggle;
    1078         [ +  + ]:         75 :         if (toggle) {
    1079                 :         38 :           Time++;
    1080         [ +  + ]:         38 :           if (Time % 10 == 0) tenminute_check();
    1081                 :         34 :           else minute_status_check();
    1082                 :            :         }
    1083         [ +  + ]:         75 :         x += sign(CitySiteList[site][1] - x);
    1084         [ +  + ]:         75 :         y += sign(CitySiteList[site][2] - y);
    1085                 :         75 :         screencheck(x,y);
    1086                 :         75 :         omshowcursor(x,y);
    1087                 :            :       }
    1088                 :          3 :       Player.x = x;
    1089                 :          3 :       Player.y = y;
    1090                 :          3 :       screencheck(Player.x,Player.y);
    1091                 :          3 :       mprint("Made it!");
    1092                 :          3 :       drawvision(Player.x, Player.y);
    1093                 :          3 :       morewait();
    1094                 :          3 :       p_movefunction(Level->site[x][y].p_locf);
    1095                 :            :     }
    1096                 :            :   }
    1097                 :          3 : }
    1098                 :            : 
    1099                 :          0 : void frobgamestatus(void)
    1100                 :            : {
    1101                 :            :   char response;
    1102                 :            :   long num;
    1103                 :          0 :   mprint("Set or Reset or Forget it [s,r,ESCAPE]:");
    1104                 :          0 :   do response = (char) mcigetc();
    1105 [ #  # ][ #  # ]:          0 :   while ((response != 'r') && (response != 's') && (response != ESCAPE));
                 [ #  # ]
    1106         [ #  # ]:          0 :   if (response != ESCAPE) {
    1107                 :          0 :     num = (int) parsenum("Enter log2 of flag:");
    1108         [ #  # ]:          0 :     if (num > -1) {
    1109                 :          0 :       num = pow2(num);
    1110         [ #  # ]:          0 :       if (num == CHEATED) {
    1111                 :          0 :         mprint("Can't alter Wizard flag.");
    1112                 :          0 :         return;
    1113                 :            :       }
    1114         [ #  # ]:          0 :       if (response == 's') setgamestatus(num);
    1115                 :          0 :       else resetgamestatus(num);
    1116                 :          0 :       mprint("Done....");
    1117                 :            :     }
    1118                 :            :   }
    1119                 :            : }

Generated by: LCOV version 1.11