Name | Type | is_array | initial_value |
//TESH.scrollpos=0
//TESH.alwaysfold=0
///////////////////////////////////////////////////////////////////
//==============================================================
// LIGHTNINGS 1.5
// eubz
//============================================================== //
//This is a very simple spell but could be useful for maps.
//
//THANKS TO:
// Luorax, iAyanami, and Adiktuz
//==============================================================
//WHAT THIS SPELL DO:
//Creates lightnings around a target that deals damage
//to its sorrounding units which are enemies of the caster.
//Level 1 - 50 damage, 250 AoE
//Level 2 - 100 damage, 500 AoE
//Level 3 - 150 damage, 750 AoE
//==============================================================
//
//HOW TO IMPORT:
//1. copy all these codes into your map OR copy the trigger labeled Lightning.
//2. create an ability for this spell or just copy the custom ability in this map for this spell.
//
//==============================================================
///////////////////////////////////////////////////////////////////////////////////
//==============================================================
library Lightnings initializer Init
//==========================================================
//THE GLOBALS BELOW CAN BE CONFIGURED=======================
globals
private constant real DAMAGE = 50 //the damage dealt (you can set this)
private constant real AREA_OF_EFFECT = 250 //how large is the lightning AoE(you can set this)
private constant string SFX = "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl" //the SFX model path
private constant integer ABIL_CODE = 'A001' //the ability ID
private constant attacktype A_TYPE = ATTACK_TYPE_NORMAL
private constant damagetype D_TYPE = DAMAGE_TYPE_NORMAL
endglobals
//END OF CONFIGURATIONS======================================
constant native UnitAlive takes unit id returns boolean
private constant function areaEffect takes integer level returns real
return AREA_OF_EFFECT*level
endfunction
private constant function damageInflict takes integer level returns real
return DAMAGE*level
endfunction
private constant function GetFilter takes unit caster, unit u returns boolean
return IsUnitEnemy((u),GetOwningPlayer(caster))/*
*/and UnitAlive(u)/*
*/and not IsUnitType((u), UNIT_TYPE_STRUCTURE)/*
*/and not IsUnitType((u), UNIT_TYPE_MAGIC_IMMUNE)
endfunction
//============================================================================
private function lightningsConditions takes nothing returns boolean
return GetSpellAbilityId() == ABIL_CODE
endfunction
//===========================================================================
//from here, we'll start the real lightning spell
globals
private group g = bj_lastCreatedGroup
endglobals
private function lightningActions takes nothing returns nothing
local real damage
local real d
local unit caster
local unit target
local real x
local real y
local unit u
local integer level
set caster = GetTriggerUnit()
set target = GetSpellTargetUnit()
set x = GetUnitX(target)
set y = GetUnitY(target)
set level = GetUnitAbilityLevel(caster, ABIL_CODE)
set d = areaEffect(level)
set damage = damageInflict(level)
call GroupEnumUnitsInRange(g, x, y, d, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if GetFilter(caster, u) then
call UnitDamageTarget(caster,u,damage,true,false,A_TYPE,D_TYPE,null)
endif
call GroupRemoveUnit(g, u)
endloop
set caster = null
set target = null
if d > 0 then
loop
set d = d - 10
exitwhen d < 0
call DestroyEffect(AddSpecialEffect(SFX,x+d*Cos(d+50*bj_DEGTORAD),y+d*Sin(d+50*bj_DEGTORAD)))
endloop
endif
endfunction
private function Init takes nothing returns nothing
local trigger L
set L = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( L, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( L, Condition( function lightningsConditions ) )
call TriggerAddAction( L, function lightningActions )
endfunction
endlibrary
//====================================================================
//Code by eubz//
//TESH.scrollpos=0
//TESH.alwaysfold=0
///////////////////////////////////////////////////
//This is just to recreate creeps when killed...//
/////////////////////////////////////////////////
library CreateCreeps initializer GetCreeps
globals
private real time
private unit creep
private location creeploc
endglobals
private function Trig_this_map_Actions takes nothing returns nothing
set time = 6.00
set creep = GetTriggerUnit()
set creeploc = GetUnitLoc(creep)
call TriggerSleepAction(time)
call CreateNUnitsAtLoc(1, GetUnitTypeId(creep),GetOwningPlayer(creep),creeploc, GetUnitFacing(creep))
endfunction
private function GetCreeps takes nothing returns nothing
local trigger trig
set trig = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( trig, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( trig, function Trig_this_map_Actions )
endfunction
endlibrary
//====================================================================================================================