//TESH.scrollpos=0
//TESH.alwaysfold=0
Name | Type | is_array | initial_value |
UnitGroup_ESC | group | No |
//TESH.scrollpos=196
//TESH.alwaysfold=0
//*********************************************
//* *
//* S P I R I T O F N A T U R E *
//* v1.2 *
//* *
//* By: Ribenamania *
//* *
//**************************************
scope SpiritOfNature
private struct Spirit_Data
unit c
unit s
real a
endstruct
globals
//**********************************************************************************************************
//* These are variables that can be manipulate to have various effects of the spell *
//**********************************************************************************************************
//* FollowCaster - Do The Dummies Follow The Caster Boolean *
//* ThreantTimedLifeLevel - Do The Threat's Timed Life Increase per Level *
//* ExplosionDamageLevel - Do The Explosion Damage Increase per Level *
//* DummyNumberLevel - Do The Number of Dummies Increase per Level *
//* SpellRawCode - Raw Code of The Spell *
//* DummyRawCode - Raw Code of The Dummy *
//* RootRawCode - Raw Code of The Entangling Root *
//* ThreantRawCode - Raw Code of The Threant *
//* DummyNumber - The Number of Dummies Summoned *
//* DummyNumberIncreasion - The Number of Dummies Summoned Added per Level *
//* ThreatTimedLife - Numbers of Waves/Dummies Summoned Out *
//* ThreatTimedLifeIncreasion - Threat's Timed Life Added per level *
//* ExplosionDamage - Damage Caused by Explosion of Spirit *
//* ExplosionDamageIncreasion - Explosion Damage Added per Level *
//* ExplosionRadius - Explosion Area of Effect's Radius *
//* Timeout - Timer's Time Out *
//* SpiritSpeed - The Speed of The Movement of The Spirit *
//* ThreantSFX - The Special Effect At Threant's Spawn *
//* ExplosionSFX - The Special Effect At Spirit's Explosion *
//* CasterSFX - The Special Effect of Caster When Spell Was Started *
//* AttachPoint - The Attachment Point where CasterSFX is attached *
//*************************************************************************************
private constant boolean ThreantTimedLifeLevel = true
private constant boolean ExplosionDamageLevel = true
private constant boolean DummyNumberLevel = true
private constant integer SpellRawCode = 'A001'
private constant integer DummyRawCode = 'n000'
private constant integer RootRawCode = 'A000'
private constant integer ThreantRawCode = 'efon'
private constant integer DummyNumber = 3
private constant integer DummyNumberIncreasion = 1
private constant real ThreantTimedLife = 5.00
private constant real ThreantTimedLifeIncreasion = 5.00
private constant real ExplosionDamage = 50.00
private constant real ExplosionDamageIncreasion = 50.00
private constant real ExplosionRadius = 256.00
private constant real TimeOut = 0.02
private constant real SpiritSpeed = 3
private constant string ThreantSFX = "Objects\\Spawnmodels\\NightElf\\EntBirthTarget\\EntBirthTarget.mdl"
private constant string ExplosionSFX = "Units\\NightElf\\Wisp\\WispExplode.mdl"
private constant string CasterSFX = "Objects\\Spawnmodels\\NightElf\\NECancelDeath\\NECancelDeath.mdl"
private constant string AttachPoint = "origin"
//************************************************************
//* These are variables that cannot be manipulate *
//**********************************************************
private constant timer Timer = CreateTimer()
private group victims = CreateGroup()
private integer Total = 0
private unit sunit
private Spirit_Data array Spirit
endglobals
private function Spirit_of_Nature_Tree takes nothing returns nothing
local destructable tree = GetEnumDestructable()
local unit t
local real tx = GetDestructableX(tree)
local real ty = GetDestructableY(tree)
local real ThreantTimeLife
local integer spelllevel = GetUnitAbilityLevel(sunit, RootRawCode)
if tree != null and GetWidgetLife(tree) > .405 and GetWidgetLife(sunit) > .415 then
if ThreantTimedLifeLevel == true then
set ThreantTimeLife = ThreantTimedLife + ((ThreantTimedLifeIncreasion * spelllevel) - ThreantTimedLifeIncreasion)
endif
call KillDestructable(tree)
call KillUnit(sunit)
call DestroyEffect(AddSpecialEffect(ThreantSFX, tx, ty))
set t = CreateUnit(GetOwningPlayer(sunit), ThreantRawCode, tx, ty, 270.00)
call UnitApplyTimedLife(t, 'BTLF', ThreantTimeLife)
set tree = null
set t = null
endif
endfunction
private function Update takes nothing returns nothing
local Spirit_Data sd
local integer i = 0
local real x
local real y
local real ExplosionDmg
local rect r
local unit target
local integer spelllevel
loop
exitwhen i == Total
set sd = Spirit[i]
if GetWidgetLife(sd.s) > .415 then
set sunit = sd.s
set sd.a = sd.a + SpiritSpeed
call SetUnitPosition(sd.s, GetUnitX(sd.c) + 300 * Cos(sd.a * bj_DEGTORAD), GetUnitY(sd.c) + 300 * Sin(sd.a * bj_DEGTORAD))
set x = GetUnitX(sd.s)
set y = GetUnitY(sd.s)
set r = Rect(x - 128, y - 128, x + 128, y + 128)
call EnumDestructablesInRect(r, null, function Spirit_of_Nature_Tree)
call RemoveRect(r)
set sunit = null
if GetWidgetLife(sd.s) > .415 then
call GroupEnumUnitsInRange(victims, x, y, 128, null)
set target = FirstOfGroup(victims)
loop
exitwhen target == null
if IsUnitType(target, UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy(target, GetOwningPlayer(sd.c)) == true and GetWidgetLife(target) > .415 then
call IssueTargetOrder(sd.s, "entanglingroots", target)
call ShowUnit(sd.s, false)
call UnitApplyTimedLife(sd.s, 'BTLF', 0.50)
call KillUnit(CreateUnit(GetOwningPlayer(sd.c), DummyRawCode, x, y, 270.00))
set Spirit[i] = Spirit[Total - 1]
set Total = Total - 1
call sd.destroy()
set i = i - 1
endif
call GroupRemoveUnit(victims, target)
set target = null
set target = FirstOfGroup(victims)
endloop
else
set Spirit[i] = Spirit[Total - 1]
set Total = Total - 1
call sd.destroy()
set i = i - 1
endif
else
set spelllevel = GetUnitAbilityLevel(sd.c, SpellRawCode)
if ExplosionDamageLevel == true then
set ExplosionDmg = ExplosionDamage + ((ExplosionDamageIncreasion * spelllevel) - ExplosionDamageIncreasion)
endif
set x = GetUnitX(sd.s)
set y = GetUnitY(sd.s)
call DestroyEffect(AddSpecialEffect(ExplosionSFX, x, y))
call GroupEnumUnitsInRange(victims, x, y, ExplosionRadius, null)
set target = FirstOfGroup(victims)
loop
exitwhen target == null
if IsUnitType(target, UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy(target, GetOwningPlayer(sd.c)) == true and GetWidgetLife(target) > .415 == true then
call UnitDamageTarget(sd.c, target, ExplosionDmg, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endif
call GroupRemoveUnit(victims, target)
set target = null
set target = FirstOfGroup(victims)
endloop
set Spirit[i] = Spirit[Total - 1]
set Total = Total - 1
call sd.destroy()
set i = i - 1
endif
set i = i + 1
endloop
if Total == 0 then
call PauseTimer(Timer)
endif
endfunction
private function SpiritOfNature_Actions takes nothing returns nothing
local Spirit_Data sd
local unit caster = GetTriggerUnit()
local integer i = 1
local integer casterlevel = GetUnitAbilityLevel(caster, SpellRawCode)
local integer DummyNum = DummyNumber
local real cx = GetUnitX(caster)
local real cy = GetUnitY(caster)
local real x
local real y
local real angle = 360/DummyNum
if DummyNumberLevel == true then
set DummyNum = DummyNumber + ((DummyNumberIncreasion * casterlevel) - DummyNumberIncreasion)
endif
loop
exitwhen i > DummyNum
set x = cx + 300 * Cos(angle * bj_DEGTORAD)
set y = cy + 300 * Sin(angle * bj_DEGTORAD)
set sd = Spirit_Data.create()
set sd.c = caster
set sd.s = CreateUnit(GetOwningPlayer(caster), DummyRawCode, x, y, 270.00)
set sd.a = angle
call SetUnitAbilityLevel(sd.s, RootRawCode, casterlevel)
if Total == 0 then
call TimerStart(Timer, TimeOut, true, function Update)
endif
set Total = Total + 1
set Spirit[Total - 1] = sd
set angle = angle + 360/DummyNum
set i = i + 1
endloop
call DestroyEffect(AddSpecialEffectTarget(CasterSFX, caster, AttachPoint))
set caster = null
endfunction
private function SpiritOfNature_Conditions takes nothing returns boolean
return GetSpellAbilityId() == SpellRawCode
endfunction
//===========================================================================
function InitTrig_SpiritOfNature takes nothing returns nothing
local integer index
call Preload(ThreantSFX)
call Preload(ExplosionSFX)
call Preload(CasterSFX)
set gg_trg_SpiritOfNature = CreateTrigger( )
set index = 0
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_SpiritOfNature, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition( gg_trg_SpiritOfNature, Condition( function SpiritOfNature_Conditions ) )
call TriggerAddAction( gg_trg_SpiritOfNature, function SpiritOfNature_Actions )
endfunction
endscope