//***************************************************************************************************
//* ===================
//* Lightning Fury
//* ===================
//* Made by emjlr3.
//*
//*
//* How to implement:
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* 1. Copy the spells Lightning Fury and Lightning Fury (Dummy) to your map.
//*
//* 2. Copy the dummy unit Cast Dummy (Enemy) to your map, and give it the spell Lightning Fury
//* (Dummy).
//*
//* 3. Copy this trigger to your map and the code in the custom script section of this map, and
//* change the dummy unit raw codes in it to those in your map.
//*
//*
//* Targets/Effects:
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* This is set to all non magic immune enemies, but can be changed in the two unit spells
//* fields. The rest of the options not available to be changed here can also be changed in
//* the two abilities Lightning Fury and Lightning Fury (Dummy).
//*
//*
//*************************************************************************************************
//Variable Configuration:
constant function Lightning_Fury_SpellId takes nothing returns integer
return 'A02Q'
endfunction
constant function Lightning_Fury_DummyId takes nothing returns integer
return 'A02R'
endfunction
constant function Lightning_Fury_Jumps takes integer Level returns integer
return 6 + Level * 2 //Number of jumps
endfunction
constant function Lightning_Fury_Explosion takes integer Level returns integer
return 0 + Level * 5 //Chance for random lightning explosion
endfunction
constant function Lightning_Fury_Radius takes real Level returns real
return 50 + Level * 100 //Radius of damage for random explosions
endfunction
constant function Lightning_Fury_Damage takes real Level returns real
return 15 + Level * 10 //Damage done by random explosions
endfunction
constant function Lightning_Fury_Effects takes nothing returns string
return "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" //Effect of random lightning explosion
endfunction
//Spell:
function Lightning_Fury_1 takes nothing returns boolean
return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false and IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction
function Lightning_Fury_2 takes nothing returns boolean
return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == false and Lightning_Fury_1() )
endfunction
function Lightning_Fury_3 takes nothing returns boolean
return ( GetFilterUnit() != GetSpellTargetUnit() and Lightning_Fury_2() )
endfunction
function Lightning_Fury_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit v
local unit w
local unit x
local unit y
local integer i = GetUnitAbilityLevel(u, Lightning_Fury_SpellId())
local integer j = GetDummyIdEnemy()
local integer k = Lightning_Fury_DummyId()
local integer l = Lightning_Fury_Jumps(i)
local integer m = 0
local integer n = Lightning_Fury_Explosion(i)
local location L = GetUnitLoc(u)
local location M = GetUnitLoc(GetSpellTargetUnit())
local location N
local real r = Lightning_Fury_Radius(i)
local real s = Lightning_Fury_Damage(i)
local group g
local player p = GetOwningPlayer(u)
call TriggerSleepAction( ( DistanceBetweenPoints(L, M) / 1500.00 ) )
set g = GetUnitsInRangeOfLocMatching(600.00, M, Condition(function Lightning_Fury_3))
if ( IsUnitGroupEmptyBJ(g) == false ) then
set v = GroupPickRandomUnit(g)
call GroupRemoveUnit( g, v )
set x = CreateUnit(p,j,GetUnitX(GetSpellTargetUnit()),GetUnitY(GetSpellTargetUnit()),bj_UNIT_FACING)
call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
call IssueTargetOrder( x, "chainlightning", v )
call UnitApplyTimedLife( x, 'BTLF', 1.00 )
if (GetRandomInt(1, 100) <= n) then
call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(v), GetUnitY(v) ))
call DamageEnemiesArea(u, r, GetUnitX(v), GetUnitY(v), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
else
endif
if ( IsUnitGroupEmptyBJ(g) == false ) then
set w = GroupPickRandomUnit(g)
set x = CreateUnit(p,j,GetUnitX(GetSpellTargetUnit()),GetUnitY(GetSpellTargetUnit()),bj_UNIT_FACING)
call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
call IssueTargetOrder( x, "chainlightning", w )
call UnitApplyTimedLife( x, 'BTLF', 1.00 )
if (GetRandomInt(1, 100) <= n) then
call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(w), GetUnitY(w) ))
call DamageEnemiesArea(u, r, GetUnitX(w), GetUnitY(w), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
else
endif
else
endif
else
endif
call DestroyGroup(g)
call TriggerSleepAction( 0.02 )
loop
set m = m + 1
exitwhen m > l
set N = GetUnitLoc(v)
set g = GetUnitsInRangeOfLocMatching(600.00, N, Condition(function Lightning_Fury_2))
call RemoveLocation(N)
if ( IsUnitGroupEmptyBJ(g) == false ) then
if ( GetFilterUnit() != v ) then
set y = v
call GroupRemoveUnit( g, y )
set v = GroupPickRandomUnit(g)
call GroupRemoveUnit( g, v )
call GroupAddUnit(g,y)
set x = CreateUnit(p,j,GetUnitX(v),GetUnitY(v),bj_UNIT_FACING)
call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
set v = GroupPickRandomUnit(g)
call IssueTargetOrder( x, "chainlightning", v )
call UnitApplyTimedLife( x, 'BTLF', 1.00 )
if (GetRandomInt(1, 100) <= n) then
call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(v), GetUnitY(v) ))
call DamageEnemiesArea(u, r, GetUnitX(v), GetUnitY(v), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
else
endif
else
set x = CreateUnit(p,j,GetUnitX(v),GetUnitY(v),bj_UNIT_FACING)
call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
call GroupRemoveUnit(g,v)
set v = GroupPickRandomUnit(g)
call IssueTargetOrder( x, "chainlightning", v )
call UnitApplyTimedLife( x, 'BTLF', 1.00 )
if (GetRandomInt(1, 100) <= n) then
call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(v), GetUnitY(v) ))
call DamageEnemiesArea(u, r, GetUnitX(v), GetUnitY(v), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
else
endif
endif
else
endif
call DestroyGroup(g)
set N = GetUnitLoc(w)
set g = GetUnitsInRangeOfLocMatching(600.00, N, Condition(function Lightning_Fury_2))
call RemoveLocation(N)
if ( IsUnitGroupEmptyBJ(g) == false ) then
if ( GetFilterUnit() != w ) then
set y = w
call GroupRemoveUnit( g, y )
set w = GroupPickRandomUnit(g)
call GroupRemoveUnit( g, w )
call GroupAddUnit(g,y)
set x = CreateUnit(p,j,GetUnitX(w),GetUnitY(w),bj_UNIT_FACING)
call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
set w = GroupPickRandomUnit(g)
call IssueTargetOrder( x, "chainlightning", w )
call UnitApplyTimedLife( x, 'BTLF', 1.00 )
if (GetRandomInt(1, 100) <= n) then
call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(w), GetUnitY(w) ))
call DamageEnemiesArea(u, r, GetUnitX(w), GetUnitY(w), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
else
endif
else
set x = CreateUnit(p,j,GetUnitX(w),GetUnitY(w),bj_UNIT_FACING)
call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
call GroupRemoveUnit(g,w)
set w = GroupPickRandomUnit(g)
call IssueTargetOrder( x, "chainlightning", w )
call UnitApplyTimedLife( x, 'BTLF', 1.00 )
if (GetRandomInt(1, 100) <= n) then
call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(w), GetUnitY(w) ))
call DamageEnemiesArea(u, r, GetUnitX(w), GetUnitY(w), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
else
endif
endif
else
endif
call DestroyGroup(g)
call TriggerSleepAction( 0.02 )
endloop
set u = null
set v = null
set w = null
set x = null
set y = null
set g = null
set p = null
call RemoveLocation(L)
call RemoveLocation(M)
set L = null
set M = null
set N = null
endfunction
//===========================================================================
function Lightning_Fury_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Lightning_Fury_SpellId()
endfunction
function InitTrig_Lightning_Fury takes nothing returns nothing
set gg_trg_Lightning_Fury = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Fury, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Lightning_Fury, Condition( function Lightning_Fury_Conditions ) )
call TriggerAddAction( gg_trg_Lightning_Fury, function Lightning_Fury_Actions )
endfunction