LCOV - code coverage report
Current view: top level - omega-rpg-0.90-pa9 - itemf3.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 629 0.0 %
Date: 2017-09-08 22:00:26 Functions: 0 36 0.0 %
Branches: 0 262 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* omega copyright (C) 1987,1988,1989 by Laurence Raphael Brothers */
       2                 :            : /* itemf3.c */
       3                 :            : 
       4                 :            : /* mostly artifact and stick functions */
       5                 :            : 
       6                 :            : #include "glob.h"
       7                 :            : 
       8                 :            : /* amulet of the planes */
       9                 :          0 : void i_planes(pob o)
      10                 :            : {
      11         [ #  # ]:          0 :   if (Player.mana < 1) print1("The amulet spits some multicolored sparks.");
      12                 :            :   else {
      13                 :          0 :     print1("You focus mana into the amulet....");
      14                 :          0 :     Player.mana = max(0,Player.mana-100);
      15                 :          0 :     dataprint();
      16                 :          0 :     morewait();
      17                 :          0 :     strategic_teleport(1);
      18                 :            :   }
      19                 :          0 : }
      20                 :            : 
      21                 :            : /* amulet of serenity */
      22                 :          0 : void i_serenity(pob o)
      23                 :            : {
      24         [ #  # ]:          0 :   if (Player.mana < 1) print1("The amulet emits a dull ring.");
      25                 :            :   /* should the amulet drop_at a real ring? */
      26                 :            :   else {
      27                 :          0 :     print1("You focus your will with the amulet....");
      28                 :          0 :     Player.mana = max(0,Player.mana-10);
      29                 :          0 :     Player.maxhp -= 1;
      30                 :          0 :     Player.hp = Player.maxhp;
      31                 :          0 :     dataprint();
      32                 :          0 :     morewait();
      33                 :            :     
      34                 :          0 :     s_restore();
      35                 :          0 :     s_cure();
      36                 :          0 :     s_breathe();
      37                 :          0 :     s_alert();
      38                 :            :     /* artifacts should have a unique function... PGM */
      39                 :            :   }
      40                 :          0 : }
      41                 :            : 
      42                 :            : 
      43                 :            : /* the sceptre of high magic */
      44                 :          0 : void i_sceptre(pob o)
      45                 :            : {
      46         [ #  # ]:          0 :   if (HiMagicUse == Date) 
      47                 :          0 :     print1("The Sceptre makes a sort of dull 'thut' noise.");
      48 [ #  # ][ #  # ]:          0 :   else if (Current_Environment == E_CIRCLE || Current_Environment == E_ASTRAL)
      49                 :            :   {
      50                 :          0 :     HiMagicUse = Date; /* WDT: this looks like it's a good place to use
      51                 :            :                         * the batteries. */
      52                 :          0 :     print1("The Sceptre warps strangely for a second, and then subsides.");
      53                 :          0 :     morewait();
      54                 :          0 :     print2("You smell ozone."); /* WDT: explain the battery use. */
      55                 :            :   }
      56                 :            :   else {
      57                 :          0 :     HiMagicUse = Date;
      58                 :          0 :     print1("With a shriek of tearing aether, a magic portal appears!");
      59                 :          0 :     print2("Step through? [yn] ");
      60         [ #  # ]:          0 :     if (ynq()=='y') change_environment(E_COURT);
      61                 :          0 :     print1("The sceptre seems to subside. You hear a high whine, as of");
      62                 :          0 :     print2("capacitors beginning to recharge.");
      63                 :          0 :     morewait();
      64                 :            :   }
      65                 :          0 : }
      66                 :            : 
      67                 :            : 
      68                 :            : /* the star gem */
      69                 :          0 : void i_stargem(pob o)
      70                 :            : {
      71         [ #  # ]:          0 :   if (StarGemUse == Date) {
      72                 :          0 :     print1("The Star Gem glints weakly as if to say:");
      73                 :          0 :     print2("'You have used me overmuch.'");
      74                 :          0 :     print3("and it vanishes a puff of regret.");
      75                 :          0 :     Objects[o->id].uniqueness = UNIQUE_UNMADE;
      76                 :            :                 /* it's now out there, somewhere */
      77                 :          0 :     dispose_lost_objects(1,o);
      78                 :            :   }
      79                 :            :   else {
      80                 :          0 :     StarGemUse = Date;
      81         [ #  # ]:          0 :     if (o->blessing < 1) {
      82                 :          0 :       print1("The Star Gem shines brightly and emits a musical tone.");
      83                 :          0 :       print2("You see a dark cloud roil away from it.");
      84                 :          0 :       morewait();
      85                 :          0 :       o->blessing = 10;
      86                 :            :     }
      87                 :          0 :     print1("The star gem flares with golden light!");
      88                 :          0 :     morewait();
      89         [ #  # ]:          0 :     if (Player.status[ILLUMINATION] < 1000) {
      90                 :          0 :       print1("Interesting, you seem to be permanently accompanied");
      91                 :          0 :       print2("by a friendly lambent glow....");
      92                 :          0 :       morewait();
      93                 :          0 :       Player.status[ILLUMINATION] = 1500;
      94                 :            :     }
      95                 :          0 :     print1("You suddenly find yourself whisked away by some unknown force!");
      96                 :          0 :     morewait();
      97                 :          0 :     setgamestatus(COMPLETED_ASTRAL);
      98                 :          0 :     change_environment(E_COUNTRYSIDE);
      99                 :          0 :     Player.x = 61;
     100                 :          0 :     Player.y = 3;
     101                 :          0 :     screencheck(Player.x,Player.y);
     102                 :          0 :     drawvision(Player.x,Player.y);
     103                 :          0 :     locprint("Star Peak");
     104                 :          0 :     Country[Player.x][Player.y].current_terrain_type =
     105                 :          0 :       Country[Player.x][Player.y].base_terrain_type;
     106                 :          0 :     c_set(Player.x, Player.y, CHANGED);
     107                 :          0 :     print2("The Star Gem's brilliance seems to fade.");
     108                 :            :   }
     109                 :          0 : }
     110                 :            : 
     111                 :            : 
     112                 :            : /* wand of fear */
     113                 :          0 : void i_fear(pob o)
     114                 :            : {
     115                 :          0 :   int x=Player.x,y=Player.y;
     116                 :          0 :   Objects[o->id].known = 1;
     117         [ #  # ]:          0 :   o->known = max(1,o->known);
     118                 :          0 :   setspot(&x,&y);
     119         [ #  # ]:          0 :   if (o->blessing < 0) {
     120                 :          0 :     x = Player.x;
     121                 :          0 :     y = Player.y;
     122                 :            :   }
     123                 :          0 :   inflict_fear(x,y);
     124                 :          0 : }
     125                 :            :         
     126                 :            : 
     127                 :          0 : void i_juggernaut(pob o)
     128                 :            : {
     129                 :          0 :   int d,x=Player.x,y=Player.y;
     130                 :          0 :   int seen = 1, not_seen = 0;
     131                 :          0 :   int tunneled = 0;
     132                 :            : 
     133                 :          0 :   print1("You activate the Juggernaut of Karnak!");
     134         [ #  # ]:          0 :   if (! o->known) {
     135                 :          0 :     print2("Uh, oh, it's coming this way!");
     136                 :          0 :     p_death("the Juggernaut of Karnak");
     137                 :            :   }
     138                 :            :   else {
     139                 :          0 :     d = getdir();
     140         [ #  # ]:          0 :     if (d == ABORT)
     141                 :          0 :       print2("You deactivate the Juggernaut before it escapes.");
     142                 :            :     else {
     143                 :          0 :       print1("Vroom! ");
     144         [ #  # ]:          0 :       while (inbounds(x+Dirs[0][d],y+Dirs[1][d])) {
     145                 :          0 :         x+=Dirs[0][d];
     146                 :          0 :         y+=Dirs[1][d];
     147 [ #  # ][ #  # ]:          0 :         if (!view_unblocked(x, y) || offscreen(x,y))
     148                 :          0 :           seen = 0;
     149         [ #  # ]:          0 :         if (Level->site[x][y].locchar == WALL)
     150                 :          0 :           tunneled++;
     151 [ #  # ][ #  # ]:          0 :         if (Level->site[x][y].locchar != WATER &&
     152         [ #  # ]:          0 :           Level->site[x][y].locchar != VOID_CHAR &&
     153         [ #  # ]:          0 :           Level->site[x][y].locchar != ABYSS &&
     154         [ #  # ]:          0 :           Level->site[x][y].locchar != SPACE &&
     155                 :          0 :           Level->site[x][y].locchar != LAVA)
     156                 :            :         {
     157                 :          0 :           Level->site[x][y].locchar = FLOOR;
     158                 :          0 :           Level->site[x][y].p_locf = L_NO_OP;
     159                 :            :         }
     160                 :          0 :         lreset(x, y, SECRET);
     161                 :          0 :         lset(x, y, CHANGED);
     162         [ #  # ]:          0 :         if (Level->site[x][y].creature != NULL) {
     163         [ #  # ]:          0 :           if (seen)
     164                 :          0 :             nprint1("Splat! ");
     165                 :            :           else
     166                 :          0 :             not_seen++;
     167                 :          0 :           setgamestatus(SUPPRESS_PRINTING);
     168                 :          0 :           m_death(Level->site[x][y].creature);
     169                 :          0 :           resetgamestatus(SUPPRESS_PRINTING);
     170                 :            :         }
     171                 :          0 :         plotspot(x, y, FALSE);
     172                 :          0 :         omshowcursor(x, y);
     173                 :            :       }
     174         [ #  # ]:          0 :       if (not_seen > 6)
     175                 :          0 :         print2("You hear many distant screams...");
     176         [ #  # ]:          0 :       else if (not_seen > 3)
     177                 :          0 :         print2("You hear several distant screams...");
     178         [ #  # ]:          0 :       else if (not_seen > 1)
     179                 :          0 :         print2("You hear a couple of distant screams...");
     180         [ #  # ]:          0 :       else if (not_seen == 1)
     181                 :          0 :         print2("You hear a distant scream...");
     182                 :          0 :       gain_experience(1000);
     183                 :          0 :       dispose_lost_objects(1,o);
     184                 :          0 :       Level->tunnelled += tunneled - 1;
     185                 :          0 :       tunnelcheck();
     186                 :            :     }
     187                 :            :   }
     188                 :          0 : }
     189                 :            : 
     190                 :            : 
     191                 :          0 : void i_symbol(pob o)
     192                 :            : {
     193                 :            :   int i;
     194         [ #  # ]:          0 :   if (! o->known)
     195                 :          0 :     print1("Nothing seems to happen.");
     196                 :            :   /* if o->charge != 17, then symbol was stolen from own high priest! */
     197 [ #  # ][ #  # ]:          0 :   else if ((o->aux != Player.patron) || (o->charge != 17)){
     198                 :          0 :     print1("You invoke the deity...");
     199                 :          0 :     print2("...who for some reason seems rather annoyed at you...");
     200                 :          0 :     print3("You are enveloped in Godsfire!");
     201                 :          0 :     morewait();
     202         [ #  # ]:          0 :     for(;Player.hp>1;Player.hp--)
     203                 :          0 :       dataprint();
     204                 :          0 :     morewait();
     205         [ #  # ]:          0 :     for(i=0;i<MAXITEMS;i++)
     206         [ #  # ]:          0 :       if (Player.possessions[i] != NULL)
     207                 :          0 :         dispose_lost_objects(Player.possessions[i]->number,
     208                 :          0 :                              Player.possessions[i]);
     209                 :          0 :     Player.mana = 0;
     210                 :          0 :     dataprint();
     211                 :            :   }
     212 [ #  # ][ #  # ]:          0 :   else if ( (SymbolUseDay == day() ) && (SymbolUseHour == hour())) {
     213                 :          0 :     print1("Your deity frowns upon this profligate use of power...");
     214                 :          0 :     print2("Shazam! A bolt of Godsfire! Your symbol shatters!");
     215                 :          0 :     dispose_lost_objects(1,o);
     216                 :          0 :     Player.hp = 1;
     217                 :          0 :     dataprint();
     218                 :            :   }
     219                 :            :   else {
     220                 :          0 :     print1("A mystic flow of theurgic energy courses through your body!");
     221                 :          0 :     SymbolUseHour = hour();
     222                 :          0 :     SymbolUseDay = day();
     223                 :          0 :     cleanse(1);
     224                 :          0 :     heal(10);
     225         [ #  # ]:          0 :     Player.mana = max(Player.mana,calcmana());
     226                 :          0 :     dataprint();
     227                 :            :   }
     228                 :          0 : }
     229                 :            : 
     230                 :            : 
     231                 :          0 : void i_crystal(pob o)
     232                 :            : {
     233         [ #  # ]:          0 :   if (!o->known) print1("You can't figure out how to activate this orb.");
     234                 :            :   else {
     235                 :          0 :     print1("You gaze into your crystal ball.");
     236 [ #  # ][ #  # ]:          0 :     if ( (ViewDay == day()) && (ViewHour == hour())) print2("All you get is Gilligan's Island reruns.");
     237 [ #  # ][ #  # ]:          0 :     else if ((o->blessing<0) || (Player.iq+Player.level < random_range(30))) {
     238                 :          0 :       ViewHour = hour();
     239                 :          0 :       ViewDay = day();
     240                 :          0 :       print2("Weird interference patterns from the crystal fog your mind....");
     241                 :          0 :       amnesia();
     242                 :            :     }
     243                 :            :     else {
     244                 :          0 :       ViewHour = hour();
     245                 :          0 :       ViewDay = day();
     246                 :          0 :       print2("You sense the presence of life...");
     247                 :          0 :       mondet(1);
     248                 :          0 :       morewait();
     249                 :          0 :       print2("You sense the presence of objects...");
     250                 :          0 :       objdet(1);
     251                 :          0 :       morewait();
     252                 :          0 :       print2("You begin to see visions of things beyond your ken....");
     253                 :          0 :       hint();
     254                 :            :     }
     255                 :            :   }
     256                 :          0 : }
     257                 :            :     
     258                 :          0 : void i_antioch(pob o)
     259                 :            : {
     260                 :          0 :   int x=Player.x,y=Player.y;
     261                 :            :   int count;
     262         [ #  # ]:          0 :   if (!o->known){
     263                 :          0 :     print1("Ka-Boom!");
     264                 :          0 :     print2("You seem to have annihilated yourself.");
     265                 :          0 :     p_death("the Holy Hand-Grenade of Antioch");
     266                 :            :   }
     267                 :            :   else {
     268                 :          0 :     print1("Bring out the Holy Hand-Grenade of Antioch!");
     269                 :          0 :     setspot(&x,&y);
     270                 :          0 :     print2("Ok, you pull the pin.....");
     271                 :          0 :     morewait();
     272                 :          0 :     print1("What do you count up to? ");
     273                 :          0 :     count = (int) parsenum("");
     274 [ #  # ][ #  # ]:          0 :     if ((count < 3)&&(Level->site[x][y].creature!=NULL)) {
     275                 :          0 :       print1("`Three shall be the number of thy counting....");
     276                 :          0 :       print2("And the number of thy counting shall be three.'");
     277                 :          0 :       print3("Your target picks up the grenade and throws it back!");
     278                 :          0 :       morewait();
     279                 :          0 :       clearmsg();
     280                 :          0 :       print1("Ka-Boom!");
     281                 :          0 :       p_death("the Holy Hand-Grenade of Antioch");
     282                 :            :     }
     283         [ #  # ]:          0 :     else if (count>3) {
     284                 :          0 :       print1("`Three shall be the number of thy counting.");
     285                 :          0 :       print2("And the number of thy counting shall be three.'");
     286                 :          0 :       morewait();
     287                 :          0 :       clearmsg();
     288                 :          0 :       print1("Ka-Boom!");
     289                 :          0 :       p_death("the Holy Hand-Grenade of Antioch");
     290                 :            :     }
     291                 :            :     else {
     292                 :          0 :       print1("Ka-Boom!");
     293                 :          0 :       gain_experience(1000);
     294                 :          0 :       Level->site[x][y].locchar = TRAP;
     295                 :          0 :       Level->site[x][y].p_locf = L_TRAP_DOOR;
     296                 :          0 :       lset(x, y, CHANGED);
     297         [ #  # ]:          0 :       if (Level->site[x][y].creature != NULL) {
     298                 :          0 :         m_death(Level->site[x][y].creature);
     299                 :          0 :         print2("You are covered with gore.");
     300                 :            :       }
     301                 :          0 :       Level->site[x][y].things = NULL;
     302                 :            :     }
     303                 :            :   }
     304                 :          0 :   dispose_lost_objects(1,o);
     305                 :          0 : }
     306                 :            : 
     307                 :          0 : void i_kolwynia(pob o)
     308                 :            : {
     309                 :            :   int i;
     310         [ #  # ]:          0 :   if (! o->known) {
     311                 :          0 :     print1("You destroy youself with a mana storm. How sad.");
     312                 :          0 :     p_death("Kolwynia, The Key That Was Lost");
     313                 :            :   }
     314                 :            :   else {
     315                 :          0 :     gain_experience(5000);
     316                 :          0 :     print1("You seem to have gained complete mastery of magic.");
     317                 :          0 :     Player.maxpow *= 2;
     318                 :          0 :     Player.pow = max( Player.pow, Player.maxpow );
     319         [ #  # ]:          0 :     for(i=0;i<NUMSPELLS;i++)
     320                 :          0 :       Spells[i].known = TRUE;
     321                 :            :   }
     322                 :          0 :   dispose_lost_objects(1,o);
     323                 :          0 : }
     324                 :            : 
     325                 :          0 : void i_enchantment(pob o)
     326                 :            : {
     327                 :            :   char response;
     328         [ #  # ]:          0 :   if (ZapHour == hour()) 
     329                 :          0 :     print1("The staff doesn't seem to have recharged yet.");
     330         [ #  # ]:          0 :   else if (! o->known) {
     331                 :          0 :     ZapHour = hour();
     332                 :          0 :     print1("You blast the staff backwards....");
     333                 :          0 :     dispel(-1);
     334                 :            :   }
     335                 :            :   else {
     336                 :          0 :     ZapHour = hour();
     337                 :          0 :     print1("Zap with white or black end [wb] ");
     338                 :          0 :     do response = (char) mcigetc();
     339 [ #  # ][ #  # ]:          0 :     while ((response != 'w') && (response != 'b'));
     340                 :          0 :     print2("The staff discharges!");
     341         [ #  # ]:          0 :     if (response == 'w') enchant(o->blessing*2+1);
     342                 :          0 :     else dispel(o->blessing);
     343                 :            :   }
     344                 :          0 : }
     345                 :            : 
     346                 :          0 : void i_helm(pob o)
     347                 :            : {
     348 [ #  # ][ #  # ]:          0 :   if ( (HelmDay == day()) && ((HelmHour == hour()) ))
     349                 :          0 :     print1("The helm doesn't seem to have recharged yet.");
     350         [ #  # ]:          0 :   else if (! o->known) {
     351                 :          0 :     HelmHour = hour();
     352                 :          0 :     HelmDay = day();
     353                 :          0 :     print1("You put the helm on backwards....");
     354                 :          0 :     p_teleport(-1);
     355                 :            :   }
     356                 :            :   else {
     357                 :          0 :     HelmHour = hour();
     358                 :          0 :     print1("Your environment fades.... and rematerializes.");
     359                 :          0 :     p_teleport(o->blessing);
     360                 :            :   }
     361                 :          0 : }
     362                 :            :  
     363                 :            : 
     364                 :          0 : void i_death(pob o)
     365                 :            : {
     366                 :          0 :   clearmsg();
     367                 :          0 :   print1("Bad move...");
     368                 :          0 :   p_death("the Potion of Death");
     369                 :          0 : }
     370                 :            : 
     371                 :          0 : void i_life(pob o)
     372                 :            : {
     373                 :          0 :   clearmsg();
     374                 :          0 :   print1("Good move.");
     375                 :          0 :   Player.maxhp = 2 * Player.maxhp;
     376                 :          0 :   Player.hp = max( Player.hp, Player.maxhp );
     377                 :          0 :   dispose_lost_objects(1,o);
     378                 :          0 : }
     379                 :            : 
     380                 :            : 
     381                 :            : /* f = fire, w = water, e = earth, a = air, m = mastery */
     382                 :          0 : int orbcheck(char element)
     383                 :            : {
     384                 :            :   char response;
     385                 :          0 :   print1("The orb begins to glow with increasing intensity!");
     386                 :          0 :   print2("You have the feeling you need to do something more....");
     387                 :          0 :   morewait();
     388                 :          0 :   print1("Burn it in fire [f] ");
     389                 :          0 :   print2("Douse it with water [w] ");
     390                 :          0 :   morewait();
     391                 :          0 :   print1("Smash it against the earth [e] ");
     392                 :          0 :   print2("Toss is through the air [a] ");
     393                 :          0 :   morewait();
     394                 :          0 :   print1("Mix the above actions, doing them in sequence [m] ");
     395                 :            :   do {
     396                 :          0 :     print2("Which one [f,w,e,a,m] ");
     397                 :          0 :     response = (char) mcigetc();
     398         [ #  # ]:          0 :   } while ((response != 'f') &&
     399         [ #  # ]:          0 :            (response != 'w') &&
     400         [ #  # ]:          0 :            (response != 'e') &&
     401         [ #  # ]:          0 :            (response != 'a') &&
     402         [ #  # ]:          0 :            (response != 'm'));
     403                 :          0 :   return(response == element);
     404                 :            : }
     405                 :            : 
     406                 :            : /* orb functions */
     407                 :          0 : void i_orbfire(pob o)
     408                 :            : {
     409         [ #  # ]:          0 :   if (! orbcheck('f')) {
     410                 :          0 :     print1("Bad choice!");
     411                 :          0 :     print2("The Orb of Fire blasts you!");
     412                 :          0 :     fball(Player.x,Player.y,Player.x,Player.y,250);
     413                 :          0 :     o->known = 1;
     414                 :            :   }
     415                 :            :   else {
     416                 :          0 :     print1("The Orb of Fire flares a brilliant red!");
     417                 :          0 :     Spells[S_FIREBOLT].known = TRUE;
     418                 :          0 :     gain_experience(10000);
     419                 :          0 :     Player.immunity[FLAME]+=100;
     420                 :          0 :     print2("You feel fiery!");
     421                 :          0 :     o->plus = 100;
     422                 :          0 :     o->blessing = 100;
     423                 :          0 :     i_firebolt(o);
     424                 :            :   }
     425                 :          0 :   *o = Objects[OB_DEAD_ORB];
     426                 :          0 : }
     427                 :            : 
     428                 :            : 
     429                 :          0 : void i_orbwater(pob o)
     430                 :            : {
     431         [ #  # ]:          0 :   if (! orbcheck('w')) {
     432                 :          0 :     print1("A serious mistake!");
     433                 :          0 :     print2("The Orb of Water blasts you!");
     434                 :          0 :     heal(-250);
     435                 :          0 :     o->known = 1;
     436                 :            :   }
     437                 :            :   else {
     438                 :          0 :     print1("The Orb of Water pulses a deep green!");
     439                 :          0 :     Spells[S_DISRUPT].known = TRUE;
     440                 :          0 :     Player.immunity[POISON]+=100;
     441                 :          0 :     gain_experience(10000);
     442                 :          0 :     print2("You feel wet!");
     443                 :          0 :     o->plus = 100;
     444                 :          0 :     o->blessing = 100;
     445                 :          0 :     i_disrupt(o);
     446                 :            :   }
     447                 :          0 :   *o = Objects[OB_DEAD_ORB];
     448                 :          0 : }
     449                 :            : 
     450                 :            : 
     451                 :            : 
     452                 :          0 : void i_orbearth(pob o)
     453                 :            : {
     454                 :            :   int i;
     455         [ #  # ]:          0 :   if (! orbcheck('e')) {
     456                 :          0 :     print1("What a maroon!");
     457                 :          0 :     print2("The Orb of Earth blasts you!");
     458                 :          0 :     Player.con -= 10;
     459         [ #  # ]:          0 :     if (Player.con < 3)
     460                 :          0 :       p_death("congestive heart failure");
     461                 :            :     else {
     462                 :          0 :       print3("Your possessions disintegrate!");
     463         [ #  # ]:          0 :       for (i=0;i<MAXITEMS;i++)
     464         [ #  # ]:          0 :         if (Player.possessions[i] != NULL) 
     465                 :          0 :           dispose_lost_objects(Player.possessions[i]->number,
     466                 :          0 :                                Player.possessions[i]);
     467         [ #  # ]:          0 :       for (i=0;i<MAXPACK;i++) 
     468         [ #  # ]:          0 :         if (Player.pack[i] != NULL) {
     469                 :          0 :           free((char *) Player.pack[i]);
     470                 :          0 :           Player.pack[i] = NULL;
     471                 :            :         }
     472                 :          0 :       Player.packptr = 0;
     473                 :          0 :       o->known = 1;
     474                 :            :     }
     475                 :            :   }
     476                 :            :   else {
     477                 :          0 :     print1("The Orb of Earth emanates a brownish aura!");
     478                 :          0 :     Spells[S_DISINTEGRATE].known = TRUE;
     479                 :          0 :     gain_experience(10000);
     480                 :          0 :     Player.immunity[NEGENERGY]+=100;
     481                 :          0 :     print2("You feel earthy!");
     482                 :          0 :     o->plus = 100;
     483                 :          0 :     o->blessing = 100;
     484                 :          0 :     i_disintegrate(o);
     485                 :            :   }
     486                 :          0 :   *o = Objects[OB_DEAD_ORB];
     487                 :          0 : }
     488                 :            : 
     489                 :            : 
     490                 :          0 : void i_orbair(pob o)
     491                 :            : {
     492         [ #  # ]:          0 :   if (! orbcheck('a')) {
     493                 :          0 :     print1("You lose!");
     494                 :          0 :     print2("The Orb of Air blasts you!");
     495                 :          0 :     lball(Player.x,Player.y,Player.x,Player.y,100);
     496                 :          0 :     o->known = 1;
     497                 :            :   }
     498                 :            :   else {
     499                 :          0 :     print1("The Orb of Air flashes blue!");
     500                 :          0 :     Spells[S_LBALL].known = TRUE; /* lball */
     501                 :          0 :     gain_experience(10000);
     502                 :          0 :     print2("You feel airy!");
     503                 :          0 :     Player.immunity[ELECTRICITY]+=100;
     504                 :          0 :     o->plus = 100;
     505                 :          0 :     o->blessing = 100;
     506                 :          0 :     i_invisible(o);
     507                 :          0 :     i_lbolt(o);
     508                 :            :   }
     509                 :          0 :   *o = Objects[OB_DEAD_ORB];
     510                 :          0 : }
     511                 :            : 
     512                 :            : 
     513                 :          0 : void i_orbmastery(pob o)
     514                 :            : {
     515                 :            : 
     516         [ #  # ]:          0 :   if (! orbcheck('m')) {
     517                 :          0 :     print1("A fatal error!");
     518                 :          0 :     print2("The Orb of Mastery blasts you to cinders!");
     519                 :          0 :     p_death("playing with the Orb of Mastery");
     520                 :          0 :     o->known = 1;
     521                 :            :   }
     522   [ #  #  #  # ]:          0 :   else if ((find_and_remove_item(OB_ORB_FIRE,-1)) &&
     523         [ #  # ]:          0 :            (find_and_remove_item(OB_ORB_WATER,-1)) &&
     524         [ #  # ]:          0 :            (find_and_remove_item(OB_ORB_EARTH,-1)) &&
     525                 :          0 :            (find_and_remove_item(OB_ORB_AIR,-1))) {
     526                 :          0 :     print1("The Orb of Mastery radiates rainbow colors!");
     527                 :          0 :     print2("You feel godlike.");
     528         [ #  # ]:          0 :     Player.iq  = max( Player.iq,  Player.maxiq  = 2 * Player.maxiq);
     529         [ #  # ]:          0 :     Player.pow = max( Player.pow, Player.maxpow = 2 * Player.maxpow);
     530         [ #  # ]:          0 :     Player.str = max( Player.str, Player.maxstr = 2 * Player.maxstr);
     531         [ #  # ]:          0 :     Player.dex = max( Player.dex, Player.maxdex = 2 * Player.maxdex);
     532         [ #  # ]:          0 :     Player.con = max( Player.con, Player.maxcon = 2 * Player.maxcon);
     533         [ #  # ]:          0 :     Player.agi = max( Player.agi, Player.maxagi = 2 * Player.maxagi);
     534                 :          0 :     dataprint();
     535                 :          0 :     morewait();
     536                 :          0 :     print1("You have been imbued with a cosmic power....");
     537                 :          0 :     morewait();
     538                 :          0 :     wish(1);
     539                 :          0 :     morewait();
     540                 :          0 :     clearmsg();
     541                 :          0 :     print2("You feel much more experienced.");
     542                 :          0 :     gain_experience(20000);
     543                 :          0 :     *o = Objects[OB_DEAD_ORB];
     544                 :            :   }
     545                 :            :   else {
     546                 :          0 :     print1("The Orb of Mastery's power is unbalanced!");
     547                 :          0 :     print2("The Orb of Mastery blasts you to cinders!");
     548                 :          0 :     p_death("playing with the Orb of Mastery");
     549                 :            :   }  
     550                 :          0 : }
     551                 :            : 
     552                 :            : 
     553                 :          0 : void i_orbdead(pob o)
     554                 :            : {
     555                 :            :   int i;
     556                 :          0 :   print1("The burnt-out orb drains all your energy!");
     557         [ #  # ]:          0 :   for(i=0;i<NUMSPELLS;i++)
     558                 :          0 :     Spells[i].known = FALSE;
     559                 :          0 :   print2("You feel not at all like a mage.");
     560         [ #  # ]:          0 :   for(i=0;i<MAXITEMS;i++) {
     561         [ #  # ]:          0 :     if (Player.possessions[i] != NULL) {
     562                 :          0 :       Player.possessions[i]->plus = 0;
     563         [ #  # ]:          0 :       if (Player.possessions[i]->usef > 100)
     564                 :          0 :         Player.possessions[i]->usef = I_NOTHING;
     565                 :            :     }
     566                 :            :   }
     567                 :          0 :   print3("A storm of mundanity surounds you!");
     568                 :          0 :   level_drain(Player.level-1,"a Burnt-out Orb");
     569                 :          0 :   Player.mana = 0;
     570                 :          0 :   Player.pow -= 10;
     571                 :          0 : }
     572                 :            : 
     573                 :            : 
     574                 :            : 
     575                 :          0 : void i_dispel(pob o)
     576                 :            : {
     577         [ #  # ]:          0 :   dispel((o->blessing > -1) ? o->blessing+random_range(3): o->blessing);
     578                 :          0 : }
     579                 :            : 
     580                 :            : /* DAG implement bag of holding */
     581                 :          0 : void i_holding(pob o)
     582                 :            : {
     583                 :            :   char c, c1, c2;
     584                 :            :   pol ol;
     585                 :            : 
     586                 :            :   /* use aux to represent # items in bag, 5 max */
     587         [ #  # ]:          0 :   if (! o->known )
     588                 :            :   {
     589                 :          0 :     clearmsg();
     590                 :          0 :     print1("You open the bag and look in.  It looks bigger on the inside");
     591                 :          0 :     print2("than on the outside.  Wow, a Bag of Holding.");
     592                 :          0 :     morewait();
     593                 :          0 :     o->known = 1;
     594                 :          0 :     Objects[o->id].known = 1;
     595                 :            :   }
     596                 :          0 :   menuclear();
     597         [ #  # ]:          0 :   if ( ! o->aux )
     598                 :          0 :     menuprint("You bag of holding is empty.\n");
     599                 :            :   else
     600                 :            :   {
     601                 :          0 :      sprintf(Str1, "You bag of holding currently holds %d items.\n", o->aux );
     602                 :          0 :      menuprint(Str1);
     603                 :            :   }
     604                 :          0 :   menuprint(" a: list contents\n");
     605                 :          0 :   menuprint(" b: put an item into the bag\n");
     606                 :          0 :   menuprint(" c: remove an item from the bag\n");
     607                 :          0 :   menuprint(" ESCAPE:cancel\n" );
     608                 :          0 :   showmenu();
     609                 :            :   do 
     610                 :          0 :     c = (char) mgetc();
     611 [ #  # ][ #  # ]:          0 :   while ( (c < 'a' || c > 'c') && c != ESCAPE);
                 [ #  # ]
     612   [ #  #  #  # ]:          0 :   switch(c)
     613                 :            :   {
     614                 :            :   case 'a':
     615         [ #  # ]:          0 :     if (!o->aux)
     616                 :          0 :       print1("The bag is empty.");
     617                 :            :     else
     618                 :            :     {
     619                 :          0 :       ol = Bagitems;
     620                 :          0 :       menuclear();
     621         [ #  # ]:          0 :       while (ol != NULL) {
     622                 :          0 :         menuprint("\n");
     623                 :          0 :         menuprint(itemid(ol->thing));
     624                 :          0 :         ol = ol->next;
     625                 :            :       }
     626                 :          0 :       showmenu();
     627                 :          0 :       morewait();
     628                 :          0 :       xredraw();
     629                 :            :     } 
     630                 :          0 :     break;
     631                 :            :   case 'b':
     632         [ #  # ]:          0 :     if (o->aux >= 5)
     633                 :          0 :       print1("The bag appears to be full.");
     634                 :            :     else
     635                 :            :     {
     636                 :            :        int i;
     637                 :            :        pob ob;
     638                 :          0 :        i = getitem( NULL_ITEM );
     639         [ #  # ]:          0 :        if (i != ABORT )
     640                 :            :        {
     641                 :          0 :          ob = Player.possessions[i];
     642 [ #  # ][ #  # ]:          0 :          if ( ob->used && (ob->blessing < 0) )
     643                 :            :          {
     644                 :          0 :            sprintf(Str1, "You can't seem to get rid of: %s", itemid(ob) );
     645                 :          0 :            print1(Str1);
     646         [ #  # ]:          0 :          } else if (ob == o)  /* put bag into itself */
     647                 :            :          {
     648                 :          0 :             mprint("You put the bottom of the bag into the top.");
     649                 :          0 :             mprint("The bag starts to slowly get sucked into the bag.");
     650                 :          0 :             mprint("You hear a high-pitched screaming sound.");
     651                 :          0 :             mprint("The world starts to twist around you.");
     652                 :          0 :             mprint("Suddenly the space-time continuum rips...");
     653                 :          0 :             mprint("And you are sucked into the rift.");
     654                 :          0 :             free_objlist( Bagitems );
     655                 :          0 :             Bagitems = NULL;
     656                 :            :             /* Bag is not destroyed, could re-appear anywhere */
     657                 :          0 :             Objects[o->id].uniqueness = UNIQUE_UNMADE;
     658                 :          0 :             free_obj( o, TRUE );
     659                 :          0 :             Player.possessions[i] = NULL;
     660                 :          0 :             strategic_teleport(-1);
     661                 :            :          } else 
     662                 :            :          {
     663                 :          0 :            ol = (pol) checkmalloc( sizeof(oltype) );
     664                 :          0 :            ol->thing = ob;
     665                 :          0 :            ol->next = Bagitems;
     666                 :          0 :            Bagitems = ol;
     667                 :          0 :            conform_unused_object(ob); /* if used, unuses it */
     668                 :          0 :            Player.possessions[i] = NULL;
     669                 :          0 :            o->aux++;
     670                 :            :          }
     671                 :            :        } /* !ABORT */
     672                 :            :     } /* not full (else) */
     673                 :          0 :     break;
     674                 :            :   case 'c':
     675         [ #  # ]:          0 :     if (!o->aux)
     676                 :          0 :       print1("The bag is empty.");
     677                 :            :     else
     678                 :            :     {
     679         [ #  # ]:          0 :       if (o->blessing < 0)
     680                 :            :       {
     681                 :          0 :          o->known = 2;
     682                 :          0 :          print1("Oops, when you go to remove the objects, you find that they aren't there.");
     683                 :          0 :          print2("It appears that this was actually a Bag of Devouring.");
     684                 :          0 :          morewait();
     685                 :          0 :          print2("You sense an aura of satisfaction around the bag.");
     686                 :          0 :          o->aux = 0;
     687                 :          0 :          free_objlist( Bagitems );
     688                 :          0 :          Bagitems = NULL;
     689                 :            :       } 
     690                 :            :       else
     691                 :            :       {
     692                 :          0 :          ol = Bagitems;
     693                 :          0 :          menuclear();
     694                 :          0 :          menuprint("Select object from bag:\n");
     695                 :          0 :          c1 = 'a';
     696         [ #  # ]:          0 :          while (ol != NULL) {
     697                 :          0 :            sprintf(Str1, "%c: %s\n", c1, itemid(ol->thing) );
     698                 :          0 :            menuprint(Str1);
     699                 :          0 :            ol = ol->next;
     700                 :          0 :            c1++;
     701                 :            :          }
     702                 :          0 :          menuprint("ESCAPE: to cancel\n");
     703                 :          0 :          showmenu();
     704                 :            :          do 
     705                 :          0 :            c = (char) mgetc();
     706 [ #  # ][ #  # ]:          0 :          while ( (c < 'a' || c >= c1) && c != ESCAPE);
                 [ #  # ]
     707         [ #  # ]:          0 :          if (c != ESCAPE)
     708                 :            :          {
     709                 :          0 :            pol prev = NULL;
     710                 :          0 :            ol = Bagitems;
     711         [ #  # ]:          0 :            for (c2='a'; c2 < c;  c2++ )
     712                 :            :            {
     713                 :          0 :              prev = ol;
     714                 :          0 :              ol = ol->next;
     715                 :            :            }
     716                 :          0 :            gain_item( ol->thing );
     717                 :          0 :            o->aux--;
     718                 :            :            /* free appropriately */
     719                 :            :            /* WDT: oops, the old assignment bug struck again.  Fixed, I hope. */
     720         [ #  # ]:          0 :            if (ol == Bagitems)
     721                 :            :            {
     722                 :          0 :               ol=ol->next;
     723                 :          0 :               free( Bagitems );
     724                 :          0 :               Bagitems = ol;
     725                 :            :            } 
     726                 :            :            else
     727                 :            :            {
     728                 :          0 :               ol = ol->next;
     729                 :          0 :               free( prev->next );
     730                 :          0 :               prev->next = ol;
     731                 :            :            }
     732                 :            : 
     733                 :            :          } /* not escape */
     734                 :            : 
     735                 :            :       } /* else blessing >= 0 */
     736                 :            :     } /* else bag is full */
     737                 :          0 :     break;
     738                 :            :   } /* switch (c) */
     739                 :            : 
     740                 :          0 :   calc_melee();
     741                 :          0 :   xredraw();
     742                 :          0 : } /* fn */
     743                 :            : 
     744                 :            : 
     745                 :            : /* stick functions */
     746                 :            : 
     747                 :            : 
     748                 :            : /* wand of apportation */
     749                 :          0 : void i_apport(pob o)
     750                 :            : {
     751         [ #  # ]:          0 :   o->known = max(1,o->known);
     752                 :          0 :   Objects[o->id].known = 1;
     753                 :          0 :   apport(o->blessing);
     754                 :          0 : }
     755                 :            : 
     756                 :            : /* staff of firebolts */
     757                 :          0 : void i_firebolt(pob o)
     758                 :            : {
     759                 :          0 :   int x=Player.x,y=Player.y;
     760         [ #  # ]:          0 :   o->known = max(1,o->known);
     761                 :          0 :   Objects[o->id].known = 1;
     762                 :          0 :   setspot(&x,&y);
     763         [ #  # ]:          0 :   if (o->blessing < 0) {
     764                 :          0 :     x = Player.x;
     765                 :          0 :     y = Player.y;
     766                 :            :   }
     767                 :          0 :   fbolt(Player.x,Player.y,x,y,Player.dex*2+Player.level,75);
     768                 :          0 : }
     769                 :            : 
     770                 :            : 
     771                 :          0 : void i_disintegrate(pob o)
     772                 :            : {
     773                 :          0 :   int x=Player.x,y=Player.y;
     774         [ #  # ]:          0 :   o->known = max(1,o->known);
     775                 :          0 :   Objects[o->id].known = 1;
     776                 :          0 :   setspot(&x,&y);
     777         [ #  # ]:          0 :   if (o->blessing < 0) {
     778                 :          0 :     x = Player.x;
     779                 :          0 :     y = Player.y;
     780                 :            :   }
     781                 :          0 :   disintegrate(x,y);
     782                 :          0 : }
     783                 :            : 
     784                 :          0 : void i_disrupt(pob o)
     785                 :            : {
     786                 :          0 :   int x=Player.x,y=Player.y;
     787         [ #  # ]:          0 :   o->known = max(1,o->known);
     788                 :          0 :   Objects[o->id].known = 1;
     789                 :          0 :   setspot(&x,&y);
     790         [ #  # ]:          0 :   if (o->blessing < 0) {
     791                 :          0 :     x = Player.x;
     792                 :          0 :     y = Player.y;
     793                 :            :   }
     794                 :          0 :   disrupt(x,y,100);
     795                 :          0 : }
     796                 :            : 
     797                 :            : 
     798                 :            : /* staff of lightning bolts */
     799                 :          0 : void i_lbolt(pob o)
     800                 :            : {
     801                 :          0 :   int x=Player.x,y=Player.y;
     802         [ #  # ]:          0 :   o->known = max(1,o->known);
     803                 :          0 :   Objects[o->id].known = 1;
     804                 :          0 :   setspot(&x,&y);
     805         [ #  # ]:          0 :   if (o->blessing < 0) {
     806                 :          0 :     x = Player.x;
     807                 :          0 :     y = Player.y;
     808                 :            :   }
     809                 :          0 :   lbolt(Player.x,Player.y,x,y,Player.dex*2+Player.level,75);
     810                 :          0 : }
     811                 :            : 
     812                 :            : /* wand of magic missiles */
     813                 :          0 : void i_missile(pob o)
     814                 :            : {
     815                 :          0 :   int x=Player.x,y=Player.y;
     816         [ #  # ]:          0 :   o->known = max(1,o->known);
     817                 :          0 :   Objects[o->id].known = 1;
     818                 :          0 :   setspot(&x,&y);
     819         [ #  # ]:          0 :   if (o->blessing < 0) {
     820                 :          0 :     x = Player.x;
     821                 :          0 :     y = Player.y;
     822                 :            :   }
     823                 :          0 :   nbolt(Player.x,Player.y,x,y,Player.dex*2+Player.level,20);
     824                 :          0 : }
     825                 :            : 
     826                 :            : /* wand of fire balls */
     827                 :          0 : void i_fireball(pob o)
     828                 :            : {
     829                 :          0 :   int x=Player.x,y=Player.y;
     830                 :          0 :   Objects[o->id].known = 1;
     831         [ #  # ]:          0 :   o->known = max(1,o->known);
     832                 :          0 :   setspot(&x,&y);
     833         [ #  # ]:          0 :   if (o->blessing < 0) {
     834                 :          0 :     x = Player.x;
     835                 :          0 :     y = Player.y;
     836                 :            :   }
     837                 :          0 :   fball(Player.x,Player.y,x,y,35);
     838                 :          0 : }
     839                 :            : 
     840                 :            : 
     841                 :            : /* wand of snowballs */
     842                 :          0 : void i_snowball(pob o)
     843                 :            : {
     844                 :          0 :   int x=Player.x,y=Player.y;
     845                 :          0 :   Objects[o->id].known = 1;
     846         [ #  # ]:          0 :   o->known = max(1,o->known);
     847                 :          0 :   setspot(&x,&y);
     848         [ #  # ]:          0 :   if (o->blessing < 0) {
     849                 :          0 :     x = Player.x;
     850                 :          0 :     y = Player.y;
     851                 :            :   }
     852                 :          0 :   snowball(Player.x,Player.y,x,y,20);
     853                 :          0 : }
     854                 :            : 
     855                 :            : /* wand of lightning balls */
     856                 :          0 : void i_lball(pob o)
     857                 :            : {
     858                 :          0 :   int x=Player.x,y=Player.y;
     859                 :          0 :   Objects[o->id].known = 1;
     860         [ #  # ]:          0 :   o->known = max(1,o->known);
     861                 :          0 :   setspot(&x,&y);
     862         [ #  # ]:          0 :   if (o->blessing < 0) {
     863                 :          0 :     x = Player.x;
     864                 :          0 :     y = Player.y;
     865                 :            :   }
     866                 :          0 :   lball(Player.x,Player.y,x,y,50);
     867                 :          0 : }
     868                 :            : 
     869                 :            : /* staff of sleep */
     870                 :          0 : void i_sleep_other(pob o)
     871                 :            : {
     872                 :          0 :   Objects[o->id].known = 1;
     873         [ #  # ]:          0 :   o->known = max(1,o->known);
     874                 :          0 :   sleep_monster(o->blessing);
     875                 :          0 : }
     876                 :            : 
     877                 :            : /* rod of summoning */
     878                 :            : /* rod of summoning now always summons as if cursed */
     879                 :          0 : void i_summon(pob o)
     880                 :            : {
     881                 :          0 :   Objects[o->id].known = 1;
     882         [ #  # ]:          0 :   o->known = max(1,o->known);
     883                 :          0 :   summon(-1,-1);
     884                 :          0 : }
     885                 :            : 
     886                 :          0 : void i_hide(pob o)
     887                 :            : {
     888                 :          0 :   int x=Player.x,y=Player.y;
     889                 :          0 :   Objects[o->id].known = 1;
     890         [ #  # ]:          0 :   o->known = max(1,o->known);
     891                 :          0 :   setspot(&x,&y);
     892                 :          0 :   hide(x,y);
     893                 :          0 : }
     894                 :            : 
     895                 :          0 : void i_polymorph(pob o)
     896                 :            : {
     897                 :          0 :   Objects[o->id].known = 1;
     898         [ #  # ]:          0 :   o->known = max(1,o->known);
     899                 :          0 :   polymorph(o->blessing);
     900                 :          0 : }

Generated by: LCOV version 1.11