322 lines
11 KiB
Lua
322 lines
11 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 ____modifier_general_hunger = require("abilities.modifiers.modifier_general_hunger")
|
|
local modifier_general_hunger = ____modifier_general_hunger.modifier_general_hunger
|
|
local ____dota_ts_adapter = require("lib.dota_ts_adapter")
|
|
local BaseItem = ____dota_ts_adapter.BaseItem
|
|
local registerAbility = ____dota_ts_adapter.registerAbility
|
|
local registerModifier = ____dota_ts_adapter.registerModifier
|
|
local BaseModifier = ____dota_ts_adapter.BaseModifier
|
|
____exports.item_candy = __TS__Class()
|
|
local item_candy = ____exports.item_candy
|
|
item_candy.name = "item_candy"
|
|
item_candy.____file_path = "scripts/vscripts/items/util_items/item_candys.lua"
|
|
__TS__ClassExtends(item_candy, BaseItem)
|
|
function item_candy.prototype.CastFilterResultTarget(self, target)
|
|
if IsServer() then
|
|
if not target:IsRealHero() then
|
|
return UF_FAIL_CUSTOM
|
|
end
|
|
if self:GetCurrentCharges() < self:GetInitialCharges() then
|
|
return UF_FAIL_CUSTOM
|
|
end
|
|
return UF_SUCCESS
|
|
end
|
|
return UF_SUCCESS
|
|
end
|
|
function item_candy.prototype.GetCustomCastErrorTarget(self, target)
|
|
if IsServer() then
|
|
if not target:IsRealHero() then
|
|
return "#dota_hud_error_cheese_bad_target"
|
|
end
|
|
if self:GetCurrentCharges() < self:GetInitialCharges() then
|
|
return "#dota_hud_error_havent_charges"
|
|
end
|
|
end
|
|
return ""
|
|
end
|
|
function item_candy.prototype.OnSpellStart(self)
|
|
local target = self:GetCursorTarget()
|
|
local item = self
|
|
if target == nil then
|
|
return
|
|
end
|
|
target:EmitSound("DOTA_Item.Cheese.Activate")
|
|
if target and target:IsRealHero() then
|
|
local modifier = target:AddNewModifier(
|
|
self:GetCaster(),
|
|
self,
|
|
modifier_general_hunger.name,
|
|
{}
|
|
)
|
|
local candyModifiers = {____exports.modifier_chocolate_candy.name, ____exports.modifier_caramel_candy.name, ____exports.modifier_mint_candy.name, ____exports.modifier_magic_candy.name}
|
|
local randomIndex = math.floor(math.random() * #candyModifiers)
|
|
local selectedModifier = candyModifiers[randomIndex + 1]
|
|
target:AddNewModifier(
|
|
self:GetCaster(),
|
|
self,
|
|
selectedModifier,
|
|
{duration = 30}
|
|
)
|
|
if modifier then
|
|
local hunger_bonus = self:GetSpecialValueFor("hunger_bonus")
|
|
do
|
|
local i = 0
|
|
while i < hunger_bonus do
|
|
modifier:IncrementStackCount()
|
|
i = i + 1
|
|
end
|
|
end
|
|
if item:GetCurrentCharges() <= item:GetInitialCharges() then
|
|
UTIL_Remove(item)
|
|
return
|
|
end
|
|
item:SetCurrentCharges(item:GetCurrentCharges() - item:GetInitialCharges())
|
|
end
|
|
end
|
|
end
|
|
item_candy = __TS__Decorate(
|
|
item_candy,
|
|
item_candy,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "item_candy"}
|
|
)
|
|
____exports.item_candy = item_candy
|
|
____exports.modifier_chocolate_candy = __TS__Class()
|
|
local modifier_chocolate_candy = ____exports.modifier_chocolate_candy
|
|
modifier_chocolate_candy.name = "modifier_chocolate_candy"
|
|
modifier_chocolate_candy.____file_path = "scripts/vscripts/items/util_items/item_candys.lua"
|
|
__TS__ClassExtends(modifier_chocolate_candy, BaseModifier)
|
|
function modifier_chocolate_candy.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_chocolate_candy.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_chocolate_candy.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_MOVESPEED_BONUS_PERCENTAGE}
|
|
end
|
|
function modifier_chocolate_candy.prototype.GetModifierMoveSpeedBonus_Percentage(self)
|
|
return 15
|
|
end
|
|
function modifier_chocolate_candy.prototype.OnCreated(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self:StartIntervalThink(0.33)
|
|
end
|
|
function modifier_chocolate_candy.prototype.OnIntervalThink(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local parent = self:GetParent()
|
|
if not parent or not parent:IsAlive() then
|
|
return
|
|
end
|
|
if parent:IsMoving() then
|
|
else
|
|
ApplyDamage({
|
|
victim = parent,
|
|
attacker = parent,
|
|
damage = self:GetParent():GetHealth() * 0.01,
|
|
damage_type = DAMAGE_TYPE_PURE
|
|
})
|
|
end
|
|
end
|
|
function modifier_chocolate_candy.prototype.GetTexture(self)
|
|
return "util_items/candy"
|
|
end
|
|
modifier_chocolate_candy = __TS__Decorate(
|
|
modifier_chocolate_candy,
|
|
modifier_chocolate_candy,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_chocolate_candy"}
|
|
)
|
|
____exports.modifier_chocolate_candy = modifier_chocolate_candy
|
|
____exports.modifier_caramel_candy = __TS__Class()
|
|
local modifier_caramel_candy = ____exports.modifier_caramel_candy
|
|
modifier_caramel_candy.name = "modifier_caramel_candy"
|
|
modifier_caramel_candy.____file_path = "scripts/vscripts/items/util_items/item_candys.lua"
|
|
__TS__ClassExtends(modifier_caramel_candy, BaseModifier)
|
|
function modifier_caramel_candy.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_caramel_candy.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_INCOMING_DAMAGE_PERCENTAGE, MODIFIER_EVENT_ON_TAKEDAMAGE}
|
|
end
|
|
function modifier_caramel_candy.prototype.GetModifierIncomingDamage_Percentage(self, event)
|
|
if RandomInt(0, 99) < 20 then
|
|
return 100
|
|
end
|
|
return 0
|
|
end
|
|
function modifier_caramel_candy.prototype.OnTakeDamage(self, event)
|
|
if event.unit ~= self:GetParent() then
|
|
return
|
|
end
|
|
if event.attacker == self:GetParent() then
|
|
return
|
|
end
|
|
if RandomInt(0, 99) < 20 then
|
|
ApplyDamage({
|
|
victim = event.attacker,
|
|
attacker = event.unit,
|
|
damage = self:GetParent():GetAverageTrueAttackDamage(event.attacker) + event.damage * 0.5,
|
|
damage_type = DAMAGE_TYPE_PHYSICAL
|
|
})
|
|
end
|
|
end
|
|
function modifier_caramel_candy.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_caramel_candy.prototype.GetTexture(self)
|
|
return "util_items/candy"
|
|
end
|
|
modifier_caramel_candy = __TS__Decorate(
|
|
modifier_caramel_candy,
|
|
modifier_caramel_candy,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_caramel_candy"}
|
|
)
|
|
____exports.modifier_caramel_candy = modifier_caramel_candy
|
|
____exports.modifier_mint_candy = __TS__Class()
|
|
local modifier_mint_candy = ____exports.modifier_mint_candy
|
|
modifier_mint_candy.name = "modifier_mint_candy"
|
|
modifier_mint_candy.____file_path = "scripts/vscripts/items/util_items/item_candys.lua"
|
|
__TS__ClassExtends(modifier_mint_candy, BaseModifier)
|
|
function modifier_mint_candy.prototype.____constructor(self, ...)
|
|
BaseModifier.prototype.____constructor(self, ...)
|
|
self.Lock = false
|
|
end
|
|
function modifier_mint_candy.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_mint_candy.prototype.OnCreated(self, params)
|
|
self:StartIntervalThink(0.1)
|
|
end
|
|
function modifier_mint_candy.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_mint_candy.prototype.OnIntervalThink(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
if RandomInt(1, 100) < 50 then
|
|
self:GetParent():AddNewModifier(
|
|
self:GetParent(),
|
|
self:GetAbility(),
|
|
"modifier_stunned",
|
|
{duration = 0.15}
|
|
)
|
|
end
|
|
end
|
|
function modifier_mint_candy.prototype.DeclareFunctions(self)
|
|
return {
|
|
MODIFIER_PROPERTY_MOVESPEED_BONUS_PERCENTAGE,
|
|
MODIFIER_PROPERTY_BONUS_DAY_VISION,
|
|
MODIFIER_PROPERTY_BONUS_NIGHT_VISION,
|
|
MODIFIER_PROPERTY_STATS_AGILITY_BONUS,
|
|
MODIFIER_PROPERTY_STATS_INTELLECT_BONUS,
|
|
MODIFIER_PROPERTY_STATS_STRENGTH_BONUS,
|
|
MODIFIER_PROPERTY_MIN_HEALTH
|
|
}
|
|
end
|
|
function modifier_mint_candy.prototype.GetModifierMinHealth(self)
|
|
return 1
|
|
end
|
|
function modifier_mint_candy.prototype.GetModifierMoveSpeedBonus_Percentage(self)
|
|
return -50
|
|
end
|
|
function modifier_mint_candy.prototype.GetBonusDayVision(self)
|
|
return -250
|
|
end
|
|
function modifier_mint_candy.prototype.GetBonusNightVision(self)
|
|
return -250
|
|
end
|
|
function modifier_mint_candy.prototype.GetModifierBonusStats_Agility(self)
|
|
if not IsServer() then
|
|
return 0
|
|
end
|
|
if self.Lock then
|
|
return 0
|
|
end
|
|
self.Lock = true
|
|
local bonus = self:GetParent():GetAgility()
|
|
local PctBonus = 0.5 * bonus
|
|
self.Lock = false
|
|
return -PctBonus
|
|
end
|
|
function modifier_mint_candy.prototype.GetModifierBonusStats_Intellect(self)
|
|
if not IsServer() then
|
|
return 0
|
|
end
|
|
if self.Lock then
|
|
return 0
|
|
end
|
|
self.Lock = true
|
|
local bonus = self:GetParent():GetIntellect(true)
|
|
local PctBonus = 0.5 * bonus
|
|
self.Lock = false
|
|
return -PctBonus
|
|
end
|
|
function modifier_mint_candy.prototype.GetModifierBonusStats_Strength(self)
|
|
if not IsServer() then
|
|
return 0
|
|
end
|
|
if self.Lock then
|
|
return 0
|
|
end
|
|
self.Lock = true
|
|
local bonus = self:GetParent():GetStrength()
|
|
local PctBonus = 0.5 * bonus
|
|
self.Lock = false
|
|
return -PctBonus
|
|
end
|
|
function modifier_mint_candy.prototype.GetTexture(self)
|
|
return "util_items/candy"
|
|
end
|
|
modifier_mint_candy = __TS__Decorate(
|
|
modifier_mint_candy,
|
|
modifier_mint_candy,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_mint_candy"}
|
|
)
|
|
____exports.modifier_mint_candy = modifier_mint_candy
|
|
____exports.modifier_magic_candy = __TS__Class()
|
|
local modifier_magic_candy = ____exports.modifier_magic_candy
|
|
modifier_magic_candy.name = "modifier_magic_candy"
|
|
modifier_magic_candy.____file_path = "scripts/vscripts/items/util_items/item_candys.lua"
|
|
__TS__ClassExtends(modifier_magic_candy, BaseModifier)
|
|
function modifier_magic_candy.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_magic_candy.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_magic_candy.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_SPELL_AMPLIFY_PERCENTAGE, MODIFIER_PROPERTY_COOLDOWN_PERCENTAGE, MODIFIER_PROPERTY_DAMAGEOUTGOING_PERCENTAGE}
|
|
end
|
|
function modifier_magic_candy.prototype.GetModifierSpellAmplify_Percentage(self)
|
|
return 15
|
|
end
|
|
function modifier_magic_candy.prototype.GetModifierCooldown_Percentage(self)
|
|
return 15
|
|
end
|
|
function modifier_magic_candy.prototype.GetModifierDamageOutgoing_Percentage(self)
|
|
return -15
|
|
end
|
|
function modifier_magic_candy.prototype.GetTexture(self)
|
|
return "util_items/candy"
|
|
end
|
|
modifier_magic_candy = __TS__Decorate(
|
|
modifier_magic_candy,
|
|
modifier_magic_candy,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_magic_candy"}
|
|
)
|
|
____exports.modifier_magic_candy = modifier_magic_candy
|
|
return ____exports
|