version 1.9 | | version 1.10 |
---|
| | |
/* | | /* |
* static char *rcsid_utils_c = | | * static char *rcsid_utils_c = |
* "$Id: utils.c,v 1.9 2003/02/07 06:57:17 garbled Exp $"; | | * "$Id: utils.c,v 1.10 2003/02/14 05:50:29 garbled Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
materialtype_t *name_to_material(char *name) | | materialtype_t *name_to_material(char *name) |
{ | | { |
materialtype_t *mt; | | materialtype_t *mt, *nmt; |
| | |
for (mt = materialt; mt != NULL && mt->next != NULL; mt=mt->next) { | | mt = NULL; |
if (strcmp(name, mt->name) == 0) | | for (nmt = materialt; nmt != NULL && nmt->next != NULL; nmt=nmt->next) { |
| | if (strcmp(name, nmt->name) == 0) { |
| | mt = nmt; |
break; | | break; |
} | | } |
| | } |
return mt; | | return mt; |
} | | } |
| | |
| | |
} | | } |
| | |
/* set the materialname and type for an item */ | | /* set the materialname and type for an item */ |
void set_materialname(object *op, int difficulty) | | void set_materialname(object *op, int difficulty, materialtype_t *nmt) |
{ | | { |
materialtype_t *mt, *lmt; | | materialtype_t *mt, *lmt; |
int j; | | int j; |
| | |
if (op->materialname != NULL) | | if (op->materialname != NULL) |
return; | | return; |
if (op->name == NULL || op->name_pl == NULL) | | |
return; | | |
| | |
| | if (nmt == NULL) { |
lmt = NULL; | | lmt = NULL; |
for (mt = materialt; mt != NULL && mt->next != NULL; mt=mt->next) { | | for (mt = materialt; mt != NULL && mt->next != NULL; mt=mt->next) { |
if (op->material & mt->material && rndm(1, 100) <= mt->chance && | | if (op->material & mt->material && rndm(1, 100) <= mt->chance && |
difficulty >= mt->difficulty && | | difficulty >= mt->difficulty && |
(op->magic >= mt->magic || mt->magic == 0)) | | (op->magic >= mt->magic || mt->magic == 0)) { |
lmt = mt; | | lmt = mt; |
| | if (!(IS_WEAPON(op) || IS_ARMOR(op))) |
| | break; |
| | } |
| | } |
| | } else { |
| | lmt = nmt; |
} | | } |
if (lmt != NULL) { | | if (lmt != NULL) { |
if (op->stats.dam && IS_WEAPON(op)) { | | if (op->stats.dam && IS_WEAPON(op)) { |