kernel/acpi: Match _HID instead of relying on _CID for PCIe.
[dragonfly.git] / games / hack / hack.mkobj.c
blobcf44d1a75947b1ced6f95c52d988b5b80f543fb2
1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.mkobj.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.mkobj.c,v 1.5 1999/11/16 10:26:37 marcel Exp $ */
4 /* $DragonFly: src/games/hack/hack.mkobj.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */
6 #include "hack.h"
8 char mkobjstr[] = "))[[!!!!????%%%%/=**))[[!!!!????%%%%/=**(%";
10 struct obj *
11 mkobj_at(int let, int x, int y)
13 struct obj *otmp = mkobj(let);
15 otmp->ox = x;
16 otmp->oy = y;
17 otmp->nobj = fobj;
18 fobj = otmp;
19 return (otmp);
22 void
23 mksobj_at(int otyp, int x, int y)
25 struct obj *otmp = mksobj(otyp);
27 otmp->ox = x;
28 otmp->oy = y;
29 otmp->nobj = fobj;
30 fobj = otmp;
33 struct obj *
34 mkobj(int let)
36 if (!let)
37 let = mkobjstr[rn2(sizeof(mkobjstr) - 1)];
38 return (
39 mksobj(
40 letter(let) ?
41 CORPSE +
42 ((let > 'Z') ? (let - 'a' + 'Z' - '@' +
43 1) : (let - '@'))
44 : probtype(let)
49 struct obj zeroobj;
51 struct obj *
52 mksobj(int otyp)
54 struct obj *otmp;
55 char let = objects[otyp].oc_olet;
57 otmp = newobj(0);
58 *otmp = zeroobj;
59 otmp->age = moves;
60 otmp->o_id = flags.ident++;
61 otmp->quan = 1;
62 otmp->olet = let;
63 otmp->otyp = otyp;
64 otmp->dknown = strchr("/=!?*", let) ? 0 : 1;
65 switch (let) {
66 case WEAPON_SYM:
67 otmp->quan = (otmp->otyp <= ROCK) ? rn1(6, 6) : 1;
68 if (!rn2(11))
69 otmp->spe = rnd(3);
70 else if (!rn2(10)) {
71 otmp->cursed = 1;
72 otmp->spe = -rnd(3);
74 break;
75 case FOOD_SYM:
76 if (otmp->otyp >= CORPSE)
77 break;
78 #ifdef NOT_YET_IMPLEMENTED
79 /* if tins are to be identified, need to adapt doname() etc */
80 if (otmp->otyp == TIN)
81 otmp->spe = rnd(...);
82 #endif /* NOT_YET_IMPLEMENTED */
83 /* fall into next case */
84 case GEM_SYM:
85 otmp->quan = rn2(6) ? 1 : 2;
86 case TOOL_SYM:
87 case CHAIN_SYM:
88 case BALL_SYM:
89 case ROCK_SYM:
90 case POTION_SYM:
91 case SCROLL_SYM:
92 case AMULET_SYM:
93 break;
94 case ARMOR_SYM:
95 if (!rn2(8))
96 otmp->cursed = 1;
97 if (!rn2(10))
98 otmp->spe = rnd(3);
99 else if (!rn2(9)) {
100 otmp->spe = -rnd(3);
101 otmp->cursed = 1;
103 break;
104 case WAND_SYM:
105 if (otmp->otyp == WAN_WISHING)
106 otmp->spe = 3;
107 else
108 otmp->spe = rn1(5,
109 (objects[otmp->otyp].bits & NODIR) ? 11 : 4);
110 break;
111 case RING_SYM:
112 if (objects[otmp->otyp].bits & SPEC) {
113 if (!rn2(3)) {
114 otmp->cursed = 1;
115 otmp->spe = -rnd(2);
116 } else
117 otmp->spe = rnd(2);
118 } else if (otmp->otyp == RIN_TELEPORTATION ||
119 otmp->otyp == RIN_AGGRAVATE_MONSTER ||
120 otmp->otyp == RIN_HUNGER || !rn2(9))
121 otmp->cursed = 1;
122 break;
123 default:
124 panic("impossible mkobj");
126 otmp->owt = weight(otmp);
127 return (otmp);
130 bool
131 letter(char c)
133 return (('@' <= c && c <= 'Z') || ('a' <= c && c <= 'z'));
137 weight(struct obj *obj)
139 int wt = objects[obj->otyp].oc_weight;
140 return (wt ? wt * obj->quan : (obj->quan + 1) / 2);
143 void
144 mkgold(long num, int x, int y)
146 struct gold *gold;
147 long amount = (num ? num : 1 + (rnd(dlevel + 2) * rnd(30)));
149 if ((gold = g_at(x, y)) != NULL)
150 gold->amount += amount;
151 else {
152 gold = newgold();
153 gold->ngold = fgold;
154 gold->gx = x;
155 gold->gy = y;
156 gold->amount = amount;
157 fgold = gold;
158 /* do sth with display? */