… | |
… | |
450 | owner = owner->owner; |
450 | owner = owner->owner; |
451 | |
451 | |
452 | this->owner = owner; |
452 | this->owner = owner; |
453 | } |
453 | } |
454 | |
454 | |
455 | void |
455 | int |
|
|
456 | object::slottype () const |
|
|
457 | { |
|
|
458 | if (type == SKILL) |
|
|
459 | { |
|
|
460 | if (IS_COMBAT_SKILL (subtype)) return slot_combat; |
|
|
461 | if (IS_RANGED_SKILL (subtype)) return slot_ranged; |
|
|
462 | } |
|
|
463 | else |
|
|
464 | { |
|
|
465 | if (slot [body_combat].info) return slot_combat; |
|
|
466 | if (slot [body_range ].info) return slot_ranged; |
|
|
467 | } |
|
|
468 | |
|
|
469 | return slot_none; |
|
|
470 | } |
|
|
471 | |
|
|
472 | bool |
456 | object::set_weapon (object *ob) |
473 | object::change_weapon (object *ob) |
457 | { |
474 | { |
458 | if (current_weapon == ob) |
475 | if (current_weapon == ob) |
459 | return; |
476 | return true; |
460 | |
|
|
461 | new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); |
|
|
462 | |
477 | |
463 | if (chosen_skill) |
478 | if (chosen_skill) |
464 | chosen_skill->flag [FLAG_APPLIED] = false; |
479 | chosen_skill->flag [FLAG_APPLIED] = false; |
465 | |
480 | |
466 | current_weapon = ob; |
481 | current_weapon = ob; |
467 | chosen_skill = ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill); |
482 | chosen_skill = !ob || ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill); |
468 | |
483 | |
469 | if (chosen_skill) |
484 | if (chosen_skill) |
470 | chosen_skill->flag [FLAG_APPLIED] = true; |
485 | chosen_skill->flag [FLAG_APPLIED] = true; |
471 | |
486 | |
472 | update_stats (); |
487 | update_stats (); |
|
|
488 | |
|
|
489 | if (ob) |
|
|
490 | { |
|
|
491 | // now check wether any body locations became invalid, in which case |
|
|
492 | // we cannot apply the weapon at the moment. |
|
|
493 | for (int i = 0; i < NUM_BODY_LOCATIONS; ++i) |
|
|
494 | if (slot[i].used < 0) |
|
|
495 | { |
|
|
496 | current_weapon = chosen_skill = 0; |
|
|
497 | update_stats (); |
|
|
498 | |
|
|
499 | new_draw_info_format (NDI_UNIQUE, 0, this, |
|
|
500 | "You try to balance your applied items all at once, but the %s is too much. " |
|
|
501 | "You need to unapply some items first.", &ob->name); |
|
|
502 | return false; |
|
|
503 | } |
|
|
504 | |
|
|
505 | //new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); |
|
|
506 | } |
|
|
507 | else |
|
|
508 | ;//new_draw_info_format (NDI_UNIQUE, 0, this, "You unwield your weapons."); |
|
|
509 | |
|
|
510 | if (ob && !ob->flag [FLAG_APPLIED] && ob->type != SPELL) |
|
|
511 | { |
|
|
512 | LOG (llevError | logBacktrace, "%s changed to unapplied weapon %s", |
|
|
513 | &name, ob->debug_desc ()); |
|
|
514 | return false; |
|
|
515 | } |
|
|
516 | |
|
|
517 | return true; |
473 | } |
518 | } |
474 | |
519 | |
475 | /* Zero the key_values on op, decrementing the shared-string |
520 | /* Zero the key_values on op, decrementing the shared-string |
476 | * refcounts and freeing the links. |
521 | * refcounts and freeing the links. |
477 | */ |
522 | */ |