132 lines
4.2 KiB
Lua
132 lines
4.2 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 registerAbility = ____dota_ts_adapter.registerAbility
|
|
local BaseModifier = ____dota_ts_adapter.BaseModifier
|
|
local registerModifier = ____dota_ts_adapter.registerModifier
|
|
local ____QuestSystem = require("quests.QuestSystem")
|
|
local QuestSystem = ____QuestSystem.QuestSystem
|
|
____exports.item_pet = __TS__Class()
|
|
local item_pet = ____exports.item_pet
|
|
item_pet.name = "item_pet"
|
|
item_pet.____file_path = "scripts/vscripts/items/quest_items/item_pet.lua"
|
|
__TS__ClassExtends(item_pet, BaseItem)
|
|
function item_pet.prototype.GetAOERadius(self)
|
|
return 450
|
|
end
|
|
function item_pet.prototype.OnAbilityPhaseStart(self)
|
|
self:GetCaster():StartGestureWithPlaybackRate(ACT_DOTA_ATTACK, 1)
|
|
return true
|
|
end
|
|
function item_pet.prototype.OnAbilityPhaseInterrupted(self)
|
|
self:GetCaster():FadeGesture(ACT_DOTA_ATTACK)
|
|
end
|
|
function item_pet.prototype.OnSpellStart(self)
|
|
local target = self:GetCursorTarget()
|
|
if not target then
|
|
return
|
|
end
|
|
if target:IsInstance(CDOTA_MapTree) then
|
|
target:CutDown(self:GetCaster():GetTeamNumber())
|
|
local unit = CreateUnitByName(
|
|
"npc_squirrel_event",
|
|
target:GetCenter(),
|
|
true,
|
|
self:GetCaster(),
|
|
self:GetCaster(),
|
|
DOTA_TEAM_GOODGUYS
|
|
)
|
|
unit:SetControllableByPlayer(
|
|
self:GetCaster():GetPlayerID(),
|
|
true
|
|
)
|
|
unit:SetOwner(self:GetCaster())
|
|
self:RemoveSelf()
|
|
else
|
|
local unitName = target:GetUnitName()
|
|
if unitName == "npc_pig" then
|
|
target:Kill(
|
|
self,
|
|
self:GetCaster()
|
|
)
|
|
local unit = CreateUnitByName(
|
|
"npc_pig_event",
|
|
target:GetCenter(),
|
|
true,
|
|
nil,
|
|
nil,
|
|
DOTA_TEAM_GOODGUYS
|
|
)
|
|
unit:SetControllableByPlayer(
|
|
self:GetCaster():GetPlayerID(),
|
|
true
|
|
)
|
|
unit:SetOwner(self:GetCaster())
|
|
self:RemoveSelf()
|
|
elseif unitName == "npc_wolf" then
|
|
target:Kill(
|
|
self,
|
|
self:GetCaster()
|
|
)
|
|
local unit = CreateUnitByName(
|
|
"npc_wolf_event",
|
|
target:GetCenter(),
|
|
true,
|
|
nil,
|
|
nil,
|
|
DOTA_TEAM_GOODGUYS
|
|
)
|
|
unit:SetControllableByPlayer(
|
|
self:GetCaster():GetPlayerID(),
|
|
true
|
|
)
|
|
unit:SetOwner(self:GetCaster())
|
|
self:RemoveSelf()
|
|
else
|
|
local questSystem = QuestSystem:getInstance()
|
|
questSystem:failQuest("denny_quest_find_pet")
|
|
GameRules:SendCustomMessage("Бля, у вас не получилось приручить питомца(((", 0, 0)
|
|
self:RemoveSelf()
|
|
end
|
|
end
|
|
target:AddNewModifier(
|
|
self:GetCaster(),
|
|
self,
|
|
"modifier_item_pet",
|
|
{}
|
|
)
|
|
end
|
|
item_pet = __TS__Decorate(
|
|
item_pet,
|
|
item_pet,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "item_pet"}
|
|
)
|
|
____exports.item_pet = item_pet
|
|
____exports.modifier_item_pet = __TS__Class()
|
|
local modifier_item_pet = ____exports.modifier_item_pet
|
|
modifier_item_pet.name = "modifier_item_pet"
|
|
modifier_item_pet.____file_path = "scripts/vscripts/items/quest_items/item_pet.lua"
|
|
__TS__ClassExtends(modifier_item_pet, BaseModifier)
|
|
function modifier_item_pet.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_item_pet.prototype.RemoveOnDeath(self)
|
|
return false
|
|
end
|
|
function modifier_item_pet.prototype.CheckState(self)
|
|
return {[MODIFIER_STATE_INVULNERABLE] = true, [MODIFIER_STATE_NO_UNIT_COLLISION] = true}
|
|
end
|
|
modifier_item_pet = __TS__Decorate(
|
|
modifier_item_pet,
|
|
modifier_item_pet,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_item_pet"}
|
|
)
|
|
____exports.modifier_item_pet = modifier_item_pet
|
|
return ____exports
|