56 lines
1.8 KiB
Lua
56 lines
1.8 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
|
|
____exports.item_bag_of_gold = __TS__Class()
|
|
local item_bag_of_gold = ____exports.item_bag_of_gold
|
|
item_bag_of_gold.name = "item_bag_of_gold"
|
|
item_bag_of_gold.____file_path = "scripts/vscripts/items/default_items/item_bag_of_gold.lua"
|
|
__TS__ClassExtends(item_bag_of_gold, BaseItem)
|
|
function item_bag_of_gold.prototype.____constructor(self, ...)
|
|
BaseItem.prototype.____constructor(self, ...)
|
|
self.GOLD_AMOUNT = RandomInt(10, 50)
|
|
end
|
|
function item_bag_of_gold.prototype.OnSpellStart(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local caster = self:GetCaster()
|
|
if not caster then
|
|
return
|
|
end
|
|
local playerID = caster:GetPlayerOwnerID()
|
|
if not PlayerResource:IsValidPlayerID(playerID) then
|
|
return
|
|
end
|
|
PlayerResource:ModifyGold(playerID, self.GOLD_AMOUNT, true, DOTA_ModifyGold_SharedGold)
|
|
EmitSoundOnClient(
|
|
"General.Coins",
|
|
PlayerResource:GetPlayer(playerID)
|
|
)
|
|
SendOverheadEventMessage(
|
|
PlayerResource:GetPlayer(playerID),
|
|
OVERHEAD_ALERT_GOLD,
|
|
caster,
|
|
self.GOLD_AMOUNT,
|
|
nil
|
|
)
|
|
local container = self:GetContainer()
|
|
if container then
|
|
container:RemoveSelf()
|
|
end
|
|
self:RemoveSelf()
|
|
end
|
|
item_bag_of_gold = __TS__Decorate(
|
|
item_bag_of_gold,
|
|
item_bag_of_gold,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "item_bag_of_gold"}
|
|
)
|
|
____exports.item_bag_of_gold = item_bag_of_gold
|
|
return ____exports
|