LCOV - code coverage report
Current view: top level - omega-rpg-0.90-pa9 - effect1.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 30 548 5.5 %
Date: 2017-09-08 22:00:26 Functions: 3 20 15.0 %
Branches: 20 343 5.8 %

           Branch data     Line data    Source code
       1                 :            : /* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
       2                 :            : /* effect1.c */
       3                 :            : 
       4                 :            : #include "glob.h"
       5                 :            : 
       6                 :            : 
       7                 :            : /* enchant */
       8                 :          0 : void enchant(int delta)
       9                 :            : {
      10                 :          0 :   int i,used = FALSE;
      11                 :            :   long change_cash;
      12                 :            : 
      13         [ #  # ]:          0 :   if (delta < 0) {
      14                 :          0 :     i = random_item();
      15 [ #  # ][ #  # ]:          0 :     if (i == ABORT || Player.possessions[i]->usef == I_NOTHING ||
                 [ #  # ]
      16         [ #  # ]:          0 :         Player.possessions[i]->usef == I_NO_OP ||
      17         [ #  # ]:          0 :         Player.possessions[i]->usef == I_NORMAL_ARMOR ||
      18         [ #  # ]:          0 :         Player.possessions[i]->usef == I_NORMAL_WEAPON ||
      19         [ #  # ]:          0 :         Player.possessions[i]->usef == I_NORMAL_SHIELD ||
      20         [ #  # ]:          0 :         Player.possessions[i]->objchar == FOOD ||
      21                 :          0 :         Player.possessions[i]->objchar == MISSILEWEAPON) {
      22                 :          0 :       print1("You feel fortunate.");
      23                 :          0 :       morewait();
      24                 :            :     }
      25 [ #  # ][ #  # ]:          0 :     else if (Player.possessions[i]->blessing < 0 ||
      26         [ #  # ]:          0 :       (Player.possessions[i]->objchar == ARTIFACT && random_range(3))) {
      27         [ #  # ]:          0 :         if (Player.possessions[i]->uniqueness == COMMON)
      28                 :          0 :           print1("Your ");
      29                 :          0 :         nprint1(itemid(Player.possessions[i]));
      30                 :          0 :         nprint1(" glows, but the glow flickers out...");
      31                 :          0 :         morewait();
      32                 :            :     }
      33                 :            :     else {
      34                 :          0 :       used = (Player.possessions[i]->used);
      35         [ #  # ]:          0 :       if (used) {
      36                 :          0 :         Player.possessions[i]->used = FALSE;
      37                 :          0 :         item_use(Player.possessions[i]);
      38                 :            :       } 
      39         [ #  # ]:          0 :       if (Player.possessions[i]->uniqueness == COMMON)
      40                 :          0 :         print1("Your ");
      41                 :          0 :       nprint1(itemid(Player.possessions[i]));
      42                 :          0 :       nprint1(" radiates an aura of mundanity!");
      43                 :          0 :       morewait();
      44                 :          0 :       Player.possessions[i]->plus = 0;
      45                 :          0 :       Player.possessions[i]->charge = -1;
      46                 :          0 :       Player.possessions[i]->usef = I_NOTHING;
      47         [ #  # ]:          0 :       if (used) {
      48                 :          0 :         Player.possessions[i]->used = TRUE;
      49                 :          0 :         item_use(Player.possessions[i]);      
      50                 :            :       }
      51                 :            :     }
      52                 :            :   }
      53                 :            :   else {
      54                 :          0 :     i = getitem(CASH);
      55         [ #  # ]:          0 :     if (i == ABORT) {
      56                 :          0 :       print1("You feel unlucky.");
      57                 :          0 :       morewait();
      58                 :            :     }
      59         [ #  # ]:          0 :     else if (i == CASHVALUE) {
      60                 :          0 :       print1("You enchant your money.... What a concept!");
      61                 :          0 :       change_cash = Player.cash*(random_range(7) - 3)/6;
      62         [ #  # ]:          0 :       if (change_cash > 0) print2("Seems to have been a good idea!");
      63                 :          0 :       else print2("Maybe it wasn't such a good idea....");
      64                 :          0 :       Player.cash += change_cash;
      65                 :          0 :       morewait();
      66                 :            :     }
      67         [ #  # ]:          0 :     else if (Player.possessions[i]->objchar == ARTIFACT) {
      68         [ #  # ]:          0 :       if (Player.possessions[i]->usef !=
      69                 :          0 :         Objects[Player.possessions[i]->id].usef) {
      70                 :          0 :         print1("It re-acquires its magical aura!");
      71                 :          0 :         Player.possessions[i]->usef = Objects[Player.possessions[i]->id].usef;
      72                 :            :       }
      73                 :            :       else {
      74                 :          0 :         print1("The enchantment spell enfolds the ");
      75                 :          0 :         nprint1(itemid(Player.possessions[i]));
      76                 :          0 :         print2("and the potent enchantment of the Artifact causes a backlash!");
      77                 :          0 :         morewait();
      78                 :          0 :         clearmsg();
      79                 :          0 :         manastorm(Player.x,Player.y,Player.possessions[i]->level*5);
      80                 :            :       }
      81                 :            :     }
      82                 :            :     else {
      83         [ #  # ]:          0 :       if (abs(Player.possessions[i]->plus) > random_range(20)+1) {
      84                 :          0 :         print1("Uh-oh, the force of the enchantment was too much!");
      85                 :          0 :         print2("There is a loud explosion!");
      86                 :          0 :         morewait();
      87                 :          0 :         manastorm(Player.x,Player.y,abs(Player.possessions[i]->plus)*5);
      88                 :          0 :         dispose_lost_objects(1,Player.possessions[i]);
      89                 :            :       }
      90                 :            :       else {
      91                 :          0 :         used = (Player.possessions[i]->used);
      92         [ #  # ]:          0 :         if (used) {
      93                 :          0 :           setgamestatus(SUPPRESS_PRINTING);
      94                 :          0 :           Player.possessions[i]->used = FALSE;
      95                 :          0 :           item_use(Player.possessions[i]);
      96                 :          0 :           resetgamestatus(SUPPRESS_PRINTING);
      97                 :            :         }
      98                 :          0 :         print1("The item shines!");
      99                 :          0 :         morewait();
     100                 :          0 :         Player.possessions[i]->plus += delta+1;
     101         [ #  # ]:          0 :         if (Player.possessions[i]->charge > -1)
     102                 :          0 :           Player.possessions[i]->charge += 
     103                 :          0 :             ((delta+1) * (random_range(10) + 1));
     104         [ #  # ]:          0 :         if (used) {
     105                 :          0 :           setgamestatus(SUPPRESS_PRINTING);
     106                 :          0 :           Player.possessions[i]->used = TRUE;
     107                 :          0 :           item_use(Player.possessions[i]);      
     108                 :          0 :           resetgamestatus(SUPPRESS_PRINTING);
     109                 :            :         }
     110                 :            :       }
     111                 :            :     }
     112                 :          0 :     calc_melee();
     113                 :            :   }
     114                 :          0 : }
     115                 :            : 
     116                 :            : /* bless */
     117                 :          0 : void bless(int blessing)
     118                 :            : {
     119                 :            :   int index,used;
     120                 :            : 
     121         [ #  # ]:          0 :   if (blessing < 0) {
     122                 :          0 :     index = random_item();
     123         [ #  # ]:          0 :     if (index == ABORT) {
     124                 :          0 :       print1("You feel fortunate.");
     125                 :          0 :       morewait();
     126                 :            :     }
     127                 :            :     else {
     128                 :          0 :       print1("A foul odor arises from ");
     129         [ #  # ]:          0 :       if (Player.possessions[index]->uniqueness == COMMON)
     130                 :          0 :         nprint1("your ");
     131                 :          0 :       nprint1(itemid(Player.possessions[index]));
     132                 :          0 :       morewait();
     133                 :          0 :       used = (Player.possessions[index]->used);
     134         [ #  # ]:          0 :       if (used) {
     135                 :          0 :         setgamestatus(SUPPRESS_PRINTING);
     136                 :          0 :         Player.possessions[index]->used = FALSE;
     137                 :          0 :         item_use(Player.possessions[index]);
     138                 :          0 :         resetgamestatus(SUPPRESS_PRINTING);
     139                 :            :       }
     140                 :          0 :       Player.possessions[index]->blessing -= 2;
     141         [ #  # ]:          0 :       if (Player.possessions[index]->blessing < 0) 
     142                 :          0 :         Player.possessions[index]->plus =
     143                 :          0 :           abs(Player.possessions[index]->plus) - 1;
     144         [ #  # ]:          0 :       if (used) {
     145                 :          0 :         setgamestatus(SUPPRESS_PRINTING);
     146                 :          0 :         Player.possessions[index]->used = TRUE;
     147                 :          0 :         item_use(Player.possessions[index]);      
     148                 :          0 :         resetgamestatus(SUPPRESS_PRINTING);
     149                 :            :       }
     150                 :            :     }
     151                 :            :   }
     152                 :            :   else {
     153                 :          0 :     index = getitem(NULL_ITEM);
     154         [ #  # ]:          0 :     if (index == CASHVALUE) {
     155                 :          0 :       print1("Blessing your money has no effect.");
     156                 :          0 :       morewait();
     157                 :            :     }
     158         [ #  # ]:          0 :     else if (index != ABORT) {
     159                 :          0 :       used = (Player.possessions[index]->used == TRUE);
     160         [ #  # ]:          0 :       if (used) {
     161                 :          0 :         setgamestatus(SUPPRESS_PRINTING);
     162                 :          0 :         Player.possessions[index]->used = FALSE;
     163                 :          0 :         item_use(Player.possessions[index]);      
     164                 :          0 :         resetgamestatus(SUPPRESS_PRINTING);
     165                 :            :       }
     166                 :          0 :       print1("A pure white light surrounds the item... ");
     167         [ #  # ]:          0 :       if (Player.possessions[index]->blessing < 0-(blessing+1)) {
     168                 :          0 :         print2("which is evil enough to resist the effect of the blessing!");
     169                 :          0 :         morewait();
     170                 :            :       }
     171         [ #  # ]:          0 :       else if (Player.possessions[index]->blessing < -1) {
     172                 :          0 :         print2("which disintegrates under the influence of the holy aura!");
     173                 :          0 :         morewait();
     174                 :          0 :         Player.itemweight -=  Player.possessions[index]->weight;
     175                 :          0 :         dispose_lost_objects(1,Player.possessions[index]);
     176                 :            :       }
     177         [ #  # ]:          0 :       else if (Player.possessions[index]->blessing < blessing+1) {
     178                 :          0 :         print2("which now seems affected by afflatus!");
     179                 :          0 :         morewait();
     180                 :          0 :         Player.possessions[index]->blessing++;
     181                 :          0 :         Player.possessions[index]->plus =
     182                 :          0 :           abs(Player.possessions[index]->plus)+1;
     183                 :            :       }
     184                 :            :       else {
     185                 :          0 :         print2("The hierolux fades without any appreciable effect....");
     186                 :          0 :         morewait();
     187                 :            :       }
     188 [ #  # ][ #  # ]:          0 :       if (used && (Player.possessions[index] != NULL)) {
     189                 :          0 :         setgamestatus(SUPPRESS_PRINTING);
     190                 :          0 :         Player.possessions[index]->used = TRUE;
     191                 :          0 :         item_use(Player.possessions[index]);     
     192                 :          0 :         resetgamestatus(SUPPRESS_PRINTING);
     193                 :            :       } 
     194                 :            :     }
     195                 :            :   }
     196                 :          0 :   calc_melee();
     197                 :          0 : }
     198                 :            : 
     199                 :            : 
     200                 :            : 
     201                 :          1 : void heal(int amount)
     202                 :            : {
     203         [ +  - ]:          1 :   if (amount > -1) {
     204                 :          1 :       mprint("You feel better.");
     205         [ +  - ]:          1 :     if (Player.hp < Player.maxhp + amount)
     206                 :            :     {
     207                 :          1 :       Player.hp += random_range(10*amount)+1;
     208         [ -  + ]:          1 :       if (Player.hp > Player.maxhp)
     209                 :          0 :         Player.hp = Player.maxhp + amount;
     210                 :            :     }
     211                 :          1 :     Player.status[BLINDED] = 0;
     212                 :            :   }
     213                 :            :   else {
     214                 :          0 :     mprint("You feel unwell.");
     215                 :          0 :     Player.hp -= random_range(10*abs(amount)+1);
     216         [ #  # ]:          0 :     if (Player.hp < 0)
     217                 :          0 :       p_death("magical disruption");
     218                 :            :   }
     219                 :          1 :   dataprint();
     220                 :          1 : }
     221                 :            : 
     222                 :            : 
     223                 :          0 : void fbolt(int fx, int fy, int tx, int ty, int hit, int dmg)
     224                 :            : {
     225                 :          0 :   bolt(fx,fy,tx,ty,hit,dmg,FLAME);
     226                 :          0 : }
     227                 :            : 
     228                 :          0 : void lbolt(int fx, int fy, int tx, int ty, int hit, int dmg)
     229                 :            : {
     230                 :          0 :   bolt(fx,fy,tx,ty,hit,dmg,ELECTRICITY);
     231                 :          0 : }
     232                 :            : 
     233                 :            : /* Added 12/30/98 DG */
     234                 :          0 : void icebolt(int fx, int fy, int tx, int ty, int hit, int dmg)
     235                 :            : {
     236                 :          0 :   bolt(fx,fy,tx,ty,hit,dmg,COLD);
     237                 :          0 : }
     238                 :            : 
     239                 :          0 : void nbolt(int fx, int fy, int tx, int ty, int hit, int dmg)
     240                 :            : {
     241                 :          0 :   bolt(fx,fy,tx,ty,hit,dmg,NORMAL_DAMAGE);
     242                 :          0 : }
     243                 :            : 
     244                 :            : 
     245                 :            : /* from f to t */
     246                 :          0 : void bolt(int fx, int fy, int tx, int ty, int hit, int dmg, int dtype)
     247                 :            : {
     248                 :            :   int xx,yy;
     249                 :            :   struct monster *target;
     250                 :          0 :   Symbol boltchar = '?';
     251                 :          0 :   xx = fx; yy = fy;
     252                 :            :   
     253   [ #  #  #  #  :          0 :   switch(dtype) {
                      # ]
     254                 :          0 :     case FLAME:boltchar=('*' | CLR(LIGHT_RED));break;
     255                 :          0 :     case ELECTRICITY:boltchar = ('^' | CLR(LIGHT_BLUE));break;
     256                 :          0 :     case NORMAL_DAMAGE:boltchar = ('!' | CLR(BROWN));break;
     257                 :          0 :     case COLD:boltchar=('o' | CLR(WHITE));break;
     258                 :          0 :     default:assert(FALSE); /* this should never happen, right? WDT */
     259                 :            :   }
     260                 :          0 :   clearmsg();
     261                 :            : 
     262                 :          0 :   do_los(boltchar,&xx,&yy,tx,ty);
     263                 :            : 
     264 [ #  # ][ #  # ]:          0 :   if ((xx == Player.x) && (yy == Player.y)) {
     265         [ #  # ]:          0 :     if (Player.status[DEFLECTION] > 0) 
     266                 :          0 :       mprint("The bolt just missed you!");
     267                 :            :     else {
     268   [ #  #  #  #  :          0 :       switch (dtype) {
                      # ]
     269                 :            :       case FLAME:
     270                 :          0 :         mprint("You were blasted by a firebolt!");
     271                 :          0 :         p_damage(random_range(dmg),dtype,"a firebolt");
     272                 :          0 :         break;
     273                 :            :       case ELECTRICITY:
     274                 :          0 :         mprint("You were zapped by lightning!");
     275                 :          0 :         p_damage(random_range(dmg),dtype,"a bolt of lightning");
     276                 :          0 :         break;
     277                 :            :       case NORMAL_DAMAGE:
     278                 :          0 :         mprint("You were hit by a missile!");
     279                 :          0 :         p_damage(random_range(dmg),dtype,"a missile");
     280                 :          0 :         break;
     281                 :            :       case COLD:
     282                 :          0 :         mprint("You were hit by an icicle!");
     283                 :          0 :         p_damage(random_range(dmg),dtype,"an icicle");
     284                 :          0 :         break;
     285                 :            :       }
     286                 :            :     }
     287                 :            :   }
     288         [ #  # ]:          0 :   else if (NULL != (target = Level->site[xx][yy].creature)) {
     289         [ #  # ]:          0 :     if (hitp(hit,target->ac)) {
     290         [ #  # ]:          0 :       if (target->uniqueness == COMMON) {
     291                 :          0 :         strcpy(Str1,"The ");
     292                 :          0 :         strcat(Str1,target->monstring);
     293                 :            :       }
     294                 :          0 :       else strcpy(Str1,target->monstring);
     295   [ #  #  #  #  :          0 :       switch (dtype) {
                      # ]
     296                 :            :         /* WDT: these sentances really ought to be livened up.  Especially
     297                 :            :          * in full verbose mode. */
     298                 :          0 :       case FLAME:strcat(Str1," was blasted by a firebolt!");break;
     299                 :          0 :       case ELECTRICITY:strcat(Str1," was zapped by lightning!");break;
     300                 :          0 :       case NORMAL_DAMAGE:strcat(Str1," was hit by a missile!"); break;
     301                 :          0 :       case COLD:strcat(Str1," was hit by an icicle!"); break;
     302                 :            :       }
     303                 :          0 :       mprint(Str1);
     304                 :          0 :       m_status_set(target,HOSTILE);
     305                 :          0 :       m_damage(target,random_range(dmg),dtype);
     306                 :            :     }
     307                 :            :     else {
     308         [ #  # ]:          0 :       if (target->uniqueness == COMMON) {
     309                 :          0 :         strcpy(Str1,"The ");
     310                 :          0 :         strcat(Str1,target->monstring);
     311                 :            :       }
     312                 :          0 :       else strcpy(Str1,target->monstring);
     313   [ #  #  #  #  :          0 :       switch (dtype) {
                      # ]
     314                 :          0 :       case FLAME:strcat(Str1," was missed by a firebolt!");break;
     315                 :          0 :       case ELECTRICITY:strcat(Str1," was missed by lightning!");break;
     316                 :          0 :       case NORMAL_DAMAGE:strcat(Str1," was missed by a missile!"); break;
     317                 :          0 :       case COLD:strcat(Str1," was missed by a flying icicle!"); break;
     318                 :            :       }
     319                 :          0 :       mprint(Str1);
     320                 :            :     }
     321                 :            :   }
     322         [ #  # ]:          0 :   else if (Level->site[xx][yy].locchar == HEDGE)
     323         [ #  # ]:          0 :     if (Level->site[xx][yy].p_locf != L_TRIFID) {
     324 [ #  # ][ #  # ]:          0 :       if ((dtype == FLAME)||(dtype == ELECTRICITY)) {
     325                 :          0 :         mprint("The hedge is blasted away!");
     326                 :          0 :         Level->site[xx][yy].p_locf = L_NO_OP;
     327                 :          0 :         Level->site[xx][yy].locchar = FLOOR;
     328                 :          0 :         plotspot(xx, yy, TRUE);
     329                 :          0 :         lset(xx, yy, CHANGED);
     330                 :            :       }
     331                 :          0 :       else mprint("The hedge is unaffected.");
     332                 :            :     }
     333                 :          0 :     else mprint("The trifid absorbs the energy and laughs!");
     334         [ #  # ]:          0 :   else if (Level->site[xx][yy].locchar == WATER)
     335         [ #  # ]:          0 :     if (dtype == FLAME) {
     336                 :          0 :       mprint("The water is vaporised!");
     337                 :          0 :       Level->site[xx][yy].p_locf = L_NO_OP;
     338                 :          0 :       Level->site[xx][yy].locchar = FLOOR;
     339                 :          0 :       lset(xx, yy, CHANGED);
     340                 :            :     }
     341                 :          0 : }
     342                 :            : 
     343                 :            : 
     344                 :          0 : void lball(int fx, int fy, int tx, int ty, int dmg)
     345                 :            : {
     346                 :          0 :   ball(fx,fy,tx,ty,dmg,ELECTRICITY);
     347                 :          0 : }
     348                 :            : 
     349                 :          0 : void manastorm(int x, int y, int dmg)
     350                 :            : {
     351                 :          0 :   ball(x,y,x,y,dmg,UNSTOPPABLE);
     352                 :          0 : }
     353                 :            : 
     354                 :          0 : void snowball(int fx, int fy, int tx, int ty, int dmg)
     355                 :            : {
     356                 :          0 :   ball(fx,fy,tx,ty,dmg,COLD);
     357                 :          0 : }
     358                 :            : 
     359                 :          0 : void fball(int fx, int fy, int tx, int ty, int dmg)
     360                 :            : {
     361                 :          0 :   ball(fx,fy,tx,ty,dmg,FLAME);
     362                 :          0 : }
     363                 :            : 
     364                 :            : 
     365                 :            : /* from f to t */
     366                 :          0 : void ball(int fx, int fy, int tx, int ty, int dmg, int dtype)
     367                 :            : {
     368                 :            :   int xx,yy,ex,ey,i;
     369                 :            :   struct monster *target;
     370                 :          0 :   Symbol expchar=('@' | CLR(LIGHT_PURPLE));
     371                 :            : 
     372                 :          0 :   xx = fx; yy = fy;
     373                 :            : 
     374   [ #  #  #  # ]:          0 :   switch(dtype){
     375                 :          0 :     case FLAME:expchar=('*' | CLR(LIGHT_RED));break;
     376                 :          0 :     case COLD:expchar=('o' | CLR(WHITE));break;
     377                 :          0 :     case ELECTRICITY:expchar=('^' | CLR(LIGHT_BLUE));break;
     378                 :            :   }
     379                 :            : 
     380                 :          0 :   do_los(expchar,&xx,&yy,tx,ty);
     381                 :          0 :   draw_explosion(expchar,xx,yy);
     382         [ #  # ]:          0 :   for(i=0;i<9;i++) {
     383                 :          0 :     ex = xx + Dirs[0][i];
     384                 :          0 :     ey = yy + Dirs[1][i];
     385                 :            : 
     386         [ #  # ]:          0 :     if(offscreen(ex, ey))
     387                 :          0 :       continue;
     388                 :            :     
     389 [ #  # ][ #  # ]:          0 :     if ((ex == Player.x) && (ey == Player.y)) {
     390   [ #  #  #  #  :          0 :       switch(dtype) {
                      # ]
     391                 :          0 :         case FLAME:mprint("You were blasted by a fireball!");
     392                 :          0 :           p_damage(random_range(dmg),FLAME,"a fireball");
     393                 :          0 :           break;
     394                 :          0 :         case COLD:mprint("You were blasted by a snowball!");
     395                 :          0 :           p_damage(random_range(dmg),COLD,"a snowball");
     396                 :          0 :           break;
     397                 :          0 :         case ELECTRICITY:mprint("You were blasted by ball lightning!");
     398                 :          0 :           p_damage(random_range(dmg),ELECTRICITY,"ball lightning");
     399                 :          0 :           break;
     400                 :          0 :         case UNSTOPPABLE:mprint("Oh No! Manastorm!");
     401                 :          0 :           p_damage(random_range(dmg),UNSTOPPABLE,"a manastorm!");
     402                 :          0 :           break;
     403                 :            :       }
     404                 :            :     }
     405         [ #  # ]:          0 :     if (NULL != (target = Level->site[ex][ey].creature)) {
     406         [ #  # ]:          0 :       if (los_p(Player.x,Player.y,target->x,target->y)) {
     407         [ #  # ]:          0 :       if (target->uniqueness == COMMON) {
     408                 :          0 :         strcpy(Str1,"The ");
     409                 :          0 :         strcat(Str1,target->monstring);
     410                 :            :       }
     411                 :          0 :       else strcpy(Str1,target->monstring);
     412   [ #  #  #  #  :          0 :         switch(dtype) {
                      # ]
     413                 :          0 :           case FLAME:strcat(Str1," was zorched by a fireball!"); break;
     414                 :          0 :           case COLD:strcat(Str1," was blasted by a snowball!"); break;
     415                 :          0 :           case ELECTRICITY:strcat(Str1," was zapped by ball lightning!");break;
     416                 :          0 :           case UNSTOPPABLE:strcat(Str1," was nuked by a manastorm!");break;
     417                 :            :         }
     418                 :          0 :         mprint(Str1);
     419                 :            :       }
     420                 :          0 :       m_status_set(target,HOSTILE);
     421                 :          0 :       m_damage(target,random_range(dmg),dtype);
     422                 :            :     }
     423         [ #  # ]:          0 :     if (Level->site[ex][ey].locchar == HEDGE)
     424         [ #  # ]:          0 :       if (Level->site[ex][ey].p_locf != L_TRIFID) {
     425 [ #  # ][ #  # ]:          0 :         if ((dtype == FLAME)||(dtype == ELECTRICITY)) {
     426                 :          0 :           mprint("The hedge is blasted away!");
     427                 :          0 :           Level->site[ex][ey].p_locf = L_NO_OP;
     428                 :          0 :           Level->site[ex][ey].locchar = FLOOR;
     429                 :          0 :           plotspot(ex,ey,TRUE);
     430                 :          0 :           lset(ex, ey, CHANGED);
     431                 :            :         }
     432                 :          0 :         else mprint("The hedge is unaffected.");
     433                 :            :       }
     434                 :          0 :       else mprint("The trifid absorbs the energy and laughs!");
     435         [ #  # ]:          0 :     else if (Level->site[ex][ey].locchar == WATER)
     436         [ #  # ]:          0 :       if (dtype == FLAME) {
     437                 :          0 :         mprint("The water is vaporised!");
     438                 :          0 :         Level->site[ex][ey].p_locf = L_NO_OP;
     439                 :          0 :         Level->site[ex][ey].locchar = FLOOR;
     440                 :          0 :         plotspot(ex,ey,TRUE);
     441                 :          0 :         lset(ex, ey, CHANGED);
     442                 :            :       }
     443                 :            :   }
     444                 :          0 : }
     445                 :            : 
     446                 :          0 : void mondet(int blessing)
     447                 :            : {
     448                 :            :   pml ml;
     449         [ #  # ]:          0 :   for (ml=Level->mlist;ml!=NULL;ml=ml->next) 
     450         [ #  # ]:          0 :     if (ml->m->hp > 0) /* FIXED 12/30/98 DG */
     451                 :            :     {
     452         [ #  # ]:          0 :       if (blessing > -1)
     453                 :          0 :         plotmon(ml->m);
     454                 :            :       else
     455                 :          0 :         putspot(random_range(Level->level_width), random_range(Level->level_length),
     456                 :          0 :             Monsters[random_range(NUMMONSTERS)].monchar);
     457                 :            :     }
     458                 :          0 :   levelrefresh();
     459                 :          0 :   morewait();
     460                 :          0 :   show_screen();
     461                 :          0 : }
     462                 :            : 
     463                 :            : 
     464                 :          0 : void objdet(int blessing)
     465                 :            : {
     466                 :            :   int i,j;
     467         [ #  # ]:          0 :   for (i=0;i<Level->level_width;i++)
     468         [ #  # ]:          0 :     for (j=0;j<Level->level_length;j++) 
     469         [ #  # ]:          0 :       if (Level->site[i][j].things != NULL) {
     470         [ #  # ]:          0 :         if (blessing < 0)
     471                 :          0 :           putspot(random_range(Level->level_width),
     472                 :          0 :                   random_range(Level->level_length),
     473                 :          0 :                   Level->site[i][j].things->thing->objchar);
     474                 :          0 :         else putspot(i,j,Level->site[i][j].things->thing->objchar);
     475                 :            :       }
     476                 :          0 :   levelrefresh();
     477                 :          0 :   morewait();
     478                 :          0 :   show_screen();
     479                 :          0 : }
     480                 :            : 
     481                 :          0 : void identify(int blessing)
     482                 :            : {
     483                 :            :   int index;
     484                 :            : 
     485                 :          0 :   clearmsg();
     486                 :            : 
     487         [ #  # ]:          0 :   if (blessing == 0) {
     488                 :          0 :     index = getitem_prompt("Identify: ", NULL_ITEM);
     489         [ #  # ]:          0 :     if (index == CASHVALUE) print3("Your money is really money.");
     490         [ #  # ]:          0 :     else if (index == ABORT)
     491                 :          0 :       setgamestatus(SKIP_MONSTERS);
     492                 :            :     else {
     493         [ #  # ]:          0 :       if (Player.possessions[index]->objchar == FOOD)
     494                 :          0 :         Player.possessions[index]->known = 1;
     495                 :            :       else {
     496                 :          0 :         Player.possessions[index]->known = 2;
     497                 :          0 :         Objects[Player.possessions[index]->id].known = 1;
     498                 :            :       }
     499                 :          0 :       print1("Identified: ");
     500                 :          0 :       mprint(itemid(Player.possessions[index]));
     501                 :            :     }
     502                 :            :   }
     503         [ #  # ]:          0 :   else if (blessing < 0) {
     504                 :          0 :     print2("You feel forgetful.");
     505         [ #  # ]:          0 :     for (index=0;index<MAXITEMS;index++) 
     506         [ #  # ]:          0 :       if (Player.possessions[index] != NULL) {
     507                 :          0 :         Player.possessions[index]->known = 0;
     508                 :          0 :         Objects[Player.possessions[index]->id].known = 0;
     509                 :            :       }
     510                 :            :   }
     511                 :            :   else {
     512                 :          0 :     print2("You feel encyclopaedic.");
     513         [ #  # ]:          0 :     for (index=0;index<MAXITEMS;index++)
     514         [ #  # ]:          0 :       if (Player.possessions[index] != NULL) {
     515         [ #  # ]:          0 :         if (Player.possessions[index]->objchar == FOOD)
     516                 :          0 :           Player.possessions[index]->known = 1;
     517                 :            :         else {
     518                 :          0 :           Player.possessions[index]->known = 2;
     519                 :          0 :           Objects[Player.possessions[index]->id].known = 1;
     520                 :            :         }
     521                 :            :       }
     522         [ #  # ]:          0 :     for (index=0;index<Player.packptr;index++)
     523         [ #  # ]:          0 :       if (Player.pack[index] != NULL) {
     524         [ #  # ]:          0 :         if (Player.pack[index]->objchar == FOOD)
     525                 :          0 :           Player.pack[index]->known = 1;
     526                 :            :         else {
     527                 :          0 :           Player.pack[index]->known = 2;
     528                 :          0 :           Objects[Player.pack[index]->id].known = 1;
     529                 :            :         }
     530                 :            :       }
     531                 :            :   }
     532                 :          0 :   calc_melee();
     533                 :          0 : }
     534                 :            : 
     535                 :            : 
     536                 :            : /* returns index of random item, ABORT if player carrying none */
     537                 :          5 : int random_item(void)
     538                 :            : {
     539                 :          5 :   int item = ABORT,tries=0;
     540                 :          5 :   int number = 0;
     541                 :            : 
     542         [ +  + ]:         85 :   for(tries=0; tries<MAXITEMS; tries++)
     543         [ +  + ]:         80 :     if (Player.possessions[tries] != NULL) {
     544                 :         40 :       number++;
     545         [ +  + ]:         40 :       if (random_range(number) == 0)
     546                 :         13 :         item = tries;
     547                 :            :     }
     548                 :          5 :   return(item);
     549                 :            : }
     550                 :            :   
     551                 :            : /* returns index of an item to steal, ABORT if player carrying none */
     552                 :         11 : int stolen_item(void)
     553                 :            : {
     554                 :            :   int idx;
     555                 :            :   int nextitem;
     556                 :            : 
     557                 :            :   int cards[MAXITEMS];
     558                 :            : 
     559                 :         11 :   nextitem = 0;
     560                 :            : 
     561                 :            :   /* look for bank cards */
     562         [ +  + ]:        187 :   for (idx = 0; idx < MAXITEMS; ++idx)
     563                 :            :     {
     564         [ +  + ]:        176 :       if (0 == Player.possessions[idx]) continue;
     565         [ -  + ]:         88 :       if (Player.possessions[idx]->id < OB_DEBIT_CARD) continue;
     566         [ +  + ]:         88 :       if (Player.possessions[idx]->id > OB_SMART_CARD) continue;
     567                 :            : 
     568                 :         11 :       cards[nextitem++] = idx;
     569                 :            :     }
     570                 :            : 
     571         [ -  + ]:         11 :   if (0 == nextitem) return random_item();
     572                 :            : 
     573         [ -  + ]:         11 :   if (nextitem > 1)
     574                 :          0 :     shuffle(cards, nextitem);
     575                 :            : 
     576         [ +  + ]:         11 :   if (random_range(100) < 75)
     577                 :            :     {
     578                 :            :       /* oh that sucks... */
     579                 :          6 :       return cards[0];
     580                 :            :     }
     581                 :            : 
     582                 :         11 :   return random_item();
     583                 :            : }
     584                 :            :   
     585                 :            : /* various kinds of wishes */
     586                 :          0 : void wish(int blessing)
     587                 :            : {
     588                 :            :   int i;
     589                 :            :   char wishstr[80];
     590                 :          0 :   clearmsg();
     591                 :          0 :   print1("What do you wish for? ");
     592         [ #  # ]:          0 :   if (blessing < 0)
     593                 :          0 :     deathprint();
     594                 :            :   else
     595                 :          0 :     strcpy(wishstr,msgscanstring());
     596 [ #  # ][ #  # ]:          0 :   if (blessing < 0 || strcmp(wishstr,"Death")==0) {
     597                 :          0 :     print2("As you wish, so shall it be.");
     598                 :          0 :     p_death("a deathwish");
     599                 :            :   }
     600         [ #  # ]:          0 :   if (strcmp(wishstr,"Power")==0) {
     601                 :          0 :     print2("You feel a sudden surge of energy");
     602                 :          0 :     Player.mana=calcmana()*10;
     603                 :            :   }
     604         [ #  # ]:          0 :   else if (strcmp(wishstr,"Skill")==0) {
     605                 :          0 :     print2("You feel more competent.");
     606         [ #  # ]:          0 :     if (gamestatusp(CHEATED))
     607                 :          0 :       gain_experience(10000);
     608                 :            :     else
     609                 :          0 :       gain_experience(min(10000,Player.xp));
     610                 :            :   }
     611         [ #  # ]:          0 :   else if (strcmp(wishstr,"Wealth")==0) {
     612                 :          0 :     print2("You are submerged in shower of gold pieces!");
     613                 :          0 :     Player.cash += 10000;
     614                 :            :   }
     615         [ #  # ]:          0 :   else if (strcmp(wishstr,"Balance")==0) {
     616                 :          0 :     print2("You feel neutral.");
     617                 :          0 :     Player.alignment = 0;
     618                 :            :   }
     619         [ #  # ]:          0 :   else if (strcmp(wishstr,"Chaos")==0) {
     620                 :          0 :     print2("You feel chaotic.");
     621                 :          0 :     Player.alignment -= 25;
     622                 :            :   }
     623         [ #  # ]:          0 :   else if (strcmp(wishstr,"Law")==0) {
     624                 :          0 :     print2("You feel lawful.");
     625                 :          0 :     Player.alignment += 25;
     626                 :            :   }
     627         [ #  # ]:          0 :   else if (strcmp(wishstr,"Location")==0)
     628                 :          0 :     strategic_teleport(1);
     629         [ #  # ]:          0 :   else if (strcmp(wishstr,"Knowledge")==0) {
     630                 :          0 :     print2("You feel more knowledgeable.");
     631                 :          0 :     i = random_range(NUMSPELLS);
     632         [ #  # ]:          0 :     if (Spells[i].known) 
     633         [ #  # ]:          0 :       Spells[i].powerdrain =
     634                 :          0 :         (max(1,Spells[i].powerdrain/2));
     635                 :          0 :     else Spells[i].known = TRUE;
     636                 :            :   }
     637         [ #  # ]:          0 :   else if (strcmp(wishstr,"Health")==0) {
     638                 :          0 :     print2("You feel vigorous");
     639                 :          0 :     Player.hp = max( Player.hp, Player.maxhp);
     640                 :          0 :     Player.status[DISEASED] = 0;
     641                 :          0 :     Player.status[POISONED] = 0;
     642                 :          0 :     Player.food = 43;
     643                 :            :     /* Wish for Health when starving does some good. PGM */
     644                 :            :   }
     645         [ #  # ]:          0 :   else if (strcmp(wishstr,"Destruction")==0)
     646                 :          0 :     annihilate(gamestatusp(CHEATED));
     647         [ #  # ]:          0 :   else if (strcmp(wishstr,"Acquisition")==0)
     648                 :          0 :     acquire(gamestatusp(CHEATED));
     649         [ #  # ]:          0 :   else if (strcmp(wishstr,"Summoning")==0)
     650                 :          0 :     summon(gamestatusp(CHEATED),-1);
     651 [ #  # ][ #  # ]:          0 :   else if (strcmp(wishstr,"Stats") == 0 && gamestatusp(CHEATED))
     652                 :            :   {
     653                 :          0 :     Player.str = Player.maxstr = Player.con = Player.maxcon = 
     654                 :          0 :       Player.agi = Player.maxagi = Player.dex = Player.maxdex = 
     655                 :          0 :       Player.iq = Player.maxiq = Player.pow = Player.maxpow = 200;
     656                 :          0 :     calc_melee();
     657                 :            :   }
     658                 :          0 :   else print2("You feel stupid.");
     659                 :          0 :   dataprint();
     660                 :          0 :   showflags();
     661                 :          0 : }
     662                 :            : 
     663                 :            : /* gain for an item */
     664                 :          0 : void acquire(int blessing)
     665                 :            : {
     666                 :            :   char otype;
     667                 :          0 :   int index,id = ABORT;
     668                 :            :   pob newthing;
     669                 :            : 
     670         [ #  # ]:          0 :   if (blessing < 0) {
     671                 :          0 :     index = random_item();
     672         [ #  # ]:          0 :     if (index == ABORT)
     673                 :          0 :       mprint("You feel fortunate.");
     674                 :            :     else {
     675                 :          0 :       print1("Smoke drifts out of your pack.... ");
     676                 :          0 :       print2("Destroyed: ");
     677                 :          0 :       nprint2(itemid(Player.possessions[index]));
     678                 :          0 :       morewait();
     679                 :          0 :       dispose_lost_objects(1,Player.possessions[index]);
     680                 :            :     }
     681                 :            :   }
     682                 :            :   else {
     683                 :          0 :     newthing = ((pob) checkmalloc(sizeof(objtype)));
     684                 :            :     /* DAG this assignment looks unneccessary */
     685                 :          0 :     newthing->id = -1;
     686         [ #  # ]:          0 :     if (gamestatusp(CHEATED))
     687                 :          0 :       print1("Acquire which kind of item: !?][}{)/=%%\\& ");
     688                 :            :     else
     689                 :          0 :       print1("Acquire which kind of item: !?][}{)/=%%\\ ");
     690                 :          0 :     otype = mgetc();
     691   [ #  #  #  #  :          0 :     switch (otype) {
          #  #  #  #  #  
             #  #  #  # ]
     692                 :            :     case (POTION&0xff): 
     693         [ #  # ]:          0 :       if (blessing > 0)
     694                 :          0 :         id = itemlist(POTIONID,NUMPOTIONS);
     695                 :            :       else
     696                 :          0 :         id = random_range(NUMPOTIONS);
     697         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     698                 :          0 :       else make_potion(newthing,id); 
     699                 :          0 :       break;
     700                 :            :     case (SCROLL&0xff):
     701         [ #  # ]:          0 :       if (blessing > 0)
     702                 :          0 :         id = itemlist(SCROLLID,NUMSCROLLS);
     703                 :            :       else
     704                 :          0 :         id = random_range(NUMSCROLLS);
     705         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     706                 :          0 :       else make_scroll(newthing,id); 
     707                 :          0 :       break;
     708                 :            :     case (RING&0xff): 
     709         [ #  # ]:          0 :       if (blessing > 0)
     710                 :          0 :         id = itemlist(RINGID,NUMRINGS);
     711                 :            :       else
     712                 :          0 :         id = random_range(NUMRINGS);
     713         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     714                 :          0 :       else make_ring(newthing,id); 
     715                 :          0 :       break;
     716                 :            :     case (STICK&0xff):
     717         [ #  # ]:          0 :       if (blessing > 0)
     718                 :          0 :         id = itemlist(STICKID,NUMSTICKS);
     719                 :            :       else
     720                 :          0 :         id = random_range(NUMSTICKS);
     721         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     722                 :          0 :       else make_stick(newthing,id); 
     723                 :          0 :       break;
     724                 :            :     case (ARMOR&0xff): 
     725         [ #  # ]:          0 :       if (blessing > 0)
     726                 :          0 :         id = itemlist(ARMORID,NUMARMOR);
     727                 :            :       else
     728                 :          0 :         id = random_range(NUMARMOR);
     729         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     730                 :          0 :       else make_armor(newthing,id); 
     731                 :          0 :       break;
     732                 :            :     case (SHIELD&0xff):
     733         [ #  # ]:          0 :       if (blessing > 0)
     734                 :          0 :         id = itemlist(SHIELDID,NUMSHIELDS);
     735                 :            :       else
     736                 :          0 :         id = random_range(NUMSHIELDS);
     737         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     738                 :          0 :       else make_shield(newthing,id); 
     739                 :          0 :       break;
     740                 :            :     case (WEAPON&0xff):
     741         [ #  # ]:          0 :       if (blessing > 0)
     742                 :          0 :         id = itemlist(WEAPONID,NUMWEAPONS);
     743                 :            :       else
     744                 :          0 :         id = random_range(NUMWEAPONS);
     745         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     746                 :          0 :       else make_weapon(newthing,id); 
     747                 :          0 :       break;
     748                 :            :     case (BOOTS&0xff):
     749         [ #  # ]:          0 :       if (blessing > 0)
     750                 :          0 :         id = itemlist(BOOTID,NUMBOOTS);
     751                 :            :       else
     752                 :          0 :         id = random_range(NUMBOOTS);
     753         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     754                 :          0 :       else make_boots(newthing,id); 
     755                 :          0 :       break;
     756                 :            :     case (CLOAK&0xff): 
     757         [ #  # ]:          0 :       if (blessing > 0)
     758                 :          0 :         id = itemlist(CLOAKID,NUMCLOAKS);
     759                 :            :       else
     760                 :          0 :         id = random_range(NUMCLOAKS);
     761         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     762                 :          0 :       else make_cloak(newthing,id); 
     763                 :          0 :       break;
     764                 :            :     case (FOOD&0xff): 
     765         [ #  # ]:          0 :       if (blessing > 0)
     766                 :          0 :         id = itemlist(FOODID,NUMFOODS);
     767                 :            :       else
     768                 :          0 :         id = random_range(NUMFOODS);
     769         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     770                 :          0 :       else make_food(newthing,id); 
     771                 :          0 :       break;
     772                 :            :     case (THING&0xff):
     773         [ #  # ]:          0 :       if (blessing > 0)
     774                 :          0 :         id = itemlist(THINGID,NUMTHINGS);
     775                 :            :       else
     776                 :          0 :         id = random_range(NUMTHINGS);
     777         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     778                 :          0 :       else make_thing(newthing,id); 
     779                 :          0 :       break;
     780                 :            :     case (ARTIFACT&0xff):
     781         [ #  # ]:          0 :       if (gamestatusp(CHEATED))
     782                 :          0 :         id = itemlist(ARTIFACTID,NUMARTIFACTS);
     783                 :            :       else
     784                 :          0 :         id = -1;
     785         [ #  # ]:          0 :       if (id < 0) print2("You feel stupid."); 
     786                 :          0 :       else make_artifact(newthing,id); 
     787                 :          0 :       break;
     788                 :            :     default:
     789                 :          0 :       print2("You feel stupid."); 
     790                 :            :     }
     791                 :          0 :     xredraw();
     792         [ #  # ]:          0 :     if (id != ABORT) {
     793         [ #  # ]:          0 :       if (blessing > 0) {
     794                 :          0 :         newthing->known = 2;
     795                 :          0 :         Objects[id].known = 1;
     796                 :            :       }
     797                 :          0 :       newthing->used = FALSE;
     798                 :          0 :       gain_item(newthing);
     799                 :            :     } 
     800                 :            :     else
     801                 :            :     {
     802                 :            :       /* DAG newthing allocated but was not freed... was YA memory leak */
     803                 :            :       /* use free() rather than free_obj() since newthing not initialized */
     804                 :          0 :       free( (char *) newthing );
     805                 :            :     }
     806                 :            :   }
     807                 :          0 : }

Generated by: LCOV version 1.11