415 lines
17 KiB
Lua
415 lines
17 KiB
Lua
local ____lualib = require("lualib_bundle")
|
|
local __TS__Class = ____lualib.__TS__Class
|
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
local __TS__Decorate = ____lualib.__TS__Decorate
|
|
local ____exports = {}
|
|
local ____dota_ts_adapter = require("lib.dota_ts_adapter")
|
|
local BaseItem = ____dota_ts_adapter.BaseItem
|
|
local BaseModifier = ____dota_ts_adapter.BaseModifier
|
|
local registerAbility = ____dota_ts_adapter.registerAbility
|
|
local registerModifier = ____dota_ts_adapter.registerModifier
|
|
local ____luck = require("utils.luck")
|
|
local rollLuckChance = ____luck.rollLuckChance
|
|
local DESOLATOR_PROJECTILE = "particles/items_fx/desolator_projectile.vpcf"
|
|
--- Кастомный Desolator (порт zombie_invasion): урон, HP, заряды с убийств, коррупция брони, снаряд.
|
|
____exports.item_desolator_custom = __TS__Class()
|
|
local item_desolator_custom = ____exports.item_desolator_custom
|
|
item_desolator_custom.name = "item_desolator_custom"
|
|
item_desolator_custom.____file_path = "scripts/vscripts/items/default_items/item_desolator_custom.lua"
|
|
__TS__ClassExtends(item_desolator_custom, BaseItem)
|
|
function item_desolator_custom.prototype.Precache(self, context)
|
|
PrecacheResource("particle", DESOLATOR_PROJECTILE, context)
|
|
PrecacheResource("particle", "particles/units/heroes/hero_spectre/spectre_desolate_debuff.vpcf", context)
|
|
end
|
|
function item_desolator_custom.prototype.GetIntrinsicModifierName(self)
|
|
return ____exports.modifier_item_desolator_custom.name
|
|
end
|
|
item_desolator_custom = __TS__Decorate(
|
|
item_desolator_custom,
|
|
item_desolator_custom,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "item_desolator_custom"}
|
|
)
|
|
____exports.item_desolator_custom = item_desolator_custom
|
|
____exports.modifier_item_desolator_custom = __TS__Class()
|
|
local modifier_item_desolator_custom = ____exports.modifier_item_desolator_custom
|
|
modifier_item_desolator_custom.name = "modifier_item_desolator_custom"
|
|
modifier_item_desolator_custom.____file_path = "scripts/vscripts/items/default_items/item_desolator_custom.lua"
|
|
__TS__ClassExtends(modifier_item_desolator_custom, BaseModifier)
|
|
function modifier_item_desolator_custom.prototype.IsHidden(self)
|
|
return true
|
|
end
|
|
function modifier_item_desolator_custom.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_item_desolator_custom.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_item_desolator_custom.prototype.GetPriority(self)
|
|
return MODIFIER_PRIORITY_ULTRA
|
|
end
|
|
function modifier_item_desolator_custom.prototype.DeclareFunctions(self)
|
|
return {
|
|
MODIFIER_PROPERTY_PREATTACK_BONUS_DAMAGE,
|
|
MODIFIER_PROPERTY_EXTRA_HEALTH_BONUS,
|
|
MODIFIER_EVENT_ON_ATTACK_LANDED,
|
|
MODIFIER_EVENT_ON_DEATH,
|
|
MODIFIER_PROPERTY_PROJECTILE_NAME
|
|
}
|
|
end
|
|
function modifier_item_desolator_custom.prototype.GetModifierProjectileName(self)
|
|
return DESOLATOR_PROJECTILE
|
|
end
|
|
function modifier_item_desolator_custom.prototype.GetModifierPreAttack_BonusDamage(self)
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return 0
|
|
end
|
|
return ability:GetSpecialValueFor("bonus_damage") + ability:GetCurrentCharges()
|
|
end
|
|
function modifier_item_desolator_custom.prototype.GetModifierExtraHealthBonus(self)
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return 0
|
|
end
|
|
return ability:GetSpecialValueFor("bonus_health") + ability:GetCurrentCharges()
|
|
end
|
|
function modifier_item_desolator_custom.prototype.OnAttackLanded(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local parent = self:GetParent()
|
|
if event.attacker ~= parent or not event.target then
|
|
return
|
|
end
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return
|
|
end
|
|
local duration = ability:GetSpecialValueFor("corruption_duration")
|
|
event.target:AddNewModifier(parent, ability, ____exports.modifier_item_desolator_custom_debuff.name, {duration = duration})
|
|
end
|
|
function modifier_item_desolator_custom.prototype.OnDeath(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local parent = self:GetParent()
|
|
local ability = self:GetAbility()
|
|
if not ability or not (parent and parent:IsAlive()) then
|
|
return
|
|
end
|
|
if event.attacker ~= parent then
|
|
return
|
|
end
|
|
local victim = event.unit
|
|
if not victim or victim == parent or not IsValidEntity(victim) then
|
|
return
|
|
end
|
|
if not victim:HasModifier(____exports.modifier_item_desolator_custom_debuff.name) then
|
|
return
|
|
end
|
|
local chancePct = ability:GetSpecialValueFor("chance_to_stack")
|
|
if chancePct <= 0 then
|
|
return
|
|
end
|
|
local ____parent_IsRealHero_result_2
|
|
if parent:IsRealHero() then
|
|
____parent_IsRealHero_result_2 = rollLuckChance(nil, parent, chancePct / 100)
|
|
else
|
|
____parent_IsRealHero_result_2 = RollPercentage(chancePct)
|
|
end
|
|
local stacked = ____parent_IsRealHero_result_2
|
|
if not stacked then
|
|
return
|
|
end
|
|
local maxCap = ability:GetSpecialValueFor("max_damage")
|
|
local perKill = ability:GetSpecialValueFor("bonus_damage_per_kill")
|
|
local next = math.min(
|
|
ability:GetCurrentCharges() + perKill,
|
|
maxCap
|
|
)
|
|
ability:SetCurrentCharges(next)
|
|
if parent:IsRealHero() then
|
|
parent:CalculateStatBonus(true)
|
|
end
|
|
end
|
|
function modifier_item_desolator_custom.prototype.GetTexture(self)
|
|
return "item_desolator"
|
|
end
|
|
modifier_item_desolator_custom = __TS__Decorate(
|
|
modifier_item_desolator_custom,
|
|
modifier_item_desolator_custom,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_item_desolator_custom"}
|
|
)
|
|
____exports.modifier_item_desolator_custom = modifier_item_desolator_custom
|
|
____exports.modifier_item_desolator_custom_debuff = __TS__Class()
|
|
local modifier_item_desolator_custom_debuff = ____exports.modifier_item_desolator_custom_debuff
|
|
modifier_item_desolator_custom_debuff.name = "modifier_item_desolator_custom_debuff"
|
|
modifier_item_desolator_custom_debuff.____file_path = "scripts/vscripts/items/default_items/item_desolator_custom.lua"
|
|
__TS__ClassExtends(modifier_item_desolator_custom_debuff, BaseModifier)
|
|
function modifier_item_desolator_custom_debuff.prototype.____constructor(self, ...)
|
|
BaseModifier.prototype.____constructor(self, ...)
|
|
self.armorDebuff = 0
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.IsDebuff(self)
|
|
return true
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.IsPurgable(self)
|
|
return true
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.OnCreated(self)
|
|
self:RefreshVals()
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.OnRefresh(self)
|
|
self:RefreshVals()
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.RefreshVals(self)
|
|
local ability = self:GetAbility()
|
|
self.armorDebuff = ability and ability:GetSpecialValueFor("corruption_armor") or 0
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_PHYSICAL_ARMOR_BONUS, MODIFIER_PROPERTY_HEALTH_REGEN_PERCENTAGE, MODIFIER_PROPERTY_MOVESPEED_BONUS_PERCENTAGE}
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.GetModifierPhysicalArmorBonus(self)
|
|
return self.armorDebuff
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.GetModifierMoveSpeedBonus_Percentage(self)
|
|
local ability = self:GetAbility()
|
|
return ability and ability:GetSpecialValueFor("corruption_movespeed_slow") or 0
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.GetModifierHealthRegenPercentage(self)
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return 1
|
|
end
|
|
local v = ability:GetSpecialValueFor("corruption_heal_reduction")
|
|
return 1 + (v - 100) * 0.01
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.GetEffectName(self)
|
|
return "particles/units/heroes/hero_spectre/spectre_desolate_debuff.vpcf"
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.GetEffectAttachType(self)
|
|
return PATTACH_ABSORIGIN_FOLLOW
|
|
end
|
|
function modifier_item_desolator_custom_debuff.prototype.GetTexture(self)
|
|
return "item_desolator"
|
|
end
|
|
modifier_item_desolator_custom_debuff = __TS__Decorate(
|
|
modifier_item_desolator_custom_debuff,
|
|
modifier_item_desolator_custom_debuff,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_item_desolator_custom_debuff"}
|
|
)
|
|
____exports.modifier_item_desolator_custom_debuff = modifier_item_desolator_custom_debuff
|
|
____exports.item_desolator_custom_2 = __TS__Class()
|
|
local item_desolator_custom_2 = ____exports.item_desolator_custom_2
|
|
item_desolator_custom_2.name = "item_desolator_custom_2"
|
|
item_desolator_custom_2.____file_path = "scripts/vscripts/items/default_items/item_desolator_custom.lua"
|
|
__TS__ClassExtends(item_desolator_custom_2, BaseItem)
|
|
function item_desolator_custom_2.prototype.Precache(self, context)
|
|
PrecacheResource("particle", DESOLATOR_PROJECTILE, context)
|
|
PrecacheResource("particle", "particles/units/heroes/hero_spectre/spectre_desolate_debuff.vpcf", context)
|
|
end
|
|
function item_desolator_custom_2.prototype.GetIntrinsicModifierName(self)
|
|
return ____exports.modifier_item_desolator_custom_2.name
|
|
end
|
|
item_desolator_custom_2 = __TS__Decorate(
|
|
item_desolator_custom_2,
|
|
item_desolator_custom_2,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "item_desolator_custom_2"}
|
|
)
|
|
____exports.item_desolator_custom_2 = item_desolator_custom_2
|
|
____exports.modifier_item_desolator_custom_2 = __TS__Class()
|
|
local modifier_item_desolator_custom_2 = ____exports.modifier_item_desolator_custom_2
|
|
modifier_item_desolator_custom_2.name = "modifier_item_desolator_custom_2"
|
|
modifier_item_desolator_custom_2.____file_path = "scripts/vscripts/items/default_items/item_desolator_custom.lua"
|
|
__TS__ClassExtends(modifier_item_desolator_custom_2, BaseModifier)
|
|
function modifier_item_desolator_custom_2.prototype.IsHidden(self)
|
|
return true
|
|
end
|
|
function modifier_item_desolator_custom_2.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_item_desolator_custom_2.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_item_desolator_custom_2.prototype.GetPriority(self)
|
|
return MODIFIER_PRIORITY_ULTRA
|
|
end
|
|
function modifier_item_desolator_custom_2.prototype.DeclareFunctions(self)
|
|
return {
|
|
MODIFIER_PROPERTY_PREATTACK_BONUS_DAMAGE,
|
|
MODIFIER_PROPERTY_EXTRA_HEALTH_BONUS,
|
|
MODIFIER_EVENT_ON_ATTACK_LANDED,
|
|
MODIFIER_EVENT_ON_DEATH,
|
|
MODIFIER_PROPERTY_PROJECTILE_NAME
|
|
}
|
|
end
|
|
function modifier_item_desolator_custom_2.prototype.GetModifierProjectileName(self)
|
|
return DESOLATOR_PROJECTILE
|
|
end
|
|
function modifier_item_desolator_custom_2.prototype.GetModifierPreAttack_BonusDamage(self)
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return 0
|
|
end
|
|
return ability:GetSpecialValueFor("bonus_damage") + ability:GetCurrentCharges()
|
|
end
|
|
function modifier_item_desolator_custom_2.prototype.GetModifierExtraHealthBonus(self)
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return 0
|
|
end
|
|
return ability:GetSpecialValueFor("bonus_health") + ability:GetCurrentCharges()
|
|
end
|
|
function modifier_item_desolator_custom_2.prototype.OnAttackLanded(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local parent = self:GetParent()
|
|
if event.attacker ~= parent or not event.target then
|
|
return
|
|
end
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return
|
|
end
|
|
local duration = ability:GetSpecialValueFor("corruption_duration")
|
|
local perStack = ability:GetSpecialValueFor("corruption_armor_per_stack")
|
|
local cap = ability:GetSpecialValueFor("corruption_armor_cap")
|
|
local maxStacks = math.max(
|
|
1,
|
|
math.ceil(cap / math.max(1, perStack))
|
|
)
|
|
local target = event.target
|
|
local existing = target:FindModifierByName(____exports.modifier_item_desolator_custom_2_debuff.name)
|
|
if existing then
|
|
if existing:GetStackCount() < maxStacks then
|
|
existing:IncrementStackCount()
|
|
end
|
|
existing:SetDuration(duration, true)
|
|
else
|
|
local m = target:AddNewModifier(parent, ability, ____exports.modifier_item_desolator_custom_2_debuff.name, {duration = duration})
|
|
if m ~= nil then
|
|
m:SetStackCount(1)
|
|
end
|
|
end
|
|
end
|
|
function modifier_item_desolator_custom_2.prototype.OnDeath(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local parent = self:GetParent()
|
|
local ability = self:GetAbility()
|
|
if not ability or not (parent and parent:IsAlive()) then
|
|
return
|
|
end
|
|
if event.attacker ~= parent then
|
|
return
|
|
end
|
|
local victim = event.unit
|
|
if not victim or victim == parent or not IsValidEntity(victim) then
|
|
return
|
|
end
|
|
if not victim:HasModifier(____exports.modifier_item_desolator_custom_2_debuff.name) then
|
|
return
|
|
end
|
|
local chancePct = ability:GetSpecialValueFor("chance_to_stack")
|
|
if chancePct <= 0 then
|
|
return
|
|
end
|
|
local ____parent_IsRealHero_result_7
|
|
if parent:IsRealHero() then
|
|
____parent_IsRealHero_result_7 = rollLuckChance(nil, parent, chancePct / 100)
|
|
else
|
|
____parent_IsRealHero_result_7 = RollPercentage(chancePct)
|
|
end
|
|
local stacked = ____parent_IsRealHero_result_7
|
|
if not stacked then
|
|
return
|
|
end
|
|
local maxCap = ability:GetSpecialValueFor("max_damage")
|
|
local perKill = ability:GetSpecialValueFor("bonus_damage_per_kill")
|
|
local next = math.min(
|
|
ability:GetCurrentCharges() + perKill,
|
|
maxCap
|
|
)
|
|
ability:SetCurrentCharges(next)
|
|
if parent:IsRealHero() then
|
|
parent:CalculateStatBonus(true)
|
|
end
|
|
end
|
|
function modifier_item_desolator_custom_2.prototype.GetTexture(self)
|
|
return "item_desolator_2"
|
|
end
|
|
modifier_item_desolator_custom_2 = __TS__Decorate(
|
|
modifier_item_desolator_custom_2,
|
|
modifier_item_desolator_custom_2,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_item_desolator_custom_2"}
|
|
)
|
|
____exports.modifier_item_desolator_custom_2 = modifier_item_desolator_custom_2
|
|
____exports.modifier_item_desolator_custom_2_debuff = __TS__Class()
|
|
local modifier_item_desolator_custom_2_debuff = ____exports.modifier_item_desolator_custom_2_debuff
|
|
modifier_item_desolator_custom_2_debuff.name = "modifier_item_desolator_custom_2_debuff"
|
|
modifier_item_desolator_custom_2_debuff.____file_path = "scripts/vscripts/items/default_items/item_desolator_custom.lua"
|
|
__TS__ClassExtends(modifier_item_desolator_custom_2_debuff, BaseModifier)
|
|
function modifier_item_desolator_custom_2_debuff.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_item_desolator_custom_2_debuff.prototype.IsDebuff(self)
|
|
return true
|
|
end
|
|
function modifier_item_desolator_custom_2_debuff.prototype.IsPurgable(self)
|
|
return true
|
|
end
|
|
function modifier_item_desolator_custom_2_debuff.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_PHYSICAL_ARMOR_BONUS, MODIFIER_PROPERTY_HEALTH_REGEN_PERCENTAGE, MODIFIER_PROPERTY_MOVESPEED_BONUS_PERCENTAGE}
|
|
end
|
|
function modifier_item_desolator_custom_2_debuff.prototype.GetModifierPhysicalArmorBonus(self)
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return 0
|
|
end
|
|
local perStack = ability:GetSpecialValueFor("corruption_armor_per_stack")
|
|
local cap = ability:GetSpecialValueFor("corruption_armor_cap")
|
|
return -math.min(
|
|
self:GetStackCount() * perStack,
|
|
cap
|
|
)
|
|
end
|
|
function modifier_item_desolator_custom_2_debuff.prototype.GetModifierMoveSpeedBonus_Percentage(self)
|
|
local ability = self:GetAbility()
|
|
return ability and ability:GetSpecialValueFor("corruption_movespeed_slow") or 0
|
|
end
|
|
function modifier_item_desolator_custom_2_debuff.prototype.GetModifierHealthRegenPercentage(self)
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return 1
|
|
end
|
|
local v = ability:GetSpecialValueFor("corruption_heal_reduction")
|
|
return 1 + (v - 100) * 0.01
|
|
end
|
|
function modifier_item_desolator_custom_2_debuff.prototype.GetEffectName(self)
|
|
return "particles/units/heroes/hero_spectre/spectre_desolate_debuff.vpcf"
|
|
end
|
|
function modifier_item_desolator_custom_2_debuff.prototype.GetEffectAttachType(self)
|
|
return PATTACH_ABSORIGIN_FOLLOW
|
|
end
|
|
function modifier_item_desolator_custom_2_debuff.prototype.GetTexture(self)
|
|
return "item_desolator_2"
|
|
end
|
|
modifier_item_desolator_custom_2_debuff = __TS__Decorate(
|
|
modifier_item_desolator_custom_2_debuff,
|
|
modifier_item_desolator_custom_2_debuff,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_item_desolator_custom_2_debuff"}
|
|
)
|
|
____exports.modifier_item_desolator_custom_2_debuff = modifier_item_desolator_custom_2_debuff
|
|
return ____exports
|