| 2821 | } |
| 2822 | |
| 2823 | bool 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 += |
no test coverage detected