# 2.11BSD#431 - /usr/src/games/hack/hack.mkobj.c

##### Functions

    letter            X
    mkgold            X
    mkobj             X
    mkobj_at          X
    mksobj            X
    mksobj_at         X
    weight            X

##### Variables

    mkobjstr          X
    zeroobj           X

       1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
       2: /* hack.mkobj.c - version 1.0.3 */
       3:
       4: #include "hack.h"
       5:
       6: char mkobjstr[] = "))[[!!!!????%%%%/=**))[[!!!!????%%%%/=**(%";
       7: struct obj *mkobj(), *mksobj();
       8:
       9: struct obj *
      10: mkobj_at(let,x,y)
      11: register let,x,y;
      12: {
      13:     register struct obj *otmp = mkobj(let);
      14:     otmp->ox = x;
      15:     otmp->oy = y;
      16:     otmp->nobj = fobj;
      17:     fobj = otmp;
      18:     return(otmp);
      19: }
      20:
      21: mksobj_at(otyp,x,y)
      22: register otyp,x,y;
      23: {
      24:     register struct obj *otmp = mksobj(otyp);
      25:     otmp->ox = x;
      26:     otmp->oy = y;
      27:     otmp->nobj = fobj;
      28:     fobj = otmp;
      29: }
      30:
      31: struct obj *
      32: mkobj(let) {
      33:     if(!let)
      34:         let = mkobjstr[rn2(sizeof(mkobjstr) - 1)];
      35:     return(
      36:         mksobj(
      37:         letter(let) ?
      38:             CORPSE + ((let > 'Z') ? (let-'a'+'Z'-'@'+1) : (let-'@'))
      39:         :   probtype(let)
      40:         )
      41:     );
      42: }
      43:
      44:
      45: struct obj zeroobj;
      46:
      47: struct obj *
      48: mksobj(otyp)
      49: register otyp;
      50: {
      51:     register struct obj *otmp;
      52:     char let = objects[otyp].oc_olet;
      53:
      54:     otmp = newobj(0);
      55:     *otmp = zeroobj;
      56:     otmp->age = moves;
      57:     otmp->o_id = flags.ident++;
      58:     otmp->quan = 1;
      59:     otmp->olet = let;
      60:     otmp->otyp = otyp;
      61:     otmp->dknown = index("/=!?*", let) ? 0 : 1;
      62:     switch(let) {
      63:     case WEAPON_SYM:
      64:         otmp->quan = (otmp->otyp <= ROCK) ? rn1(6,6) : 1;
      65:         if(!rn2(11)) otmp->spe = rnd(3);
      66:         else if(!rn2(10)) {
      67:             otmp->cursed = 1;
      68:             otmp->spe = -rnd(3);
      69:         }
      70:         break;
      71:     case FOOD_SYM:
      72:         if(otmp->otyp >= CORPSE) break;
      73: #ifdef NOT_YET_IMPLEMENTED
      74:         /* if tins are to be identified, need to adapt doname() etc */
      75:         if(otmp->otyp == TIN)
      76:             otmp->spe = rnd(...);
      77: #endif NOT_YET_IMPLEMENTED
      78:         /* fall into next case */
      79:     case GEM_SYM:
      80:         otmp->quan = rn2(6) ? 1 : 2;
      81:     case TOOL_SYM:
      82:     case CHAIN_SYM:
      83:     case BALL_SYM:
      84:     case ROCK_SYM:
      85:     case POTION_SYM:
      86:     case SCROLL_SYM:
      87:     case AMULET_SYM:
      88:         break;
      89:     case ARMOR_SYM:
      90:         if(!rn2(8)) otmp->cursed = 1;
      91:         if(!rn2(10)) otmp->spe = rnd(3);
      92:         else if(!rn2(9)) {
      93:             otmp->spe = -rnd(3);
      94:             otmp->cursed = 1;
      95:         }
      96:         break;
      97:     case WAND_SYM:
      98:         if(otmp->otyp == WAN_WISHING) otmp->spe = 3; else
      99:         otmp->spe = rn1(5,
     100:             (objects[otmp->otyp].bits & NODIR) ? 11 : 4);
     101:         break;
     102:     case RING_SYM:
     103:         if(objects[otmp->otyp].bits & SPEC) {
     104:             if(!rn2(3)) {
     105:                 otmp->cursed = 1;
     106:                 otmp->spe = -rnd(2);
     107:             } else otmp->spe = rnd(2);
     108:         } else if(otmp->otyp == RIN_TELEPORTATION ||
     109:               otmp->otyp == RIN_AGGRAVATE_MONSTER ||
     110:               otmp->otyp == RIN_HUNGER || !rn2(9))
     111:             otmp->cursed = 1;
     112:         break;
     113:     default:
     114:         panic("impossible mkobj");
     115:     }
     116:     otmp->owt = weight(otmp);
     117:     return(otmp);
     118: }
     119:
     120: letter(c) {
     121:     return(('@' <= c && c <= 'Z') || ('a' <= c && c <= 'z'));
     122: }
     123:
     124: weight(obj)
     125: register struct obj *obj;
     126: {
     127: /* KLUDGE -- our C chokes on the return below if `wt' is register */
     128: /* register */ int wt = objects[obj->otyp].oc_weight;
     129:     return(wt ? wt*obj->quan : (obj->quan + 1)/2);
     130: }
     131:
     132: mkgold(num,x,y)
     133: register long num;
     134: {
     135:     register struct gold *gold;
     136:     register long amount = (num ? num : 1 + (rnd(dlevel+2) * rnd(30)));
     137:
     138:     if(gold = g_at(x,y))
     139:         gold->amount += amount;
     140:     else {
     141:         gold = newgold();
     142:         gold->ngold = fgold;
     143:         gold->gx = x;
     144:         gold->gy = y;
     145:         gold->amount = amount;
     146:         fgold = gold;
     147:         /* do sth with display? */
     148:     }
     149: }

