- Joined
- Jul 19, 2007
- Messages
- 824
So once again I have imported a spell into my map from a Dota Spellpack and this time I imported the "Paralyzing Cask" spell and it seems to be working like it should but the problem is that it even seems to bounce into buildings and wards for some reason. How can I make so it only bounces to organic units?
JASS:
//TESH.scrollpos=33
//TESH.alwaysfold=0
scope ParalyzingCask initializer Init
globals
private constant integer AbilId = 'A0IO'
private constant integer DumAbilId = 'A0IN'
private integer I
endglobals
private struct data
unit u
player p
unit targ
integer lvl
integer count = 1
timer t
method onDestroy takes nothing returns nothing
call ReleaseTimer(.t)
endmethod
endstruct
private function Cast takes unit cast,unit oldtarg,unit newtarg,integer lvl returns real
local unit dum=CreateUnit(GetOwningPlayer(cast),CasterId,GetUnitX(oldtarg),GetUnitY(oldtarg),0.)
call UnitAddAbility(dum,DumAbilId)
call IssueTargetOrder(dum,"thunderbolt",newtarg)
call UnitApplyTimedLife(dum,'BTLF',1.)
set dum = null
return DBU(oldtarg,newtarg)/500.
endfunction
private function Filt takes nothing returns boolean
local data d = I
if GetFilterUnit()!=d.targ and IsUnitVisible(GetFilterUnit(),d.p) and IsUnitEnemy(GetFilterUnit(),d.p) and GetWidgetLife(GetFilterUnit())>.405 then
return true
endif
return false
endfunction
private function GetTarget takes unit cast, unit targ, data d returns unit
local group g=NewGroup()
set I=d
call GroupEnumUnitsInRange(g,GetUnitX(targ),GetUnitY(targ),575.,Condition(function Filt))
set targ=GroupPickRandomUnit(g)
call ReleaseGroup(g)
return targ
endfunction
private function Check takes nothing returns nothing
local data d = GetTimerData(GetExpiredTimer())
local unit old
set d.count = d.count + 1
if IsUnitType(d.targ,UNIT_TYPE_HERO)==false then
call UnitDamageTargetEx(d.u, d.targ, 50.+(25.*d.lvl), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_SPELL, false)
else
call UnitDamageTargetEx(d.u, d.targ, 50., ATTACK_TYPE_NORMAL, DAMAGE_TYPE_SPELL, false)
endif
if d.count<=d.lvl*2 then
set old = d.targ
set d.targ=GetTarget(d.u,d.targ,d)
if d.targ!=null then
call TimerStart(d.t,Cast(d.u,old,d.targ,d.lvl),false,function Check)
else
call d.destroy()
endif
set old = null
else
call d.destroy()
endif
endfunction
private function Actions takes nothing returns nothing
local data d = data.create()
set d.u=GetTriggerUnit()
set d.p = GetOwningPlayer(d.u)
set d.targ=GetSpellTargetUnit()
set d.lvl=GetUnitAbilityLevel(d.u,AbilId)
set d.t = NewTimer()
call SetTimerData(d.t,d)
call TimerStart(d.t,Cast(d.u,d.u,d.targ,d.lvl),false,function Check)
endfunction
private function Conds takes nothing returns boolean
if GetSpellAbilityId()==AbilId then
call Actions()
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function Conds))
call PreloadAbil(DumAbilId)
endfunction
endscope