version 1.7 | | version 1.8 |
---|
| | |
/* | | /* |
* static char *rcsid_utils_c = | | * static char *rcsid_utils_c = |
* "$Id: utils.c,v 1.7 2003/01/30 00:07:08 garbled Exp $"; | | * "$Id: utils.c,v 1.8 2003/02/06 08:08:49 garbled Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
return mt; | | return mt; |
} | | } |
| | |
| | /* when doing transmutation of objects, we have to recheck the resistances, |
| | * as some that did not apply previously, may apply now. |
| | */ |
| | |
| | void transmute_materialname(object *op, object *change) |
| | { |
| | materialtype_t *mt; |
| | int j; |
| | |
| | if (op->materialname == NULL) |
| | return; |
| | |
| | if (change->materialname != NULL && |
| | strcmp(op->materialname, change->materialname)) |
| | return; |
| | |
| | if (!IS_ARMOR(op)) |
| | return; |
| | |
| | mt = name_to_material(op->materialname); |
| | |
| | for (j=0; j < NROFATTACKS; j++) |
| | if (op->resist[j] == 0 && change->resist[j] != 0) { |
| | op->resist[j] += mt->mod[j]; |
| | if (op->resist[j] > 100) |
| | op->resist[j] = 100; |
| | if (op->resist[j] < -100) |
| | op->resist[j] = -100; |
| | } |
| | } |
| | |
/* 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) |
{ | | { |
| | |
if (op->stats.wc && IS_WEAPON(op)) | | if (op->stats.wc && IS_WEAPON(op)) |
op->stats.wc += lmt->wc; | | op->stats.wc += lmt->wc; |
if (IS_ARMOR(op)) { | | if (IS_ARMOR(op)) { |
| | if (op->stats.ac) |
op->stats.ac += lmt->ac; | | op->stats.ac += lmt->ac; |
for (j=0; j < NROFATTACKS; j++) | | for (j=0; j < NROFATTACKS; j++) |
if (op->resist[j] != 0) | | if (op->resist[j] != 0) { |
op->resist[j] += lmt->mod[j]; | | op->resist[j] += lmt->mod[j]; |
| | if (op->resist[j] > 100) |
| | op->resist[j] = 100; |
| | if (op->resist[j] < -100) |
| | op->resist[j] = -100; |
| | } |
} | | } |
op->materialname = add_string(lmt->name); | | op->materialname = add_string(lmt->name); |
/* dont make it unstackable if it doesn't need to be */ | | /* dont make it unstackable if it doesn't need to be */ |