scope Light initializer InitTrig_Light
globals
private constant string Lightning = "HWSB" //RAWCODE!
private constant integer SPELL_ID = 'A003'
private constant string Effect1 = "Abilities\\Spells\\Human\\ReviveHuman\\ReviveHuman.mdl"
private constant integer DAMBASE = 100 // This is the base damage. It is multiplyed by the level later
private constant real Real1 = 45 //Change the Real stuff up to Real4 to change were the lightning is created(Degrees)
private constant real Real2 = 135
private constant real Real3 = 225
private constant real Real4 = 315
private constant real Real5 = 400 // Change this to increase or decrease how far away the lightning is
private constant real Real6 = 750 // This changes the size of the area were units are grouped and effects are created
private constant real Real7 = 500//Change this to set the height of the lightnings in the air.
private constant real Real8 = 250//Change this to set the height were the lightning meets above the caster.Set it heigher them Rea7 to make it over the cube.
private boolexpr BOOL // Don't touch this
endglobals
private function FilterFunc takes nothing returns boolean
local unit u = GetFilterUnit()
local boolean ok = GetWidgetLife(u) > .405 and IsUnitEnemy(u,GetOwningPlayer(GetTriggerUnit()))
set u = null
return ok
endfunction
private function Light_Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Light_Actions takes nothing returns nothing
local unit C = GetSpellAbilityUnit()
local location CL = GetUnitLoc(C)
local real CR = GetUnitX(C)
local real RC = GetUnitY(C)
local rect R = RectFromCenterSizeBJ(CL,Real6,Real6)
local player Y = GetOwningPlayer(C)
local integer Level = GetUnitAbilityLevel(C,SPELL_ID)
local integer Index
local real X1 = CR + Real5 * Cos(Real1*bj_DEGTORAD)
local real X2 = CR + Real5 * Cos(Real2*bj_DEGTORAD)
local real X3 = CR + Real5 * Cos(Real3*bj_DEGTORAD)
local real X4 = CR + Real5 * Cos(Real4*bj_DEGTORAD)
local real Y1 = RC + Real5 * Sin(Real1*bj_DEGTORAD)
local real Y2 = RC + Real5 * Sin(Real2*bj_DEGTORAD)
local real Y3 = RC + Real5 * Sin(Real3*bj_DEGTORAD)
local real Y4 = RC + Real5 * Sin(Real4*bj_DEGTORAD)
local real Z1 = GetUnitFlyHeight(C)+Real7
local real Z2 = GetUnitFlyHeight(C)+Real8
local lightning array L
local real M1
local real M2
local real X5
local real Y5
local integer P =1
local real Damage = DAMBASE * Level
local location M
local integer PE =30*Level
local unit U
local group G = CreateGroup()
set L[0] = AddLightning(Lightning,true,X1,Y1,X2,Y2)
set L[1] = AddLightning(Lightning,true,X2,Y2,X3,Y3)
set L[2] = AddLightning(Lightning,true,X3,Y3,X4,Y4)
set L[3] = AddLightning(Lightning,true,X4,Y4,X1,Y1)
set L[4] = AddLightningEx(Lightning,true,X1,Y1,0,X1,Y1,Z1)
set L[5] = AddLightningEx(Lightning,true,X2,Y2,0,X2,Y2,Z1)
set L[6] = AddLightningEx(Lightning,true,X3,Y3,0,X3,Y3,Z1)
set L[7] = AddLightningEx(Lightning,true,X4,Y4,0,X4,Y4,Z1)
set L[8] = AddLightningEx(Lightning,true,X1,Y1,Z1,X2,Y2,Z1)
set L[9] = AddLightningEx(Lightning,true,X2,Y2,Z1,X3,Y3,Z1)
set L[10] = AddLightningEx(Lightning,true,X3,Y3,Z1,X4,Y4,Z1)
set L[11] = AddLightningEx(Lightning,true,X4,Y4,Z1,X1,Y1,Z1)
set L[12] = AddLightningEx(Lightning,true,X1,Y1,Z1,CR,RC,Z2)
set L[13] = AddLightningEx(Lightning,true,X2,Y2,Z1,CR,RC,Z2)
set L[14] = AddLightningEx(Lightning,true,X3,Y3,Z1,CR,RC,Z2)
set L[15] = AddLightningEx(Lightning,true,X4,Y4,Z1,CR,RC,Z2)
set L[16] = AddLightningEx(Lightning,true,X1,Y1,0,CR,RC,Z2)
set L[17] = AddLightningEx(Lightning,true,X2,Y2,0,CR,RC,Z2)
set L[18] = AddLightningEx(Lightning,true,X3,Y3,0,CR,RC,Z2)
set L[19] = AddLightningEx(Lightning,true,X4,Y4,0,CR,RC,Z2)
call GroupEnumUnitsInRange(G,CR,RC,Real6,BOOL)
loop
exitwhen P>PE
set M = GetRandomLocInRect(R)
call DestroyEffect(AddSpecialEffectLoc(Effect1,M))
set M = GetRandomLocInRect(R)
call DestroyEffect(AddSpecialEffectLoc(Effect1,M))
set M = GetRandomLocInRect(R)
call DestroyEffect(AddSpecialEffectLoc(Effect1,M))
set M = GetRandomLocInRect(R)
call DestroyEffect(AddSpecialEffectLoc(Effect1,M))
call RemoveLocation(M)
call TriggerSleepAction(.3)
set P=P+1
endloop
loop
set U = FirstOfGroup(G)
exitwhen U==null
call GroupRemoveUnit(G,U)
call UnitDamageTarget(C,U,Damage,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
endloop
call RemoveRect(R)
set P = 0
loop
exitwhen P==20
call DestroyLightning(L)
set P = P+1
endloop
call DestroyGroup(G)
set C=null
endfunction
//===========================================================================
private function InitTrig_Light takes nothing returns nothing
local trigger I = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(I,EVENT_PLAYER_UNIT_SPELL_CAST)
call TriggerAddCondition(I,Condition(function Light_Conditions))
call TriggerAddAction(I,function Light_Actions)
set I=null
call Preload(Effect1)
set BOOL = Filter(function FilterFunc)
endfunction
endscope