Spell Shadow Rush

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.

sr1pq7.jpg


sr2rs3.jpg


sr3jg9.jpg



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='A000' // ID of the shadow rush spell.
    private constant integer DUMMY_ID='h000' // 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.
 

Attachments

  • Shadow Rush v2.4b.w3x
    47.9 KB · Views: 467
  • Shadow Rush vJass.w3x
    87.1 KB · Views: 279

Kenny

Back for now.
Reaction score
202
Haha, man, i was just in the process of making a spell exactly like this... except for the night/day thing, but oh well. Anyway, this spell is very cool :) it looks exactly as i imagined it, good job. I think i remember seeing something similar to this on battle.net one day, maybe thats where i got the idea, but still, very cool.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
This:
Code:
        Custom script:   call SetUnitAnimationByIndex(udg_DRDummy[udg_CV], 2)

Doesn't work too well... If you have a footman or something, it won't play the animation... What if 2 was a stand animation. :rolleyes: You should probably either set a configurable global variable or just use the regular set unit animation.

Still, good job on the spell. Nice coding. A lot of triggers tho. :p
 

Flare

Stops copies me!
Reaction score
662
Looks awesome from the screenshots :D It's not MUI in your third trigger since you are only referring to unit[CV]. and its only one timer that expires, so timers may overlap and you have know what of determining which spell instance started the timer :p

you could add the damage actions to your periodic trigger when DRDist <= 35. Would keep the spell MUI, but may have slight impact on the visuals (since damage and text would be appearing 0.1 seconds earlier than with the timer)
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Each time I test this spell it says:
"double free of location in Trig_Rush_FuncA001A" ;s
 

BRUTAL

I'm working
Reaction score
118
Haha, man, i was just in the process of making a spell exactly like this... except for the night/day thing, but oh well. Anyway, this spell is very cool it looks exactly as i imagined it, good job. I think i remember seeing something similar to this on battle.net one day, maybe thats where i got the idea, but still, very cool.

lol really? XD

This:

Code:
Custom script: call SetUnitAnimationByIndex(udg_DRDummy[udg_CV], 2)Doesn't work too well... If you have a footman or something, it won't play the animation... What if 2 was a stand animation. You should probably either set a configurable global variable or just use the regular set unit animation.

Still, good job on the spell. Nice coding. A lot of triggers tho.

ya i knew that, but you could just do this
You could use the "SetUnitAnimationByIndex" function.
But first, you will need to find which value plays the animation you want.
A simple method like so will display each index value from 1 to 15 over 30 seconds for some unit:

Code:
Actions
Set My_Unit = <your unit>
For Each (Integer A) from 1 to 15 do (Loop Actions)
Loop - Actions
Custom script: call SetUnitAnimationByIndex(udg_My_Unit, bj_forLoopAIndex)
Game - Display to (All Players) the text: (Integer(Integer A))
Wait 2.00 seconds

maybe i can put that trigger in so you can test the dummy unit your using and see what animation is what number, so it can be easiy changed :p

Looks awesome from the screenshots It's not MUI in your third trigger since you are only referring to unit[CV]. and its only one timer that expires, so timers may overlap and you have know what of determining which spell instance started the timer

you could add the damage actions to your periodic trigger when DRDist <= 35. Would keep the spell MUI, but may have slight impact on the visuals (since damage and text would be appearing 0.1 seconds earlier than with the timer)

ty :), o crap T_T lol well i'll try to fix that then
eh, i tried doing that but, it was complicated, didnt work as well :p

Each time I test this spell it says:
"double free of location in Trig_Rush_FuncA001A" ;s

can you post a screeny or something?

awesome spell
+rep

ty :)

Update*
Added in instructions for figuring out what number is the dummy unit's running animation(only if you use a different model) and changing the Dummy unit's animation, if you want a different animation:
Changing the unit "dummy"'s animation while rushing:
---------------------------------------------------

You could use the "SetUnitAnimationByIndex" function.
But first, you will need to find which value plays the animation you want.
A simple method like so will display each index value from 1 to 15 over 30 seconds for some unit

example trigger bellow:

Actions
Set My_Unit = <your unit>
For Each (Integer A) from 1 to 15 do (Loop Actions)
Loop - Actions
Custom script: call SetUnitAnimationByIndex(udg_My_Unit, bj_forLoopAIndex)
Game - Display to (All Players) the text: (Integer(Integer A))
Wait 2.00 seconds

the game will show numbers, then it will play all the units animations
so when you see the unit running or whatever animation you desire for using
for the dummy unit, use the corresponding number and put it into this
"Custom script: call SetUnitAnimationByIndex(udg_My_Unit, bj_forLoopAIndex)"
=================
example:
--------

Custom script: call SetUnitAnimationByIndex(udg_My_Unit, 6)
 

BRUTAL

I'm working
Reaction score
118
ty mr.tutorial

and im pretty sure its mui now, i changed the damage trigger and tested it!\
added a second kael, to test the MUIness easier :p
 

BRUTAL

I'm working
Reaction score
118
o >.>
must have forgot to add in a if/then/else
i thoguht i alrdy did :rolleyes:

okay, updated with working day/night thing
 

Flare

Stops copies me!
Reaction score
662
It needs to be in a .zip with a readme attached to be approved. Also, include some screenshots of the spell in action :thup:

Ahm... that's for models and textures... you can submit the spell map directly (without zipping it). Have you seen any approved spells in .zip? Because I haven't :p And the screenshots are there (between Spell Description and Triggers)

Taken from How to Correctly Submit a Resource
(Systems and spells do not have to be compressed to .zip)

These are Tinki3's spell approval guidelines (hopefully they are still the same :p)
When all conditions are true:
- Code is leakless
- Code is decently optimised
- <Spell> comes with implementation instructions
- <Spell's> tooltips are up-to-scratch
- <Spell> does not lag too much
- <Spell> has to fully work, and must not "bug" at anytime

EDIT: Wait... who said anything about approval? Just because he is hoping a mod will take a look doesn't mean he is implying approval (probable, but not certain :p)
 

BRUTAL

I'm working
Reaction score
118
how did you miss the screenshots? they are there,
but i think theyre like messed up cause theyre not loading for me now :p, i'll fix them, but i lost one screenshot :p

lol
guess its not that good :p

anyways, updated map, fixed a small problemish thing
 

Tinki3

Special Member
Reaction score
418
Let's go over the periodic trigger.

Newgen gave me (a lot of) "double free of location" errors when the spell was cast.
So your custom script actions for removing leaks are not in the correct places.

Also, some variables were being overwritten, which were also causing leaks, and were not required to be re-set anyway.

I have uploaded the fixed map to filefront, so you can compare the two triggers and sort out what's changed:
http://dodownload.filefront.com/102...3787f71954d1876df36b276e5fc05876151dee5472f2f
 

BRUTAL

I'm working
Reaction score
118
i dont have newgen :p
ya, im not that good with removing leaks when theres alot of variables and meh
leak checker said it was fine :eek:
o i see what you mean now :p

..
so do i just copy what you put and upload? :p
-------------------------------------------------
updated map on first post
credits to tinki3 :p
 

Magoiche

Member
Reaction score
20
Good Work!

You can make the Dummy Shadow Unit have the Model of Lycanthrope in dota(i forgot his name in WC3 xD).
In all back him will be like a shadow =D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top