LCOV - code coverage report
Current view: top level - omega-rpg-0.90-pa9 - item.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 229 485 47.2 %
Date: 2017-09-08 22:00:26 Functions: 25 28 89.3 %
Branches: 164 416 39.4 %

           Branch data     Line data    Source code
       1                 :            : /* omega copyright (C) 1987,1988,1989 by Laurence Raphael Brothers */
       2                 :            : /* item.c */
       3                 :            : 
       4                 :            : #include "glob.h"
       5                 :            : 
       6                 :            : /* make a random new object, returning pointer */
       7                 :         16 : pob create_object(int itemlevel)
       8                 :            : {
       9                 :            :   pob new;
      10                 :            :   int  r; 
      11                 :         16 :   int ok = FALSE;
      12                 :            : 
      13         [ +  + ]:         40 :   while (! ok) {
      14                 :         24 :     new = ((pob) checkmalloc(sizeof(objtype)));
      15                 :         24 :     r= random_range(135);
      16         [ +  + ]:         24 :     if (r < 20) make_thing(new,-1);
      17         [ +  + ]:         18 :     else if (r < 40) make_food(new,-1);
      18         [ +  + ]:         16 :     else if (r < 50) make_scroll(new,-1);
      19         [ -  + ]:         12 :     else if (r < 60) make_potion(new,-1);
      20         [ +  + ]:         12 :     else if (r < 70) make_weapon(new,-1);
      21         [ +  + ]:         10 :     else if (r < 80) make_armor(new,-1);
      22         [ +  + ]:          8 :     else if (r < 90) make_shield(new,-1);
      23         [ +  + ]:          5 :     else if (r < 100) make_stick(new,-1);
      24         [ +  + ]:          4 :     else if (r < 110) make_boots(new,-1);
      25         [ +  + ]:          3 :     else if (r < 120) make_cloak(new,-1);
      26         [ +  - ]:          1 :     else if (r < 130) make_ring(new,-1);
      27                 :          0 :     else make_artifact(new,-1);
      28                 :            :     /* not ok if object is too good for level, or if unique and already made */
      29                 :            :     /* 1/100 chance of finding object if too good for level */
      30   [ +  +  +  + ]:         55 :     ok = ((new->uniqueness < UNIQUE_MADE) &&
      31                 :         23 :           ((new->level < itemlevel+random_range(3))
      32         [ +  + ]:          8 :            || (random_range(100)==23)));
      33         [ +  + ]:         24 :     if (!ok)
      34                 :            :     {
      35                 :          8 :         free_obj( new, TRUE );
      36                 :            :     }
      37                 :            :   }
      38         [ -  + ]:         16 :   if (new->uniqueness == UNIQUE_UNMADE) 
      39                 :          0 :     Objects[new->id].uniqueness=UNIQUE_MADE;
      40                 :         16 :   return(new);
      41                 :            : }
      42                 :            : 
      43                 :          1 : void make_cash(pob new, int level)
      44                 :            : {
      45                 :          1 :   *new = Objects[CASHID];
      46                 :          1 :   new->basevalue = random_range(level*level+10)+1; /* aux is AU value */
      47                 :          1 :   new->objstr = cashstr();
      48                 :          1 :   new->cursestr = new->truename = new->objstr;
      49                 :          1 : }
      50                 :            : 
      51                 :          2 : void make_food(pob new, int id)
      52                 :            : {
      53         [ +  - ]:          2 :   if (id == -1) id = random_range(NUMFOODS);
      54                 :          2 :   *new = Objects[FOODID+id];
      55                 :          2 : }
      56                 :            : 
      57                 :            : 
      58                 :          1 : void make_corpse(pob new, pmt m)
      59                 :            : {
      60                 :          1 :   *new = Objects[CORPSEID];
      61                 :          1 :   new->charge = m->id;
      62                 :          1 :   new->weight = m->corpseweight;
      63                 :          1 :   new->basevalue = m->corpsevalue;
      64                 :          1 :   new->known = 2;
      65                 :          1 :   new->objstr = m->corpsestr;
      66                 :          1 :   new->truename = new->cursestr = new->objstr;
      67         [ -  + ]:          1 :   if ( m_statusp(m, ALLOC ) )
      68                 :            :   {
      69                 :            :     /* DAG we are keeping the corpsestr here, can free monstring */
      70                 :            :     /*     later, should track this in the object as well, as this */
      71                 :            :     /*     is still a memory leak (though smaller than before)  */
      72                 :          0 :     free ( m->monstring );
      73                 :          0 :     m->monstring = Monsters[m->id].monstring;
      74                 :          0 :     m->corpsestr = Monsters[m->id].corpsestr;
      75                 :          0 :     m_status_reset( m, ALLOC );
      76                 :            :     /* DAG level not otherwise used for corpses.  Use to hold ALLOC info. */
      77                 :          0 :     new->level |= ALLOC;
      78                 :            :   }
      79                 :            : /* DG I_CANNIBAL not implemented... fall through to code in I_CORPSE */
      80                 :            : /* WDT HACK, of course -- we need to implement I_CANNIBAL. */
      81                 :            : #if 0 
      82                 :            :   if ((m->monchar&0xff) == '@')
      83                 :            :     new->usef = I_CANNIBAL;
      84                 :            :   else 
      85                 :            : #endif
      86         [ -  + ]:          1 :   if (m_statusp(m,EDIBLE)) {
      87                 :          0 :     new->usef = I_FOOD;
      88                 :          0 :     new->aux = 6;
      89                 :            :   }
      90         [ -  + ]:          1 :   else if (m_statusp(m,POISONOUS))
      91                 :          0 :     new->usef = I_POISON_FOOD;
      92                 :            :   /* Special corpse-eating effects */
      93   [ -  -  -  -  :          1 :   else switch(m->id) {
          -  -  -  -  -  
                -  -  + ]
      94                 :            :   case TSETSE: /*tse tse fly */
      95                 :            :   case TORPOR: /*torpor beast */
      96                 :          0 :     new->usef = I_SLEEP_SELF;
      97                 :          0 :     break;
      98                 :            :   case NASTY:
      99                 :          0 :     new->usef = I_INVISIBLE;
     100                 :          0 :     break;
     101                 :            :   case BLIPPER:
     102                 :          0 :     new->usef = I_TELEPORT;
     103                 :          0 :     break;
     104                 :            :   case EYE: /* floating eye -- it's traditional.... */
     105                 :          0 :     new->usef = I_CLAIRVOYANCE;
     106                 :          0 :     break;
     107                 :            :   case FUZZY: /*astral fuzzy */
     108                 :          0 :     new->usef = I_DISPLACE;
     109                 :          0 :     break;
     110                 :            :   case SERV_LAW:
     111                 :          0 :     new->usef = I_CHAOS;
     112                 :          0 :     break;
     113                 :            :   case SERV_CHAOS:
     114                 :          0 :     new->usef = I_LAW;
     115                 :          0 :     break;
     116                 :            :   case ASTRAL_VAMP: /* astral vampire */
     117                 :          0 :     new->usef = I_ENCHANT;
     118                 :          0 :     break;
     119                 :            :   case MANABURST:
     120                 :          0 :     new->usef = I_SPELLS;
     121                 :          0 :     break;
     122                 :            :   case RAKSHASA:
     123                 :          0 :     new->usef = I_TRUESIGHT;
     124                 :          0 :     break;
     125                 :            : /* DG fall through to code in I_CORPSE and special case there */
     126                 :            : #if 0 /* WDT HACK? */
     127                 :            :   case BEHEMOTH:
     128                 :            :     new->usef = I_HEAL;
     129                 :            :     break;
     130                 :            :   case UNICORN:
     131                 :            :     new->usef = I_NEUTRALIZE_POISON;
     132                 :            :     break;
     133                 :            : #endif
     134                 :            :   case COMA: /*coma beast */
     135                 :          0 :     new->usef = I_ALERT;
     136                 :          0 :     break;
     137                 :            : /* DG I_INEDIBLE not implemented... fall through to code in I_CORPSE */
     138                 :            : #if 0 /* WDT HACK: yawn. */
     139                 :            :   default:
     140                 :            :     new->usef = I_INEDIBLE; 
     141                 :            :     break;
     142                 :            : #endif
     143                 :            :   }
     144                 :          1 : }
     145                 :            : 
     146                 :            : 
     147                 :          1 : void make_ring(pob new, int id)
     148                 :            : {
     149         [ +  - ]:          1 :   if (id == -1) id = random_range(NUMRINGS);
     150                 :          1 :   *new = Objects[RINGID+id];
     151         [ -  + ]:          1 :   if (new->blessing == 0) new->blessing = itemblessing();
     152         [ +  - ]:          1 :   if (new->plus == 0) new->plus = itemplus()+1;
     153         [ +  - ]:          1 :   if (new->blessing < 0) new->plus = -1 - abs(new->plus);
     154                 :          1 : }
     155                 :            : 
     156                 :          6 : void make_thing (pob new, int id)
     157                 :            : {
     158         [ +  - ]:          6 :   if (id == -1) id = random_range(NUMTHINGS);
     159                 :            : 
     160                 :          6 :   *new = Objects[THINGID+id];
     161                 :            : 
     162         [ +  + ]:          6 :   if (0 == strcmp(new->objstr, "grot"))
     163                 :            :     {
     164                 :          2 :       new->objstr = grotname();
     165                 :          2 :       new->truename = new->cursestr = new->objstr;
     166                 :            :     }
     167 [ -  + ][ #  # ]:          4 :   else if (new->id >= CARDID && new->id < (CARDID + NUMCARDS))
     168                 :            :     {
     169   [ #  #  #  #  :          0 :       switch (new->id)
                      # ]
     170                 :            :         {
     171                 :            :         case OB_DEBIT_CARD:
     172                 :          0 :           new->aux = bank_random_account_number();
     173                 :          0 :           break;
     174                 :            : 
     175                 :            :         case OB_CREDIT_CARD:
     176                 :          0 :           new->charge = random_range(250) + random_range(250) + random_range(250);
     177                 :          0 :           break;
     178                 :            : 
     179                 :            :         case OB_PREPAID_CARD:
     180                 :          0 :           new->charge = random_range(50) + random_range(50) + random_range(50);
     181                 :          0 :           break;
     182                 :            : 
     183                 :            :         case OB_SMART_CARD:
     184                 :          0 :           new->aux = bank_random_account_number();
     185                 :          0 :           new->charge = random_range(500) + random_range(500) + random_range(500);
     186                 :          0 :           break;
     187                 :            :         }
     188                 :            :     }
     189                 :          6 : }
     190                 :            : 
     191                 :            : 
     192                 :          4 : void make_scroll(pob new, int id)
     193                 :            : {
     194         [ +  - ]:          4 :   if (id == -1) id = random_range(NUMSCROLLS);
     195                 :          4 :   *new = Objects[SCROLLID+id];
     196                 :            :   /* if a scroll of spells, aux is the spell id in Spells */
     197         [ -  + ]:          4 :   if (new->id == OB_SPELLS_SCROLL) {
     198                 :          0 :     new->aux = random_range(NUMSPELLS);
     199                 :            :   }
     200                 :          4 : }
     201                 :            : 
     202                 :          0 : void make_potion(pob new, int id)
     203                 :            : {
     204         [ #  # ]:          0 :   if (id == -1) id = random_range(NUMPOTIONS);
     205                 :          0 :   *new = Objects[POTIONID+id];
     206         [ #  # ]:          0 :   if (new->plus == 0) new->plus = itemplus();
     207                 :          0 : }
     208                 :            : 
     209                 :          2 : void make_weapon(pob new, int id)
     210                 :            : {
     211         [ +  - ]:          2 :   if (id == -1) id = random_range(NUMWEAPONS);
     212                 :          2 :   *new = Objects[WEAPONID+id];
     213 [ +  - ][ -  + ]:          2 :   if ((id == 28) || (id == 29)) /* bolt or arrow */
     214                 :          0 :     new->number = random_range(20)+1;
     215         [ -  + ]:          2 :   if (new->blessing == 0) new->blessing = itemblessing();
     216         [ -  + ]:          2 :   if (new->plus == 0) {
     217                 :          0 :     new->plus = itemplus();
     218         [ #  # ]:          0 :     if (new->blessing < 0)
     219                 :          0 :       new->plus = -1 - abs(new->plus);
     220         [ #  # ]:          0 :     else if (new->blessing > 0)
     221                 :          0 :       new->plus = 1 + abs(new->plus);
     222                 :            :   }
     223                 :          2 : }
     224                 :            : 
     225                 :          3 : void make_shield(pob new, int id)
     226                 :            : {
     227         [ +  - ]:          3 :   if (id == -1) id = random_range(NUMSHIELDS);
     228                 :          3 :   *new = Objects[SHIELDID+id];
     229         [ +  + ]:          3 :   if (new->plus == 0)
     230                 :          2 :     new->plus = itemplus();
     231         [ +  - ]:          3 :   if (new->blessing == 0) new->blessing = itemblessing();
     232         [ +  + ]:          3 :   if (new->blessing < 0)
     233                 :          1 :     new->plus = -1 - abs(new->plus);
     234         [ -  + ]:          2 :   else if (new->blessing > 0)
     235                 :          0 :     new->plus = 1 + abs(new->plus);
     236                 :          3 : }
     237                 :            : 
     238                 :          2 : void make_armor(pob new, int id)
     239                 :            : {
     240         [ +  - ]:          2 :   if (id == -1) id = random_range(NUMARMOR);
     241                 :          2 :   *new = Objects[ARMORID+id];
     242         [ +  + ]:          2 :   if (new->plus == 0) new->plus = itemplus();
     243         [ +  - ]:          2 :   if (new->blessing == 0) new->blessing = itemblessing();
     244         [ -  + ]:          2 :   if (new->blessing < 0)
     245                 :          0 :     new->plus = -1 - abs(new->plus);
     246         [ -  + ]:          2 :   else if (new->blessing > 0)
     247                 :          0 :     new->plus = 1 + abs(new->plus);  
     248                 :          2 : }
     249                 :            : 
     250                 :          2 : void make_cloak(pob new, int id)
     251                 :            : {
     252         [ +  - ]:          2 :   if (id == -1) id = random_range(NUMCLOAKS);
     253                 :          2 :   Objects[OB_CLOAK_PROTECT].plus = 2;
     254                 :          2 :   *new = Objects[CLOAKID+id];
     255         [ +  - ]:          2 :   if (new->blessing == 0) new->blessing = itemblessing();
     256                 :          2 : }
     257                 :            : 
     258                 :          1 : void make_boots(pob new, int id)
     259                 :            : {
     260         [ +  - ]:          1 :   if (id == -1) id = random_range(NUMBOOTS);
     261                 :          1 :   *new = Objects[BOOTID+id];
     262         [ +  - ]:          1 :   if (new->blessing == 0) new->blessing = itemblessing();
     263                 :          1 : }
     264                 :            : 
     265                 :          1 : void make_stick(pob new, int id)
     266                 :            : {
     267         [ +  - ]:          1 :   if (id == -1) id = random_range(NUMSTICKS);
     268                 :          1 :   *new = Objects[STICKID+id];
     269                 :          1 :   new->charge = itemcharge();
     270         [ +  - ]:          1 :   if (new->blessing == 0) new->blessing = itemblessing();
     271                 :          1 : }
     272                 :            : 
     273                 :          0 : void make_artifact(pob new, int id)
     274                 :            : {
     275         [ #  # ]:          0 :   if (id == -1)
     276                 :            :     do
     277                 :          0 :       id = random_range(NUMARTIFACTS);
     278         [ #  # ]:          0 :     while (Objects[id].uniqueness >= UNIQUE_MADE);
     279                 :          0 :   *new = Objects[ARTIFACTID+id];
     280         [ #  # ]:          0 :   if ( new->id == OB_HOLDING )
     281                 :          0 :     new->blessing = itemblessing();
     282                 :          0 : }
     283                 :            : 
     284                 :            : 
     285                 :            : /* this function is used to shuffle the id numbers of scrolls, potions, etc */
     286                 :            : /* taken from Knuth 2 */
     287                 :          0 : void shuffle(int ids[], int number)
     288                 :            : {
     289                 :            :   int top, swap, with;
     290                 :            : 
     291         [ #  # ]:          0 :   for (top = 0; top < number; top++)
     292                 :          0 :     ids[top] = top;
     293         [ #  # ]:          0 :   for (top = number - 1; top >= 0; top--) {
     294                 :          0 :     swap = ids[top];
     295                 :          0 :     with = random_range(top + 1);       /* from  0 to top, inclusive */
     296                 :          0 :     ids[top] = ids[with];
     297                 :          0 :     ids[with] = swap;
     298                 :            :   }
     299                 :          0 : }
     300                 :            : 
     301                 :            : /* item name functions */
     302                 :            : 
     303                 :         24 : char *scrollname(int id)
     304                 :            : {
     305   [ +  +  -  +  :         24 :   switch(scroll_ids[id]) {
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  -  +  
          +  -  +  +  +  
          +  -  +  +  -  
                      - ]
     306                 :          1 :       case 0: return "scroll-GRISTOGRUE";
     307                 :          1 :       case 1: return "scroll-Kho Reck Tighp";
     308                 :          0 :       case 2: return "scroll-E Z";
     309                 :          1 :       case 3: return "scroll-Kevitz";
     310                 :          1 :       case 4: return "scroll-Arcanum Prime";
     311                 :          1 :       case 5: return "scroll-NYARLATHOTEP";
     312                 :          1 :       case 6: return "scroll-Gilthoniel";
     313                 :          1 :       case 7: return "scroll-Zarathustra";
     314                 :          1 :       case 8: return "scroll-Ancient Lore";
     315                 :          1 :       case 9: return "scroll-Eyes Only";
     316                 :          1 :       case 10: return "scroll-Ambogar Empheltz";
     317                 :          1 :       case 11: return "scroll-Isengard";
     318                 :          1 :       case 12: return "scroll-Deosil Widdershins";
     319                 :          1 :       case 13: return "scroll-Magister Paracelsus";
     320                 :          1 :       case 14: return "scroll-Qlipphotic Summons";
     321                 :          1 :       case 15: return "scroll-Aratron Samael";
     322                 :          1 :       case 16: return "scroll-De Wormiis Mysterius";
     323                 :          0 :       case 17: return "scroll-Necronomicon";
     324                 :          1 :       case 18: return "scroll-Pnakotic Manuscript";
     325                 :          1 :       case 19: return "scroll-Codex of Xalimar";
     326                 :          0 :       case 20: return "scroll-The Mabinogion";
     327                 :          1 :       case 21: return "scroll-Ginseng Shiatsu";
     328                 :          1 :       case 22: return "scroll-Tome of Tromax";
     329                 :          1 :       case 23: return "scroll-Book of the Dead ";
     330                 :          1 :       case 24: return "scroll-The Flame Tongue";
     331                 :          0 :       case 25: return "scroll-Karst Khogar";
     332                 :          1 :       case 26: return "scroll-The Yellow Sign";
     333                 :          1 :       case 27: return "scroll-The Kevillist Manifesto";
     334                 :          0 :       case 28: return "scroll-Goshtar Script";
     335                 :            :       default:
     336                 :          0 :       case 29: return "scroll-Pendragon Encryption";
     337                 :            :     }
     338                 :            : }
     339                 :            : 
     340                 :          2 : char *grotname(void)
     341                 :            : {
     342   [ +  -  -  -  :          2 :   switch(random_range(21)) {
          -  -  -  -  -  
          -  -  -  -  +  
          -  -  -  -  -  
                   -  - ]
     343                 :          1 :     case 0: return "pot lid";
     344                 :          0 :     case 1: return "mound of offal";
     345                 :          0 :     case 2: return "sword that was broken";
     346                 :          0 :     case 3: return "salted snail";
     347                 :          0 :     case 4: return "key";
     348                 :          0 :     case 5: return "toadstool";
     349                 :          0 :     case 6: return "greenish spindle";
     350                 :          0 :     case 7: return "tin soldier";
     351                 :          0 :     case 8: return "broken yo-yo";
     352                 :          0 :     case 9: return "NYC subway map";
     353                 :          0 :     case 10: return "Nixon's the One! button";
     354                 :          0 :     case 11: return "beer can (empty)";
     355                 :          0 :     case 12: return "golden bejewelled falcon";
     356                 :          1 :     case 13: return "hamster cage";
     357                 :          0 :     case 14: return "wooden nickel";
     358                 :          0 :     case 15: return "three-dollar bill";
     359                 :          0 :     case 16: return "rosebud";
     360                 :          0 :     case 17: return "water pistol";
     361                 :          0 :     case 18: return "shattered skull";
     362                 :          0 :     case 19: return "black bag";
     363                 :            :     default:
     364                 :          0 :     case 20: return "jawbone of an ass";
     365                 :            :   }
     366                 :            : }
     367                 :            : 
     368                 :            : 
     369                 :            : 
     370                 :            : 
     371                 :         20 : char *potionname(int id)
     372                 :            : {
     373   [ +  +  +  +  :         20 :   switch (potion_ids[id]) {
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
                      + ]
     374                 :          1 :     case 0: return "vial of dewy liquid";
     375                 :          1 :     case 1: return "jug of tarry black substance";
     376                 :          1 :     case 2: return "flask of cold smoking froth";
     377                 :          1 :     case 3: return "phial of glowing fluid";
     378                 :          1 :     case 4: return "bottle of sickening slime";
     379                 :          1 :     case 5: return "sac of greenish gel";
     380                 :          1 :     case 6: return "wineskin of odorous goo";
     381                 :          1 :     case 7: return "canteen of sweet sap";
     382                 :          1 :     case 8: return "urn of clear fluid";
     383                 :          1 :     case 9: return "clotted grey ooze";
     384                 :          1 :     case 10: return "keg of bubbly golden fluid";
     385                 :          1 :     case 11: return "tube of minty paste";
     386                 :          1 :     case 12: return "pitcher of aromatic liquid";
     387                 :          1 :     case 13: return "pot of rancid grease";
     388                 :          1 :     case 14: return "thermos of hot black liquid";
     389                 :          1 :     case 15: return "magnum of deep red liquid";
     390                 :          1 :     case 16: return "vase full of ichor";
     391                 :          1 :     case 17: return "container of white cream";
     392                 :          1 :     case 18: return "syringe of clear fluid";
     393                 :            :     default:
     394                 :          1 :     case 19: return "can of volatile essence";
     395                 :            :   }      
     396                 :            : }
     397                 :            : 
     398                 :            : 
     399                 :         17 : char *stickname(int id)
     400                 :            : {
     401   [ +  +  -  +  :         17 :   switch (stick_ids[id]) {
          +  +  +  +  +  
          -  +  -  +  +  
          +  +  +  +  +  
                      + ]
     402                 :          1 :     case 0: return "oaken staff";
     403                 :          1 :     case 1: return "heavy metal rod";
     404                 :          0 :     case 2: return "shaft of congealed light";
     405                 :          1 :     case 3: return "slender ceramic wand";
     406                 :          1 :     case 4: return "rune-inscribed bone wand";
     407                 :          1 :     case 5: return "knurly staff";
     408                 :          1 :     case 6: return "steel knobbed rod";
     409                 :          1 :     case 7: return "lucite wand";
     410                 :          1 :     case 8: return "sturdy alpenstock";
     411                 :          0 :     case 9: return "gem-studded ebony staff";
     412                 :          1 :     case 10: return "chromed sequinned staff";
     413                 :          0 :     case 11: return "old peeling stick";
     414                 :          1 :     case 12: return "jointed metal rod";
     415                 :          1 :     case 13: return "wand with lead ferrules";
     416                 :          1 :     case 14: return "forked wooden stick";
     417                 :          1 :     case 15: return "cane with gold eagle handle";
     418                 :          1 :     case 16: return "crystalline wand";
     419                 :          1 :     case 17: return "metal stick with trigger";
     420                 :          1 :     case 18: return "leather-handled stone rod";
     421                 :            :     default:
     422                 :          1 :     case 19: return "tiny mithril wand";
     423                 :            :   }      
     424                 :            : }
     425                 :            : 
     426                 :          9 : char *ringname(int id)
     427                 :            : {
     428   [ +  -  -  -  :          9 :   switch (ring_ids[id]) {
          -  +  -  -  +  
          -  -  -  -  +  
          -  +  +  +  +  
                      + ]
     429                 :          1 :     case 0: return "gold ring with a blue gem";
     430                 :          0 :     case 1: return "brass ring";
     431                 :          0 :     case 2: return "mithril ring with a red gem";
     432                 :          0 :     case 3: return "platinum ring";  break;
     433                 :          0 :     case 4: return "gold dragon's head ring";
     434                 :          1 :     case 5: return "bronze ring";
     435                 :          0 :     case 6: return "aardvark seal ring";
     436                 :          0 :     case 7: return "grey metal ring";
     437                 :          1 :     case 8: return "silver skull ring";
     438                 :          0 :     case 9: return "onyx ring";
     439                 :          0 :     case 10: return "Collegium Magii class ring";
     440                 :          0 :     case 11: return "worn stone ring";
     441                 :          0 :     case 12: return "diorite ring";
     442                 :          1 :     case 13: return "ancient scarab ring";  break;
     443                 :          0 :     case 14: return "plastic charm ring";
     444                 :          1 :     case 15: return "soapy gypsum ring";
     445                 :          1 :     case 16: return "glass ring";
     446                 :          1 :     case 17: return "glowing bluestone ring";
     447                 :          1 :     case 18: return "ring with eye sigil";
     448                 :            :     default:
     449                 :          1 :     case 19: return "zirconium ring";
     450                 :            :   }      
     451                 :            : }
     452                 :            : 
     453                 :            : 
     454                 :          7 : char *cloakname(int id)
     455                 :            : {
     456   [ -  +  -  +  :          7 :   switch (cloak_ids[id]) {
          +  -  -  +  -  
          -  -  -  -  +  
          +  -  -  -  -  
                      + ]
     457                 :          0 :     case 0: return "tattered piece of cloth";
     458                 :          1 :     case 1: return "fuligin cloak";
     459                 :          0 :     case 2: return "chintz cloak";
     460                 :          1 :     case 3: return "diaphanous cape";  break;
     461                 :          1 :     case 4: return "red half-cloak";
     462                 :          0 :     case 5: return "mouse-hide cloak";
     463                 :          0 :     case 6: return "kelly green cloak";
     464                 :          1 :     case 7: return "cloth-of-gold cloak";
     465                 :          0 :     case 8: return "dirty old cloak";
     466                 :          0 :     case 9: return "weightless cloak";
     467                 :          0 :     case 10: return "boat cloak";
     468                 :          0 :     case 11: return "greasy tarpaulin";
     469                 :          0 :     case 12: return "sable cloak";
     470                 :          1 :     case 13: return "soft velvet cloak";  break;
     471                 :          1 :     case 14: return "opera cape";
     472                 :          0 :     case 15: return "elegant brocade cloak";
     473                 :          0 :     case 16: return "cloak of many colors";
     474                 :          0 :     case 17: return "grey-green rag";
     475                 :          0 :     case 18: return "puce and chartreuse cloak";
     476                 :            :     default:
     477                 :          1 :     case 19: return "smoky cloak";
     478                 :            :   }      
     479                 :            : }
     480                 :            : 
     481                 :          7 : char *bootname(int id)
     482                 :            : {
     483   [ +  +  -  +  :          7 :   switch (boot_ids[id]) {
          -  -  -  +  -  
          -  -  -  -  +  
          +  -  -  +  -  
                      - ]
     484                 :          1 :     case 0: return "sturdy leather boots";
     485                 :          1 :     case 1: return "calf-length moccasins";
     486                 :          0 :     case 2: return "dark-colored tabi";
     487                 :          1 :     case 3: return "patent-leather shoes";  break;
     488                 :          0 :     case 4: return "beaten-up gumshoes";
     489                 :          0 :     case 5: return "alligator-hide boots";
     490                 :          0 :     case 6: return "comfortable sandals";
     491                 :          1 :     case 7: return "roller skates";
     492                 :          0 :     case 8: return "purple suede gaiters";
     493                 :          0 :     case 9: return "mirror-plated wingtips";
     494                 :          0 :     case 10: return "heavy workboots";
     495                 :          0 :     case 11: return "polyurethane-soled sneakers";
     496                 :          0 :     case 12: return "clodhoppers";
     497                 :          1 :     case 13: return "wooden shoes";  break;
     498                 :          1 :     case 14: return "ski boots";
     499                 :          0 :     case 15: return "hob-nailed boots";
     500                 :          0 :     case 16: return "elven boots";
     501                 :          1 :     case 17: return "cowboy boots";
     502                 :          0 :     case 18: return "flipflop slippers";
     503                 :            :     default:
     504                 :          0 :     case 19: return "riding boots";
     505                 :            :   }      
     506                 :            : }
     507                 :            : 
     508                 :          4 : int itemplus(void)
     509                 :            : {
     510                 :          4 :   int p = 0;
     511                 :            : 
     512         [ +  + ]:          5 :   while (random_range(2) == 0)
     513                 :          1 :     p++;
     514                 :          4 :   return(p);
     515                 :            : }
     516                 :            : 
     517                 :            : 
     518                 :            : 
     519                 :          1 : int itemcharge(void)
     520                 :            : {
     521                 :          1 :   return(random_range(20)+1);
     522                 :            : }
     523                 :            : 
     524                 :            : 
     525                 :            : 
     526                 :          9 : int itemblessing(void)
     527                 :            : {
     528      [ +  +  + ]:          9 :   switch(random_range(10)) {
     529                 :            :     case 0:
     530                 :          2 :     case 1:return(-1-random_range(10));
     531                 :            :     case 8:
     532                 :          1 :     case 9:return(1+random_range(10));
     533                 :          6 :     default: return(0);    
     534                 :            :   }
     535                 :            : }
     536                 :            : 
     537                 :            :     
     538                 :          6 : int twohandedp(int id)
     539                 :            : {
     540         [ -  + ]:          6 :   switch(id) {
     541                 :            :   case OB_GREAT_SWORD:
     542                 :            :   case OB_GREAT_AXE:
     543                 :            :   case OB_QUARTERSTAFF:
     544                 :            :   case OB_HALBERD:
     545                 :            :   case OB_LONGBOW:
     546                 :            :   case OB_CROSSBOW:
     547                 :            :   case OB_DESECRATOR:
     548                 :            :   case OB_HEWER:
     549                 :            :   case OB_GIANT_CLUB:
     550                 :            :   case OB_SCYTHE_DEATH:
     551                 :          0 :     return(TRUE);
     552                 :          6 :   default: return(FALSE);
     553                 :            :   }
     554                 :            : }
     555                 :            : 
     556                 :            : 
     557                 :          2 : void item_use(pob o)
     558                 :            : {
     559                 :          2 :   clearmsg();
     560   [ -  -  -  -  :          2 :   switch(o->usef) {
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  +  +  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
             -  -  -  -  
                      - ]
     561                 :          0 :     case -1:i_no_op(o); break;
     562                 :          0 :     case 0:i_nothing(o); break;
     563                 :            : 
     564                 :            :     /* scrolls */           
     565                 :          0 :     case I_SPELLS: i_spells(o); break;
     566                 :          0 :     case I_BLESS: i_bless(o); break;
     567                 :          0 :     case I_ACQUIRE: i_acquire(o); break;
     568                 :          0 :     case I_ENCHANT: i_enchant(o); break;
     569                 :          0 :     case I_TELEPORT: i_teleport(o); break;
     570                 :          0 :     case I_WISH: i_wish(o); break;
     571                 :          0 :     case I_CLAIRVOYANCE: i_clairvoyance(o); break;
     572                 :          0 :     case I_DISPLACE: i_displace(o); break;
     573                 :          0 :     case I_ID: i_id(o); break;
     574                 :          0 :     case I_JANE_T: i_jane_t(o); break;
     575                 :          0 :     case I_FLUX: i_flux(o); break;
     576                 :          0 :     case I_WARP: i_warp(o); break;
     577                 :          0 :     case I_ALERT: i_alert(o); break;
     578                 :          0 :     case I_CHARGE: i_charge(o); break;
     579                 :          0 :     case I_KNOWLEDGE: i_knowledge(o); break;
     580                 :          0 :     case I_LAW: i_law(o); break;
     581                 :          0 :     case I_HINT: hint(); break;
     582                 :          0 :     case I_HERO: i_hero(o); break;
     583                 :          0 :     case I_TRUESIGHT: i_truesight(o); break;
     584                 :          0 :     case I_ILLUMINATE: i_illuminate(o); break;
     585                 :          0 :     case I_DEFLECT: i_deflect(o); break;
     586                 :            : 
     587                 :            :     /* potion functions */
     588                 :          0 :     case I_HEAL: i_heal(o); break;
     589                 :          0 :     case I_OBJDET: i_objdet(o); break;
     590                 :          0 :     case I_MONDET: i_mondet(o); break;
     591                 :          0 :     case I_SLEEP_SELF: i_sleep_self(o); break;
     592                 :          0 :     case I_NEUTRALIZE_POISON: i_neutralize_poison(o); break;
     593                 :          0 :     case I_RESTORE: i_restore(o); break;
     594                 :          0 :     case I_SPEED: i_speed(o); break;
     595                 :          0 :     case I_AZOTH: i_azoth(o); break;
     596                 :          0 :     case I_AUGMENT: i_augment(o); break;
     597                 :          0 :     case I_REGENERATE: i_regenerate(o); break;
     598                 :          0 :     case I_INVISIBLE: i_invisible(o); break;
     599                 :          0 :     case I_BREATHING: i_breathing(o); break;
     600                 :          0 :     case I_FEAR_RESIST: i_fear_resist(o); break;
     601                 :          0 :     case I_CHAOS: i_chaos(o); break;
     602                 :          0 :     case I_ACCURACY: i_accuracy(o); break;
     603                 :          0 :     case I_LEVITATION: i_levitate(o); break;
     604                 :          0 :     case I_CURE: i_cure(o); break;
     605                 :            :             
     606                 :            :     /* stick functions */
     607                 :          0 :     case I_FIREBOLT: i_firebolt(o); break;
     608                 :          0 :     case I_LBOLT: i_lbolt(o); break;
     609                 :          0 :     case I_MISSILE: i_missile(o); break;
     610                 :          0 :     case I_SLEEP_OTHER: i_sleep_other(o); break;
     611                 :          0 :     case I_FIREBALL: i_fireball(o); break;
     612                 :          0 :     case I_LBALL: i_lball(o); break;    
     613                 :          0 :     case I_SNOWBALL: i_snowball(o); break;
     614                 :          0 :     case I_SUMMON: i_summon(o); break;
     615                 :          0 :     case I_HIDE: i_hide(o); break;
     616                 :          0 :     case I_DISRUPT: i_disrupt(o); break;
     617                 :          0 :     case I_DISINTEGRATE: i_disintegrate(o); break;
     618                 :          0 :     case I_APPORT: i_apport(o); break;
     619                 :          0 :     case I_DISPEL: i_dispel(o); break;
     620                 :          0 :     case I_POLYMORPH: i_polymorph(o); break;
     621                 :          0 :     case I_FEAR:i_fear(o); break;
     622                 :            : 
     623                 :            :     /* food functions */
     624                 :          1 :     case I_FOOD: i_food(o); break;
     625                 :          1 :     case I_LEMBAS: i_lembas(o); break;
     626                 :          0 :     case I_STIM: i_stim(o); break;
     627                 :          0 :     case I_POW: i_pow(o); break;
     628                 :          0 :     case I_IMMUNE: i_immune(o); break;
     629                 :          0 :     case I_POISON_FOOD: i_poison_food(o); break;
     630                 :          0 :     case I_CORPSE: i_corpse(o); break;
     631                 :          0 :     case I_PEPPER_FOOD: i_pepper_food(o); break;
     632                 :            : 
     633                 :            :     /* boots functions */
     634                 :          0 :     case I_PERM_SPEED: i_perm_speed(o); break;
     635                 :          0 :     case I_PERM_HERO: i_perm_hero(o); break;
     636                 :          0 :     case I_PERM_LEVITATE: i_perm_levitate(o); break;
     637                 :          0 :     case I_PERM_AGILITY: i_perm_agility(o); break;
     638                 :            :       
     639                 :            :     /* artifact functions */
     640                 :          0 :     case I_SCEPTRE:i_sceptre(o);break;
     641                 :          0 :     case I_PLANES:i_planes(o);break;
     642                 :          0 :     case I_SERENITY:i_serenity(o);break;
     643                 :          0 :     case I_STARGEM:i_stargem(o);break;
     644                 :          0 :     case I_SYMBOL:i_symbol(o); break;
     645                 :          0 :     case I_ORBMASTERY: i_orbmastery(o); break;
     646                 :          0 :     case I_ORBFIRE: i_orbfire(o); break;
     647                 :          0 :     case I_ORBWATER: i_orbwater(o); break;
     648                 :          0 :     case I_ORBEARTH: i_orbearth(o); break;
     649                 :          0 :     case I_ORBAIR: i_orbair(o); break;
     650                 :          0 :     case I_ORBDEAD: i_orbdead(o); break;
     651                 :          0 :     case I_CRYSTAL: i_crystal(o); break;
     652                 :          0 :     case I_LIFE: i_life(o); break;
     653                 :          0 :     case I_DEATH: i_death(o); break;
     654                 :          0 :     case I_ANTIOCH: i_antioch(o); break;
     655                 :          0 :     case I_HELM: i_helm(o); break;
     656                 :          0 :     case I_KOLWYNIA: i_kolwynia(o); break;
     657                 :          0 :     case I_ENCHANTMENT: i_enchantment(o); break;
     658                 :          0 :     case I_JUGGERNAUT: i_juggernaut(o); break;
     659                 :          0 :     case I_HOLDING: i_holding(o); break;
     660                 :            : 
     661                 :            :     /* cloak functions */
     662                 :          0 :     case I_PERM_DISPLACE: i_perm_displace(o); break;
     663                 :          0 :     case I_PERM_NEGIMMUNE: i_perm_negimmune(o); break;
     664                 :          0 :     case I_PERM_INVISIBLE: i_perm_invisible(o); break;
     665                 :          0 :     case I_PERM_PROTECTION: i_perm_protection(o);break;
     666                 :          0 :     case I_PERM_ACCURACY: i_perm_accuracy(o);break;
     667                 :          0 :     case I_PERM_TRUESIGHT: i_perm_truesight(o); break;
     668                 :            : 
     669                 :            :     /* ring functions */
     670                 :          0 :     case I_PERM_BURDEN: i_perm_burden(o); break;
     671                 :          0 :     case I_PERM_STRENGTH: i_perm_strength(o); break;
     672                 :          0 :     case I_PERM_GAZE_IMMUNE: i_perm_gaze_immune(o); break;
     673                 :          0 :     case I_PERM_FIRE_RESIST: i_perm_fire_resist(o); break;
     674                 :          0 :     case I_PERM_POISON_RESIST: i_perm_poison_resist(o); break;
     675                 :          0 :     case I_PERM_REGENERATE: i_perm_regenerate(o); break;
     676                 :          0 :     case I_PERM_KNOWLEDGE: i_perm_knowledge(o); break;
     677                 :            : 
     678                 :            :     /* armor functions */
     679                 :          0 :     case I_NORMAL_ARMOR: i_normal_armor(o); break;
     680                 :          0 :     case I_PERM_FEAR_RESIST: i_perm_fear_resist(o); break;
     681                 :          0 :     case I_PERM_ENERGY_RESIST: i_perm_energy_resist(o); break;
     682                 :          0 :     case I_PERM_BREATHING: i_perm_breathing(o); break;
     683                 :            : 
     684                 :            :     /* weapons functions */
     685                 :          0 :     case I_NORMAL_WEAPON: i_normal_weapon(o); break;
     686                 :          0 :     case I_LIGHTSABRE: i_lightsabre(o); break;
     687                 :          0 :     case I_DEMONBLADE: i_demonblade(o); break;
     688                 :          0 :     case I_DESECRATE: i_desecrate(o); break;
     689                 :          0 :     case I_MACE_DISRUPT: i_mace_disrupt(o); break;
     690                 :          0 :     case I_DEFEND: i_defend(o); break;
     691                 :          0 :     case I_VICTRIX: i_victrix(o); break;
     692                 :            : 
     693                 :            :     /* thing functions */           
     694                 :          0 :     case I_PICK: i_pick(o); break;
     695                 :          0 :     case I_KEY: i_key(o); break;
     696                 :          0 :     case I_PERM_ILLUMINATE: i_perm_illuminate(o); break;
     697                 :          0 :     case I_TRAP: i_trap(o); break;
     698                 :          0 :     case I_RAISE_PORTCULLIS:i_raise_portcullis(o); break;
     699                 :            : 
     700                 :            :     /* shield functions */
     701                 :          0 :     case I_NORMAL_SHIELD: i_normal_shield(o); break;
     702                 :          0 :     case I_PERM_DEFLECT: i_perm_deflect(o); break;
     703                 :            : #ifdef DEBUG /* WDT: good idea, DG.  I'll be using this often, I predict! */
     704                 :            :     /* looking for objects without, or with unimplemented, functions */
     705                 :            :     default:
     706                 :            :        fprintf(DG_debug_log, "tried to use a %s with o->usef %d\n",
     707                 :            :                itemid(o), o->usef); 
     708                 :            :        break;
     709                 :            : #endif
     710                 :            :   }
     711                 :          2 : }
     712                 :            : 

Generated by: LCOV version 1.11