Spell Summon Treant

BRUTAL

I'm working
Reaction score
118
Summon Treant

Requires GTrigger, Key Timers 2; all included in the map.

Spell Description: Summon the Treant of Evisceration from nature's inertly evil energy.

Screen Shots:
st1rv.jpg
st2ha.jpg

st3v.jpg
st4w.jpg

Code:
JASS:
// Summon Treant by BRUTAL.
// Requires GT, and KT2.
// Credits are welcome but not necessary.
// June 30th, 2010.

scope SummonTreant initializer init

globals
    private constant integer ID                 ='A000'  // ID of the spell.
    
    private constant integer DUMMY_BEAM         = 'h005'    // ID of the beam unit.
    private constant boolean BEAM_ON            = true      // Whether you want the beam effect on.
    private constant integer BEAM_RED           = 0         // Red value of the beam unit.
    private constant integer BEAM_GREEN         = 255       // Green value of the beam unit.
    private constant integer BEAM_BLUE          = 0         // Blue value of the beam unit.
    private constant integer BEAM_ALPHA         = 255       // Alpha value of the beam unit
    private constant real    BEAM_SCALE         = 1.        // Scaling size of the beam unit.
        
    private constant integer DUMMY_BIRD         = 'h001'    // ID of the bird unit.
    private constant boolean BIRD_ON            = true      // Whether you want the bird effect on.
    private constant integer BIRD_RED           = 255       // Red value of the bird unit.
    private constant integer BIRD_GREEN         = 255       // Green value of the bird unit.
    private constant integer BIRD_BLUE          = 255       // Blue value of the bird unit.
    private constant integer BIRD_ALPHA         = 255       // Alpha value of the bird unit.
    private constant real    BIRD_SCALE         = 1.        // Scaling size of the bird unit. 
    private constant real    BIRD_TLIFE         = 6.        // Timed life of the birds.
    private constant real    BIRD_OFFSET        = 200.      // Offset distance of the birds.
    private constant real    BIRD_HEIGHT        = 4.        // The interval for increasing flying height.
        
    private constant integer DUMMY_EXPLO        = 'h004'    // ID of the explosion unit.
    private constant boolean EXPLO_ON           = true      // Whether you want the explosion effect on.
    private constant integer EXPLO_RED          = 0         // Red value of the explosion unit.
    private constant integer EXPLO_GREEN        = 255       // Green value of the explosion unit.
    private constant integer EXPLO_BLUE         = 75        // Blue value of the explosion unit.
    private constant integer EXPLO_ALPHA        = 155       // Alpha value of the explosion unit.
    private constant real    EXPLO_SCALE        = 2.        // Scaling size of the explosion unit.
		
    private constant integer DUMMY_GREEN        = 'h006'    // ID of the green ball unit.
    private constant boolean GREEN_ON           = true      // Whether you want the green ball effect on.
    private constant integer GREEN_RED          = 255       // Red value of the green ball unit.
    private constant integer GREEN_GREEN        = 255       // Green value of the green ball unit.
    private constant integer GREEN_BLUE         = 255       // Blue value of the green ball unit.
    private constant integer GREEN_ALPHA        = 255       // Aplha value of the green ball unit.
    private constant real    GREEN_SCALE        = .75       // Scaling size of the green ball unit.
    private constant real    GREEN_MSPEED       = 100.      // Movement speed of the green ball unit.
		
    private constant integer DUMMY_LEAF         = 'h007'    // ID of the leaf unit.
    private constant boolean LEAF_ON            = true      // Whether you want the leaf effect on.
    private constant real    LEAF_SCALE         = 1.        // Scaling size of the leaf unit.
        
    private constant integer DUMMY_SPAWN        = 'h000'    // ID of the spawning effect unit.
    private constant boolean SPAWN_ON           = true      // Whether you want the spawning effect on.
    private constant integer SPAWN_RED          = 255       // Red value of the spawning effect unit.
    private constant integer SPAWN_GREEN        = 255       // Green value of the spawning effect unit.
    private constant integer SPAWN_BLUE         = 255       // Blue value of the spawning effect unit.
    private constant integer SPAWN_ALPHA        = 255       // Alpha value of the spawning effect unit.
    private constant real    SPAWN_SCALE        = 1.        // Scalaing size of the spawning effect unit.
    private constant integer SPAWN_NUM          = 5         // Amount of spawning effect units created on summon.
    private constant real    SPAWN_OFFSET       = 200.      // Offset of the spawning effect unit.
		
    private constant integer DUMMY_SPIN         = 'h003'    // ID of the spin dummy unit.
    private constant boolean SPIN_ON            = true      // Whether you want the spinning effect on.
    private constant integer SPIN_RED           = 255       // Red value of the spin dummy unit.
    private constant integer SPIN_GREEN         = 255       // Green value of the spin dummy unit.
    private constant integer SPIN_BLUE          = 255       // Blue value of the spin dummy unit.
    private constant real    SPIN_SCALE         = .85       // Scaling value of the spin dummy unit.
    private constant real    SPIN_OFFSET        = 250.      // Starting offset of the inward spinning.
    private constant real    SPIN_TLIFE         = 1.        // Timed life of the spin dummy unit.
        
    private constant integer SPAWNED_UNIT       = 'e000'    // ID of the spawned unit.
    private constant integer SPAWNED_UNIT_RED   = 255       // Red value of the spawned unit.
    private constant integer SPAWNED_UNIT_GREEN = 255       // Green value of the spawned unit.
    private constant integer SPAWNED_UNIT_BLUE  = 255       // Blue value of the spawned unit.
    private constant integer SPAWNED_UNIT_ALPHA = 255       // Alpha value of the spawned unit.
    private constant real    SPAWNED_UNIT_SCALE = 1.        // Scaling value of the spawned unit.
    private constant real    SPAWNED_UNIT_TLIFE = 60.       // Timed life of the spawned unit.
		
    private constant boolean RIPPLE_ON          = true      // Whether you want the ripple effect on.
    private constant real RIPPLE_TIME        = 3.        // Time length of the ripple.
    private constant real RIPPLE_S_RADIUS       = 50.       // Starting radius of the ripple.
    private constant real RIPPLE_E_RADIUS       = 300.      // Ending radius of the ripple.
    private constant real RIPPLE_DEPTH          = 64.       // Depth of the ripple.
    private constant real RIPPLE_SEQ            = 1.        // Time between each ripple.
    private constant real RIPPLE_SEQ_SPACE      = 50.       // Space between each ripple.
    
    private constant string SPAWN_SOUND         = "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaos.wav"
    // Sound played during spawn effects.
    private constant boolean SPAWN_SOUND_ON     = true      // Enable or disable the sound during the spawning effects.
    private constant integer SPAWN_SOUND_VOL    = 100       // Volume of the sound during the spawning effects. 
    // Recommended that this is lower then SUM_SOUND_VOL so that both sounds can be heard.
    
    private constant string SUM_SOUND           = "Abilities\\Spells\\Human\\Banish\\BanishLoop1.wav"
    // Background sound played during the summon.
    private constant boolean SUM_SOUND_ON       = true      // Enable or disable the sound during summon.
    private constant integer SUM_SOUND_VOL    = 127         // Volume of the sound during summon. 
    
    private constant string  EXPLO_SOUND        = "Units\\NightElf\\Ent\\ForceOfNatureBirth1.wav"
    // Sound played during the explosion effect.
    private constant boolean EXPLO_SOUND_ON     = true      // Enable or disable the sound during the explosion effect.
    private constant integer EXPLO_SOUND_VOL    = 127       // Volume of the sound during the explosion effect. 
    
    private constant string  SFX_BLINK          = "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"
    // Path of the blink sfx that occurs on cast to signify where birds will spawn from.

    private constant real    PERIOD             = .02       // Period of the KT2 timer.
    // Configurable time options, measured in seconds.

    private constant real    MAX_TIME           = 7.        // Max time of the spell in seconds.
    // Extra time past SUM_TIME is to account for the birds still visible on screen, to fly more
    
    private constant real    SUM_TIME           = 5.        // Amount of time that it takes to summon the unit.
    private constant real    SUM_SOUND_TIME_ST  = 0         // Amount of time into the summen when SUM_SOUND begins playing.
    private constant real    SUM_SOUND_TIME_END = 4.6       // Amount of time into the summon when SUM_SOUND is no longer played.
	
    private constant real    BIRD_START         = .6        // Time into the summon when birds spawn.
    private constant real    BIRD_END           = 2.5       // Time into the summon when birds stop spawning.
    
    private constant real    GREEN_START        = 0.        // Time into the summon when green ball effect spawns.
    private constant real    GREEN_END          = 3.        // Time into the summon when the green ball effect stop spawning.
    
    private constant real    LEAF_START         = 0.        // Time into the summon when leaves fly up.
    private constant real    LEAF_END           = SUM_TIME  // Time into the summon when leaves stop flying up.
   
    private constant real    SPIN_START         = 1         // Time into the summon when the dummys spin inward.
    private constant real    SPIN_END           = SUM_TIME  // Time into the summon when the spinning is done.

    private          integer filter
