Skip to content

Commit

Permalink
refactor(items): usd OnAttackLanded as a pure damage entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
ark120202 committed Nov 21, 2018
1 parent 661087d commit c70157c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
9 changes: 4 additions & 5 deletions game/scripts/vscripts/items/item_piercing_blade.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ modifier_item_piercing_blade = {
function modifier_item_piercing_blade:DeclareFunctions()
return {
MODIFIER_PROPERTY_PREATTACK_BONUS_DAMAGE,
MODIFIER_EVENT_ON_TAKEDAMAGE,
MODIFIER_EVENT_ON_ATTACK_LANDED,
}
end

Expand All @@ -22,14 +22,13 @@ function modifier_item_piercing_blade:GetModifierPreAttack_BonusDamage()
end

if IsServer() then
function modifier_item_piercing_blade:OnTakeDamage(keys)
function modifier_item_piercing_blade:OnAttackLanded(keys)
local attacker = keys.attacker
if attacker ~= self:GetParent() then return end
if keys.damage_type ~= DAMAGE_TYPE_PHYSICAL or keys.inflictor then return end

local ability = self:GetAbility()

ApplyDamage({
victim = keys.unit,
victim = keys.target,
attacker = attacker,
damage = keys.original_damage * ability:GetSpecialValueFor("attack_damage_to_pure_pct") * 0.01,
damage_type = ability:GetAbilityDamageType(),
Expand Down
16 changes: 4 additions & 12 deletions game/scripts/vscripts/items/item_soulcutter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function modifier_item_soulcutter:DeclareFunctions()
return {
MODIFIER_PROPERTY_PREATTACK_BONUS_DAMAGE,
MODIFIER_PROPERTY_ATTACKSPEED_BONUS_CONSTANT,
MODIFIER_EVENT_ON_TAKEDAMAGE,
MODIFIER_EVENT_ON_ATTACK_LANDED,
}
end
Expand All @@ -34,30 +33,23 @@ function modifier_item_soulcutter:GetModifierAttackSpeedBonus_Constant()
end

if IsServer() then
function modifier_item_soulcutter:OnTakeDamage(keys)
function modifier_item_soulcutter:OnAttackLanded(keys)
local attacker = keys.attacker
if attacker ~= self:GetParent() then return end
if keys.damage_type ~= DAMAGE_TYPE_PHYSICAL or keys.inflictor then return end

local ability = self:GetAbility()
local target = keys.target

ApplyDamage({
victim = keys.unit,
victim = target,
attacker = attacker,
damage = keys.original_damage * ability:GetSpecialValueFor("attack_damage_to_pure_pct") * 0.01,
damage_type = ability:GetAbilityDamageType(),
damage_flags = DOTA_DAMAGE_FLAG_NO_SPELL_AMPLIFICATION,
})
end

function modifier_item_soulcutter:OnAttackLanded(keys)
local attacker = keys.attacker
if attacker ~= self:GetParent() then return end
local target = keys.target
if target:IsBoss() then return end
local ability = self:GetAbility()

ParticleManager:CreateParticle("particles/arena/items_fx/dark_flow_explosion.vpcf", PATTACH_ABSORIGIN_FOLLOW, target)

target:AddNewModifier(
target,
ability,
Expand Down

0 comments on commit c70157c

Please sign in to comment.