CODE JASS
scope ScatterShot
globals
private integer abil_id = 'Shot' // ScatterShot ability rawcode
private integer dum_id = 'ehBN' // ScatterShot unit rawcode
private integer dum2_id = 'eXXZ' // ScatterShot (Effect) unit rawcode
endglobals
private function GetShots takes integer lvl returns integer
return 1+3*lvl // Number of shots/lvl
endfunction
private function Distance takes nothing returns real
return GetRandomReal(0.,360.) // Min to max distance for area
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId()==abil_id
endfunction
private function Actions takes nothing returns nothing
local location l = GetSpellTargetLoc()
local real xl = GetLocationX(l)
local real yl = GetLocationY(l)
local real dist
local real ang
local location m
local unit u = GetTriggerUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local integer i = GetShots(GetUnitAbilityLevel(u,abil_id))
local player p = GetOwningPlayer(u)
local unit dum
loop
exitwhen i<=0
set dum = CreateUnit(p,dum_id,x,y,0.)
set dist = Distance()
set ang = GetRandomReal(0.,360.)*bj_DEGTORAD
set m = Location(xl+dist*Cos(ang),yl+dist*Sin(ang))
call IssuePointOrderLoc(dum,"attackground",m)
call UnitApplyTimedLife(dum,'BTLF',.5)
call RemoveLocation(m)
set i = i-1
endloop
set dum = CreateUnit(p,dum2_id,GetUnitX(u),GetUnitY(u),0.)
call SetUnitTimeScale(dum,1.75)
call PolledWait2(.9)
call RemoveUnit(dum)
call RemoveLocation(l)
set l = null
set dum = null
endfunction
//===========================================================================
public function InitTrig takes nothing returns nothing
local trigger trig = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction( trig, function Actions )
call TriggerAddCondition(trig,Condition(function Conditions))
endfunction
endscope
scope Burrowstrike
globals
private integer abil_id = 'ASTR' // Burrowstrike ability rawcode
private integer dum1_id = 'ABUR' // BSImaple (1) ability rawcode
private integer dum2_id = '2STR' // BSImaple (2) ability rawcode
private integer dum3_id = '3STR' // BSImaple (3) ability rawcode
private integer dum4_id = '4STR' // BSImaple (4) ability rawcode
private integer dum5_id = '5STR' // BSImaple (5) ability rawcode
private integer dum6_id = '6STR' // BSImaple (6) ability rawcode
private integer dum7_id = '7STR' // BSImaple (7) ability rawcode
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId()==abil_id
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer lvl = GetUnitAbilityLevel(u,abil_id)
local location l = GetSpellTargetLoc()
local location lu = GetUnitLoc(u)
local real ang = AngleBetweenPoints(lu,l)
local unit dum = CreateUnitAtLoc(GetOwningPlayer(u),CasterUnitId,lu,ang)
local integer id
if lvl==1 then
set id = dum1_id
elseif lvl==2 then
set id = dum2_id
elseif lvl==3 then
set id = dum3_id
elseif lvl==4 then
set id = dum4_id
elseif lvl==5 then
set id = dum5_id
elseif lvl==6 then
set id = dum6_id
else
set id = dum7_id
endif
call UnitAddAbility(dum,id)
call SetUnitAbilityLevel(dum,id,R2I(DistanceBetweenPoints(lu,l))/100)
call IssuePointOrderByIdLoc(dum,OrderId("impale"),l)
call UnitApplyTimedLife(dum,'BTLF',1.)
call PolledWait2((DistanceBetweenPoints(lu,l)/4000.))
call SetUnitX(u,SafeX(GetLocationX(l)))
call SetUnitY(u,SafeY(GetLocationY(l)))
call SetUnitAnimation(u,"morph ALTERNATE")
call RemoveLocation(l)
set l = null
call RemoveLocation(lu)
set lu = null
set dum = null
endfunction
//===========================================================================
public function InitTrig takes nothing returns nothing
local trigger trig = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction( trig, function Actions )
call TriggerAddCondition(trig,Condition(function Conditions))
call PreLoadAbil(dum1_id)
call PreLoadAbil(dum2_id)
call PreLoadAbil(dum3_id)
call PreLoadAbil(dum4_id)
call PreLoadAbil(dum5_id)
call PreLoadAbil(dum6_id)
call PreLoadAbil(dum7_id)
endfunction
endscope