Aim and then perform a standard ranged attack, either by autofight or the quiver interface.
| 656 | |
| 657 | // Aim and then perform a standard ranged attack, either by autofight or the quiver interface. |
| 658 | void aim_player_ranged_attack(quiver::action &a) |
| 659 | { |
| 660 | ASSERT(a.get_item() >= 0); |
| 661 | item_def* item = &you.inv[a.get_item()]; |
| 662 | const bool throwing = item->base_type == OBJ_MISSILES; |
| 663 | |
| 664 | if (you.confused()) |
| 665 | { |
| 666 | do |
| 667 | { |
| 668 | a.target.target.x = you.pos().x + random2(13) - 6; |
| 669 | a.target.target.y = you.pos().y + random2(13) - 6; |
| 670 | } while (a.target.target == you.pos()); |
| 671 | |
| 672 | a.target.isValid = true; |
| 673 | a.target.cmd_result = CMD_FIRE; |
| 674 | } |
| 675 | else |
| 676 | { |
| 677 | // non-confused interactive or non-interactive firing |
| 678 | fire_target_behaviour beh(a); |
| 679 | direction_chooser_args args; |
| 680 | args.behaviour = &beh; |
| 681 | args.mode = TARG_HOSTILE; |
| 682 | args.self = confirm_prompt_type::cancel; |
| 683 | direction(a.target, args); |
| 684 | } |
| 685 | if (!a.target.isValid || a.target.isCancel) |
| 686 | return; |
| 687 | |
| 688 | // Now that we have a target, set up the attacks and run tracers |
| 689 | // (which may also adjust targeting slightly). |
| 690 | vector<ranged_attack_beam> atks = _construct_player_ranged_beams(throwing ? item : nullptr); |
| 691 | |
| 692 | for (ranged_attack_beam& atk : atks) |
| 693 | atk.beam.set_target(a.target); |
| 694 | |
| 695 | if (_trace_player_ranged_attacks(atks)) |
| 696 | return; |
| 697 | |
| 698 | // Actually perform the attack and spend time. |
| 699 | you.time_taken = you.attack_delay(item).roll(); |
| 700 | _fire_player_ranged_attacks(atks); |
| 701 | you.turn_is_over = true; |
| 702 | } |
| 703 | |
| 704 | // Make the player immediately perform a ranged attack at a given target, optionally |
| 705 | // with a specific projectile. Does not handle spending time. |
no test coverage detected