LCOV - code coverage report
Current view: top level - omega-rpg-0.90-pa9 - effect3.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 8 795 1.0 %
Date: 2017-09-08 22:00:26 Functions: 1 36 2.8 %
Branches: 4 448 0.9 %

           Branch data     Line data    Source code
       1                 :            : /* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
       2                 :            : /* effect3.c */
       3                 :            : 
       4                 :            : #include "glob.h"
       5                 :            : 
       6                 :            : /* if know id, then summon that monster; else (if < 0) get one. */
       7                 :          0 : void summon (int blessing, int id)
       8                 :            : {
       9                 :            :   int i,x,y;
      10                 :            :   pml tml;
      11                 :            : 
      12         [ #  # ]:          0 :   if (id < 0)
      13                 :            :     {
      14         [ #  # ]:          0 :       if (blessing > 0)
      15                 :            :         {
      16                 :          0 :           id = monsterlist();
      17                 :          0 :           xredraw();
      18                 :            :         }
      19                 :            : 
      20                 :            :       /* for (id ==0) case, see below -- get a "fair" monster */
      21         [ #  # ]:          0 :       else if (blessing < 0)
      22                 :          0 :         id = random_range(NUMMONSTERS);
      23                 :            :   }
      24                 :            : 
      25         [ #  # ]:          0 :   for (i = 0; i < 8; ++i)
      26                 :            :     {
      27                 :          0 :       x = Player.x+Dirs[0][i];
      28                 :          0 :       y = Player.y+Dirs[1][i];
      29                 :            : 
      30         [ #  # ]:          0 :       if (!inbounds(x,y)) continue;
      31         [ #  # ]:          0 :       if (Level->site[x][y].locchar != FLOOR) continue;
      32         [ #  # ]:          0 :       if (Level->site[x][y].creature) continue;
      33                 :            : 
      34                 :          0 :       break;
      35                 :            :     }
      36                 :            : 
      37         [ #  # ]:          0 :   if (i < 8)
      38                 :            :     {
      39 [ #  # ][ #  # ]:          0 :       if ((blessing == 0) && (id < 0))
      40                 :          0 :         Level->site[x][y].creature = m_create(x,y,WANDERING,difficulty());
      41                 :            :       else
      42                 :          0 :         Level->site[x][y].creature = make_creature(id);
      43                 :            : 
      44                 :          0 :       Level->site[x][y].creature->x = x;
      45                 :          0 :       Level->site[x][y].creature->y = y;
      46                 :          0 :       tml = checkmalloc(sizeof(mltype));
      47                 :          0 :       tml->m = Level->site[x][y].creature;
      48                 :            : 
      49         [ #  # ]:          0 :       if (blessing > 0)
      50                 :          0 :         m_status_reset(tml->m,HOSTILE);
      51         [ #  # ]:          0 :       else if (blessing < 0)
      52                 :          0 :         m_status_set(tml->m,HOSTILE);
      53                 :            : 
      54                 :          0 :       tml->next = Level->mlist;
      55                 :          0 :       Level->mlist = tml;
      56                 :            :     }
      57                 :          0 : }
      58                 :            : 
      59                 :            : 
      60                 :          0 : int itemlist(int itemindex, int num)
      61                 :            : {
      62                 :            :   int i,itemno;
      63                 :            : 
      64                 :          0 :   print2("Show ID list? ");
      65         [ #  # ]:          0 :   if (ynq2() == 'y') {
      66                 :          0 :     menuclear();
      67         [ #  # ]:          0 :     for(i=0;i<num;i++) {
      68                 :          0 :       menunumprint(i+1);
      69                 :          0 :       menuprint(":");
      70                 :          0 :       menuprint(Objects[i+itemindex].truename);
      71                 :          0 :       menuprint("\n");
      72                 :            :     }
      73                 :          0 :     showmenu();
      74                 :            :   }
      75                 :          0 :   itemno = (int) parsenum("Item ID? ")-1;
      76 [ #  # ][ #  # ]:          0 :   if ((itemno >= num)||(itemno<0)) itemno = ABORT;
      77                 :          0 :   return(itemno);
      78                 :            : }
      79                 :            : 
      80                 :          0 : int monsterlist(void)
      81                 :            : {
      82                 :            :   int i,itemno;
      83                 :          0 :   print2("Show ID list? ");
      84         [ #  # ]:          0 :   if (ynq2() == 'y')
      85                 :            :     do {
      86                 :          0 :       clearmsg();
      87                 :          0 :       menuclear();
      88         [ #  # ]:          0 :       for(i=0;i<NUMMONSTERS;i++) {
      89                 :          0 :         menunumprint(i+1);
      90                 :          0 :         menuprint(":");
      91                 :          0 :         menuprint(Monsters[i].monstring);
      92                 :          0 :         menuprint("\n");
      93                 :            :       }
      94                 :          0 :       showmenu();
      95                 :          0 :       itemno = (int) parsenum("Summon monster: ")-1;
      96 [ #  # ][ #  # ]:          0 :       if ((itemno < 0) || (itemno > NUMMONSTERS-1)) {
      97                 :          0 :         print3("How about trying a real monster?");
      98                 :          0 :         morewait();
      99                 :            :       }
     100 [ #  # ][ #  # ]:          0 :     } while ((itemno < 0) || (itemno > NUMMONSTERS-1));
     101                 :            :   else
     102                 :            :     do {
     103                 :          0 :       itemno = (int) parsenum("Summon monster: ")-1;
     104 [ #  # ][ #  # ]:          0 :     } while ((itemno < 0) || (itemno > NUMMONSTERS-1));
     105                 :          0 :   return(itemno);
     106                 :            : }
     107                 :            :       
     108                 :            : 
     109                 :            : /* uncurse all items, cure diseases, and neutralize poison */
     110                 :          1 : void cleanse(int blessing)
     111                 :            : {
     112                 :            :   int i;
     113                 :            : 
     114         [ +  - ]:          1 :   if (blessing > -1) {
     115         [ -  + ]:          1 :     if (blessing > 0)
     116         [ #  # ]:          0 :       for(i=0;i<MAXITEMS;i++) 
     117         [ #  # ]:          0 :         if (Player.possessions[i] != NULL) {
     118 [ #  # ][ #  # ]:          0 :           if ((Player.possessions[i]->used) &&
     119                 :          0 :               (Player.possessions[i]->blessing < 0)) {
     120                 :          0 :             Player.possessions[i]->used = FALSE;
     121                 :          0 :             item_use(Player.possessions[i]);
     122                 :          0 :             Player.possessions[i]->blessing = 0;
     123                 :          0 :             Player.possessions[i]->used = TRUE;
     124                 :          0 :             item_use(Player.possessions[i]);
     125                 :            :           }
     126                 :            :         }
     127                 :            :     
     128         [ -  + ]:          1 :     if (Player.status[POISONED] > 0) {
     129                 :          0 :       Player.status[POISONED] = 0;
     130                 :            :     }
     131         [ -  + ]:          1 :     if (Player.status[DISEASED] > 0) {
     132                 :          0 :       Player.status[DISEASED] = 0;
     133                 :            :     }
     134                 :          1 :     showflags();
     135                 :          1 :     mprint("You feel radiant!");
     136                 :            :   }
     137                 :            :   else {
     138                 :          0 :     Player.status[POISONED] += 10;
     139                 :          0 :     Player.status[DISEASED] += 10;
     140                 :          0 :     mprint("You feel besmirched!");
     141                 :          0 :     showflags();
     142                 :            :   }
     143                 :          1 : }
     144                 :            : 
     145                 :          0 : void annihilate(int blessing)
     146                 :            : {
     147                 :            :   pml ml;
     148                 :            :   int i;
     149                 :            : 
     150         [ #  # ]:          0 :   if (blessing == 0) {
     151                 :          0 :     mprint("Lightning strikes flash all around you!!!");
     152         [ #  # ]:          0 :     for(i=0;i<9;i++)
     153         [ #  # ]:          0 :       if (Level->site[Player.x+Dirs[0][i]][Player.y+Dirs[1][i]].creature !=
     154                 :            :           NULL)
     155                 :          0 :         m_death(Level->site[Player.x+Dirs[0][i]][Player.y+Dirs[1][i]].creature);
     156                 :            :   }
     157         [ #  # ]:          0 :   if (blessing > 0) {
     158         [ #  # ]:          0 :     if (Current_Environment == E_COUNTRYSIDE) {
     159                 :          0 :         clearmsg();
     160                 :          0 :         print1("Bolts of lightning flash down for as far as you can see!!!");
     161                 :          0 :         morewait();
     162                 :          0 :         print1("There is a rain of small birds and insects from the sky, and you");
     163                 :          0 :         print2("notice that you can't hear any animal noises around here any more...");
     164                 :          0 :         Player.alignment -= 3;
     165                 :            :     }
     166                 :            :     else {
     167                 :          0 :       mprint("Thousands of bolts of lightning flash throughout the level!!!");
     168         [ #  # ]:          0 :       for(ml=Level->mlist;ml!=NULL;ml=ml->next)
     169 [ #  # ][ #  # ]:          0 :         if (ml->m != NULL && ml->m->hp > 0)
     170                 :          0 :           m_death(ml->m);
     171                 :            :     }
     172                 :            :   }
     173                 :            :   else {
     174                 :          0 :     mprint("You are hit by a bolt of mystic lightning!");
     175                 :          0 :     p_death("self-annihilation");
     176                 :            :   }
     177                 :          0 : }
     178                 :            : 
     179                 :            : 
     180                 :          0 : void sleep_monster(int blessing)
     181                 :            : {
     182                 :            :   /* pml ml; */
     183                 :          0 :   int x=Player.x,y=Player.y;
     184                 :            :   struct monster *target;
     185                 :            : 
     186         [ #  # ]:          0 :   if (blessing == 0) setspot(&x,&y);
     187                 :            : 
     188         [ #  # ]:          0 :   if (blessing < 0)
     189                 :          0 :     sleep_player(abs(blessing)+2);
     190                 :            :   /*
     191                 :            :   else if (blessing > 0) {
     192                 :            :     mprint("A silence pervades the area.");
     193                 :            :     for (ml=Level->mlist;ml!=NULL;ml=ml->next) {
     194                 :            :       m_status_reset(ml->m,AWAKE);
     195                 :            :       ml->m->wakeup = 0;
     196                 :            :     }
     197                 :            :   }
     198                 :            :   */
     199                 :            :   else {
     200                 :          0 :     target = Level->site[x][y].creature;
     201         [ #  # ]:          0 :     if (target != NULL) {
     202         [ #  # ]:          0 :       if (target->uniqueness == COMMON) {
     203                 :          0 :         strcpy(Str1,"The ");
     204                 :          0 :         strcat(Str1,target->monstring);
     205                 :            :       }
     206                 :          0 :       else strcpy(Str1,target->monstring);
     207 [ #  # ][ #  # ]:          0 :       if ( (! m_immunityp(target,SLEEP)) || (blessing > 0)) {
     208                 :          0 :         strcat(Str1," seems to have fallen asleep.");
     209                 :          0 :         m_status_reset(target,AWAKE);
     210                 :          0 :         target->wakeup = 0;
     211                 :            :       }
     212                 :          0 :       else strcat(Str1," is bright eyed, and bushy tailed!");
     213                 :          0 :       mprint(Str1);
     214                 :            :     }
     215                 :          0 :     else mprint("Nothing to sleep there!");
     216                 :            :   }
     217                 :          0 : }
     218                 :            :   
     219                 :          0 : void sleep_player(int amount)
     220                 :            : {
     221         [ #  # ]:          0 :   if (Player.status[SLEPT] == 0) { /* prevent player from sleeping forever */
     222                 :          0 :     mprint("You feel sleepy...");
     223         [ #  # ]:          0 :     if (! p_immune(SLEEP)) {
     224                 :          0 :       Player.status[SLEPT] += random_range(amount*2)+2;
     225                 :            :     }
     226                 :          0 :     else mprint("but you shrug off the momentary lassitude.");
     227                 :            :   }
     228                 :          0 : }
     229                 :            : 
     230                 :            : 
     231                 :          0 : void hide(int x, int y)
     232                 :            : {
     233         [ #  # ]:          0 :   if (inbounds(x,y)) {
     234                 :          0 :     lset(x,y,SECRET);
     235                 :          0 :     lset(x, y, CHANGED);
     236                 :          0 :     putspot(x, y, WALL);
     237                 :          0 :     mprint("You feel sneaky.");
     238                 :            :   }
     239                 :          0 : }
     240                 :            : 
     241                 :          0 : void clairvoyance(int vision)
     242                 :            : {
     243                 :            :   int i,j;
     244                 :          0 :   int x = Player.x, y = Player.y;
     245                 :          0 :   mprint("Clairvoyance... ");
     246                 :          0 :   setspot(&x,&y);
     247         [ #  # ]:          0 :   for(i=x-vision;i<x+vision+1;i++)
     248         [ #  # ]:          0 :     for(j=y-vision;j<y+vision+1;j++) {
     249         [ #  # ]:          0 :       if (inbounds(i,j)) {
     250                 :          0 :         Level->site[i][j].showchar = SPACE;
     251                 :          0 :         lreset(i,j,SECRET);
     252                 :          0 :         lset(i, j, CHANGED);
     253                 :          0 :         dodrawspot(i,j);
     254                 :            :       }
     255                 :            :     }
     256                 :          0 :   levelrefresh();
     257                 :          0 : }
     258                 :            : 
     259                 :          0 : void aggravate(void)
     260                 :            : {
     261                 :            :   pml tm;
     262                 :            : 
     263         [ #  # ]:          0 :   for (tm=Level->mlist;tm!=NULL;tm=tm->next){
     264                 :          0 :     m_status_set(tm->m,AWAKE);
     265                 :          0 :     m_status_set(tm->m,HOSTILE);
     266                 :            :   }
     267                 :          0 : }
     268                 :            : 
     269                 :            : 
     270                 :          0 : void learnspell(int blessing)
     271                 :            : {
     272                 :          0 :   int i,spell,done=FALSE;
     273         [ #  # ]:          0 :   if (blessing < 0) {
     274 [ #  # ][ #  # ]:          0 :     for(i=NUMSPELLS;((i>-1) && (! done));i--)
     275         [ #  # ]:          0 :       if (Spells[i].known) {
     276                 :          0 :         done = TRUE;
     277                 :          0 :         Objects[OB_SPELLS_SCROLL].known = TRUE;
     278                 :          0 :         mprint("You feel forgetful.");
     279                 :          0 :         Spells[i].known = FALSE;
     280                 :            :       }
     281         [ #  # ]:          0 :     if (i == ABORT)
     282                 :          0 :       mprint("You feel fortunate.");
     283                 :            :   }
     284                 :            :   else {
     285                 :          0 :     Objects[OB_SPELLS_SCROLL].known = TRUE;
     286                 :          0 :     spell = random_range(NUMSPELLS);
     287                 :          0 :     print1("Spell Research");
     288         [ #  # ]:          0 :     if ((random_range(4*Spells[spell].powerdrain)+
     289                 :          0 :          Spells[spell].powerdrain) <
     290                 :          0 :         (4*Player.iq+8*Player.level)) {
     291                 :          0 :       nprint1(" -- Research successful: ");
     292                 :          0 :       nprint1(spellid(spell));
     293         [ #  # ]:          0 :       if (Spells[spell].known) {
     294                 :          0 :         print2("...is now easier to cast.");
     295                 :          0 :         Spells[spell].powerdrain = ((int) ((Spells[spell].powerdrain+1)/2));
     296                 :            :       }
     297                 :            :       else {
     298                 :          0 :         print2("...is added to your repertoire");
     299                 :          0 :         Spells[spell].known = TRUE;
     300                 :          0 :         gain_experience(Spells[spell].powerdrain*10);
     301                 :            :       }
     302                 :            :     }
     303                 :          0 :     else nprint1(" -- Research unsuccessful.");
     304                 :            :   }
     305                 :          0 : }
     306                 :            : 
     307                 :            : 
     308                 :          0 : void amnesia(void)
     309                 :            : {
     310                 :            :   int i,j;
     311         [ #  # ]:          0 :   for (j=0;j<Level->level_length;j++)
     312         [ #  # ]:          0 :     for (i=0;i<Level->level_width;i++)
     313                 :          0 :       lreset(i,j,SEEN);
     314                 :            : 
     315                 :          0 :   erase_level();
     316                 :          0 :   drawvision(Player.x,Player.y);
     317                 :          0 : }
     318                 :            : 
     319                 :            : 
     320                 :            : /*affects player only */
     321                 :          0 : void level_drain(int levels, char *source)
     322                 :            : {
     323                 :            :   long exp_loss;
     324                 :          0 :   int decrement = ((int) (Player.maxhp / (Player.level+1)));
     325                 :            :   /* lost experience is the delta between what is needed for the */
     326                 :            :   /* current level and for the target level -DAG */
     327                 :          0 :   exp_loss = expval(Player.level) - expval( Player.level-levels );
     328                 :            : 
     329                 :          0 :   Player.level -= levels;
     330                 :          0 :   Player.xp -= exp_loss;
     331                 :          0 :   Player.maxhp -= (levels * decrement);
     332                 :            :   /* should pro-rate hp loss? - DAG */
     333                 :          0 :   Player.hp -= (levels * decrement);
     334                 :            : 
     335 [ #  # ][ #  # ]:          0 :   if ((Player.hp < 1) || (Player.level < 0))
     336                 :          0 :     p_death(source);
     337                 :          0 : }
     338                 :            : 
     339                 :            : 
     340                 :          0 : void disrupt(int x, int y, int amount)
     341                 :            : {
     342                 :            :   struct monster *target;
     343                 :            : 
     344 [ #  # ][ #  # ]:          0 :   if ((x ==Player.x) && (y==Player.y)) {
     345                 :          0 :     mprint("You feel disrupted!");
     346                 :          0 :     p_damage(amount,NORMAL_DAMAGE,"magical disruption");
     347                 :            :   }
     348                 :            :   else {
     349                 :          0 :     target = Level->site[x][y].creature;
     350         [ #  # ]:          0 :     if (target != NULL) {
     351         [ #  # ]:          0 :       if (target->uniqueness == COMMON) {
     352                 :          0 :         strcpy(Str1,"The ");
     353                 :          0 :         strcat(Str1,target->monstring);
     354                 :            :       }
     355                 :          0 :       else strcpy(Str1,target->monstring);
     356         [ #  # ]:          0 :       if (! m_immunityp(target,NORMAL_DAMAGE)) {
     357                 :          0 :         strcat(Str1," was blasted!");
     358                 :          0 :         mprint(Str1);
     359                 :          0 :         m_damage(target,amount,NORMAL_DAMAGE);
     360                 :          0 :         target->wakeup = 0;
     361                 :            :       }
     362                 :            :       else {
     363                 :          0 :         strcat(Str1," does not seem affected.");
     364                 :          0 :         mprint(Str1);
     365                 :            :       }
     366                 :            :     }
     367                 :            :   }
     368                 :          0 : }
     369                 :            : 
     370                 :            : 
     371                 :          0 : void disintegrate(int x, int y)
     372                 :            : {
     373                 :            :   struct monster *target;
     374         [ #  # ]:          0 :   if (! inbounds(x,y)) mprint("You feel a sense of wastage.");
     375 [ #  # ][ #  # ]:          0 :   else if ((x==Player.x)&&(y==Player.y)) {
     376         [ #  # ]:          0 :     if (Player.possessions[O_CLOAK] != NULL) {
     377                 :          0 :       mprint("Your cloak disintegrates!");
     378                 :          0 :       dispose_lost_objects(1,Player.possessions[O_CLOAK]);
     379                 :            :     }
     380         [ #  # ]:          0 :     else if (Player.possessions[O_ARMOR] != NULL) {
     381                 :          0 :       mprint("Your armor disintegrates!");
     382                 :          0 :       dispose_lost_objects(1,Player.possessions[O_ARMOR]);
     383                 :            :     }
     384                 :            :     else {
     385                 :          0 :       mprint("Uh, oh....");
     386                 :          0 :       mprint("Zzzap! You've been disintegrated!");
     387                 :          0 :       p_damage(250,UNSTOPPABLE,"disintegration");
     388                 :            :     }
     389                 :            :   }
     390                 :            :   else {
     391         [ #  # ]:          0 :     if (!view_los_p(Player.x, Player.y, x, y))
     392                 :          0 :       setgamestatus(SUPPRESS_PRINTING);
     393         [ #  # ]:          0 :     if ((target = Level->site[x][y].creature) != NULL) {
     394         [ #  # ]:          0 :       if (target->uniqueness == COMMON) {
     395                 :          0 :         strcpy(Str1,"The ");
     396                 :          0 :         strcat(Str1,target->monstring);
     397                 :            :       }
     398                 :          0 :       else strcpy(Str1,target->monstring);
     399                 :          0 :       strcat(Str1," disintegrates!");
     400                 :          0 :       mprint(Str1);
     401                 :          0 :       m_damage(target,100,UNSTOPPABLE);
     402         [ #  # ]:          0 :       if (target->hp > 0) mprint("It was partially protected by its armor.");
     403                 :            :     }
     404         [ #  # ]:          0 :     else if (Level->site[x][y].locchar == ALTAR) {
     405                 :          0 :       mprint("Zzzzap! the altar seems unaffected...");
     406                 :          0 :       mprint("But an angry deity retaliates....");
     407                 :          0 :       disintegrate(Player.x,Player.y);
     408                 :            :     }
     409         [ #  # ]:          0 :     else if (Level->site[x][y].p_locf == L_TRAP_PIT) {
     410         [ #  # ]:          0 :       if (Current_Environment == Current_Dungeon) {
     411                 :          0 :         mprint("A hole is blasted in the base of the pit!");
     412                 :          0 :         Level->site[x][y].locchar = TRAP;
     413                 :          0 :         Level->site[x][y].p_locf = L_TRAP_DOOR;
     414                 :          0 :         Level->site[x][y].aux = S_DISINTEGRATE;
     415                 :          0 :         lset(x, y, CHANGED);
     416                 :            :       }
     417                 :          0 :       else mprint("The hole just gets deeper....");
     418                 :            :     }
     419         [ #  # ]:          0 :     else if (Level->site[x][y].locchar == FLOOR) {
     420                 :          0 :       mprint("You zap a hole in the floor!");
     421                 :          0 :       Level->site[x][y].locchar = TRAP;
     422                 :          0 :       Level->site[x][y].p_locf = L_TRAP_PIT;
     423                 :          0 :       lset(x, y, CHANGED);
     424                 :            :     }
     425 [ #  # ][ #  # ]:          0 :     else if ((Level->site[x][y].locchar == WALL) ||
     426         [ #  # ]:          0 :              (Level->site[x][y].locchar == OPEN_DOOR) ||
     427         [ #  # ]:          0 :              (Level->site[x][y].locchar == CLOSED_DOOR) ||
     428         [ #  # ]:          0 :              (Level->site[x][y].locchar == PORTCULLIS) ||
     429                 :          0 :              (Level->site[x][y].locchar == STATUE)) {
     430                 :          0 :       mprint("The site is reduced to rubble!");
     431         [ #  # ]:          0 :       if (Level->site[x][y].locchar == WALL)
     432                 :          0 :         tunnelcheck();
     433                 :          0 :       Level->site[x][y].p_locf = L_RUBBLE;
     434                 :          0 :       Level->site[x][y].locchar = RUBBLE;
     435                 :          0 :       lreset(x,y,SECRET);
     436                 :          0 :       lset(x, y, CHANGED);
     437                 :            :     }
     438 [ #  # ][ #  # ]:          0 :     else if ((Level->site[x][y].locchar == RUBBLE) ||
     439                 :          0 :              (Level->site[x][y].locchar == TRAP)) {
     440                 :          0 :       mprint("The site is blasted clear!");
     441                 :          0 :       Level->site[x][y].p_locf = L_NO_OP;
     442                 :          0 :       Level->site[x][y].locchar = FLOOR;
     443                 :          0 :       lreset(x,y,SECRET);
     444                 :          0 :       lset(x, y, CHANGED);
     445                 :            :     }
     446         [ #  # ]:          0 :     else if (Level->site[x][y].locchar == HEDGE) {
     447         [ #  # ]:          0 :       if (Level->site[x][y].p_locf == L_TRIFID) {
     448                 :          0 :         mprint("The trifid screams as it disintgrates!");
     449                 :          0 :         gain_experience(50);
     450                 :          0 :         Level->site[x][y].p_locf = L_NO_OP;
     451                 :          0 :         Level->site[x][y].locchar = FLOOR;
     452                 :          0 :         lreset(x,y,SECRET);
     453                 :          0 :         lset(x, y, CHANGED);
     454                 :            :       }
     455                 :            :       else {
     456                 :          0 :         mprint("The hedge is blasted away!");
     457                 :          0 :         Level->site[x][y].p_locf = L_NO_OP;
     458                 :          0 :         Level->site[x][y].locchar = FLOOR;
     459                 :          0 :         lreset(x,y,SECRET);
     460                 :          0 :         lset(x, y, CHANGED);
     461                 :            :       }
     462                 :            :     }
     463                 :          0 :     else mprint("The blast has no effect.");
     464         [ #  # ]:          0 :     if (!view_los_p(Player.x, Player.y, x, y))
     465                 :          0 :       resetgamestatus(SUPPRESS_PRINTING);
     466                 :            :     else
     467                 :          0 :       plotspot(x, y, TRUE);
     468                 :            :   }
     469                 :          0 : }
     470                 :            : 
     471                 :          0 : void acid_cloud(void)
     472                 :            : {
     473                 :          0 :   mprint("You are caught in an acid cloud!  ");
     474         [ #  # ]:          0 :   if (Player.possessions[O_CLOAK] != NULL) {
     475                 :          0 :     (void) damage_item(Player.possessions[O_CLOAK]);
     476                 :          0 :     mprint("You are burned by acid.");
     477                 :          0 :     p_damage(3,ACID,"an acid cloud");
     478                 :            :   }
     479         [ #  # ]:          0 :   else if (Player.possessions[O_ARMOR] != NULL) {
     480                 :          0 :     mprint("You are burned by acid.");
     481                 :          0 :     p_damage(3,ACID,"an acid cloud");
     482                 :          0 :     (void) damage_item(Player.possessions[O_ARMOR]);
     483                 :            :   }
     484         [ #  # ]:          0 :   else if (p_immune(ACID))
     485                 :            :   {
     486                 :          0 :     mprint("You resist the effects!");
     487                 :          0 :     return;
     488                 :            :   }
     489                 :            :   else {
     490                 :          0 :     mprint("The acid eats away at your bare skin!");
     491                 :          0 :     p_damage(25,ACID,"an acid cloud");
     492                 :            :   }
     493                 :            : }
     494                 :            : 
     495                 :            : 
     496                 :            : /* teleport player */
     497                 :          0 : void p_teleport(int type)
     498                 :            : {
     499                 :          0 :   int x=Player.x,y=Player.y;
     500                 :          0 :   drawspot(x,y);
     501         [ #  # ]:          0 :   if (type < 0) {
     502                 :          0 :     x = random_range(Level->level_width);
     503                 :          0 :     y = random_range(Level->level_length);
     504 [ #  # ][ #  # ]:          0 :     if ((Level->site[x][y].locchar != FLOOR) &&
     505                 :          0 :         (Level->site[x][y].locchar != OPEN_DOOR)) {
     506                 :          0 :       mprint("You teleported into a solid object....");
     507                 :          0 :       mprint("You are dead!");
     508                 :          0 :       p_death("teleportation into a solid object");
     509                 :            :     }
     510                 :            :     else {
     511                 :          0 :       Player.x = x;
     512                 :          0 :       Player.y = y;
     513                 :            :     }
     514                 :            :   }
     515         [ #  # ]:          0 :   else if (type == 0)
     516                 :          0 :     findspace(&(Player.x),&(Player.y),-1);
     517                 :            :   else {
     518                 :          0 :     setspot(&Player.x,&Player.y);
     519 [ #  # ][ #  # ]:          0 :     if ((Level->site[Player.x][Player.y].locchar != FLOOR) ||
     520                 :          0 :         (Level->site[Player.x][Player.y].creature != NULL)) {
     521                 :          0 :       mprint("You feel deflected.");
     522                 :          0 :       p_teleport(0);
     523                 :            :     }
     524                 :            :   }
     525                 :          0 :   Player.status[IMMOBILE] = 0;
     526                 :          0 :   screencheck(Player.x,Player.y);
     527                 :          0 :   roomcheck();
     528                 :          0 : }
     529                 :            : 
     530                 :            : 
     531                 :          0 : void p_poison(int toxicity)
     532                 :            : {
     533                 :          0 :   mprint("You feel sick.");
     534         [ #  # ]:          0 :   if (! p_immune(POISON))
     535                 :          0 :     Player.status[POISONED]+=toxicity;
     536                 :          0 :   else mprint("The sickness fades!");
     537                 :          0 :   showflags();
     538                 :          0 : }
     539                 :            : 
     540                 :          0 : void apport(int blessing)
     541                 :            : {
     542                 :          0 :   int i,index,x=Player.x,y=Player.y;
     543         [ #  # ]:          0 :   if (blessing > -1) {
     544                 :          0 :     mprint("Apport from:");
     545                 :          0 :     setspot(&x,&y);
     546         [ #  # ]:          0 :     if (Level->site[x][y].things != NULL) {
     547                 :          0 :       pickup_at(x,y);
     548                 :          0 :       plotspot(x, y, TRUE);
     549                 :            :     }
     550                 :          0 :     else mprint("There's nothing there to apport!");
     551                 :            :   }
     552                 :            :   else {
     553                 :          0 :     mprint("You have a sense of loss.");
     554         [ #  # ]:          0 :     for(i=0;i<abs(blessing);i++) {
     555                 :          0 :       index = random_item();
     556         [ #  # ]:          0 :       if (index != ABORT) {
     557                 :          0 :         drop_at(x,y,Player.possessions[index]);
     558                 :          0 :         dispose_lost_objects(Player.possessions[index]->number,
     559                 :          0 :           Player.possessions[index]);
     560                 :            :       }
     561                 :            :     }
     562                 :            :   }
     563                 :          0 : }
     564                 :            : 
     565                 :            : 
     566                 :          0 : void strategic_teleport(int blessing)
     567                 :            : {
     568                 :            :   int new_env;
     569                 :            : 
     570                 :            :   /* WDT HACK: Game balance issue: the star gem is supposed to be the only
     571                 :            :    * way out of the astral plane (including the Circle of Sorcerors).  However,
     572                 :            :    * Hy Magic offers the Location wish, and some artifacts grant this
     573                 :            :    * as well.  Seems to me that Hy Magic ought to allow it, and nothing
     574                 :            :    * else (aside from the Star Gem, of course). */
     575 [ #  # ][ #  # ]:          0 :   if ((Current_Environment == E_CIRCLE || Current_Environment == E_ASTRAL) &&
                 [ #  # ]
     576                 :          0 :       !gamestatusp(CHEATED))
     577                 :            :   {
     578                 :          0 :     mprint("Some property of this eerie place interferes with the magic!\n");
     579                 :          0 :     return;
     580                 :            :   }
     581                 :          0 :   mprint("Magic portals open up all around you!");
     582         [ #  # ]:          0 :   if (blessing < 0) {
     583                 :          0 :     morewait();
     584                 :          0 :     mprint("You are dragged into one!");
     585                 :          0 :     change_environment(E_COUNTRYSIDE);
     586                 :            :     do {
     587                 :          0 :       setPlayerXY( random_range(Level->level_width), random_range(Level->level_length) );
     588         [ #  # ]:          0 :     } while(Country[Player.x][Player.y].base_terrain_type == CHAOS_SEA);
     589                 :            :   }
     590                 :            :   else {
     591                 :          0 :     mprint("Below each portal is a caption. Enter which one:");
     592                 :          0 :     menuclear();
     593                 :          0 :     menuprint("a: Rampart\n");
     594                 :          0 :     menuprint("b: Village of Star View\n");
     595                 :          0 :     menuprint("c: Village of Woodmere\n");
     596                 :          0 :     menuprint("d: Village of Stormwatch\n");
     597                 :          0 :     menuprint("e: Village of Thaumaris\n");
     598                 :          0 :     menuprint("f: Village of Skorch\n");
     599                 :          0 :     menuprint("g: Village of Whorfen\n");
     600                 :          0 :     menuprint("h: Temple of the Noose\n");
     601                 :          0 :     menuprint("i: The Parthenon\n");
     602                 :          0 :     menuprint("j: Temple of the Black Hand\n");
     603                 :          0 :     menuprint("k: Temple of the Hidden Moon\n");
     604                 :          0 :     menuprint("l: WoodHenge\n");
     605                 :          0 :     menuprint("m: Temple of Destiny\n");
     606                 :          0 :     menuprint("n: HellWell Volcano\n");
     607                 :          0 :     menuprint("o: Ruined Palace\n");
     608         [ #  # ]:          0 :     if (gamestatusp(CHEATED))
     609                 :          0 :       menuprint("z: Anywhere\n");
     610                 :          0 :     menuprint("ANYTHING ELSE: Avoid entering a portal.");
     611                 :          0 :     showmenu();
     612   [ #  #  #  #  :          0 :     switch((char) mcigetc()) {
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     613                 :            :     case 'a': 
     614                 :          0 :       change_environment(E_COUNTRYSIDE); 
     615                 :          0 :       setPlayerXY( 27, 19 );
     616                 :          0 :       break;
     617                 :            :     case 'b':
     618                 :          0 :       change_environment(E_COUNTRYSIDE);
     619                 :          0 :       setPlayerXY( 56, 5 );
     620                 :          0 :       break;
     621                 :            :     case 'c':
     622                 :          0 :       change_environment(E_COUNTRYSIDE);
     623                 :          0 :       setPlayerXY( 35, 11 );
     624                 :          0 :       break;
     625                 :            :     case 'd':
     626                 :          0 :       change_environment(E_COUNTRYSIDE);
     627                 :          0 :       setPlayerXY( 10, 40 );
     628                 :          0 :       break;
     629                 :            :     case 'e':
     630                 :          0 :       change_environment(E_COUNTRYSIDE);
     631                 :          0 :       setPlayerXY( 7, 6 );
     632                 :          0 :       break;
     633                 :            :     case 'f':
     634                 :          0 :       change_environment(E_COUNTRYSIDE);
     635                 :          0 :       setPlayerXY( 41, 43 );
     636                 :          0 :       break;
     637                 :            :     case 'g':
     638                 :          0 :       change_environment(E_COUNTRYSIDE);
     639                 :          0 :       setPlayerXY( 20, 41 );
     640                 :          0 :       break;
     641                 :            :     case 'h':
     642                 :          0 :       change_environment(E_COUNTRYSIDE);
     643                 :          0 :       setPlayerXY( 22, 30 );
     644                 :          0 :       break;
     645                 :            :     case 'i':
     646                 :          0 :       change_environment(E_COUNTRYSIDE);
     647                 :          0 :       setPlayerXY( 51, 11 );
     648                 :          0 :       break;
     649                 :            :     case 'j':
     650                 :          0 :       change_environment(E_COUNTRYSIDE);
     651                 :          0 :       setPlayerXY( 45, 45 );
     652                 :          0 :       break;
     653                 :            :     case 'k':
     654                 :          0 :       change_environment(E_COUNTRYSIDE);
     655                 :          0 :       setPlayerXY( 19, 46 );
     656                 :          0 :       break;
     657                 :            :     case 'l':
     658                 :          0 :       change_environment(E_COUNTRYSIDE);
     659                 :          0 :       setPlayerXY( 32, 5 );
     660                 :          0 :       break;
     661                 :            :     case 'm':
     662                 :          0 :       change_environment(E_COUNTRYSIDE);
     663                 :          0 :       setPlayerXY( 49, 59 );
     664                 :          0 :       break;
     665                 :            :     case 'n':
     666                 :          0 :       change_environment(E_COUNTRYSIDE);
     667                 :          0 :       setPlayerXY( 30, 58 );
     668                 :          0 :       break;
     669                 :            :     case 'o':
     670                 :          0 :       change_environment(E_COUNTRYSIDE);
     671                 :          0 :       setPlayerXY( 51, 51 );
     672                 :          0 :       break;
     673                 :            :     default:
     674         [ #  # ]:          0 :       if (gamestatusp(CHEATED)) {
     675                 :          0 :         new_env = (int) parsenum("Enter environment number: ");
     676                 :          0 :         change_environment(new_env);
     677                 :            :       }
     678                 :            :     }
     679                 :          0 :     xredraw();
     680         [ #  # ]:          0 :     if (gamestatusp(LOST)) {
     681                 :          0 :       print1("You know where you are now.");
     682                 :          0 :       resetgamestatus(LOST);
     683                 :          0 :       Precipitation = 0;
     684                 :            :     }
     685                 :            :   }
     686                 :          0 :   setlastxy(Player.x, Player.y);
     687                 :          0 :   screencheck(Player.x,Player.y);
     688                 :          0 :   drawvision(Player.x,Player.y);
     689         [ #  # ]:          0 :   if (Current_Environment == E_COUNTRYSIDE)
     690                 :          0 :     terrain_check(FALSE);
     691                 :            : }
     692                 :            : 
     693                 :            : 
     694                 :          0 : void hero(int blessing)
     695                 :            : {
     696         [ #  # ]:          0 :   if (blessing > -1) {
     697                 :          0 :       mprint("You feel super!");
     698                 :          0 :       Player.status[HERO] += random_range(5)+1+blessing;
     699                 :          0 :       calc_melee();
     700                 :            :     }
     701                 :            :   else {
     702                 :          0 :     Player.status[HERO]=0;
     703                 :          0 :     calc_melee();
     704                 :          0 :     mprint("You feel cowardly.");
     705                 :          0 :     level_drain(abs(blessing),"a potion of cowardice");
     706                 :            :   }
     707                 :          0 : }
     708                 :            : 
     709                 :            : 
     710                 :          0 : void levitate(int blessing)
     711                 :            : {
     712         [ #  # ]:          0 :   if (blessing > -1) {
     713         [ #  # ]:          0 :     if (gamestatusp(MOUNTED)) 
     714                 :          0 :       mprint("You have a strange feeling of lightness in your saddle.");
     715                 :            :     else {
     716                 :          0 :       mprint("You start to float a few inches above the floor.");
     717                 :          0 :       mprint("You discover you can easily control your altitude...");
     718                 :          0 :       mprint("(Note use of '@' command may be useful while levitating)");
     719                 :          0 :       Player.status[LEVITATING] += random_range(5)+1+blessing;
     720                 :            :     }
     721                 :            :   }
     722                 :          0 :   else mprint("Nothing much happens.");
     723                 :          0 : }
     724                 :            : 
     725                 :            : 
     726                 :            : /* has effect of switching between 1st level and deepest level attained */
     727                 :          0 : void level_return(void)
     728                 :            : {
     729         [ #  # ]:          0 :   if (Current_Environment == Current_Dungeon) {
     730                 :          0 :     mprint("The vortex of mana carries you off!");
     731         [ #  # ]:          0 :     if (Level->depth > 1)
     732                 :          0 :       change_level(Level->depth,1,FALSE);
     733                 :          0 :     else change_level(Level->depth,deepest[Current_Environment],FALSE);
     734                 :            :   }
     735         [ #  # ]:          0 :   else if (Current_Environment == E_COUNTRYSIDE) {
     736                 :          0 :     mprint("A mysterious force wafts you back home!");
     737                 :          0 :     Player.x = 27;
     738                 :          0 :     Player.y = 19;
     739                 :          0 :     screencheck(Player.x,Player.y);
     740                 :          0 :     drawvision(Player.x,Player.y);
     741                 :          0 :     locprint("Back Outside Rampart.");
     742                 :            :   }
     743                 :          0 :   else mprint("A feeble vortex of magic swirls by and has no further effect.");
     744                 :          0 : }
     745                 :            : 
     746                 :            : 
     747                 :          0 : void cure(int blessing)
     748                 :            : {
     749                 :          0 :   int happened = FALSE;
     750         [ #  # ]:          0 :   if (blessing > -1) {
     751         [ #  # ]:          0 :     if (Player.status[DISEASED]) {
     752                 :          0 :       Player.status[DISEASED]=0;
     753                 :          0 :       mprint("You feel hygienic!");
     754                 :          0 :       happened = TRUE;
     755                 :            :     }
     756         [ #  # ]:          0 :     if (Player.status[POISONED]) {
     757                 :          0 :       Player.status[POISONED] -= 5+blessing*10;
     758         [ #  # ]:          0 :       if (Player.status[POISONED] > 0)
     759                 :          0 :         mprint("The effect of the poison has been reduced.");
     760                 :            :       else {
     761                 :          0 :         Player.status[POISONED] = 0;
     762                 :          0 :         mprint("The poison has been purged from your system.");
     763                 :            :       }
     764                 :          0 :       happened = TRUE;
     765                 :            :     }
     766         [ #  # ]:          0 :     if (Player.status[BLINDED]) {
     767                 :          0 :       Player.status[BLINDED]=0;
     768                 :          0 :       happened = TRUE;
     769                 :          0 :       mprint("Cobwebs clear from before your eyes.");
     770                 :            :     }
     771         [ #  # ]:          0 :     if (! happened) mprint("Nothing much happens.");
     772                 :            :   }
     773                 :          0 :   else disease(12);
     774                 :          0 :   showflags();
     775                 :          0 : }
     776                 :            : 
     777                 :          0 : void disease(int amount)
     778                 :            : {
     779                 :          0 :   mprint("You feel ill.");
     780         [ #  # ]:          0 :   if (! Player.immunity[INFECTION]) {
     781                 :          0 :     mprint("You begin to shiver with ague.");
     782                 :          0 :     Player.status[DISEASED]+=random_range(amount*2)+1;
     783                 :            :   }
     784                 :          0 :   else mprint("The illness fades.");
     785                 :          0 : }
     786                 :            : 
     787                 :          0 : void truesight(int blessing)
     788                 :            : {
     789         [ #  # ]:          0 :   if (blessing > -1) {
     790                 :          0 :     Player.status[TRUESIGHT]+=random_range(10)+1;
     791                 :          0 :     mprint("You feel sharp.");
     792                 :            :   }
     793                 :            :   else {
     794                 :          0 :     Player.status[BLINDED]+=random_range(10)+1;
     795                 :          0 :     mprint("You've been blinded!");
     796                 :            :   }
     797                 :          0 : }
     798                 :            : 
     799                 :            : 
     800                 :          0 : void dispel(int blessing)
     801                 :            : {
     802                 :          0 :   int i,x=Player.x,y=Player.y;
     803                 :            :   pob o;
     804         [ #  # ]:          0 :     if (blessing > -1) {
     805                 :          0 :       setspot(&x,&y);
     806 [ #  # ][ #  # ]:          0 :       if ((x==Player.x)&&(y==Player.y)) {
     807         [ #  # ]:          0 :         for(i=0;i<MAXITEMS;i++) {
     808                 :          0 :         o = Player.possessions[i];
     809         [ #  # ]:          0 :         if (o != NULL)
     810 [ #  # ][ #  # ]:          0 :           if ((o->used) && (o->blessing < 0)) {
     811         [ #  # ]:          0 :             if (blessing+1 + o->blessing >=0) {
     812                 :          0 :               o->used = FALSE;
     813                 :          0 :               setgamestatus(SUPPRESS_PRINTING);
     814                 :          0 :               item_use(o);
     815                 :          0 :               resetgamestatus(SUPPRESS_PRINTING);
     816                 :          0 :               mprint("You hear a sighing sound from");
     817                 :          0 :               mprint(itemid(o));
     818                 :          0 :               o->blessing = 0;
     819                 :          0 :               o->used = TRUE;
     820                 :          0 :               setgamestatus(SUPPRESS_PRINTING);
     821                 :          0 :               item_use(o);
     822                 :          0 :               resetgamestatus(SUPPRESS_PRINTING);
     823                 :            :             }
     824                 :            :             else {
     825                 :          0 :               mprint("You hear dark laughter from");
     826                 :          0 :               mprint(itemid(o));
     827                 :            :             }
     828                 :            :           }
     829                 :            :       }
     830                 :            :     }
     831         [ #  # ]:          0 :     else if (Level->site[x][y].creature != NULL) {
     832         [ #  # ]:          0 :       if (Level->site[x][y].creature->level < blessing * 3) {
     833                 :          0 :         Level->site[x][y].creature->specialf = M_NO_OP;
     834         [ #  # ]:          0 :         if (Level->site[x][y].creature->meleef != M_NO_OP)
     835                 :          0 :           Level->site[x][y].creature->meleef = M_MELEE_NORMAL;
     836                 :          0 :         Level->site[x][y].creature->strikef = M_NO_OP;
     837                 :          0 :         Level->site[x][y].creature->immunity=0;
     838                 :          0 :         m_status_reset(Level->site[x][y].creature,M_INVISIBLE);      
     839                 :          0 :         m_status_reset(Level->site[x][y].creature,INTANGIBLE);
     840                 :            :       }
     841                 :          0 :       else mprint("The monster ignores the effect!");
     842                 :            :     }
     843 [ #  # ][ #  # ]:          0 :     else if ((Level->site[x][y].p_locf == L_TRAP_FIRE) ||
     844         [ #  # ]:          0 :              (Level->site[x][y].p_locf == L_STATUE_WAKE) ||
     845         [ #  # ]:          0 :              (Level->site[x][y].p_locf == L_TRAP_TELEPORT) ||
     846                 :          0 :              (Level->site[x][y].p_locf == L_TRAP_DISINTEGRATE)) {
     847                 :          0 :       Level->site[x][y].p_locf = L_NO_OP;
     848         [ #  # ]:          0 :       if (Level->site[x][y].locchar == TRAP)
     849                 :          0 :         Level->site[x][y].locchar = FLOOR;
     850                 :          0 :       lset(x, y, CHANGED);
     851                 :            :     }
     852         [ #  # ]:          0 :     else if (Level->site[x][y].p_locf == L_MAGIC_POOL)
     853                 :          0 :       Level->site[x][y].p_locf = L_WATER;
     854                 :          0 :     else mprint("Nothing much seems to happen.");
     855                 :            :   }
     856                 :            :   else {
     857                 :          0 :     mprint("A smell of ozone and positive ions fills the air..");
     858 [ #  # ][ #  # ]:          0 :     if (Player.status[ACCURACY] && (Player.status[ACCURACY] < 1000))
     859                 :          0 :       Player.status[ACCURACY]=1;
     860 [ #  # ][ #  # ]:          0 :     if (Player.status[DISPLACED]&&(Player.status[DISPLACED] < 1000))
     861                 :          0 :         Player.status[DISPLACED]=1;
     862 [ #  # ][ #  # ]:          0 :     if (Player.status[HASTED]&&(Player.status[HASTED] < 1000))
     863                 :          0 :       Player.status[HASTED]=1;
     864 [ #  # ][ #  # ]:          0 :     if (Player.status[BREATHING]&&(Player.status[BREATHING] < 1000))
     865                 :          0 :       Player.status[BREATHING]=1;
     866 [ #  # ][ #  # ]:          0 :     if (Player.status[INVISIBLE]&&(Player.status[INVISIBLE] < 1000))
     867                 :          0 :         Player.status[INVISIBLE]=1;
     868 [ #  # ][ #  # ]:          0 :     if (Player.status[REGENERATING]&&(Player.status[REGENERATING] < 1000))
     869                 :          0 :       Player.status[REGENERATING]=1;
     870 [ #  # ][ #  # ]:          0 :     if (Player.status[ALERT]&&(Player.status[ALERT] < 1000))
     871                 :          0 :         Player.status[ALERT]=1;
     872 [ #  # ][ #  # ]:          0 :     if (Player.status[HERO]&&(Player.status[HERO] < 1000))
     873                 :          0 :         Player.status[HERO]=1;
     874 [ #  # ][ #  # ]:          0 :     if (Player.status[LEVITATING]&&(Player.status[LEVITATING] < 1000))
     875                 :          0 :         Player.status[LEVITATING]=1;
     876 [ #  # ][ #  # ]:          0 :     if (Player.status[ACCURATE]&&(Player.status[ACCURATE] < 1000))
     877                 :          0 :         Player.status[ACCURATE]=1;
     878 [ #  # ][ #  # ]:          0 :     if (Player.status[TRUESIGHT]&&(Player.status[TRUESIGHT] < 1000))
     879                 :          0 :         Player.status[TRUESIGHT]=1;
     880                 :          0 :     tenminute_status_check();
     881                 :            :   }
     882                 :          0 : }
     883                 :            : 
     884                 :            : 
     885                 :          0 : void polymorph(int blessing)
     886                 :            : {
     887                 :          0 :   int x=Player.x,y=Player.y,newmonster;
     888                 :            :   struct monster *m;
     889                 :            :   int rnd;
     890                 :            :   /* for the copy */
     891                 :            :   int ohp,olvl;
     892                 :            :   long oimmunity, oxpv;
     893                 :            : 
     894                 :          0 :   setspot(&x,&y);
     895                 :          0 :   clearmsg();
     896 [ #  # ][ #  # ]:          0 :   if ((x==Player.x)&&(y==Player.y)) {
     897                 :          0 :     rnd = random_range(NUMMONSTERS);
     898                 :          0 :     strcpy(Str2,"You enjoy your new life as ");
     899                 :          0 :     strcat(Str2,getarticle(Monsters[rnd].monstring));
     900                 :          0 :     mprint(Str2);
     901                 :          0 :     mprint(Monsters[rnd].monstring);
     902                 :          0 :     mprint("But your game is over....");
     903                 :            : #ifdef NEW_QUOTES
     904                 :          0 :     p_death("autopolymorphosis");
     905                 :            : #else
     906                 :            :     p_death("polymorphing oneself");
     907                 :            : #endif
     908                 :            :   }
     909         [ #  # ]:          0 :   else if ((m=Level->site[x][y].creature) == NULL)
     910                 :          0 :     mprint("Nothing happens.");
     911                 :            :   else {
     912 [ #  # ][ #  # ]:          0 :     if (m_immunityp(m,OTHER_MAGIC) || (m->level > random_range(12))) {
     913                 :          0 :       strcpy(Str1,"The ");
     914                 :          0 :       strcat(Str1,m->monstring);
     915                 :          0 :       strcat(Str1," resists the change!");
     916                 :          0 :       m_status_set(m,HOSTILE);
     917                 :            :     }
     918                 :            :     else {
     919         [ #  # ]:          0 :       if (blessing < 0) {
     920                 :          0 :         do newmonster = random_range(NUMMONSTERS);
     921         [ #  # ]:          0 :         while ((newmonster == NPC) ||
     922         [ #  # ]:          0 :                (newmonster == MAST_THIEF) ||
     923         [ #  # ]:          0 :                (Monsters[newmonster].level <= m->level) ||
     924         [ #  # ]:          0 :                (Monsters[newmonster].uniqueness != COMMON));
     925                 :            :       }
     926                 :            :       else {
     927                 :          0 :         do newmonster = random_range(NUMMONSTERS);
     928         [ #  # ]:          0 :         while ((newmonster == NPC) ||
     929         [ #  # ]:          0 :                (newmonster == MAST_THIEF) ||
     930         [ #  # ]:          0 :                (Monsters[newmonster].uniqueness != COMMON));
     931                 :            :       }
     932                 :            : 
     933                 :          0 :       ohp = m->hp;
     934                 :          0 :       olvl = m->level;
     935                 :          0 :       oimmunity = m->immunity;
     936                 :          0 :       oxpv = m->xpv;
     937                 :          0 :       *m = Monsters[newmonster];
     938                 :          0 :       m->hp = max(m->hp, ohp);
     939                 :          0 :       m->level = max(m->level, olvl);
     940                 :          0 :       m->immunity |= oimmunity;
     941                 :          0 :       m->xpv = max(m->xpv, oxpv);
     942                 :          0 :       m_status_set(m,HOSTILE);
     943                 :            :     }
     944                 :            :   }
     945                 :          0 : }
     946                 :            : 
     947                 :            : 
     948                 :          0 : void hellfire(int x, int y, int blessing)
     949                 :            : {
     950                 :            :   struct monster *m;
     951 [ #  # ][ #  # ]:          0 :   if ((x==Player.x)&&(y==Player.y)) {
     952                 :          0 :     mprint("You have been completely annihilated. Congratulations.");
     953                 :          0 :     p_death("hellfire");
     954                 :            :   }
     955         [ #  # ]:          0 :   else if ((m=Level->site[x][y].creature) == NULL) {
     956                 :          0 :     mprint("The gods are angry over your waste of power...");
     957                 :          0 :     level_drain(5,"indiscriminate use of hellfire");
     958                 :            :   }
     959                 :            :   else {
     960                 :          0 :     mprint("The monster writhes in the flames...");
     961         [ #  # ]:          0 :     if (blessing < 0) {
     962                 :          0 :       mprint("...and appears stronger.");
     963                 :          0 :       morewait();
     964                 :          0 :       mprint("Much stronger.");
     965                 :          0 :       m->hp += 1000;
     966                 :          0 :       m->hit +=20;
     967                 :          0 :       m->dmg += 100;
     968                 :          0 :       m_status_set(m,HOSTILE);
     969                 :            :     }
     970                 :            :     else {
     971         [ #  # ]:          0 :       if (m->uniqueness == COMMON) {
     972                 :          0 :         mprint("and is utterly annihilated. Only a greasy spot remains...");
     973                 :          0 :         m->corpsestr = "a greasy spot";
     974                 :          0 :         m->id = 0;
     975                 :          0 :         free_objlist(m->possessions);
     976                 :          0 :         m->possessions = NULL;
     977                 :            :       }
     978                 :            :       else
     979                 :          0 :         mprint("and dies, cursing your name and the uncaring gods....");
     980                 :          0 :       m_death(m);
     981                 :            :     }
     982                 :            :   }
     983                 :          0 : }
     984                 :            : 
     985                 :            : 
     986                 :          0 : void drain(int blessing)
     987                 :            : {
     988                 :          0 :   int x=Player.x,y=Player.y;
     989                 :            :   struct monster *m;
     990                 :          0 :   setspot(&x,&y);
     991                 :          0 :   mprint("You begin to drain energy...");
     992 [ #  # ][ #  # ]:          0 :   if ((x==Player.x)&&(y==Player.y)) {
     993                 :          0 :     mprint("You drain your own energy....");
     994                 :          0 :     mprint("Uh, oh, positive feedback....");
     995                 :          0 :     level_drain(Player.level,"self-vampirism");
     996                 :            :   }
     997         [ #  # ]:          0 :   else if ((m=Level->site[x][y].creature) != NULL) {
     998 [ #  # ][ #  # ]:          0 :     if ((blessing > -1) && (! m_immunityp(m,NEGENERGY))) {
     999                 :          0 :       mprint("The monster seems weaker...");
    1000                 :          0 :       m_damage(m,m->level*m->level,NEGENERGY);
    1001                 :          0 :       m->hit = max(m->hit - m->level, 1);
    1002                 :          0 :       m->dmg = max(m->dmg - m->level*m->level, 1);
    1003                 :          0 :       m->ac = max(m->ac - m->level, 1);
    1004                 :          0 :       m->level = max(1,m->level-1);
    1005                 :          0 :       mprint("You feel stronger...");
    1006                 :          0 :       gain_experience(m->level*5);
    1007                 :          0 :       Player.hp+=(m->level*m->level / 2);
    1008                 :            :     }
    1009                 :            :     else {
    1010                 :          0 :       mprint("The effect reverses itself!");
    1011                 :          0 :       mprint("The monster seems stronger...");
    1012                 :          0 :       m->hp+=Player.level*Player.level;
    1013                 :          0 :       m->hit += Player.level;
    1014                 :          0 :       m->dmg += Player.level*Player.level;
    1015                 :          0 :       m->ac += Player.level;
    1016                 :          0 :       m->level++;
    1017                 :          0 :       mprint("You feel weaker...");
    1018                 :          0 :       Player.mana = min(0,Player.level*Player.level);
    1019                 :          0 :       level_drain(m->level,"negative energy conflict");
    1020                 :            :     }
    1021                 :            :   }
    1022         [ #  # ]:          0 :   else if (blessing < 0) {
    1023                 :          0 :     mprint("You seem to lose energy, instead of gaining it!");
    1024                 :          0 :     level_drain(3,"reversed energy drain");
    1025                 :            :   }
    1026         [ #  # ]:          0 :   else if (Level->site[x][y].locchar == ALTAR) {
    1027                 :          0 :     mprint("The altar collapses in on itself....");
    1028                 :          0 :     Level->site[x][y].locchar = ABYSS;
    1029                 :          0 :     Level->site[x][y].p_locf = L_ABYSS;
    1030                 :          0 :     lset(x, y, CHANGED);
    1031         [ #  # ]:          0 :     if (! Player.patron) {
    1032                 :          0 :       mprint("You drain some theurgic energy from the altar....");
    1033                 :          0 :       gain_experience(40);
    1034                 :          0 :       Player.hp += 20;
    1035                 :          0 :       Player.pow+=2;
    1036                 :            :     }
    1037         [ #  # ]:          0 :     if (Level->site[x][y].aux == Player.patron) {
    1038                 :          0 :       mprint("Your deity is enraged.");
    1039                 :          0 :       mprint("You are struck by godsfire.");
    1040                 :          0 :       p_damage(Player.hp-1,UNSTOPPABLE,"godsfire");
    1041                 :          0 :       mprint("You feel atheistic.");
    1042                 :          0 :       Player.patron = -1;
    1043                 :          0 :       Player.rank[PRIESTHOOD] = 0;
    1044                 :            :     }
    1045                 :            :     else {
    1046                 :          0 :       mprint("You feel the wrath of a god....");
    1047                 :          0 :       p_damage(random_range(Player.level*10),UNSTOPPABLE,"divine wrath");
    1048         [ #  # ]:          0 :       if (Player.patron != 0) {
    1049                 :          0 :         mprint("Your deity doesn't seem to mind your action, though.");
    1050                 :          0 :         gain_experience(100);
    1051                 :            :       }
    1052                 :            :     }
    1053                 :            :   }
    1054                 :            :   else {
    1055                 :          0 :     mprint("You drain some energy from the ambient megaflow.");
    1056                 :          0 :     Player.hp++;
    1057                 :            :   }
    1058                 :          0 : }
    1059                 :            : 
    1060                 :          0 : void sanctuary(void)
    1061                 :            : {
    1062         [ #  # ]:          0 :   if (Level->environment == E_TEMPLE) 
    1063                 :          0 :     mprint("Odd, the spell has no effect. I wonder why.");
    1064                 :            :   else {
    1065                 :          0 :     mprint("You're standing on sacred ground!");
    1066                 :          0 :     Player.sx = Player.x;
    1067                 :          0 :     Player.sy = Player.y;
    1068                 :            :   }
    1069                 :          0 : }
    1070                 :            : 
    1071                 :          0 : void shadowform(void)
    1072                 :            : {
    1073                 :            :   /* WDT HACK: this fix might work, but it seems like the immunity
    1074                 :            :    * will be FAR too short.  It's obviously better than the old 
    1075                 :            :    * situation, though... */
    1076                 :            :   /* DAG reply: this is not too short, SHADOWFORM gets decremented in
    1077                 :            :      ten minute intervals (tenminute_check), not one minute intervals. */
    1078         [ #  # ]:          0 :   if (!Player.status[SHADOWFORM]) {
    1079                 :          0 :     mprint("You feel like a shadow.");
    1080                 :          0 :     Player.immunity[NORMAL_DAMAGE]++;
    1081                 :          0 :     Player.immunity[ACID]++;
    1082                 :          0 :     Player.immunity[THEFT]++;
    1083                 :          0 :     Player.immunity[INFECTION]++;
    1084                 :          0 :     Player.status[SHADOWFORM]+=Player.level;
    1085                 :            :   }
    1086                 :            :   else {
    1087                 :          0 :     mprint("You feel even more shadowy.");
    1088                 :          0 :     Player.status[SHADOWFORM]+=Player.level;
    1089                 :            :   }
    1090                 :          0 : }
    1091                 :            : 
    1092                 :          0 : void illuminate(int blessing)
    1093                 :            : {
    1094                 :          0 :   int r=Level->site[Player.x][Player.y].roomnumber;
    1095         [ #  # ]:          0 :   if (blessing > -1) {
    1096         [ #  # ]:          0 :     if (r > ROOMBASE) {
    1097         [ #  # ]:          0 :       if (loc_statusp(Player.x,Player.y,LIT))
    1098                 :          0 :         mprint("A glow surrounds you.");
    1099                 :            :       else {
    1100                 :          0 :         mprint("The room lights up!");
    1101                 :          0 :         Player.status[ILLUMINATION]+=blessing+3;
    1102                 :          0 :         spreadroomlight(Player.x,
    1103                 :            :                         Player.y,
    1104                 :          0 :                         Level->site[Player.x][Player.y].roomnumber);
    1105                 :            :       }
    1106                 :            :     }
    1107                 :          0 :     else mprint("You see a faint glimmer of light which quickly fades.");
    1108                 :            :   }
    1109                 :            :   else {
    1110         [ #  # ]:          0 :     if (r > ROOMBASE) {
    1111         [ #  # ]:          0 :       if (! loc_statusp(Player.x,Player.y,LIT))
    1112                 :          0 :         mprint("Nothing much happens.");
    1113                 :            :       else {
    1114                 :          0 :         mprint("The room darkens!");
    1115                 :          0 :         spreadroomdark(Player.x,
    1116                 :            :                        Player.y,
    1117                 :          0 :                        Level->site[Player.x][Player.y].roomnumber);
    1118                 :            :       }
    1119                 :            :     }
    1120                 :          0 :     else mprint("The gloom thickens for a moment.");
    1121                 :            :   }
    1122                 :          0 : }
    1123                 :            : 
    1124                 :            : 
    1125                 :          0 : void drain_life(int amount)
    1126                 :            : {
    1127                 :          0 :   amount = abs(amount);
    1128                 :          0 :   mprint("You feel cold!");
    1129         [ #  # ]:          0 :   if (p_immune(NEGENERGY))
    1130                 :          0 :     mprint("... but the feeling quickly fades.");
    1131                 :            :   else {
    1132         [ #  # ]:          0 :     if (random_range(2)) {
    1133                 :          0 :       mprint("The coldness spreads throughout your body...");
    1134                 :          0 :       Player.str-=amount;
    1135                 :          0 :       Player.con-=amount;
    1136 [ #  # ][ #  # ]:          0 :       if ((Player.str < 3) || (Player.con < 3)) {
    1137                 :          0 :         mprint("You suffer a fatal heart attack!!!");
    1138                 :          0 :         Player.hp = 0;
    1139                 :          0 :         strcpy(Str2,"a coronary");
    1140                 :          0 :         p_death(Str2);
    1141                 :            :       }
    1142                 :            :     }
    1143                 :            :     else {
    1144                 :          0 :       mprint("The coldness saps your very soul...");
    1145                 :          0 :       strcpy(Str2,"soul destruction");
    1146                 :          0 :       level_drain(amount,Str2);
    1147                 :            :     }
    1148                 :            :   }
    1149                 :          0 : }
    1150                 :            : 
    1151                 :            : 
    1152                 :          0 : void inflict_fear(int x, int y)
    1153                 :            : {
    1154                 :            :   struct monster *m;
    1155 [ #  # ][ #  # ]:          0 :   if ((Player.x == x) && (Player.y == y)) {
    1156                 :          0 :     mprint("You shudder with otherworldly dread.");
    1157         [ #  # ]:          0 :     if (Player.immunity[FEAR] > 0)
    1158                 :          0 :       mprint("You brace up and face your fear like a hero!");
    1159                 :            :     else {
    1160                 :          0 :       mprint("You panic!");
    1161                 :          0 :       Player.status[AFRAID]+=10;
    1162                 :            :     }
    1163                 :            :   }
    1164         [ #  # ]:          0 :   else if ((m = Level->site[x][y].creature) != NULL) {
    1165         [ #  # ]:          0 :     if (m->uniqueness == COMMON) {
    1166                 :          0 :       strcpy(Str2,"The ");
    1167                 :          0 :       strcat(Str2,m->monstring);
    1168                 :            :     }
    1169                 :          0 :     else strcpy(Str2,m->monstring);
    1170                 :          0 :     m->speed = max(2,m->speed-1);
    1171         [ #  # ]:          0 :     if (m_immunityp(m,FEAR)) 
    1172                 :          0 :       strcat(Str2,"seems enraged!");
    1173                 :            :     else {
    1174                 :          0 :       strcat(Str2,"is terrorized!");
    1175                 :          0 :       m_dropstuff(m);
    1176         [ #  # ]:          0 :       if (m_statusp(m,MOBILE))
    1177                 :          0 :         m->movef = M_MOVE_SCAREDY;
    1178                 :            :     }
    1179                 :            :   }
    1180                 :          0 :   else mprint("A thrill of fear tickles your spine ... and passes.");
    1181                 :          0 : }
    1182                 :            : 
    1183                 :            : 
    1184                 :            : /*Turns on deflection status for the player */
    1185                 :          0 : void deflection(int blessing)
    1186                 :            : {
    1187         [ #  # ]:          0 :   if (blessing > -1) {
    1188                 :          0 :       mprint("You feel buffered.");
    1189                 :          0 :       Player.status[DEFLECTION] = blessing + random_range(6);
    1190                 :            :     }
    1191                 :            :   else {
    1192                 :          0 :     mprint("You feel vulnerable");
    1193                 :          0 :     Player.status[VULNERABLE] += random_range(6) - blessing;
    1194                 :            :   }
    1195                 :          0 : }

Generated by: LCOV version 1.11