LCOV - code coverage report
Current view: top level - omega-rpg-0.90-pa9 - itemf1.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 9 591 1.5 %
Date: 2017-09-08 22:00:26 Functions: 2 62 3.2 %
Branches: 1 272 0.4 %

           Branch data     Line data    Source code
       1                 :            : /* omega copyright (C) 1987,1988,1989 by Laurence Raphael Brothers */
       2                 :            : /* itemf1.c */
       3                 :            : 
       4                 :            : /* various item functions: potions,scrolls,boots,cloaks,things,food */
       5                 :            : 
       6                 :            : #include "glob.h"
       7                 :            : 
       8                 :            : /* general item functions */
       9                 :            : 
      10                 :          0 : void i_no_op(pob o)
      11                 :            : {
      12                 :          0 : }
      13                 :            : 
      14                 :          0 : void i_nothing(pob o)
      15                 :            : {
      16                 :          0 : }
      17                 :            : 
      18                 :            : /*  scroll functions */
      19                 :            : 
      20                 :          0 : void i_knowledge(pob o)
      21                 :            : {
      22         [ #  # ]:          0 :   if (o->blessing > -1)
      23                 :          0 :     Objects[o->id].known = 1;
      24                 :          0 :   knowledge(o->blessing);
      25                 :          0 : }
      26                 :            : 
      27                 :          0 : static int is_capital_letter (char ch)
      28                 :            : {
      29 [ #  # ][ #  # ]:          0 :   if (ch >= 'A' && ch <= 'Z') return TRUE;
      30                 :          0 :   return FALSE;
      31                 :            : }
      32                 :            : 
      33                 :          0 : static int is_vowel (char ch)
      34                 :            : {
      35         [ #  # ]:          0 :   if ('a' == ch) return TRUE;
      36         [ #  # ]:          0 :   if ('e' == ch) return TRUE;
      37         [ #  # ]:          0 :   if ('i' == ch) return TRUE;
      38         [ #  # ]:          0 :   if ('o' == ch) return TRUE;
      39         [ #  # ]:          0 :   if ('u' == ch) return TRUE;
      40                 :          0 :   return FALSE;
      41                 :            : }
      42                 :            : 
      43                 :          0 : void i_jane_t (pob o)
      44                 :            : {
      45                 :            :   int volume;
      46                 :            :   int range_idx;
      47                 :            :   int range_beg;
      48                 :            :   int range_end;
      49                 :            :   char first_letter;
      50                 :            : 
      51                 :          0 :   Objects[o->id].known = 1;
      52                 :            : 
      53                 :          0 :   print1("Jane's Guide to the World's Treasures: ");
      54                 :            : 
      55                 :          0 :   volume = random_range(6);
      56   [ #  #  #  #  :          0 :   switch (volume)
                #  #  # ]
      57                 :            :     {
      58                 :            :     case 0:
      59                 :          0 :       nprint1("SCROLLS");
      60                 :          0 :       range_beg = SCROLLID;
      61                 :          0 :       range_end = POTIONID;
      62                 :          0 :       break;
      63                 :            : 
      64                 :            :     case 1:
      65                 :          0 :       nprint1("POTIONS");
      66                 :          0 :       range_beg = POTIONID;
      67                 :          0 :       range_end = WEAPONID;
      68                 :          0 :       break;
      69                 :            : 
      70                 :            :     case 2:
      71                 :          0 :       nprint1("CLOAKS");
      72                 :          0 :       range_beg = CLOAKID;
      73                 :          0 :       range_end = BOOTID;
      74                 :          0 :       break;
      75                 :            : 
      76                 :            :     case 3:
      77                 :          0 :       nprint1("BOOTS");
      78                 :          0 :       range_beg = BOOTID;
      79                 :          0 :       range_end = RINGID;
      80                 :          0 :       break;
      81                 :            : 
      82                 :            :     case 4:
      83                 :          0 :       nprint1("RINGS");
      84                 :          0 :       range_beg = RINGID;
      85                 :          0 :       range_end = STICKID;
      86                 :          0 :       break;
      87                 :            : 
      88                 :            :     case 5:
      89                 :          0 :       nprint1("STICKS");
      90                 :          0 :       range_beg = STICKID;
      91                 :          0 :       range_end = ARTIFACTID;
      92                 :          0 :       break;
      93                 :            : 
      94                 :            :     default:
      95                 :            :       /* bomb on error */
      96                 :          0 :       range_beg = range_end = 0;
      97                 :          0 :       assert(FALSE);
      98                 :            :     }
      99                 :            : 
     100                 :          0 :   menuclear();
     101                 :          0 :   menuprint("You could probably now recognise:\n");
     102                 :            : 
     103         [ #  # ]:          0 :   for(range_idx = range_beg; range_idx < range_end; ++range_idx)
     104                 :            :     {
     105                 :          0 :       Objects[range_idx].known = 1;
     106                 :          0 :       first_letter = Objects[range_idx].truename[0];
     107                 :            : 
     108 [ #  # ][ #  # ]:          0 :       if (is_capital_letter(first_letter) || volume == 3)
     109                 :          0 :         sprintf(Str1, "   %s\n", Objects[range_idx].truename);
     110         [ #  # ]:          0 :       else if (is_vowel(first_letter))
     111                 :          0 :         sprintf(Str1, "   an %s\n", Objects[range_idx].truename);
     112                 :            :       else
     113                 :          0 :         sprintf(Str1, "   a %s\n", Objects[range_idx].truename);
     114                 :            : 
     115                 :          0 :     menuprint(Str1);
     116                 :            :   }
     117                 :            : 
     118                 :          0 :   showmenu();
     119                 :          0 :   morewait();
     120                 :          0 :   xredraw();
     121                 :          0 : }
     122                 :            : 
     123                 :            :    
     124                 :          0 : void i_flux(pob o)
     125                 :            : {
     126         [ #  # ]:          0 :   if (o->blessing > -1)
     127                 :          0 :     Objects[o->id].known = 1;
     128                 :          0 :   flux(o->blessing);
     129                 :          0 : }
     130                 :            : 
     131                 :            : 
     132                 :            : /* enchantment */
     133                 :          0 : void i_enchant(pob o)
     134                 :            : {
     135         [ #  # ]:          0 :   if (o->blessing > -1)
     136                 :          0 :     Objects[o->id].known = 1;
     137         [ #  # ]:          0 :   enchant(o->blessing < 0 ? -1-o->plus : o->plus+1);
     138                 :          0 : }
     139                 :            : 
     140                 :            : /* scroll of clairvoyance */
     141                 :          0 : void i_clairvoyance(pob o)
     142                 :            : {
     143         [ #  # ]:          0 :   if (o->blessing > -1)
     144                 :          0 :     Objects[o->id].known = 1;
     145         [ #  # ]:          0 :   if (o->blessing < 0)
     146                 :          0 :     amnesia();
     147                 :          0 :   else clairvoyance(5+o->blessing*5);
     148                 :          0 : }
     149                 :            : 
     150                 :            : 
     151                 :            : 
     152                 :          0 : void i_acquire(pob o)
     153                 :            : {
     154                 :            :   int blessing;
     155                 :            : 
     156         [ #  # ]:          0 :   if (o->blessing > -1)
     157                 :          0 :     Objects[o->id].known = 1;
     158                 :          0 :   blessing = o->blessing;
     159                 :          0 :   *o = Objects[OB_BLANK_SCROLL]; /* blank out the scroll */
     160                 :          0 :   acquire(blessing);
     161                 :          0 : }
     162                 :            : 
     163                 :          0 : void i_teleport(pob o)
     164                 :            : {
     165         [ #  # ]:          0 :   if (o->blessing > -1)
     166                 :          0 :     Objects[o->id].known = 1;
     167                 :          0 :   p_teleport(o->blessing);
     168                 :          0 : }
     169                 :            : 
     170                 :            : 
     171                 :          0 : void i_spells(pob o)
     172                 :            : {
     173         [ #  # ]:          0 :   if (o->blessing > -1)
     174                 :          0 :     Objects[o->id].known = 1;
     175                 :          0 :   mprint("A scroll of spells.");
     176                 :          0 :   morewait();
     177                 :          0 :   learnspell(o->blessing);
     178                 :          0 : }
     179                 :            : 
     180                 :            : 
     181                 :            : 
     182                 :            : /* scroll of blessing */
     183                 :          0 : void i_bless(pob o)
     184                 :            : {
     185                 :          0 :   Objects[o->id].known = 1;
     186                 :          0 :   bless(o->blessing);
     187                 :          0 : }
     188                 :            : 
     189                 :            : /* scroll of wishing */
     190                 :          0 : void i_wish(pob o)
     191                 :            : {
     192         [ #  # ]:          0 :   if (o->blessing > -1)
     193                 :          0 :     Objects[o->id].known = 1;
     194                 :          0 :   wish(o->blessing);
     195                 :          0 :   *o = Objects[OB_BLANK_SCROLL]; /* blank out the scroll */
     196                 :          0 : }
     197                 :            : 
     198                 :            : /* scroll of displacement */
     199                 :          0 : void i_displace(pob o)
     200                 :            : {
     201         [ #  # ]:          0 :   if (o->blessing > -1) 
     202                 :          0 :       Objects[o->id].known = 1;
     203                 :          0 :   displace(o->blessing);
     204                 :          0 : }
     205                 :            : 
     206                 :            : 
     207                 :            : /* scroll of deflection */
     208                 :          0 : void i_deflect(pob o)
     209                 :            : {
     210         [ #  # ]:          0 :   if (o->blessing > -1) 
     211                 :          0 :     Objects[o->id].known = 1;
     212                 :          0 :   deflection(o->blessing);
     213                 :          0 : }
     214                 :            : 
     215                 :            : /* scroll of identification */
     216                 :          0 : void i_id(pob o)
     217                 :            : {
     218         [ #  # ]:          0 :   if (o->blessing > -1)
     219                 :          0 :     Objects[o->id].known = 1;
     220                 :          0 :   identify(o->blessing);
     221                 :          0 : }
     222                 :            : 
     223                 :            : /* potion functions */
     224                 :            : 
     225                 :            : /* potion of healing */
     226                 :          0 : void i_heal(pob o)
     227                 :            : {
     228         [ #  # ]:          0 :   if (o->blessing > -1) {
     229                 :          0 :     Objects[o->id].known = 1;
     230                 :          0 :     heal(1+o->plus);
     231                 :            :   }
     232                 :          0 :   else heal(-1-abs(o->plus));
     233                 :          0 : }
     234                 :            : 
     235                 :            : /* potion of monster detection */
     236                 :          0 : void i_mondet(pob o)
     237                 :            : {
     238         [ #  # ]:          0 :   if (o->blessing > -1)
     239                 :          0 :     Objects[o->id].known = 1;
     240                 :          0 :   mondet(o->blessing);
     241                 :          0 : }
     242                 :            : 
     243                 :            : 
     244                 :            : /* potion of object detection */
     245                 :          0 : void i_objdet(pob o)
     246                 :            : {
     247                 :            : 
     248         [ #  # ]:          0 :   if (o->blessing > -1)
     249                 :          0 :     Objects[o->id].known = 1;
     250                 :          0 :   objdet(o->blessing);
     251                 :          0 : }
     252                 :            : 
     253                 :            : /* potion of neutralize poison */
     254                 :          0 : void i_neutralize_poison(pob o)
     255                 :            : {
     256         [ #  # ]:          0 :   if (o->blessing > -1) {
     257                 :          0 :     Objects[o->id].known = 1;
     258                 :          0 :     mprint("You feel vital!");
     259                 :          0 :     Player.status[POISONED] = 0;
     260                 :            :   }
     261                 :          0 :   else p_poison(random_range(20)+5);
     262                 :          0 : }
     263                 :            : 
     264                 :            : 
     265                 :            : /* potion of sleep */
     266                 :          0 : void i_sleep_self(pob o)
     267                 :            : {
     268                 :          0 :   sleep_player(6);
     269                 :          0 :   Objects[o->id].known = 1;
     270                 :          0 : }
     271                 :            : 
     272                 :            : 
     273                 :            : 
     274                 :            : 
     275                 :            : /* potion of speed */
     276                 :          0 : void i_speed(pob o)
     277                 :            : {
     278         [ #  # ]:          0 :   if (o->blessing > -1) 
     279                 :          0 :     Objects[o->id].known = 1;
     280                 :          0 :   haste(o->blessing);
     281                 :          0 : }
     282                 :            : 
     283                 :            : 
     284                 :            : /* potion of restoration */
     285                 :          0 : void i_restore(pob o)
     286                 :            : {
     287         [ #  # ]:          0 :   if (o->blessing > -1) 
     288                 :          0 :     Objects[o->id].known = 1;
     289                 :          0 :   recover_stat(o->blessing);
     290                 :          0 : }
     291                 :            : 
     292                 :          0 : void i_augment(pob o)
     293                 :            : {
     294         [ #  # ]:          0 :   if (o->blessing > -1) 
     295                 :          0 :     Objects[o->id].known = 1;
     296                 :          0 :   augment(o->blessing);
     297                 :          0 : }  
     298                 :            : 
     299                 :          0 : void i_azoth(pob o)
     300                 :            : {
     301         [ #  # ]:          0 :   if (o->plus < 0) {
     302                 :          0 :     mprint("The mercury was poisonous!");
     303                 :          0 :     p_poison(25);
     304                 :            :   }
     305         [ #  # ]:          0 :   else if (o->plus == 0) {
     306                 :          0 :     mprint("The partially enchanted azoth makes you sick!");
     307                 :          0 :     Player.con = ((int) (Player.con / 2));
     308                 :          0 :     calc_melee();
     309                 :            :   }
     310         [ #  # ]:          0 :   else if (o->blessing < 1) {
     311                 :          0 :     mprint("The unblessed azoth warps your soul!");
     312                 :          0 :     Player.pow = Player.maxpow = ((int) (Player.maxpow / 2));
     313                 :          0 :     level_drain(random_range(10),"cursed azoth");
     314                 :            :   }
     315                 :            :   else {
     316                 :          0 :     mprint("The azoth fills you with cosmic power!");
     317         [ #  # ]:          0 :     if (Player.str > Player.maxstr*2) {
     318                 :          0 :       mprint("The power rages out of control!");
     319                 :          0 :       p_death("overdose of azoth");
     320                 :            :     }
     321                 :            :     else {
     322                 :          0 :       heal(10);
     323                 :          0 :       cleanse(1);
     324                 :          0 :       Player.mana = calcmana()*3;
     325                 :          0 :       toggle_item_use(TRUE);
     326                 :          0 :       Player.str = (Player.maxstr++)*3;
     327                 :          0 :       toggle_item_use(FALSE);
     328                 :            :     }
     329                 :            :   }
     330                 :          0 : }
     331                 :            : 
     332                 :          0 : void i_regenerate(pob o)
     333                 :            : {
     334                 :          0 :   regenerate(o->blessing);
     335                 :          0 : }
     336                 :            : 
     337                 :            : 
     338                 :            : 
     339                 :            : 
     340                 :            : 
     341                 :            : /* boots functions */
     342                 :          0 : void i_perm_speed(pob o)
     343                 :            : {
     344         [ #  # ]:          0 :   if (o->blessing > -1) {
     345         [ #  # ]:          0 :     if (o->used) {
     346                 :          0 :       o->known = 2;
     347                 :          0 :       Objects[o->id].known = 1;
     348         [ #  # ]:          0 :       if (Player.status[SLOWED] > 0) {
     349                 :          0 :         Player.status[SLOWED] = 0;
     350                 :            :       }
     351                 :          0 :       mprint("The world slows down!"); 
     352                 :          0 :       Player.status[HASTED] += 1500;
     353                 :            :     }
     354                 :            :     else {
     355                 :          0 :       Player.status[HASTED] -= 1500;
     356         [ #  # ]:          0 :       if (Player.status[HASTED] < 1) 
     357                 :          0 :         mprint("The world speeds up again.");
     358                 :            :     }
     359                 :            :   }
     360                 :            :   else {
     361         [ #  # ]:          0 :     if (o->used) {
     362         [ #  # ]:          0 :       if (Player.status[HASTED] > 0) {
     363                 :          0 :         Player.status[HASTED] = 0;
     364                 :            :       }
     365                 :          0 :       mprint("You feel slower.");
     366                 :          0 :       Player.status[SLOWED] += 1500;
     367                 :            :     }
     368                 :            :     else  {
     369                 :          0 :       Player.status[SLOWED] -= 1500;
     370         [ #  # ]:          0 :       if (Player.status[SLOWED] < 1) 
     371                 :          0 :         mprint("You feel quicker again.");
     372                 :            :     }  
     373                 :            :   }
     374                 :          0 : }
     375                 :            : 
     376                 :            : /* cloak functions */
     377                 :          0 : void i_perm_displace(pob o)
     378                 :            : {
     379         [ #  # ]:          0 :   if (o->blessing > -1) {
     380         [ #  # ]:          0 :     if (o->used) {
     381                 :          0 :       mprint("You feel dislocated.");
     382                 :          0 :       Player.status[DISPLACED] += 1500;
     383                 :            :     }
     384                 :            :     else {
     385                 :          0 :       Player.status[DISPLACED] -= 1500;
     386         [ #  # ]:          0 :       if (Player.status[DISPLACED] < 1) {
     387                 :          0 :         mprint("You feel a sense of position.");
     388                 :          0 :         Player.status[DISPLACED] = 0;
     389                 :            :       }
     390                 :            :     }
     391                 :            :   }
     392                 :            :   else {
     393         [ #  # ]:          0 :     if (o->used) {
     394                 :          0 :       mprint("You have a forboding of bodily harm!");
     395                 :          0 :       Player.status[VULNERABLE] += 1500;
     396                 :            :     }
     397                 :            :     else {
     398                 :          0 :       Player.status[VULNERABLE] -= 1500;
     399         [ #  # ]:          0 :       if (Player.status[VULNERABLE] < 1) {
     400                 :          0 :         mprint("You feel less endangered.");
     401                 :          0 :         Player.status[VULNERABLE] = 0;
     402                 :            :       }
     403                 :            :     }
     404                 :            :   }
     405                 :          0 : }
     406                 :            : 
     407                 :          0 : void i_perm_negimmune(pob o)
     408                 :            : {
     409         [ #  # ]:          0 :   if (o->blessing > -1) {
     410         [ #  # ]:          0 :     if (o->used) {
     411                 :          0 :       Player.immunity[NEGENERGY]++;
     412                 :            :     }
     413                 :          0 :     else Player.immunity[NEGENERGY]--;
     414                 :            :   }
     415         [ #  # ]:          0 :   else if (o->used)
     416                 :          0 :     level_drain(abs(o->blessing),"cursed cloak of level drain");
     417                 :          0 : }
     418                 :            : 
     419                 :            : /* food functions */
     420                 :            : 
     421                 :            : 
     422                 :          1 : void i_food(pob o)
     423                 :            : {
     424   [ -  -  -  -  :          1 :   switch(random_range(6)) {
                +  -  - ]
     425                 :          0 :     case 0: mprint("That tasted horrible!"); break;
     426                 :          0 :     case 1: mprint("Yum!"); break;
     427                 :          0 :     case 2: mprint("How nauseous!"); break;
     428                 :          0 :     case 3: mprint("Can I have some more? Please?"); break;
     429                 :          1 :     case 4: mprint("Your mouth feels like it is growing hair!"); break;
     430                 :          0 :     case 5: mprint("Tastes like home cooking!"); break;
     431                 :            :   }
     432                 :          1 : }
     433                 :            : 
     434                 :          0 : void i_stim(pob o)
     435                 :            : {
     436                 :          0 :   mprint("You feel Hyper!");
     437                 :          0 :   i_speed(o);
     438                 :          0 :   Player.str +=3;
     439                 :          0 :   Player.con -=1;
     440                 :          0 :   calc_melee();
     441                 :          0 : }
     442                 :            : 
     443                 :          0 : void i_pow(pob o)
     444                 :            : {
     445                 :          0 :   mprint("You feel a surge of mystic power!");
     446                 :          0 :   Player.mana = 2 * calcmana();
     447                 :          0 : }
     448                 :            : 
     449                 :          0 : void i_poison_food(pob o)
     450                 :            : {
     451                 :          0 :   mprint("This food was contaminated with cyanide!");
     452                 :          0 :   p_poison(random_range(20)+5);
     453                 :          0 : }
     454                 :            : 
     455                 :          0 : void i_pepper_food(pob o)
     456                 :            : {
     457                 :          0 :   mprint("You innocently start to chew the szechuan pepper.....");
     458                 :          0 :   morewait();
     459                 :          0 :   mprint("hot.");
     460                 :          0 :   morewait();
     461                 :          0 :   mprint("Hot.");
     462                 :          0 :   morewait();
     463                 :          0 :   mprint("Hot!");
     464                 :          0 :   morewait();
     465                 :          0 :   mprint("HOT!!!!!!");
     466                 :          0 :   morewait();
     467                 :          0 :   p_damage(1,UNSTOPPABLE,"a szechuan pepper");
     468                 :          0 :   mprint("Your sinuses melt and run out your ears.");
     469                 :          0 :   mprint("Your mouth and throat seem to be permanently on fire.");
     470                 :          0 :   mprint("You feel much more awake now....");
     471                 :          0 :   Player.immunity[SLEEP]++;
     472                 :          0 : }
     473                 :            : 
     474                 :          1 : void i_lembas(pob o)
     475                 :            : {
     476                 :          1 :   heal(10);
     477                 :          1 :   cleanse(0);
     478                 :          1 :   Player.food = 40;
     479                 :          1 : }
     480                 :            : 
     481                 :            : 
     482                 :          0 : void i_cure(pob o)
     483                 :            : {
     484                 :          0 :   cure(o->blessing);
     485                 :          0 : }
     486                 :            : 
     487                 :          0 : void i_immune(pob o)
     488                 :            : {
     489         [ #  # ]:          0 :   if (o->blessing > 0) {
     490                 :          0 :     mprint("You feel a sense of innoculation");
     491                 :          0 :     Player.immunity[INFECTION]++;
     492                 :          0 :     cure(o->blessing);
     493                 :            :   }
     494                 :          0 : }
     495                 :            : 
     496                 :          0 : void i_breathing(pob o)
     497                 :            : {
     498                 :            :   
     499         [ #  # ]:          0 :   if (o->blessing > -1)
     500                 :          0 :     Objects[o->id].known = 1;
     501                 :          0 :   breathe(o->blessing);
     502                 :          0 : }
     503                 :            : 
     504                 :            :       
     505                 :          0 : void i_invisible(pob o)
     506                 :            : {
     507         [ #  # ]:          0 :   if (o->blessing > -1)
     508                 :          0 :     Objects[o->id].known = 1;
     509                 :          0 :   invisible(o->blessing);
     510                 :          0 : }
     511                 :            : 
     512                 :            : 
     513                 :          0 : void i_perm_invisible(pob o)
     514                 :            : {
     515         [ #  # ]:          0 :   if (o->blessing > -1)
     516                 :          0 :     Objects[o->id].known = 1;
     517         [ #  # ]:          0 :   if (o->used) {
     518         [ #  # ]:          0 :     if (o->blessing > -1) {
     519                 :          0 :       mprint("You feel transparent!");
     520                 :          0 :       Player.status[INVISIBLE] += 1500;
     521                 :            :     }
     522                 :            :     else {
     523                 :          0 :       mprint("You feel a forboding of bodily harm!");
     524                 :          0 :       Player.status[VULNERABLE] += 1500;
     525                 :            :     }
     526                 :            :   }
     527                 :            :   else {
     528         [ #  # ]:          0 :     if (o->blessing > -1) {
     529                 :          0 :       Player.status[INVISIBLE]-=1500;
     530         [ #  # ]:          0 :       if (Player.status[INVISIBLE] < 1) {
     531                 :          0 :         mprint("You feel opaque again.");
     532                 :          0 :         Player.status[INVISIBLE] = 0;
     533                 :            :       }
     534                 :            :     }
     535                 :            :     else {
     536                 :          0 :       Player.status[VULNERABLE] -= 1500;
     537         [ #  # ]:          0 :       if (Player.status[VULNERABLE] < 1) {
     538                 :          0 :         mprint("You feel less endangered now.");
     539                 :          0 :         Player.status[VULNERABLE] = 0;
     540                 :            :       }
     541                 :            :     }
     542                 :            :   }
     543                 :          0 : }
     544                 :            : 
     545                 :            : 
     546                 :          0 : void i_warp(pob o)
     547                 :            : {
     548         [ #  # ]:          0 :   if (o->blessing > -1)
     549                 :          0 :     Objects[o->id].known = 1;
     550                 :          0 :   warp(o->blessing);
     551                 :          0 : }
     552                 :            : 
     553                 :            : 
     554                 :          0 : void i_alert(pob o)
     555                 :            : {
     556         [ #  # ]:          0 :   if (o->blessing > -1) {
     557                 :          0 :     Objects[o->id].known = 1;
     558                 :          0 :     alert(o->blessing);
     559                 :            :   }
     560                 :          0 : }
     561                 :            : 
     562                 :          0 : void i_charge(pob o)
     563                 :            : {
     564                 :            :   int i;
     565         [ #  # ]:          0 :   if (o->blessing > -1)
     566                 :          0 :     Objects[o->id].known = 1;
     567                 :          0 :   i = getitem_prompt("A scroll of charging. Charge: ", STICK);
     568         [ #  # ]:          0 :   if (i != ABORT) {
     569         [ #  # ]:          0 :     if (o->blessing < 0) {
     570                 :          0 :       mprint("The stick glows black!");
     571                 :          0 :       Player.possessions[i]->charge = 0;
     572                 :            :     }
     573                 :            :     else {
     574                 :          0 :       mprint("The stick glows blue!");
     575                 :          0 :       Player.possessions[i]->charge += (random_range(10)+1)*(o->blessing+1);
     576         [ #  # ]:          0 :       if (Player.possessions[i]->charge > 99)
     577                 :          0 :         Player.possessions[i]->charge = 99;
     578                 :            :     }
     579                 :            :   }
     580                 :          0 : }
     581                 :            : 
     582                 :            : 
     583                 :          0 : void i_fear_resist(pob o)
     584                 :            : {
     585         [ #  # ]:          0 :   if (o->blessing > -1) {
     586                 :          0 :     Objects[o->id].known = 1;
     587         [ #  # ]:          0 :     if (Player.status[AFRAID] > 0) {
     588                 :          0 :       mprint("You feel stauncher now.");
     589                 :          0 :       Player.status[AFRAID] = 0;
     590                 :            :     }
     591                 :            :   }
     592         [ #  # ]:          0 :   else if (! p_immune(FEAR)) {
     593                 :          0 :     mprint("You panic!");
     594                 :          0 :     Player.status[AFRAID]+=random_range(100);
     595                 :            :   }
     596                 :          0 : }
     597                 :            : 
     598                 :            : 
     599                 :            : 
     600                 :            : /* use a thieves pick */
     601                 :          0 : void i_pick(pob o)
     602                 :            : {
     603                 :            :   int dir;
     604                 :            :   int ox,oy;
     605                 :          0 :   o->used = FALSE;
     606 [ #  # ][ #  # ]:          0 :   if ((! o->known) && (! Player.rank[THIEVES]))
     607                 :          0 :     mprint("You have no idea what do with a piece of twisted metal.");
     608                 :            :   else {
     609         [ #  # ]:          0 :     if (o->known < 1) o->known = 1;
     610                 :          0 :     Objects[o->id].known = 1;
     611                 :          0 :     mprint("Pick lock:");
     612                 :          0 :     dir = getdir();
     613         [ #  # ]:          0 :     if (dir == ABORT)
     614                 :          0 :       resetgamestatus(SKIP_MONSTERS);
     615                 :            :     else {
     616                 :          0 :       ox = Player.x + Dirs[0][dir];
     617                 :          0 :       oy = Player.y + Dirs[1][dir];
     618 [ #  # ][ #  # ]:          0 :       if ((Level->site[ox][oy].locchar != CLOSED_DOOR) || 
     619                 :          0 :           loc_statusp(ox,oy,SECRET)) {
     620                 :          0 :         mprint("You can't unlock that!");
     621                 :          0 :         resetgamestatus(SKIP_MONSTERS);
     622                 :            :       }
     623         [ #  # ]:          0 :       else if (Level->site[ox][oy].aux == LOCKED) {
     624         [ #  # ]:          0 :         if (Level->depth == MaxDungeonLevels-1) 
     625                 :          0 :           mprint("The lock is too complicated for you!!!");
     626         [ #  # ]:          0 :         else if (Level->depth*2 + random_range(50) <
     627                 :          0 :             Player.dex+Player.level+Player.rank[THIEVES]*10) {
     628                 :          0 :           mprint("You picked the lock!");
     629                 :          0 :           Level->site[ox][oy].aux = UNLOCKED;
     630                 :          0 :           lset(ox, oy, CHANGED);
     631                 :          0 :           gain_experience(max(3,Level->depth));
     632                 :            :         }
     633                 :          0 :         else mprint("You failed to pick the lock.");
     634                 :            :       }
     635                 :          0 :       else mprint("That door is already unlocked!");
     636                 :            :     }
     637                 :            :   }
     638                 :          0 : }
     639                 :            : 
     640                 :            : /* use a magic key*/
     641                 :          0 : void i_key(pob o)
     642                 :            : {
     643                 :            :   int dir;
     644                 :            :   int ox,oy;
     645                 :          0 :   o->used = FALSE;
     646                 :          0 :   mprint("Unlock door: ");
     647                 :          0 :   dir = getdir();
     648         [ #  # ]:          0 :   if (dir == ABORT)
     649                 :          0 :     resetgamestatus(SKIP_MONSTERS);
     650                 :            :   else {
     651                 :          0 :     ox = Player.x + Dirs[0][dir];
     652                 :          0 :     oy = Player.y + Dirs[1][dir];
     653 [ #  # ][ #  # ]:          0 :     if ((Level->site[ox][oy].locchar != CLOSED_DOOR) || 
     654                 :          0 :         loc_statusp(ox,oy,SECRET)) {
     655                 :          0 :           mprint("You can't unlock that!");
     656                 :          0 :           resetgamestatus(SKIP_MONSTERS);
     657                 :            :         }
     658         [ #  # ]:          0 :     else if (Level->site[ox][oy].aux == LOCKED) {
     659                 :          0 :         mprint("The lock clicks open!");
     660                 :          0 :         Level->site[ox][oy].aux = UNLOCKED;
     661                 :          0 :         lset(ox, oy, CHANGED);
     662                 :          0 :         o->blessing--;
     663 [ #  # ][ #  # ]:          0 :         if ((o->blessing<0)||(Level->depth == MaxDungeonLevels-1)) {
     664                 :          0 :           mprint("The key disintegrates!");
     665                 :          0 :           conform_lost_objects(1,o);
     666                 :            :         }
     667                 :            :         else
     668                 :          0 :           mprint("Your key glows faintly.");
     669                 :            :       }
     670                 :          0 :     else mprint("That door is already unlocked!");
     671                 :            :   }
     672                 :          0 : }
     673                 :            : 
     674                 :          0 : void i_corpse(pob o)
     675                 :            : {
     676                 :            :   /* WDT HACK: there are some comments in this function which need
     677                 :            :    * to be backed up with assert(). */
     678                 :            :   /* DAG reply: I don't like to use assert() for minor things like this
     679                 :            :      as the game can safely play on, yet an assert() will cause the game
     680                 :            :      to exit if it fails.  Not friendly.  Now an error message or error
     681                 :            :      log of some sort would make sense. */
     682                 :            :   /* WDT discussion: there's no law which demands that an assert has to
     683                 :            :    * kill the program -- well, okay, not the standard assert, but I seldom
     684                 :            :    * use that one.  And anyhow, we shouldn't distribute a version with the
     685                 :            :    * asserts compiled in; that's against the purpose. */
     686                 :            :   /* object's charge holds the former monster id */
     687   [ #  #  #  #  :          0 :   switch (o->charge) {
          #  #  #  #  #  
                      # ]
     688                 :            :   case MEND_PRIEST: 
     689                 :            :   case ITIN_MERCH:
     690                 :            :   case GUARD:
     691                 :            :   case NPC:
     692                 :            :   case MERCHANT:
     693                 :            :   case ZERO_NPC:
     694                 :            :   case HISCORE_NPC:
     695                 :            :   case APPR_NINJA:
     696                 :            :   case SNEAK_THIEF:
     697                 :            :   case BRIGAND:
     698                 :            :   case GENIN:
     699                 :            :   case MAST_THIEF:
     700                 :            :   case CHUNIN:
     701                 :            :   case JONIN: /* cannibalism */
     702                 :          0 :     mprint("Yechh! How could you! You didn't even cook him first!");
     703         [ #  # ]:          0 :     if (Player.alignment > 0) Player.food = 25;
     704                 :          0 :     else mprint("You'd eat your own grandmother.");
     705         [ #  # ]:          0 :     if (Player.alignment < 0) mprint("...without salt.");
     706                 :          0 :     Player.food += 8;
     707                 :          0 :     Player.alignment -=10;
     708                 :          0 :     foodcheck();
     709                 :          0 :     break;
     710                 :            :   case FNORD: /* fnord */
     711                 :          0 :     mprint("You feel illuminated!");
     712                 :          0 :     Player.iq++;
     713                 :          0 :     break;
     714                 :            :   case DENEBIAN: /* denebian slime devil */
     715                 :          0 :     mprint("I don't believe this. You ate Denebian Slime?");
     716                 :          0 :     mprint("You deserve a horrible wasting death, uncurable by any means!");
     717                 :          0 :     break;
     718                 :            :   case DRAGONETTE:  /* can't get here... i_usef changed to I_FOOD */ 
     719                 :          0 :     mprint("Those dragon-steaks were fantastic!");
     720                 :          0 :     Player.food=24;
     721                 :          0 :     foodcheck();
     722                 :          0 :     break;
     723                 :            :   case BEHEMOTH:
     724                 :          0 :     mprint("You feel infinitely more virile now.");
     725                 :          0 :     Player.str = max(Player.str,Player.maxstr+10);
     726                 :          0 :     Player.food = 24;
     727                 :          0 :     foodcheck();
     728                 :          0 :     break;
     729                 :            :   case INVIS_SLAY:
     730                 :          0 :     mprint("Guess what? You're invisible.");
     731         [ #  # ]:          0 :     if (Player.status[INVISIBLE] < 1000) Player.status[INVISIBLE] = 666;
     732                 :          0 :     Player.food+=6;
     733                 :          0 :     foodcheck();
     734                 :          0 :     break;
     735                 :            :   case UNICORN:  
     736                 :          0 :     mprint("You ATE a unicorn's horn?!?!?");
     737                 :          0 :     Player.immunity[POISON]=1000;
     738                 :          0 :     break;
     739                 :            :   case HORNET: /* can't get here... i_usef changed to I_POISON_FOOD */
     740                 :            :   case GRUNT:
     741                 :            :   case TSETSE:  /* can't get here... i_usef changed to I_SLEEP_SELF */
     742                 :            :   case AGGRAVATOR:
     743                 :            :   case BLIPPER: /* can't get here... i_usef changed to I_TELEPORT */
     744                 :            :   case GOBLIN:
     745                 :            :   case GEEK:
     746                 :            :   case NIGHT_GAUNT: /* can't get here... i_usef changed to I_POISON_FOOD */
     747                 :            :   case TOVE:
     748                 :            :   case TASMANIAN:
     749                 :            :   case JUBJUB:  /* can't get here... i_usef changed to I_FOOD */
     750                 :            :   case CATEAGLE:
     751                 :          0 :     mprint("Well, you forced it down. Not much nutrition, though.");
     752                 :          0 :     Player.food++;
     753                 :          0 :     foodcheck();
     754                 :          0 :     break;
     755                 :            :   case SEWER_RAT:
     756                 :            :   case PHANTASTICON: /* can't get here... i_usef changed to I_POISON_FOOD */
     757                 :            :   case EYE:  /* can't get here... i_usef changed to I_CLAIRVOYANCE */
     758                 :            :   case NASTY:  /* can't get here... i_usef changed to I_INVISIBLE */
     759                 :            :   case CATOBLEPAS:
     760                 :            :   case HAUNT: /* can't get here... i_usef changed to I_POISON_FOOD */
     761                 :            :   case ROUS:
     762                 :            :   case DEATHSTAR: /* can't get here... i_usef changed to I_POISON_FOOD */
     763                 :            :   case EATER:
     764                 :          0 :     mprint("Oh, yuck. The 'food' seems to be tainted.");
     765                 :          0 :     mprint("You feel very sick. You throw up.");
     766                 :          0 :     Player.food = min(Player.food, 4);
     767                 :          0 :   default: mprint("It proved completely inedible, but you tried anyhow.");
     768                 :            :   }
     769                 :          0 : }
     770                 :            : 
     771                 :          0 : void i_accuracy(pob o)
     772                 :            : {
     773         [ #  # ]:          0 :   if (o->known < 1) o->known = 1;
     774                 :          0 :   Objects[o->id].known = 1;
     775                 :          0 :   accuracy(o->blessing);
     776                 :          0 : }
     777                 :            : 
     778                 :          0 : void i_perm_accuracy(pob o)
     779                 :            : {
     780         [ #  # ]:          0 :   if (o->known < 1) o->known = 1;
     781                 :          0 :   Objects[o->id].known = 1;
     782 [ #  # ][ #  # ]:          0 :   if ((o->used) && (o->blessing > -1)) {
     783                 :          0 :     Player.status[ACCURATE] += 1500;
     784                 :          0 :     mprint("You feel skillful and see bulls' eyes everywhere.");
     785                 :            :   }
     786                 :            :   else {
     787                 :          0 :     Player.status[ACCURATE] -= 1500;
     788         [ #  # ]:          0 :     if (Player.status[ACCURATE] < 1) {
     789                 :          0 :       Player.status[ACCURATE] = 0;
     790                 :          0 :       calc_melee();
     791                 :          0 :       mprint("Your vision blurs....");
     792                 :            :     }
     793                 :            :   }
     794                 :          0 : }
     795                 :            : 
     796                 :          0 : void i_hero(pob o)
     797                 :            : {
     798         [ #  # ]:          0 :   if (o->known < 1) o->known = 1;
     799                 :          0 :   Objects[o->id].known = 1;
     800                 :          0 :   hero(o->blessing);
     801                 :          0 : }
     802                 :            : 
     803                 :          0 : void i_perm_hero(pob o)
     804                 :            : {
     805         [ #  # ]:          0 :   if (o->known < 1) o->known = 1;
     806                 :          0 :   Objects[o->id].known = 1;
     807         [ #  # ]:          0 :   if (o->used){
     808         [ #  # ]:          0 :     if (o->blessing > -1) {
     809                 :          0 :       Player.status[HERO] += 1500;
     810                 :          0 :       calc_melee();
     811                 :          0 :       mprint("You feel super!");
     812                 :            :     }
     813                 :            :     else {
     814                 :          0 :       Player.status[HERO] = 0;
     815                 :          0 :       calc_melee();
     816         [ #  # ]:          0 :       if (! Player.immunity[FEAR]) {
     817                 :          0 :         Player.status[AFRAID]+=1500;
     818                 :          0 :         mprint("You feel cowardly....");
     819                 :            :       }
     820                 :            :     }
     821                 :            :   }
     822                 :            :   else {
     823         [ #  # ]:          0 :     if (o->blessing > -1) {
     824                 :          0 :       Player.status[HERO] -= 1500;
     825         [ #  # ]:          0 :       if (Player.status[HERO] < 1) {
     826                 :          0 :         calc_melee();
     827                 :          0 :         mprint("You feel less super now.");
     828                 :          0 :         Player.status[HERO] = 0;
     829                 :            :       }
     830                 :            :     }
     831                 :            :     else {
     832                 :          0 :       Player.status[AFRAID] -= 1500;
     833         [ #  # ]:          0 :       if (Player.status[AFRAID] < 1) {
     834                 :          0 :         mprint("You finally conquer your fear.");
     835                 :          0 :         Player.status[AFRAID] = 0;
     836                 :            :       }
     837                 :            :     }
     838                 :            :   } 
     839                 :          0 : }
     840                 :            : 
     841                 :          0 : void i_levitate(pob o)
     842                 :            : {
     843         [ #  # ]:          0 :   if (o->known < 1) o->known = 1;
     844                 :          0 :   Objects[o->id].known = 1;
     845                 :          0 :   levitate(o->blessing);
     846                 :          0 : }
     847                 :            : 
     848                 :          0 : void i_perm_levitate(pob o)
     849                 :            : {
     850         [ #  # ]:          0 :   if (o->known < 1) o->known = 1;
     851                 :          0 :   Objects[o->id].known = 1;
     852         [ #  # ]:          0 :   if (o->blessing > -1) {
     853         [ #  # ]:          0 :     if (o->used) {
     854                 :          0 :       Player.status[LEVITATING] += 1400;
     855                 :          0 :       mprint("You start to float a few inches above the floor");
     856                 :          0 :       mprint("You find you can easily control your altitude");
     857                 :            :     }
     858                 :            :     else {
     859                 :          0 :       Player.status[LEVITATING] -= 1500;
     860         [ #  # ]:          0 :       if (Player.status[LEVITATING] < 1) {
     861                 :          0 :         Player.status[LEVITATING] = 0;
     862                 :          0 :         mprint("You sink to the floor.");
     863                 :            :       }
     864                 :            :     }
     865                 :            :   }
     866                 :          0 :   else i_perm_burden(o);
     867                 :          0 : }
     868                 :            : 
     869                 :          0 : void i_perm_protection(pob o)
     870                 :            : {
     871         [ #  # ]:          0 :   if (o->used){
     872         [ #  # ]:          0 :     if (o->blessing > -1)
     873                 :          0 :       Player.status[PROTECTION] += abs(o->plus)+1;
     874                 :            :     else
     875                 :          0 :       Player.status[PROTECTION] -= abs(o->plus)+1;
     876                 :            :   }
     877                 :            :   else {
     878         [ #  # ]:          0 :     if (o->blessing > -1)
     879                 :          0 :       Player.status[PROTECTION] -= abs(o->plus)+1;
     880                 :            :     else
     881                 :          0 :       Player.status[PROTECTION] += abs(o->plus)+1;
     882                 :            :   }
     883                 :          0 :   calc_melee();
     884                 :          0 : }
     885                 :            : 
     886                 :          0 : void i_perm_agility(pob o)
     887                 :            : {
     888         [ #  # ]:          0 :   if (o->known < 1) o->known = 2;
     889                 :          0 :   Objects[o->id].known = 1;
     890         [ #  # ]:          0 :   if (o->used){
     891         [ #  # ]:          0 :     if (o->blessing > -1)
     892                 :          0 :       Player.agi += abs(o->plus)+1;
     893                 :            :     else
     894                 :          0 :       Player.agi -= abs(o->plus)+1;
     895                 :            :   }
     896                 :            :   else {
     897         [ #  # ]:          0 :     if (o->blessing > -1)
     898                 :          0 :       Player.agi -= abs(o->plus)+1;
     899                 :            :     else
     900                 :          0 :       Player.agi += abs(o->plus)+1;
     901                 :            :   }
     902                 :          0 :   calc_melee();
     903                 :          0 : }
     904                 :            : 
     905                 :          0 : void i_truesight(pob o)
     906                 :            : {
     907         [ #  # ]:          0 :   if (o->known < 1) o->known = 1;
     908                 :          0 :   Objects[o->id].known = 1;
     909                 :          0 :   truesight(o->blessing);
     910                 :          0 : }
     911                 :            : 
     912                 :          0 : void i_perm_truesight(pob o)
     913                 :            : {
     914         [ #  # ]:          0 :   if (o->known < 1) o->known = 1;
     915                 :          0 :   Objects[o->id].known = 1;
     916         [ #  # ]:          0 :   if (o->used){
     917         [ #  # ]:          0 :     if (o->blessing > -1) {
     918                 :          0 :       Player.status[TRUESIGHT] += 1500;
     919                 :          0 :       mprint("You feel sharp!");
     920                 :            :     }
     921                 :            :     else {
     922                 :          0 :       Player.status[BLINDED] += 1500;
     923                 :          0 :       mprint("You've been blinded!");
     924                 :            :     }
     925                 :            :   }
     926                 :            :   else {
     927         [ #  # ]:          0 :     if (o->blessing > -1) {
     928                 :          0 :       Player.status[TRUESIGHT] -= 1500;
     929         [ #  # ]:          0 :       if (Player.status[TRUESIGHT] < 1) {
     930                 :          0 :         mprint("You feel less keen now.");
     931                 :          0 :         Player.status[TRUESIGHT] = 0;
     932                 :            :       }
     933                 :            :     }
     934                 :            :     else {
     935                 :          0 :       Player.status[BLINDED] -= 1500;
     936         [ #  # ]:          0 :       if (Player.status[BLINDED] < 1) {
     937                 :          0 :         mprint("You can see again!"); 
     938                 :          0 :         Player.status[BLINDED] = 0;
     939                 :            :       }
     940                 :            :     }
     941                 :            :   } 
     942                 :          0 : }
     943                 :            : 
     944                 :          0 : void i_illuminate(pob o)
     945                 :            : {
     946         [ #  # ]:          0 :   if (o->known < 1) o->known = 1;
     947                 :          0 :   Objects[o->id].known = 1;
     948                 :          0 :   illuminate(o->blessing);
     949                 :          0 : }
     950                 :            : 
     951                 :          0 : void i_perm_illuminate(pob o)
     952                 :            : {
     953         [ #  # ]:          0 :   if (o->known < 1) o->known = 1;
     954                 :          0 :   Objects[o->id].known = 1;
     955         [ #  # ]:          0 :   if (o->used) 
     956                 :          0 :     Player.status[ILLUMINATION]+=1500;
     957                 :            :   else
     958                 :          0 :     Player.status[ILLUMINATION]=max(0,Player.status[ILLUMINATION]-1500);
     959                 :          0 : }
     960                 :            : 
     961                 :            : 
     962                 :            : 
     963                 :            : 
     964                 :          0 : void i_trap(pob o)
     965                 :            : {
     966                 :          0 :   Objects[o->id].known = 1;
     967                 :            :   
     968 [ #  # ][ #  # ]:          0 :   if ((Level->site[Player.x][Player.y].locchar != FLOOR) ||
     969                 :          0 :       (Level->site[Player.x][Player.y].p_locf != L_NO_OP))
     970                 :          0 :     mprint("Your attempt fails.");
     971         [ #  # ]:          0 :   else  if (! o->known) {
     972                 :          0 :     mprint("Fiddling with the thing, you have a small accident....");
     973                 :          0 :     p_movefunction(o->aux);
     974                 :            :   }
     975                 :            :   else {
     976                 :          0 :     mprint("You successfully set a trap at your location.");
     977                 :          0 :     Level->site[Player.x][Player.y].p_locf = o->aux;
     978                 :          0 :     lset(Player.x, Player.y, CHANGED);
     979                 :            :   }
     980                 :          0 :   dispose_lost_objects(1,o);
     981                 :          0 : }
     982                 :            : 
     983                 :            : 
     984                 :          0 : void i_raise_portcullis(pob o)
     985                 :            : {
     986                 :          0 :   l_raise_portcullis();
     987                 :          0 :   mprint("The box beeps once and explodes in your hands!");
     988                 :          0 :   conform_lost_objects(1,o);
     989                 :          0 : }
     990                 :            : 

Generated by: LCOV version 1.11