OnHealReceived отлов хиллера

Можно ли через OnHealReceived отловить хиллера?
Код:
strange_fate_predict = class({})
LinkLuaModifier( "modifier_strange_fate_predict", "strange_fate_predict.lua",LUA_MODIFIER_MOTION_NONE )

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function strange_fate_predict:GetCastRange( vLocation, hTarget )
  if self:GetCaster():HasScepter() then
    return 2000
  end

  return self.BaseClass.GetCastRange( self, vLocation, hTarget )
end
function strange_fate_predict:GetCooldown( nLevel )
  if self:GetCaster():HasScepter() then
    return 25
  end

  return self.BaseClass.GetCooldown( self, nLevel )
end


--------------------------------------------------------------------------------

function strange_fate_predict:OnSpellStart()
  local hTarget = self:GetCursorTarget()
  if hTarget ~= nil then
    local duration = self:GetSpecialValueFor( "duration" )
    hTarget:AddNewModifier( self:GetCaster(), self, "modifier_strange_fate_predict", { duration = duration } )
    EmitSoundOn( "Hero_Oracle.FalsePromise.Cast", hTarget )

    local nFXIndex = ParticleManager:CreateParticle( "particles/units/heroes/hero_lina/lina_spell_laguna_blade.vpcf", PATTACH_CUSTOMORIGIN, nil );
    ParticleManager:SetParticleControlEnt( nFXIndex, 0, self:GetCaster(), PATTACH_POINT_FOLLOW, "attach_attack1", self:GetCaster():GetOrigin() + Vector( 0, 0, 96 ), true );
    ParticleManager:SetParticleControlEnt( nFXIndex, 1, hTarget, PATTACH_POINT_FOLLOW, "attach_hitloc", hTarget:GetOrigin(), true );
    ParticleManager:ReleaseParticleIndex( nFXIndex );

    EmitSoundOn( "Hero_Oracle.FalsePromise.Cast", self:GetCaster() )
    self:SetActivated(false)
  end
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
modifier_strange_fate_predict = class({})

function modifier_strange_fate_predict:DeclareFunctions()
  return { MODIFIER_EVENT_ON_HEAL_RECEIVED, MODIFIER_EVENT_ON_MANA_GAINED, MODIFIER_EVENT_ON_SPENT_MANA, MODIFIER_EVENT_ON_TAKEDAMAGE}
end
function modifier_strange_fate_predict:OnCreated( event )
  local ability = self:GetAbility()
  local unit = self:GetParent()
  self.heal = 0
  self.mana_loss = 0
  self.mana_gain = 0
  self.tick_interval = 0.1
  if IsServer() then
    self.health = unit:GetHealth()
    self.mana = unit:GetMana()
    EmitSoundOn( "Hero_Oracle.FalsePromise.Target", unit )
    for i=0, 15 do
      if unit:GetAbilityByIndex(i) ~= nil then
        self.cd = unit:GetAbilityByIndex(i):GetCooldownTimeRemaining()
      end
    end
  end
  self:StartIntervalThink(self.tick_interval)
end

function modifier_strange_fate_predict:OnIntervalThink()
  if IsServer() then
    local unit = self:GetParent()
    for i=0, 15 do
      if unit:GetAbilityByIndex(i) ~= nil then
        local cooldown = unit:GetAbilityByIndex(i):GetCooldownTimeRemaining() + 0.1
        if cooldown >= 0.2 then
          unit:GetAbilityByIndex(i):EndCooldown()
          unit:GetAbilityByIndex(i):StartCooldown(cooldown)
        end
      end
    end
  end
end

function modifier_strange_fate_predict:OnHealReceived( event )
  if IsServer() then
    local unit = self:GetParent()
    self.heal = self.heal + event.gain
    unit:SetHealth(self.health)
  end
end
function modifier_strange_fate_predict:OnSpentMana( event )
  if IsServer() then
    local unit = self:GetParent()
    self.mana_loss = self.mana_loss + event.cost
    unit:SetMana(self.mana)
  end
end
function modifier_strange_fate_predict:OnManaGained( event )
  if IsServer() then
    local unit = self:GetParent()
    self.mana_gain = self.mana_gain + event.gain
    unit:SetMana(self.mana)
  end
end
function modifier_strange_fate_predict:OnDestroy()
  if IsServer() then
    local unit = self:GetParent()
    unit:GiveMana(self.mana_gain)
    unit:SpendMana(self.mana_loss, self:GetAbility())
    self.heal = self.heal/15
    unit:Heal(self.heal, unit)
    ParticleManager:CreateParticle("particles/units/heroes/hero_oracle/oracle_false_promise_dmg.vpcf", PATTACH_POINT_FOLLOW, unit)
    EmitSoundOn( "Hero_Oracle.FalsePromise.FP", unit )
    EmitSoundOn( "Hero_Oracle.FalsePromise.Damaged", unit )
    GameRules.lotus[1][unit:GetPlayerOwnerID() + 1] = 0
    self.heal = nil
    self.mana_loss = nil
    self.mana_gain = nil
    self:GetAbility():SetActivated(true)
  end
end

function modifier_strange_fate_predict:GetStatusEffectName()
  return "particles/status_fx/status_effect_ancestral_spirit.vpcf"
end
function modifier_strange_fate_predict:GetEffectName()
  return "particles/strange_fate_edict.vpcf"
end
function modifier_strange_fate_predict:GetEffectAttachType()
  return PATTACH_POINT_FOLLOW
end

function modifier_strange_fate_predict:IsHidden()
  return false
end

function modifier_strange_fate_predict:GetAttributes()
  return MODIFIER_ATTRIBUTE_PERMANENT
end

OnHealReceived передает kv ТОЛЬКО через луа, чекай и принтуй, вроде можно
 
Последнее редактирование модератором:
Реклама: