1 | /* |
1 | /* |
2 | * static char *rcsid_item_c = |
2 | * static char *rcsid_item_c = |
3 | * "$Id: item.C,v 1.1 2006/08/13 17:16:00 elmex Exp $"; |
3 | * "$Id: item.C,v 1.2 2006/08/29 08:01:35 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
282 | { |
282 | { |
283 | int i, tmp, enc; |
283 | int i, tmp, enc; |
284 | |
284 | |
285 | enc = 0; |
285 | enc = 0; |
286 | for (i=0; i<NUM_STATS; i++) |
286 | for (i=0; i<NUM_STATS; i++) |
287 | enc += get_attr_value(&op->stats, i); |
287 | enc += get_attr_value(&op->stats, i); |
288 | |
288 | |
289 | /* This protection logic is pretty flawed. 20% fire resistance |
289 | /* This protection logic is pretty flawed. 20% fire resistance |
290 | * is much more valuable than 20% confusion, or 20% slow, or |
290 | * is much more valuable than 20% confusion, or 20% slow, or |
291 | * several others. Start at 1 - ignore physical - all that normal |
291 | * several others. Start at 1 - ignore physical - all that normal |
292 | * armour shouldn't be counted against |
292 | * armour shouldn't be counted against |
293 | */ |
293 | */ |
294 | tmp = 0; |
294 | tmp = 0; |
295 | for (i=1; i<NROFATTACKS; i++) |
295 | for (i=1; i<NROFATTACKS; i++) |
296 | tmp += op->resist[i]; |
296 | tmp += op->resist[i]; |
297 | |
297 | |
298 | /* Add/substract 10 so that the rounding works out right */ |
298 | /* Add/substract 10 so that the rounding works out right */ |
299 | if (tmp>0) enc += (tmp+10)/20; |
299 | if (tmp>0) enc += (tmp+10)/20; |
300 | else if (tmp<0) enc += (tmp - 10) / 20; |
300 | else if (tmp<0) enc += (tmp - 10) / 20; |
301 | |
301 | |
… | |
… | |
303 | |
303 | |
304 | /* For each attacktype a weapon has, one more encantment. Start at 1 - |
304 | /* For each attacktype a weapon has, one more encantment. Start at 1 - |
305 | * physical doesn't count against total. |
305 | * physical doesn't count against total. |
306 | */ |
306 | */ |
307 | if (op->type == WEAPON) { |
307 | if (op->type == WEAPON) { |
308 | for (i=1; i<NROFATTACKS; i++) |
308 | for (i=1; i<NROFATTACKS; i++) |
309 | if (op->attacktype & (1 << i)) enc++; |
309 | if (op->attacktype & (1 << i)) enc++; |
310 | if (op->slaying) enc += 2; /* What it slays is probably more relevent */ |
310 | if (op->slaying) enc += 2; /* What it slays is probably more relevent */ |
311 | } |
311 | } |
312 | /* Items the player can equip */ |
312 | /* Items the player can equip */ |
313 | if ((op->type == WEAPON) || (op->type == ARMOUR) || (op->type == HELMET) || |
313 | if ((op->type == WEAPON) || (op->type == ARMOUR) || (op->type == HELMET) || |
314 | (op->type == SHIELD) || (op->type == RING) || |
314 | (op->type == SHIELD) || (op->type == RING) || |
315 | (op->type == BOOTS) || (op->type == GLOVES) || |
315 | (op->type == BOOTS) || (op->type == GLOVES) || |
316 | (op->type == AMULET ) || (op->type == GIRDLE) || |
316 | (op->type == AMULET ) || (op->type == GIRDLE) || |
317 | (op->type == BRACERS ) || (op->type == CLOAK)) { |
317 | (op->type == BRACERS ) || (op->type == CLOAK)) { |
318 | enc += op->stats.food; /* sustenance */ |
318 | enc += op->stats.food; /* sustenance */ |
319 | enc += op->stats.hp; /* hp regen */ |
319 | enc += op->stats.hp; /* hp regen */ |
320 | enc += op->stats.sp; /* mana regen */ |
320 | enc += op->stats.sp; /* mana regen */ |
321 | enc += op->stats.grace; /* grace regen */ |
321 | enc += op->stats.grace; /* grace regen */ |
322 | enc += op->stats.exp; /* speed bonus */ |
322 | enc += op->stats.exp; /* speed bonus */ |
323 | } |
323 | } |
324 | enc += op->stats.luck; |
324 | enc += op->stats.luck; |
325 | |
325 | |
326 | /* Do spell paths now */ |
326 | /* Do spell paths now */ |
327 | for (i=1; i<NRSPELLPATHS; i++) { |
327 | for (i=1; i<NRSPELLPATHS; i++) { |
328 | if (op->path_attuned& (1 << i)) enc++; |
328 | if (op->path_attuned& (1 << i)) enc++; |
329 | else if (op->path_denied & (1 << i)) enc-=2; |
329 | else if (op->path_denied & (1 << i)) enc-=2; |
330 | else if (op->path_repelled & (1 << i)) enc--; |
330 | else if (op->path_repelled & (1 << i)) enc--; |
331 | } |
331 | } |
332 | |
332 | |
333 | if(QUERY_FLAG(op,FLAG_LIFESAVE)) enc += 5; |
333 | if(QUERY_FLAG(op,FLAG_LIFESAVE)) enc += 5; |
334 | if(QUERY_FLAG(op,FLAG_REFL_SPELL)) enc += 3; |
334 | if(QUERY_FLAG(op,FLAG_REFL_SPELL)) enc += 3; |
335 | if(QUERY_FLAG(op,FLAG_REFL_MISSILE)) enc += 2; |
335 | if(QUERY_FLAG(op,FLAG_REFL_MISSILE)) enc += 2; |
… | |
… | |
346 | * isn't one, returns NULL */ |
346 | * isn't one, returns NULL */ |
347 | |
347 | |
348 | const typedata *get_typedata(int itemtype) { |
348 | const typedata *get_typedata(int itemtype) { |
349 | int i; |
349 | int i; |
350 | for (i=0;i<item_types_size;i++) |
350 | for (i=0;i<item_types_size;i++) |
351 | if (item_types[i].number==itemtype) return &item_types[i]; |
351 | if (item_types[i].number==itemtype) return &item_types[i]; |
352 | return NULL; |
352 | return NULL; |
353 | } |
353 | } |
354 | |
354 | |
355 | /* returns the typedata that has a name equal to itemtype, if there |
355 | /* returns the typedata that has a name equal to itemtype, if there |
356 | * isn't one, return the plural name that matches, if there still isn't |
356 | * isn't one, return the plural name that matches, if there still isn't |
357 | * one return NULL */ |
357 | * one return NULL */ |
358 | |
358 | |
359 | const typedata *get_typedata_by_name(const char *name) { |
359 | const typedata *get_typedata_by_name(const char *name) { |
360 | int i; |
360 | int i; |
361 | for (i=0;i<item_types_size;i++) |
361 | for (i=0;i<item_types_size;i++) |
362 | if (!strcmp(item_types[i].name, name)) return &item_types[i]; |
362 | if (!strcmp(item_types[i].name, name)) return &item_types[i]; |
363 | for (i=0;i<item_types_size;i++) |
363 | for (i=0;i<item_types_size;i++) |
364 | if (!strcmp(item_types[i].name_pl, name)) { |
364 | if (!strcmp(item_types[i].name_pl, name)) { |
365 | LOG(llevInfo, |
365 | LOG(llevInfo, |
366 | "get_typedata_by_name: I have been sent the plural %s, the singular form %s is preffered\n", |
366 | "get_typedata_by_name: I have been sent the plural %s, the singular form %s is preffered\n", |
367 | name, item_types[i].name); |
367 | name, item_types[i].name); |
368 | return &item_types[i]; |
368 | return &item_types[i]; |
369 | } |
369 | } |
370 | return NULL; |
370 | return NULL; |
371 | } |
371 | } |
372 | /* describe_resistance generates the visible naming for resistances. |
372 | /* describe_resistance generates the visible naming for resistances. |
373 | * returns a static array of the description. This can return |
373 | * returns a static array of the description. This can return |
374 | * a big buffer. |
374 | * a big buffer. |
… | |
… | |
382 | int tmpvar; |
382 | int tmpvar; |
383 | |
383 | |
384 | buf[0]=0; |
384 | buf[0]=0; |
385 | for (tmpvar=0; tmpvar<NROFATTACKS; tmpvar++) { |
385 | for (tmpvar=0; tmpvar<NROFATTACKS; tmpvar++) { |
386 | if (op->resist[tmpvar] && (op->type != FLESH || atnr_is_dragon_enabled(tmpvar)==1)) { |
386 | if (op->resist[tmpvar] && (op->type != FLESH || atnr_is_dragon_enabled(tmpvar)==1)) { |
387 | if (!newline) |
387 | if (!newline) |
388 | sprintf(buf1,"(%s %+d)", resist_plus[tmpvar], op->resist[tmpvar]); |
388 | sprintf(buf1,"(%s %+d)", resist_plus[tmpvar], op->resist[tmpvar]); |
389 | else |
389 | else |
390 | sprintf(buf1,"%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]); |
390 | sprintf(buf1,"%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]); |
391 | |
391 | |
392 | strcat(buf, buf1); |
392 | strcat(buf, buf1); |
393 | } |
393 | } |
394 | } |
394 | } |
395 | return buf; |
395 | return buf; |
396 | } |
396 | } |
397 | |
397 | |
… | |
… | |
471 | int attr, val,len; |
471 | int attr, val,len; |
472 | |
472 | |
473 | buf[0] = 0; |
473 | buf[0] = 0; |
474 | |
474 | |
475 | if (! QUERY_FLAG(op, FLAG_IDENTIFIED)) |
475 | if (! QUERY_FLAG(op, FLAG_IDENTIFIED)) |
476 | return buf; |
476 | return buf; |
477 | |
477 | |
478 | for (attr=0; attr<NUM_STATS; attr++) { |
478 | for (attr=0; attr<NUM_STATS; attr++) { |
479 | if ((val=get_attr_value(&(op->stats),attr))!=0) { |
479 | if ((val=get_attr_value(&(op->stats),attr))!=0) { |
480 | sprintf (buf+strlen(buf), "(%s%+d)", short_stat_name[attr], val); |
480 | sprintf (buf+strlen(buf), "(%s%+d)", short_stat_name[attr], val); |
481 | } |
481 | } |
482 | } |
482 | } |
483 | if(op->stats.exp) |
483 | if(op->stats.exp) |
484 | sprintf(buf+strlen(buf), "(speed %+lld)", op->stats.exp); |
484 | sprintf(buf+strlen(buf), "(speed %+lld)", op->stats.exp); |
485 | if(op->stats.wc) |
485 | if(op->stats.wc) |
486 | sprintf(buf+strlen(buf), "(wc%+d)", op->stats.wc); |
486 | sprintf(buf+strlen(buf), "(wc%+d)", op->stats.wc); |
487 | if(op->stats.dam) |
487 | if(op->stats.dam) |
488 | sprintf(buf+strlen(buf), "(dam%+d)", op->stats.dam); |
488 | sprintf(buf+strlen(buf), "(dam%+d)", op->stats.dam); |
489 | if(op->stats.ac) |
489 | if(op->stats.ac) |
490 | sprintf(buf+strlen(buf), "(ac%+d)", op->stats.ac); |
490 | sprintf(buf+strlen(buf), "(ac%+d)", op->stats.ac); |
491 | |
491 | |
492 | strcat(buf,describe_resistance(op, 0)); |
492 | strcat(buf,describe_resistance(op, 0)); |
493 | |
493 | |
494 | if (op->stats.food != 0) |
494 | if (op->stats.food != 0) |
495 | sprintf(buf+strlen(buf), "(sustenance%+d)", op->stats.food); |
495 | sprintf(buf+strlen(buf), "(sustenance%+d)", op->stats.food); |
496 | /* else if (op->stats.food < 0) |
496 | /* else if (op->stats.food < 0) |
497 | sprintf(buf+strlen(buf), "(hunger%+d)", op->stats.food); */ |
497 | sprintf(buf+strlen(buf), "(hunger%+d)", op->stats.food); */ |
498 | if(op->stats.grace) |
498 | if(op->stats.grace) |
499 | sprintf(buf+strlen(buf), "(grace%+d)", op->stats.grace); |
499 | sprintf(buf+strlen(buf), "(grace%+d)", op->stats.grace); |
500 | if(op->stats.sp && op->type!=SKILL) |
500 | if(op->stats.sp && op->type!=SKILL) |
501 | sprintf(buf+strlen(buf), "(magic%+d)", op->stats.sp); |
501 | sprintf(buf+strlen(buf), "(magic%+d)", op->stats.sp); |
502 | if(op->stats.hp) |
502 | if(op->stats.hp) |
503 | sprintf(buf+strlen(buf), "(regeneration%+d)", op->stats.hp); |
503 | sprintf(buf+strlen(buf), "(regeneration%+d)", op->stats.hp); |
504 | if(op->stats.luck) |
504 | if(op->stats.luck) |
505 | sprintf(buf+strlen(buf), "(luck%+d)", op->stats.luck); |
505 | sprintf(buf+strlen(buf), "(luck%+d)", op->stats.luck); |
506 | if(QUERY_FLAG(op,FLAG_LIFESAVE)) |
506 | if(QUERY_FLAG(op,FLAG_LIFESAVE)) |
507 | strcat(buf,"(lifesaving)"); |
507 | strcat(buf,"(lifesaving)"); |
508 | if(QUERY_FLAG(op,FLAG_REFL_SPELL)) |
508 | if(QUERY_FLAG(op,FLAG_REFL_SPELL)) |
509 | strcat(buf,"(reflect spells)"); |
509 | strcat(buf,"(reflect spells)"); |
510 | if(QUERY_FLAG(op,FLAG_REFL_MISSILE)) |
510 | if(QUERY_FLAG(op,FLAG_REFL_MISSILE)) |
511 | strcat(buf,"(reflect missiles)"); |
511 | strcat(buf,"(reflect missiles)"); |
512 | if(QUERY_FLAG(op,FLAG_STEALTH)) |
512 | if(QUERY_FLAG(op,FLAG_STEALTH)) |
513 | strcat(buf,"(stealth)"); |
513 | strcat(buf,"(stealth)"); |
514 | /* Shorten some of the names, so they appear better in the windows */ |
514 | /* Shorten some of the names, so they appear better in the windows */ |
515 | len=strlen(buf); |
515 | len=strlen(buf); |
516 | DESCRIBE_PATH_SAFE(buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF); |
516 | DESCRIBE_PATH_SAFE(buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF); |
517 | DESCRIBE_PATH_SAFE(buf, op->path_repelled, "Repelled", &len, VERY_BIG_BUF); |
517 | DESCRIBE_PATH_SAFE(buf, op->path_repelled, "Repelled", &len, VERY_BIG_BUF); |
518 | DESCRIBE_PATH_SAFE(buf, op->path_denied, "Denied", &len, VERY_BIG_BUF); |
518 | DESCRIBE_PATH_SAFE(buf, op->path_denied, "Denied", &len, VERY_BIG_BUF); |
519 | |
519 | |
520 | /* if(op->item_power) |
520 | /* if(op->item_power) |
521 | sprintf(buf+strlen(buf), "(item_power %+d)",op->item_power); |
521 | sprintf(buf+strlen(buf), "(item_power %+d)",op->item_power); |
522 | */ |
522 | */ |
523 | if(buf[0] == 0 && op->type!=SKILL) |
523 | if(buf[0] == 0 && op->type!=SKILL) |
524 | strcpy(buf,"of adornment"); |
524 | strcpy(buf,"of adornment"); |
525 | |
525 | |
526 | |
526 | |
527 | return buf; |
527 | return buf; |
528 | } |
528 | } |
529 | |
529 | |
… | |
… | |
536 | static char buf[HUGE_BUF]; |
536 | static char buf[HUGE_BUF]; |
537 | char buf2[HUGE_BUF]; |
537 | char buf2[HUGE_BUF]; |
538 | int len=0; |
538 | int len=0; |
539 | |
539 | |
540 | if(op->name == NULL) |
540 | if(op->name == NULL) |
541 | return "(null)"; |
541 | return "(null)"; |
542 | if(!op->nrof && !op->weight && !op->title && !is_magical(op)) |
542 | if(!op->nrof && !op->weight && !op->title && !is_magical(op)) |
543 | return op->name; /* To speed things up (or make things slower?) */ |
543 | return op->name; /* To speed things up (or make things slower?) */ |
544 | |
544 | |
545 | if (op->nrof <= 1) |
545 | if (op->nrof <= 1) |
546 | safe_strcat(buf,op->name, &len, HUGE_BUF); |
546 | safe_strcat(buf,op->name, &len, HUGE_BUF); |
547 | else |
547 | else |
548 | safe_strcat(buf,op->name_pl, &len, HUGE_BUF); |
548 | safe_strcat(buf,op->name_pl, &len, HUGE_BUF); |
549 | |
549 | |
550 | if (op->title && QUERY_FLAG(op,FLAG_IDENTIFIED)) { |
550 | if (op->title && QUERY_FLAG(op,FLAG_IDENTIFIED)) { |
551 | safe_strcat(buf, " ", &len, HUGE_BUF); |
551 | safe_strcat(buf, " ", &len, HUGE_BUF); |
552 | safe_strcat(buf, op->title, &len, HUGE_BUF); |
552 | safe_strcat(buf, op->title, &len, HUGE_BUF); |
553 | } |
553 | } |
554 | |
554 | |
555 | switch(op->type) { |
555 | switch(op->type) { |
556 | case SPELLBOOK: |
556 | case SPELLBOOK: |
557 | case SCROLL: |
557 | case SCROLL: |
558 | case WAND: |
558 | case WAND: |
559 | case ROD: |
559 | case ROD: |
560 | if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { |
560 | if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { |
561 | if(!op->title) { |
561 | if(!op->title) { |
562 | safe_strcat(buf," of ", &len, HUGE_BUF); |
562 | safe_strcat(buf," of ", &len, HUGE_BUF); |
563 | if (op->inv) |
563 | if (op->inv) |
564 | safe_strcat(buf,op->inv->name, &len, HUGE_BUF); |
564 | safe_strcat(buf,op->inv->name, &len, HUGE_BUF); |
565 | else |
565 | else |
566 | LOG(llevError,"Spellbook %s lacks inventory\n", op->name); |
566 | LOG(llevError,"Spellbook %s lacks inventory\n", op->name); |
567 | } |
567 | } |
568 | if(op->type != SPELLBOOK) { |
568 | if(op->type != SPELLBOOK) { |
569 | sprintf(buf2, " (lvl %d)", op->level); |
569 | sprintf(buf2, " (lvl %d)", op->level); |
570 | safe_strcat(buf, buf2, &len, HUGE_BUF); |
570 | safe_strcat(buf, buf2, &len, HUGE_BUF); |
571 | } |
571 | } |
572 | } |
572 | } |
573 | break; |
573 | break; |
574 | |
574 | |
575 | case SKILL: |
575 | case SKILL: |
576 | case AMULET: |
576 | case AMULET: |
577 | case RING: |
577 | case RING: |
578 | if (!op->title) { |
578 | if (!op->title) { |
579 | /* If ring has a title, full description isn't so useful */ |
579 | /* If ring has a title, full description isn't so useful */ |
580 | char *s = ring_desc(op); |
580 | char *s = ring_desc(op); |
581 | if (s[0]) { |
581 | if (s[0]) { |
582 | safe_strcat (buf, " ", &len, HUGE_BUF); |
582 | safe_strcat (buf, " ", &len, HUGE_BUF); |
583 | safe_strcat(buf, s, &len, HUGE_BUF); |
583 | safe_strcat(buf, s, &len, HUGE_BUF); |
584 | } |
584 | } |
585 | } |
585 | } |
586 | break; |
586 | break; |
587 | default: |
587 | default: |
588 | if(op->magic && ((QUERY_FLAG(op,FLAG_BEEN_APPLIED) && |
588 | if(op->magic && ((QUERY_FLAG(op,FLAG_BEEN_APPLIED) && |
589 | need_identify(op)) || QUERY_FLAG(op,FLAG_IDENTIFIED))) { |
589 | need_identify(op)) || QUERY_FLAG(op,FLAG_IDENTIFIED))) { |
590 | sprintf(buf2, " %+d", op->magic); |
590 | sprintf(buf2, " %+d", op->magic); |
591 | safe_strcat(buf, buf2, &len, HUGE_BUF); |
591 | safe_strcat(buf, buf2, &len, HUGE_BUF); |
592 | } |
592 | } |
593 | } |
593 | } |
594 | return buf; |
594 | return buf; |
595 | } |
595 | } |
596 | |
596 | |
597 | /* |
597 | /* |
… | |
… | |
616 | use_buf++; |
616 | use_buf++; |
617 | use_buf %=5; |
617 | use_buf %=5; |
618 | |
618 | |
619 | #ifdef NEW_MATERIAL_CODE |
619 | #ifdef NEW_MATERIAL_CODE |
620 | if ((IS_ARMOR(op) || IS_WEAPON(op)) && op->materialname) { |
620 | if ((IS_ARMOR(op) || IS_WEAPON(op)) && op->materialname) { |
621 | mt = name_to_material(op->materialname); |
621 | mt = name_to_material(op->materialname); |
622 | if (mt) { |
622 | if (mt) { |
623 | safe_strcat(buf[use_buf], mt->description, &len, HUGE_BUF); |
623 | safe_strcat(buf[use_buf], mt->description, &len, HUGE_BUF); |
624 | safe_strcat(buf[use_buf], " ", &len, HUGE_BUF); |
624 | safe_strcat(buf[use_buf], " ", &len, HUGE_BUF); |
625 | } |
625 | } |
626 | } |
626 | } |
627 | #endif |
627 | #endif |
628 | |
628 | |
629 | safe_strcat(buf[use_buf], query_short_name(op), &len, HUGE_BUF); |
629 | safe_strcat(buf[use_buf], query_short_name(op), &len, HUGE_BUF); |
630 | |
630 | |
631 | if (QUERY_FLAG(op,FLAG_INV_LOCKED)) |
631 | if (QUERY_FLAG(op,FLAG_INV_LOCKED)) |
632 | safe_strcat(buf[use_buf], " *", &len, HUGE_BUF); |
632 | safe_strcat(buf[use_buf], " *", &len, HUGE_BUF); |
633 | if (op->type == CONTAINER && ((op->env && op->env->container == op) || |
633 | if (op->type == CONTAINER && ((op->env && op->env->container == op) || |
634 | (!op->env && QUERY_FLAG(op,FLAG_APPLIED)))) |
634 | (!op->env && QUERY_FLAG(op,FLAG_APPLIED)))) |
635 | safe_strcat(buf[use_buf]," (open)", &len, HUGE_BUF); |
635 | safe_strcat(buf[use_buf]," (open)", &len, HUGE_BUF); |
636 | |
636 | |
637 | if (QUERY_FLAG(op,FLAG_KNOWN_CURSED)) { |
637 | if (QUERY_FLAG(op,FLAG_KNOWN_CURSED)) { |
638 | if(QUERY_FLAG(op,FLAG_DAMNED)) |
638 | if(QUERY_FLAG(op,FLAG_DAMNED)) |
639 | safe_strcat(buf[use_buf], " (damned)", &len, HUGE_BUF); |
639 | safe_strcat(buf[use_buf], " (damned)", &len, HUGE_BUF); |
640 | else if(QUERY_FLAG(op,FLAG_CURSED)) |
640 | else if(QUERY_FLAG(op,FLAG_CURSED)) |
641 | safe_strcat(buf[use_buf], " (cursed)", &len, HUGE_BUF); |
641 | safe_strcat(buf[use_buf], " (cursed)", &len, HUGE_BUF); |
642 | } |
642 | } |
643 | /* Basically, if the object is known magical (detect magic spell on it), |
643 | /* Basically, if the object is known magical (detect magic spell on it), |
644 | * and it isn't identified, print out the fact that |
644 | * and it isn't identified, print out the fact that |
645 | * it is magical. Assume that the detect magical spell will only set |
645 | * it is magical. Assume that the detect magical spell will only set |
646 | * KNOWN_MAGICAL if the item actually is magical. |
646 | * KNOWN_MAGICAL if the item actually is magical. |
… | |
… | |
648 | * Changed in V 0.91.4 - still print that the object is magical even |
648 | * Changed in V 0.91.4 - still print that the object is magical even |
649 | * if it has been applied. Equipping an item does not tell full |
649 | * if it has been applied. Equipping an item does not tell full |
650 | * abilities, especially for artifact items. |
650 | * abilities, especially for artifact items. |
651 | */ |
651 | */ |
652 | if (QUERY_FLAG(op,FLAG_KNOWN_MAGICAL) && !QUERY_FLAG(op,FLAG_IDENTIFIED)) |
652 | if (QUERY_FLAG(op,FLAG_KNOWN_MAGICAL) && !QUERY_FLAG(op,FLAG_IDENTIFIED)) |
653 | safe_strcat(buf[use_buf], " (magic)", &len, HUGE_BUF); |
653 | safe_strcat(buf[use_buf], " (magic)", &len, HUGE_BUF); |
654 | |
654 | |
655 | #if 0 |
655 | #if 0 |
656 | /* item_power will be returned in desribe_item - it shouldn't really |
656 | /* item_power will be returned in desribe_item - it shouldn't really |
657 | * be returned in the name. |
657 | * be returned in the name. |
658 | */ |
658 | */ |
659 | if(op->item_power) |
659 | if(op->item_power) |
660 | sprintf(buf[use_buf]+strlen(buf[use_buf]), "(item_power %+d)", |
660 | sprintf(buf[use_buf]+strlen(buf[use_buf]), "(item_power %+d)", |
661 | op->item_power); |
661 | op->item_power); |
662 | |
662 | |
663 | #endif |
663 | #endif |
664 | |
664 | |
665 | if (QUERY_FLAG(op,FLAG_APPLIED)) { |
665 | if (QUERY_FLAG(op,FLAG_APPLIED)) { |
666 | switch(op->type) { |
666 | switch(op->type) { |
667 | case BOW: |
667 | case BOW: |
668 | case WAND: |
668 | case WAND: |
669 | case ROD: |
669 | case ROD: |
670 | case HORN: |
670 | case HORN: |
671 | safe_strcat(buf[use_buf]," (readied)", &len, HUGE_BUF); |
671 | safe_strcat(buf[use_buf]," (readied)", &len, HUGE_BUF); |
672 | break; |
672 | break; |
673 | case WEAPON: |
673 | case WEAPON: |
674 | safe_strcat(buf[use_buf]," (wielded)", &len, HUGE_BUF); |
674 | safe_strcat(buf[use_buf]," (wielded)", &len, HUGE_BUF); |
675 | break; |
675 | break; |
676 | case ARMOUR: |
676 | case ARMOUR: |
677 | case HELMET: |
677 | case HELMET: |
678 | case SHIELD: |
678 | case SHIELD: |
679 | case RING: |
679 | case RING: |
680 | case BOOTS: |
680 | case BOOTS: |
681 | case GLOVES: |
681 | case GLOVES: |
682 | case AMULET: |
682 | case AMULET: |
683 | case GIRDLE: |
683 | case GIRDLE: |
684 | case BRACERS: |
684 | case BRACERS: |
685 | case CLOAK: |
685 | case CLOAK: |
686 | safe_strcat(buf[use_buf]," (worn)", &len, HUGE_BUF); |
686 | safe_strcat(buf[use_buf]," (worn)", &len, HUGE_BUF); |
687 | break; |
687 | break; |
688 | case CONTAINER: |
688 | case CONTAINER: |
689 | safe_strcat(buf[use_buf]," (active)", &len, HUGE_BUF); |
689 | safe_strcat(buf[use_buf]," (active)", &len, HUGE_BUF); |
690 | break; |
690 | break; |
691 | case SKILL: |
691 | case SKILL: |
692 | default: |
692 | default: |
693 | safe_strcat(buf[use_buf]," (applied)", &len, HUGE_BUF); |
693 | safe_strcat(buf[use_buf]," (applied)", &len, HUGE_BUF); |
694 | } |
694 | } |
695 | } |
695 | } |
696 | if(QUERY_FLAG(op, FLAG_UNPAID)) |
696 | if(QUERY_FLAG(op, FLAG_UNPAID)) |
697 | safe_strcat(buf[use_buf]," (unpaid)", &len, HUGE_BUF); |
697 | safe_strcat(buf[use_buf]," (unpaid)", &len, HUGE_BUF); |
698 | |
698 | |
699 | return buf[use_buf]; |
699 | return buf[use_buf]; |
700 | } |
700 | } |
701 | |
701 | |
702 | /* |
702 | /* |
… | |
… | |
712 | static char buf[MAX_BUF], buf2[MAX_BUF]; |
712 | static char buf[MAX_BUF], buf2[MAX_BUF]; |
713 | int len; |
713 | int len; |
714 | materialtype_t *mt; |
714 | materialtype_t *mt; |
715 | |
715 | |
716 | if((!plural && !op->name) || (plural && !op->name_pl)) |
716 | if((!plural && !op->name) || (plural && !op->name_pl)) |
717 | return "(null)"; |
717 | return "(null)"; |
718 | |
718 | |
719 | if(!op->nrof && !op->weight && !op->title && !is_magical(op)) |
719 | if(!op->nrof && !op->weight && !op->title && !is_magical(op)) |
720 | return op->name; /* To speed things up (or make things slower?) */ |
720 | return op->name; /* To speed things up (or make things slower?) */ |
721 | |
721 | |
722 | if ((IS_ARMOR(op) || IS_WEAPON(op)) && op->materialname) |
722 | if ((IS_ARMOR(op) || IS_WEAPON(op)) && op->materialname) |
723 | mt = name_to_material(op->materialname); |
723 | mt = name_to_material(op->materialname); |
724 | |
724 | |
725 | #ifdef NEW_MATERIAL_CODE |
725 | #ifdef NEW_MATERIAL_CODE |
726 | if ((IS_ARMOR(op) || IS_WEAPON(op)) && op->materialname && mt && |
726 | if ((IS_ARMOR(op) || IS_WEAPON(op)) && op->materialname && mt && |
727 | op->arch->clone.materialname != mt->name && |
727 | op->arch->clone.materialname != mt->name && |
728 | !(op->material & M_SPECIAL)) { |
728 | !(op->material & M_SPECIAL)) { |
729 | strcpy(buf, mt->description); |
729 | strcpy(buf, mt->description); |
730 | len=strlen(buf); |
730 | len=strlen(buf); |
731 | safe_strcat(buf, " ", &len, MAX_BUF); |
731 | safe_strcat(buf, " ", &len, MAX_BUF); |
732 | if (!plural) |
732 | if (!plural) |
733 | safe_strcat(buf, op->name, &len, MAX_BUF); |
733 | safe_strcat(buf, op->name, &len, MAX_BUF); |
734 | else |
734 | else |
735 | safe_strcat(buf, op->name_pl, &len, MAX_BUF); |
735 | safe_strcat(buf, op->name_pl, &len, MAX_BUF); |
736 | } else { |
736 | } else { |
737 | #endif |
737 | #endif |
738 | if (!plural) |
738 | if (!plural) |
739 | strcpy(buf, op->name); |
739 | strcpy(buf, op->name); |
740 | else |
740 | else |
741 | strcpy(buf, op->name_pl); |
741 | strcpy(buf, op->name_pl); |
742 | len=strlen(buf); |
742 | len=strlen(buf); |
743 | #ifdef NEW_MATERIAL_CODE |
743 | #ifdef NEW_MATERIAL_CODE |
744 | } |
744 | } |
745 | #endif |
745 | #endif |
746 | |
746 | |
747 | if (op->title && QUERY_FLAG(op,FLAG_IDENTIFIED)) { |
747 | if (op->title && QUERY_FLAG(op,FLAG_IDENTIFIED)) { |
748 | safe_strcat(buf, " ", &len, MAX_BUF); |
748 | safe_strcat(buf, " ", &len, MAX_BUF); |
749 | safe_strcat(buf, op->title, &len, MAX_BUF); |
749 | safe_strcat(buf, op->title, &len, MAX_BUF); |
750 | } |
750 | } |
751 | |
751 | |
752 | switch(op->type) { |
752 | switch(op->type) { |
753 | case SPELLBOOK: |
753 | case SPELLBOOK: |
754 | case SCROLL: |
754 | case SCROLL: |
755 | case WAND: |
755 | case WAND: |
756 | case ROD: |
756 | case ROD: |
757 | if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { |
757 | if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { |
758 | if(!op->title) { |
758 | if(!op->title) { |
759 | safe_strcat(buf," of ", &len, MAX_BUF); |
759 | safe_strcat(buf," of ", &len, MAX_BUF); |
760 | if (op->inv) |
760 | if (op->inv) |
761 | safe_strcat(buf,op->inv->name, &len, MAX_BUF); |
761 | safe_strcat(buf,op->inv->name, &len, MAX_BUF); |
762 | else |
762 | else |
763 | LOG(llevError,"Spellbook %s lacks inventory\n", op->name); |
763 | LOG(llevError,"Spellbook %s lacks inventory\n", op->name); |
764 | } |
764 | } |
765 | if(op->type != SPELLBOOK) { |
765 | if(op->type != SPELLBOOK) { |
766 | sprintf(buf2, " (lvl %d)", op->level); |
766 | sprintf(buf2, " (lvl %d)", op->level); |
767 | safe_strcat(buf, buf2, &len, MAX_BUF); |
767 | safe_strcat(buf, buf2, &len, MAX_BUF); |
768 | } |
768 | } |
769 | } |
769 | } |
770 | break; |
770 | break; |
771 | |
771 | |
772 | |
772 | |
773 | case SKILL: |
773 | case SKILL: |
774 | case AMULET: |
774 | case AMULET: |
775 | case RING: |
775 | case RING: |
776 | if (!op->title) { |
776 | if (!op->title) { |
777 | /* If ring has a title, full description isn't so useful */ |
777 | /* If ring has a title, full description isn't so useful */ |
778 | char *s = ring_desc(op); |
778 | char *s = ring_desc(op); |
779 | if (s[0]) { |
779 | if (s[0]) { |
780 | safe_strcat (buf, " ", &len, MAX_BUF); |
780 | safe_strcat (buf, " ", &len, MAX_BUF); |
781 | safe_strcat (buf, s, &len, MAX_BUF); |
781 | safe_strcat (buf, s, &len, MAX_BUF); |
782 | } |
782 | } |
783 | } |
783 | } |
784 | break; |
784 | break; |
785 | default: |
785 | default: |
786 | if(op->magic && ((QUERY_FLAG(op,FLAG_BEEN_APPLIED) && |
786 | if(op->magic && ((QUERY_FLAG(op,FLAG_BEEN_APPLIED) && |
787 | need_identify(op)) || QUERY_FLAG(op,FLAG_IDENTIFIED))) { |
787 | need_identify(op)) || QUERY_FLAG(op,FLAG_IDENTIFIED))) { |
788 | sprintf(buf + strlen(buf), " %+d", op->magic); |
788 | sprintf(buf + strlen(buf), " %+d", op->magic); |
789 | } |
789 | } |
790 | } |
790 | } |
791 | return buf; |
791 | return buf; |
792 | } |
792 | } |
793 | |
793 | |
794 | /* Break this off from describe_item - that function was way |
794 | /* Break this off from describe_item - that function was way |
… | |
… | |
808 | /* Note that the resolution this provides for players really isn't |
808 | /* Note that the resolution this provides for players really isn't |
809 | * very good. Any player with a speed greater than .67 will |
809 | * very good. Any player with a speed greater than .67 will |
810 | * fall into the 'lightning fast movement' category. |
810 | * fall into the 'lightning fast movement' category. |
811 | */ |
811 | */ |
812 | if(FABS(op->speed)>MIN_ACTIVE_SPEED) { |
812 | if(FABS(op->speed)>MIN_ACTIVE_SPEED) { |
813 | switch((int)((FABS(op->speed))*15)) { |
813 | switch((int)((FABS(op->speed))*15)) { |
814 | case 0: |
814 | case 0: |
815 | strcat(retbuf,"(very slow movement)"); |
815 | strcat(retbuf,"(very slow movement)"); |
816 | break; |
816 | break; |
817 | case 1: |
817 | case 1: |
818 | strcat(retbuf,"(slow movement)"); |
818 | strcat(retbuf,"(slow movement)"); |
819 | break; |
819 | break; |
820 | case 2: |
820 | case 2: |
821 | strcat(retbuf,"(normal movement)"); |
821 | strcat(retbuf,"(normal movement)"); |
822 | break; |
822 | break; |
823 | case 3: |
823 | case 3: |
824 | case 4: |
824 | case 4: |
825 | strcat(retbuf,"(fast movement)"); |
825 | strcat(retbuf,"(fast movement)"); |
826 | break; |
826 | break; |
827 | case 5: |
827 | case 5: |
828 | case 6: |
828 | case 6: |
829 | strcat(retbuf,"(very fast movement)"); |
829 | strcat(retbuf,"(very fast movement)"); |
830 | break; |
830 | break; |
831 | case 7: |
831 | case 7: |
832 | case 8: |
832 | case 8: |
833 | case 9: |
833 | case 9: |
834 | case 10: |
834 | case 10: |
835 | strcat(retbuf,"(extremely fast movement)"); |
835 | strcat(retbuf,"(extremely fast movement)"); |
836 | break; |
836 | break; |
837 | default: |
837 | default: |
838 | strcat(retbuf,"(lightning fast movement)"); |
838 | strcat(retbuf,"(lightning fast movement)"); |
839 | break; |
839 | break; |
840 | } |
840 | } |
841 | } |
841 | } |
842 | if(QUERY_FLAG(op,FLAG_UNDEAD)) |
842 | if(QUERY_FLAG(op,FLAG_UNDEAD)) |
843 | strcat(retbuf,"(undead)"); |
843 | strcat(retbuf,"(undead)"); |
844 | if(QUERY_FLAG(op,FLAG_SEE_INVISIBLE)) |
844 | if(QUERY_FLAG(op,FLAG_SEE_INVISIBLE)) |
845 | strcat(retbuf,"(see invisible)"); |
845 | strcat(retbuf,"(see invisible)"); |
846 | if(QUERY_FLAG(op,FLAG_USE_WEAPON)) |
846 | if(QUERY_FLAG(op,FLAG_USE_WEAPON)) |
847 | strcat(retbuf,"(wield weapon)"); |
847 | strcat(retbuf,"(wield weapon)"); |
848 | if(QUERY_FLAG(op,FLAG_USE_BOW)) |
848 | if(QUERY_FLAG(op,FLAG_USE_BOW)) |
849 | strcat(retbuf,"(archer)"); |
849 | strcat(retbuf,"(archer)"); |
850 | if(QUERY_FLAG(op,FLAG_USE_ARMOUR)) |
850 | if(QUERY_FLAG(op,FLAG_USE_ARMOUR)) |
851 | strcat(retbuf,"(wear armour)"); |
851 | strcat(retbuf,"(wear armour)"); |
852 | if(QUERY_FLAG(op,FLAG_USE_RING)) |
852 | if(QUERY_FLAG(op,FLAG_USE_RING)) |
853 | strcat(retbuf,"(wear ring)"); |
853 | strcat(retbuf,"(wear ring)"); |
854 | if(QUERY_FLAG(op,FLAG_USE_SCROLL)) |
854 | if(QUERY_FLAG(op,FLAG_USE_SCROLL)) |
855 | strcat(retbuf,"(read scroll)"); |
855 | strcat(retbuf,"(read scroll)"); |
856 | if(QUERY_FLAG(op,FLAG_USE_RANGE)) |
856 | if(QUERY_FLAG(op,FLAG_USE_RANGE)) |
857 | strcat(retbuf,"(fires wand/rod/horn)"); |
857 | strcat(retbuf,"(fires wand/rod/horn)"); |
858 | if(QUERY_FLAG(op,FLAG_CAN_USE_SKILL)) |
858 | if(QUERY_FLAG(op,FLAG_CAN_USE_SKILL)) |
859 | strcat(retbuf,"(skill user)"); |
859 | strcat(retbuf,"(skill user)"); |
860 | if(QUERY_FLAG(op,FLAG_CAST_SPELL)) |
860 | if(QUERY_FLAG(op,FLAG_CAST_SPELL)) |
861 | strcat(retbuf,"(spellcaster)"); |
861 | strcat(retbuf,"(spellcaster)"); |
862 | if(QUERY_FLAG(op,FLAG_FRIENDLY)) |
862 | if(QUERY_FLAG(op,FLAG_FRIENDLY)) |
863 | strcat(retbuf,"(friendly)"); |
863 | strcat(retbuf,"(friendly)"); |
864 | if(QUERY_FLAG(op,FLAG_UNAGGRESSIVE)) |
864 | if(QUERY_FLAG(op,FLAG_UNAGGRESSIVE)) |
865 | strcat(retbuf,"(unaggressive)"); |
865 | strcat(retbuf,"(unaggressive)"); |
866 | if(QUERY_FLAG(op,FLAG_HITBACK)) |
866 | if(QUERY_FLAG(op,FLAG_HITBACK)) |
867 | strcat(retbuf,"(hitback)"); |
867 | strcat(retbuf,"(hitback)"); |
868 | if(QUERY_FLAG(op,FLAG_STEALTH)) |
868 | if(QUERY_FLAG(op,FLAG_STEALTH)) |
869 | strcat(retbuf,"(stealthy)"); |
869 | strcat(retbuf,"(stealthy)"); |
870 | if(op->randomitems != NULL) { |
870 | if(op->randomitems != NULL) { |
871 | treasure *t; |
871 | treasure *t; |
872 | int first = 1; |
872 | int first = 1; |
873 | for(t=op->randomitems->items; t != NULL; t=t->next) |
873 | for(t=op->randomitems->items; t != NULL; t=t->next) |
874 | if(t->item && (t->item->clone.type == SPELL)) { |
874 | if(t->item && (t->item->clone.type == SPELL)) { |
875 | if(first) { |
875 | if(first) { |
876 | first = 0; |
876 | first = 0; |
877 | strcat(retbuf,"(Spell abilities:)"); |
877 | strcat(retbuf,"(Spell abilities:)"); |
878 | } |
878 | } |
879 | strcat(retbuf,"("); |
879 | strcat(retbuf,"("); |
880 | strcat(retbuf,t->item->clone.name); |
880 | strcat(retbuf,t->item->clone.name); |
881 | strcat(retbuf,")"); |
881 | strcat(retbuf,")"); |
882 | } |
882 | } |
883 | } |
883 | } |
884 | if (op->type == PLAYER) { |
884 | if (op->type == PLAYER) { |
885 | if(op->contr->digestion) { |
885 | if(op->contr->digestion) { |
886 | if(op->contr->digestion!=0) |
886 | if(op->contr->digestion!=0) |
887 | sprintf(buf,"(sustenance%+d)",op->contr->digestion); |
887 | sprintf(buf,"(sustenance%+d)",op->contr->digestion); |
888 | strcat(retbuf,buf); |
888 | strcat(retbuf,buf); |
889 | } |
889 | } |
890 | if(op->contr->gen_grace) { |
890 | if(op->contr->gen_grace) { |
891 | sprintf(buf,"(grace%+d)",op->contr->gen_grace); |
891 | sprintf(buf,"(grace%+d)",op->contr->gen_grace); |
892 | strcat(retbuf,buf); |
892 | strcat(retbuf,buf); |
893 | } |
893 | } |
894 | if(op->contr->gen_sp) { |
894 | if(op->contr->gen_sp) { |
895 | sprintf(buf,"(magic%+d)",op->contr->gen_sp); |
895 | sprintf(buf,"(magic%+d)",op->contr->gen_sp); |
896 | strcat(retbuf,buf); |
896 | strcat(retbuf,buf); |
897 | } |
897 | } |
898 | if(op->contr->gen_hp) { |
898 | if(op->contr->gen_hp) { |
899 | sprintf(buf,"(regeneration%+d)",op->contr->gen_hp); |
899 | sprintf(buf,"(regeneration%+d)",op->contr->gen_hp); |
900 | strcat(retbuf,buf); |
900 | strcat(retbuf,buf); |
901 | } |
901 | } |
902 | if(op->stats.luck) { |
902 | if(op->stats.luck) { |
903 | sprintf(buf,"(luck%+d)",op->stats.luck); |
903 | sprintf(buf,"(luck%+d)",op->stats.luck); |
904 | strcat(retbuf,buf); |
904 | strcat(retbuf,buf); |
905 | } |
905 | } |
906 | } |
906 | } |
907 | |
907 | |
908 | /* describe attacktypes */ |
908 | /* describe attacktypes */ |
909 | if (is_dragon_pl(op)) { |
909 | if (is_dragon_pl(op)) { |
910 | /* for dragon players display the attacktypes from clawing skill |
910 | /* for dragon players display the attacktypes from clawing skill |
911 | * Break apart the for loop - move the comparison checking down - |
911 | * Break apart the for loop - move the comparison checking down - |
912 | * this makes it more readable. |
912 | * this makes it more readable. |
913 | */ |
913 | */ |
914 | object *tmp; |
914 | object *tmp; |
915 | |
915 | |
916 | for (tmp=op->inv; tmp!=NULL; tmp=tmp->below) |
916 | for (tmp=op->inv; tmp!=NULL; tmp=tmp->below) |
917 | if (tmp->type == SKILL && !strcmp(tmp->name, "clawing")) break; |
917 | if (tmp->type == SKILL && !strcmp(tmp->name, "clawing")) break; |
918 | |
918 | |
919 | if (tmp && tmp->attacktype!=0) { |
919 | if (tmp && tmp->attacktype!=0) { |
920 | DESCRIBE_ABILITY(retbuf, tmp->attacktype, "Claws"); |
920 | DESCRIBE_ABILITY(retbuf, tmp->attacktype, "Claws"); |
921 | } |
921 | } |
922 | else { |
922 | else { |
923 | DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); |
923 | DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); |
924 | } |
924 | } |
925 | } else { |
925 | } else { |
926 | DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); |
926 | DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); |
927 | } |
927 | } |
928 | DESCRIBE_PATH(retbuf, op->path_attuned, "Attuned"); |
928 | DESCRIBE_PATH(retbuf, op->path_attuned, "Attuned"); |
929 | DESCRIBE_PATH(retbuf, op->path_repelled, "Repelled"); |
929 | DESCRIBE_PATH(retbuf, op->path_repelled, "Repelled"); |
930 | DESCRIBE_PATH(retbuf, op->path_denied, "Denied"); |
930 | DESCRIBE_PATH(retbuf, op->path_denied, "Denied"); |
931 | for (i=0; i < NROFATTACKS; i++) { |
931 | for (i=0; i < NROFATTACKS; i++) { |
932 | if (op->resist[i]) { |
932 | if (op->resist[i]) { |
933 | sprintf(buf, "(%s %+d)", resist_plus[i], op->resist[i]); |
933 | sprintf(buf, "(%s %+d)", resist_plus[i], op->resist[i]); |
934 | strcat(retbuf, buf); |
934 | strcat(retbuf, buf); |
935 | } |
935 | } |
936 | } |
936 | } |
937 | return retbuf; |
937 | return retbuf; |
938 | } |
938 | } |
939 | |
939 | |
940 | |
940 | |
… | |
… | |
970 | static char retbuf[VERY_BIG_BUF]; |
970 | static char retbuf[VERY_BIG_BUF]; |
971 | int identified,i; |
971 | int identified,i; |
972 | |
972 | |
973 | retbuf[0]='\0'; |
973 | retbuf[0]='\0'; |
974 | if(QUERY_FLAG(op,FLAG_MONSTER) || op->type==PLAYER) { |
974 | if(QUERY_FLAG(op,FLAG_MONSTER) || op->type==PLAYER) { |
975 | return describe_monster(op); |
975 | return describe_monster(op); |
976 | } |
976 | } |
977 | /* figure this out once, instead of making multiple calls to need_identify. |
977 | /* figure this out once, instead of making multiple calls to need_identify. |
978 | * also makes the code easier to read. |
978 | * also makes the code easier to read. |
979 | */ |
979 | */ |
980 | if (!need_identify(op) || QUERY_FLAG(op, FLAG_IDENTIFIED)) identified = 1; |
980 | if (!need_identify(op) || QUERY_FLAG(op, FLAG_IDENTIFIED)) identified = 1; |
981 | else { |
981 | else { |
982 | strcpy(retbuf,"(unidentified)"); |
982 | strcpy(retbuf,"(unidentified)"); |
983 | identified = 0; |
983 | identified = 0; |
984 | } |
984 | } |
985 | switch(op->type) { |
985 | switch(op->type) { |
986 | case BOW: |
986 | case BOW: |
987 | case ARROW: |
987 | case ARROW: |
988 | case WAND: |
988 | case WAND: |
989 | case ROD: |
989 | case ROD: |
990 | case HORN: |
990 | case HORN: |
991 | case WEAPON: |
991 | case WEAPON: |
992 | case ARMOUR: |
992 | case ARMOUR: |
993 | case HELMET: |
993 | case HELMET: |
994 | case SHIELD: |
994 | case SHIELD: |
995 | case BOOTS: |
995 | case BOOTS: |
996 | case GLOVES: |
996 | case GLOVES: |
997 | case GIRDLE: |
997 | case GIRDLE: |
998 | case BRACERS: |
998 | case BRACERS: |
999 | case CLOAK: |
999 | case CLOAK: |
1000 | case SKILL_TOOL: |
1000 | case SKILL_TOOL: |
1001 | break; /* We have more information to do below this switch */ |
1001 | break; /* We have more information to do below this switch */ |
1002 | |
1002 | |
1003 | case POWER_CRYSTAL: |
1003 | case POWER_CRYSTAL: |
1004 | if (op->stats.maxsp>1000){ /*higher capacity crystals*/ |
1004 | if (op->stats.maxsp>1000){ /*higher capacity crystals*/ |
1005 | i = (op->stats.maxsp%100)/10; |
1005 | i = (op->stats.maxsp%100)/10; |
1006 | if (i) |
1006 | if (i) |
1007 | snprintf(buf,MAX_BUF,"(capacity %d.%dk). It is ",op->stats.maxsp/100,i); |
1007 | snprintf(buf,MAX_BUF,"(capacity %d.%dk). It is ",op->stats.maxsp/100,i); |
1008 | else |
1008 | else |
1009 | snprintf(buf,MAX_BUF,"(capacity %dk). It is ",op->stats.maxsp/100); |
1009 | snprintf(buf,MAX_BUF,"(capacity %dk). It is ",op->stats.maxsp/100); |
1010 | }else |
1010 | }else |
1011 | snprintf(buf,MAX_BUF,"(capacity %d). It is ",op->stats.maxsp); |
1011 | snprintf(buf,MAX_BUF,"(capacity %d). It is ",op->stats.maxsp); |
1012 | strcat(retbuf,buf); |
1012 | strcat(retbuf,buf); |
1013 | i = (op->stats.sp*10)/op->stats.maxsp; |
1013 | i = (op->stats.sp*10)/op->stats.maxsp; |
1014 | if (op->stats.sp==0) |
1014 | if (op->stats.sp==0) |
1015 | strcat(retbuf,"empty."); |
1015 | strcat(retbuf,"empty."); |
1016 | else if (i==0) |
1016 | else if (i==0) |
1017 | strcat(retbuf,"almost empty."); |
1017 | strcat(retbuf,"almost empty."); |
1018 | else if (i<3) |
1018 | else if (i<3) |
1019 | strcat(retbuf,"partially filled."); |
1019 | strcat(retbuf,"partially filled."); |
1020 | else if (i<6) |
1020 | else if (i<6) |
1021 | strcat(retbuf,"half full."); |
1021 | strcat(retbuf,"half full."); |
1022 | else if (i<9) |
1022 | else if (i<9) |
1023 | strcat(retbuf,"well charged."); |
1023 | strcat(retbuf,"well charged."); |
1024 | else if (op->stats.sp == op->stats.maxsp) |
1024 | else if (op->stats.sp == op->stats.maxsp) |
1025 | strcat(retbuf,"fully charged."); |
1025 | strcat(retbuf,"fully charged."); |
1026 | else |
1026 | else |
1027 | strcat(retbuf,"almost full."); |
1027 | strcat(retbuf,"almost full."); |
1028 | break; |
1028 | break; |
1029 | case FOOD: |
1029 | case FOOD: |
1030 | case FLESH: |
1030 | case FLESH: |
1031 | case DRINK: |
1031 | case DRINK: |
1032 | if(identified || QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { |
1032 | if(identified || QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { |
1033 | sprintf(buf,"(food+%d)", op->stats.food); |
1033 | sprintf(buf,"(food+%d)", op->stats.food); |
1034 | strcat(retbuf, buf); |
1034 | strcat(retbuf, buf); |
1035 | |
1035 | |
1036 | if (op->type == FLESH && op->last_eat>0 && atnr_is_dragon_enabled(op->last_eat)) { |
1036 | if (op->type == FLESH && op->last_eat>0 && atnr_is_dragon_enabled(op->last_eat)) { |
1037 | sprintf(buf, "(%s metabolism)", change_resist_msg[op->last_eat]); |
1037 | sprintf(buf, "(%s metabolism)", change_resist_msg[op->last_eat]); |
1038 | strcat(retbuf, buf); |
1038 | strcat(retbuf, buf); |
1039 | } |
1039 | } |
1040 | |
1040 | |
1041 | if (!QUERY_FLAG(op,FLAG_CURSED)) { |
1041 | if (!QUERY_FLAG(op,FLAG_CURSED)) { |
1042 | if (op->stats.hp) |
1042 | if (op->stats.hp) |
1043 | strcat(retbuf,"(heals)"); |
1043 | strcat(retbuf,"(heals)"); |
1044 | if (op->stats.sp) |
1044 | if (op->stats.sp) |
1045 | strcat(retbuf,"(spellpoint regen)"); |
1045 | strcat(retbuf,"(spellpoint regen)"); |
1046 | } |
1046 | } |
1047 | else { |
1047 | else { |
1048 | if (op->stats.hp) |
1048 | if (op->stats.hp) |
1049 | strcat(retbuf,"(damages)"); |
1049 | strcat(retbuf,"(damages)"); |
1050 | if (op->stats.sp) |
1050 | if (op->stats.sp) |
1051 | strcat(retbuf,"(spellpoint depletion)"); |
1051 | strcat(retbuf,"(spellpoint depletion)"); |
1052 | } |
1052 | } |
1053 | } |
1053 | } |
1054 | break; |
1054 | break; |
1055 | |
1055 | |
1056 | |
1056 | |
1057 | case SKILL: |
1057 | case SKILL: |
1058 | case RING: |
1058 | case RING: |
1059 | case AMULET: |
1059 | case AMULET: |
1060 | if(op->item_power) { |
1060 | if(op->item_power) { |
1061 | sprintf(buf,"(item_power %+d)",op->item_power); |
1061 | sprintf(buf,"(item_power %+d)",op->item_power); |
1062 | strcat(retbuf,buf); |
1062 | strcat(retbuf,buf); |
1063 | } |
1063 | } |
1064 | if (op->title) |
1064 | if (op->title) |
1065 | strcat (retbuf, ring_desc(op)); |
1065 | strcat (retbuf, ring_desc(op)); |
1066 | return retbuf; |
1066 | return retbuf; |
1067 | |
1067 | |
1068 | default: |
1068 | default: |
1069 | return retbuf; |
1069 | return retbuf; |
1070 | } |
1070 | } |
1071 | |
1071 | |
1072 | /* Down here, we more further describe equipment type items. |
1072 | /* Down here, we more further describe equipment type items. |
1073 | * only describe them if they have been identified or the like. |
1073 | * only describe them if they have been identified or the like. |
1074 | */ |
1074 | */ |
1075 | if (identified || QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { |
1075 | if (identified || QUERY_FLAG(op,FLAG_BEEN_APPLIED)) { |
1076 | int attr,val; |
1076 | int attr,val; |
1077 | |
1077 | |
1078 | for (attr=0; attr<NUM_STATS; attr++) { |
1078 | for (attr=0; attr<NUM_STATS; attr++) { |
1079 | if ((val=get_attr_value(&(op->stats),attr))!=0) { |
1079 | if ((val=get_attr_value(&(op->stats),attr))!=0) { |
1080 | sprintf(buf, "(%s%+d)", short_stat_name[attr], val); |
1080 | sprintf(buf, "(%s%+d)", short_stat_name[attr], val); |
1081 | strcat(retbuf,buf); |
1081 | strcat(retbuf,buf); |
1082 | } |
1082 | } |
1083 | } |
1083 | } |
1084 | |
1084 | |
1085 | if(op->stats.exp) { |
1085 | if(op->stats.exp) { |
1086 | sprintf(buf,"(speed %+lld)",op->stats.exp); |
1086 | sprintf(buf,"(speed %+lld)",op->stats.exp); |
1087 | strcat(retbuf,buf); |
1087 | strcat(retbuf,buf); |
1088 | } |
1088 | } |
1089 | |
1089 | |
1090 | |
1090 | |
1091 | switch(op->type) { |
1091 | switch(op->type) { |
1092 | case BOW: |
1092 | case BOW: |
1093 | case ARROW: |
1093 | case ARROW: |
1094 | case GIRDLE: |
1094 | case GIRDLE: |
1095 | case HELMET: |
1095 | case HELMET: |
1096 | case SHIELD: |
1096 | case SHIELD: |
1097 | case BOOTS: |
1097 | case BOOTS: |
1098 | case GLOVES: |
1098 | case GLOVES: |
1099 | case WEAPON: |
1099 | case WEAPON: |
1100 | case SKILL: |
1100 | case SKILL: |
1101 | case RING: |
1101 | case RING: |
1102 | case AMULET: |
1102 | case AMULET: |
1103 | case ARMOUR: |
1103 | case ARMOUR: |
1104 | case BRACERS: |
1104 | case BRACERS: |
1105 | case FORCE: |
1105 | case FORCE: |
1106 | case CLOAK: |
1106 | case CLOAK: |
1107 | if(op->stats.wc) { |
1107 | if(op->stats.wc) { |
1108 | sprintf(buf,"(wc%+d)",op->stats.wc); |
1108 | sprintf(buf,"(wc%+d)",op->stats.wc); |
1109 | strcat(retbuf,buf); |
1109 | strcat(retbuf,buf); |
1110 | } |
1110 | } |
1111 | if(op->stats.dam) { |
1111 | if(op->stats.dam) { |
1112 | sprintf(buf,"(dam%+d)",op->stats.dam); |
1112 | sprintf(buf,"(dam%+d)",op->stats.dam); |
1113 | strcat(retbuf,buf); |
1113 | strcat(retbuf,buf); |
1114 | } |
1114 | } |
1115 | if(op->stats.ac) { |
1115 | if(op->stats.ac) { |
1116 | sprintf(buf,"(ac%+d)",op->stats.ac); |
1116 | sprintf(buf,"(ac%+d)",op->stats.ac); |
1117 | strcat(retbuf,buf); |
1117 | strcat(retbuf,buf); |
1118 | } |
1118 | } |
1119 | if ((op->type==WEAPON || op->type == BOW) && op->level>0) { |
1119 | if ((op->type==WEAPON || op->type == BOW) && op->level>0) { |
1120 | sprintf(buf,"(improved %d/%d)",op->last_eat,op->level); |
1120 | sprintf(buf,"(improved %d/%d)",op->last_eat,op->level); |
1121 | strcat(retbuf,buf); |
1121 | strcat(retbuf,buf); |
1122 | } |
1122 | } |
1123 | break; |
1123 | break; |
1124 | |
1124 | |
1125 | default: |
1125 | default: |
1126 | break; |
1126 | break; |
1127 | } |
1127 | } |
1128 | if(QUERY_FLAG(op,FLAG_XRAYS)) |
1128 | if(QUERY_FLAG(op,FLAG_XRAYS)) |
1129 | strcat(retbuf,"(xray-vision)"); |
1129 | strcat(retbuf,"(xray-vision)"); |
1130 | if(QUERY_FLAG(op,FLAG_SEE_IN_DARK)) |
1130 | if(QUERY_FLAG(op,FLAG_SEE_IN_DARK)) |
1131 | strcat(retbuf,"(infravision)"); |
1131 | strcat(retbuf,"(infravision)"); |
1132 | |
1132 | |
1133 | /* levitate was what is was before, so we'll keep it */ |
1133 | /* levitate was what is was before, so we'll keep it */ |
1134 | if (op->move_type & MOVE_FLY_LOW) |
1134 | if (op->move_type & MOVE_FLY_LOW) |
1135 | strcat(retbuf,"(levitate)"); |
1135 | strcat(retbuf,"(levitate)"); |
1136 | |
1136 | |
1137 | if (op->move_type & MOVE_FLY_HIGH) |
1137 | if (op->move_type & MOVE_FLY_HIGH) |
1138 | strcat(retbuf,"(fly)"); |
1138 | strcat(retbuf,"(fly)"); |
1139 | |
1139 | |
1140 | if (op->move_type & MOVE_SWIM) |
1140 | if (op->move_type & MOVE_SWIM) |
1141 | strcat(retbuf,"(swim)"); |
1141 | strcat(retbuf,"(swim)"); |
1142 | |
1142 | |
1143 | /* walking is presumed as 'normal', so doesn't need mentioning */ |
1143 | /* walking is presumed as 'normal', so doesn't need mentioning */ |
1144 | |
1144 | |
1145 | if(op->item_power) { |
1145 | if(op->item_power) { |
1146 | sprintf(buf,"(item_power %+d)",op->item_power); |
1146 | sprintf(buf,"(item_power %+d)",op->item_power); |
1147 | strcat(retbuf,buf); |
1147 | strcat(retbuf,buf); |
1148 | } |
1148 | } |
1149 | } /* End if identified or applied */ |
1149 | } /* End if identified or applied */ |
1150 | |
1150 | |
1151 | /* This blocks only deals with fully identified object. |
1151 | /* This blocks only deals with fully identified object. |
1152 | * it is intentional that this is not an 'else' from a above - |
1152 | * it is intentional that this is not an 'else' from a above - |
1153 | * in this way, information is added. |
1153 | * in this way, information is added. |
1154 | */ |
1154 | */ |
1155 | if(identified) { |
1155 | if(identified) { |
1156 | int more_info = 0; |
1156 | int more_info = 0; |
1157 | |
1157 | |
1158 | switch(op->type) { |
1158 | switch(op->type) { |
1159 | case ROD: /* These use stats.sp for spell selection and stats.food */ |
1159 | case ROD: /* These use stats.sp for spell selection and stats.food */ |
1160 | case HORN: /* and stats.hp for spell-point regeneration... */ |
1160 | case HORN: /* and stats.hp for spell-point regeneration... */ |
1161 | case BOW: |
1161 | case BOW: |
1162 | case ARROW: |
1162 | case ARROW: |
1163 | case WAND: |
1163 | case WAND: |
1164 | case FOOD: |
1164 | case FOOD: |
1165 | case FLESH: |
1165 | case FLESH: |
1166 | case DRINK: |
1166 | case DRINK: |
1167 | more_info = 0; |
1167 | more_info = 0; |
1168 | break; |
1168 | break; |
1169 | |
1169 | |
1170 | /* Armor type objects */ |
1170 | /* Armor type objects */ |
1171 | case ARMOUR: |
1171 | case ARMOUR: |
1172 | case HELMET: |
1172 | case HELMET: |
1173 | case SHIELD: |
1173 | case SHIELD: |
1174 | case BOOTS: |
1174 | case BOOTS: |
1175 | case GLOVES: |
1175 | case GLOVES: |
1176 | case GIRDLE: |
1176 | case GIRDLE: |
1177 | case BRACERS: |
1177 | case BRACERS: |
1178 | case CLOAK: |
1178 | case CLOAK: |
1179 | if (ARMOUR_SPEED(op)) { |
1179 | if (ARMOUR_SPEED(op)) { |
1180 | sprintf(buf,"(Max speed %1.2f)", ARMOUR_SPEED(op) / 10.0); |
1180 | sprintf(buf,"(Max speed %1.2f)", ARMOUR_SPEED(op) / 10.0); |
1181 | strcat(retbuf, buf); |
1181 | strcat(retbuf, buf); |
1182 | } |
1182 | } |
1183 | if (ARMOUR_SPELLS(op)) { |
1183 | if (ARMOUR_SPELLS(op)) { |
1184 | sprintf(buf,"(Spell regen penalty %d)", ARMOUR_SPELLS(op)); |
1184 | sprintf(buf,"(Spell regen penalty %d)", ARMOUR_SPELLS(op)); |
1185 | strcat(retbuf, buf); |
1185 | strcat(retbuf, buf); |
1186 | } |
1186 | } |
1187 | more_info=1; |
1187 | more_info=1; |
1188 | break; |
1188 | break; |
1189 | |
1189 | |
1190 | case WEAPON: |
1190 | case WEAPON: |
1191 | /* Calculate it the same way fix_player does so the results |
1191 | /* Calculate it the same way fix_player does so the results |
1192 | * make sense. |
1192 | * make sense. |
1193 | */ |
1193 | */ |
1194 | i = (WEAPON_SPEED(op)*2-op->magic)/2; |
1194 | i = (WEAPON_SPEED(op)*2-op->magic)/2; |
1195 | if (i<0) i=0; |
1195 | if (i<0) i=0; |
1196 | |
1196 | |
1197 | sprintf(buf,"(weapon speed %d)", i); |
1197 | sprintf(buf,"(weapon speed %d)", i); |
1198 | strcat(retbuf, buf); |
1198 | strcat(retbuf, buf); |
1199 | more_info=1; |
1199 | more_info=1; |
1200 | break; |
1200 | break; |
1201 | |
1201 | |
1202 | } |
1202 | } |
1203 | if (more_info) { |
1203 | if (more_info) { |
1204 | if(op->stats.food) { |
1204 | if(op->stats.food) { |
1205 | if(op->stats.food!=0) |
1205 | if(op->stats.food!=0) |
1206 | sprintf(buf,"(sustenance%+d)",op->stats.food); |
1206 | sprintf(buf,"(sustenance%+d)",op->stats.food); |
1207 | strcat(retbuf,buf); |
1207 | strcat(retbuf,buf); |
1208 | } |
1208 | } |
1209 | if(op->stats.grace) { |
1209 | if(op->stats.grace) { |
1210 | sprintf(buf,"(grace%+d)",op->stats.grace); |
1210 | sprintf(buf,"(grace%+d)",op->stats.grace); |
1211 | strcat(retbuf,buf); |
1211 | strcat(retbuf,buf); |
1212 | } |
1212 | } |
1213 | if(op->stats.sp) { |
1213 | if(op->stats.sp) { |
1214 | sprintf(buf,"(magic%+d)",op->stats.sp); |
1214 | sprintf(buf,"(magic%+d)",op->stats.sp); |
1215 | strcat(retbuf,buf); |
1215 | strcat(retbuf,buf); |
1216 | } |
1216 | } |
1217 | if(op->stats.hp) { |
1217 | if(op->stats.hp) { |
1218 | sprintf(buf,"(regeneration%+d)",op->stats.hp); |
1218 | sprintf(buf,"(regeneration%+d)",op->stats.hp); |
1219 | strcat(retbuf,buf); |
1219 | strcat(retbuf,buf); |
1220 | } |
1220 | } |
1221 | } |
1221 | } |
1222 | |
1222 | |
1223 | if(op->stats.luck) { |
1223 | if(op->stats.luck) { |
1224 | sprintf(buf,"(luck%+d)",op->stats.luck); |
1224 | sprintf(buf,"(luck%+d)",op->stats.luck); |
1225 | strcat(retbuf,buf); |
1225 | strcat(retbuf,buf); |
1226 | } |
1226 | } |
1227 | if(QUERY_FLAG(op,FLAG_LIFESAVE)) |
1227 | if(QUERY_FLAG(op,FLAG_LIFESAVE)) |
1228 | strcat(retbuf,"(lifesaving)"); |
1228 | strcat(retbuf,"(lifesaving)"); |
1229 | if(QUERY_FLAG(op,FLAG_REFL_SPELL)) |
1229 | if(QUERY_FLAG(op,FLAG_REFL_SPELL)) |
1230 | strcat(retbuf,"(reflect spells)"); |
1230 | strcat(retbuf,"(reflect spells)"); |
1231 | if(QUERY_FLAG(op,FLAG_REFL_MISSILE)) |
1231 | if(QUERY_FLAG(op,FLAG_REFL_MISSILE)) |
1232 | strcat(retbuf,"(reflect missiles)"); |
1232 | strcat(retbuf,"(reflect missiles)"); |
1233 | if(QUERY_FLAG(op,FLAG_STEALTH)) |
1233 | if(QUERY_FLAG(op,FLAG_STEALTH)) |
1234 | strcat(retbuf,"(stealth)"); |
1234 | strcat(retbuf,"(stealth)"); |
1235 | if(op->slaying!=NULL && op->type != FOOD) { |
1235 | if(op->slaying!=NULL && op->type != FOOD) { |
1236 | sprintf(buf,"(slay %s)",op->slaying); |
1236 | sprintf(buf,"(slay %s)",op->slaying); |
1237 | strcat(retbuf,buf); |
1237 | strcat(retbuf,buf); |
1238 | } |
1238 | } |
1239 | DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); |
1239 | DESCRIBE_ABILITY(retbuf, op->attacktype, "Attacks"); |
1240 | /* resistance on flesh is only visible for quetzals. If |
1240 | /* resistance on flesh is only visible for quetzals. If |
1241 | * non flesh, everyone can see its resistances |
1241 | * non flesh, everyone can see its resistances |
1242 | */ |
1242 | */ |
1243 | if (op->type != FLESH || (owner && is_dragon_pl(owner))) |
1243 | if (op->type != FLESH || (owner && is_dragon_pl(owner))) |
1244 | strcat(retbuf,describe_resistance(op, 0)); |
1244 | strcat(retbuf,describe_resistance(op, 0)); |
1245 | DESCRIBE_PATH(retbuf, op->path_attuned, "Attuned"); |
1245 | DESCRIBE_PATH(retbuf, op->path_attuned, "Attuned"); |
1246 | DESCRIBE_PATH(retbuf, op->path_repelled, "Repelled"); |
1246 | DESCRIBE_PATH(retbuf, op->path_repelled, "Repelled"); |
1247 | DESCRIBE_PATH(retbuf, op->path_denied, "Denied"); |
1247 | DESCRIBE_PATH(retbuf, op->path_denied, "Denied"); |
1248 | } |
1248 | } |
1249 | |
1249 | |
1250 | return retbuf; |
1250 | return retbuf; |
1251 | } |
1251 | } |
1252 | |
1252 | |
… | |
… | |
1268 | |
1268 | |
1269 | /* Handle rings and amulets specially. If they change any of these |
1269 | /* Handle rings and amulets specially. If they change any of these |
1270 | * values, it means they are magical. |
1270 | * values, it means they are magical. |
1271 | */ |
1271 | */ |
1272 | if ((op->type==AMULET || op->type==RING) && |
1272 | if ((op->type==AMULET || op->type==RING) && |
1273 | (op->stats.ac || op->stats.food || op->stats.exp || op->stats.dam || |
1273 | (op->stats.ac || op->stats.food || op->stats.exp || op->stats.dam || |
1274 | op->stats.wc || op->stats.sp || op->stats.hp || op->stats.luck)) |
1274 | op->stats.wc || op->stats.sp || op->stats.hp || op->stats.luck)) |
1275 | return 1; |
1275 | return 1; |
1276 | |
1276 | |
1277 | /* Check for stealty, speed, flying, or just plain magic in the boots */ |
1277 | /* Check for stealty, speed, flying, or just plain magic in the boots */ |
1278 | /* Presume any boots that hvae a move_type are special. */ |
1278 | /* Presume any boots that hvae a move_type are special. */ |
1279 | if (op->type== BOOTS && |
1279 | if (op->type== BOOTS && |
1280 | ((QUERY_FLAG(op, FLAG_STEALTH) || op->move_type || op->stats.exp))) |
1280 | ((QUERY_FLAG(op, FLAG_STEALTH) || op->move_type || op->stats.exp))) |
1281 | return 1; |
1281 | return 1; |
1282 | |
1282 | |
1283 | /* Take care of amulet/shield that reflects spells/missiles */ |
1283 | /* Take care of amulet/shield that reflects spells/missiles */ |
1284 | if ((op->type==AMULET || op->type==SHIELD) && |
1284 | if ((op->type==AMULET || op->type==SHIELD) && |
1285 | (QUERY_FLAG(op, FLAG_REFL_SPELL) || QUERY_FLAG(op, FLAG_REFL_MISSILE))) |
1285 | (QUERY_FLAG(op, FLAG_REFL_SPELL) || QUERY_FLAG(op, FLAG_REFL_MISSILE))) |
1286 | return 1; |
1286 | return 1; |
1287 | |
1287 | |
1288 | /* Take care of helmet of xrays */ |
1288 | /* Take care of helmet of xrays */ |
1289 | if (op->type==HELMET && QUERY_FLAG(op,FLAG_XRAYS)) return 1; |
1289 | if (op->type==HELMET && QUERY_FLAG(op,FLAG_XRAYS)) return 1; |
1290 | |
1290 | |
1291 | /* Potions & rods are always magical. Wands/staves are also magical, |
1291 | /* Potions & rods are always magical. Wands/staves are also magical, |
1292 | * assuming they still have any charges left. |
1292 | * assuming they still have any charges left. |
1293 | */ |
1293 | */ |
1294 | if (op->type==POTION || op->type==ROD || |
1294 | if (op->type==POTION || op->type==ROD || |
1295 | (op->type==WAND && op->stats.food)) |
1295 | (op->type==WAND && op->stats.food)) |
1296 | return 1; |
1296 | return 1; |
1297 | |
1297 | |
1298 | /* if something gives a protection, either positive or negative, its magical */ |
1298 | /* if something gives a protection, either positive or negative, its magical */ |
1299 | /* This is really a pretty bad hack - as of now, ATNR_PHYSICAL is 0, |
1299 | /* This is really a pretty bad hack - as of now, ATNR_PHYSICAL is 0, |
1300 | * so this always works out fine. |
1300 | * so this always works out fine. |
1301 | */ |
1301 | */ |
1302 | for (i=ATNR_PHYSICAL+1; i<NROFATTACKS; i++) |
1302 | for (i=ATNR_PHYSICAL+1; i<NROFATTACKS; i++) |
1303 | if (op->resist[i]) return 1; |
1303 | if (op->resist[i]) return 1; |
1304 | |
1304 | |
1305 | /* Physical protection is expected on some item types, so they should |
1305 | /* Physical protection is expected on some item types, so they should |
1306 | * not be considered magical. |
1306 | * not be considered magical. |
1307 | */ |
1307 | */ |
1308 | if (op->resist[ATNR_PHYSICAL] && op->type != HELMET && op->type != SHIELD && |
1308 | if (op->resist[ATNR_PHYSICAL] && op->type != HELMET && op->type != SHIELD && |
1309 | op->type != BOOTS && op->type != GLOVES && op->type != ARMOUR) return 1; |
1309 | op->type != BOOTS && op->type != GLOVES && op->type != ARMOUR) return 1; |
1310 | |
1310 | |
1311 | /* power crystal, spellbooks, and scrolls are always magical. */ |
1311 | /* power crystal, spellbooks, and scrolls are always magical. */ |
1312 | if (op->magic || op->type==POWER_CRYSTAL || op->type==SPELLBOOK || |
1312 | if (op->magic || op->type==POWER_CRYSTAL || op->type==SPELLBOOK || |
1313 | op->type==SCROLL || op->type==GIRDLE) |
1313 | op->type==SCROLL || op->type==GIRDLE) |
1314 | return 1; |
1314 | return 1; |
1315 | |
1315 | |
1316 | /* Check to see if it increases/decreases any stats */ |
1316 | /* Check to see if it increases/decreases any stats */ |
1317 | for (i=0; i<NUM_STATS; i++) |
1317 | for (i=0; i<NUM_STATS; i++) |
1318 | if (get_attr_value(&(op->stats),i)!=0) return 1; |
1318 | if (get_attr_value(&(op->stats),i)!=0) return 1; |
1319 | |
1319 | |
1320 | /* If it doesn't fall into any of the above categories, must |
1320 | /* If it doesn't fall into any of the above categories, must |
1321 | * be non magical. |
1321 | * be non magical. |
1322 | */ |
1322 | */ |
1323 | return 0; |
1323 | return 0; |
… | |
… | |
1328 | * should need it. |
1328 | * should need it. |
1329 | */ |
1329 | */ |
1330 | |
1330 | |
1331 | int need_identify(const object *op) { |
1331 | int need_identify(const object *op) { |
1332 | switch(op->type) { |
1332 | switch(op->type) { |
1333 | case RING: |
1333 | case RING: |
1334 | case WAND: |
1334 | case WAND: |
1335 | case ROD: |
1335 | case ROD: |
1336 | case HORN: |
1336 | case HORN: |
1337 | case SCROLL: |
1337 | case SCROLL: |
1338 | case SKILL: |
1338 | case SKILL: |
1339 | case SKILLSCROLL: |
1339 | case SKILLSCROLL: |
1340 | case SPELLBOOK: |
1340 | case SPELLBOOK: |
1341 | case FOOD: |
1341 | case FOOD: |
1342 | case POTION: |
1342 | case POTION: |
1343 | case BOW: |
1343 | case BOW: |
1344 | case ARROW: |
1344 | case ARROW: |
1345 | case WEAPON: |
1345 | case WEAPON: |
1346 | case ARMOUR: |
1346 | case ARMOUR: |
1347 | case SHIELD: |
1347 | case SHIELD: |
1348 | case HELMET: |
1348 | case HELMET: |
1349 | case AMULET: |
1349 | case AMULET: |
1350 | case BOOTS: |
1350 | case BOOTS: |
1351 | case GLOVES: |
1351 | case GLOVES: |
1352 | case BRACERS: |
1352 | case BRACERS: |
1353 | case GIRDLE: |
1353 | case GIRDLE: |
1354 | case CONTAINER: |
1354 | case CONTAINER: |
1355 | case DRINK: |
1355 | case DRINK: |
1356 | case FLESH: |
1356 | case FLESH: |
1357 | case INORGANIC: |
1357 | case INORGANIC: |
1358 | case CLOSE_CON: |
1358 | case CLOSE_CON: |
1359 | case CLOAK: |
1359 | case CLOAK: |
1360 | case GEM: |
1360 | case GEM: |
1361 | case POWER_CRYSTAL: |
1361 | case POWER_CRYSTAL: |
1362 | case POISON: |
1362 | case POISON: |
1363 | case BOOK: |
1363 | case BOOK: |
1364 | case SKILL_TOOL: |
1364 | case SKILL_TOOL: |
1365 | return 1; |
1365 | return 1; |
1366 | } |
1366 | } |
1367 | /* Try to track down some stuff that may show up here. Thus, the |
1367 | /* Try to track down some stuff that may show up here. Thus, the |
1368 | * archetype file can be updated, and this function removed. |
1368 | * archetype file can be updated, and this function removed. |
1369 | */ |
1369 | */ |
1370 | #if 0 |
1370 | #if 0 |
… | |
… | |
1387 | |
1387 | |
1388 | /* |
1388 | /* |
1389 | * We want autojoining of equal objects: |
1389 | * We want autojoining of equal objects: |
1390 | */ |
1390 | */ |
1391 | if (QUERY_FLAG(op,FLAG_CURSED) || QUERY_FLAG(op,FLAG_DAMNED)) |
1391 | if (QUERY_FLAG(op,FLAG_CURSED) || QUERY_FLAG(op,FLAG_DAMNED)) |
1392 | SET_FLAG(op,FLAG_KNOWN_CURSED); |
1392 | SET_FLAG(op,FLAG_KNOWN_CURSED); |
1393 | |
1393 | |
1394 | if (op->type == POTION) { |
1394 | if (op->type == POTION) { |
1395 | if (op->inv && op->randomitems) { |
1395 | if (op->inv && op->randomitems) { |
1396 | if (op->title) free_string(op->title); |
1396 | if (op->title) free_string(op->title); |
1397 | op->title = add_refcount(op->inv->name); |
1397 | op->title = add_refcount(op->inv->name); |
1398 | } else if (op->arch) { |
1398 | } else if (op->arch) { |
1399 | free_string(op->name); |
1399 | free_string(op->name); |
1400 | op->name = add_refcount(op->arch->clone.name); |
1400 | op->name = add_refcount(op->arch->clone.name); |
1401 | free_string(op->name_pl); |
1401 | free_string(op->name_pl); |
1402 | op->name_pl = add_refcount(op->arch->clone.name_pl); |
1402 | op->name_pl = add_refcount(op->arch->clone.name_pl); |
1403 | } |
1403 | } |
1404 | } |
1404 | } |
1405 | |
1405 | |
1406 | /* If the object is on a map, make sure we update its face */ |
1406 | /* If the object is on a map, make sure we update its face */ |
1407 | if (op->map) |
1407 | if (op->map) |
1408 | update_object(op,UP_OBJ_FACE); |
1408 | update_object(op,UP_OBJ_FACE); |
1409 | else { |
1409 | else { |
1410 | pl = is_player_inv(op->env); |
1410 | pl = is_player_inv(op->env); |
1411 | if (pl) |
1411 | if (pl) |
1412 | /* A lot of the values can change from an update - might as well send |
1412 | /* A lot of the values can change from an update - might as well send |
1413 | * it all. |
1413 | * it all. |
1414 | */ |
1414 | */ |
1415 | esrv_send_item(pl, op); |
1415 | esrv_send_item(pl, op); |
1416 | } |
1416 | } |
1417 | } |
1417 | } |