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

Function mons_throw

crawl-ref/source/throw.cc:811–883  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

809}
810
811bool mons_throw(monster* mons, ranged_attack_beam& ratk, bool teleport, bool was_redirected)
812{
813 const item_def &weapon = *ratk.atk.weapon;
814 bolt& beam = ratk.beam;
815
816 // Energy is already deducted for the spell cast, if using portal projectile
817 // FIXME: should it use this delay and not the spell delay?
818 if (!teleport)
819 {
820 const int energy = mons->action_energy(EUT_MISSILE);
821 const int delay = mons->attack_delay(&weapon).roll();
822 ASSERT(energy > 0);
823 ASSERT(delay > 0);
824 mons->speed_increment -= div_rand_round(energy * delay, 10);
825 }
826
827 // Avoid overshooting unless we're *trying* to hit allies.
828 // (Piercing beam tracers should already handle this).
829 if (!was_redirected)
830 beam.stop_at_allies |= !beam.pierce;
831 beam.aimed_at_spot |= _returning(weapon);
832
833 const bool thrown = is_throwable(mons, weapon);
834 if (mons->observable())
835 {
836 mpr(make_stringf("%s%s %s %s.",
837 mons->name(DESC_THE).c_str(),
838 teleport ? " magically" : "",
839 thrown ? "throws" : "shoots",
840 article_a(ratk.atk.projectile_name()).c_str()).c_str());
841 }
842
843 _throw_noise(mons, weapon);
844
845 const bool uses_ammo = weapon.is_type(OBJ_MISSILES, MI_THROWING_NET);
846 beam.drop_item = uses_ammo;
847
848 // Redraw the screen before firing, in case the monster just
849 // came into view and the screen hasn't been updated yet.
850 viewwindow();
851 update_screen();
852 const coord_def target = beam.target;
853 if (teleport)
854 {
855 beam.use_target_as_pos = true;
856 unwind_var<ranged_attack*> old_atk(beam.ranged_atk, &ratk.atk);
857 beam.affect_cell();
858 beam.affect_endpoint();
859 }
860 else
861 ratk.fire();
862
863 if (_returning(weapon))
864 {
865 // Fire beam in reverse.
866 beam.setup_retrace();
867 viewwindow();
868 update_screen();

Callers 2

handle_throwFunction · 0.85
dithmenos_shadow_shootFunction · 0.85

Calls 15

_returningFunction · 0.85
is_throwableFunction · 0.85
mprFunction · 0.85
make_stringfFunction · 0.85
article_aFunction · 0.85
_throw_noiseFunction · 0.85
viewwindowFunction · 0.85
dec_mitm_item_quantityFunction · 0.85
_handle_cannon_fxFunction · 0.85
action_energyMethod · 0.80
observableMethod · 0.80
projectile_nameMethod · 0.80

Tested by

no test coverage detected