115 lines
4.1 KiB
Lua
115 lines
4.1 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 ____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 ____ability_stacking_crit = require("abilities.modifiers.ability_stacking_crit")
|
|
local modifier_stacking_crit = ____ability_stacking_crit.modifier_stacking_crit
|
|
local CARD_ID = 65
|
|
local CRIT_SOURCE = "card_65_first_bite_crit"
|
|
____exports.card_65 = __TS__Class()
|
|
local card_65 = ____exports.card_65
|
|
card_65.name = "card_65"
|
|
card_65.____file_path = "scripts/vscripts/cards/examples/card_65.lua"
|
|
__TS__ClassExtends(card_65, CardBase)
|
|
function card_65.prototype.GetModifierName(self)
|
|
return "modifier_card_65"
|
|
end
|
|
card_65 = __TS__Decorate(card_65, card_65, {RegisterCard}, {kind = "class", name = "card_65"})
|
|
____exports.card_65 = card_65
|
|
____exports.modifier_card_65 = __TS__Class()
|
|
local modifier_card_65 = ____exports.modifier_card_65
|
|
modifier_card_65.name = "modifier_card_65"
|
|
modifier_card_65.____file_path = "scripts/vscripts/cards/examples/card_65.lua"
|
|
__TS__ClassExtends(modifier_card_65, CardBaseModifier)
|
|
function modifier_card_65.prototype.getValue(self, key, fallback)
|
|
return self:getCardValue(key, fallback, CARD_ID)
|
|
end
|
|
function modifier_card_65.prototype.OnCustomCreated(self, params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self:ensureCustomCritRegistered()
|
|
end
|
|
function modifier_card_65.prototype.OnCustomRefresh(self, params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self:ensureCustomCritRegistered()
|
|
end
|
|
function modifier_card_65.prototype.OnDestroy(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local attacker = self:GetParent()
|
|
if not attacker or not IsValidEntity(attacker) or not attacker:IsRealHero() then
|
|
return
|
|
end
|
|
local stackingCrit = modifier_stacking_crit:GetForUnit(attacker)
|
|
if stackingCrit ~= nil then
|
|
stackingCrit:RemoveCrit(CRIT_SOURCE)
|
|
end
|
|
if stackingCrit ~= nil then
|
|
stackingCrit:ForceNextCritOnTarget(nil)
|
|
end
|
|
end
|
|
function modifier_card_65.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_EVENT_ON_ATTACK_START}
|
|
end
|
|
function modifier_card_65.prototype.OnAttackStart(self, params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local attacker = self:GetParent()
|
|
if not attacker or not IsValidEntity(attacker) or not attacker:IsRealHero() then
|
|
return
|
|
end
|
|
if params.attacker ~= attacker then
|
|
return
|
|
end
|
|
local target = params.target
|
|
if not target or not IsValidEntity(target) or target:IsNull() or not target:IsAlive() then
|
|
return
|
|
end
|
|
if target:GetTeamNumber() == attacker:GetTeamNumber() then
|
|
return
|
|
end
|
|
local stackingCrit = modifier_stacking_crit:GetForUnit(attacker)
|
|
if not stackingCrit then
|
|
return
|
|
end
|
|
local fullHpThresholdPct = self:getValue("target_hp_full_pct", 100)
|
|
if target:GetHealthPercent() >= fullHpThresholdPct then
|
|
stackingCrit:ForceNextCritOnTarget(target)
|
|
return
|
|
end
|
|
stackingCrit:ForceNextCritOnTarget(nil)
|
|
end
|
|
function modifier_card_65.prototype.ensureCustomCritRegistered(self)
|
|
local attacker = self:GetParent()
|
|
if not attacker or not IsValidEntity(attacker) or not attacker:IsRealHero() then
|
|
return
|
|
end
|
|
local stackingCrit = modifier_stacking_crit:GetForUnit(attacker)
|
|
if not stackingCrit then
|
|
return
|
|
end
|
|
local critMultiplierPct = self:getValue("crit_multiplier_pct", 200) * self:getCardCopies()
|
|
stackingCrit:UpdateExistingCrit(0, critMultiplierPct, CRIT_SOURCE)
|
|
end
|
|
modifier_card_65 = __TS__Decorate(
|
|
modifier_card_65,
|
|
modifier_card_65,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_65"}
|
|
)
|
|
____exports.modifier_card_65 = modifier_card_65
|
|
return ____exports
|