… | |
… | |
591 | } |
591 | } |
592 | |
592 | |
593 | return slot_none; |
593 | return slot_none; |
594 | } |
594 | } |
595 | |
595 | |
596 | bool |
|
|
597 | object::change_weapon (object *ob) |
|
|
598 | { |
|
|
599 | if (current_weapon == ob) |
|
|
600 | return true; |
|
|
601 | |
|
|
602 | if (chosen_skill) |
|
|
603 | chosen_skill->flag [FLAG_APPLIED] = false; |
|
|
604 | |
|
|
605 | current_weapon = ob; |
|
|
606 | chosen_skill = !ob || ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill); |
|
|
607 | |
|
|
608 | if (chosen_skill) |
|
|
609 | chosen_skill->flag [FLAG_APPLIED] = true; |
|
|
610 | |
|
|
611 | update_stats (); |
|
|
612 | |
|
|
613 | if (ob) |
|
|
614 | { |
|
|
615 | // now check wether any body locations became invalid, in which case |
|
|
616 | // we cannot apply the weapon at the moment. |
|
|
617 | for (int i = 0; i < NUM_BODY_LOCATIONS; ++i) |
|
|
618 | if (slot[i].used < 0) |
|
|
619 | { |
|
|
620 | if (chosen_skill) |
|
|
621 | chosen_skill->flag [FLAG_APPLIED] = false; |
|
|
622 | |
|
|
623 | current_weapon = chosen_skill = 0; |
|
|
624 | update_stats (); |
|
|
625 | |
|
|
626 | new_draw_info_format (NDI_UNIQUE, 0, this, |
|
|
627 | "You try to balance all your items at once, " |
|
|
628 | "but the %s is just too much for your body. " |
|
|
629 | "[You need to unapply some items first - use the 'body' command to see " |
|
|
630 | "how many items you can wear on a specific body part.]", &ob->name); |
|
|
631 | return false; |
|
|
632 | } |
|
|
633 | |
|
|
634 | //new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); |
|
|
635 | } |
|
|
636 | else |
|
|
637 | ;//new_draw_info_format (NDI_UNIQUE, 0, this, "You unwield your weapons."); |
|
|
638 | |
|
|
639 | if (ob && !ob->flag [FLAG_APPLIED] && ob->type != SPELL) |
|
|
640 | { |
|
|
641 | LOG (llevError | logBacktrace, "%s changed to unapplied weapon %s", |
|
|
642 | &name, ob->debug_desc ()); |
|
|
643 | return false; |
|
|
644 | } |
|
|
645 | |
|
|
646 | return true; |
|
|
647 | } |
|
|
648 | |
|
|
649 | /* Zero the key_values on op, decrementing the shared-string |
596 | /* Zero the key_values on op, decrementing the shared-string |
650 | * refcounts and freeing the links. |
597 | * refcounts and freeing the links. |
651 | */ |
598 | */ |
652 | static void |
599 | static void |
653 | free_key_values (object *op) |
600 | free_key_values (object *op) |
… | |
… | |
1152 | below = 0; |
1099 | below = 0; |
1153 | env = 0; |
1100 | env = 0; |
1154 | |
1101 | |
1155 | if (pl && pl->is_player ()) |
1102 | if (pl && pl->is_player ()) |
1156 | { |
1103 | { |
|
|
1104 | if (expect_false (pl->contr->combat_ob == this)) |
|
|
1105 | { |
|
|
1106 | pl->apply (pl->contr->combat_ob, AP_UNAPPLY); |
|
|
1107 | pl->contr->combat_ob = 0; |
|
|
1108 | if (pl->contr->ranged_ob) pl->apply (pl->contr->ranged_ob); |
|
|
1109 | } |
|
|
1110 | |
|
|
1111 | if (expect_false (pl->contr->ranged_ob == this)) |
|
|
1112 | { |
|
|
1113 | pl->apply (pl->contr->ranged_ob, AP_UNAPPLY); |
|
|
1114 | pl->contr->ranged_ob = 0; |
|
|
1115 | if (pl->contr->combat_ob) pl->apply (pl->contr->combat_ob); |
|
|
1116 | } |
|
|
1117 | |
1157 | pl->contr->queue_stats_update (); |
1118 | pl->contr->queue_stats_update (); |
1158 | |
1119 | |
1159 | if (glow_radius && pl->is_on_map ()) |
1120 | if (expect_false (glow_radius) && pl->is_on_map ()) |
1160 | update_all_los (pl->map, pl->x, pl->y); |
1121 | update_all_los (pl->map, pl->x, pl->y); |
1161 | } |
1122 | } |
1162 | } |
1123 | } |
1163 | else if (map) |
1124 | else if (map) |
1164 | { |
1125 | { |