]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.u_init.c
1 /* $NetBSD: hack.u_init.c,v 1.5 1997/10/19 16:59:19 christos Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.u_init.c,v 1.5 1997/10/19 16:59:19 christos Exp $");
18 #define Strcpy (void) strcpy
19 #define Strcat (void) strcat
21 #define UNDEF_SPE '\177'
24 char pl_character
[PL_CSIZ
];
25 char *(roles
[]) = { /* must all have distinct first letter */
26 /* roles[4] may be changed to -woman */
27 "Tourist", "Speleologist", "Fighter", "Knight",
30 #define NR_OF_ROLES SIZE(roles)
31 char rolesyms
[NR_OF_ROLES
+ 1]; /* filled by u_init() */
42 struct trobj Extra_objs
[] = {
48 struct trobj Cave_man
[] = {
49 {MACE
, 1, WEAPON_SYM
, 1, 1},
50 {BOW
, 1, WEAPON_SYM
, 1, 1},
51 {ARROW
, 0, WEAPON_SYM
, 25, 1}, /* quan is variable */
52 {LEATHER_ARMOR
, 0, ARMOR_SYM
, 1, 1},
56 struct trobj Fighter
[] = {
57 {TWO_HANDED_SWORD
, 0, WEAPON_SYM
, 1, 1},
58 {RING_MAIL
, 0, ARMOR_SYM
, 1, 1},
62 struct trobj Knight
[] = {
63 {LONG_SWORD
, 0, WEAPON_SYM
, 1, 1},
64 {SPEAR
, 2, WEAPON_SYM
, 1, 1},
65 {RING_MAIL
, 1, ARMOR_SYM
, 1, 1},
66 {HELMET
, 0, ARMOR_SYM
, 1, 1},
67 {SHIELD
, 0, ARMOR_SYM
, 1, 1},
68 {PAIR_OF_GLOVES
, 0, ARMOR_SYM
, 1, 1},
72 struct trobj Speleologist
[] = {
73 {STUDDED_LEATHER_ARMOR
, 0, ARMOR_SYM
, 1, 1},
74 {UNDEF_TYP
, 0, POTION_SYM
, 2, 0},
75 {FOOD_RATION
, 0, FOOD_SYM
, 3, 1},
76 {PICK_AXE
, UNDEF_SPE
, TOOL_SYM
, 1, 0},
77 {ICE_BOX
, 0, TOOL_SYM
, 1, 0},
81 struct trobj Tinopener
[] = {
82 {CAN_OPENER
, 0, TOOL_SYM
, 1, 1},
86 struct trobj Tourist
[] = {
87 {UNDEF_TYP
, 0, FOOD_SYM
, 10, 1},
88 {POT_EXTRA_HEALING
, 0, POTION_SYM
, 2, 0},
89 {EXPENSIVE_CAMERA
, 0, TOOL_SYM
, 1, 1},
90 {DART
, 2, WEAPON_SYM
, 25, 1}, /* quan is variable */
94 struct trobj Wizard
[] = {
95 {ELVEN_CLOAK
, 0, ARMOR_SYM
, 1, 1},
96 {UNDEF_TYP
, UNDEF_SPE
, WAND_SYM
, 2, 0},
97 {UNDEF_TYP
, UNDEF_SPE
, RING_SYM
, 2, 0},
98 {UNDEF_TYP
, UNDEF_SPE
, POTION_SYM
, 2, 0},
99 {UNDEF_TYP
, UNDEF_SPE
, SCROLL_SYM
, 3, 0},
107 char exper
= 'y', pc
;
108 if (flags
.female
) /* should have been set in HACKOPTIONS */
109 roles
[4] = "Cave-woman";
110 for (i
= 0; i
< NR_OF_ROLES
; i
++)
111 rolesyms
[i
] = roles
[i
][0];
114 if ((pc
= pl_character
[0]) != '\0') {
117 if ((i
= role_index(pc
)) >= 0)
118 goto got_suffix
; /* implies experienced */
119 printf("\nUnknown role: %c\n", pc
);
120 pl_character
[0] = pc
= 0;
122 printf("\nAre you an experienced player? [ny] ");
124 while (!strchr("ynYN \n\004", (exper
= readchar())))
126 if (exper
== '\004') /* Give him an opportunity to get out */
128 printf("%c\n", exper
); /* echo */
129 if (strchr("Nn \n", exper
)) {
133 printf("\nTell me what kind of character you are:\n");
135 for (i
= 0; i
< NR_OF_ROLES
; i
++) {
136 printf(" a %s", roles
[i
]);
139 else if (i
< NR_OF_ROLES
- 2)
141 else if (i
== NR_OF_ROLES
- 2)
144 printf("? [%s] ", rolesyms
);
146 while ((pc
= readchar()) != '\0') {
149 if ((i
= role_index(pc
)) >= 0) {
150 printf("%c\n", pc
); /* echo */
151 (void) fflush(stdout
); /* should be seen */
156 if (pc
== '\004') /* Give him the opportunity to get
166 printf("\nI'll choose a character for you.\n");
167 i
= rn2(NR_OF_ROLES
);
169 printf("This game you will be a%s %s.\n",
170 exper
? "n experienced" : "",
173 /* give him some feedback in case mklev takes much time */
174 (void) putchar('\n');
175 (void) fflush(stdout
);
179 * Given the above code, I can't see why this would ever change
180 * anything; it does core pretty well, though. - cmh 4/20/93
189 (void) strncpy(pl_character
, roles
[i
], PL_CSIZ
- 1);
190 pl_character
[PL_CSIZ
- 1] = 0;
199 uarm
= uarm2
= uarmh
= uarms
= uarmg
= uwep
= uball
= uchain
=
205 Cave_man
[2].trquan
= 12 + rnd(9) * rnd(9);
206 u
.uhp
= u
.uhpmax
= 16;
207 u
.ustr
= u
.ustrmax
= 18;
212 Tourist
[3].trquan
= 20 + rnd(20);
213 u
.ugold
= u
.ugold0
= rnd(1000);
214 u
.uhp
= u
.uhpmax
= 10;
215 u
.ustr
= u
.ustrmax
= 8;
222 for (i
= 1; i
<= 4; i
++)
224 Wizard
[i
].trquan
+= rn2(3) - 1;
225 u
.uhp
= u
.uhpmax
= 15;
226 u
.ustr
= u
.ustrmax
= 16;
233 u
.uhp
= u
.uhpmax
= 12;
234 u
.ustr
= u
.ustrmax
= 10;
235 ini_inv(Speleologist
);
241 u
.uhp
= u
.uhpmax
= 12;
242 u
.ustr
= u
.ustrmax
= 10;
247 u
.uhp
= u
.uhpmax
= 14;
248 u
.ustr
= u
.ustrmax
= 17;
251 default: /* impossible */
252 u
.uhp
= u
.uhpmax
= 12;
253 u
.ustr
= u
.ustrmax
= 16;
257 int d
= rn2(7) - 2; /* biased variation */
266 /* make sure he can carry all he has - especially for T's */
267 while (inv_weight() > 0 && u
.ustr
< 118)
268 u
.ustr
++, u
.ustrmax
++;
276 while (trop
->trolet
) {
277 obj
= mkobj(trop
->trolet
);
278 obj
->known
= trop
->trknown
;
279 /* not obj->dknown = 1; - let him look at it at least once */
281 if (obj
->olet
== WEAPON_SYM
) {
282 obj
->quan
= trop
->trquan
;
285 if (trop
->trspe
!= UNDEF_SPE
)
286 obj
->spe
= trop
->trspe
;
287 if (trop
->trotyp
!= UNDEF_TYP
)
288 obj
->otyp
= trop
->trotyp
;
289 else if (obj
->otyp
== WAN_WISHING
) /* gitpyr!robert */
290 obj
->otyp
= WAN_DEATH
;
291 obj
->owt
= weight(obj
); /* defined after setting otyp+quan */
293 if (obj
->olet
== ARMOR_SYM
) {
297 setworn(obj
, W_ARMS
);
301 setworn(obj
, W_ARMH
);
305 setworn(obj
, W_ARMG
);
316 if (obj
->olet
== WEAPON_SYM
)
321 continue; /* make a similar object */
323 if (trop
->trquan
) { /* check if zero first */
326 continue; /* make a similar object */
328 #endif /* PYRAMID_BUG */
337 struct trobj
*trop
= &Extra_objs
[0];
338 char *ep
= getenv("INVENT");
342 ep
= strchr(ep
, ',');
344 while (*ep
== ',' || *ep
== ' ')
346 if (type
<= 0 || type
> NROFOBJECTS
)
349 trop
->trolet
= objects
[type
].oc_olet
;
355 /* give him a wand of wishing by default */
356 trop
->trotyp
= WAN_WISHING
;
357 trop
->trolet
= WAND_SYM
;
369 if ((p
= strrchr(plname
, '-')) != NULL
) {
371 pl_character
[0] = p
[1];
383 { /* must be called only from u_init() */
384 /* so that rolesyms[] is defined */
387 if ((cp
= strchr(rolesyms
, pc
)) != NULL
)
388 return (cp
- rolesyms
);