OnSpellStart when using DOTA_ABILITY_BEHAVIOR_ATTACK

Hi. I'm trying to create an attack modifier (orb effect) on one of my melee heroes. The hero's AbilityBehavior is defined like so (exactly like Kunkka's Tidebringer):

DOTA_ABILITY_BEHAVIOR_UNIT_TARGET | DOTA_ABILITY_BEHAVIOR_AUTOCAST | DOTA_ABILITY_BEHAVIOR_ATTACK

The ability works perfectly when I use auto-cast but the problem is I have no way of checking if the ability is manually casted by clicking on an enemy unit. I thought I could use OnSpellStart for this but as it turns out OnSpellStart will not run when DOTA_ABILITY_BEHAVIOR_ATTACK is active. Thing is it should be, at least according to some reference sources like this kunkka implementation (look for Tidebringer).

Any help on creating an orb effect?

Comments

  • Posts: 2

    Wow accidentally stumbled across a solution while experimenting. You can make use of the OnOrder function to check if your current order is casting the spell like so:

    function modifier_your_modifier_name:OnOrder(keys)
        if keys.unit == self:GetCaster() then
            if keys.order_type == DOTA_UNIT_ORDER_CAST_TARGET then
                if keys.ability == self:GetAbility() then
                    self:GetAbility().manual_cast = true
                end
            elseif keys.order_type ~= DOTA_UNIT_ORDER_ATTACK_TARGET then
                self:GetAbility().manual_cast = false
            end
        end
    end