BRUTAL
I'm working
- Reaction score
- 118
Shadow Rush
Requires AIDS, Damage, Event, GTrigger, Key Timers 2; all included in the map.
Spell Description: Kael releases his shadow, which rushes at a targeted unit. Dashing through the target stealing part of its soul; damaging the target. At that precise moment, Kael is able to quickly teleport to the position of his shadow. His shadow can only be exposed to sun for so long, if a unit can evade the shadow long enough during day, the shadow will disappear.
Code:
Feedback is welcomed, if you see any bugs or mistakes let me know.
Shadow Rush v2.4b is the GUI version.
Requires AIDS, Damage, Event, GTrigger, Key Timers 2; all included in the map.
Spell Description: Kael releases his shadow, which rushes at a targeted unit. Dashing through the target stealing part of its soul; damaging the target. At that precise moment, Kael is able to quickly teleport to the position of his shadow. His shadow can only be exposed to sun for so long, if a unit can evade the shadow long enough during day, the shadow will disappear.
Code:
JASS:
// Shadow Rush by BRUTAL.
// Requires AIDS, Damage, Event, GT, and KT2.
// Credits are welcome but not necessary.
// June 30th 2010.
scope ShadowRush initializer Init
globals
private constant integer ID=039;A000039; // ID of the shadow rush spell.
private constant integer DUMMY_ID=039;h000039; // ID of the dummy rushing unit.
private constant integer FADE=8 // The interval for fading out the dummy.
private constant integer TRANSPAR=80 // Percent transparency the dummy has initially.
private constant real PERIOD=.02 // Period of KT2.
private constant real SPEED=1000. // The rushing speed.
private constant real FADE_TIME=.6 // The time after damage that the dummy rushing unit can still move for.
private constant real AOE_DIS=100. // The minimal range from the target to the dummy rushing unit to activate damage.
private constant string SOUND="Abilities\\Spells\\Items\\OrbCorruption\\OrbOfCorruptionMissile.wav"
// Path of the sound played when the dummy is rushing the target.
private constant integer SOUND_VOL=127 // The volume of the sound played.
private constant string SFX="Abilities\\Spells\\Other\\Silence\\SilenceAreaBirth.mdl"
// Path of the sfx created on the target on impact.
private constant string SFX2="Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
// Path of the blood sfx created on the target on impact.
private constant string SFX3="Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
// Path of the blink sfx that is created at the hero's position when it teleports.
private integer filter
endglobals
private function DAMAGE takes integer level, unit u returns real
return 80.*level+2.*I2R(GetHeroAgi(u,true))
endfunction
private function Text takes unit u, real damage returns nothing
local texttag tt=CreateTextTag() // This creates floating text.
if u!=null then
call SetTextTagText(tt,I2S(R2I(damage)),.023)
call SetTextTagPosUnit(tt,u,-125)
call SetTextTagColor(tt,255,0,0,255)
call SetTextTagPermanent(tt,false)
call SetTextTagVelocity(tt,0,.044)
call SetTextTagLifespan(tt,3)
call SetTextTagFadepoint(tt,2)
else
call DestroyTextTag(tt)
endif
set tt=null
endfunction
private struct Data
unit caster
unit target
unit dummy
real x
real y
real angle
real transpar=255*(I2R(TRANSPAR)/100)
integer ticks
boolean damaged=false
static method Create takes unit u, unit t, real tx, real ty returns Data
local Data d=Data.allocate()
local sound s
local real dx
local real dy
set d.caster=u
set d.target=t
set d.x=GetUnitX(u)
set d.y=GetUnitY(u)
set dx=tx-d.x
set dy=ty-d.y
set d.angle=Atan2(dy,dx)
set d.dummy=CreateUnit(GetOwningPlayer(d.caster),DUMMY_ID,d.x,d.y,d.angle/.0175)
call SetUnitVertexColor(d.dummy,0,0,0,R2I(d.transpar))
call SetUnitTimeScale(d.dummy,2)
call SetUnitAnimationByIndex(d.dummy,2)
set s=CreateSound(SOUND,false,false,false,10,10,"")
call StartSound(s)
call SetSoundVolume(s,SOUND_VOL)
call AttachSoundToUnit(s,d.dummy)
call KillSoundWhenDone(s)
set s=null
set d.ticks=R2I(SquareRoot(dx*dx+dy*dy)/(SPEED*PERIOD))
return d
endmethod
method Rush takes nothing returns nothing
local real dmg=DAMAGE(GetUnitAbilityLevel(.caster,ID),.caster)
local real x=GetUnitX(.dummy)
local real y=GetUnitY(.dummy)
local real tx=GetUnitX(.target)
local real ty=GetUnitY(.target)
if not .damaged then
if (tx-x)*(tx-x)+(ty-y)*(ty-y)<=AOE_DIS*AOE_DIS then
set .damaged=true
set .ticks=R2I(FADE_TIME/PERIOD)
call DestroyEffect(AddSpecialEffectTarget(SFX,.target,"origin"))
call DestroyEffect(AddSpecialEffectTarget(SFX2,.target,"origin"))
call DestroyEffect(AddSpecialEffect(SFX,GetUnitX(.caster),GetUnitY(.caster)))
call SetUnitX(.caster,.x)
call SetUnitY(.caster,.y)
call Text(.target,dmg)
call Damage_Spell(.caster,.target,dmg)
else
set .angle=Atan2(ty-y,tx-x)
endif
else
set .transpar=.transpar-FADE
call SetUnitVertexColor(.dummy,0,0,0,R2I(.transpar))
endif
set .x=.x+(SPEED*PERIOD)*Cos(.angle)
set .y=.y+(SPEED*PERIOD)*Sin(.angle)
call SetUnitX(.dummy,.x)
call SetUnitY(.dummy,.y)
endmethod
endstruct
private function PeriodicFunc takes nothing returns boolean
local Data d=KT_GetData()
set d.ticks=d.ticks-1
if d.ticks<=0 then
call RemoveUnit(d.dummy)
call d.destroy()
return true
endif
call d.Rush()
return false
endfunction
private function Actions takes nothing returns nothing
call KT_Add(function PeriodicFunc,Data.Create(GetTriggerUnit(),GetSpellTargetUnit(),GetSpellTargetX(),GetSpellTargetY()),PERIOD)
endfunction
private function Init takes nothing returns nothing
call TriggerAddAction(GT_RegisterStartsEffectEvent(CreateTrigger(),ID),function Actions)
endfunction
endscope
Feedback is welcomed, if you see any bugs or mistakes let me know.
Shadow Rush v2.4b is the GUI version.