… | |
… | |
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 | bool |
456 | object::set_weapon (object *ob) |
456 | object::change_weapon (object *ob) |
457 | { |
457 | { |
458 | if (current_weapon == ob) |
458 | if (current_weapon == ob) |
459 | return; |
459 | return true; |
460 | |
|
|
461 | new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); |
|
|
462 | |
460 | |
463 | if (chosen_skill) |
461 | if (chosen_skill) |
464 | chosen_skill->flag [FLAG_APPLIED] = false; |
462 | chosen_skill->flag [FLAG_APPLIED] = false; |
465 | |
463 | |
466 | current_weapon = ob; |
464 | current_weapon = ob; |
467 | chosen_skill = ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill); |
465 | chosen_skill = !ob || ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill); |
468 | |
466 | |
469 | if (chosen_skill) |
467 | if (chosen_skill) |
470 | chosen_skill->flag [FLAG_APPLIED] = true; |
468 | chosen_skill->flag [FLAG_APPLIED] = true; |
471 | |
469 | |
472 | update_stats (); |
470 | update_stats (); |
|
|
471 | |
|
|
472 | if (ob) |
|
|
473 | { |
|
|
474 | // now check wether any body locations became invalid, in which case |
|
|
475 | // we cannot apply the weapon at the moment. |
|
|
476 | for (int i = 0; i < NUM_BODY_LOCATIONS; ++i) |
|
|
477 | if (slot[i].used < 0) |
|
|
478 | { |
|
|
479 | current_weapon = chosen_skill = 0; |
|
|
480 | update_stats (); |
|
|
481 | |
|
|
482 | new_draw_info_format (NDI_UNIQUE, 0, this, |
|
|
483 | "You try to balance your applied items all at once, but the %s is too much. " |
|
|
484 | "You need to unapply some items first.", &ob->name); |
|
|
485 | return false; |
|
|
486 | } |
|
|
487 | |
|
|
488 | new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); |
|
|
489 | } |
|
|
490 | else |
|
|
491 | new_draw_info_format (NDI_UNIQUE, 0, this, "You unwield your weapons."); |
|
|
492 | |
|
|
493 | return true; |
473 | } |
494 | } |
474 | |
495 | |
475 | /* Zero the key_values on op, decrementing the shared-string |
496 | /* Zero the key_values on op, decrementing the shared-string |
476 | * refcounts and freeing the links. |
497 | * refcounts and freeing the links. |
477 | */ |
498 | */ |