#### Defined functions

letter defined in line 120; used 1 times

- in line 37

mkgold defined in line 132; used 7 times

- in /usr/src/games/hack/hack.bones.c line 47
- in /usr/src/games/hack/hack.do.c line 32
- in /usr/src/games/hack/hack.mklev.c line 91, 117
- in /usr/src/games/hack/hack.mkmaze.c line 79
- in /usr/src/games/hack/hack.mkshop.c line 179
- in /usr/src/games/hack/hack.steal.c line 199

mkobj defined in line 31; used 4 times

- in line 7, 13
- in /usr/src/games/hack/hack.u_init.c line 254-256(2)

mkobj_at defined in line 9; used 23 times

- in /usr/src/games/hack/hack.fight.c line 7, 73
- in /usr/src/games/hack/hack.makemon.c line 7, 78
- in /usr/src/games/hack/hack.mklev.c line 7, 93, 100, 532, 654
- in /usr/src/games/hack/hack.mkmaze.c line 8, 34, 49, 65-69(2)
- in /usr/src/games/hack/hack.mkshop.c line 10, 132
- in /usr/src/games/hack/hack.mon.c line 8, 759
- in /usr/src/games/hack/hack.read.c line 7, 419-420(2)
- in /usr/src/games/hack/hack.zap.c line 6, 82

mksobj defined in line 47; used 7 times

- in line 7, 24, 36
- in /usr/src/games/hack/hack.objnam.c line 517-519(2)
- in /usr/src/games/hack/hack.unix.c line 327-331(2)

mksobj_at defined in line 21; used 12 times

- in /usr/src/games/hack/hack.fight.c line 87-89(2)
- in /usr/src/games/hack/hack.mklev.c line 653
- in /usr/src/games/hack/hack.mkmaze.c line 48
- in /usr/src/games/hack/hack.mkshop.c line 184-189(2)
- in /usr/src/games/hack/hack.mon.c line 744, 750
- in /usr/src/games/hack/hack.trap.c line 74, 83, 106
- in /usr/src/games/hack/hack.zap.c line 204

weight defined in line 124; used 7 times

- in line 116
- in /usr/src/games/hack/hack.c line 415
- in /usr/src/games/hack/hack.do.c line 451-453(2)
- in /usr/src/games/hack/hack.invent.c line 100
- in /usr/src/games/hack/hack.u_init.c line 271
- in /usr/src/games/hack/hack.zap.c line 617

#### Defined variables

mkobjstr defined in line 6; used 2 times

- in line 34(2)

zeroobj defined in line 45; used 4 times

- in line 55
- in /usr/src/games/hack/hack.engrave.c line 142
- in /usr/src/games/hack/hack.invent.c line 381
- in /usr/src/games/hack/hack.wield.c line 23

Last modified: 1985-10-01 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 774 |