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

Function activate_talent

crawl-ref/source/ability.cc:2823–2984  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2821}
2822
2823bool activate_talent(const talent& tal, dist *target)
2824{
2825 const ability_def& abil = get_ability_def(tal.which);
2826
2827 bolt beam;
2828 dist target_local;
2829 if (!target)
2830 target = &target_local;
2831
2832 if (!_check_ability_possible(abil))
2833 {
2834 crawl_state.zero_turns_taken();
2835 return false;
2836 }
2837
2838 const int range = ability_range(abil.ability);
2839 beam.range = range;
2840
2841 bool is_targeted = !!(abil.flags & abflag::targeting_mask);
2842 unique_ptr<targeter> hitfunc = find_ability_targeter(abil.ability);
2843
2844 if (is_targeted
2845 || hitfunc
2846 && (target->fire_context
2847 || Options.always_use_static_ability_targeters
2848 || Options.force_ability_targeter.count(abil.ability) > 0))
2849 {
2850 ability_targeting_behaviour beh(abil.ability);
2851 direction_chooser_args args;
2852
2853 args.hitfunc = hitfunc.get();
2854 args.restricts = testbits(abil.flags, abflag::target) ? DIR_ENFORCE_RANGE
2855 : DIR_NONE;
2856 args.mode = TARG_HOSTILE;
2857 args.range = range;
2858 args.needs_path = !testbits(abil.flags, abflag::target);
2859 args.top_prompt = make_stringf("%s: <w>%s</w>",
2860 is_targeted ? "Aiming" : "Activating",
2861 ability_name(abil.ability).c_str());
2862 targeter_beam* beamfunc = dynamic_cast<targeter_beam*>(hitfunc.get());
2863 if (beamfunc && beamfunc->beam.hit > 0 && !beamfunc->beam.is_explosion)
2864 args.get_desc_func = bind(desc_beam_hit_chance, placeholders::_1, hitfunc.get());
2865 else if (abil.ability == ABIL_YRED_BIND_SOUL)
2866 args.get_desc_func = bind(_desc_bind_soul_hp, placeholders::_1);
2867 else if (abil.ability == ABIL_CHEIBRIADOS_SLOUCH)
2868 args.get_desc_func = bind(_desc_slouch_damage, placeholders::_1);
2869 else if (abil.ability == ABIL_DITHMENOS_APHOTIC_MARIONETTE)
2870 {
2871 args.get_desc_func = bind(_desc_marionette_spells, placeholders::_1);
2872 // Calculate and cache what spells are usable by each target in
2873 // screen so that this doesn't get recalculated numerous times as
2874 // the player interacts with the targeter.
2875 dithmenos_cache_marionette_viability();
2876 }
2877
2878 if (abil.failure.base_chance)
2879 {
2880 args.top_prompt +=

Callers 3

handle_mouseMethod · 0.85
triggerMethod · 0.85
activate_abilityFunction · 0.85

Calls 15

_check_ability_possibleFunction · 0.85
ability_rangeFunction · 0.85
find_ability_targeterFunction · 0.85
testbitsFunction · 0.85
make_stringfFunction · 0.85
ability_nameFunction · 0.85
failure_rate_to_stringFunction · 0.85
spell_directionFunction · 0.85
canned_msgFunction · 0.85
random2avgFunction · 0.85
pay_mpFunction · 0.85

Tested by

no test coverage detected