scope ThunderRage initializer init
globals
private constant integer SPELL_ID = 'A000' // Ability raw code.
private constant integer SLOW_ID = 'A001' // Slow ability raw code.
private constant integer THUNDER_ID = 'h000' // Thunder raw code.
private constant integer R_ASHES_ID = 'h001' // Red ashes raw code.
private constant integer SHADOWLVL1_ID = 'h006' // Shadow LVL 1 raw code.
private constant integer SHADOWLVL2_ID = 'h005' // Shadow LVL 2 raw code.
private constant integer SHADOWLVL3_ID = 'h004' // Shadow LVL 3 raw code.
private constant integer DUMMY_CASTER = 'h007' // Dummy caster raw code.
private constant string STOMP_EFFECT = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"
private constant real SPELL_TIME = 3.00 // How long the thunders gonna wait for the enemy.
private constant real TIME_OUT = 0.03125 // How often the timers fire.
private constant hashtable HS = InitHashtable() // Spell hashtable.Very important.
endglobals
private function stopshake takes nothing returns nothing
local timer z = GetExpiredTimer()
local integer id = GetHandleId(z)
call CameraClearNoiseForPlayer(LoadPlayerHandle(HS,id,1))
call DestroyTimer(z)
endfunction
private function shake takes player p, real m, real t returns nothing
local timer z = CreateTimer()
local integer id = GetHandleId(z)
call CameraSetEQNoiseForPlayer(p,m)
call SavePlayerHandle(HS,id,1,p)
call TimerStart(z,t,false,function stopshake)
endfunction
private function destroydes takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
private function effc takes nothing returns nothing
local timer z = GetExpiredTimer()
local integer id = GetHandleId(z)
local location p = LoadLocationHandle(HS,id,1)
local real ani = LoadReal(HS,id,2)
local real radius = LoadReal(HS,id,3)
local real time = LoadReal(HS,id,4)
local player pl = LoadPlayerHandle(HS,id,5)
local location p2
if time <= SPELL_TIME-(SPELL_TIME*0.1) then
set ani = ani+1
if ani >= (TIME_OUT*8)/TIME_OUT then
set p2 = GetRandomLocInRect(RectFromCenterSizeBJ(p,radius,radius))
set bj_lastCreatedUnit = CreateUnit(pl,THUNDER_ID,GetLocationX(p2),GetLocationY(p2),0.00)
call UnitApplyTimedLife(bj_lastCreatedUnit,'BTLF',1.00)
call RemoveLocation(p2)
set ani = 0
endif
call SaveReal(HS,id,2,ani)
set time = time+TIME_OUT
call SaveReal(HS,id,4,time)
else
call DestroyTimer(z)
call RemoveLocation(p)
endif
endfunction
private function effs takes player pl, real x, real y, real radius returns nothing
local timer z = CreateTimer()
local integer id = GetHandleId(z)
local location p = Location(x,y)
call SaveLocationHandle(HS,id,1,p)
call SaveReal(HS,id,2,0.00)
call SaveReal(HS,id,3,radius)
call SaveReal(HS,id,4,0.00)
call SavePlayerHandle(HS,id,5,pl)
call TimerStart(z,TIME_OUT,true,function effc)
endfunction
private function onLoop takes nothing returns nothing
local timer z = GetExpiredTimer()
local integer id = GetHandleId(z)
local unit caster = LoadUnitHandle(HS,id,1)
local unit enemy
local unit enum
local real x1
local real y1
local real x = LoadReal(HS,id,2)
local real y = LoadReal(HS,id,3)
local real radius = LoadReal(HS,id,4)
local real damage = LoadReal(HS,id,5)
local real time = LoadReal(HS,id,6)
local group egroup = LoadGroupHandle(HS,id,7)
local group dgroup = LoadGroupHandle(HS,id,8)
local group en = CreateGroup()
local location p = Location(x,y)
if time < SPELL_TIME then
call GroupEnumUnitsInRange(en,x,y,radius,null)
loop
set enemy = FirstOfGroup(en)
exitwhen enemy == null
if IsUnitEnemy(enemy,GetOwningPlayer(caster)) == true and IsUnitAliveBJ(enemy) == true then
call PauseUnit(enemy,true)
call SetUnitTimeScalePercent(enemy,0)
call GroupAddUnit(egroup,enemy)
call GroupRemoveUnit(en,enemy)
else
call GroupRemoveUnit(en,enemy)
endif
endloop
call DestroyGroup(en)
set time = time + TIME_OUT
call SaveReal(HS,id,6,time)
else
if CountUnitsInGroup(egroup) == 0 then
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),THUNDER_ID,x,y,0.00)
call UnitApplyTimedLife(bj_lastCreatedUnit,'BTLF',3.00)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),R_ASHES_ID,x,y,0.00)
call UnitApplyTimedLife(bj_lastCreatedUnit,'BTLF',2)
call DestroyEffect(AddSpecialEffect(STOMP_EFFECT,x,y))
else
loop
set enum = FirstOfGroup(egroup)
exitwhen enum == null
set x1 = GetUnitX(enum)
set y1 = GetUnitY(enum)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),THUNDER_ID,x1,y1,0.00)
call UnitApplyTimedLife(bj_lastCreatedUnit,'BTLF',3.00)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),R_ASHES_ID,x1,y1,0.00)
call UnitApplyTimedLife(bj_lastCreatedUnit,'BTLF',2)
call DestroyEffect(AddSpecialEffect(STOMP_EFFECT,x1,y1))
call UnitDamageTargetBJ(caster,enum,damage,null,null)
call shake(GetOwningPlayer(enum),15,.5)
call PauseUnit(enum,false)
call SetUnitTimeScalePercent(enum,100)
call GroupRemoveUnit(egroup,enum)
endloop
endif
call EnumDestructablesInCircleBJ(radius,p,function destroydes)
call RemoveLocation(p)
call CameraClearNoiseForPlayer(GetOwningPlayer(caster))
call shake(GetOwningPlayer(caster),15,.5)
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, SPELL_TIME/3, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100, 0, 0, 30 )
loop
set enum = FirstOfGroup(dgroup)
exitwhen enum == null
call GroupRemoveUnit(dgroup,enum)
call RemoveUnit(enum)
endloop
call DestroyGroup(dgroup)
call DestroyGroup(egroup)
call DestroyTimer(z)
endif
endfunction
private function Spell_Id takes nothing returns boolean
if ( not ( GetSpellAbilityId() == SPELL_ID) ) then
return false
endif
return true
endfunction
private function Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local group egroup = CreateGroup()
local group dgroup = CreateGroup()
local timer z = CreateTimer()
local integer id = GetHandleId(z)
local integer lvl = GetUnitAbilityLevelSwapped(SPELL_ID,caster)// Spell level
local integer c
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
local real radius = (100*lvl)+300 // You can change this
local real damage = (200*lvl)+300 // You also can change this one.
if lvl == 1 then
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL1_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL1_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL1_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL1_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL1_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
elseif lvl == 2 then
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL2_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL2_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL2_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL2_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL2_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
elseif lvl == 3 then
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL3_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL3_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL3_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL3_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(caster),SHADOWLVL3_ID,x,y,0.00)
call GroupAddUnit(dgroup,bj_lastCreatedUnit)
endif
call effs(GetOwningPlayer(caster),x,y,radius)
call PauseUnit(caster,true)
call SetUnitAnimation(caster,"channel")
call PauseUnit(caster,false)
// Save all of the data.
call SaveUnitHandle(HS,id,1,caster)
call SaveReal(HS,id,2,x)
call SaveReal(HS,id,3,y)
call SaveReal(HS,id,4,radius)
call SaveReal(HS,id,5,damage)
call SaveReal(HS,id,6,0.00)
call SaveGroupHandle(HS,id,7,egroup)
call SaveGroupHandle(HS,id,8,dgroup)
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, SPELL_TIME/3, "ReplaceableTextures\\CameraMasks\\White_Mask.blp", 100.00, 0, 0, 80.00 )
call CameraSetEQNoiseForPlayer(GetOwningPlayer(caster),3)
call TimerStart(z,TIME_OUT,true,function onLoop)
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer index
set index = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index),EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t,Condition(function Spell_Id))
call TriggerAddAction(t,function Actions)
set t = null
endfunction
endscope