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
mkobj
defined in line
31; used 4 times
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
Defined variables