scope HundredSlash initializer init
globals
private hashtable HundredSlash = InitHashtable()
private constant integer ABILITY = 'A000' //Ability ID for the ability.
private constant integer DUMMY = 'e000' //The Unit ID of the dummy
private constant string EFFECT_A = "BlackBlink.mdx" //The SFX used when the dummies appear.
private constant string EFFECT_B = "AncientExplode.mdx" //The SFX used at the end.
private constant string EFFECT_C = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" //SFX used when the target is being slashed.
private constant string ATTACHMENT = "chest" //Where EFFECT_C shows up
private constant real DAMAGE_BASE = 200 //Base damage of the spell
private constant real DAMAGE_BONUS = 150 //Damage increment per level of the ability.
private constant attacktype ATTACKTYPE = ATTACK_TYPE_NORMAL //Attack type
private constant damagetype DAMAGETYPE = DAMAGE_TYPE_ENHANCED //Damage type
private constant weapontype WEAPONTYPE = null //The sound that plays during the damage step.
endglobals
private function Damage takes integer i returns real
return DAMAGE_BASE + (I2R(i - 1) * DAMAGE_BONUS)
endfunction
//--------------------START OF SPELL-----------------------\\
private function Callback takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local unit u = GetEnumUnit()
local unit uu = LoadUnitHandle(HundredSlash, id, 1)
local integer count = LoadInteger(HundredSlash, id, 3)
if count <= 40 then
call SetUnitAnimation(u, "attack")
call DestroyEffect(AddSpecialEffectTarget(EFFECT_C, uu, ATTACHMENT))
else
call DestroyEffect(AddSpecialEffect(EFFECT_A, GetUnitX(u), GetUnitY(u)))
call RemoveUnit(u)
endif
set u = null
set uu = null
endfunction
private function Loop takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local unit u = LoadUnitHandle(HundredSlash, id, 0)
local unit uu = LoadUnitHandle(HundredSlash, id, 1)
local group g = LoadGroupHandle(HundredSlash, id, 2)
local integer count = LoadInteger(HundredSlash, id, 3)
local unit uuu
call ForGroup(g, function Callback)
if count > 40 then
call DestroyEffect(AddSpecialEffect(EFFECT_A, GetUnitX(u), GetUnitY(u)))
call ShowUnit(u, true)
if GetLocalPlayer() == GetOwningPlayer(u) then
call SelectUnit(u, true)
endif
call SetUnitInvulnerable(u, false)
call SetUnitInvulnerable(uu, false)
call PauseUnit(uu, false)
call DestroyEffect(AddSpecialEffect(EFFECT_B, GetUnitX(uu), GetUnitY(uu)))
call UnitDamageTarget(u, uu, Damage(GetUnitAbilityLevel(u, ABILITY)), false, false, ATTACKTYPE, DAMAGETYPE, WEAPONTYPE)
call PauseTimer(t)
call DestroyTimer(t)
call DestroyGroup(g)
call FlushChildHashtable(HundredSlash, id)
endif
call SaveInteger(HundredSlash, id, 3, count + 1)
set t = null
set u = null
set uu = null
set g = null
endfunction
private function Actions takes nothing returns nothing
local timer t = CreateTimer()
local integer id = GetHandleId(t)
local unit u = GetTriggerUnit()
local unit uu = GetSpellTargetUnit()
local real x = GetUnitX(uu)
local real y = GetUnitY(uu)
local group g = CreateGroup()
local integer i = 0
local real angle = 1.257
local real xx
local real yy
local unit uuu
call DestroyEffect(AddSpecialEffect(EFFECT_A, GetUnitX(u), GetUnitY(u)))
call PauseUnit(uu, true)
call SetUnitInvulnerable(uu, true)
call SetUnitInvulnerable(u, true)
call ShowUnit(u, false)
loop
exitwhen i == 5
set i = i + 1
set xx = x + 150 * Cos(angle)
set yy = y + 150 * Sin(angle)
call DestroyEffect(AddSpecialEffect(EFFECT_A, xx, yy))
set uuu = CreateUnit(GetOwningPlayer(u), DUMMY, xx, yy, bj_RADTODEG * Atan2(y - yy, x - xx))
call SetUnitTimeScale(uuu, 5.0)
call GroupAddUnit(g, uuu)
set angle = angle + 1.257
set uuu = null
endloop
call SaveUnitHandle(HundredSlash, id, 0, u)
call SaveUnitHandle(HundredSlash, id, 1, uu)
call SaveGroupHandle(HundredSlash, id, 2, g)
call SaveInteger(HundredSlash, id, 3, 0)
call TimerStart(t, 0.10, true, function Loop)
set t = null
set u = null
set uu = null
set g = null
endfunction
private function Conditions takes nothing returns boolean
if GetSpellAbilityId() == ABILITY then
call Actions()
endif
return false
endfunction
//===========================================================================
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function Conditions ) )
set t = null
endfunction
endscope