NetBSD/games/hack/hack.objnam.c

588 lines
12 KiB
C
Raw Normal View History

1997-10-19 20:56:41 +04:00
/* $NetBSD: hack.objnam.c,v 1.4 1997/10/19 16:58:39 christos Exp $ */
1993-08-02 21:16:36 +04:00
/*
* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
*/
1997-10-19 20:56:41 +04:00
#include <sys/cdefs.h>
1993-08-02 21:16:36 +04:00
#ifndef lint
1997-10-19 20:56:41 +04:00
__RCSID("$NetBSD: hack.objnam.c,v 1.4 1997/10/19 16:58:39 christos Exp $");
#endif /* not lint */
1993-03-21 12:45:37 +03:00
1997-10-19 20:56:41 +04:00
#include <stdlib.h>
#include "hack.h"
#include "extern.h"
1993-03-21 12:45:37 +03:00
#define Sprintf (void) sprintf
#define Strcat (void) strcat
#define Strcpy (void) strcpy
#define PREFIX 15
1997-10-19 20:56:41 +04:00
char *
strprepend(s, pref)
char *s, *pref;
{
int i = strlen(pref);
if (i > PREFIX) {
1993-03-21 12:45:37 +03:00
pline("WARNING: prefix too short.");
1997-10-19 20:56:41 +04:00
return (s);
1993-03-21 12:45:37 +03:00
}
s -= i;
(void) strncpy(s, pref, i); /* do not copy trailing 0 */
1997-10-19 20:56:41 +04:00
return (s);
1993-03-21 12:45:37 +03:00
}
1997-10-19 20:56:41 +04:00
char *
sitoa(a)
int a;
{
static char buf[13];
1993-03-21 12:45:37 +03:00
Sprintf(buf, (a < 0) ? "%d" : "+%d", a);
1997-10-19 20:56:41 +04:00
return (buf);
1993-03-21 12:45:37 +03:00
}
1997-10-19 20:56:41 +04:00
char *
1993-03-21 12:45:37 +03:00
typename(otyp)
1997-10-19 20:56:41 +04:00
int otyp;
1993-03-21 12:45:37 +03:00
{
1997-10-19 20:56:41 +04:00
static char buf[BUFSZ];
struct objclass *ocl = &objects[otyp];
char *an = ocl->oc_name;
char *dn = ocl->oc_descr;
char *un = ocl->oc_uname;
int nn = ocl->oc_name_known;
switch (ocl->oc_olet) {
1993-03-21 12:45:37 +03:00
case POTION_SYM:
Strcpy(buf, "potion");
break;
case SCROLL_SYM:
Strcpy(buf, "scroll");
break;
case WAND_SYM:
Strcpy(buf, "wand");
break;
case RING_SYM:
Strcpy(buf, "ring");
break;
default:
1997-10-19 20:56:41 +04:00
if (nn) {
1993-03-21 12:45:37 +03:00
Strcpy(buf, an);
1997-10-19 20:56:41 +04:00
if (otyp >= TURQUOISE && otyp <= JADE)
1993-03-21 12:45:37 +03:00
Strcat(buf, " stone");
1997-10-19 20:56:41 +04:00
if (un)
1993-03-21 12:45:37 +03:00
Sprintf(eos(buf), " called %s", un);
1997-10-19 20:56:41 +04:00
if (dn)
1993-03-21 12:45:37 +03:00
Sprintf(eos(buf), " (%s)", dn);
} else {
Strcpy(buf, dn ? dn : an);
1997-10-19 20:56:41 +04:00
if (ocl->oc_olet == GEM_SYM)
1993-03-21 12:45:37 +03:00
Strcat(buf, " gem");
1997-10-19 20:56:41 +04:00
if (un)
1993-03-21 12:45:37 +03:00
Sprintf(eos(buf), " called %s", un);
}
1997-10-19 20:56:41 +04:00
return (buf);
1993-03-21 12:45:37 +03:00
}
/* here for ring/scroll/potion/wand */
1997-10-19 20:56:41 +04:00
if (nn)
1993-03-21 12:45:37 +03:00
Sprintf(eos(buf), " of %s", an);
1997-10-19 20:56:41 +04:00
if (un)
1993-03-21 12:45:37 +03:00
Sprintf(eos(buf), " called %s", un);
1997-10-19 20:56:41 +04:00
if (dn)
1993-03-21 12:45:37 +03:00
Sprintf(eos(buf), " (%s)", dn);
1997-10-19 20:56:41 +04:00
return (buf);
1993-03-21 12:45:37 +03:00
}
1997-10-19 20:56:41 +04:00
char *
1993-03-21 12:45:37 +03:00
xname(obj)
1997-10-19 20:56:41 +04:00
struct obj *obj;
1993-03-21 12:45:37 +03:00
{
1997-10-19 20:56:41 +04:00
static char bufr[BUFSZ];
char *buf = &(bufr[PREFIX]); /* leave room for "17 -3 " */
int nn = objects[obj->otyp].oc_name_known;
char *an = objects[obj->otyp].oc_name;
char *dn = objects[obj->otyp].oc_descr;
char *un = objects[obj->otyp].oc_uname;
int pl = (obj->quan != 1);
if (!obj->dknown && !Blind)
obj->dknown = 1;/* %% doesnt belong here */
switch (obj->olet) {
1993-03-21 12:45:37 +03:00
case AMULET_SYM:
Strcpy(buf, (obj->spe < 0 && obj->known)
1997-10-19 20:56:41 +04:00
? "cheap plastic imitation of the " : "");
Strcat(buf, "Amulet of Yendor");
1993-03-21 12:45:37 +03:00
break;
case TOOL_SYM:
1997-10-19 20:56:41 +04:00
if (!nn) {
1993-03-21 12:45:37 +03:00
Strcpy(buf, dn);
break;
}
1997-10-19 20:56:41 +04:00
Strcpy(buf, an);
1993-03-21 12:45:37 +03:00
break;
case FOOD_SYM:
1997-10-19 20:56:41 +04:00
if (obj->otyp == DEAD_HOMUNCULUS && pl) {
1993-03-21 12:45:37 +03:00
pl = 0;
Strcpy(buf, "dead homunculi");
break;
}
/* fungis ? */
/* fall into next case */
case WEAPON_SYM:
1997-10-19 20:56:41 +04:00
if (obj->otyp == WORM_TOOTH && pl) {
1993-03-21 12:45:37 +03:00
pl = 0;
Strcpy(buf, "worm teeth");
break;
}
1997-10-19 20:56:41 +04:00
if (obj->otyp == CRYSKNIFE && pl) {
1993-03-21 12:45:37 +03:00
pl = 0;
Strcpy(buf, "crysknives");
break;
}
/* fall into next case */
case ARMOR_SYM:
case CHAIN_SYM:
case ROCK_SYM:
1997-10-19 20:56:41 +04:00
Strcpy(buf, an);
1993-03-21 12:45:37 +03:00
break;
case BALL_SYM:
Sprintf(buf, "%sheavy iron ball",
(obj->owt > objects[obj->otyp].oc_weight) ? "very " : "");
break;
case POTION_SYM:
1997-10-19 20:56:41 +04:00
if (nn || un || !obj->dknown) {
1993-03-21 12:45:37 +03:00
Strcpy(buf, "potion");
1997-10-19 20:56:41 +04:00
if (pl) {
1993-03-21 12:45:37 +03:00
pl = 0;
Strcat(buf, "s");
}
1997-10-19 20:56:41 +04:00
if (!obj->dknown)
break;
if (un) {
1993-03-21 12:45:37 +03:00
Strcat(buf, " called ");
Strcat(buf, un);
} else {
Strcat(buf, " of ");
Strcat(buf, an);
}
} else {
Strcpy(buf, dn);
Strcat(buf, " potion");
}
break;
case SCROLL_SYM:
Strcpy(buf, "scroll");
1997-10-19 20:56:41 +04:00
if (pl) {
1993-03-21 12:45:37 +03:00
pl = 0;
Strcat(buf, "s");
}
1997-10-19 20:56:41 +04:00
if (!obj->dknown)
break;
if (nn) {
1993-03-21 12:45:37 +03:00
Strcat(buf, " of ");
Strcat(buf, an);
1997-10-19 20:56:41 +04:00
} else if (un) {
1993-03-21 12:45:37 +03:00
Strcat(buf, " called ");
Strcat(buf, un);
} else {
Strcat(buf, " labeled ");
Strcat(buf, dn);
}
break;
case WAND_SYM:
1997-10-19 20:56:41 +04:00
if (!obj->dknown)
1993-03-21 12:45:37 +03:00
Sprintf(buf, "wand");
1997-10-19 20:56:41 +04:00
else if (nn)
1993-03-21 12:45:37 +03:00
Sprintf(buf, "wand of %s", an);
1997-10-19 20:56:41 +04:00
else if (un)
1993-03-21 12:45:37 +03:00
Sprintf(buf, "wand called %s", un);
else
Sprintf(buf, "%s wand", dn);
break;
case RING_SYM:
1997-10-19 20:56:41 +04:00
if (!obj->dknown)
1993-03-21 12:45:37 +03:00
Sprintf(buf, "ring");
1997-10-19 20:56:41 +04:00
else if (nn)
1993-03-21 12:45:37 +03:00
Sprintf(buf, "ring of %s", an);
1997-10-19 20:56:41 +04:00
else if (un)
1993-03-21 12:45:37 +03:00
Sprintf(buf, "ring called %s", un);
else
Sprintf(buf, "%s ring", dn);
break;
case GEM_SYM:
1997-10-19 20:56:41 +04:00
if (!obj->dknown) {
1993-03-21 12:45:37 +03:00
Strcpy(buf, "gem");
break;
}
1997-10-19 20:56:41 +04:00
if (!nn) {
1993-03-21 12:45:37 +03:00
Sprintf(buf, "%s gem", dn);
break;
}
Strcpy(buf, an);
1997-10-19 20:56:41 +04:00
if (obj->otyp >= TURQUOISE && obj->otyp <= JADE)
1993-03-21 12:45:37 +03:00
Strcat(buf, " stone");
break;
default:
1997-10-19 20:56:41 +04:00
Sprintf(buf, "glorkum %c (0%o) %u %d",
obj->olet, obj->olet, obj->otyp, obj->spe);
1993-03-21 12:45:37 +03:00
}
1997-10-19 20:56:41 +04:00
if (pl) {
char *p;
1993-03-21 12:45:37 +03:00
1997-10-19 20:56:41 +04:00
for (p = buf; *p; p++) {
if (!strncmp(" of ", p, 4)) {
1993-03-21 12:45:37 +03:00
/* pieces of, cloves of, lumps of */
1997-10-19 20:56:41 +04:00
int c1, c2 = 's';
1993-03-21 12:45:37 +03:00
do {
1997-10-19 20:56:41 +04:00
c1 = c2;
c2 = *p;
*p++ = c1;
} while (c1);
1993-03-21 12:45:37 +03:00
goto nopl;
}
}
1997-10-19 20:56:41 +04:00
p = eos(buf) - 1;
if (*p == 's' || *p == 'z' || *p == 'x' ||
1993-03-21 12:45:37 +03:00
(*p == 'h' && p[-1] == 's'))
Strcat(buf, "es"); /* boxes */
1997-10-19 20:56:41 +04:00
else if (*p == 'y' && !strchr(vowels, p[-1]))
1993-03-21 12:45:37 +03:00
Strcpy(p, "ies"); /* rubies, zruties */
else
Strcat(buf, "s");
}
nopl:
1997-10-19 20:56:41 +04:00
if (obj->onamelth) {
1993-03-21 12:45:37 +03:00
Strcat(buf, " named ");
Strcat(buf, ONAME(obj));
}
1997-10-19 20:56:41 +04:00
return (buf);
1993-03-21 12:45:37 +03:00
}
1997-10-19 20:56:41 +04:00
char *
1993-03-21 12:45:37 +03:00
doname(obj)
1997-10-19 20:56:41 +04:00
struct obj *obj;
1993-03-21 12:45:37 +03:00
{
1997-10-19 20:56:41 +04:00
char prefix[PREFIX];
char *bp = xname(obj);
if (obj->quan != 1)
1993-03-21 12:45:37 +03:00
Sprintf(prefix, "%u ", obj->quan);
else
Strcpy(prefix, "a ");
1997-10-19 20:56:41 +04:00
switch (obj->olet) {
1993-03-21 12:45:37 +03:00
case AMULET_SYM:
1997-10-19 20:56:41 +04:00
if (strncmp(bp, "cheap ", 6))
1993-03-21 12:45:37 +03:00
Strcpy(prefix, "the ");
break;
case ARMOR_SYM:
1997-10-19 20:56:41 +04:00
if (obj->owornmask & W_ARMOR)
1993-03-21 12:45:37 +03:00
Strcat(bp, " (being worn)");
/* fall into next case */
case WEAPON_SYM:
1997-10-19 20:56:41 +04:00
if (obj->known) {
1993-03-21 12:45:37 +03:00
Strcat(prefix, sitoa(obj->spe));
Strcat(prefix, " ");
}
break;
case WAND_SYM:
1997-10-19 20:56:41 +04:00
if (obj->known)
1993-03-21 12:45:37 +03:00
Sprintf(eos(bp), " (%d)", obj->spe);
break;
case RING_SYM:
1997-10-19 20:56:41 +04:00
if (obj->owornmask & W_RINGR)
Strcat(bp, " (on right hand)");
if (obj->owornmask & W_RINGL)
Strcat(bp, " (on left hand)");
if (obj->known && (objects[obj->otyp].bits & SPEC)) {
1993-03-21 12:45:37 +03:00
Strcat(prefix, sitoa(obj->spe));
Strcat(prefix, " ");
}
break;
}
1997-10-19 20:56:41 +04:00
if (obj->owornmask & W_WEP)
1993-03-21 12:45:37 +03:00
Strcat(bp, " (weapon in hand)");
1997-10-19 20:56:41 +04:00
if (obj->unpaid)
1993-03-21 12:45:37 +03:00
Strcat(bp, " (unpaid)");
1997-10-19 20:56:41 +04:00
if (!strcmp(prefix, "a ") && strchr(vowels, *bp))
1993-03-21 12:45:37 +03:00
Strcpy(prefix, "an ");
bp = strprepend(bp, prefix);
1997-10-19 20:56:41 +04:00
return (bp);
1993-03-21 12:45:37 +03:00
}
/* used only in hack.fight.c (thitu) */
1997-10-19 20:56:41 +04:00
void
setan(str, buf)
char *str, *buf;
1993-03-21 12:45:37 +03:00
{
1997-10-19 20:56:41 +04:00
if (strchr(vowels, *str))
1993-03-21 12:45:37 +03:00
Sprintf(buf, "an %s", str);
else
Sprintf(buf, "a %s", str);
}
1997-10-19 20:56:41 +04:00
char *
aobjnam(otmp, verb)
struct obj *otmp;
char *verb;
{
char *bp = xname(otmp);
char prefix[PREFIX];
if (otmp->quan != 1) {
1993-03-21 12:45:37 +03:00
Sprintf(prefix, "%u ", otmp->quan);
bp = strprepend(bp, prefix);
}
1997-10-19 20:56:41 +04:00
if (verb) {
1993-03-21 12:45:37 +03:00
/* verb is given in plural (i.e., without trailing s) */
Strcat(bp, " ");
1997-10-19 20:56:41 +04:00
if (otmp->quan != 1)
1993-03-21 12:45:37 +03:00
Strcat(bp, verb);
1997-10-19 20:56:41 +04:00
else if (!strcmp(verb, "are"))
1993-03-21 12:45:37 +03:00
Strcat(bp, "is");
else {
Strcat(bp, verb);
Strcat(bp, "s");
}
}
1997-10-19 20:56:41 +04:00
return (bp);
1993-03-21 12:45:37 +03:00
}
1997-10-19 20:56:41 +04:00
char *
1993-03-21 12:45:37 +03:00
Doname(obj)
1997-10-19 20:56:41 +04:00
struct obj *obj;
1993-03-21 12:45:37 +03:00
{
1997-10-19 20:56:41 +04:00
char *s = doname(obj);
1993-03-21 12:45:37 +03:00
1997-10-19 20:56:41 +04:00
if ('a' <= *s && *s <= 'z')
*s -= ('a' - 'A');
return (s);
1993-03-21 12:45:37 +03:00
}
1997-10-19 20:56:41 +04:00
char *wrp[] = {"wand", "ring", "potion", "scroll", "gem"};
char wrpsym[] = {WAND_SYM, RING_SYM, POTION_SYM, SCROLL_SYM, GEM_SYM};
1993-03-21 12:45:37 +03:00
1997-10-19 20:56:41 +04:00
struct obj *
readobjnam(bp)
char *bp;
{
char *p;
int i;
int cnt, spe, spesgn, typ, heavy;
char let;
char *un, *dn, *an;
/* int the = 0; char *oname = 0; */
1993-03-21 12:45:37 +03:00
cnt = spe = spesgn = typ = heavy = 0;
let = 0;
an = dn = un = 0;
1997-10-19 20:56:41 +04:00
for (p = bp; *p; p++)
if ('A' <= *p && *p <= 'Z')
*p += 'a' - 'A';
if (!strncmp(bp, "the ", 4)) {
/* the = 1; */
1993-03-21 12:45:37 +03:00
bp += 4;
1997-10-19 20:56:41 +04:00
} else if (!strncmp(bp, "an ", 3)) {
1993-03-21 12:45:37 +03:00
cnt = 1;
bp += 3;
1997-10-19 20:56:41 +04:00
} else if (!strncmp(bp, "a ", 2)) {
1993-03-21 12:45:37 +03:00
cnt = 1;
bp += 2;
}
1997-10-19 20:56:41 +04:00
if (!cnt && digit(*bp)) {
1993-03-21 12:45:37 +03:00
cnt = atoi(bp);
1997-10-19 20:56:41 +04:00
while (digit(*bp))
bp++;
while (*bp == ' ')
bp++;
1993-03-21 12:45:37 +03:00
}
1997-10-19 20:56:41 +04:00
if (!cnt)
cnt = 1; /* %% what with "gems" etc. ? */
1993-03-21 12:45:37 +03:00
1997-10-19 20:56:41 +04:00
if (*bp == '+' || *bp == '-') {
1993-03-21 12:45:37 +03:00
spesgn = (*bp++ == '+') ? 1 : -1;
spe = atoi(bp);
1997-10-19 20:56:41 +04:00
while (digit(*bp))
bp++;
while (*bp == ' ')
bp++;
1993-03-21 12:45:37 +03:00
} else {
1997-10-19 20:56:41 +04:00
p = strrchr(bp, '(');
if (p) {
if (p > bp && p[-1] == ' ')
p[-1] = 0;
else
*p = 0;
1993-03-21 12:45:37 +03:00
p++;
spe = atoi(p);
1997-10-19 20:56:41 +04:00
while (digit(*p))
p++;
if (strcmp(p, ")"))
spe = 0;
else
spesgn = 1;
1993-03-21 12:45:37 +03:00
}
}
1997-10-19 20:56:41 +04:00
/*
* now we have the actual name, as delivered by xname, say green
* potions called whisky scrolls labeled "QWERTY" egg dead zruties
* fortune cookies very heavy iron ball named hoei wand of wishing
* elven cloak
*/
for (p = bp; *p; p++)
if (!strncmp(p, " named ", 7)) {
*p = 0;
/* oname = p+7; */
}
for (p = bp; *p; p++)
if (!strncmp(p, " called ", 8)) {
*p = 0;
un = p + 8;
}
for (p = bp; *p; p++)
if (!strncmp(p, " labeled ", 9)) {
*p = 0;
dn = p + 9;
}
1993-03-21 12:45:37 +03:00
/* first change to singular if necessary */
1997-10-19 20:56:41 +04:00
if (cnt != 1) {
1993-03-21 12:45:37 +03:00
/* find "cloves of garlic", "worthless pieces of blue glass" */
1997-10-19 20:56:41 +04:00
for (p = bp; *p; p++)
if (!strncmp(p, "s of ", 5)) {
while ((*p = p[1]) != '\0')
p++;
goto sing;
}
1993-03-21 12:45:37 +03:00
/* remove -s or -es (boxes) or -ies (rubies, zruties) */
p = eos(bp);
1997-10-19 20:56:41 +04:00
if (p[-1] == 's') {
if (p[-2] == 'e') {
if (p[-3] == 'i') {
if (!strcmp(p - 7, "cookies"))
1993-03-21 12:45:37 +03:00
goto mins;
1997-10-19 20:56:41 +04:00
Strcpy(p - 3, "y");
1993-03-21 12:45:37 +03:00
goto sing;
}
/* note: cloves / knives from clove / knife */
1997-10-19 20:56:41 +04:00
if (!strcmp(p - 6, "knives")) {
Strcpy(p - 3, "fe");
1993-03-21 12:45:37 +03:00
goto sing;
}
/* note: nurses, axes but boxes */
1997-10-19 20:56:41 +04:00
if (!strcmp(p - 5, "boxes")) {
1993-03-21 12:45:37 +03:00
p[-2] = 0;
goto sing;
}
}
1997-10-19 20:56:41 +04:00
mins:
1993-03-21 12:45:37 +03:00
p[-1] = 0;
} else {
1997-10-19 20:56:41 +04:00
if (!strcmp(p - 9, "homunculi")) {
Strcpy(p - 1, "us"); /* !! makes string
* longer */
1993-03-21 12:45:37 +03:00
goto sing;
}
1997-10-19 20:56:41 +04:00
if (!strcmp(p - 5, "teeth")) {
Strcpy(p - 5, "tooth");
1993-03-21 12:45:37 +03:00
goto sing;
}
/* here we cannot find the plural suffix */
}
}
sing:
1997-10-19 20:56:41 +04:00
if (!strcmp(bp, "amulet of yendor")) {
1993-03-21 12:45:37 +03:00
typ = AMULET_OF_YENDOR;
goto typfnd;
}
p = eos(bp);
1997-10-19 20:56:41 +04:00
if (!strcmp(p - 5, " mail")) { /* Note: ring mail is not a ring ! */
1993-03-21 12:45:37 +03:00
let = ARMOR_SYM;
an = bp;
goto srch;
}
1997-10-19 20:56:41 +04:00
for (i = 0; i < sizeof(wrpsym); i++) {
int j = strlen(wrp[i]);
if (!strncmp(bp, wrp[i], j)) {
1993-03-21 12:45:37 +03:00
let = wrpsym[i];
bp += j;
1997-10-19 20:56:41 +04:00
if (!strncmp(bp, " of ", 4))
an = bp + 4;
1993-03-21 12:45:37 +03:00
/* else if(*bp) ?? */
goto srch;
}
1997-10-19 20:56:41 +04:00
if (!strcmp(p - j, wrp[i])) {
1993-03-21 12:45:37 +03:00
let = wrpsym[i];
p -= j;
*p = 0;
1997-10-19 20:56:41 +04:00
if (p[-1] == ' ')
p[-1] = 0;
1993-03-21 12:45:37 +03:00
dn = bp;
goto srch;
}
}
1997-10-19 20:56:41 +04:00
if (!strcmp(p - 6, " stone")) {
1993-03-21 12:45:37 +03:00
p[-6] = 0;
let = GEM_SYM;
an = bp;
goto srch;
}
1997-10-19 20:56:41 +04:00
if (!strcmp(bp, "very heavy iron ball")) {
1993-03-21 12:45:37 +03:00
heavy = 1;
typ = HEAVY_IRON_BALL;
goto typfnd;
}
an = bp;
srch:
1997-10-19 20:56:41 +04:00
if (!an && !dn && !un)
1993-03-21 12:45:37 +03:00
goto any;
i = 1;
1997-10-19 20:56:41 +04:00
if (let)
i = bases[letindex(let)];
while (i <= NROFOBJECTS && (!let || objects[i].oc_olet == let)) {
char *zn = objects[i].oc_name;
1993-03-21 12:45:37 +03:00
1997-10-19 20:56:41 +04:00
if (!zn)
goto nxti;
if (an && strcmp(an, zn))
1993-03-21 12:45:37 +03:00
goto nxti;
1997-10-19 20:56:41 +04:00
if (dn && (!(zn = objects[i].oc_descr) || strcmp(dn, zn)))
1993-03-21 12:45:37 +03:00
goto nxti;
1997-10-19 20:56:41 +04:00
if (un && (!(zn = objects[i].oc_uname) || strcmp(un, zn)))
1993-03-21 12:45:37 +03:00
goto nxti;
typ = i;
goto typfnd;
1997-10-19 20:56:41 +04:00
nxti:
1993-03-21 12:45:37 +03:00
i++;
}
any:
1997-10-19 20:56:41 +04:00
if (!let)
let = wrpsym[rn2(sizeof(wrpsym))];
1993-03-21 12:45:37 +03:00
typ = probtype(let);
typfnd:
1997-10-19 20:56:41 +04:00
{
struct obj *otmp;
let = objects[typ].oc_olet;
otmp = mksobj(typ);
if (heavy)
otmp->owt += 15;
if (cnt > 0 && strchr("%?!*)", let) &&
1993-03-21 12:45:37 +03:00
(cnt < 4 || (let == WEAPON_SYM && typ <= ROCK && cnt < 20)))
1997-10-19 20:56:41 +04:00
otmp->quan = cnt;
1993-03-21 12:45:37 +03:00
1997-10-19 20:56:41 +04:00
if (spe > 3 && spe > otmp->spe)
spe = 0;
else if (let == WAND_SYM)
spe = otmp->spe;
if (spe == 3 && u.uluck < 0)
spesgn = -1;
if (let != WAND_SYM && spesgn == -1)
spe = -spe;
if (let == BALL_SYM)
spe = 0;
else if (let == AMULET_SYM)
spe = -1;
else if (typ == WAN_WISHING && rn2(10))
spe = (rn2(10) ? -1 : 0);
otmp->spe = spe;
1993-03-21 12:45:37 +03:00
1997-10-19 20:56:41 +04:00
if (spesgn == -1)
otmp->cursed = 1;
1993-03-21 12:45:37 +03:00
1997-10-19 20:56:41 +04:00
return (otmp);
}
1993-03-21 12:45:37 +03:00
}