Name | Type | is_array | initial_value |
Creep_Face_Ang | real | Yes | |
Creep_Loc | location | Yes | |
Integer | integer | No | |
Temp_Point | location | No |
//TESH.scrollpos=63
//TESH.alwaysfold=0
scope DPteehee initializer Init
globals
//SpellId of the spell
private constant integer SpellId = 'A000'
//How close units need to be to become infected
private constant real effectRadius = 125
//This is the total amount of damage a unit will recieve over the time it is infected
private constant real damagePerLevel = 40
//This is the set amount of time a unit will take damage before the infection leaves
private constant real timeOnEachUnit = 2.00
//sets the frequency that the spell checks for infectable units, how often the damage text is displayed
//and the amount of damage per interval. Does not change total amount of damage.
private constant real interval = .1
//special effect displayed over the heads of infected units
private constant string effectPath = "Abilities\\Spells\\NightElf\\shadowstrike\\shadowstrike.mdl"
//string for where the effect named above is attached
private constant string effectPoint = "overhead"
endglobals
private struct DP
unit hurter
unit which
real time = timeOnEachUnit
real damagePerTick
effect sfx
endstruct
globals
private DP array c
private integer i = 0
private timer t = CreateTimer()
private integer instances = 0
private group affected = CreateGroup()
endglobals
private function IsGroundUnit takes nothing returns boolean
local unit u = GetFilterUnit()
local boolean b = IsUnitType(u, UNIT_TYPE_FLYING) == false and IsUnitType(u, UNIT_TYPE_STRUCTURE) == false and IsUnitType(u, UNIT_TYPE_DEAD) == false and IsUnitInGroup(u, affected) == false
set u = null
return b
endfunction
private function looping takes nothing returns boolean
local integer z = i
local group g = CreateGroup()
local unit target
local unit caster
loop
exitwhen z <= 0
call GroupEnumUnitsInRange(g, GetUnitX(c[z].which), GetUnitY(c[z].which), effectRadius, Condition(function IsGroundUnit))
call GroupRemoveUnit(g, c[z].hurter)
loop
set target = FirstOfGroup(g)
exitwhen target == null
call GroupRemoveUnit(g, target)
if IsUnitAlly(target, GetOwningPlayer(c[z].hurter)) == false then
set caster = c[z].which
set i = i+1
if i > instances then
set instances = instances+1
set c[i] = DP.create()
endif
set c[i].hurter = c[z].hurter
set c[i].which = target
set c[i].damagePerTick = GetUnitAbilityLevel(c[i].hurter, SpellId) * damagePerLevel * interval / timeOnEachUnit
set c[i].sfx = AddSpecialEffectTarget(effectPath, target, effectPoint)
call GroupAddUnit(affected, c[i].which)
set target = null
set caster = null
endif
endloop
call UnitDamageTarget(c[z].hurter, c[z].which, c[z].damagePerTick, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call DestroyGroup(g)
set g = null
set c[z].time = c[z].time - interval
if c[z].time <= 0 or IsUnitType(c[z].which, UNIT_TYPE_DEAD) == true then
call GroupRemoveUnit(affected, c[z].which)
call DestroyEffect(c[z].sfx)
set c[z] = c[i]
set i = i-1
set instances = instances - 1
if i==0 then
call GroupClear(affected)
call PauseTimer(t)
endif
endif
set z = z-1
endloop
return false
endfunction
private function Actions takes unit caster, unit target returns nothing
set i = i+1
if i > instances then
set instances = instances+1
set c[i] = DP.create()
endif
set c[i].hurter = caster
set c[i].which = target
set c[i].damagePerTick = GetUnitAbilityLevel(c[i].hurter, SpellId) * damagePerLevel * interval / timeOnEachUnit
set c[i].sfx = AddSpecialEffectTarget(effectPath, target, effectPoint)
call GroupAddUnit(affected, c[i].which)
set target = null
set caster = null
if i == 1 then
call TimerStart(t, interval, true, function looping)
endif
endfunction
private function Conditions takes nothing returns boolean
if SpellId == GetSpellAbilityId() then
call Actions(GetTriggerUnit(), GetSpellTargetUnit())
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer index = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition( t, Condition(function Conditions) )
endfunction
endscope