]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.u_init.c
1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.u_init.c - version 1.0.3 */
7 #define Strcpy (void) strcpy
8 #define Strcat (void) strcat
10 #define UNDEF_SPE '\177'
11 extern struct obj
*addinv();
16 char pl_character
[PL_CSIZ
];
17 char *(roles
[]) = { /* must all have distinct first letter */
18 /* roles[4] may be changed to -man */
19 "Tourist", "Speleologist", "Fighter", "Knight",
22 #define NR_OF_ROLES SIZE(roles)
23 char rolesyms
[NR_OF_ROLES
+ 1]; /* filled by u_init() */
34 struct trobj Extra_objs
[] = {
40 struct trobj Cave_man
[] = {
41 { MACE
, 1, WEAPON_SYM
, 1, 1 },
42 { BOW
, 1, WEAPON_SYM
, 1, 1 },
43 { ARROW
, 0, WEAPON_SYM
, 25, 1 }, /* quan is variable */
44 { LEATHER_ARMOR
, 0, ARMOR_SYM
, 1, 1 },
48 struct trobj Fighter
[] = {
49 { TWO_HANDED_SWORD
, 0, WEAPON_SYM
, 1, 1 },
50 { RING_MAIL
, 0, ARMOR_SYM
, 1, 1 },
54 struct trobj Knight
[] = {
55 { LONG_SWORD
, 0, WEAPON_SYM
, 1, 1 },
56 { SPEAR
, 2, WEAPON_SYM
, 1, 1 },
57 { RING_MAIL
, 1, ARMOR_SYM
, 1, 1 },
58 { HELMET
, 0, ARMOR_SYM
, 1, 1 },
59 { SHIELD
, 0, ARMOR_SYM
, 1, 1 },
60 { PAIR_OF_GLOVES
, 0, ARMOR_SYM
, 1, 1 },
64 struct trobj Speleologist
[] = {
65 { STUDDED_LEATHER_ARMOR
, 0, ARMOR_SYM
, 1, 1 },
66 { UNDEF_TYP
, 0, POTION_SYM
, 2, 0 },
67 { FOOD_RATION
, 0, FOOD_SYM
, 3, 1 },
68 { PICK_AXE
, UNDEF_SPE
, TOOL_SYM
, 1, 0 },
69 { ICE_BOX
, 0, TOOL_SYM
, 1, 0 },
73 struct trobj Tinopener
[] = {
74 { CAN_OPENER
, 0, TOOL_SYM
, 1, 1 },
78 struct trobj Tourist
[] = {
79 { UNDEF_TYP
, 0, FOOD_SYM
, 10, 1 },
80 { POT_EXTRA_HEALING
, 0, POTION_SYM
, 2, 0 },
81 { EXPENSIVE_CAMERA
, 0, TOOL_SYM
, 1, 1 },
82 { DART
, 2, WEAPON_SYM
, 25, 1 }, /* quan is variable */
86 struct trobj Wizard
[] = {
87 { ELVEN_CLOAK
, 0, ARMOR_SYM
, 1, 1 },
88 { UNDEF_TYP
, UNDEF_SPE
, WAND_SYM
, 2, 0 },
89 { UNDEF_TYP
, UNDEF_SPE
, RING_SYM
, 2, 0 },
90 { UNDEF_TYP
, UNDEF_SPE
, POTION_SYM
, 2, 0 },
91 { UNDEF_TYP
, UNDEF_SPE
, SCROLL_SYM
, 3, 0 },
98 extern char readchar();
99 if(flags
.female
) /* should have been set in HACKOPTIONS */
100 roles
[4] = "Cave-woman";
101 for(i
= 0; i
< NR_OF_ROLES
; i
++)
102 rolesyms
[i
] = roles
[i
][0];
105 if(pc
= pl_character
[0]) {
106 if('a' <= pc
&& pc
<= 'z') pc
+= 'A'-'a';
107 if((i
= role_index(pc
)) >= 0)
108 goto got_suffix
; /* implies experienced */
109 printf("\nUnknown role: %c\n", pc
);
110 pl_character
[0] = pc
= 0;
113 printf("\nAre you an experienced player? [ny] ");
115 while(!index("ynYN \n\004", (exper
= readchar())))
117 if(exper
== '\004') /* Give him an opportunity to get out */
119 printf("%c\n", exper
); /* echo */
120 if(index("Nn \n", exper
)) {
125 printf("\nTell me what kind of character you are:\n");
127 for(i
= 0; i
< NR_OF_ROLES
; i
++) {
128 printf(" a %s", roles
[i
]);
131 else if(i
< NR_OF_ROLES
- 2)
133 else if(i
== NR_OF_ROLES
- 2)
136 printf("? [%s] ", rolesyms
);
138 while(pc
= readchar()) {
139 if('a' <= pc
&& pc
<= 'z') pc
+= 'A'-'a';
140 if((i
= role_index(pc
)) >= 0) {
141 printf("%c\n", pc
); /* echo */
142 (void) fflush(stdout
); /* should be seen */
147 if(pc
== '\004') /* Give him the opportunity to get out */
156 printf("\nI'll choose a character for you.\n");
157 i
= rn2(NR_OF_ROLES
);
159 printf("This game you will be a%s %s.\n",
160 exper
? "n experienced" : "",
163 /* give him some feedback in case mklev takes much time */
164 (void) putchar('\n');
165 (void) fflush(stdout
);
173 (void) strncpy(pl_character
, roles
[i
], PL_CSIZ
-1);
174 pl_character
[PL_CSIZ
-1] = 0;
183 uarm
= uarm2
= uarmh
= uarms
= uarmg
= uwep
= uball
= uchain
=
189 Cave_man
[2].trquan
= 12 + rnd(9)*rnd(9);
190 u
.uhp
= u
.uhpmax
= 16;
191 u
.ustr
= u
.ustrmax
= 18;
196 Tourist
[3].trquan
= 20 + rnd(20);
197 u
.ugold
= u
.ugold0
= rnd(1000);
198 u
.uhp
= u
.uhpmax
= 10;
199 u
.ustr
= u
.ustrmax
= 8;
201 if(!rn2(25)) ini_inv(Tinopener
);
205 for(i
=1; i
<=4; i
++) if(!rn2(5))
206 Wizard
[i
].trquan
+= rn2(3) - 1;
207 u
.uhp
= u
.uhpmax
= 15;
208 u
.ustr
= u
.ustrmax
= 16;
215 u
.uhp
= u
.uhpmax
= 12;
216 u
.ustr
= u
.ustrmax
= 10;
217 ini_inv(Speleologist
);
218 if(!rn2(10)) ini_inv(Tinopener
);
222 u
.uhp
= u
.uhpmax
= 12;
223 u
.ustr
= u
.ustrmax
= 10;
228 u
.uhp
= u
.uhpmax
= 14;
229 u
.ustr
= u
.ustrmax
= 17;
232 default: /* impossible */
233 u
.uhp
= u
.uhpmax
= 12;
234 u
.ustr
= u
.ustrmax
= 16;
238 register int d
= rn2(7) - 2; /* biased variation */
244 if(wizard
) wiz_inv();
247 /* make sure he can carry all he has - especially for T's */
248 while(inv_weight() > 0 && u
.ustr
< 118)
249 u
.ustr
++, u
.ustrmax
++;
252 ini_inv(trop
) register struct trobj
*trop
; {
253 register struct obj
*obj
;
254 extern struct obj
*mkobj();
255 while(trop
->trolet
) {
256 obj
= mkobj(trop
->trolet
);
257 obj
->known
= trop
->trknown
;
258 /* not obj->dknown = 1; - let him look at it at least once */
260 if(obj
->olet
== WEAPON_SYM
){
261 obj
->quan
= trop
->trquan
;
264 if(trop
->trspe
!= UNDEF_SPE
)
265 obj
->spe
= trop
->trspe
;
266 if(trop
->trotyp
!= UNDEF_TYP
)
267 obj
->otyp
= trop
->trotyp
;
269 if(obj
->otyp
== WAN_WISHING
) /* gitpyr!robert */
270 obj
->otyp
= WAN_DEATH
;
271 obj
->owt
= weight(obj
); /* defined after setting otyp+quan */
273 if(obj
->olet
== ARMOR_SYM
){
276 if(!uarms
) setworn(obj
, W_ARMS
);
279 if(!uarmh
) setworn(obj
, W_ARMH
);
282 if(!uarmg
) setworn(obj
, W_ARMG
);
289 if(!uarm
) setworn(obj
, W_ARM
);
292 if(obj
->olet
== WEAPON_SYM
)
293 if(!uwep
) setuwep(obj
);
295 if(--trop
->trquan
) continue; /* make a similar object */
297 if(trop
->trquan
) { /* check if zero first */
300 continue; /* make a similar object */
309 register struct trobj
*trop
= &Extra_objs
[0];
310 extern char *getenv();
311 register char *ep
= getenv("INVENT");
316 if(ep
) while(*ep
== ',' || *ep
== ' ') ep
++;
317 if(type
<= 0 || type
> NROFOBJECTS
) continue;
319 trop
->trolet
= objects
[type
].oc_olet
;
325 /* give him a wand of wishing by default */
326 trop
->trotyp
= WAN_WISHING
;
327 trop
->trolet
= WAND_SYM
;
337 if(p
= rindex(plname
, '-')) {
339 pl_character
[0] = p
[1];
350 { /* must be called only from u_init() */
351 /* so that rolesyms[] is defined */
354 if(cp
= index(rolesyms
, pc
))
355 return(cp
- rolesyms
);