Вобщем у меня задача апнуть способность (скрытую) она есть у героя но не отображается в списке. Я пытаюсь её апнуть скриптом, но пока безуспешно, и подобная темка на форуме не помогла.
ВОТ мой addon_game_mode.lua и что то я намудрил...
ВОТ мой addon_game_mode.lua и что то я намудрил...
Код:
if main == nil then
_G.main = class({})
end
require('stat_GameMode')
function Precache( context )
PrecacheResource( "texture", "resource/flash3/images/items/longrange_rifle", context )
end
function Activate()
main:InitGameMode()
end
function main:InitGameMode()
GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_GOODGUYS, 3 )
GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_BADGUYS, 3 )
ListenToGameEvent("dota_player_killed", Dynamic_Wrap(main, "OnHeroKilled"), self)
ListenToGameEvent('npc_spawned', Dynamic_Wrap(main, 'OnNPCSpawned'), self )
end
function main:OnHeroKilled(data)
local CountPlayers = PlayerResource:GetPlayerCountForTeam(DOTA_TEAM_GOODGUYS) + PlayerResource:GetPlayerCountForTeam(DOTA_TEAM_BADGUYS)
if (PlayerResource:GetTeamKills(DOTA_TEAM_BADGUYS) + 1 ) > (10 * CountPlayers) then
GameRules:SetGameWinner(DOTA_TEAM_BADGUYS)
elseif (PlayerResource:GetTeamKills(DOTA_TEAM_GOODGUYS) +1) > (10 * CountPlayers) then
GameRules:SetGameWinner(DOTA_TEAM_GOODGUYS)
end
function main:OnNPCSpawned(keys)
print(" NPC Spawned")
DeepPrintTable(keys)
local npc = EntIndexToHScript(keys.entindex)
if npc:IsRealHero() and npc.bFirstSpawned == nil then
npc.bFirstSpawned = true
main:OnHeroInGame(npc)
npc:AddAbility("dota_ability_xp_granter"):SetLevel(1)
end
end
function main:OnHeroInGame(hero)
local ability_count = GetAbilityCount()
for i = 0, ability_count do
local ability = hero:GetAbilityByIndex(i)
if ability then
ability:SetLevel(1)
end
end
end
end
Последнее редактирование модератором: