--- deliantra/server/common/item.C 2006/08/13 17:16:00 1.1 +++ deliantra/server/common/item.C 2006/08/29 08:01:35 1.2 @@ -1,6 +1,6 @@ /* * static char *rcsid_item_c = - * "$Id: item.C,v 1.1 2006/08/13 17:16:00 elmex Exp $"; + * "$Id: item.C,v 1.2 2006/08/29 08:01:35 root Exp $"; */ /* @@ -284,7 +284,7 @@ enc = 0; for (i=0; istats, i); + enc += get_attr_value(&op->stats, i); /* This protection logic is pretty flawed. 20% fire resistance * is much more valuable than 20% confusion, or 20% slow, or @@ -293,7 +293,7 @@ */ tmp = 0; for (i=1; iresist[i]; + tmp += op->resist[i]; /* Add/substract 10 so that the rounding works out right */ if (tmp>0) enc += (tmp+10)/20; @@ -305,9 +305,9 @@ * physical doesn't count against total. */ if (op->type == WEAPON) { - for (i=1; iattacktype & (1 << i)) enc++; - if (op->slaying) enc += 2; /* What it slays is probably more relevent */ + for (i=1; iattacktype & (1 << i)) enc++; + if (op->slaying) enc += 2; /* What it slays is probably more relevent */ } /* Items the player can equip */ if ((op->type == WEAPON) || (op->type == ARMOUR) || (op->type == HELMET) || @@ -315,19 +315,19 @@ (op->type == BOOTS) || (op->type == GLOVES) || (op->type == AMULET ) || (op->type == GIRDLE) || (op->type == BRACERS ) || (op->type == CLOAK)) { - enc += op->stats.food; /* sustenance */ - enc += op->stats.hp; /* hp regen */ - enc += op->stats.sp; /* mana regen */ - enc += op->stats.grace; /* grace regen */ - enc += op->stats.exp; /* speed bonus */ + enc += op->stats.food; /* sustenance */ + enc += op->stats.hp; /* hp regen */ + enc += op->stats.sp; /* mana regen */ + enc += op->stats.grace; /* grace regen */ + enc += op->stats.exp; /* speed bonus */ } enc += op->stats.luck; /* Do spell paths now */ for (i=1; ipath_attuned& (1 << i)) enc++; - else if (op->path_denied & (1 << i)) enc-=2; - else if (op->path_repelled & (1 << i)) enc--; + if (op->path_attuned& (1 << i)) enc++; + else if (op->path_denied & (1 << i)) enc-=2; + else if (op->path_repelled & (1 << i)) enc--; } if(QUERY_FLAG(op,FLAG_LIFESAVE)) enc += 5; @@ -348,7 +348,7 @@ const typedata *get_typedata(int itemtype) { int i; for (i=0;iresist[tmpvar] && (op->type != FLESH || atnr_is_dragon_enabled(tmpvar)==1)) { - if (!newline) - sprintf(buf1,"(%s %+d)", resist_plus[tmpvar], op->resist[tmpvar]); - else - sprintf(buf1,"%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]); + if (!newline) + sprintf(buf1,"(%s %+d)", resist_plus[tmpvar], op->resist[tmpvar]); + else + sprintf(buf1,"%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]); - strcat(buf, buf1); + strcat(buf, buf1); } } return buf; @@ -473,44 +473,44 @@ buf[0] = 0; if (! QUERY_FLAG(op, FLAG_IDENTIFIED)) - return buf; + return buf; for (attr=0; attrstats),attr))!=0) { - sprintf (buf+strlen(buf), "(%s%+d)", short_stat_name[attr], val); - } + if ((val=get_attr_value(&(op->stats),attr))!=0) { + sprintf (buf+strlen(buf), "(%s%+d)", short_stat_name[attr], val); + } } if(op->stats.exp) - sprintf(buf+strlen(buf), "(speed %+lld)", op->stats.exp); + sprintf(buf+strlen(buf), "(speed %+lld)", op->stats.exp); if(op->stats.wc) - sprintf(buf+strlen(buf), "(wc%+d)", op->stats.wc); + sprintf(buf+strlen(buf), "(wc%+d)", op->stats.wc); if(op->stats.dam) - sprintf(buf+strlen(buf), "(dam%+d)", op->stats.dam); + sprintf(buf+strlen(buf), "(dam%+d)", op->stats.dam); if(op->stats.ac) - sprintf(buf+strlen(buf), "(ac%+d)", op->stats.ac); + sprintf(buf+strlen(buf), "(ac%+d)", op->stats.ac); strcat(buf,describe_resistance(op, 0)); if (op->stats.food != 0) - sprintf(buf+strlen(buf), "(sustenance%+d)", op->stats.food); - /* else if (op->stats.food < 0) - sprintf(buf+strlen(buf), "(hunger%+d)", op->stats.food); */ + sprintf(buf+strlen(buf), "(sustenance%+d)", op->stats.food); + /* else if (op->stats.food < 0) + sprintf(buf+strlen(buf), "(hunger%+d)", op->stats.food); */ if(op->stats.grace) - sprintf(buf+strlen(buf), "(grace%+d)", op->stats.grace); + sprintf(buf+strlen(buf), "(grace%+d)", op->stats.grace); if(op->stats.sp && op->type!=SKILL) - sprintf(buf+strlen(buf), "(magic%+d)", op->stats.sp); + sprintf(buf+strlen(buf), "(magic%+d)", op->stats.sp); if(op->stats.hp) - sprintf(buf+strlen(buf), "(regeneration%+d)", op->stats.hp); + sprintf(buf+strlen(buf), "(regeneration%+d)", op->stats.hp); if(op->stats.luck) - sprintf(buf+strlen(buf), "(luck%+d)", op->stats.luck); + sprintf(buf+strlen(buf), "(luck%+d)", op->stats.luck); if(QUERY_FLAG(op,FLAG_LIFESAVE)) - strcat(buf,"(lifesaving)"); + strcat(buf,"(lifesaving)"); if(QUERY_FLAG(op,FLAG_REFL_SPELL)) - strcat(buf,"(reflect spells)"); + strcat(buf,"(reflect spells)"); if(QUERY_FLAG(op,FLAG_REFL_MISSILE)) - strcat(buf,"(reflect missiles)"); + strcat(buf,"(reflect missiles)"); if(QUERY_FLAG(op,FLAG_STEALTH)) - strcat(buf,"(stealth)"); + strcat(buf,"(stealth)"); /* Shorten some of the names, so they appear better in the windows */ len=strlen(buf); DESCRIBE_PATH_SAFE(buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF); @@ -518,10 +518,10 @@ DESCRIBE_PATH_SAFE(buf, op->path_denied, "Denied", &len, VERY_BIG_BUF); /* if(op->item_power) - sprintf(buf+strlen(buf), "(item_power %+d)",op->item_power); + sprintf(buf+strlen(buf), "(item_power %+d)",op->item_power); */ if(buf[0] == 0 && op->type!=SKILL) - strcpy(buf,"of adornment"); + strcpy(buf,"of adornment"); return buf; @@ -538,58 +538,58 @@ int len=0; if(op->name == NULL) - return "(null)"; + return "(null)"; if(!op->nrof && !op->weight && !op->title && !is_magical(op)) - return op->name; /* To speed things up (or make things slower?) */ + return op->name; /* To speed things up (or make things slower?) */ if (op->nrof <= 1) - safe_strcat(buf,op->name, &len, HUGE_BUF); + safe_strcat(buf,op->name, &len, HUGE_BUF); else - safe_strcat(buf,op->name_pl, &len, HUGE_BUF); + safe_strcat(buf,op->name_pl, &len, HUGE_BUF); if (op->title && QUERY_FLAG(op,FLAG_IDENTIFIED)) { - safe_strcat(buf, " ", &len, HUGE_BUF); - safe_strcat(buf, op->title, &len, HUGE_BUF); + safe_strcat(buf, " ", &len, HUGE_BUF); + safe_strcat(buf, op->title, &len, HUGE_BUF); } switch(op->type) { - case SPELLBOOK: - case SCROLL: - case WAND: - case ROD: - if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { - if(!op->title) { - safe_strcat(buf," of ", &len, HUGE_BUF); - if (op->inv) - safe_strcat(buf,op->inv->name, &len, HUGE_BUF); - else - LOG(llevError,"Spellbook %s lacks inventory\n", op->name); - } - if(op->type != SPELLBOOK) { - sprintf(buf2, " (lvl %d)", op->level); - safe_strcat(buf, buf2, &len, HUGE_BUF); - } - } - break; + case SPELLBOOK: + case SCROLL: + case WAND: + case ROD: + if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { + if(!op->title) { + safe_strcat(buf," of ", &len, HUGE_BUF); + if (op->inv) + safe_strcat(buf,op->inv->name, &len, HUGE_BUF); + else + LOG(llevError,"Spellbook %s lacks inventory\n", op->name); + } + if(op->type != SPELLBOOK) { + sprintf(buf2, " (lvl %d)", op->level); + safe_strcat(buf, buf2, &len, HUGE_BUF); + } + } + break; case SKILL: case AMULET: case RING: - if (!op->title) { - /* If ring has a title, full description isn't so useful */ - char *s = ring_desc(op); - if (s[0]) { - safe_strcat (buf, " ", &len, HUGE_BUF); - safe_strcat(buf, s, &len, HUGE_BUF); - } - } - break; + if (!op->title) { + /* If ring has a title, full description isn't so useful */ + char *s = ring_desc(op); + if (s[0]) { + safe_strcat (buf, " ", &len, HUGE_BUF); + safe_strcat(buf, s, &len, HUGE_BUF); + } + } + break; default: - if(op->magic && ((QUERY_FLAG(op,FLAG_BEEN_APPLIED) && - need_identify(op)) || QUERY_FLAG(op,FLAG_IDENTIFIED))) { - sprintf(buf2, " %+d", op->magic); - safe_strcat(buf, buf2, &len, HUGE_BUF); - } + if(op->magic && ((QUERY_FLAG(op,FLAG_BEEN_APPLIED) && + need_identify(op)) || QUERY_FLAG(op,FLAG_IDENTIFIED))) { + sprintf(buf2, " %+d", op->magic); + safe_strcat(buf, buf2, &len, HUGE_BUF); + } } return buf; } @@ -618,27 +618,27 @@ #ifdef NEW_MATERIAL_CODE if ((IS_ARMOR(op) || IS_WEAPON(op)) && op->materialname) { - mt = name_to_material(op->materialname); - if (mt) { - safe_strcat(buf[use_buf], mt->description, &len, HUGE_BUF); - safe_strcat(buf[use_buf], " ", &len, HUGE_BUF); - } + mt = name_to_material(op->materialname); + if (mt) { + safe_strcat(buf[use_buf], mt->description, &len, HUGE_BUF); + safe_strcat(buf[use_buf], " ", &len, HUGE_BUF); + } } #endif safe_strcat(buf[use_buf], query_short_name(op), &len, HUGE_BUF); if (QUERY_FLAG(op,FLAG_INV_LOCKED)) - safe_strcat(buf[use_buf], " *", &len, HUGE_BUF); + safe_strcat(buf[use_buf], " *", &len, HUGE_BUF); if (op->type == CONTAINER && ((op->env && op->env->container == op) || - (!op->env && QUERY_FLAG(op,FLAG_APPLIED)))) - safe_strcat(buf[use_buf]," (open)", &len, HUGE_BUF); + (!op->env && QUERY_FLAG(op,FLAG_APPLIED)))) + safe_strcat(buf[use_buf]," (open)", &len, HUGE_BUF); if (QUERY_FLAG(op,FLAG_KNOWN_CURSED)) { - if(QUERY_FLAG(op,FLAG_DAMNED)) - safe_strcat(buf[use_buf], " (damned)", &len, HUGE_BUF); - else if(QUERY_FLAG(op,FLAG_CURSED)) - safe_strcat(buf[use_buf], " (cursed)", &len, HUGE_BUF); + if(QUERY_FLAG(op,FLAG_DAMNED)) + safe_strcat(buf[use_buf], " (damned)", &len, HUGE_BUF); + else if(QUERY_FLAG(op,FLAG_CURSED)) + safe_strcat(buf[use_buf], " (cursed)", &len, HUGE_BUF); } /* Basically, if the object is known magical (detect magic spell on it), * and it isn't identified, print out the fact that @@ -650,51 +650,51 @@ * abilities, especially for artifact items. */ if (QUERY_FLAG(op,FLAG_KNOWN_MAGICAL) && !QUERY_FLAG(op,FLAG_IDENTIFIED)) - safe_strcat(buf[use_buf], " (magic)", &len, HUGE_BUF); + safe_strcat(buf[use_buf], " (magic)", &len, HUGE_BUF); #if 0 /* item_power will be returned in desribe_item - it shouldn't really * be returned in the name. */ if(op->item_power) - sprintf(buf[use_buf]+strlen(buf[use_buf]), "(item_power %+d)", - op->item_power); + sprintf(buf[use_buf]+strlen(buf[use_buf]), "(item_power %+d)", + op->item_power); #endif if (QUERY_FLAG(op,FLAG_APPLIED)) { - switch(op->type) { - case BOW: - case WAND: - case ROD: - case HORN: - safe_strcat(buf[use_buf]," (readied)", &len, HUGE_BUF); - break; - case WEAPON: - safe_strcat(buf[use_buf]," (wielded)", &len, HUGE_BUF); - break; - case ARMOUR: - case HELMET: - case SHIELD: - case RING: - case BOOTS: - case GLOVES: - case AMULET: - case GIRDLE: - case BRACERS: - case CLOAK: - safe_strcat(buf[use_buf]," (worn)", &len, HUGE_BUF); - break; - case CONTAINER: - safe_strcat(buf[use_buf]," (active)", &len, HUGE_BUF); - break; - case SKILL: - default: - safe_strcat(buf[use_buf]," (applied)", &len, HUGE_BUF); - } + switch(op->type) { + case BOW: + case WAND: + case ROD: + case HORN: + safe_strcat(buf[use_buf]," (readied)", &len, HUGE_BUF); + break; + case WEAPON: + safe_strcat(buf[use_buf]," (wielded)", &len, HUGE_BUF); + break; + case ARMOUR: + case HELMET: + case SHIELD: + case RING: + case BOOTS: + case GLOVES: + case AMULET: + case GIRDLE: + case BRACERS: + case CLOAK: + safe_strcat(buf[use_buf]," (worn)", &len, HUGE_BUF); + break; + case CONTAINER: + safe_strcat(buf[use_buf]," (active)", &len, HUGE_BUF); + break; + case SKILL: + default: + safe_strcat(buf[use_buf]," (applied)", &len, HUGE_BUF); + } } if(QUERY_FLAG(op, FLAG_UNPAID)) - safe_strcat(buf[use_buf]," (unpaid)", &len, HUGE_BUF); + safe_strcat(buf[use_buf]," (unpaid)", &len, HUGE_BUF); return buf[use_buf]; } @@ -714,79 +714,79 @@ materialtype_t *mt; if((!plural && !op->name) || (plural && !op->name_pl)) - return "(null)"; + return "(null)"; if(!op->nrof && !op->weight && !op->title && !is_magical(op)) - return op->name; /* To speed things up (or make things slower?) */ + return op->name; /* To speed things up (or make things slower?) */ if ((IS_ARMOR(op) || IS_WEAPON(op)) && op->materialname) - mt = name_to_material(op->materialname); + mt = name_to_material(op->materialname); #ifdef NEW_MATERIAL_CODE if ((IS_ARMOR(op) || IS_WEAPON(op)) && op->materialname && mt && - op->arch->clone.materialname != mt->name && - !(op->material & M_SPECIAL)) { - strcpy(buf, mt->description); - len=strlen(buf); - safe_strcat(buf, " ", &len, MAX_BUF); - if (!plural) - safe_strcat(buf, op->name, &len, MAX_BUF); - else - safe_strcat(buf, op->name_pl, &len, MAX_BUF); + op->arch->clone.materialname != mt->name && + !(op->material & M_SPECIAL)) { + strcpy(buf, mt->description); + len=strlen(buf); + safe_strcat(buf, " ", &len, MAX_BUF); + if (!plural) + safe_strcat(buf, op->name, &len, MAX_BUF); + else + safe_strcat(buf, op->name_pl, &len, MAX_BUF); } else { #endif - if (!plural) - strcpy(buf, op->name); - else - strcpy(buf, op->name_pl); - len=strlen(buf); + if (!plural) + strcpy(buf, op->name); + else + strcpy(buf, op->name_pl); + len=strlen(buf); #ifdef NEW_MATERIAL_CODE } #endif if (op->title && QUERY_FLAG(op,FLAG_IDENTIFIED)) { - safe_strcat(buf, " ", &len, MAX_BUF); - safe_strcat(buf, op->title, &len, MAX_BUF); + safe_strcat(buf, " ", &len, MAX_BUF); + safe_strcat(buf, op->title, &len, MAX_BUF); } switch(op->type) { - case SPELLBOOK: - case SCROLL: - case WAND: - case ROD: - if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { - if(!op->title) { - safe_strcat(buf," of ", &len, MAX_BUF); - if (op->inv) - safe_strcat(buf,op->inv->name, &len, MAX_BUF); - else - LOG(llevError,"Spellbook %s lacks inventory\n", op->name); - } - if(op->type != SPELLBOOK) { - sprintf(buf2, " (lvl %d)", op->level); - safe_strcat(buf, buf2, &len, MAX_BUF); - } - } - break; + case SPELLBOOK: + case SCROLL: + case WAND: + case ROD: + if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { + if(!op->title) { + safe_strcat(buf," of ", &len, MAX_BUF); + if (op->inv) + safe_strcat(buf,op->inv->name, &len, MAX_BUF); + else + LOG(llevError,"Spellbook %s lacks inventory\n", op->name); + } + if(op->type != SPELLBOOK) { + sprintf(buf2, " (lvl %d)", op->level); + safe_strcat(buf, buf2, &len, MAX_BUF); + } + } + break; case SKILL: case AMULET: case RING: - if (!op->title) { - /* If ring has a title, full description isn't so useful */ - char *s = ring_desc(op); - if (s[0]) { - safe_strcat (buf, " ", &len, MAX_BUF); - safe_strcat (buf, s, &len, MAX_BUF); - } - } - break; + if (!op->title) { + /* If ring has a title, full description isn't so useful */ + char *s = ring_desc(op); + if (s[0]) { + safe_strcat (buf, " ", &len, MAX_BUF); + safe_strcat (buf, s, &len, MAX_BUF); + } + } + break; default: - if(op->magic && ((QUERY_FLAG(op,FLAG_BEEN_APPLIED) && - need_identify(op)) || QUERY_FLAG(op,FLAG_IDENTIFIED))) { - sprintf(buf + strlen(buf), " %+d", op->magic); - } + if(op->magic && ((QUERY_FLAG(op,FLAG_BEEN_APPLIED) && + need_identify(op)) || QUERY_FLAG(op,FLAG_IDENTIFIED))) { + sprintf(buf + strlen(buf), " %+d", op->magic); + } } return buf; } @@ -810,129 +810,129 @@ * fall into the 'lightning fast movement' category. */ if(FABS(op->speed)>MIN_ACTIVE_SPEED) { - switch((int)((FABS(op->speed))*15)) { - case 0: - strcat(retbuf,"(very slow movement)"); - break; - case 1: - strcat(retbuf,"(slow movement)"); - break; - case 2: - strcat(retbuf,"(normal movement)"); - break; - case 3: - case 4: - strcat(retbuf,"(fast movement)"); - break; - case 5: - case 6: - strcat(retbuf,"(very fast movement)"); - break; - case 7: - case 8: - case 9: - case 10: - strcat(retbuf,"(extremely fast movement)"); - break; - default: - strcat(retbuf,"(lightning fast movement)"); - break; - } + switch((int)((FABS(op->speed))*15)) { + case 0: + strcat(retbuf,"(very slow movement)"); + break; + case 1: + strcat(retbuf,"(slow movement)"); + break; + case 2: + strcat(retbuf,"(normal movement)"); + break; + case 3: + case 4: + strcat(retbuf,"(fast movement)"); + break; + case 5: + case 6: + strcat(retbuf,"(very fast movement)"); + break; + case 7: + case 8: + case 9: + case 10: + strcat(retbuf,"(extremely fast movement)"); + break; + default: + strcat(retbuf,"(lightning fast movement)"); + break; + } } if(QUERY_FLAG(op,FLAG_UNDEAD)) - strcat(retbuf,"(undead)"); + strcat(retbuf,"(undead)"); if(QUERY_FLAG(op,FLAG_SEE_INVISIBLE)) - strcat(retbuf,"(see invisible)"); + strcat(retbuf,"(see invisible)"); if(QUERY_FLAG(op,FLAG_USE_WEAPON)) - strcat(retbuf,"(wield weapon)"); + strcat(retbuf,"(wield weapon)"); if(QUERY_FLAG(op,FLAG_USE_BOW)) - strcat(retbuf,"(archer)"); + strcat(retbuf,"(archer)"); if(QUERY_FLAG(op,FLAG_USE_ARMOUR)) - strcat(retbuf,"(wear armour)"); + strcat(retbuf,"(wear armour)"); if(QUERY_FLAG(op,FLAG_USE_RING)) - strcat(retbuf,"(wear ring)"); + strcat(retbuf,"(wear ring)"); if(QUERY_FLAG(op,FLAG_USE_SCROLL)) - strcat(retbuf,"(read scroll)"); + strcat(retbuf,"(read scroll)"); if(QUERY_FLAG(op,FLAG_USE_RANGE)) - strcat(retbuf,"(fires wand/rod/horn)"); + strcat(retbuf,"(fires wand/rod/horn)"); if(QUERY_FLAG(op,FLAG_CAN_USE_SKILL)) - strcat(retbuf,"(skill user)"); + strcat(retbuf,"(skill user)"); if(QUERY_FLAG(op,FLAG_CAST_SPELL)) - strcat(retbuf,"(spellcaster)"); + strcat(retbuf,"(spellcaster)"); if(QUERY_FLAG(op,FLAG_FRIENDLY)) - strcat(retbuf,"(friendly)"); + strcat(retbuf,"(friendly)"); if(QUERY_FLAG(op,FLAG_UNAGGRESSIVE)) - strcat(retbuf,"(unaggressive)"); + strcat(retbuf,"(unaggressive)"); if(QUERY_FLAG(op,FLAG_HITBACK)) - strcat(retbuf,"(hitback)"); + strcat(retbuf,"(hitback)"); if(QUERY_FLAG(op,FLAG_STEALTH)) - strcat(retbuf,"(stealthy)"); + strcat(retbuf,"(stealthy)"); if(op->randomitems != NULL) { - treasure *t; - int first = 1; - for(t=op->randomitems->items; t != NULL; t=t->next) - if(t->item && (t->item->clone.type == SPELL)) { - if(first) { - first = 0; - strcat(retbuf,"(Spell abilities:)"); - } - strcat(retbuf,"("); - strcat(retbuf,t->item->clone.name); - strcat(retbuf,")"); - } + treasure *t; + int first = 1; + for(t=op->randomitems->items; t != NULL; t=t->next) + if(t->item && (t->item->clone.type == SPELL)) { + if(first) { + first = 0; + strcat(retbuf,"(Spell abilities:)"); + } + strcat(retbuf,"("); + strcat(retbuf,t->item->clone.name); + strcat(retbuf,")"); + } } if (op->type == PLAYER) { - if(op->contr->digestion) { - if(op->contr->digestion!=0) - sprintf(buf,"(sustenance%+d)",op->contr->digestion); - strcat(retbuf,buf); - } - if(op->contr->gen_grace) { - sprintf(buf,"(grace%+d)",op->contr->gen_grace); - strcat(retbuf,buf); - } - if(op->contr->gen_sp) { - sprintf(buf,"(magic%+d)",op->contr->gen_sp); - strcat(retbuf,buf); - } - if(op->contr->gen_hp) { - sprintf(buf,"(regeneration%+d)",op->contr->gen_hp); - strcat(retbuf,buf); - } - if(op->stats.luck) { - sprintf(buf,"(luck%+d)",op->stats.luck); - strcat(retbuf,buf); - } + if(op->contr->digestion) { + if(op->contr->digestion!=0) + sprintf(buf,"(sustenance%+d)",op->contr->digestion); + strcat(retbuf,buf); + } + if(op->contr->gen_grace) { + sprintf(buf,"(grace%+d)",op->contr->gen_grace); + strcat(retbuf,buf); + } + if(op->contr->gen_sp) { + sprintf(buf,"(magic%+d)",op->contr->gen_sp); + strcat(retbuf,buf); + } + if(op->contr->gen_hp) { + sprintf(buf,"(regeneration%+d)",op->contr->gen_hp); + strcat(retbuf,buf); + } + if(op->stats.luck) { + sprintf(buf,"(luck%+d)",op->stats.luck); + strcat(retbuf,buf); + } } /* describe attacktypes */ if (is_dragon_pl(op)) { - /* for dragon players display the attacktypes from clawing skill - * Break apart the for loop - move the comparison checking down - - * this makes it more readable. - */ - object *tmp; - - for (tmp=op->inv; tmp!=NULL; tmp=tmp->below) - if (tmp->type == SKILL && !strcmp(tmp->name, "clawing")) break; - - if (tmp && tmp->attacktype!=0) { - DESCRIBE_ABILITY(retbuf, tmp->attacktype, "Claws"); - } - else { - DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); - } + /* for dragon players display the attacktypes from clawing skill + * Break apart the for loop - move the comparison checking down - + * this makes it more readable. + */ + object *tmp; + + for (tmp=op->inv; tmp!=NULL; tmp=tmp->below) + if (tmp->type == SKILL && !strcmp(tmp->name, "clawing")) break; + + if (tmp && tmp->attacktype!=0) { + DESCRIBE_ABILITY(retbuf, tmp->attacktype, "Claws"); + } + else { + DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); + } } else { - DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); + DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); } DESCRIBE_PATH(retbuf, op->path_attuned, "Attuned"); DESCRIBE_PATH(retbuf, op->path_repelled, "Repelled"); DESCRIBE_PATH(retbuf, op->path_denied, "Denied"); for (i=0; i < NROFATTACKS; i++) { - if (op->resist[i]) { - sprintf(buf, "(%s %+d)", resist_plus[i], op->resist[i]); - strcat(retbuf, buf); - } + if (op->resist[i]) { + sprintf(buf, "(%s %+d)", resist_plus[i], op->resist[i]); + strcat(retbuf, buf); + } } return retbuf; } @@ -972,180 +972,180 @@ retbuf[0]='\0'; if(QUERY_FLAG(op,FLAG_MONSTER) || op->type==PLAYER) { - return describe_monster(op); + return describe_monster(op); } /* figure this out once, instead of making multiple calls to need_identify. * also makes the code easier to read. */ if (!need_identify(op) || QUERY_FLAG(op, FLAG_IDENTIFIED)) identified = 1; else { - strcpy(retbuf,"(unidentified)"); - identified = 0; + strcpy(retbuf,"(unidentified)"); + identified = 0; } switch(op->type) { - case BOW: - case ARROW: - case WAND: - case ROD: - case HORN: - case WEAPON: - case ARMOUR: - case HELMET: - case SHIELD: - case BOOTS: - case GLOVES: - case GIRDLE: - case BRACERS: - case CLOAK: - case SKILL_TOOL: - break; /* We have more information to do below this switch */ - - case POWER_CRYSTAL: - if (op->stats.maxsp>1000){ /*higher capacity crystals*/ - i = (op->stats.maxsp%100)/10; - if (i) - snprintf(buf,MAX_BUF,"(capacity %d.%dk). It is ",op->stats.maxsp/100,i); + case BOW: + case ARROW: + case WAND: + case ROD: + case HORN: + case WEAPON: + case ARMOUR: + case HELMET: + case SHIELD: + case BOOTS: + case GLOVES: + case GIRDLE: + case BRACERS: + case CLOAK: + case SKILL_TOOL: + break; /* We have more information to do below this switch */ + + case POWER_CRYSTAL: + if (op->stats.maxsp>1000){ /*higher capacity crystals*/ + i = (op->stats.maxsp%100)/10; + if (i) + snprintf(buf,MAX_BUF,"(capacity %d.%dk). It is ",op->stats.maxsp/100,i); else - snprintf(buf,MAX_BUF,"(capacity %dk). It is ",op->stats.maxsp/100); - }else - snprintf(buf,MAX_BUF,"(capacity %d). It is ",op->stats.maxsp); - strcat(retbuf,buf); - i = (op->stats.sp*10)/op->stats.maxsp; - if (op->stats.sp==0) - strcat(retbuf,"empty."); - else if (i==0) - strcat(retbuf,"almost empty."); - else if (i<3) - strcat(retbuf,"partially filled."); - else if (i<6) - strcat(retbuf,"half full."); - else if (i<9) - strcat(retbuf,"well charged."); - else if (op->stats.sp == op->stats.maxsp) - strcat(retbuf,"fully charged."); - else - strcat(retbuf,"almost full."); - break; - case FOOD: - case FLESH: - case DRINK: - if(identified || QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { - sprintf(buf,"(food+%d)", op->stats.food); - strcat(retbuf, buf); - - if (op->type == FLESH && op->last_eat>0 && atnr_is_dragon_enabled(op->last_eat)) { - sprintf(buf, "(%s metabolism)", change_resist_msg[op->last_eat]); - strcat(retbuf, buf); - } - - if (!QUERY_FLAG(op,FLAG_CURSED)) { - if (op->stats.hp) - strcat(retbuf,"(heals)"); - if (op->stats.sp) - strcat(retbuf,"(spellpoint regen)"); - } - else { - if (op->stats.hp) - strcat(retbuf,"(damages)"); - if (op->stats.sp) - strcat(retbuf,"(spellpoint depletion)"); - } - } - break; - - - case SKILL: - case RING: - case AMULET: - if(op->item_power) { - sprintf(buf,"(item_power %+d)",op->item_power); - strcat(retbuf,buf); - } - if (op->title) - strcat (retbuf, ring_desc(op)); - return retbuf; + snprintf(buf,MAX_BUF,"(capacity %dk). It is ",op->stats.maxsp/100); + }else + snprintf(buf,MAX_BUF,"(capacity %d). It is ",op->stats.maxsp); + strcat(retbuf,buf); + i = (op->stats.sp*10)/op->stats.maxsp; + if (op->stats.sp==0) + strcat(retbuf,"empty."); + else if (i==0) + strcat(retbuf,"almost empty."); + else if (i<3) + strcat(retbuf,"partially filled."); + else if (i<6) + strcat(retbuf,"half full."); + else if (i<9) + strcat(retbuf,"well charged."); + else if (op->stats.sp == op->stats.maxsp) + strcat(retbuf,"fully charged."); + else + strcat(retbuf,"almost full."); + break; + case FOOD: + case FLESH: + case DRINK: + if(identified || QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { + sprintf(buf,"(food+%d)", op->stats.food); + strcat(retbuf, buf); + + if (op->type == FLESH && op->last_eat>0 && atnr_is_dragon_enabled(op->last_eat)) { + sprintf(buf, "(%s metabolism)", change_resist_msg[op->last_eat]); + strcat(retbuf, buf); + } + + if (!QUERY_FLAG(op,FLAG_CURSED)) { + if (op->stats.hp) + strcat(retbuf,"(heals)"); + if (op->stats.sp) + strcat(retbuf,"(spellpoint regen)"); + } + else { + if (op->stats.hp) + strcat(retbuf,"(damages)"); + if (op->stats.sp) + strcat(retbuf,"(spellpoint depletion)"); + } + } + break; + + + case SKILL: + case RING: + case AMULET: + if(op->item_power) { + sprintf(buf,"(item_power %+d)",op->item_power); + strcat(retbuf,buf); + } + if (op->title) + strcat (retbuf, ring_desc(op)); + return retbuf; - default: - return retbuf; + default: + return retbuf; } /* Down here, we more further describe equipment type items. * only describe them if they have been identified or the like. */ if (identified || QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { - int attr,val; + int attr,val; - for (attr=0; attrstats),attr))!=0) { - sprintf(buf, "(%s%+d)", short_stat_name[attr], val); - strcat(retbuf,buf); - } - } - - if(op->stats.exp) { - sprintf(buf,"(speed %+lld)",op->stats.exp); - strcat(retbuf,buf); - } - - - switch(op->type) { - case BOW: - case ARROW: - case GIRDLE: - case HELMET: - case SHIELD: - case BOOTS: - case GLOVES: - case WEAPON: - case SKILL: - case RING: - case AMULET: - case ARMOUR: - case BRACERS: - case FORCE: - case CLOAK: - if(op->stats.wc) { - sprintf(buf,"(wc%+d)",op->stats.wc); - strcat(retbuf,buf); - } - if(op->stats.dam) { - sprintf(buf,"(dam%+d)",op->stats.dam); - strcat(retbuf,buf); - } - if(op->stats.ac) { - sprintf(buf,"(ac%+d)",op->stats.ac); - strcat(retbuf,buf); - } - if ((op->type==WEAPON || op->type == BOW) && op->level>0) { - sprintf(buf,"(improved %d/%d)",op->last_eat,op->level); - strcat(retbuf,buf); - } - break; - - default: - break; - } - if(QUERY_FLAG(op,FLAG_XRAYS)) - strcat(retbuf,"(xray-vision)"); - if(QUERY_FLAG(op,FLAG_SEE_IN_DARK)) - strcat(retbuf,"(infravision)"); - - /* levitate was what is was before, so we'll keep it */ - if (op->move_type & MOVE_FLY_LOW) - strcat(retbuf,"(levitate)"); - - if (op->move_type & MOVE_FLY_HIGH) - strcat(retbuf,"(fly)"); - - if (op->move_type & MOVE_SWIM) - strcat(retbuf,"(swim)"); - - /* walking is presumed as 'normal', so doesn't need mentioning */ - - if(op->item_power) { - sprintf(buf,"(item_power %+d)",op->item_power); - strcat(retbuf,buf); - } + for (attr=0; attrstats),attr))!=0) { + sprintf(buf, "(%s%+d)", short_stat_name[attr], val); + strcat(retbuf,buf); + } + } + + if(op->stats.exp) { + sprintf(buf,"(speed %+lld)",op->stats.exp); + strcat(retbuf,buf); + } + + + switch(op->type) { + case BOW: + case ARROW: + case GIRDLE: + case HELMET: + case SHIELD: + case BOOTS: + case GLOVES: + case WEAPON: + case SKILL: + case RING: + case AMULET: + case ARMOUR: + case BRACERS: + case FORCE: + case CLOAK: + if(op->stats.wc) { + sprintf(buf,"(wc%+d)",op->stats.wc); + strcat(retbuf,buf); + } + if(op->stats.dam) { + sprintf(buf,"(dam%+d)",op->stats.dam); + strcat(retbuf,buf); + } + if(op->stats.ac) { + sprintf(buf,"(ac%+d)",op->stats.ac); + strcat(retbuf,buf); + } + if ((op->type==WEAPON || op->type == BOW) && op->level>0) { + sprintf(buf,"(improved %d/%d)",op->last_eat,op->level); + strcat(retbuf,buf); + } + break; + + default: + break; + } + if(QUERY_FLAG(op,FLAG_XRAYS)) + strcat(retbuf,"(xray-vision)"); + if(QUERY_FLAG(op,FLAG_SEE_IN_DARK)) + strcat(retbuf,"(infravision)"); + + /* levitate was what is was before, so we'll keep it */ + if (op->move_type & MOVE_FLY_LOW) + strcat(retbuf,"(levitate)"); + + if (op->move_type & MOVE_FLY_HIGH) + strcat(retbuf,"(fly)"); + + if (op->move_type & MOVE_SWIM) + strcat(retbuf,"(swim)"); + + /* walking is presumed as 'normal', so doesn't need mentioning */ + + if(op->item_power) { + sprintf(buf,"(item_power %+d)",op->item_power); + strcat(retbuf,buf); + } } /* End if identified or applied */ /* This blocks only deals with fully identified object. @@ -1153,98 +1153,98 @@ * in this way, information is added. */ if(identified) { - int more_info = 0; + int more_info = 0; - switch(op->type) { - case ROD: /* These use stats.sp for spell selection and stats.food */ - case HORN: /* and stats.hp for spell-point regeneration... */ - case BOW: - case ARROW: - case WAND: - case FOOD: - case FLESH: - case DRINK: - more_info = 0; - break; - - /* Armor type objects */ - case ARMOUR: - case HELMET: - case SHIELD: - case BOOTS: - case GLOVES: - case GIRDLE: - case BRACERS: - case CLOAK: - if (ARMOUR_SPEED(op)) { - sprintf(buf,"(Max speed %1.2f)", ARMOUR_SPEED(op) / 10.0); - strcat(retbuf, buf); - } - if (ARMOUR_SPELLS(op)) { - sprintf(buf,"(Spell regen penalty %d)", ARMOUR_SPELLS(op)); - strcat(retbuf, buf); - } - more_info=1; - break; - - case WEAPON: - /* Calculate it the same way fix_player does so the results - * make sense. - */ - i = (WEAPON_SPEED(op)*2-op->magic)/2; - if (i<0) i=0; - - sprintf(buf,"(weapon speed %d)", i); - strcat(retbuf, buf); - more_info=1; - break; - - } - if (more_info) { - if(op->stats.food) { - if(op->stats.food!=0) - sprintf(buf,"(sustenance%+d)",op->stats.food); - strcat(retbuf,buf); - } - if(op->stats.grace) { - sprintf(buf,"(grace%+d)",op->stats.grace); - strcat(retbuf,buf); - } - if(op->stats.sp) { - sprintf(buf,"(magic%+d)",op->stats.sp); - strcat(retbuf,buf); - } - if(op->stats.hp) { - sprintf(buf,"(regeneration%+d)",op->stats.hp); - strcat(retbuf,buf); - } - } - - if(op->stats.luck) { - sprintf(buf,"(luck%+d)",op->stats.luck); - strcat(retbuf,buf); - } - if(QUERY_FLAG(op,FLAG_LIFESAVE)) - strcat(retbuf,"(lifesaving)"); - if(QUERY_FLAG(op,FLAG_REFL_SPELL)) - strcat(retbuf,"(reflect spells)"); - if(QUERY_FLAG(op,FLAG_REFL_MISSILE)) - strcat(retbuf,"(reflect missiles)"); - if(QUERY_FLAG(op,FLAG_STEALTH)) - strcat(retbuf,"(stealth)"); - if(op->slaying!=NULL && op->type != FOOD) { - sprintf(buf,"(slay %s)",op->slaying); - strcat(retbuf,buf); - } - DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); - /* resistance on flesh is only visible for quetzals. If - * non flesh, everyone can see its resistances - */ - if (op->type != FLESH || (owner && is_dragon_pl(owner))) - strcat(retbuf,describe_resistance(op, 0)); - DESCRIBE_PATH(retbuf, op->path_attuned, "Attuned"); - DESCRIBE_PATH(retbuf, op->path_repelled, "Repelled"); - DESCRIBE_PATH(retbuf, op->path_denied, "Denied"); + switch(op->type) { + case ROD: /* These use stats.sp for spell selection and stats.food */ + case HORN: /* and stats.hp for spell-point regeneration... */ + case BOW: + case ARROW: + case WAND: + case FOOD: + case FLESH: + case DRINK: + more_info = 0; + break; + + /* Armor type objects */ + case ARMOUR: + case HELMET: + case SHIELD: + case BOOTS: + case GLOVES: + case GIRDLE: + case BRACERS: + case CLOAK: + if (ARMOUR_SPEED(op)) { + sprintf(buf,"(Max speed %1.2f)", ARMOUR_SPEED(op) / 10.0); + strcat(retbuf, buf); + } + if (ARMOUR_SPELLS(op)) { + sprintf(buf,"(Spell regen penalty %d)", ARMOUR_SPELLS(op)); + strcat(retbuf, buf); + } + more_info=1; + break; + + case WEAPON: + /* Calculate it the same way fix_player does so the results + * make sense. + */ + i = (WEAPON_SPEED(op)*2-op->magic)/2; + if (i<0) i=0; + + sprintf(buf,"(weapon speed %d)", i); + strcat(retbuf, buf); + more_info=1; + break; + + } + if (more_info) { + if(op->stats.food) { + if(op->stats.food!=0) + sprintf(buf,"(sustenance%+d)",op->stats.food); + strcat(retbuf,buf); + } + if(op->stats.grace) { + sprintf(buf,"(grace%+d)",op->stats.grace); + strcat(retbuf,buf); + } + if(op->stats.sp) { + sprintf(buf,"(magic%+d)",op->stats.sp); + strcat(retbuf,buf); + } + if(op->stats.hp) { + sprintf(buf,"(regeneration%+d)",op->stats.hp); + strcat(retbuf,buf); + } + } + + if(op->stats.luck) { + sprintf(buf,"(luck%+d)",op->stats.luck); + strcat(retbuf,buf); + } + if(QUERY_FLAG(op,FLAG_LIFESAVE)) + strcat(retbuf,"(lifesaving)"); + if(QUERY_FLAG(op,FLAG_REFL_SPELL)) + strcat(retbuf,"(reflect spells)"); + if(QUERY_FLAG(op,FLAG_REFL_MISSILE)) + strcat(retbuf,"(reflect missiles)"); + if(QUERY_FLAG(op,FLAG_STEALTH)) + strcat(retbuf,"(stealth)"); + if(op->slaying!=NULL && op->type != FOOD) { + sprintf(buf,"(slay %s)",op->slaying); + strcat(retbuf,buf); + } + DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); + /* resistance on flesh is only visible for quetzals. If + * non flesh, everyone can see its resistances + */ + if (op->type != FLESH || (owner && is_dragon_pl(owner))) + strcat(retbuf,describe_resistance(op, 0)); + DESCRIBE_PATH(retbuf, op->path_attuned, "Attuned"); + DESCRIBE_PATH(retbuf, op->path_repelled, "Repelled"); + DESCRIBE_PATH(retbuf, op->path_denied, "Denied"); } return retbuf; @@ -1270,20 +1270,20 @@ * values, it means they are magical. */ if ((op->type==AMULET || op->type==RING) && - (op->stats.ac || op->stats.food || op->stats.exp || op->stats.dam || - op->stats.wc || op->stats.sp || op->stats.hp || op->stats.luck)) - return 1; + (op->stats.ac || op->stats.food || op->stats.exp || op->stats.dam || + op->stats.wc || op->stats.sp || op->stats.hp || op->stats.luck)) + return 1; /* Check for stealty, speed, flying, or just plain magic in the boots */ /* Presume any boots that hvae a move_type are special. */ if (op->type== BOOTS && - ((QUERY_FLAG(op, FLAG_STEALTH) || op->move_type || op->stats.exp))) - return 1; + ((QUERY_FLAG(op, FLAG_STEALTH) || op->move_type || op->stats.exp))) + return 1; /* Take care of amulet/shield that reflects spells/missiles */ if ((op->type==AMULET || op->type==SHIELD) && - (QUERY_FLAG(op, FLAG_REFL_SPELL) || QUERY_FLAG(op, FLAG_REFL_MISSILE))) - return 1; + (QUERY_FLAG(op, FLAG_REFL_SPELL) || QUERY_FLAG(op, FLAG_REFL_MISSILE))) + return 1; /* Take care of helmet of xrays */ if (op->type==HELMET && QUERY_FLAG(op,FLAG_XRAYS)) return 1; @@ -1292,30 +1292,30 @@ * assuming they still have any charges left. */ if (op->type==POTION || op->type==ROD || - (op->type==WAND && op->stats.food)) - return 1; + (op->type==WAND && op->stats.food)) + return 1; /* if something gives a protection, either positive or negative, its magical */ /* This is really a pretty bad hack - as of now, ATNR_PHYSICAL is 0, * so this always works out fine. */ for (i=ATNR_PHYSICAL+1; iresist[i]) return 1; + if (op->resist[i]) return 1; /* Physical protection is expected on some item types, so they should * not be considered magical. */ if (op->resist[ATNR_PHYSICAL] && op->type != HELMET && op->type != SHIELD && - op->type != BOOTS && op->type != GLOVES && op->type != ARMOUR) return 1; - + op->type != BOOTS && op->type != GLOVES && op->type != ARMOUR) return 1; + /* power crystal, spellbooks, and scrolls are always magical. */ if (op->magic || op->type==POWER_CRYSTAL || op->type==SPELLBOOK || - op->type==SCROLL || op->type==GIRDLE) - return 1; + op->type==SCROLL || op->type==GIRDLE) + return 1; /* Check to see if it increases/decreases any stats */ for (i=0; istats),i)!=0) return 1; + if (get_attr_value(&(op->stats),i)!=0) return 1; /* If it doesn't fall into any of the above categories, must * be non magical. @@ -1330,39 +1330,39 @@ int need_identify(const object *op) { switch(op->type) { - case RING: - case WAND: - case ROD: - case HORN: - case SCROLL: - case SKILL: - case SKILLSCROLL: - case SPELLBOOK: - case FOOD: - case POTION: - case BOW: - case ARROW: - case WEAPON: - case ARMOUR: - case SHIELD: - case HELMET: - case AMULET: - case BOOTS: - case GLOVES: - case BRACERS: - case GIRDLE: - case CONTAINER: - case DRINK: - case FLESH: - case INORGANIC: - case CLOSE_CON: - case CLOAK: - case GEM: - case POWER_CRYSTAL: - case POISON: - case BOOK: - case SKILL_TOOL: - return 1; + case RING: + case WAND: + case ROD: + case HORN: + case SCROLL: + case SKILL: + case SKILLSCROLL: + case SPELLBOOK: + case FOOD: + case POTION: + case BOW: + case ARROW: + case WEAPON: + case ARMOUR: + case SHIELD: + case HELMET: + case AMULET: + case BOOTS: + case GLOVES: + case BRACERS: + case GIRDLE: + case CONTAINER: + case DRINK: + case FLESH: + case INORGANIC: + case CLOSE_CON: + case CLOAK: + case GEM: + case POWER_CRYSTAL: + case POISON: + case BOOK: + case SKILL_TOOL: + return 1; } /* Try to track down some stuff that may show up here. Thus, the * archetype file can be updated, and this function removed. @@ -1389,29 +1389,29 @@ * We want autojoining of equal objects: */ if (QUERY_FLAG(op,FLAG_CURSED) || QUERY_FLAG(op,FLAG_DAMNED)) - SET_FLAG(op,FLAG_KNOWN_CURSED); + SET_FLAG(op,FLAG_KNOWN_CURSED); if (op->type == POTION) { - if (op->inv && op->randomitems) { - if (op->title) free_string(op->title); - op->title = add_refcount(op->inv->name); - } else if (op->arch) { - free_string(op->name); - op->name = add_refcount(op->arch->clone.name); - free_string(op->name_pl); - op->name_pl = add_refcount(op->arch->clone.name_pl); - } + if (op->inv && op->randomitems) { + if (op->title) free_string(op->title); + op->title = add_refcount(op->inv->name); + } else if (op->arch) { + free_string(op->name); + op->name = add_refcount(op->arch->clone.name); + free_string(op->name_pl); + op->name_pl = add_refcount(op->arch->clone.name_pl); + } } /* If the object is on a map, make sure we update its face */ if (op->map) - update_object(op,UP_OBJ_FACE); + update_object(op,UP_OBJ_FACE); else { - pl = is_player_inv(op->env); - if (pl) - /* A lot of the values can change from an update - might as well send - * it all. - */ - esrv_send_item(pl, op); + pl = is_player_inv(op->env); + if (pl) + /* A lot of the values can change from an update - might as well send + * it all. + */ + esrv_send_item(pl, op); } }