#Split shot custom ability, projectiles work, registering projectiles for damage doesn't

1 messages · Page 1 of 1 (latest)

paper briar
#

As title says, code:

function modifier_dire_tower_boss_glyph:OnAttack( keys )
    local unit = self:GetParent() -- Get the unit that has this modifier attached
    if unit:HasModifier("modifier_dire_tower_boss_glyph") then
      self:SplitShot( keys.target)
    end
end

function modifier_dire_tower_boss_glyph:OnProjectileHit_ExtraData(target, location, data)
  print("sprojectiles")
  local caster = self:GetCaster()

  -- If there is no target don't continue
  if not target or not data then
    return
  end

  print("secondary shot")
  caster:PerformAttack(target, false, false, true, false, false, false, false)
end


function modifier_dire_tower_boss_glyph:SplitShot(target )
    local radius = self.parent:Script_GetAttackRange() + self.bonus_range
    local enemies = FindUnitsInRadius(
        self.parent:GetTeamNumber(),
        self.parent:GetOrigin(),
        nil,
        radius,
        DOTA_UNIT_TARGET_TEAM_ENEMY,
        DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC + DOTA_UNIT_TARGET_COURIER,
        DOTA_UNIT_TARGET_FLAG_FOW_VISIBLE + DOTA_UNIT_TARGET_FLAG_NO_INVIS + DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES,
        0,
        false
    )

    local count = 0
    for _,enemy in pairs(enemies) do
        if enemy~=target then
            local info = {
                Target = enemy,
                Source = self.parent,
                Ability = self:GetAbility(),
                EffectName = self.projectile_name,
                iMoveSpeed = self.projectile_speed,
                bDodgeable = true,
                ExtraData = {
                  secondary_shot = true
                }
            }
            ProjectileManager:CreateTrackingProjectile(info)

            count = count + 1
            if count >= self.count then break end
        end
    end

    if count>0 then
        EmitSoundOn( "Hero_Medusa.AttackSplit", self.parent )
    end
end
#

It does not print either debug line :/

#

I realised my registed functions are only

function modifier_dire_tower_boss_glyph:DeclareFunctions()
  local funcs = {
    MODIFIER_PROPERTY_INCOMING_DAMAGE_PERCENTAGE,
    MODIFIER_EVENT_ON_ATTACK,
    MODIFIER_PROPERTY_ATTACKSPEED_BONUS_CONSTANT,
  }

  return 

However I can't find the event for projectile?

#

no evidence here in API of what ive done wrong..

#

im a very confused

novel lion
#

attack projectiles are different from spell projectiles.

#

CreateProjectile and OnProjectileHit refers to spell projectiles like CK stun, while attack projectiles are like Medusa Split Shot

#

I dont know if instant attacks would be registered or not, but it's easy to make the attack know that it is instant: you sandwich PerformAttack with some kind of tag

#

like,

self.split_shot = true
PerformAttack()
self.split_shot = false

so you know if that instant attack is your own split shot

paper briar
novel lion
#

so, the event modifier will proc on many kinds of attacks.
This includes PerformAttack itself. Think of it that performattack will trigger OnAttack.

when you sandwich that, you can check if self.split_shot==true during OnAttack or other events.
If the value is true, you know that it is your PerformAttack, because it will only be true inside the sandwich.

paper briar
#

THank you very much

flint quiver
#

He is not my son, I swear 🙂