//TESH.scrollpos=0
//TESH.alwaysfold=0
//=============================================================================
// Mamaragan
// By: scorpion182
//
// Creates a thunder storm showers lightning everywhere in target location,
// that deal massive damage.
//
//
// Spell Requires: Mamaragan ability
// Mamaragan dummy unit
//
//
// Implementation:
// Simply copy the forementioned requirements to your map, go through the
// options below and enjoy!
//=============================================================================
//Configuration Options:
//=============================================================================
constant function Mamaragan_Dummy takes nothing returns integer
return 'u00G' // rawcode of Mamaragan Dummy unit
endfunction
constant function Mamaragan_AbilId takes nothing returns integer
return 'A03A' // ability rawcode of Mamaragan ability
endfunction
constant function Mamaragan_Damage takes integer lvl returns integer
return 150 + ( 140 * lvl) // damage option
endfunction
//Configuration end
//=============================================================================
//=============================================================================
//The Spell itself
//Don't Touch unless you know what you are doing!!
//=============================================================================
function M_DamageFilter takes nothing returns boolean
if(IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE))then//not effect on building
return false
endif
if(GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0)then//not effect on died unit
return false
endif
if(IsUnitAlly(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit())))then//only damage enemies
return false
endif
return true
endfunction
function M_DoDamage takes nothing returns nothing
local integer dmg=Mamaragan_Damage(GetUnitAbilityLevel(GetTriggerUnit(),Mamaragan_AbilId()))
call UnitDamageTarget(GetTriggerUnit(), GetEnumUnit(), I2R(dmg), true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endfunction
function Trig_Mamaragan_Conditions takes nothing returns boolean
return( GetSpellAbilityId() == Mamaragan_AbilId() )
endfunction
function Trig_Mamaragan_Actions takes nothing returns nothing
local location loc=GetSpellTargetLoc()
local unit caster=GetTriggerUnit()
local location loc2
local integer i=0
local unit dummy
local group grp
local real x = GetLocationX(loc)
local real y = GetLocationY(loc)
local rect r=Rect( x - 400.0*0.5, y - 400.*0.5, x + 400.*0.5, y + 400*0.5 )
local boolexpr b=Condition(function M_DamageFilter)
loop
exitwhen i>5
set loc2=Location(GetRandomReal(GetRectMinX(r), GetRectMaxX(r)), GetRandomReal(GetRectMinY(r), GetRectMaxY(r)))
set dummy=CreateUnitAtLoc(GetOwningPlayer(caster),Mamaragan_Dummy(),loc2,bj_UNIT_FACING)
call UnitApplyTimedLife(dummy,'BTLF',0.5)
call SetUnitPathing(dummy,false)
call SetUnitInvulnerable(dummy,true)
call RemoveLocation(loc2)
set loc2=null
set i=i+1
endloop
set grp=CreateGroup()
call GroupEnumUnitsInRangeOfLoc(grp,loc,400., b)
call ForGroup(grp,function M_DoDamage)
call DestroyGroup(grp)
call DestroyBoolExpr(b)
call RemoveLocation(loc)
call RemoveRect(r)
set b=null
set caster=null
set loc=null
set grp=null
set dummy=null
set r=null
endfunction
//===========================================================================
function InitTrig_Mamaragan takes nothing returns nothing
set gg_trg_Mamaragan = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Mamaragan, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Mamaragan, Condition( function Trig_Mamaragan_Conditions ) )
call TriggerAddAction( gg_trg_Mamaragan, function Trig_Mamaragan_Actions )
endfunction