- Joined
- Jul 19, 2007
- Messages
- 822
I imported an ability from a Dota Spellpack that was named "Dispersion" and it damages all enemy units around the hero with the Dispersion ability when it takes damage but the problem is that it also seems to damage buildings... I only want it to damage organic units...
JASS:
//TESH.scrollpos=21
//TESH.alwaysfold=0
scope Dispersion initializer Init
globals
private constant integer AbilId = 'A0KK'
private boolexpr B
private real R
private unit U
endglobals
private function Filt takes nothing returns boolean
local unit targ = GetFilterUnit()
if IsUnitVisible(targ,GetOwningPlayer(GetTriggerUnit())) and IsUnitEnemy(targ,GetOwningPlayer(GetTriggerUnit())) and GetWidgetLife(targ)>.405 then
if DBU(U,targ)<=300. then
call UnitDamageTargetEx(GetTriggerUnit(), targ,R, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_SPELL, false)
else
call UnitDamageTargetEx(GetTriggerUnit(), targ,R*(1-DBU(U,targ)/1000.), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_SPELL, false)
endif
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayDamage.mdl",targ,"chest"))
endif
set targ = null
return false
endfunction
private function Effects takes nothing returns boolean
local unit u=GetTriggerUnit()
local real r=GetEventDamage()
local group g
if r>.1 and r<3000. then
set g=NewGroup()
set R=r*(0.04*GetUnitAbilityLevel(u,AbilId)+.06)
//call Echo(R2S(GetEventDamage())+" : "+R2S(R))
call ShieldUnit(u,R,r)
//call SetWidgetLife(u,GetWidgetLife(u)+R)
set U = u
call GroupEnumUnitsInRange(g,GetUnitX(u),GetUnitY(u),1000.,B)
call ReleaseGroup(g)
endif
set u = null
return false
endfunction
private function Actions takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterUnitEvent(t,GetTriggerUnit(),EVENT_UNIT_DAMAGED)
call TriggerAddCondition(t,Condition(function Effects))
endfunction
private function Conds takes nothing returns boolean
if GetOwningPlayer(GetTriggerUnit())!=Player(15) and GetLearnedSkill()==AbilId and GetUnitAbilityLevel(GetTriggerUnit(),AbilId)==1 and not IsUnitIllusion(GetTriggerUnit()) then
call Actions()
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(t,Condition(function Conds))
set B = Condition(function Filt)
endfunction
endscope