#Cast ability without cancelling auto-attack target.

1 messages · Page 1 of 1 (latest)

sour pagoda
#

I have an ability that applies a modifier when cast.

Right now what happens is

  1. A-click
    --hero starts auto-attacking bot
  2. I press Q
    --modifier is applied, but hero stops auto-attacking
  3. A-click again and the auto attack resumes
    --want to not have to a-click again

What I want is

  1. A-click
    --hero starts auto-attacking bot
  2. I press Q
    --modifier is added, auto-attack timer is reset, and hero continues auto-attacking the original target without needing to press any more buttons.

Code for ability is below.

yuki_q = class({})

LinkLuaModifier("modifier_yuki_q", "abilities/yuki/modifier_yuki_q", LUA_MODIFIER_MOTION_NONE)

print("yuki q loaded at least")

function yuki_q:OnSpellStart()
    print("adding yuki Q modifier")
    local caster = self:GetCaster()
    print("adding new modifier")
    caster:AddNewModifier(caster, self, "modifier_yuki_q", {})
end
keen sand
#

whats the behaviour of your ability

lethal flicker
#

I think you want "immediate" cast behavior

#

And 0 cast point

keen sand
#

👆

hoary flax
#

Must be no target as well right?

sour pagoda
#

I had it as just
"AbilityBehavior" "DOTA_ABILITY_BEHAVIOR_NO_TARGET"
changed it to
"AbilityBehavior" "DOTA_ABILITY_BEHAVIOR_IMMEDIATE"
but I think I'd need "AbilityBehavior" "DOTA_ABILITY_BEHAVIOR_IMMEDIATE | DOTA_ABILITY_BEHAVIOR_NO_TARGET"?
I'm about to test ^^

keen sand
#

you do need both

sour pagoda
#

Ty that got stuff most of the way there.
It's continuing to attack the target it was targeting.

#

The only thing I'm not sure about now is resetting the auto-attack timer

#

Would that be done with something like SetBaseAttackTime(0.0)?

#

Nope. My dude is attacking fast now.

gleaming field
#

What 'resetting the auto-attack timer' means?

sour pagoda
#

Basically, make it so the hero can immediately start a new auto-attack.
Not sure what the dota name for it is exactly.

gleaming field
#

there is no such thing in dota afaik

#

echo sabre comes to mind though

sour pagoda
#

Ah I see.
Maybe it's more of an ERBS/league mechanic

gleaming field
#

echo sabre gives a buff with 400 or 500 bonus attack speed so the hero 'can immediately start a new auto-attack' in some way

#

bonus attack speed reduces attack backswing and downtime between attacks

#

maybe that helps

sour pagoda
#

I think it does.
The main thing is making the end part get skipped, and giving super high AS for 1 auto attack would get that done I think

hoary flax
gleaming field
#

yes I wrote that, 400 or 500, idk the exact number

#

but it's not above 500

hoary flax
#

Oh yeah, I should read the rest of the conversation before replying lul

#

Seems like you're on the right path

gleaming field
#

I remember when echo sabre was a good counter to Enchantress' Untouchable, you were able to completely ignore Untouchable and land 2 attacks with Echo Sabre passive. They changed it at one point to how it is now.

sour pagoda
#

Yeah, it seems like probably the best available path since resetting the auto-attack doesn't seem like an option here.
Thanks for the help y'all.

slim oyster
#

I had that same problem but the way I made the fast attack was to use PerformAttack

lethal flicker
#

Yeah I'd recommend an instant attack to simulate it

#

It's not exactly what you're looking for, mechanically, but close enough

sour pagoda
# slim oyster I had that same problem but the way I made the fast attack was to use PerformAtt...

PerformAttack applies another auto-attack worth of damage, but the animation does not reset, and the damage is applied immediately upon using the ability for me.
(code below)

function yuki_q:OnSpellStart()
    if IsServer() then
        local caster = self:GetCaster()
        print("attack ready", caster:AttackReady(), 'is attacking', caster:IsAttacking())
        print("currently attacking", caster:GetAttackTarget())
        if caster:GetAttackTarget() ~= nil and caster:IsAttacking() then
            print('performing attack reset?')
            caster:PerformAttack(caster:GetAttackTarget(), false, true, true, false, false, false, false)
            caster:StartGesture(ACT_MELEE_ATTACK1)
        end
        print()
    end
end

I thought calling StartGesture() would reset the animation, but it doesn't seem to do anything for me.

Did you do something like the above, or am I maybe missing something?

hoary flax
#

Indeed PerformAttack does an instant attack without waiting for an animation cycle. That's intended.

Not sure why StartGesture doesn't work though, I used it in many places. Does it not work even when you're idle?

sour pagoda
#

Yeah, even when just standing around it doesn't do anything.
I was thinking that maybe skills with AbilityBehavior of DOTA_ABILITY_BEHAVIOR_IMMEDIATE can't start animations.

I figured it makes sense for them to not do animation on start, but It'd seem a bit odd to me that they can't start animations/gestures programatically.
Though calling stuff like caster:Interrupt(), caster:SetAttacking(nil), and caster:Stop() didn't do anything either.

hoary flax
#

Ability behaviors only affect cast animations when you cast the spell as a player would. They don't have any effect on something like StartGesture

#

Can you try a different animation? Are you sure this model has the ACT_MELEE_ATTACK1 animation?

sour pagoda
#

I'm not sure how to check that, but I'm using npc_dota_hero_juggernaut so I just assumed it had that animation since it's a melee attack.

hoary flax
#

It might not have an animation named this way exactly. You can check animations in the model editor.

sour pagoda
#

If I change it to StartGesture(ACT_DOTA_CAST_ABILITY_1) it does an animation.
So seems like an issue with it not having that specific animation.

I'll try checking out the model editor tomorrow.

hoary flax
#

That makes sense. I would check but I'm in the office, no access to Dota ^^

#

Will check in tomorrow