202 lines
7.6 KiB
Lua
202 lines
7.6 KiB
Lua
local ____lualib = require("lualib_bundle")
|
|
local __TS__Class = ____lualib.__TS__Class
|
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
|
|
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 BaseModifier = ____dota_ts_adapter.BaseModifier
|
|
local registerModifier = ____dota_ts_adapter.registerModifier
|
|
local ____dota_ts_adapter = require("lib.dota_ts_adapter")
|
|
local registerAbility = ____dota_ts_adapter.registerAbility
|
|
____exports.item_pizza = __TS__Class()
|
|
local item_pizza = ____exports.item_pizza
|
|
item_pizza.name = "item_pizza"
|
|
item_pizza.____file_path = "scripts/vscripts/items/util_items/item_pizza.lua"
|
|
__TS__ClassExtends(item_pizza, BaseItem)
|
|
function item_pizza.prototype.CastFilterResultTarget(self, target)
|
|
if IsServer() then
|
|
if self:GetCurrentCharges() < self:GetInitialCharges() then
|
|
return UF_FAIL_CUSTOM
|
|
end
|
|
return UF_SUCCESS
|
|
end
|
|
return UF_SUCCESS
|
|
end
|
|
function item_pizza.prototype.GetCustomCastErrorTarget(self, target)
|
|
if IsServer() then
|
|
if self:GetCurrentCharges() < self:GetInitialCharges() then
|
|
return "#dota_hud_error_havent_charges"
|
|
end
|
|
end
|
|
return ""
|
|
end
|
|
function item_pizza.prototype.OnSpellStart(self)
|
|
local target = self:GetCursorTarget()
|
|
local item = self
|
|
local castedOnGurd = (target and target:GetName()) == "npc_quest_giver_friend"
|
|
if target and target:IsRealHero() and target:GetName() ~= "npc_quest_giver_friend" then
|
|
local modifier = target:AddNewModifier(
|
|
self:GetCaster(),
|
|
self,
|
|
modifier_general_hunger.name,
|
|
{}
|
|
)
|
|
local modifier_pizza = target:AddNewModifier(
|
|
self:GetCaster(),
|
|
self,
|
|
____exports.modifier_item_pizza.name,
|
|
{}
|
|
)
|
|
if not ____exports.item_pizza.wasGivenToGurd then
|
|
Timers:CreateTimer(
|
|
50,
|
|
function()
|
|
EmitGlobalSound("Hero_Bloodseeker.Thirst.Cast")
|
|
local soundCount = 0
|
|
local maxRepeats = 20
|
|
local repeatSound
|
|
repeatSound = function()
|
|
if soundCount < maxRepeats then
|
|
EmitGlobalSound("Hero_Pudge.Dismember")
|
|
soundCount = soundCount + 1
|
|
Timers:CreateTimer(0.5, repeatSound)
|
|
end
|
|
end
|
|
repeatSound(nil)
|
|
local questGiver = Entities:FindByName(nil, "npc_quest_giver_friend")
|
|
local questGiverVictim1 = Entities:FindByName(nil, "npc_quest_giver_maiden")
|
|
local questGiverVictim2 = Entities:FindByName(nil, "npc_quest_giver_lina")
|
|
if not questGiver then
|
|
return
|
|
end
|
|
__TS__ArrayForEach(
|
|
FindUnitsInRadius(
|
|
2,
|
|
questGiver:GetAbsOrigin(),
|
|
nil,
|
|
2000,
|
|
1,
|
|
1,
|
|
8192,
|
|
1,
|
|
false
|
|
),
|
|
function(____, unit)
|
|
unit:ForceKill(false)
|
|
end
|
|
)
|
|
UTIL_Remove(questGiver)
|
|
UTIL_Remove(questGiverVictim1)
|
|
UTIL_Remove(questGiverVictim2)
|
|
end
|
|
)
|
|
end
|
|
if modifier_pizza then
|
|
modifier_pizza:SetStackCount(modifier_pizza:GetStackCount() + self:GetSpecialValueFor("stack_count"))
|
|
end
|
|
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
|
|
else
|
|
if castedOnGurd then
|
|
____exports.item_pizza.wasGivenToGurd = true
|
|
end
|
|
local heroes = HeroList:GetAllHeroes()
|
|
GameRules:SendCustomMessage("#friend_quest_pizza_prep_message_complete_2", 0, 0)
|
|
for ____, hero in ipairs(heroes) do
|
|
if hero:IsRealHero() and hero:GetName() ~= "npc_quest_giver_friend" then
|
|
local modifier = hero:AddNewModifier(
|
|
self:GetCaster(),
|
|
self,
|
|
modifier_general_hunger.name,
|
|
{}
|
|
)
|
|
local modifier_pizza = hero:AddNewModifier(
|
|
self:GetCaster(),
|
|
self,
|
|
____exports.modifier_item_pizza.name,
|
|
{}
|
|
)
|
|
if modifier_pizza then
|
|
modifier_pizza:SetStackCount(modifier_pizza:GetStackCount() + self:GetSpecialValueFor("stack_count"))
|
|
end
|
|
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
|
|
end
|
|
end
|
|
end
|
|
UTIL_Remove(item)
|
|
end
|
|
end
|
|
item_pizza.wasGivenToGurd = false
|
|
item_pizza = __TS__Decorate(
|
|
item_pizza,
|
|
item_pizza,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "item_pizza"}
|
|
)
|
|
____exports.item_pizza = item_pizza
|
|
____exports.modifier_item_pizza = __TS__Class()
|
|
local modifier_item_pizza = ____exports.modifier_item_pizza
|
|
modifier_item_pizza.name = "modifier_item_pizza"
|
|
modifier_item_pizza.____file_path = "scripts/vscripts/items/util_items/item_pizza.lua"
|
|
__TS__ClassExtends(modifier_item_pizza, BaseModifier)
|
|
function modifier_item_pizza.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_item_pizza.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_item_pizza.prototype.IsDebuff(self)
|
|
return false
|
|
end
|
|
function modifier_item_pizza.prototype.RemoveOnDeath(self)
|
|
return false
|
|
end
|
|
function modifier_item_pizza.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_STATS_AGILITY_BONUS, MODIFIER_PROPERTY_STATS_INTELLECT_BONUS, MODIFIER_PROPERTY_STATS_STRENGTH_BONUS}
|
|
end
|
|
function modifier_item_pizza.prototype.GetModifierBonusStats_Agility(self)
|
|
return self:GetStackCount()
|
|
end
|
|
function modifier_item_pizza.prototype.GetModifierBonusStats_Intellect(self)
|
|
return self:GetStackCount()
|
|
end
|
|
function modifier_item_pizza.prototype.GetModifierBonusStats_Strength(self)
|
|
return self:GetStackCount()
|
|
end
|
|
function modifier_item_pizza.prototype.GetTexture(self)
|
|
return "../items/utils/pizza"
|
|
end
|
|
modifier_item_pizza = __TS__Decorate(
|
|
modifier_item_pizza,
|
|
modifier_item_pizza,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_item_pizza"}
|
|
)
|
|
____exports.modifier_item_pizza = modifier_item_pizza
|
|
return ____exports
|