endglobals

private function Sound takes unit u returns nothing
    local sound s=CreateSound(SPAWN_SOUND,false,false,false,10,10,"")
    call StartSound(s)
    call AttachSoundToUnit(s,u)
    call SetSoundVolume(s,SPAWN_SOUND_VOL)
    call KillSoundWhenDone(s)
    set s=null
endfunction

private struct Data
    unit caster
    unit spawnEffect
    unit array bird[100]
    player p
    real x
    real y
    real angle
    integer array birdAlpha[100]
    group birds=CreateGroup()
    integer birdIndex=0
    real birdTimer=0
    real greenFloatTimer=0
    real leafTimer=0
    real spawnGrowth=1
    real spawnTimer=0
    real spawnAlpha=0
    real spinAngle=0
    real spinDistance=SPIN_OFFSET
    real spinTimer=0
    sound array sumSound[10]
    real sumSoundTimer=0
    real array sumSoundVol[10]
    integer ticks=R2I(MAX_TIME/PERIOD)
    integer maxTicks=.ticks
    
    static method Create takes unit u, real tx, real ty returns Data
        local Data d=Data.allocate()
        local integer i=1
        local unit dummy
        set d.caster=u
        set d.p=GetOwningPlayer(u)
        set d.x=tx
        set d.y=ty
        set d.angle=bj_DEGTORAD*(GetUnitFacing(u)+90)
        static if BEAM_ON then
            set dummy=CreateUnit(d.p,DUMMY_BEAM,tx,ty,0)
            call SetUnitVertexColor(dummy,BEAM_RED,BEAM_GREEN,BEAM_BLUE,BEAM_ALPHA)
            call SetUnitScale(dummy,BEAM_SCALE,0,0)
            call UnitApplyTimedLife(dummy,'BTLF',SUM_TIME)
        endif
        static if SPAWN_ON then
            set d.spawnEffect=CreateUnit(d.p,DUMMY_SPAWN,tx,ty,0)
            call SetUnitVertexColor(d.spawnEffect,SPAWN_RED,SPAWN_GREEN,SPAWN_BLUE,SPAWN_ALPHA)
            call SetUnitScale(d.spawnEffect,SPAWN_SCALE,0,0)
            static if SPAWN_SOUND_ON then
                call Sound(d.spawnEffect)
            endif
        endif
        static if SUM_SOUND_ON then
            loop
            exitwhen i>10
                set d.sumSound<i>=CreateSound(SUM_SOUND,false,false,false,10,10,&quot;&quot;)
                set d.sumSoundVol<i>=SUM_SOUND_VOL
                call StartSound(d.sumSound<i>)
                call AttachSoundToUnit(d.sumSound<i>,d.spawnEffect)
                call SetSoundVolume(d.sumSound<i>,SUM_SOUND_VOL)
                call KillSoundWhenDone(d.sumSound<i>)
                set i=i+1
            endloop
        endif
        call DestroyEffect(AddSpecialEffect(SFX_BLINK,tx+BIRD_OFFSET*Cos(d.angle),ty+BIRD_OFFSET*Sin(d.angle)))
        set dummy=null
        return d
    endmethod
    
    static method BirdSpin takes nothing returns nothing
        local Data d=Data(filter)
        local unit u=GetEnumUnit()
        local real x=GetUnitX(u)
        local real y=GetUnitY(u)
        local real angle=Atan2(y-d.y,x-d.x)
        local real x2=d.x+BIRD_OFFSET*Cos(angle+.087)
        local real y2=d.y+BIRD_OFFSET*Sin(angle+.087)
        call SetUnitX(u,x2)
        call SetUnitY(u,y2)
        set x=d.x+BIRD_OFFSET*Cos(angle+.105)
        set y=d.y+BIRD_OFFSET*Sin(angle+.105)
        call SetUnitFacing(u,Atan2(y-y2,x-x2)/.0175)
        call SetUnitFlyHeight(u,GetUnitFlyHeight(u)+BIRD_HEIGHT,0)
        set u=null
    endmethod
    
    method Summon takes nothing returns nothing
        local sound s
        local integer i=0
        local real angle
        local real x
        local real y
        local real x2
        local real y2
        local unit d
        set filter=this
        if .ticks==.maxTicks-SUM_TIME/PERIOD then
            static if RIPPLE_ON then
                call TerrainDeformRipple(.x,.y,RIPPLE_E_RADIUS,RIPPLE_DEPTH,R2I(RIPPLE_TIME)*1000,1,2.*RIPPLE_E_RADIUS/RIPPLE_SEQ_SPACE,2.*RIPPLE_TIME/RIPPLE_SEQ,RIPPLE_S_RADIUS/RIPPLE_E_RADIUS,false)
            endif
            static if EXPLO_ON then
                set d=CreateUnit(.p,DUMMY_EXPLO,.x,.y,0)
                call SetUnitVertexColor(d,EXPLO_RED,EXPLO_GREEN,EXPLO_BLUE,EXPLO_ALPHA)
                call SetUnitScale(d,EXPLO_SCALE,0,0)
            endif
            static if EXPLO_SOUND_ON then
                set s=CreateSound(EXPLO_SOUND,false,false,false,10,10,&quot;&quot;)
                call StartSound(s)
                call AttachSoundToUnit(s,d)
                call SetSoundVolume(s,EXPLO_SOUND_VOL)
                call KillSoundWhenDone(s)
            endif
            static if SPAWN_ON then
                loop
                exitwhen i&gt;SPAWN_NUM-1
                    set x=.x+SPAWN_OFFSET*Cos(i*1.26)
                    set y=.y+SPAWN_OFFSET*Sin(i*1.26)
                    set d=CreateUnit(.p,DUMMY_SPAWN,x,y,0)
                    call SetUnitVertexColor(d,SPAWN_RED,SPAWN_GREEN,SPAWN_BLUE,SPAWN_ALPHA)
                    call SetUnitScale(d,SPAWN_SCALE,0,0)
                    call UnitApplyTimedLife(d,&#039;BTLF&#039;,.75)
                    static if SPAWN_SOUND_ON then
                        call Sound(d)
                    endif
                    set i=i+1
                endloop
            endif
            call RemoveUnit(.spawnEffect)
            set d=CreateUnit(.p,SPAWNED_UNIT,.x,.y,.angle/.0175-90)
            call SetUnitVertexColor(d,SPAWNED_UNIT_RED,SPAWNED_UNIT_GREEN,SPAWNED_UNIT_BLUE,SPAWNED_UNIT_ALPHA)
            call SetUnitScale(d,SPAWNED_UNIT_SCALE,0,0)
            call UnitApplyTimedLife(d,&#039;BTLF&#039;,SPAWNED_UNIT_TLIFE)
            call SetUnitAnimation(d,&quot;birth&quot; )
            call QueueUnitAnimation(d,&quot;stand&quot;)
        endif
        static if SUM_SOUND_ON then
            if .sumSoundTimer==1.5 and .ticks&lt;=.maxTicks-SUM_SOUND_TIME_ST/PERIOD and .ticks&gt;.maxTicks-SUM_SOUND_TIME_END/PERIOD then
                set i=0
                loop
                exitwhen i&gt;10
                    set .sumSound<i>=CreateSound(SUM_SOUND,false,false,false,10,10,&quot;&quot;)
                    call StartSound(.sumSound<i>)
                    call AttachSoundToUnit(.sumSound<i>,.spawnEffect)
                    call SetSoundVolume(.sumSound<i>,SUM_SOUND_VOL)
                    call KillSoundWhenDone(.sumSound<i>)
                    set i=i+1
                endloop
                set .sumSoundTimer=0
            else
                set .sumSoundTimer=.sumSoundTimer+PERIOD
            endif
            if .ticks&lt;.maxTicks-220 then
                set i=0
                loop
                exitwhen i&gt;4
                    set .sumSoundVol<i>=.sumSoundVol<i>-1
                    call SetSoundVolume(.sumSound<i>,R2I(.sumSoundVol<i>))
                    set i=i+1
                endloop
            endif
        endif
        static if GREEN_ON then 
            if .ticks&lt;.maxTicks-GREEN_START/PERIOD and .ticks&gt;=.maxTicks-GREEN_END/PERIOD and .greenFloatTimer&gt;=25*PERIOD then
                set i=0
                loop
                exitwhen i&gt;4
                    set x2=GetRandomInt(250,400)
                    set angle=GetRandomReal(0,6.283)
                    set x=.x+x2*Cos(angle)
                    set y=.y+x2*Sin(angle)
                    set d=CreateUnit(.p,DUMMY_GREEN,x,y,0)
                    call SetUnitVertexColor(d,GREEN_RED,GREEN_GREEN,GREEN_BLUE,GREEN_ALPHA)
                    call SetUnitScale(d,GREEN_SCALE,0,0)
                    call SetUnitMoveSpeed(d,GREEN_MSPEED)
                    call UnitApplyTimedLife(d,&#039;BTLF&#039;,(.ticks-100)*PERIOD)
                    call IssuePointOrder(d,&quot;move&quot;,.x,.y)
                    set i=i+1
                endloop
                set .greenFloatTimer=0
            else
                set .greenFloatTimer=.greenFloatTimer+PERIOD
            endif
        endif
        static if SPAWN_ON then
            if .ticks&gt;=.maxTicks-SUM_TIME/PERIOD and .spawnTimer&gt;=50*PERIOD then
                call Sound(.spawnEffect)
                set .spawnGrowth=.spawnGrowth+.25
                call SetUnitScale(.spawnEffect,.spawnGrowth,.spawnGrowth,.spawnGrowth)
                call SetUnitAnimation(.spawnEffect,&quot;birth&quot;)
                set .spawnTimer=0
            else
                set .spawnTimer=.spawnTimer+PERIOD
            endif
        endif
        static if SPIN_ON then 
            if .ticks&gt;.maxTicks-(SPIN_END/PERIOD-40) and .ticks&lt;.maxTicks-SPIN_START/PERIOD then
                if .spinTimer==3*PERIOD then
                    set i=0
                    loop
                    exitwhen i&gt;2
                        set x=.x+.spinDistance*Cos(.angle+.spinAngle+2.1*i)
                        set y=.y+.spinDistance*Sin(.angle+.spinAngle+2.1*i)
                        set x2=.x+.spinDistance*Cos(.angle+.spinAngle+(2.1*i)+.0175)
                        set y2=.y+.spinDistance*Sin(.angle+.spinAngle+(2.1*i)+.0175)
                        set angle=Atan2(y2-y,x2-x)
                        set d=CreateUnit(.p,DUMMY_SPIN,x,y,angle/.0175)
                        call SetUnitVertexColor(d,SPIN_RED,SPIN_GREEN,SPIN_BLUE,0)
                        call SetUnitScale(d,SPIN_SCALE,0,0)
                        call UnitApplyTimedLife(d,&#039;BTLF&#039;,SPIN_TLIFE)
                        call SetUnitTimeScale(d,0)
                        call SetUnitVertexColor(d,255,255,255,R2I(.spawnAlpha))
                        set i=i+1
                    endloop
                    set .spinTimer=0
                else
                    set .spinTimer=.spinTimer+PERIOD
                endif
                if .spawnAlpha&lt;=255 then
                    set .spawnAlpha=.spawnAlpha+.3825
                endif
                set .spinAngle=.spinAngle+.035
                set .spinDistance=.spinDistance-1.5
            endif
        endif
        static if BIRD_ON then
            set i=0
            loop
            exitwhen i==.birdIndex
                set .birdAlpha<i>=.birdAlpha<i>-1
                call SetUnitVertexColor(.bird<i>,BIRD_RED,BIRD_GREEN,BIRD_BLUE,.birdAlpha<i>)
                set i=i+1
            endloop
            if  .ticks&lt;.maxTicks-BIRD_START/PERIOD and .ticks&gt;.maxTicks-BIRD_END/PERIOD then
                if .birdTimer==3*PERIOD then
                    set x=.x+BIRD_OFFSET*Cos(.angle)
                    set y=.y+BIRD_OFFSET*Sin(.angle)
                    set x2=.x+BIRD_OFFSET*Cos(.angle+.0175)
                    set y2=.y+BIRD_OFFSET*Sin(.angle+.0175)
                    set angle=Atan2(y2-y,x2-x)
                    set d=CreateUnit(.p,DUMMY_BIRD,x,y,angle/.0175)
                    set .bird[.birdIndex]=d
                    set .birdAlpha[.birdIndex]=BIRD_ALPHA
                    set .birdIndex=.birdIndex+1
                    call SetUnitVertexColor(d,BIRD_RED,BIRD_GREEN,BIRD_BLUE,BIRD_ALPHA)
                    call SetUnitScale(d,BIRD_SCALE,0,0)
                    call UnitApplyTimedLife(d,&#039;BTLF&#039;,BIRD_TLIFE)
                    call GroupAddUnit(.birds,d)
                    call UnitAddAbility(d,&#039;Amrf&#039;)
                    set .birdTimer=0
                else
                    set .birdTimer=.birdTimer+PERIOD
                endif
            endif
            call ForGroup(.birds,function Data.BirdSpin)
        endif
        static if LEAF_ON then 
            if .leafTimer==15*PERIOD and .ticks&lt;.maxTicks-LEAF_START/PERIOD and .ticks&gt;.maxTicks-LEAF_END/PERIOD then
                set x2=GetRandomReal(0,150)
                set angle=GetRandomReal(0,6.283)
                set x=.x+x2*Cos(angle)
                set y=.y+x2*Sin(angle)
                set d=CreateUnit(.p,DUMMY_LEAF,x,y,GetRandomReal(0,150))
                call SetUnitScale(d,LEAF_SCALE,0,0)
                call SetUnitAnimationByIndex(d,3)
                call UnitApplyTimedLife(d,&#039;BTLF&#039;,2.5)
                set .leafTimer=0
            else
                set .leafTimer=.leafTimer+PERIOD
            endif
        endif
        set d=null
        set d=null
    endmethod
endstruct 

private function PeriodicFunc takes nothing returns boolean
    local Data d=KT_GetData()
    set d.ticks=d.ticks-1
    if d.ticks&lt;=0 then  
        call d.destroy()
        return true
    endif
    call d.Summon()
    return false 
endfunction 

private function Remove takes nothing returns nothing
    local integer i=GetUnitTypeId(GetTriggerUnit())
    if i==DUMMY_BEAM or i==DUMMY_BIRD or i==DUMMY_EXPLO or i==DUMMY_GREEN or i==DUMMY_LEAF or i==DUMMY_SPAWN or i==DUMMY_SPIN then
        call RemoveUnit(GetTriggerUnit())
    endif
endfunction

private function Actions takes nothing returns nothing
    call KT_Add(function PeriodicFunc,Data.Create(GetTriggerUnit(),GetSpellTargetX(),GetSpellTargetY()),PERIOD)
endfunction

private function init takes nothing returns nothing
    local trigger t=CreateTrigger()
    local sound s
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddAction(t,function Remove)
    call TriggerAddAction(GT_RegisterStartsEffectEvent(CreateTrigger(),ID),function Actions)
    set s=CreateSound(SUM_SOUND,false,false,false,10,10,&quot;&quot;)
    call StartSound(s)
    call SetSoundVolume(s,0)
    call KillSoundWhenDone(s)
    set s=CreateSound(SPAWN_SOUND,false,false,false,10,10,&quot;&quot;)
    call StartSound(s)
    call SetSoundVolume(s,0)
    call KillSoundWhenDone(s)
    set s=CreateSound(EXPLO_SOUND,false,false,false,10,10,&quot;&quot;)
    call StartSound(s)
    call SetSoundVolume(s,0)
    call KillSoundWhenDone(s)
    set s=null
endfunction

endscope</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


I tried to make it as customizable as possible. If there are other things that you think should be customizable, let me know.
Feedback is welcomed, if you see any bugs or mistakes let me know.
 

Attachments

  • Summon Treant.w3x
    73.1 KB · Views: 560

BlackRose

Forum User
Reaction score
239
Ok.

1) I've got a major problem with the globals section.. it's a giant mess. Inconsistent indenting. No spacing to categorise it (even just a bit). It's just a giant messy block right now.

2) Use [ljass]static if[/ljass] for constant booleans. Like SPAWN_ON and BEAM_ON.

I don't have much motivation to look it thorougly, since to me it's really messy. It's me. You can't really fix that. I'm picky. I prefer stuff like [ljass]call KillUnit( unit )[/ljass] to [ljass]call KillUnit(unit)[/ljass] (note the spacing between the brackets).

Anyways the spell looks good :) Didn't it come like 2nd or 1st or something for the Flash SFX contest?
 

BRUTAL

I'm working
Reaction score
118
Alright.
I figured the global block would get that, but it didn't really seem too messy for me. I'll space out certain chunks and hopefully make it more neat.
What is a static if? I've never heard of that (since I've been gone).
I prefer the no space between brackets because its not hard to read without spaces, but thats just me.
Thanks, yes it tied for first.
 

BlackRose

Forum User
Reaction score
239
A static if compiles only if it matches the boolean.... if it doesn't. It's not compiled. So it doesn't check for the if = efficiency I think?

like:

JASS:
globals
    constant boolean KILL_ENEMY = true
endglobals

static if KILL_ENEMY then
    call KillUnit( unit )
endif


[ljass]static if not KILL_ENEMY then[/ljass]
[ljass] call ShowUnit( unit, false )[/ljass]
[ljass]endif[/ljass]
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
looks neat, but I would prefer to use this for summoning some boss unit, not a treant :p
 

SanKakU

Member
Reaction score
21
Alright.
I figured the global block would get that, but it didn't really seem too messy for me. I'll space out certain chunks and hopefully make it more neat.
What is a static if? I've never heard of that (since I've been gone).
I prefer the no space between brackets because its not hard to read without spaces, but thats just me.
Thanks, yes it tied for first.

no, it's not just you. i dislike lots of useless whitespace myself.

as for the spell...it looks pretty good. although i don't like the way it sounds...seems too mechanical. like a factory sound or something.
 

Laiev

Hey Listen!!
Reaction score
188
JASS:
globals
    private constant integer ID                 = &#039;A000&#039;    // ID of the spell.
    
    private constant integer DUMMY_BEAM         = &#039;h005&#039;    // ID of the beam unit.
    private constant boolean BEAM_ON            = true      // Whether you want the beam effect on.
    private constant integer BEAM_RED           = 0         // Red value of the beam unit.
    private constant integer BEAM_GREEN         = 255       // Green value of the beam unit.
    private constant integer BEAM_BLUE          = 0         // Blue value of the beam unit.
    private constant integer BEAM_ALPHA         = 255       // Alpha value of the beam unit
    private constant real    BEAM_SCALE         = 1.        // Scaling size of the beam unit.
        
		
    private constant integer DUMMY_BIRD         = &#039;h001&#039;    // ID of the bird unit.
    private constant boolean BIRD_ON            = true      // Whether you want the bird effect on.
    private constant integer BIRD_RED           = 255       // Red value of the bird unit.
    private constant integer BIRD_GREEN         = 255       // Green value of the bird unit.
    private constant integer BIRD_BLUE          = 255       // Blue value of the bird unit.
    private constant integer BIRD_ALPHA         = 255       // Alpha value of the bird unit.
    private constant real    BIRD_SCALE         = 1.        // Scaling size of the bird unit. 
    private constant real    BIRD_TLIFE         = 6.        // Timed life of the birds.
    private constant real    BIRD_OFFSET        = 200.      // Offset distance of the birds.
    private constant real    BIRD_HEIGHT        = 4.        // The interval for increasing flying height.
        
		
    private constant integer DUMMY_EXPLO        = &#039;h004&#039;    // ID of the explosion unit.
    private constant boolean EXPLO_ON           = true      // Whether you want the explosion effect on.
    private constant integer EXPLO_RED          = 0         // Red value of the explosion unit.
    private constant integer EXPLO_GREEN        = 255       // Green value of the explosion unit.
    private constant integer EXPLO_BLUE         = 75        // Blue value of the explosion unit.
    private constant integer EXPLO_ALPHA        = 155       // Alpha value of the explosion unit.
    private constant real    EXPLO_SCALE        = 2.        // Scaling size of the explosion unit.
        
		
    private constant integer DUMMY_GREEN        = &#039;h006&#039;    // ID of the green ball unit.
    private constant boolean GREEN_ON           = true      // Whether you want the green ball effect on.
    private constant integer GREEN_RED          = 255       // Red value of the green ball unit.
    private constant integer GREEN_GREEN        = 255       // Green value of the green ball unit.
    private constant integer GREEN_BLUE         = 255       // Blue value of the green ball unit.
    private constant integer GREEN_ALPHA        = 255       // Aplha value of the green ball unit.
    private constant real    GREEN_SCALE        = .75       // Scaling size of the green ball unit.
    private constant real    GREEN_MSPEED       = 100.      // Movement speed of the green ball unit.
        
		
    private constant integer DUMMY_LEAF         = &#039;h007&#039;    // ID of the leaf unit.
    private constant boolean LEAF_ON            = true      // Whether you want the leaf effect on.
    private constant real    LEAF_SCALE         = 1.        // Scaling size of the leaf unit.
        
		
    private constant integer DUMMY_SPAWN        = &#039;h000&#039;    // ID of the spawning effect unit.
    private constant boolean SPAWN_ON           = true      // Whether you want the spawning effect on.
    private constant integer SPAWN_RED          = 255       // Red value of the spawning effect unit.
    private constant integer SPAWN_GREEN        = 255       // Green value of the spawning effect unit.
    private constant integer SPAWN_BLUE         = 255       // Blue value of the spawning effect unit.
    private constant integer SPAWN_ALPHA        = 255       // Alpha value of the spawning effect unit.
    private constant integer SPAWN_NUM          = 5         // Amount of spawning effect units created on summon.
    private constant real    SPAWN_OFFSET       = 200.      // Offset of the spawning effect unit.
    private constant real    SPAWN_SCALE        = 1.        // Scalaing size of the spawning effect unit.
        
		
    private constant integer DUMMY_SPIN         = &#039;h003&#039;    // ID of the spin dummy unit.
    private constant boolean SPIN_ON            = true      // Whether you want the spinning effect on.
    private constant real    SPIN_OFFSET        = 250.      // Starting offset of the inward spinning.
    private constant integer SPIN_RED           = 225       // Red value of the spin dummy unit.
    private constant integer SPIN_GREEN         = 255       // Green value of the spin dummy unit.
    private constant integer SPIN_BLUE          = 255       // Blue value of the spin dummy unit.
    private constant real    SPIN_SCALE         = .85       // Scaling value of the spin dummy unit.
    private constant real    SPIN_TLIFE         = 1.        // Timed life of the spin dummy unit.
        
		
    private constant integer SPAWNED_UNIT       = &#039;e000&#039;    // ID of the spawned unit.
    private constant integer SPAWNED_UNIT_RED   = 255       // Red value of the spawned unit.
    private constant integer SPAWNED_UNIT_GREEN = 255       // Green value of the spawned unit.
    private constant integer SPAWNED_UNIT_BLUE  = 255       // Blue value of the spawned unit.
    private constant integer SPAWNED_UNIT_ALPHA = 255       // Alpha value of the spawned unit.
    private constant real    SPAWNED_UNIT_SCALE = 1.        // Scaling value of the spawned unit.
    private constant real    SPAWNED_UNIT_TLIFE = 60.       // Timed life of the spawned unit.
        
		
    private constant boolean RIPPLE_ON          = true      // Whether you want the ripple effect on.
    private constant string  SOUND              = &quot;Units\\NightElf\\Ent\\ForceOfNatureBirth1.wav&quot;
    // Path of the sound that is played when the spawn effect birth animation is looped.
	
    private constant string  SFX_BLINK          = &quot;Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl&quot;
    // Path of the blink sfx that occurs on cast to signify where birds will spawn from.
	
    private constant real    PERIOD             = .02       // Period of the KT2 timer.
    // Configurable time options, measured in seconds.
    
    private constant real    MAX_TIME           = 7.        // Max time of the spell in seconds.
    // Extra time past SUM_TIME is to account for the birds still visible on screen, to fly more
	
	
    private constant real    SUM_TIME           = 5.        // Amount of time that it takes to summon the unit.
    
	
    private constant real    BIRD_START         = .6        // Time into the summon when birds spawn.
    private constant real    BIRD_END           = 2.5       // Time into the summon when birds stop spawning.
    
	
    private constant real    GREEN_START        = 0.        // Time into the summon when green ball effect spawns.
    private constant real    GREEN_END          = 3.        // Time into the summon when the green ball effect stop spawning.
    
	
    private constant real    LEAF_START         = 0.        // Time into the summon when leaves fly up.
    private constant real    LEAF_END           = SUM_TIME  // Time into the summon when leaves stop flying up.
   
   
    private constant real    SPIN_START         = 1         // Time into the summon when the dummys spin inward.
    private constant real    SPIN_END           = SUM_TIME  // Time into the summon when the spinning is done.


    private          integer filter
endglobals

:rolleyes:
 

Romek

Super Moderator
Reaction score
964
Scope names, non-constant globals, and (all) function names should be named in UpperCamelCase. Simple naming conventions make things easier to read, and also allow people to easily identify what type a variable, function, etc is. This isn't quite as much of an issue here, as everything is private besides the scope name.
_____________

There also seems to be some confusion about static ifs:
JASS:
globals
    constant boolean BOOL1 = false
    constant boolean BOOL2 = true
endglobals

function ExampleFunc takes nothing returns nothing
    static if BOOL1 then
        call KillUnit(GetTriggerUnit())
    endif
    static if BOOL2 then
        call GetRandomReal(2, 4)
    endif
endfunction

Compiles to:
JASS:
globals
    constant boolean BOOL1 = false
    constant boolean BOOL2 = true
endglobals

function ExampleFunc takes nothing returns nothing
//    static if BOOL1 then
//        call KillUnit(GetTriggerUnit())
//    endif
//    static if BOOL2 then
        call GetRandomReal(2, 4)
//    endif
endfunction

More efficient? Oh yes. :p
_____________

Function 'Sound' doesn't need the string parameter, as all that's being passed to it is a constant, it seems. Just use the constant directly.
_____________

JASS:
.
    if d.ticks&lt;=0 then  
        call d.destroy()
        return true
    else
        call d.summon()
        return false
    endif

Statements like these could be changed to:
JASS:
.
    if d.ticks&lt;=0 then  
        call d.destroy()
        return true
    endif
    call d.summon()
    return false

_____________

JASS:
        if LEAF_ON and .leafTimer==15*PERIOD and .ticks&lt;.maxTicks-LEAF_START/PERIOD and .ticks&gt;.maxTicks-LEAF_END/PERIOD then
            set x2=GetRandomReal(0,150)
            &lt;...Other Stuff...&gt;
            set .leafTimer=0
        else
            set .leafTimer=.leafTimer+PERIOD
        endif

If [ljass]LEAF_ON[/ljass] is false, [ljass].leafTimer[/ljass] is being pointlessly incremented. Other similar issues are also present in the code.
_____________

You could use radians directly instead of using all those conversions from degrees.
_____________

In method 'create', [ljass]real x[/ljass] and [ljass]real y[/ljass] are only used once. You should just inline them. [ljass]real angle[/ljass] could then also be removed, and the struct member could be used instead.
_____________

I'm sure I've missed quite a few things in this post, but it'll do for now.
 

BlackRose

Forum User
Reaction score
239
@Laiev:
That's the style of coding I am liking :D

Bitch Romek Bitch. I nag you for some time now and you don't check my resource :( But this guy gets like ZOMG. Lolz. Meh.

I think this is overkill for a treant..

It was for a fancy sfx contest :p
 

Laiev

Hey Listen!!
Reaction score
188
@BlackRose

same here :thup:

i just forget to add space to the rawcode ability D: (already fixed)
 

Crazy_Dead

New Member
Reaction score
24
I dont really like that looking globals :p.

JASS:
globals
    private constant integer SOMETHING   = &#039;A000&#039;
    private constant real ANOTHER_THING = bj_PI
endglobals


i think this could look nicer like this:

JASS:
globals
    //The Rawcode for the Spell
    private constant integer SOMETHIN     = &#039;A000&#039;
    //Declaring bj_PI for some strange reason. -.-
    private constant real ANOTHER_THING = bj_PI
endglobals


EDIT:

In your actions, you can store GetTriggerUnit(), GetSpellTargetPoint(Loc?) and, then use them. I think what you use now causes leaks.
 

BlackRose

Forum User
Reaction score
239
JASS:
globals
    //The Rawcode for the Spell
    private constant integer SOMETHIN     = &#039;A000&#039;
    //Declaring bj_PI for some strange reason. -.-
    private constant real ANOTHER_THING = bj_PI
endglobals

If it was something only one person worked on and they found it natural. That's ok :)

But this is a public resource.... to me, I can't stand reading something like that (what you suggested). The no space after the [ljass]//[/ljass] irritates me. But that's enough of that...

In your actions, you can store GetTriggerUnit(), GetSpellTargetPoint(Loc?) and, then use them. I think what you use now causes leaks.

[ljass]real[/ljass] don't leak. [ljass]unit[/ljass] won't leak as it's not being declared as local, it's being used straight off.*

*Need citation :(
 

BRUTAL

I'm working
Reaction score
118
looks neat, but I would prefer to use this for summoning some boss unit, not a treant :p
Thanks. Well who says a treant can't be a boss, just because its small? lol.

no, it's not just you. i dislike lots of useless whitespace myself.

as for the spell...it looks pretty good. although i don't like the way it sounds...seems too mechanical. like a factory sound or something.
Good, I'm only going to make the globals spaced out because of the large amount of variables.
Thanks anyways, but I agree with the sound. I changed the sounds to give it a better sense of belonging, I'll find even more suitable ones soon enough.

I think this is overkill for a treant..
Why? And its not just a treant, look at its skills; that is a treant I'd want fighting for me. I even changed the name of it so its a little more than a treant.

At Laiev; thanks, I used that global block as a template.

Function 'Sound' doesn't need the string parameter, as all that's being passed to it is a constant, it seems. Just use the constant directly.
Oh my mistake, I must have accidentally added that parameter in randomly one night. I changed the sounds so the function is slightly different now.

JASS:
.
    if d.ticks&lt;=0 then  
        call d.destroy()
        return true
    else
        call d.summon()
        return false
    endif

Statements like these could be changed to:
JASS:
.
    if d.ticks&lt;=0 then  
        call d.destroy()
        return true
    endif
    call d.summon()
    return false
Alright I changed that.

JASS:
        if LEAF_ON and .leafTimer==15*PERIOD and .ticks&lt;.maxTicks-LEAF_START/PERIOD and .ticks&gt;.maxTicks-LEAF_END/PERIOD then
            set x2=GetRandomReal(0,150)
            &lt;...Other Stuff...&gt;
            set .leafTimer=0
        else
            set .leafTimer=.leafTimer+PERIOD
        endif

If [ljass]LEAF_ON[/ljass] is false, [ljass].leafTimer[/ljass] is being pointlessly incremented. Other similar issues are also present in the code.
Wow, thanks for pointing that out. I just remembered how inlining conditions was always good. I fixed all those issues.

You could use radians directly instead of using all those conversions from degrees.
_____________

In method 'create', [ljass]real x[/ljass] and [ljass]real y[/ljass] are only used once. You should just inline them. [ljass]real angle[/ljass] could then also be removed, and the struct member could be used instead.
Done.

I also made the ripple effects configurable, as well as the new sounds with some properties.
 
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