LCOV - code coverage report
Current view: top level - omega-rpg-0.90-pa9 - aux3.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 148 892 16.6 %
Date: 2017-09-08 22:00:26 Functions: 10 17 58.8 %
Branches: 89 464 19.2 %

           Branch data     Line data    Source code
       1                 :            : /* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
       2                 :            : /* aux3.c */
       3                 :            : /* some functions called by com.c, also see aux1.c, aux2.c */ 
       4                 :            : /* This is a real grab bag file. It contains functions used by
       5                 :            :    aux1.c and omega.c, as well as elsewhere. It is mainly here so aux1.c
       6                 :            :    and aux2.c are not huge */
       7                 :            :   
       8                 :            : #include "glob.h"
       9                 :            : 
      10                 :            : /* check every ten minutes */
      11                 :         14 : void tenminute_check(void)
      12                 :            : {
      13         [ +  + ]:         14 :   if (Time % 60 == 0) hourly_check();
      14                 :            :   else {
      15         [ -  + ]:         12 :     if (Current_Environment == Current_Dungeon)  wandercheck();
      16                 :         12 :     minute_status_check();
      17                 :         12 :     tenminute_status_check();
      18 [ +  - ][ -  + ]:         12 :     if ((Player.status[DISEASED] < 1) && (Player.hp < Player.maxhp))
      19                 :          0 :       Player.hp = min(Player.maxhp,Player.hp+Player.level+1);
      20 [ +  - ][ +  - ]:         12 :     if (Current_Environment != E_COUNTRYSIDE && Current_Environment != E_ABYSS)
      21                 :         12 :       indoors_random_event();
      22                 :            :   }
      23                 :         14 : }
      24                 :            : 
      25                 :            : 
      26                 :            : 
      27                 :            : /* hourly check is same as ten_minutely check except food is also
      28                 :            :    checked, and since time moves in hours out of doors, also
      29                 :            :    outdoors_random_event is possible */
      30                 :            : 
      31                 :         31 : void hourly_check(void)
      32                 :            : {
      33                 :         31 :   Player.food--;
      34                 :         31 :   foodcheck();
      35         [ +  + ]:         31 :   if (hour()==0) { /* midnight, a new day */
      36                 :          1 :     moon_check();
      37                 :          1 :     Date++;
      38                 :            :   }
      39                 :         31 :   torch_check();
      40         [ -  + ]:         31 :   if (Current_Environment == Current_Dungeon)  wandercheck();
      41                 :         31 :   minute_status_check();
      42                 :         31 :   tenminute_status_check();
      43 [ +  - ][ +  + ]:         31 :   if ((Player.status[DISEASED] == 0) && (Player.hp < Player.maxhp))
      44                 :         14 :     Player.hp = min(Player.maxhp,Player.hp+Player.level+1);
      45 [ +  + ][ +  - ]:         31 :   if (Current_Environment != E_COUNTRYSIDE && Current_Environment != E_ABYSS)
      46                 :          2 :     indoors_random_event();
      47                 :         31 : }
      48                 :            : 
      49                 :            : 
      50                 :            : 
      51                 :            : 
      52                 :         14 : void indoors_random_event(void)
      53                 :            : {
      54                 :            :   pml ml;
      55                 :            :   pol ol;
      56                 :            : 
      57   [ -  -  -  -  :         14 :   switch(random_range(1000)) {
          -  -  -  -  -  
             -  -  -  + ]
      58                 :            :   case 0: 
      59                 :          0 :     print3("You feel an unexplainable elation.");
      60                 :          0 :     morewait();
      61                 :          0 :     break;
      62                 :            :   case 1:
      63                 :          0 :     print3("You hear a distant rumbling.");
      64                 :          0 :     morewait();
      65                 :          0 :     break;
      66                 :            :   case 2:
      67                 :          0 :     print3("You realize your fly is open.");
      68                 :          0 :     morewait();
      69                 :          0 :     break;
      70                 :            :   case 3:
      71                 :          0 :     print3("You have a sudden craving for a pecan twirl.");
      72                 :          0 :     morewait();
      73                 :          0 :     break;
      74                 :            :   case 4:
      75                 :          0 :     print3("A mysterious healing flux settles over the level.");
      76                 :          0 :     morewait();
      77         [ #  # ]:          0 :     for (ml=Level->mlist;ml!=NULL;ml=ml->next)
      78         [ #  # ]:          0 :       if (ml->m->hp > 0) ml->m->hp = Monsters[ml->m->id].hp;
      79                 :          0 :     Player.hp = max(Player.hp,Player.maxhp);
      80                 :          0 :     break;
      81                 :            :   case 5:
      82                 :          0 :     print3("You discover an itch just where you can't scratch it.");
      83                 :          0 :     morewait();
      84                 :          0 :     break;
      85                 :            :   case 6:
      86                 :          0 :     print3("A cosmic ray strikes!");
      87                 :          0 :     p_damage(10,UNSTOPPABLE,"a cosmic ray");
      88                 :          0 :     morewait();
      89                 :          0 :     break;
      90                 :            :   case 7:
      91                 :          0 :     print3("You catch your second wind....");
      92                 :          0 :     Player.maxhp++;
      93                 :          0 :     Player.hp = max(Player.hp, Player.maxhp);
      94         [ #  # ]:          0 :     Player.mana = max(Player.mana, calcmana());
      95                 :          0 :     morewait();
      96                 :          0 :     break;
      97                 :            :   case 8:
      98                 :          0 :     print3("You find some spare change in a hidden pocket.");
      99                 :          0 :     morewait();
     100                 :          0 :     Player.cash += Player.level*Player.level+1;
     101                 :          0 :     break;
     102                 :            :   case 9:
     103                 :          0 :     print3("You feel strangely lucky.");
     104                 :          0 :     morewait();
     105                 :          0 :     break;
     106                 :            :   case 10:
     107                 :          0 :     print3("You trip over something hidden in a shadow...");
     108                 :          0 :     morewait();
     109                 :          0 :     ol = ((pol) checkmalloc(sizeof(oltype)));
     110                 :          0 :     ol->thing = create_object(difficulty()); /* FIXED!  12/30/98 */
     111         [ #  # ]:          0 :     assert(ol->thing); /* WDT I want to make sure... */
     112                 :          0 :     ol->next = Level->site[Player.x][Player.y].things;
     113                 :          0 :     Level->site[Player.x][Player.y].things = ol;
     114                 :          0 :     pickup();
     115                 :          0 :     break;
     116                 :            :   case 11: 
     117                 :          0 :     print3("A mysterious voice echoes all around you....");
     118                 :          0 :     morewait();
     119                 :          0 :     hint();
     120                 :          0 :     morewait();
     121                 :          0 :     break;
     122                 :            : 
     123                 :            : #if 0
     124                 :            : #ifdef NEW_BANK
     125                 :            :   case 12:
     126                 :            :     {
     127                 :            :       int num_accounts;
     128                 :            :       bank_account *account;
     129                 :            : 
     130                 :            :       num_accounts = 0;
     131                 :            :       for(account = bank; account; account = account->next_account)
     132                 :            :         {
     133                 :            :           if (account->player && account->balance > 0)
     134                 :            :             {
     135                 :            :               ++num_accounts;
     136                 :            :               account->balance = 0;
     137                 :            :             }
     138                 :            :         }
     139                 :            : 
     140                 :            :       if (num_accounts)
     141                 :            :         print3( "You feel unlucky." );
     142                 :            :       else
     143                 :            :         print3( "You feel lucky." );
     144                 :            :     }
     145                 :            :     break;
     146                 :            : 
     147                 :            :   case 13:
     148                 :            :     {
     149                 :            :       int num_accounts;
     150                 :            :       bank_account *account;
     151                 :            : 
     152                 :            :       num_accounts = 0;
     153                 :            :       for(account = bank; account; account = account->next_account)
     154                 :            :         if (account->player && account->balance > 0) ++num_accounts;
     155                 :            :                         
     156                 :            :       if (num_accounts)
     157                 :            :         {
     158                 :            :           num_accounts = random_range(num_accounts);
     159                 :            :           for(account = bank; account; account = account->next_account)
     160                 :            :             {
     161                 :            :               if (account->player)
     162                 :            :                 {
     163                 :            :                   if (0 == num_accounts)
     164                 :            :                     {
     165                 :            :                       account->balance += random_range( 4000 ) + 1000;
     166                 :            :                       break;
     167                 :            :                     }
     168                 :            : 
     169                 :            :                   --num_accounts;
     170                 :            :                 }
     171                 :            :             }
     172                 :            : 
     173                 :            :           print3( "You feel lucky." );
     174                 :            :         }
     175                 :            :       else
     176                 :            :         {
     177                 :            :           print3( "You feel unlucky." );
     178                 :            :         }
     179                 :            :     }
     180                 :            :     break;
     181                 :            : #else /* !NEW_BANK */
     182                 :            :   case 12:
     183                 :            :     if (Balance > 0)
     184                 :            :       {
     185                 :            :         print3("You get word of the failure of your bank!");
     186                 :            :         Balance = 0;
     187                 :            :       }
     188                 :            :     else
     189                 :            :       {
     190                 :            :         print3("You feel lucky.");
     191                 :            :       }
     192                 :            :     break;
     193                 :            : 
     194                 :            :   case 13:
     195                 :            :     if (Balance > 0)
     196                 :            :       {
     197                 :            :         print3("You get word of a bank error in your favor!");
     198                 :            :         Balance += 5000;
     199                 :            :       }
     200                 :            :     else
     201                 :            :       {
     202                 :            :         print3("You feel unlucky.");
     203                 :            :       }
     204                 :            :     break;
     205                 :            : #endif /* !NEW_BANK */
     206                 :            : #endif /* 0 */
     207                 :            :   }
     208                 :         14 :   dataprint();
     209                 :         14 :   showflags();
     210                 :         14 : }
     211                 :            : 
     212                 :            : 
     213                 :            : 
     214                 :         34 : void outdoors_random_event(void)
     215                 :            : {
     216                 :            :   int num,i,j;
     217                 :            :   pob ob;
     218                 :            : 
     219   [ -  -  -  -  :         34 :   switch(random_range(300)) {
          -  -  +  -  -  
             -  +  -  -  
                      + ]
     220                 :            :   case 0:
     221      [ #  #  # ]:          0 :     switch(Country[Player.x][Player.y].current_terrain_type) {
     222                 :            :     case TUNDRA: 
     223                 :          0 :       mprint("It begins to snow. Heavily.");
     224                 :          0 :       break;
     225                 :            :     case DESERT:
     226                 :          0 :       mprint("A sandstorm swirls around you.");
     227                 :          0 :       break;
     228                 :            :     default:
     229 [ #  # ][ #  # ]:          0 :       if ((Date > 75) && (Date < 330))
     230                 :          0 :         mprint("You are drenched by a sudden downpour!");
     231                 :          0 :       else mprint("It begins to snow. Heavily.");
     232                 :            :     }
     233                 :          0 :     morewait();
     234                 :          0 :     mprint("Due to the inclement weather conditions, you have become lost.");
     235                 :          0 :     morewait();
     236                 :          0 :     Precipitation+=random_range(12)+1;
     237                 :          0 :     setgamestatus(LOST);
     238                 :          0 :     break;
     239                 :            :   case 1:
     240                 :          0 :     mprint("You enter a field of brightly colored flowers...");
     241                 :          0 :     mprint("Wow, man! These are some pretty poppies...");
     242                 :          0 :     morewait();
     243                 :          0 :     mprint("poppies...");
     244                 :          0 :     morewait();
     245                 :          0 :     mprint("poppies...");
     246                 :          0 :     morewait();
     247                 :          0 :     print3("You become somewhat disoriented...");
     248                 :          0 :     setgamestatus(LOST);
     249                 :          0 :     break;
     250                 :            :   case 2:
     251                 :          0 :     mprint("You discover a sprig of athelas growing lonely in the wild.");
     252                 :          0 :     morewait();
     253                 :          0 :     mprint("Using your herbalist lore you cook a cake of lembas....");
     254                 :          0 :     morewait();
     255                 :          0 :     ob = ((pob) checkmalloc(sizeof(objtype)));
     256                 :          0 :     *ob = Objects[OB_LEMBAS];
     257                 :          0 :     gain_item(ob);
     258                 :          0 :     break;
     259                 :            :   case 3:
     260         [ #  # ]:          0 :     if (Precipitation > 0) {
     261                 :          0 :       mprint("You are struck by a bolt of lightning!");
     262                 :          0 :       p_damage(random_range(25),ELECTRICITY,"a lightning strike");
     263                 :          0 :       morewait();
     264                 :            :     }
     265                 :          0 :     else mprint("You feel static cling");
     266                 :          0 :     break;
     267                 :            :   case 4:
     268                 :          0 :     mprint("You find a fast-food establishment.");
     269                 :          0 :     morewait();
     270                 :          0 :     l_commandant();
     271                 :          0 :     break;
     272                 :            :   case 5:
     273                 :          0 :     mprint("A weird howling tornado hits from out of the West!");
     274                 :          0 :     morewait();
     275                 :          0 :     mprint("You've been caught in a chaos storm!");
     276                 :          0 :     morewait();
     277                 :          0 :     num = random_range(300);
     278         [ #  # ]:          0 :     if (num <10) {
     279                 :          0 :       mprint("Your cell-structure was disrupted!");
     280                 :          0 :       p_damage(random_range(100),UNSTOPPABLE,"a chaos storm");
     281                 :          0 :       morewait();
     282                 :            :     }
     283         [ #  # ]:          0 :     else if (num < 20) {
     284                 :          0 :       mprint("The chaos storm warps your frame!");
     285                 :          0 :       morewait();
     286                 :          0 :       mprint("Your statistical entropy has been maximized.");
     287                 :          0 :       morewait();
     288                 :          0 :       mprint("You feel average...");
     289                 :          0 :       morewait();
     290                 :          0 :       toggle_item_use(TRUE); /* FIXED! 12/30/98 */
     291                 :          0 :       Player.str = Player.maxstr = Player.con = Player.maxcon =
     292                 :          0 :         Player.dex = Player.maxdex = Player.agi = Player.maxagi =
     293                 :          0 :           Player.iq = Player.maxiq = Player.pow = Player.maxpow =
     294                 :          0 :             ((Player.maxstr+Player.maxcon+Player.maxdex+Player.maxagi+
     295                 :          0 :               Player.maxiq+Player.maxpow+12)/6);
     296                 :          0 :       toggle_item_use(FALSE); /* FIXED! 12/30/98 */
     297                 :            :     }
     298         [ #  # ]:          0 :     else if (num < 30) {
     299                 :          0 :       mprint("Your entire body glows with an eerie flickering light.");
     300                 :          0 :       morewait();
     301                 :          0 :       toggle_item_use(TRUE); /* FIXED! 12/30/98 */
     302         [ #  # ]:          0 :       for(i=1;i<MAXITEMS;i++)
     303         [ #  # ]:          0 :         if (Player.possessions[i] != NULL) {
     304                 :          0 :           Player.possessions[i]->plus++;
     305         [ #  # ]:          0 :           if (Player.possessions[i]->objchar == STICK)
     306                 :          0 :             Player.possessions[i]->charge+=10;
     307                 :          0 :           Player.possessions[i]->blessing+=10;
     308                 :            :         }
     309                 :          0 :       toggle_item_use(FALSE); /* FIXED! 12/30/98 */
     310                 :          0 :       cleanse(1);
     311                 :          0 :       mprint("You feel filled with energy!");
     312                 :          0 :       morewait();
     313                 :          0 :       Player.maxpow += 5;
     314                 :          0 :       Player.pow += 5;
     315                 :          0 :       Player.mana = Player.maxmana = calcmana() * 5;
     316                 :          0 :       mprint("You also feel weaker. Paradoxical, no?");
     317                 :          0 :       morewait();
     318                 :          0 :       Player.con -= 5;
     319                 :          0 :       Player.maxcon -= 5;
     320         [ #  # ]:          0 :       if (Player.con < 3)
     321                 :          0 :         p_death("congestive heart failure");
     322                 :            :     }
     323         [ #  # ]:          0 :     else if (num < 40) {
     324                 :          0 :       mprint("Your entire body glows black.");
     325                 :          0 :       morewait();
     326                 :          0 :       dispel(-1);
     327                 :          0 :       dispel(-1);
     328                 :          0 :       Player.pow-=10;
     329                 :          0 :       Player.mana=0;
     330                 :            :     }
     331         [ #  # ]:          0 :     else if (num < 60) {
     332                 :          0 :       mprint("The storm deposits you in a strange place....");
     333                 :          0 :       morewait();
     334                 :          0 :       setPlayerXY( random_range(COUNTRY_WIDTH), random_range(COUNTRY_LENGTH));      
     335                 :          0 :       screencheck(Player.x,Player.y);
     336                 :            :     }
     337         [ #  # ]:          0 :     else if (num < 70) {
     338                 :          0 :       mprint("A tendril of the storm condenses and falls into your hands.");
     339                 :          0 :       morewait();
     340                 :          0 :       ob = ((pob) checkmalloc(sizeof(objtype)));
     341                 :          0 :       make_artifact(ob,-1);
     342                 :          0 :       gain_item(ob);
     343                 :            :     }
     344         [ #  # ]:          0 :     else if (num < 80) {
     345         [ #  # ]:          0 :       if (gamestatusp(MOUNTED)) {
     346                 :          0 :         mprint("Your horse screams as he is transformed into an");
     347                 :          0 :         morewait();
     348                 :          0 :         mprint("imaginary unseen dead tortoise.");
     349                 :          0 :         morewait();
     350                 :          0 :         mprint("You are now on foot.");
     351                 :          0 :         morewait();
     352                 :          0 :         resetgamestatus(MOUNTED);
     353                 :            :       }
     354                 :            :       else {
     355                 :          0 :         mprint("You notice you are riding a horse. Odd. Very odd....");
     356                 :          0 :         morewait();
     357                 :          0 :         mprint("Now that's a horse of a different color!");
     358                 :          0 :         morewait();
     359                 :          0 :         setgamestatus(MOUNTED);
     360                 :            :       }
     361                 :            :     }
     362         [ #  # ]:          0 :     else if (num < 90) {
     363                 :          0 :       mprint("You feel imbued with godlike power....");
     364                 :          0 :       morewait();
     365                 :          0 :       wish(1);
     366                 :            :     }
     367         [ #  # ]:          0 :     else if (num < 100) {
     368                 :          0 :       mprint("The chaos storm has wiped your memory!");
     369                 :          0 :       morewait();
     370                 :          0 :       mprint("You feel extraordinarily naive....");
     371                 :          0 :       morewait();
     372                 :          0 :       mprint("You can't remember a thing! Not even your name.");
     373                 :          0 :       morewait();
     374                 :          0 :       Player.xp = 0;
     375                 :          0 :       Player.level = 0;
     376         [ #  # ]:          0 :       for (i=0;i<NUMRANKS;i++) Player.rank[i] = 0;
     377         [ #  # ]:          0 :       for (i=0;i<NUMSPELLS;i++) Spells[i].known = FALSE;
     378                 :          0 :       rename_player();
     379                 :            :     }
     380                 :            :     else {
     381                 :          0 :       mprint("You survive the chaos storm relatively unscathed.");
     382                 :          0 :       morewait();
     383                 :          0 :       mprint("It was a learning experience.");
     384                 :          0 :       morewait();
     385                 :          0 :       gain_experience(1000);
     386                 :            :     }
     387                 :          0 :     break;
     388                 :            :   case 6: case 7: case 8: case 9: case 10:
     389                 :          2 :     mprint("An encounter!");
     390                 :          2 :     morewait();
     391                 :          2 :     change_environment(E_TACTICAL_MAP);
     392                 :          2 :     break;
     393                 :            :   case 11:
     394                 :          0 :     mprint("You find a Traveller's Aid station with maps of the local area.");
     395                 :          0 :     morewait();
     396         [ #  # ]:          0 :     if (gamestatusp(LOST)) {
     397                 :          0 :       resetgamestatus(LOST);
     398                 :          0 :       mprint("You know where you are now.");
     399                 :            :     }
     400         [ #  # ]:          0 :     for(i=Player.x-5;i<Player.x+6;i++)
     401         [ #  # ]:          0 :       for(j=Player.y-5;j<Player.y+6;j++)
     402         [ #  # ]:          0 :         if (inbounds(i,j)) {
     403                 :          0 :           c_set(i, j, SEEN);
     404         [ #  # ]:          0 :           if (Country[i][j].current_terrain_type !=
     405                 :          0 :             Country[i][j].base_terrain_type) {
     406                 :          0 :             c_set(i, j, CHANGED);
     407                 :          0 :             Country[i][j].current_terrain_type = 
     408                 :          0 :               Country[i][j].base_terrain_type;
     409                 :            :           }
     410                 :            :         }
     411                 :          0 :     show_screen();
     412                 :          0 :     break;
     413                 :            :   case 12:
     414         [ #  # ]:          0 :     if (! gamestatusp(MOUNTED)) {
     415                 :          0 :       mprint("You develop blisters....");
     416                 :          0 :       p_damage(1,UNSTOPPABLE,"blisters");
     417                 :            :     }
     418                 :          0 :     break;
     419                 :            :   case 13:
     420                 :          0 :     mprint("You discover an itch just where you can't scratch it.");
     421                 :          0 :     break;
     422                 :            :   case 14:
     423                 :          1 :     mprint("A cosmic ray strikes!");
     424                 :          1 :     morewait();
     425                 :          1 :     p_damage(10,UNSTOPPABLE,"a cosmic ray");
     426                 :          1 :     break;
     427                 :            :   case 15:
     428                 :          0 :     mprint("You feel strangely lucky.");
     429                 :          0 :     break;
     430                 :            :   case 16:
     431                 :          0 :     mprint("The west wind carries with it a weird echoing voice....");
     432                 :            :     /* DAG hint() uses mprint, which should morewait() if needed */
     433                 :            :     /* morewait(); */
     434                 :          0 :     hint();
     435                 :          0 :     morewait();
     436                 :          0 :     break;
     437                 :            :   }
     438                 :         34 :   dataprint();
     439                 :         34 :   showflags();
     440                 :         34 : }
     441                 :            : 
     442                 :            : 
     443                 :          6 : char getlocation(void)
     444                 :            : {
     445                 :          6 :   char c = '\0';
     446                 :            : 
     447                 :          6 :   menuprint(" (enter location [HCL]) ");
     448                 :          6 :   showmenu();
     449         [ +  + ]:         14 :   while (c == '\0')
     450   [ +  +  +  + ]:          8 :     switch (c = ((char) mcigetc())) {
     451                 :          1 :       case 'h':menuprint(" High."); break;
     452                 :          2 :       case 'c':menuprint(" Center."); break;
     453                 :          3 :       case 'l':menuprint(" Low."); break;
     454                 :          2 :       default: c = '\0'; break;
     455                 :            :     }
     456                 :          6 :   showmenu();
     457                 :          6 :   return (c - 'a' + 'A');
     458                 :            : }
     459                 :            : 
     460                 :            : 
     461                 :            : /* chance for player to resist magic somehow */
     462                 :            : /* hostile_magic ranges in power from 0 (weak) to 10 (strong) */
     463                 :          0 : int magic_resist(int hostile_magic)
     464                 :            : {
     465   [ #  #  #  # ]:          0 :   if ((Player.rank[COLLEGE]+Player.rank[CIRCLE] > 0) &&
     466                 :          0 :       (Player.level/2 + random_range(20) >
     467                 :          0 :        hostile_magic + random_range(20))) {
     468         [ #  # ]:          0 :     if (Player.mana > hostile_magic * hostile_magic) {
     469                 :          0 :       mprint("Thinking fast, you defend youself with a counterspell!");
     470                 :          0 :       Player.mana -= hostile_magic * hostile_magic;
     471                 :          0 :       dataprint();
     472                 :          0 :       return(TRUE);
     473                 :            :     }
     474                 :            :   }
     475         [ #  # ]:          0 :   if (Player.level/4 + Player.status[PROTECTION] + random_range(20) > 
     476                 :          0 :       hostile_magic + random_range(30)) {
     477                 :          0 :     mprint("You resist the spell!");
     478                 :          0 :     return(TRUE);
     479                 :            :   }
     480                 :          0 :   else return(FALSE);
     481                 :            : }
     482                 :            : 
     483                 :            : 
     484                 :         34 : void terrain_check(int takestime)
     485                 :            : {
     486                 :         34 :   int faster = 0;
     487                 :            : 
     488         [ -  + ]:         34 :   if (Player.patron == DRUID) {
     489                 :          0 :     faster = 1;
     490      [ #  #  # ]:          0 :     switch(random_range(32)) {
     491                 :          0 :       case 0:print2("Along the many paths of nature..."); break;
     492                 :          0 :       case 1:print2("You move swiftly through the wilderness."); break;
     493                 :            :     }
     494                 :            :   }
     495         [ +  - ]:         34 :   else if (gamestatusp(MOUNTED)) {
     496                 :         34 :     faster = 1;
     497   [ +  +  -  + ]:         34 :     switch(random_range(32)) {
     498                 :            :       case 0:
     499                 :          2 :       case 1:print2("Clippity Clop.");break;
     500                 :          1 :       case 2:print2("....my spurs go jingle jangle jingle....");break;
     501                 :         34 :       case 3:print2("....as I go riding merrily along....");break;
     502                 :            :     }
     503                 :            :   }
     504 [ #  # ][ #  # ]:          0 :   else if (Player.possessions[O_BOOTS] &&
     505                 :          0 :       Player.possessions[O_BOOTS]->usef == I_BOOTS_7LEAGUE) {
     506                 :          0 :     takestime = 0;
     507   [ #  #  #  #  :          0 :     switch(random_range(32)) {
                      # ]
     508                 :          0 :       case 0:print2("Boingg!"); break;
     509                 :          0 :       case 1:print2("Whooosh!"); break;
     510                 :          0 :       case 2:print2("Over hill, over dale...."); break;
     511                 :          0 :       case 3:print2("...able to leap over 7 leagues in a single bound....");
     512                 :          0 :         break;
     513                 :            :     }
     514                 :          0 :   }
     515         [ #  # ]:          0 :   else if (Player.status[SHADOWFORM]) {
     516                 :          0 :     faster = 1;
     517      [ #  #  # ]:          0 :     switch(random_range(32)) {
     518                 :          0 :       case 0:print2("As swift as a shadow."); break;
     519                 :          0 :       case 1:print2("\"I walk through the trees...\""); break;
     520                 :            :     }
     521                 :            :   }
     522      [ #  #  # ]:          0 :   else switch(random_range(32)) {
     523                 :          0 :     case 0:print2("Trudge. Trudge."); break;
     524                 :          0 :     case 1:print2("The road goes ever onward...."); break;
     525                 :            :   }
     526   [ -  +  +  -  :         34 :   switch(Country[Player.x][Player.y].current_terrain_type) {
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
                -  -  - ]
     527                 :            :   case RIVER:
     528 [ #  # ][ #  # ]:          0 :     if ((Player.y < 6) && (Player.x > 20)) locprint("Star Lake.");
     529         [ #  # ]:          0 :     else if (Player.y < 41) {
     530         [ #  # ]:          0 :       if (Player.x < 10) locprint("Aerie River.");
     531                 :          0 :       else locprint("The Great Flood.");
     532                 :            :     }
     533         [ #  # ]:          0 :     else if (Player.x < 42) locprint("The Swamp Runs.");
     534                 :          0 :     else locprint("River Greenshriek.");
     535         [ #  # ]:          0 :     if (takestime) {
     536                 :          0 :       Time += 60;
     537                 :          0 :       hourly_check();
     538                 :          0 :       Time += 60;
     539                 :          0 :       hourly_check();
     540                 :          0 :       Time += 60;
     541                 :          0 :       hourly_check();
     542                 :            :     }
     543                 :          0 :     break;
     544                 :            :   case ROAD:
     545                 :         30 :     locprint("A well-maintained road.");
     546         [ +  + ]:         30 :     if (takestime) {
     547                 :         28 :       Time += 60;
     548                 :         28 :       hourly_check();
     549                 :            :     }
     550                 :         30 :     break;
     551                 :            :   case PLAINS:
     552                 :          1 :     locprint("A rippling sea of grass.");
     553         [ +  - ]:          1 :     if (takestime) {
     554                 :          1 :       Time += 60;
     555                 :          1 :       hourly_check();
     556         [ -  + ]:          1 :       if (! faster) {
     557                 :          0 :         Time += 60;
     558                 :          0 :         hourly_check();
     559                 :            :       }
     560                 :            :     }
     561                 :          1 :     break;
     562                 :            :   case TUNDRA:
     563                 :          0 :     locprint("The Great Northern Wastes.");
     564         [ #  # ]:          0 :     if (takestime) {
     565                 :          0 :       Time += 60;
     566                 :          0 :       hourly_check();
     567         [ #  # ]:          0 :       if (! faster) {
     568                 :          0 :         Time += 60;
     569                 :          0 :         hourly_check();
     570                 :            :       }
     571                 :            :     }
     572                 :          0 :     break;
     573                 :            :   case FOREST:
     574         [ #  # ]:          0 :     if (Player.y < 10) locprint("The Deepwood.");
     575         [ #  # ]:          0 :     else if (Player.y < 18) locprint("The Forest of Erelon.");
     576         [ #  # ]:          0 :     else if (Player.y < 46) locprint("The Great Forest.");
     577         [ #  # ]:          0 :     if (takestime) {
     578                 :          0 :       Time += 60;
     579                 :          0 :       hourly_check();
     580 [ #  # ][ #  # ]:          0 :       if (Player.rank[PRIESTHOOD] == 0 || Player.patron != DRUID) {
     581                 :          0 :         Time += 60;
     582                 :          0 :         hourly_check();
     583         [ #  # ]:          0 :         if (! faster) {
     584                 :          0 :           Time += 60;
     585                 :          0 :           hourly_check();
     586                 :            :         }
     587                 :            :       }
     588                 :            :     }
     589                 :          0 :     break;
     590                 :            :   case JUNGLE:
     591                 :          0 :     locprint("Greenshriek Jungle.");
     592         [ #  # ]:          0 :     if (takestime) {
     593                 :          0 :       Time += 60;
     594                 :          0 :       hourly_check();
     595                 :          0 :       Time += 60;
     596                 :          0 :       hourly_check();
     597         [ #  # ]:          0 :       if (! faster) {
     598                 :          0 :         Time += 60;
     599                 :          0 :         hourly_check();
     600                 :          0 :         Time += 60;
     601                 :          0 :         hourly_check();
     602                 :            :       }
     603                 :            :     }
     604                 :          0 :     break;
     605                 :            :   case DESERT:
     606                 :          0 :     locprint("The Waste of Time.");
     607         [ #  # ]:          0 :     if (takestime) {
     608                 :          0 :       Time += 60;
     609                 :          0 :       hourly_check();
     610                 :          0 :       Time += 60;
     611                 :          0 :       hourly_check();
     612         [ #  # ]:          0 :       if (! faster) {
     613                 :          0 :         Time += 60;
     614                 :          0 :         hourly_check();
     615                 :          0 :         Time += 60;
     616                 :          0 :         hourly_check();
     617                 :            :       }
     618                 :            :     }
     619                 :          0 :     break;
     620                 :            :   case MOUNTAINS:
     621 [ #  # ][ #  # ]:          0 :     if ((Player.y < 9) && (Player.x < 12))
     622                 :          0 :       locprint("The Magic Mountains");
     623 [ #  # ][ #  # ]:          0 :     else if ((Player.y < 9) && (Player.y > 2) && (Player.x < 40))
                 [ #  # ]
     624                 :          0 :       locprint("The Peaks of the Fist.");
     625         [ #  # ]:          0 :     else if (Player.x < 52)
     626                 :          0 :       locprint("The Rift Mountains.");
     627                 :          0 :     else locprint("Borderland Mountains.");
     628         [ #  # ]:          0 :     if (takestime) {
     629                 :          0 :       Time += 60;
     630                 :          0 :       hourly_check();
     631                 :          0 :       Time += 60;
     632                 :          0 :       hourly_check();
     633                 :          0 :       Time += 60;
     634                 :          0 :       hourly_check();
     635                 :          0 :       Time += 60;
     636                 :          0 :       hourly_check();
     637                 :          0 :       Time += 60;
     638                 :          0 :       hourly_check();
     639         [ #  # ]:          0 :       if (! faster) {
     640                 :          0 :         Time += 60;
     641                 :          0 :         hourly_check();
     642                 :          0 :         Time += 60;
     643                 :          0 :         hourly_check();
     644                 :          0 :         Time += 60;
     645                 :          0 :         hourly_check();
     646                 :            :       }
     647                 :            :     }
     648                 :          0 :     break;
     649                 :            :   case PASS:
     650                 :          0 :     locprint("A hidden pass.");
     651         [ #  # ]:          0 :     if (takestime) {
     652                 :          0 :       Time += 60;
     653                 :          0 :       hourly_check();
     654                 :            :     }
     655                 :          0 :     break;
     656                 :            :   case CHAOS_SEA:
     657                 :          0 :     locprint("The Sea of Chaos.");
     658         [ #  # ]:          0 :     if (takestime) {
     659                 :          0 :       Time += 60;
     660                 :          0 :       hourly_check();
     661                 :            :     }
     662                 :          0 :     mprint("You have entered the sea of chaos...");
     663                 :          0 :     morewait();
     664                 :          0 :     l_chaos();
     665                 :          0 :     break;
     666                 :            :   case SWAMP:
     667                 :          0 :     locprint("The Loathly Swamp.");
     668         [ #  # ]:          0 :     if (takestime) {
     669                 :          0 :       Time += 60;
     670                 :          0 :       hourly_check();
     671                 :          0 :       Time += 60;
     672                 :          0 :       hourly_check();
     673                 :          0 :       Time += 60;
     674                 :          0 :       hourly_check();
     675                 :          0 :       Time += 60;
     676                 :          0 :       hourly_check();
     677                 :          0 :       Time += 60;
     678                 :          0 :       hourly_check();
     679                 :          0 :       Time += 60;
     680                 :          0 :       hourly_check();
     681         [ #  # ]:          0 :       if (! faster) {
     682                 :          0 :         Time += 60;
     683                 :          0 :         hourly_check();
     684                 :          0 :         Time += 60;
     685                 :          0 :         hourly_check();
     686                 :            :       }
     687                 :            :     }
     688                 :          0 :     break;
     689                 :            :   case CITY:
     690         [ -  + ]:          2 :     if (gamestatusp(LOST)) {
     691                 :          0 :       resetgamestatus(LOST); 
     692                 :          0 :       mprint("Well, I guess you know where you are now....");
     693                 :            :     }
     694                 :          2 :     locprint("Outside Rampart, the city.");
     695                 :          2 :     break;
     696                 :            :   case VILLAGE:
     697         [ -  + ]:          1 :     if (gamestatusp(LOST)) {
     698                 :          0 :       resetgamestatus(LOST); 
     699                 :          0 :       mprint("The village guards let you know where you are....");
     700                 :            :     }
     701                 :          1 :     locprint("Outside a small village.");
     702                 :          1 :     break;
     703                 :            :   case CAVES:
     704                 :          0 :     locprint("A deserted hillside.");
     705         [ #  # ]:          0 :     if (takestime) {
     706                 :          0 :       Time += 60;
     707                 :          0 :       hourly_check();
     708                 :            :     }
     709                 :          0 :     mprint("You notice a concealed entrance into the hill.");
     710                 :          0 :     break;
     711                 :            :   case CASTLE:
     712                 :          0 :     locprint("Near a fortified castle.");
     713         [ #  # ]:          0 :     if (takestime) {
     714                 :          0 :       Time += 60;
     715                 :          0 :       hourly_check();
     716                 :            :     }
     717                 :          0 :     mprint("The castle is hewn from solid granite. The drawbridge is down.");
     718                 :          0 :     break;
     719                 :            :   case TEMPLE:
     720   [ #  #  #  #  :          0 :     switch(Country[Player.x][Player.y].aux) {
                #  #  # ]
     721                 :          0 :     case ODIN: locprint("A rough-hewn granite temple."); break;
     722                 :          0 :     case SET: locprint("A black pyramidal temple made of sandstone."); break;
     723                 :          0 :     case ATHENA: locprint("A classical marble-columned temple."); break;
     724                 :          0 :     case HECATE: locprint("A temple of ebony adorned with ivory."); break;
     725                 :          0 :     case DRUID: locprint("A temple formed of living trees."); break;
     726                 :          0 :     case DESTINY: locprint("A temple of some mysterious blue crystal."); break;
     727                 :            :     }
     728         [ #  # ]:          0 :     if (takestime) {
     729                 :          0 :       Time += 60;
     730                 :          0 :       hourly_check();
     731                 :            :     }
     732                 :          0 :     mprint("You notice an entrance conveniently at hand.");
     733                 :          0 :     break;
     734                 :            :   case MAGIC_ISLE:
     735                 :          0 :     locprint("A strange island in the midst of the Sea of Chaos.");
     736         [ #  # ]:          0 :     if (takestime) {
     737                 :          0 :       Time += 60;
     738                 :          0 :       hourly_check();
     739                 :            :     }
     740                 :          0 :     mprint("There is a narrow causeway to the island from here.");
     741                 :          0 :     break;
     742                 :            :   case STARPEAK:
     743                 :          0 :     locprint("Star Peak.");
     744         [ #  # ]:          0 :     if (takestime) {
     745                 :          0 :       Time += 60;
     746                 :          0 :       hourly_check();
     747                 :            :     }
     748                 :          0 :     mprint("The top of the mountain seems to glow with a allochroous aura.");
     749                 :          0 :     break;
     750                 :            :   case DRAGONLAIR:
     751                 :          0 :     locprint("A rocky chasm.");
     752         [ #  # ]:          0 :     if (takestime) {
     753                 :          0 :       Time += 60;
     754                 :          0 :       hourly_check();
     755                 :            :     }
     756                 :          0 :     mprint("You are at a cave entrance from which you see the glint of gold.");
     757                 :          0 :     break;
     758                 :            :   case PALACE:
     759                 :          0 :     locprint("The ruins of a once expansive palace.");
     760         [ #  # ]:          0 :     if (takestime) {
     761                 :          0 :       Time += 60;
     762                 :          0 :       hourly_check();
     763                 :            :     }
     764                 :          0 :     mprint("The palace dungeons are still intact...");
     765                 :          0 :     break;
     766                 :            :   case VOLCANO:
     767                 :          0 :     locprint("HellWell Volcano.");
     768         [ #  # ]:          0 :     if (takestime) {
     769                 :          0 :       Time += 60;
     770                 :          0 :       hourly_check();
     771                 :            :     }
     772                 :          0 :     mprint("A shimmer of heat lightning plays about the crater rim.");
     773                 :          0 :     break;
     774                 :            :   default:
     775                 :          0 :     locprint("I haven't any idea where you are!!!");
     776                 :          0 :     break;
     777                 :            :    }
     778                 :         34 :   outdoors_random_event();
     779                 :         34 : }
     780                 :            : 
     781                 :            : 
     782                 :            : 
     783                 :          0 : void countrysearch(void)
     784                 :            : {
     785                 :            :   int x,y;
     786                 :          0 :   Time+=60;
     787                 :          0 :   hourly_check();
     788         [ #  # ]:          0 :   for (x=Player.x-1;x<Player.x+2;x++)
     789         [ #  # ]:          0 :     for (y=Player.y-1;y<Player.y+2;y++)
     790         [ #  # ]:          0 :       if (inbounds(x,y)) {
     791         [ #  # ]:          0 :         if (Country[x][y].current_terrain_type !=
     792                 :          0 :             Country[x][y].base_terrain_type) {
     793                 :          0 :           clearmsg();
     794                 :          0 :           mprint("Your search was fruitful!");
     795                 :          0 :           Country[x][y].current_terrain_type=Country[x][y].base_terrain_type;
     796                 :          0 :           c_set(x, y, CHANGED);
     797                 :          0 :           mprint("You discovered:");
     798                 :          0 :           mprint(countryid(Country[x][y].base_terrain_type));
     799                 :            :         }
     800                 :            :       }
     801                 :          0 : }
     802                 :            : 
     803                 :          0 : char *countryid(Symbol terrain)
     804                 :            : {
     805   [ #  #  #  #  :          0 :   switch(terrain&0xff) {
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                #  #  # ]
     806                 :            :   case MOUNTAINS&0xff:
     807                 :          0 :     strcpy(Str1,"Almost impassable mountains");
     808                 :          0 :     break;
     809                 :            :   case PLAINS&0xff:
     810                 :          0 :     strcpy(Str1,"Seemingly endless plains");
     811                 :          0 :     break;
     812                 :            :   case TUNDRA&0xff:
     813                 :          0 :     strcpy(Str1,"A frosty stretch of tundra");
     814                 :          0 :     break;
     815                 :            :   case ROAD&0xff:
     816                 :          0 :     strcpy(Str1,"A paved highway");
     817                 :          0 :     break;
     818                 :            :   case PASS&0xff:
     819                 :          0 :     strcpy(Str1,"A secret mountain pass");
     820                 :          0 :     break;
     821                 :            :   case RIVER&0xff:
     822                 :          0 :     strcpy(Str1,"A rolling river");
     823                 :          0 :     break;
     824                 :            :   case CITY&0xff:
     825                 :          0 :     strcpy(Str1,"The city of Rampart");
     826                 :          0 :     break;
     827                 :            :   case VILLAGE&0xff:
     828                 :          0 :     strcpy(Str1,"A rural village");
     829                 :          0 :     break;
     830                 :            :   case FOREST&0xff:
     831                 :          0 :     strcpy(Str1,"A verdant forest");
     832                 :          0 :     break;
     833                 :            :   case JUNGLE&0xff:
     834                 :          0 :     strcpy(Str1,"A densely overgrown jungle");
     835                 :          0 :     break;
     836                 :            :   case SWAMP&0xff:
     837                 :          0 :     strcpy(Str1,"A swampy fen");
     838                 :          0 :     break;
     839                 :            :   case VOLCANO&0xff:
     840                 :          0 :     strcpy(Str1,"A huge active volcano");
     841                 :          0 :     break;
     842                 :            :   case CASTLE&0xff:
     843                 :          0 :     strcpy(Str1,"An imposing castle");
     844                 :          0 :     break;
     845                 :            :   case STARPEAK&0xff:
     846                 :          0 :     strcpy(Str1,"A mysterious mountain.");
     847                 :          0 :     break;
     848                 :            :   case DRAGONLAIR&0xff:
     849                 :          0 :     strcpy(Str1,"A cavern filled with treasure.");
     850                 :          0 :     break;
     851                 :            :   case PALACE&0xff:
     852                 :          0 :     strcpy(Str1,"An ancient palace ruins.");
     853                 :          0 :     break;
     854                 :            :   case MAGIC_ISLE&0xff:
     855                 :          0 :     strcpy(Str1,"An island emanating magic.");
     856                 :          0 :     break;
     857                 :            :   case CAVES&0xff:
     858                 :          0 :     strcpy(Str1,"A hidden cave entrance");
     859                 :          0 :     break;
     860                 :            :   case TEMPLE&0xff:
     861                 :          0 :     strcpy(Str1,"A neoclassical temple");
     862                 :          0 :     break;
     863                 :            :   case DESERT&0xff:
     864                 :          0 :     strcpy(Str1,"A sere desert");
     865                 :          0 :     break;
     866                 :            :   case CHAOS_SEA&0xff:
     867                 :          0 :     strcpy(Str1,"The Sea of Chaos");
     868                 :          0 :     break;
     869                 :            :   default:
     870                 :          0 :     strcpy(Str1,"I have no idea.");
     871                 :          0 :     break;
     872                 :            :   }
     873                 :          0 :   return(Str1);
     874                 :            : }
     875                 :            : 
     876                 :            : /* WDT: I removed a space which appeared after "sorcerors' guild ". */
     877                 :            : static char sitenames[][30] = { /* alphabetical listing */
     878                 :            : "alchemist", "arena", "armorer", "bank", "brothel", "casino", "castle",
     879                 :            : "city gates", "collegium magii", "condo", "department of public works",
     880                 :            : "diner", "explorers' club", "fast food", "gymnasium", "healer", 
     881                 :            : "hospice", "les crapuleux", "library", "mercenary guild",
     882                 :            : #ifdef INCLUDE_MONKS
     883                 :            : "monastery",
     884                 :            : #endif
     885                 :            : "oracle", "order of paladins", "pawn shop", "sewer entrance",
     886                 :            : "sorcerors' guild", "tavern", "temple", "thieves' guild",
     887                 :            : "tourist information"
     888                 :            : };
     889                 :            : 
     890                 :            : static int sitenums[] = {       /* the order matches sitenames[] */
     891                 :            :  L_ALCHEMIST, L_ARENA, L_ARMORER, L_BANK, L_BROTHEL, L_CASINO, L_CASTLE,
     892                 :            :  L_COUNTRYSIDE, L_COLLEGE, L_CONDO, L_DPW, L_DINER, L_CLUB, 
     893                 :            :  L_COMMANDANT, L_GYM, L_HEALER, L_CHARITY, L_CRAP, L_LIBRARY, L_MERC_GUILD, 
     894                 :            : #ifdef INCLUDE_MONKS
     895                 :            :  L_MONASTERY,
     896                 :            : #endif
     897                 :            :  L_ORACLE, L_ORDER, L_PAWN_SHOP, L_SEWER, L_SORCERORS, L_TAVERN, L_TEMPLE, 
     898                 :            :  L_THIEVES_GUILD, L_TOURIST
     899                 :            : };
     900                 :            : 
     901                 :          2 : void showknownsites(int first, int last)
     902                 :            : {
     903                 :          2 :   int i,printed=FALSE;
     904                 :            : 
     905                 :          2 :   menuclear();
     906                 :          2 :   menuprint("\nPossible Sites:\n");
     907         [ +  + ]:         62 :   for (i = first; i <= last; i++)
     908         [ +  + ]:         60 :     if (CitySiteList[sitenums[i] - CITYSITEBASE][0]) {
     909                 :         52 :       printed = TRUE;
     910                 :         52 :       menuprint(sitenames[i]);
     911                 :         52 :       menuprint("\n");
     912                 :            :     }
     913         [ -  + ]:          2 :   if (! printed)
     914                 :          0 :     menuprint("\nNo known sites match that prefix!");
     915                 :          2 :   showmenu();
     916                 :          2 : }
     917                 :            : 
     918                 :          3 : int parsecitysite()
     919                 :            : {
     920                 :            :   int first, last, pos;
     921                 :            :   char byte, prefix[80];
     922                 :          3 :   int found = 0;
     923                 :            :   int f, l;
     924                 :            : 
     925                 :          3 :   first = 0;
     926                 :          3 :   last = NUMCITYSITES - 1;
     927                 :          3 :   pos = 0;
     928                 :          3 :   print2("");
     929                 :            :   do {
     930                 :         13 :     byte = mgetc();
     931 [ +  - ][ -  + ]:         13 :     if (byte == BACKSPACE || byte == DELETE) {
     932         [ #  # ]:          0 :       if (pos > 0) {
     933                 :          0 :         prefix[--pos] = '\0';
     934                 :          0 :         byte = prefix[pos - 1];
     935                 :          0 :         f = first;
     936 [ #  # ][ #  # ]:          0 :         while (f >= 0 && !strncmp(prefix, sitenames[f], pos)) {
     937         [ #  # ]:          0 :           if (CitySiteList[sitenums[f] - CITYSITEBASE][0])
     938                 :          0 :             first = f;
     939                 :          0 :           f--;
     940                 :            :         }
     941                 :          0 :         l = last;
     942 [ #  # ][ #  # ]:          0 :         while (l < NUMCITYSITES && !strncmp(prefix, sitenames[l], pos)) {
     943         [ #  # ]:          0 :           if (CitySiteList[sitenums[l] - CITYSITEBASE][0])
     944                 :          0 :             last = l;
     945                 :          0 :           l++;
     946                 :            :         }
     947         [ #  # ]:          0 :         if (found)
     948                 :          0 :           found = 0;
     949                 :          0 :         print2(prefix);
     950                 :            :       }
     951         [ #  # ]:          0 :       if (pos == 0) {
     952                 :          0 :         first = 0;
     953                 :          0 :         last = NUMCITYSITES - 1;
     954                 :          0 :         found = 0;
     955                 :          0 :         print2("");
     956                 :            :       }
     957                 :            :     }
     958         [ -  + ]:         13 :     else if (byte == ESCAPE) {
     959                 :          0 :       xredraw();
     960                 :          0 :       return ABORT;
     961                 :            :     }
     962         [ +  + ]:         13 :     else if (byte == '?')
     963                 :          2 :       showknownsites(first, last);
     964         [ +  + ]:         11 :     else if (byte != '\n') {
     965 [ +  - ][ -  + ]:          8 :       if (byte >= 'A' && byte <= 'Z') 
     966                 :          0 :         byte += 'a' - 'A';
     967         [ +  + ]:          8 :       if (found)
     968                 :          3 :         continue;
     969                 :          5 :       f = first;
     970                 :          5 :       l = last;
     971 [ +  - ][ +  + ]:         33 :       while (f < NUMCITYSITES &&
     972         [ -  + ]:         31 :           (!CitySiteList[sitenums[f] - CITYSITEBASE][0] ||
     973         [ +  + ]:         31 :           strlen(sitenames[f]) < pos || sitenames[f][pos] < byte))
     974                 :         28 :         f++;
     975 [ +  - ][ +  + ]:         64 :       while (l >= 0 && (!CitySiteList[sitenums[l] - CITYSITEBASE][0] ||
                 [ -  + ]
     976         [ +  + ]:         54 :           strlen(sitenames[l]) < pos || sitenames[l][pos] > byte))
     977                 :         59 :         l--;
     978         [ -  + ]:          5 :       if (l < f)
     979                 :          0 :         continue;
     980                 :          5 :       prefix[pos++] = byte;
     981                 :          5 :       prefix[pos] = '\0';
     982                 :          5 :       nprint2(prefix + pos - 1);
     983                 :          5 :       first = f;
     984                 :          5 :       last = l;
     985 [ +  + ][ +  - ]:          5 :       if (first == last && !found) {    /* unique name */
     986                 :          3 :         found = 1;
     987                 :          3 :         nprint2(sitenames[first] + pos);
     988                 :            :       }
     989                 :            :     }
     990         [ +  + ]:         13 :   } while (byte != '\n');
     991                 :          3 :   xredraw();
     992         [ +  - ]:          3 :   if (found)
     993                 :          3 :     return sitenums[first] - CITYSITEBASE;
     994                 :            :   else {
     995                 :          0 :     print3("That is an ambiguous abbreviation!");
     996                 :          3 :     return ABORT;
     997                 :            :   }
     998                 :            : }
     999                 :            : 
    1000                 :            : 
    1001                 :            : /* are there hostile monsters within 2 moves? */
    1002                 :          3 : int hostilemonstersnear(void)
    1003                 :            : {
    1004                 :          3 :   int i,j,hostile = FALSE;
    1005                 :            : 
    1006 [ +  + ][ +  - ]:         18 :   for (i=Player.x-2;((i<Player.x+3)&&(! hostile));i++)
    1007 [ +  + ][ +  - ]:         90 :     for (j=Player.y-2;((j<Player.y+3)&&(! hostile));j++)
    1008         [ +  - ]:         75 :       if (inbounds(i,j))
    1009         [ +  + ]:         75 :         if (Level->site[i][j].creature != NULL)
    1010                 :          1 :           hostile = m_statusp(Level->site[i][j].creature,HOSTILE);
    1011                 :            :   
    1012                 :          3 :   return(hostile);
    1013                 :            : }
    1014                 :            : 
    1015                 :            : /* random effects from some of stones in villages */  
    1016                 :            : /* if alignment of stone is alignment of player, gets done sooner */
    1017                 :          0 : int stonecheck(int alignment)
    1018                 :            : {
    1019                 :          0 :   int *stone,match=FALSE,cycle=FALSE,i;
    1020                 :            : 
    1021         [ #  # ]:          0 :   if (alignment == 1) {
    1022                 :          0 :     stone = &Lawstone;
    1023                 :          0 :     match = Player.alignment > 0;
    1024                 :            :   }
    1025         [ #  # ]:          0 :   else if (alignment == -1) {
    1026                 :          0 :     stone = &Chaostone;
    1027                 :          0 :     match = Player.alignment < 0;
    1028                 :            :   }
    1029                 :            :   else {
    1030                 :          0 :     stone = &Mindstone;
    1031                 :          0 :     match = FALSE;
    1032                 :            :   }
    1033         [ #  # ]:          0 :   *stone += random_range(4) + (match ? random_range(4) : 0);
    1034   [ #  #  #  #  :          0 :   switch((*stone)++) {
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
    1035                 :            :   case 0:case 2:case 4:case 6:case 8:case 10:case 12:case 14:case 16:case 18:
    1036                 :            :   case 20:case 22:case 24:case 26:case 28:case 30:case 32:case 34:case 36:
    1037                 :          0 :   case 38:case 40: print1("The stone glows grey.");
    1038                 :          0 :     print2("Not much seems to happen this time."); 
    1039                 :          0 :     (*stone)--;
    1040                 :          0 :     break;
    1041                 :          0 :   case 1: print1("The stone glows black"); 
    1042                 :          0 :     print2("A burden has been removed from your shoulders.....");
    1043                 :          0 :     print3("Your pack has disintegrated!");
    1044         [ #  # ]:          0 :     for(i=0;i<MAXPACK;i++) 
    1045         [ #  # ]:          0 :       if (Player.pack[i] != NULL) {
    1046                 :          0 :         free_obj( Player.pack[i], TRUE );
    1047                 :          0 :         Player.pack[i] = NULL;
    1048                 :            :       }
    1049                 :          0 :     Player.packptr = 0;
    1050                 :          0 :     break;
    1051                 :          0 :   case 3: print1("The stone glows microwave");
    1052                 :          0 :     print2("A vortex of antimana spins about you!");
    1053                 :          0 :     morewait();
    1054                 :          0 :     dispel(-1);
    1055                 :          0 :     break;
    1056                 :          0 :   case 5: print1("The stone glows infrared");
    1057                 :          0 :     print2("A portal opens nearby and an obviously confused monster appears!");
    1058                 :          0 :     summon(-1,-1);
    1059                 :          0 :     morewait();
    1060                 :          0 :     break;
    1061                 :          0 :   case 7: print1("The stone glows brick red");
    1062                 :          0 :     print2("A gold piece falls from the heavens into your money pouch!");
    1063                 :          0 :     Player.cash++;
    1064                 :          0 :     break;
    1065                 :          0 :   case 9: print1("The stone glows cherry red");
    1066                 :          0 :     print2("A flush of warmth spreads through your body.");
    1067                 :          0 :     augment(1);
    1068                 :          0 :     break;
    1069                 :          0 :   case 11: print1("The stone glows orange");
    1070                 :          0 :     print2("A flux of energy blasts you!"); 
    1071                 :          0 :     manastorm(Player.x,Player.y,random_range(Player.maxhp)+1);
    1072                 :          0 :     break;
    1073                 :          0 :   case 13: print1("The stone glows lemon yellow");
    1074                 :          0 :     print2("You're surrounded by enemies! You begin to foam at the mouth.");
    1075                 :          0 :     Player.status[BERSERK] += 10;
    1076                 :          0 :     break;
    1077                 :          0 :   case 15: print1("The stone glows yellow");
    1078                 :          0 :     print2("Oh no! The DREADED AQUAE MORTIS!");
    1079                 :          0 :     morewait();
    1080                 :          0 :     print2("No, wait, it's just your imagination.");
    1081                 :          0 :     break;
    1082                 :          0 :   case 17: print1("The stone glows chartreuse");
    1083                 :          0 :     print2("Your joints stiffen up.");
    1084                 :          0 :     Player.agi -= 3;
    1085                 :          0 :     break;
    1086                 :          0 :   case 19: print1("The stone glows green");
    1087                 :          0 :     print2("You come down with an acute case of Advanced Leprosy.");
    1088                 :          0 :     Player.status[DISEASED] = 1100;
    1089                 :          0 :     Player.hp = 1;
    1090                 :          0 :     Player.dex -= 5;
    1091                 :          0 :     break;
    1092                 :          0 :   case 21: print1("The stone glows forest green");
    1093                 :          0 :     print2("You feel wonderful!");
    1094                 :          0 :     Player.status[HERO]+=10;
    1095                 :          0 :     break;
    1096                 :          0 :   case 23: print1("The stone glows cyan");
    1097                 :          0 :     print2("You feel a strange twisting sensation....");
    1098                 :          0 :     morewait();
    1099                 :          0 :     strategic_teleport(-1);
    1100                 :          0 :     break;
    1101                 :          0 :   case 25: print1("The stone glows blue");
    1102                 :          0 :     morewait();
    1103                 :          0 :     print1("You feel a tingle of an unearthly intuition:");
    1104                 :          0 :     morewait();
    1105                 :          0 :     hint();
    1106                 :          0 :     break;
    1107                 :          0 :   case 27: print1("The stone glows navy blue");
    1108                 :          0 :     print2("A sudden shock of knowledge overcomes you.");
    1109                 :          0 :     morewait();
    1110                 :          0 :     clearmsg();
    1111                 :          0 :     identify(1);
    1112                 :          0 :     knowledge(1);
    1113                 :          0 :     break;
    1114                 :          0 :   case 29: print1("The stone glows blue-violet");
    1115                 :          0 :     print2("You feel forgetful.");
    1116         [ #  # ]:          0 :     for(i=0;i<NUMSPELLS;i++) 
    1117         [ #  # ]:          0 :       if (Spells[i].known) {
    1118                 :          0 :         Spells[i].known = FALSE;
    1119                 :          0 :         break;
    1120                 :            :       }
    1121                 :          0 :     break;
    1122                 :          0 :   case 31: print1("The stone glows violet");
    1123                 :          0 :     morewait();
    1124                 :          0 :     acquire(0);
    1125                 :          0 :     break;
    1126                 :          0 :   case 33: print1("The stone glows deep purple");
    1127                 :          0 :     print2("You vanish.");
    1128                 :          0 :     Player.status[INVISIBLE]+=10;
    1129                 :          0 :     break;
    1130                 :          0 :   case 35: print1("The stone glows ultraviolet");
    1131                 :          0 :     print2("All your hair rises up on end.... A bolt of lightning hits you!");
    1132                 :          0 :     p_damage(random_range(Player.maxhp),ELECTRICITY,"mystic lightning");
    1133                 :          0 :     break;
    1134                 :          0 :   case 37: print1("The stone glows roentgen");
    1135                 :          0 :     print2("You feel more experienced.");
    1136                 :          0 :     gain_experience((Player.level+1)*250);
    1137                 :          0 :     break;
    1138                 :          0 :   case 39: print1("The stone glows gamma"); 
    1139                 :          0 :     print2("Your left hand shines silvery, and your right emits a golden aura."); 
    1140                 :          0 :     morewait();
    1141                 :          0 :     enchant(1);
    1142                 :          0 :     bless(1);
    1143                 :          0 :     print3("Your hands stop glowing.");
    1144                 :          0 :     break;
    1145                 :            :   case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 48:case 49:
    1146                 :          0 :     print1("The stone glows cosmic!");
    1147                 :          0 :     print2("The stone's energy field quiets for a moment...");
    1148                 :          0 :     *stone = 50;
    1149                 :          0 :     cycle = TRUE;
    1150                 :          0 :     break;  
    1151                 :          0 :   default: print1("The stone glows polka-dot (?!?!?!?)");
    1152                 :          0 :     print2("You feel a strange twisting sensation....");
    1153                 :          0 :     morewait();
    1154                 :          0 :     *stone = 0;
    1155                 :          0 :     strategic_teleport(-1);
    1156                 :          0 :     break;
    1157                 :            :   }
    1158                 :          0 :   calc_melee();
    1159                 :          0 :   return(cycle);
    1160                 :            : }
    1161                 :            : 
    1162                 :          0 : void alert_guards(void)
    1163                 :            : {
    1164                 :          0 :   int foundguard=FALSE;
    1165                 :            :   pml ml;
    1166                 :          0 :   int suppress = 0;
    1167         [ #  # ]:          0 :   for(ml=Level->mlist;ml!=NULL;ml=ml->next)
    1168 [ #  # ][ #  # ]:          0 :     if (((ml->m->id == GUARD) ||
    1169 [ #  # ][ #  # ]:          0 :          ((ml->m->id == HISCORE_NPC) && (ml->m->aux2 == 15))) && /*justiciar*/
    1170                 :          0 :         (ml->m->hp > 0)) {
    1171                 :          0 :       foundguard=TRUE;
    1172                 :          0 :       m_status_set(ml->m,AWAKE);
    1173                 :          0 :       m_status_set(ml->m,HOSTILE);
    1174                 :            :     }
    1175         [ #  # ]:          0 :   if (foundguard) {
    1176                 :          0 :     mprint("You hear a whistle and the sound of running feet!");
    1177         [ #  # ]:          0 :     if (Current_Environment == E_CITY)
    1178                 :          0 :       Level->site[40][60].p_locf = L_NO_OP; /* pacify_guards restores this */
    1179                 :            :   }
    1180 [ #  # ][ #  # ]:          0 :   if ((! foundguard) && (Current_Environment == E_CITY) &&
                 [ #  # ]
    1181                 :          0 :       !gamestatusp(DESTROYED_ORDER)) {
    1182                 :          0 :     suppress = gamestatusp(SUPPRESS_PRINTING);
    1183                 :          0 :     resetgamestatus(SUPPRESS_PRINTING);
    1184                 :          0 :     print2("The last member of the Order of Paladins dies....");
    1185                 :          0 :     morewait();
    1186                 :          0 :     gain_experience(1000);
    1187                 :          0 :     Player.alignment -= 250;
    1188         [ #  # ]:          0 :     if (! gamestatusp(KILLED_LAWBRINGER)) {
    1189                 :          0 :       print1("A chime sounds from far away.... The sound grows stronger....");
    1190                 :          0 :       print2("Suddenly the great shadowy form of the LawBringer appears over");
    1191                 :          0 :       print3("the city. He points his finger at you....");
    1192                 :          0 :       morewait();
    1193                 :          0 :       print1("\"Cursed art thou, minion of chaos! May thy strength fail thee");
    1194                 :          0 :       print2("in thy hour of need!\" You feel an unearthly shiver as the");
    1195                 :          0 :       print3("LawBringer waves his palm across the city skies....");
    1196                 :          0 :       morewait();
    1197                 :          0 :       Player.str /= 2;
    1198                 :          0 :       dataprint();
    1199                 :          0 :       print1("You hear a bell tolling, and eerie moans all around you....");
    1200                 :          0 :       print2("Suddenly, the image of the LawBringer is gone.");
    1201                 :          0 :       print3("You hear a guardsman's whistle in the distance!");
    1202                 :          0 :       morewait();
    1203                 :          0 :       resurrect_guards();
    1204                 :            :     }
    1205                 :            :     else {
    1206                 :          0 :       print1("The Order's magical defenses have dropped, and the");
    1207                 :          0 :       print2("Legions of Chaos strike....");
    1208                 :          0 :       morewait();
    1209                 :          0 :       print1("The city shakes! An earthquake has struck!");
    1210                 :          0 :       print2("Cracks open in the street, and a chasm engulfs the Order HQ!");
    1211                 :          0 :       print3("Flames lick across the sky and you hear wild laughter....");
    1212                 :          0 :       morewait();
    1213                 :          0 :       gain_experience(5000);
    1214                 :          0 :       destroy_order();
    1215                 :            :     }
    1216                 :            :   }
    1217         [ #  # ]:          0 :   if (suppress)
    1218                 :          0 :     resetgamestatus(SUPPRESS_PRINTING);
    1219                 :          0 : }
    1220                 :            : 
    1221                 :            : 
    1222                 :            : /* can only occur when player is in city, so OK to use Level */
    1223                 :          0 : void destroy_order(void)
    1224                 :            : {
    1225                 :            :   int i,j;
    1226                 :          0 :   setgamestatus(DESTROYED_ORDER);
    1227         [ #  # ]:          0 :   if (Level != City) print1("Zounds! A Serious Mistake!");
    1228                 :            :   else 
    1229         [ #  # ]:          0 :     for(i=35;i<46;i++)
    1230         [ #  # ]:          0 :       for(j=60;j<63;j++) {
    1231 [ #  # ][ #  # ]:          0 :         if (i == 40 && (j == 60 || j == 61)) {
                 [ #  # ]
    1232                 :          0 :           lreset(i,j,SECRET);
    1233                 :          0 :           Level->site[i][j].locchar = FLOOR;
    1234                 :          0 :           Level->site[i][j].p_locf = L_NO_OP;
    1235                 :          0 :           lset(i, j, CHANGED);
    1236                 :            :         }
    1237                 :            :         else {
    1238                 :          0 :           Level->site[i][j].locchar = RUBBLE;
    1239                 :          0 :           Level->site[i][j].p_locf = L_RUBBLE;
    1240                 :          0 :           lset(i, j, CHANGED);
    1241                 :            :         }
    1242         [ #  # ]:          0 :         if (Level->site[i][j].creature != NULL) {
    1243                 :          0 :           Level->site[i][j].creature->hp = -1;
    1244                 :          0 :           Level->site[i][j].creature = NULL;
    1245                 :            :         }
    1246                 :          0 :         make_site_monster(i,j,GHOST);
    1247                 :          0 :         Level->site[i][j].creature->monstring = "ghost of a Paladin";
    1248                 :          0 :         m_status_set(Level->site[i][j].creature,HOSTILE);
    1249                 :            :       }
    1250                 :          0 : }
    1251                 :            : 
    1252                 :            : 
    1253                 :            : 
    1254                 :         25 : int maneuvers(void)
    1255                 :            : {
    1256                 :            :   int m;
    1257                 :            : 
    1258                 :         25 :   m = 2 + Player.level/7;
    1259         [ -  + ]:         25 :   if (Player.rank[ARENA]) m++;
    1260         [ -  + ]:         25 :   if (Player.status[HASTED])
    1261                 :          0 :     m *= 2;
    1262         [ -  + ]:         25 :   if (Player.status[SLOWED])
    1263                 :          0 :     m /= 2;
    1264         [ +  - ]:         25 :   m = min(8,max(1,m));
    1265                 :            :   
    1266                 :         25 :   return(m);
    1267                 :            : }
    1268                 :            : 
    1269                 :            : /* for when haste runs out, etc. */
    1270                 :          0 : void default_maneuvers(void)
    1271                 :            : {
    1272                 :            :   int i;
    1273                 :          0 :   morewait();
    1274                 :          0 :   clearmsg();
    1275                 :          0 :   print1("Warning, resetting your combat options to the default.");
    1276                 :          0 :   print2("Use the 'F' command to select which options you prefer.");
    1277                 :          0 :   morewait();
    1278         [ #  # ]:          0 :   for(i=0;i<maneuvers();i+=2) {
    1279                 :          0 :     Player.meleestr[i*2]='A';
    1280                 :          0 :     Player.meleestr[(i*2)+1]='C';
    1281                 :          0 :     Player.meleestr[(i+1)*2]='B';
    1282                 :          0 :     Player.meleestr[((i+1)*2)+1]='C';
    1283                 :            :   }
    1284                 :          0 :   Player.meleestr[maneuvers()*2]=0;
    1285                 :          0 : }

Generated by: LCOV version 1.11