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 ____CardSystem = require("cards.CardSystem") local CardBase = ____CardSystem.CardBase local RegisterCard = ____CardSystem.RegisterCard local ____CardBaseModifier = require("cards.CardBaseModifier") local CardBaseModifier = ____CardBaseModifier.CardBaseModifier local ____dota_ts_adapter = require("lib.dota_ts_adapter") local registerModifier = ____dota_ts_adapter.registerModifier local CARD_ID = 73 local THINK_INTERVAL = 0.3 ____exports.card_73 = __TS__Class() local card_73 = ____exports.card_73 card_73.name = "card_73" card_73.____file_path = "scripts/vscripts/cards/examples/card_73.lua" __TS__ClassExtends(card_73, CardBase) function card_73.prototype.GetModifierName(self) return "modifier_card_73" end card_73 = __TS__Decorate(card_73, card_73, {RegisterCard}, {kind = "class", name = "card_73"}) ____exports.card_73 = card_73 ____exports.modifier_card_73 = __TS__Class() local modifier_card_73 = ____exports.modifier_card_73 modifier_card_73.name = "modifier_card_73" modifier_card_73.____file_path = "scripts/vscripts/cards/examples/card_73.lua" __TS__ClassExtends(modifier_card_73, CardBaseModifier) function modifier_card_73.prototype.____constructor(self, ...) CardBaseModifier.prototype.____constructor(self, ...) self.skipRumHooks = false self.pendingDeferredDamage = 0 self.drainEndTime = 0 self.pendingTooltipStacks = 0 end function modifier_card_73.prototype.getValue(self, key, fallback) return self:getCardValue(key, fallback, CARD_ID) end function modifier_card_73.prototype.DeclareFunctions(self) return {MODIFIER_PROPERTY_INCOMING_DAMAGE_PERCENTAGE, MODIFIER_EVENT_ON_TAKEDAMAGE, MODIFIER_PROPERTY_TOOLTIP} end function modifier_card_73.prototype.syncPendingTooltipStacks(self) self.pendingTooltipStacks = math.min( 2147483647, math.max( 0, math.floor(self.pendingDeferredDamage + 0.0001) ) ) end function modifier_card_73.prototype.ensureDrainThinkRunning(self, duration) if duration <= 0 then return end self:StartIntervalThink(THINK_INTERVAL) end function modifier_card_73.prototype.GetModifierIncomingDamage_Percentage(self, _event) if self.skipRumHooks then return 0 end local deferPct = math.min( 95, math.max( 1, math.floor(self:getScaledCardValue("deferred_damage_pct", 30)) ) ) return -deferPct end function modifier_card_73.prototype.OnTakeDamage(self, event) if not IsServer() or self.skipRumHooks then return end local parent = self:GetParent() if not parent or not IsValidEntity(parent) or not parent:IsAlive() or not parent:IsRealHero() then return end if event.unit ~= parent then return end local deferPct = math.min( 95, math.max( 1, math.floor(self:getScaledCardValue("deferred_damage_pct", 30)) ) ) local duration = math.max( 0.1, self:getValue("deferred_dot_duration_sec", 3) ) local immediateDamage = event.damage if immediateDamage <= 0 then return end local deferred = math.floor(immediateDamage * deferPct / (100 - deferPct) * 100 + 0.5) / 100 if deferred <= 0 then return end local attacker = event.attacker if attacker and IsValidEntity(attacker) and attacker:IsAlive() and attacker:GetTeamNumber() ~= parent:GetTeamNumber() then self.rumDamageAttacker = attacker elseif not self.rumDamageAttacker or not IsValidEntity(self.rumDamageAttacker) then self.rumDamageAttacker = parent end self.pendingDeferredDamage = self.pendingDeferredDamage + deferred self.drainEndTime = GameRules:GetGameTime() + duration self:syncPendingTooltipStacks() self:ensureDrainThinkRunning(duration) end function modifier_card_73.prototype.OnIntervalThink(self) if not IsServer() then return end local hero = self:GetParent() if not hero or not IsValidEntity(hero) or not hero:IsAlive() or not hero:IsRealHero() then self.pendingDeferredDamage = 0 self:syncPendingTooltipStacks() self:StartIntervalThink(-1) return end if self.pendingDeferredDamage <= 0.001 then self.pendingDeferredDamage = 0 self:syncPendingTooltipStacks() self:StartIntervalThink(-1) return end local now = GameRules:GetGameTime() local tLeft = self.drainEndTime - now local damageAttacker = self.rumDamageAttacker and IsValidEntity(self.rumDamageAttacker) and self.rumDamageAttacker or hero local slice = 0 if tLeft <= 0 then slice = self.pendingDeferredDamage elseif tLeft <= THINK_INTERVAL * 0.5 then slice = self.pendingDeferredDamage else slice = self.pendingDeferredDamage * (THINK_INTERVAL / tLeft) end slice = math.max( 0, math.floor(slice * 100 + 0.5) / 100 ) if slice <= 0 then slice = math.min(self.pendingDeferredDamage, 0.01) end slice = math.min(slice, self.pendingDeferredDamage) self.pendingDeferredDamage = self.pendingDeferredDamage - slice if self.pendingDeferredDamage < 0.001 then self.pendingDeferredDamage = 0 end self:syncPendingTooltipStacks() self.skipRumHooks = true ApplyDamage({ victim = hero, attacker = damageAttacker, damage = slice, damage_type = DAMAGE_TYPE_PURE, damage_flags = DOTA_DAMAGE_FLAG_NO_SPELL_AMPLIFICATION }) self.skipRumHooks = false if self.pendingDeferredDamage <= 0.001 then self:StartIntervalThink(-1) end end function modifier_card_73.prototype.OnTooltip(self) return self.pendingTooltipStacks end function modifier_card_73.prototype.GetTexture(self) return "item_bottle" end modifier_card_73 = __TS__Decorate( modifier_card_73, modifier_card_73, {registerModifier(nil)}, {kind = "class", name = "modifier_card_73"} ) ____exports.modifier_card_73 = modifier_card_73 return ____exports