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 ____incoming_damage_reduction_combine = require("utils.incoming_damage_reduction_combine") local removeIncomingDamageReductionSource = ____incoming_damage_reduction_combine.removeIncomingDamageReductionSource local setIncomingDamageReductionEventSource = ____incoming_damage_reduction_combine.setIncomingDamageReductionEventSource local CARD_ID = 77 local CARD_77_INCOMING_SOURCE = "modifier_card_77" local MANA_SHIELD_PARTICLE = "particles/econ/items/medusa/medusa_daughters/medusa_daughters_mana_shield_shell_impact_d.vpcf" ____exports.card_77 = __TS__Class() local card_77 = ____exports.card_77 card_77.name = "card_77" card_77.____file_path = "scripts/vscripts/cards/examples/card_77.lua" __TS__ClassExtends(card_77, CardBase) function card_77.prototype.GetModifierName(self) return "modifier_card_77" end card_77 = __TS__Decorate(card_77, card_77, {RegisterCard}, {kind = "class", name = "card_77"}) ____exports.card_77 = card_77 ____exports.modifier_card_77 = __TS__Class() local modifier_card_77 = ____exports.modifier_card_77 modifier_card_77.name = "modifier_card_77" modifier_card_77.____file_path = "scripts/vscripts/cards/examples/card_77.lua" __TS__ClassExtends(modifier_card_77, CardBaseModifier) function modifier_card_77.prototype.getValue(self, key, fallback) return self:getCardValue(key, fallback, CARD_ID) end function modifier_card_77.prototype.OnCustomRefresh(self, _params) if not IsServer() then return end removeIncomingDamageReductionSource( nil, self:GetParent(), CARD_77_INCOMING_SOURCE ) self:OnCustomCreated(_params) end function modifier_card_77.prototype.OnCustomCreated(self, params) if not IsServer() then return end setIncomingDamageReductionEventSource( nil, self:GetParent(), CARD_77_INCOMING_SOURCE, function(____, event) local hero = self:GetParent() if not hero or not IsValidEntity(hero) or not hero:IsAlive() or not hero:IsRealHero() then return 0 end local reducePct = math.min( 95, math.max( 1, math.floor(self:getScaledCardValue("damage_reduction_pct", 60)) ) ) local manaPerMitigated = math.max( 0.01, self:getScaledCardValue("mana_per_mitigated_damage", 1) ) local baseDamage = self:readBaseDamageFromAttackEvent(event) if baseDamage <= 0 then return 0 end local targetBlocked = baseDamage * (reducePct / 100) local maxBlockedFromMana = hero:GetMana() / manaPerMitigated local actualBlocked = math.min(targetBlocked, maxBlockedFromMana) if actualBlocked <= 0 then return 0 end return math.max(0, actualBlocked / baseDamage * 100) end ) end function modifier_card_77.prototype.OnDestroy(self) if not IsServer() then return end removeIncomingDamageReductionSource( nil, self:GetParent(), CARD_77_INCOMING_SOURCE ) end function modifier_card_77.prototype.DeclareFunctions(self) return {MODIFIER_EVENT_ON_TAKEDAMAGE, MODIFIER_PROPERTY_TOOLTIP} end function modifier_card_77.prototype.GetEffectName(self) return "particles/units/heroes/hero_medusa/medusa_mana_shield.vpcf" end function modifier_card_77.prototype.GetEffectAttachType(self) return PATTACH_ABSORIGIN_FOLLOW end function modifier_card_77.prototype.readBaseDamageFromAttackEvent(self, event) local raw = event local fromOriginal = raw.original_damage if fromOriginal ~= nil and fromOriginal ~= nil and fromOriginal > 0 then return fromOriginal end local d = raw.damage if d ~= nil and d ~= nil and d > 0 then return d end return 0 end function modifier_card_77.prototype.OnTakeDamage(self, event) if not IsServer() 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 reducePct = math.min( 95, math.max( 1, math.floor(self:getScaledCardValue("damage_reduction_pct", 60)) ) ) local manaPerMitigated = math.max( 0.01, self:getScaledCardValue("mana_per_mitigated_damage", 1) ) local rawEv = event local original = rawEv.original_damage ~= nil and rawEv.original_damage ~= nil and rawEv.original_damage or event.damage local finalDamage = event.damage if original <= 0 then return end local totalMitigated = math.max(0, original - finalDamage) if totalMitigated <= 0 then return end local expectedFromCard = original * (reducePct / 100) local attributedBlock = math.min(expectedFromCard, totalMitigated) if attributedBlock <= 0 then return end local manaCost = attributedBlock * manaPerMitigated if manaCost <= 0 then return end local manaBefore = parent:GetMana() local manaPaid = math.min(manaCost, manaBefore) if manaPaid <= 0 then return end parent:SetMana(math.max(0, manaBefore - manaPaid)) local shieldFx = ParticleManager:CreateParticle(MANA_SHIELD_PARTICLE, PATTACH_ABSORIGIN_FOLLOW, parent) ParticleManager:ReleaseParticleIndex(shieldFx) end modifier_card_77 = __TS__Decorate( modifier_card_77, modifier_card_77, {registerModifier(nil)}, {kind = "class", name = "modifier_card_77"} ) ____exports.modifier_card_77 = modifier_card_77 return ____exports