MCPcopy Create free account
hub / github.com/crawl/crawl / _player_shoot

Function _player_shoot

crawl-ref/source/throw.cc:719–809  ·  view source on GitHub ↗

Once the player has committed to a target, shoot/throw/toss at it. Handles conducts, action counts, ammunition use, etc.

Source from the content-addressed store, hash-verified

717// Once the player has committed to a target, shoot/throw/toss at it.
718// Handles conducts, action counts, ammunition use, etc.
719static void _player_shoot(ranged_attack_beam &pbolt)
720{
721 const item_def& item = *pbolt.atk.weapon;
722 const int bow_brand = get_weapon_brand(item);
723 const int ammo_brand = get_ammo_brand(item);
724 const bool returning = _returning(item);
725 const bool is_thrown = is_throwable(&you, item);
726 const bool will_mulch = _thrown_object_destroyed(item);
727
728 if (is_range_weapon(item))
729 {
730 practise_launching(item);
731 if (is_unrandom_artefact(item)
732 && get_unrand_entry(item.unrand_idx)->type_name)
733 {
734 count_action(CACT_FIRE, item.unrand_idx);
735 }
736 else
737 count_action(CACT_FIRE, item.sub_type);
738 }
739 else if (is_thrown)
740 {
741 practise_throwing((missile_type)item.sub_type);
742 count_action(CACT_THROW, item.sub_type, OBJ_MISSILES);
743 }
744
745 // Create message.
746 mprf("You %s %s%s.",
747 is_thrown ? "throw" : "shoot" ,
748 article_a(pbolt.atk.projectile_name()).c_str(),
749 you.current_vision == 0 ? " into the darkness" : "");
750
751 pbolt.beam.set_is_tracer(false);
752
753 pbolt.beam.loudness = item.base_type == OBJ_MISSILES
754 ? ammo_type_damage(item.sub_type) / 3
755 : 0; // Maybe not accurate, but reflects the damage.
756
757 pbolt.beam.drop_item = is_thrown && !returning && !will_mulch;
758 pbolt.atk.will_mulch = will_mulch;
759
760 if (crawl_state.game_is_hints())
761 Hints.hints_throw_counter++;
762
763 const coord_def target = pbolt.beam.target;
764
765 // XXX: Firing via beam will never hit a target outside our vision range,
766 // so create the ranged_attack manually when bumping into something
767 // during the start of Primordial Nightfall
768 if (you.current_vision == 0)
769 {
770 monster* mon = monster_at(target);
771 if (mon && mon->alive())
772 {
773 ranged_attack attk(&you, mon, &item, false, &you);
774 attk.will_mulch = will_mulch;
775 attk.attack();
776 }

Callers 1

Calls 15

get_weapon_brandFunction · 0.85
get_ammo_brandFunction · 0.85
_returningFunction · 0.85
is_throwableFunction · 0.85
_thrown_object_destroyedFunction · 0.85
is_range_weaponFunction · 0.85
practise_launchingFunction · 0.85
is_unrandom_artefactFunction · 0.85
get_unrand_entryFunction · 0.85
count_actionFunction · 0.85
practise_throwingFunction · 0.85
mprfFunction · 0.85

Tested by

no test coverage detected