]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.u_init.c
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
6 static char rcsid
[] = "$NetBSD: hack.u_init.c,v 1.4 1995/03/23 08:31:51 cgd Exp $";
12 #define Strcpy (void) strcpy
13 #define Strcat (void) strcat
15 #define UNDEF_SPE '\177'
16 extern struct obj
*addinv();
21 char pl_character
[PL_CSIZ
];
22 char *(roles
[]) = { /* must all have distinct first letter */
23 /* roles[4] may be changed to -woman */
24 "Tourist", "Speleologist", "Fighter", "Knight",
27 #define NR_OF_ROLES SIZE(roles)
28 char rolesyms
[NR_OF_ROLES
+ 1]; /* filled by u_init() */
39 struct trobj Extra_objs
[] = {
45 struct trobj Cave_man
[] = {
46 { MACE
, 1, WEAPON_SYM
, 1, 1 },
47 { BOW
, 1, WEAPON_SYM
, 1, 1 },
48 { ARROW
, 0, WEAPON_SYM
, 25, 1 }, /* quan is variable */
49 { LEATHER_ARMOR
, 0, ARMOR_SYM
, 1, 1 },
53 struct trobj Fighter
[] = {
54 { TWO_HANDED_SWORD
, 0, WEAPON_SYM
, 1, 1 },
55 { RING_MAIL
, 0, ARMOR_SYM
, 1, 1 },
59 struct trobj Knight
[] = {
60 { LONG_SWORD
, 0, WEAPON_SYM
, 1, 1 },
61 { SPEAR
, 2, WEAPON_SYM
, 1, 1 },
62 { RING_MAIL
, 1, ARMOR_SYM
, 1, 1 },
63 { HELMET
, 0, ARMOR_SYM
, 1, 1 },
64 { SHIELD
, 0, ARMOR_SYM
, 1, 1 },
65 { PAIR_OF_GLOVES
, 0, ARMOR_SYM
, 1, 1 },
69 struct trobj Speleologist
[] = {
70 { STUDDED_LEATHER_ARMOR
, 0, ARMOR_SYM
, 1, 1 },
71 { UNDEF_TYP
, 0, POTION_SYM
, 2, 0 },
72 { FOOD_RATION
, 0, FOOD_SYM
, 3, 1 },
73 { PICK_AXE
, UNDEF_SPE
, TOOL_SYM
, 1, 0 },
74 { ICE_BOX
, 0, TOOL_SYM
, 1, 0 },
78 struct trobj Tinopener
[] = {
79 { CAN_OPENER
, 0, TOOL_SYM
, 1, 1 },
83 struct trobj Tourist
[] = {
84 { UNDEF_TYP
, 0, FOOD_SYM
, 10, 1 },
85 { POT_EXTRA_HEALING
, 0, POTION_SYM
, 2, 0 },
86 { EXPENSIVE_CAMERA
, 0, TOOL_SYM
, 1, 1 },
87 { DART
, 2, WEAPON_SYM
, 25, 1 }, /* quan is variable */
91 struct trobj Wizard
[] = {
92 { ELVEN_CLOAK
, 0, ARMOR_SYM
, 1, 1 },
93 { UNDEF_TYP
, UNDEF_SPE
, WAND_SYM
, 2, 0 },
94 { UNDEF_TYP
, UNDEF_SPE
, RING_SYM
, 2, 0 },
95 { UNDEF_TYP
, UNDEF_SPE
, POTION_SYM
, 2, 0 },
96 { UNDEF_TYP
, UNDEF_SPE
, SCROLL_SYM
, 3, 0 },
102 char exper
= 'y', pc
;
103 extern char readchar();
104 if(flags
.female
) /* should have been set in HACKOPTIONS */
105 roles
[4] = "Cave-woman";
106 for(i
= 0; i
< NR_OF_ROLES
; i
++)
107 rolesyms
[i
] = roles
[i
][0];
110 if(pc
= pl_character
[0]) {
111 if(islower(pc
)) pc
= toupper(pc
);
112 if((i
= role_index(pc
)) >= 0)
113 goto got_suffix
; /* implies experienced */
114 printf("\nUnknown role: %c\n", pc
);
115 pl_character
[0] = pc
= 0;
118 printf("\nAre you an experienced player? [ny] ");
120 while(!index("ynYN \n\004", (exper
= readchar())))
122 if(exper
== '\004') /* Give him an opportunity to get out */
124 printf("%c\n", exper
); /* echo */
125 if(index("Nn \n", exper
)) {
130 printf("\nTell me what kind of character you are:\n");
132 for(i
= 0; i
< NR_OF_ROLES
; i
++) {
133 printf(" a %s", roles
[i
]);
136 else if(i
< NR_OF_ROLES
- 2)
138 else if(i
== NR_OF_ROLES
- 2)
141 printf("? [%s] ", rolesyms
);
143 while(pc
= readchar()) {
144 if(islower(pc
)) pc
= toupper(pc
);
145 if((i
= role_index(pc
)) >= 0) {
146 printf("%c\n", pc
); /* echo */
147 (void) fflush(stdout
); /* should be seen */
152 if(pc
== '\004') /* Give him the opportunity to get out */
161 printf("\nI'll choose a character for you.\n");
162 i
= rn2(NR_OF_ROLES
);
164 printf("This game you will be a%s %s.\n",
165 exper
? "n experienced" : "",
168 /* give him some feedback in case mklev takes much time */
169 (void) putchar('\n');
170 (void) fflush(stdout
);
173 /* Given the above code, I can't see why this would ever change
174 anything; it does core pretty well, though. - cmh 4/20/93 */
182 (void) strncpy(pl_character
, roles
[i
], PL_CSIZ
-1);
183 pl_character
[PL_CSIZ
-1] = 0;
192 uarm
= uarm2
= uarmh
= uarms
= uarmg
= uwep
= uball
= uchain
=
198 Cave_man
[2].trquan
= 12 + rnd(9)*rnd(9);
199 u
.uhp
= u
.uhpmax
= 16;
200 u
.ustr
= u
.ustrmax
= 18;
205 Tourist
[3].trquan
= 20 + rnd(20);
206 u
.ugold
= u
.ugold0
= rnd(1000);
207 u
.uhp
= u
.uhpmax
= 10;
208 u
.ustr
= u
.ustrmax
= 8;
210 if(!rn2(25)) ini_inv(Tinopener
);
214 for(i
=1; i
<=4; i
++) if(!rn2(5))
215 Wizard
[i
].trquan
+= rn2(3) - 1;
216 u
.uhp
= u
.uhpmax
= 15;
217 u
.ustr
= u
.ustrmax
= 16;
224 u
.uhp
= u
.uhpmax
= 12;
225 u
.ustr
= u
.ustrmax
= 10;
226 ini_inv(Speleologist
);
227 if(!rn2(10)) ini_inv(Tinopener
);
231 u
.uhp
= u
.uhpmax
= 12;
232 u
.ustr
= u
.ustrmax
= 10;
237 u
.uhp
= u
.uhpmax
= 14;
238 u
.ustr
= u
.ustrmax
= 17;
241 default: /* impossible */
242 u
.uhp
= u
.uhpmax
= 12;
243 u
.ustr
= u
.ustrmax
= 16;
247 register int d
= rn2(7) - 2; /* biased variation */
253 if(wizard
) wiz_inv();
256 /* make sure he can carry all he has - especially for T's */
257 while(inv_weight() > 0 && u
.ustr
< 118)
258 u
.ustr
++, u
.ustrmax
++;
261 ini_inv(trop
) register struct trobj
*trop
; {
262 register struct obj
*obj
;
263 extern struct obj
*mkobj();
264 while(trop
->trolet
) {
265 obj
= mkobj(trop
->trolet
);
266 obj
->known
= trop
->trknown
;
267 /* not obj->dknown = 1; - let him look at it at least once */
269 if(obj
->olet
== WEAPON_SYM
){
270 obj
->quan
= trop
->trquan
;
273 if(trop
->trspe
!= UNDEF_SPE
)
274 obj
->spe
= trop
->trspe
;
275 if(trop
->trotyp
!= UNDEF_TYP
)
276 obj
->otyp
= trop
->trotyp
;
278 if(obj
->otyp
== WAN_WISHING
) /* gitpyr!robert */
279 obj
->otyp
= WAN_DEATH
;
280 obj
->owt
= weight(obj
); /* defined after setting otyp+quan */
282 if(obj
->olet
== ARMOR_SYM
){
285 if(!uarms
) setworn(obj
, W_ARMS
);
288 if(!uarmh
) setworn(obj
, W_ARMH
);
291 if(!uarmg
) setworn(obj
, W_ARMG
);
298 if(!uarm
) setworn(obj
, W_ARM
);
301 if(obj
->olet
== WEAPON_SYM
)
302 if(!uwep
) setuwep(obj
);
304 if(--trop
->trquan
) continue; /* make a similar object */
306 if(trop
->trquan
) { /* check if zero first */
309 continue; /* make a similar object */
318 register struct trobj
*trop
= &Extra_objs
[0];
319 extern char *getenv();
320 register char *ep
= getenv("INVENT");
325 if(ep
) while(*ep
== ',' || *ep
== ' ') ep
++;
326 if(type
<= 0 || type
> NROFOBJECTS
) continue;
328 trop
->trolet
= objects
[type
].oc_olet
;
334 /* give him a wand of wishing by default */
335 trop
->trotyp
= WAN_WISHING
;
336 trop
->trolet
= WAND_SYM
;
346 if(p
= rindex(plname
, '-')) {
348 pl_character
[0] = p
[1];
359 { /* must be called only from u_init() */
360 /* so that rolesyms[] is defined */
363 if(cp
= index(rolesyms
, pc
))
364 return(cp
- rolesyms
);