Files
2026-05-29 15:11:31 +07:00

212 lines
7.5 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 ____dota_ts_adapter = require("lib.dota_ts_adapter")
local BaseItem = ____dota_ts_adapter.BaseItem
local BaseModifier = ____dota_ts_adapter.BaseModifier
local registerAbility = ____dota_ts_adapter.registerAbility
local registerModifier = ____dota_ts_adapter.registerModifier
local ____kunkka_shovel_anchor_markers = require("quests.kunkka_shovel_anchor_markers")
local handleShovelDigAt = ____kunkka_shovel_anchor_markers.handleShovelDigAt
local isNearUndugShovelPoint = ____kunkka_shovel_anchor_markers.isNearUndugShovelPoint
local SHOVEL_DIG_RADIUS = ____kunkka_shovel_anchor_markers.SHOVEL_DIG_RADIUS
local ____QuestSystem = require("quests.QuestSystem")
local QuestSystem = ____QuestSystem.QuestSystem
local SHOVEL_DIG_PARTICLE = "particles/econ/events/ti9/shovel_dig.vpcf"
local SHOVEL_REVEAL_PARTICLE = "particles/econ/events/ti9/shovel_revealed_baby_roshan.vpcf"
local KUNKA_FIND_ANCHOR_QUEST_ID = "kunkka_quest_find_anchor"
____exports.item_shovel = __TS__Class()
local item_shovel = ____exports.item_shovel
item_shovel.name = "item_shovel"
item_shovel.____file_path = "scripts/vscripts/items/quest_items/item_shovel.lua"
__TS__ClassExtends(item_shovel, BaseItem)
function item_shovel.prototype.Precache(self, context)
PrecacheResource("particle", SHOVEL_DIG_PARTICLE, context)
PrecacheResource("particle", SHOVEL_REVEAL_PARTICLE, context)
PrecacheResource("soundfile", "soundevents/game_sounds_items.vsndevts", context)
end
function item_shovel.prototype.GetIntrinsicModifierName(self)
return ____exports.modifier_shovel_effect.name
end
function item_shovel.prototype.isOnShovelPoint(self, caster)
return isNearUndugShovelPoint(
nil,
caster:GetAbsOrigin(),
SHOVEL_DIG_RADIUS
)
end
function item_shovel.prototype.getMaxDigs(self)
return math.max(
1,
self:GetSpecialValueFor("max_digs")
)
end
function item_shovel.prototype.getDigCharges(self)
return self:GetCurrentCharges()
end
function item_shovel.prototype.CastFilterResult(self)
if not IsServer() then
return UF_SUCCESS
end
local caster = self:GetCaster()
if not caster or caster:IsNull() or not self:isOnShovelPoint(caster) then
return UF_FAIL_CUSTOM
end
if self:getDigCharges() >= self:getMaxDigs() then
return UF_FAIL_CUSTOM
end
return UF_SUCCESS
end
function item_shovel.prototype.GetCustomCastError(self)
if IsServer() and self:getDigCharges() >= self:getMaxDigs() then
return "#dota_hud_error_shovel_broken"
end
return "#dota_hud_error_shovel_not_on_cross"
end
function item_shovel.prototype.OnSpellStart(self)
if not IsServer() then
return
end
local caster = self:GetCaster()
if not caster or caster:IsNull() then
return
end
EmitSoundOn("DOTA_Item.MaskOfMadness.Activate", caster)
self.digParticle = ParticleManager:CreateParticle(SHOVEL_DIG_PARTICLE, PATTACH_ABSORIGIN, caster)
ParticleManager:SetParticleControl(
self.digParticle,
0,
caster:GetAbsOrigin()
)
end
function item_shovel.prototype.OnChannelFinish(self, interrupted)
if not IsServer() then
return
end
local caster = self:GetCaster()
if not caster or caster:IsNull() then
return
end
if self.digParticle ~= nil then
ParticleManager:DestroyParticle(self.digParticle, false)
ParticleManager:ReleaseParticleIndex(self.digParticle)
self.digParticle = nil
end
StopSoundOn("DOTA_Item.MaskOfMadness.Activate", caster)
if interrupted then
return
end
if not self:isOnShovelPoint(caster) then
return
end
local digOrigin = caster:GetAbsOrigin()
local digMarker = handleShovelDigAt(nil, digOrigin, SHOVEL_DIG_RADIUS)
if not digMarker.removed then
return
end
local revealFx = ParticleManager:CreateParticle(SHOVEL_REVEAL_PARTICLE, PATTACH_ABSORIGIN, caster)
ParticleManager:SetParticleControl(revealFx, 0, digOrigin)
ParticleManager:ReleaseParticleIndex(revealFx)
if digMarker.grantsShamefulPipe then
self:grantShamefulPipe(caster)
end
local goldMin = self:GetSpecialValueFor("gold_min")
local goldMax = self:GetSpecialValueFor("gold_max")
local gold = RandomInt(
math.max(0, goldMin),
math.max(goldMin, goldMax)
)
local playerId = caster:GetPlayerOwnerID()
if PlayerResource:IsValidPlayerID(playerId) and gold > 0 then
PlayerResource:ModifyGold(playerId, gold, true, DOTA_ModifyGold_Unspecified)
local player = PlayerResource:GetPlayer(playerId)
if player then
EmitSoundOnClient("General.Coins", player)
SendOverheadEventMessage(
player,
OVERHEAD_ALERT_GOLD,
caster,
gold,
nil
)
end
end
self:tryCompleteKunkkaFindAnchorQuest(caster)
self:consumeDigCharge()
end
function item_shovel.prototype.consumeDigCharge(self)
local item = self
if not item or item:IsNull() then
return
end
local maxDigs = self:getMaxDigs()
local nextCharges = item:GetCurrentCharges() + 1
if nextCharges >= maxDigs then
UTIL_Remove(item)
return
end
item:SetCurrentCharges(nextCharges)
end
function item_shovel.prototype.grantShamefulPipe(self, hero)
if hero:FindItemInInventory("item_shameful_pipe") then
return
end
local item = hero:AddItemByName("item_shameful_pipe")
if item and not item:IsNull() then
EmitSoundOn("Item.PickUpGemShop", hero)
end
end
function item_shovel.prototype.tryCompleteKunkkaFindAnchorQuest(self, _caster)
QuestSystem:getInstance():setQuestProgress(KUNKA_FIND_ANCHOR_QUEST_ID, "find_anchor", 1)
end
item_shovel = __TS__Decorate(
item_shovel,
item_shovel,
{registerAbility(nil)},
{kind = "class", name = "item_shovel"}
)
____exports.item_shovel = item_shovel
____exports.modifier_shovel_effect = __TS__Class()
local modifier_shovel_effect = ____exports.modifier_shovel_effect
modifier_shovel_effect.name = "modifier_shovel_effect"
modifier_shovel_effect.____file_path = "scripts/vscripts/items/quest_items/item_shovel.lua"
__TS__ClassExtends(modifier_shovel_effect, BaseModifier)
function modifier_shovel_effect.prototype.____constructor(self, ...)
BaseModifier.prototype.____constructor(self, ...)
self.bonusHealth = 0
end
function modifier_shovel_effect.prototype.IsHidden(self)
return true
end
function modifier_shovel_effect.prototype.IsPurgable(self)
return false
end
function modifier_shovel_effect.prototype.RemoveOnDeath(self)
return false
end
function modifier_shovel_effect.prototype.GetAttributes(self)
return MODIFIER_ATTRIBUTE_MULTIPLE
end
function modifier_shovel_effect.prototype.OnCreated(self)
local ability = self:GetAbility()
if ability and not ability:IsNull() then
self.bonusHealth = ability:GetSpecialValueFor("bonus_health")
end
end
function modifier_shovel_effect.prototype.DeclareFunctions(self)
return {MODIFIER_PROPERTY_HEALTH_BONUS}
end
function modifier_shovel_effect.prototype.GetModifierHealthBonus(self)
return self.bonusHealth
end
modifier_shovel_effect = __TS__Decorate(
modifier_shovel_effect,
modifier_shovel_effect,
{registerModifier(nil)},
{kind = "class", name = "modifier_shovel_effect"}
)
____exports.modifier_shovel_effect = modifier_shovel_effect
return ____exports