print( "Dota PvP game mode loaded." )
if DotaPvP == nil then
DotaPvP = class({})
end
-- ACTIVATE
function Activate()
GameRules.DotaPvP = DotaPvP()
GameRules.DotaPvP:InitGameMode()
end
-- INIT
function DotaPvP:InitGameMode()
local GameMode = GameRules:GetGameModeEntity()
-- Enable the standard Dota PvP game rules
GameRules:GetGameModeEntity():SetTowerBackdoorProtectionEnabled( true )
-- Register Think
GameMode:SetContextThink( "DotaPvP:GameThink", function() return self:GameThink() end, 0.25 )
-- Register Game Events
GameRules:SetGoldPerTick(5)
--listeners
ListenToGameEvent('dota_player_used_ability', Dynamic_Wrap(DotaPvP, 'AbilityUsed'), self)
end
--------------------------------------------------------------------------------
function DotaPvP:GameThink()
return 0.25
end
function DotaPvP:AbilityUsed()
print('[DotaPvP] AbilityUsed')
-- Цикл от 0 до системной константы DOTA_MAX_TEAM_PLAYERS
for nPlayerID = 0, DOTA_MAX_TEAM_PLAYERS-1 do
if PlayerResource:HasSelectedHero( nPlayerID ) then
local hero = PlayerResource:GetSelectedHeroEntity( nPlayerID )
local maxHp = hero:GetMaxHealth()
hero:SetMaxHealth( maxHp + 500 )
hero:SetHealth( maxHp + 500 )
PlayerResource:ModifyGold(nPlayerID, 500, false, 1)
end
end
end