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:
Code:
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.
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:
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 =039;A000039; // ID of the spell.
private constant integer DUMMY_BEAM = 039;h005039; // 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;h001039; // 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;h004039; // 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;h006039; // 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;h007039; // 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;h000039; // 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 = 039;h003039; // 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 = 039;e000039; // 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,039;BTLF039;,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,"")
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,"")
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>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;BTLF039;,.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;BTLF039;,SPAWNED_UNIT_TLIFE)
call SetUnitAnimation(d,"birth" )
call QueueUnitAnimation(d,"stand")
endif
static if SUM_SOUND_ON then
if .sumSoundTimer==1.5 and .ticks<=.maxTicks-SUM_SOUND_TIME_ST/PERIOD and .ticks>.maxTicks-SUM_SOUND_TIME_END/PERIOD then
set i=0
loop
exitwhen i>10
set .sumSound<i>=CreateSound(SUM_SOUND,false,false,false,10,10,"")
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<.maxTicks-220 then
set i=0
loop
exitwhen i>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<.maxTicks-GREEN_START/PERIOD and .ticks>=.maxTicks-GREEN_END/PERIOD and .greenFloatTimer>=25*PERIOD then
set i=0
loop
exitwhen i>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;BTLF039;,(.ticks-100)*PERIOD)
call IssuePointOrder(d,"move",.x,.y)
set i=i+1
endloop
set .greenFloatTimer=0
else
set .greenFloatTimer=.greenFloatTimer+PERIOD
endif
endif
static if SPAWN_ON then
if .ticks>=.maxTicks-SUM_TIME/PERIOD and .spawnTimer>=50*PERIOD then
call Sound(.spawnEffect)
set .spawnGrowth=.spawnGrowth+.25
call SetUnitScale(.spawnEffect,.spawnGrowth,.spawnGrowth,.spawnGrowth)
call SetUnitAnimation(.spawnEffect,"birth")
set .spawnTimer=0
else
set .spawnTimer=.spawnTimer+PERIOD
endif
endif
static if SPIN_ON then
if .ticks>.maxTicks-(SPIN_END/PERIOD-40) and .ticks<.maxTicks-SPIN_START/PERIOD then
if .spinTimer==3*PERIOD then
set i=0
loop
exitwhen i>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;BTLF039;,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<=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<.maxTicks-BIRD_START/PERIOD and .ticks>.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;BTLF039;,BIRD_TLIFE)
call GroupAddUnit(.birds,d)
call UnitAddAbility(d,039;Amrf039;)
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<.maxTicks-LEAF_START/PERIOD and .ticks>.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;BTLF039;,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<=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,"")
call StartSound(s)
call SetSoundVolume(s,0)
call KillSoundWhenDone(s)
set s=CreateSound(SPAWN_SOUND,false,false,false,10,10,"")
call StartSound(s)
call SetSoundVolume(s,0)
call KillSoundWhenDone(s)
set s=CreateSound(EXPLO_SOUND,false,false,false,10,10,"")
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.