- Joined
- Jun 28, 2007
- Messages
- 21
Spell:
Dragons' Horde
Dragons' Horde
- Description of spell is in the screenshot.
- JASS (JESP)
- MUI
- Spell's Code:
JASS:
//*****************************************************************************************
//*****************************************************************************************
//** //**
//** Name : Dragons' Horde //**
//** //**
//** Author : --Thanatos-- //**
//** //**
//*****************************************************************************************
//*****************************************************************************************
//** //**
//** Credits: KaTTaNa's Handle Vars //**
//** //**
//*****************************************************************************************
//*****************************************************************************************
//#########################################################################################
//#####################################configurations######################################
//## //##
//## Change the part "return ****" with your configuration. //##
//## //##
constant function Dragons_Horde_Rawcode takes nothing returns integer //##
return 'A000' //##
endfunction //##
//## Spell's Rawcode. Base it on Vampiric Aura ('AIpv'). Change duration here. //##
//## //##
constant function Dragons_Horde_BuffRawcode takes nothing returns integer //##
return 'B000' //##
endfunction //##
//## The Immolation's Buff's Rawcode. //##
//## //##
constant function Dragons_Horde_BreathRawcode takes nothing returns integer //##
return 'A007' //##
endfunction //##
//## A Breath ability. Base it on Carrion Swarm ('ACca'). //##
//## //##
constant function Dragons_Horde_FrostArmorRawcode takes nothing returns integer //##
return 'A002' //##
endfunction //##
//## The base of slowing frost. Base it on Frost Armor ('ACfa'). Change slow duration //##
//## here. //##
//## //##
constant function Dragons_Horde_DragonRawcode takes nothing returns integer //##
return 'h004' //##
endfunction //##
//## The unit used as the dragons. Should act like dummies, have Movement Speed of 1, //##
//## or more, Movement type of flying, ability Locust ('Aloc'), and Invulnerable //##
//## ('Avul'). (Should act like a dummy) //##
//## //##
constant function Dragons_Horde_Radius takes nothing returns real //##
return 700. //##
endfunction //##
//## Radius of enemies from the dragons that shall be breathed by the dragons. //##
//## //##
constant function Dragons_Horde_DragonSpeed takes nothing returns real //##
return 600. //##
endfunction //##
//## Movement Speed of the dragons. This may pass the Movement Speed limit. //##
//## //##
constant function Dragons_Horde_DragonSpeedDist takes nothing returns real //##
return 300. //##
endfunction //##
//## Distance between Minimum and Maximum Movement Speed with it's default. //##
//## //##
constant function Dragons_Horde_DragonSpeedSpeed takes nothing returns real //##
return 600. //##
endfunction //##
//## Movement Speed change per second. //##
//## //##
constant function Dragons_Horde_DragonRadius takes nothing returns real //##
return 300. //##
endfunction //##
//## How far the dragons should be from the caster. //##
//## //##
constant function Dragons_Horde_DragonRadiusDist takes nothing returns real //##
return 150. //##
endfunction //##
//## Distance between Minimum and Maximum Range of the dragons to the caster with it's //##
//## default. //##
//## //##
constant function Dragons_Horde_DragonRadiusSpeed takes nothing returns real //##
return 150. //##
endfunction //##
//## Range change between dragons to caster per second. //##
//## //##
constant function Dragons_Horde_DragonHeight takes nothing returns real //##
return 150. //##
endfunction //##
//## Flying height of the dragons. //##
//## //##
constant function Dragons_Horde_DragonHeightDist takes nothing returns real //##
return 50. //##
endfunction //##
//## Distance between Minimum and Maximum Flying Height with it's default. //##
//## //##
constant function Dragons_Horde_DragonHeightSpeed takes nothing returns real //##
return 25. //##
endfunction //##
//## Flying Height change per second. //##
//## //##
constant function Dragons_Horde_TimerPeriod takes nothing returns real //##
return .02 //##
endfunction //##
//## Period of the main timer. The best should range between .01 - .05. //##
//## The less it is, the laggier it is. However, the less it is, the better the //##
//## resolution is. //##
//## //##
constant function Dragons_Horde_RegistryPeriod takes nothing returns real //##
return 1. //##
endfunction //##
//## Period of the registry timer. Best is to keep it at 1.. //##
//## //##
constant function Dragons_Horde_DamagePoint takes nothing returns real //##
return .75 //##
endfunction //##
//## Damage point of the dragons' animation. //##
//## //##
constant function Dragons_Horde_Dragons takes integer level returns integer //##
if level == 1 then //##
return 2 //##
elseif level == 2 then //##
return 2 //##
elseif level == 3 then //##
return 3 //##
else //##
return level / 2 + 1 //##
endif //##
endfunction //##
//## Quantity of the dragons at each level. //##
//## //##
constant function Dragons_Horde_Damage takes integer level returns real //##
if level == 1 then //##
return 50. //##
elseif level == 2 then //##
return 75. //##
elseif level == 3 then //##
return 100. //##
else //##
return level * 25. + 25. //##
endif //##
endfunction //##
//## Damage of each dragon at each level. //##
//## //##
constant function Dragons_Horde_Cooldown takes integer level returns real //##
if level == 1 then //##
return 1.5 //##
elseif level == 2 then //##
return 1.5 //##
elseif level == 3 then //##
return 1.5 //##
else //##
return 1.5 //##
endif //##
endfunction //##
//## Cooldown of the dragons at each level. //##
//## //##
constant function Dragons_Horde_ActivateEffect takes nothing returns string //##
return "Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl" //##
endfunction //##
//## Special Effect that should appear when activated. //##
//## //##
constant function Dragons_Horde_BirthEffect takes nothing returns string //##
return "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl" //##
endfunction //##
//## Special Effect that should appear when the dragons come. //##
//## //##
//#########################################################################################
//#########################################################################################
//***************************************conditions****************************************
//* //*
function Dragons_Horde_Conditions takes nothing returns boolean //*
//*
return GetSpellAbilityId () == Dragons_Horde_Rawcode () //*
//*
endfunction //*
//* //*
//*****************************************************************************************
//*************************************spell's script*************************************
function Dragons_Horde_Filter takes nothing returns boolean
local player owner = GetOwningPlayer (GetHandleUnit(GetExpiredTimer(),"caster"))
local unit target = GetFilterUnit ()
local boolean returnVal = false
if GetUnitAbilityLevel (target,Dummy_Ability_Rawcode()) <= 0 then
if IsUnitHidden (target) == false then
if GetWidgetLife (target) > .405 then
if IsUnitEnemy (target,owner) then
if IsUnitVisible (target,owner) then
if IsUnitType (target,UNIT_TYPE_STRUCTURE) == false then
if IsUnitType (target,UNIT_TYPE_MAGIC_IMMUNE) == false then
set returnVal = true
endif
endif
endif
endif
endif
endif
endif
set owner = null
set target = null
return returnVal
endfunction
function Dragons_Horde_FrostEnd takes nothing returns nothing
local timer dhTimer = GetExpiredTimer ()
local trigger DhTrig = GetHandleTrigger (dhTimer,"dhtrig")
call FlushHandleLocals (dhTimer)
call PauseTimer (dhTimer)
call DestroyTimer (dhTimer)
call FlushHandleLocals (DhTrig )
call TriggerClearActions (DhTrig )
call DestroyTrigger (DhTrig )
set dhTimer = null
set DhTrig = null
endfunction
function Dragons_Horde_Frost takes nothing returns nothing
local trigger DhTrig = GetTriggeringTrigger ()
local unit caster = GetHandleUnit (DhTrig,"caster")
local unit dummy = GetHandleUnit (DhTrig,"dummy" )
local unit frost = GetHandleUnit (DhTrig,"frost" )
local integer level = GetHandleInt (DhTrig,"level" )
local unit source = GetEventDamageSource ()
local unit target = GetTriggerUnit ()
local real damage = Dragons_Horde_Damage (level)
if source == dummy then
call UnitDamageTarget (target,frost ,0. ,true ,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
call UnitDamageTarget (caster,target,damage,false,true ,ATTACK_TYPE_CHAOS ,DAMAGE_TYPE_MAGIC ,null)
endif
set DhTrig = null
set caster = null
set dummy = null
set frost = null
set source = null
set target = null
endfunction
function Dragons_Horde_Effect takes nothing returns nothing
local timer DhTimer = GetExpiredTimer ()
local timer dhTimer
local trigger DhTrig
local unit caster = GetHandleUnit (DhTimer,"caster")
local integer level = GetHandleInt (DhTimer,"level" )
local boolean buffed = GetUnitAbilityLevel (caster,Dragons_Horde_BuffRawcode()) > 0
local integer dragons = Dragons_Horde_Dragons (level)
local real cooldown = Dragons_Horde_Cooldown (level)
local player owner = GetOwningPlayer (caster)
local real castX = GetWidgetX (caster)
local real castY = GetWidgetY (caster)
local real drgnX
local real drgnY
local real targX
local real targY
local real nextX
local real nextY
local real angle
local real random
local real attack
local real spin
local real dist
local real height
local boolean Spin
local boolean Dist
local boolean Height
local boolean breath
local boolean Attack
local group targets
local unit target
local unit enum
local integer Enum
local unit dummy
local unit frost
local unit eDragon
local integer lDragon = 0
local string lString
local integer dragoncode = Dragons_Horde_DragonRawcode ()
local string birtheffect = Dragons_Horde_BirthEffect ()
local real period = Dragons_Horde_TimerPeriod ()
local real dmgPoint = Dragons_Horde_DamagePoint ()
local real radius = Dragons_Horde_Radius ()
local real drgnSpd = Dragons_Horde_DragonSpeed ()
local real drgnSpdDist = Dragons_Horde_DragonSpeedDist ()
local real drgnSpdSpd = Dragons_Horde_DragonSpeedSpeed ()
local real drgnRad = Dragons_Horde_DragonRadius ()
local real drgnRadDist = Dragons_Horde_DragonRadiusDist ()
local real drgnRadSpd = Dragons_Horde_DragonRadiusSpeed ()
local real drgnHgt = Dragons_Horde_DragonHeight ()
local real drgnHgtDist = Dragons_Horde_DragonHeightDist ()
local real drgnHgtSpd = Dragons_Horde_DragonHeightSpeed ()
local real multiplier = period
local filterfunc DhFilter = Filter (function Dragons_Horde_Filter)
loop
set lDragon = lDragon + 1
exitwhen lDragon > dragons
set lString = I2S (lDragon)
set eDragon = GetHandleUnit (DhTimer,"dragon" + lString)
if not buffed then
call UnitApplyTimedLife (eDragon,'BTLF',.00001)
else
if GetWidgetLife (eDragon) <= .405 then
set spin = GetRandomReal (drgnSpd - drgnSpdDist,drgnSpd + drgnSpdDist)
set dist = GetRandomReal (drgnRad - drgnRadDist,drgnRad + drgnRadDist)
set height = GetRandomReal (drgnHgt - drgnHgtDist,drgnHgt + drgnHgtDist)
set Spin = GetRandomInt (1,2) == 1
set Dist = GetRandomInt (1,2) == 1
set Height = GetRandomInt (1,2) == 1
set angle = GetRandomReal (0.,360.)
set attack = 0.
set breath = false
set drgnX = castX + dist * Cos (angle * (3.14159 / 180.))
set drgnY = castY + dist * Sin (angle * (3.14159 / 180.))
set targX = 0.
set targY = 0.
set eDragon = CreateUnit (owner,dragoncode,drgnX,drgnY,angle + 90.)
call SetUnitColor (eDragon,PLAYER_COLOR_BLUE)
call DestroyEffect (AddSpecialEffectTarget(birtheffect,eDragon,"chest"))
call SetUnitAnimationByIndex (eDragon,0)
call SetUnitX (eDragon,drgnX)
call SetUnitY (eDragon,drgnY)
call SetUnitFlyHeight (eDragon,height,0.)
call SetHandleHandle (DhTimer,"dragon" + lString,eDragon)
call SetHandleReal (DhTimer,"dragonspin" + lString,spin )
call SetHandleReal (DhTimer,"dragondist" + lString,dist )
call SetHandleReal (DhTimer,"dragonfly" + lString,height )
call SetHandleBoolean (DhTimer,"dragonspinr" + lString,Spin )
call SetHandleBoolean (DhTimer,"dragondistr" + lString,Dist )
call SetHandleBoolean (DhTimer,"dragonflyr" + lString,Height )
call SetHandleReal (DhTimer,"dragonangle" + lString,angle )
call SetHandleReal (DhTimer,"dragoncool" + lString,attack )
call SetHandleBoolean (DhTimer,"dragondone" + lString,breath )
call SetHandleReal (DhTimer,"dragontargx" + lString,targX )
call SetHandleReal (DhTimer,"dragontargy" + lString,targY )
endif
set spin = GetHandleReal (DhTimer,"dragonspin" + lString)
set dist = GetHandleReal (DhTimer,"dragondist" + lString)
set height = GetHandleReal (DhTimer,"dragonfly" + lString)
set Spin = GetHandleBoolean (DhTimer,"dragonspinr" + lString)
set Dist = GetHandleBoolean (DhTimer,"dragondistr" + lString)
set Height = GetHandleBoolean (DhTimer,"dragonflyr" + lString)
set angle = GetHandleReal (DhTimer,"dragonangle" + lString)
set attack = GetHandleReal (DhTimer,"dragoncool" + lString)
set breath = GetHandleBoolean (DhTimer,"dragondone" + lString)
set targX = GetHandleReal (DhTimer,"dragontargx" + lString)
set targY = GetHandleReal (DhTimer,"dragontargy" + lString)
set drgnX = GetWidgetX (eDragon)
set drgnY = GetWidgetY (eDragon)
set Attack = attack > 0. and attack <= dmgPoint
if Attack then
set multiplier = 0.
endif
set random = drgnSpdSpd * multiplier
if Spin then
set spin = spin + random
if spin >= drgnSpd + drgnSpdDist then
set Spin = false
endif
elseif not Spin then
set spin = spin - random
if spin <= drgnSpd - drgnSpdDist then
set Spin = true
endif
endif
set angle = angle + spin / (2. * 3.14159 * dist / 360.) * multiplier
set random = drgnRadSpd * multiplier
if Dist then
set dist = dist + random
if dist >= drgnRad + drgnRadDist then
set Dist = false
endif
elseif not Dist then
set dist = dist - random
if dist <= drgnRad - drgnRadDist then
set Dist = true
endif
endif
set random = drgnHgtSpd * multiplier
if Height then
set height = height + random
if height >= drgnHgt + drgnHgtDist then
set Height = false
endif
elseif not Height then
set height = height - random
if height <= drgnHgt - drgnHgtDist then
set Height = true
endif
endif
set nextX = castX + dist * Cos (angle * (3.14159 / 180.))
set nextY = castY + dist * Sin (angle * (3.14159 / 180.))
set drgnX = nextX
set drgnY = nextY
call SetUnitX (eDragon,drgnX)
call SetUnitY (eDragon,drgnY)
call SetUnitFlyHeight (eDragon,height,0.)
call SetHandleReal (DhTimer,"dragonspin" + lString,spin )
call SetHandleReal (DhTimer,"dragondist" + lString,dist )
call SetHandleReal (DhTimer,"dragonfly" + lString,height)
call SetHandleBoolean (DhTimer,"dragonspinr" + lString,Spin )
call SetHandleBoolean (DhTimer,"dragondistr" + lString,Dist )
call SetHandleBoolean (DhTimer,"dragonflyr" + lString,Height)
call SetHandleReal (DhTimer,"dragonangle" + lString,angle )
if Attack then
set angle = Atan2 (targY - drgnY,targX - drgnX) * (180. / 3.14159)
else
set angle = angle + 90.
endif
call SetUnitFacing (eDragon,angle)
if attack >= cooldown then
set attack = 0.
set breath = false
call SetHandleReal (DhTimer,"dragoncool" + lString,attack)
call SetHandleBoolean (DhTimer,"dragondone" + lString,breath)
elseif attack > 0. then
if attack >= dmgPoint and (breath == false) then
set breath = true
call SetHandleBoolean (DhTimer,"dragondone" + lString,breath)
set dummy = CreateUnit (owner,Dummy_Visibility_Rawcode(),drgnX,drgnY,0.)
call UnitApplyTimedLife (dummy,'BTLF',2.5 )
call UnitAddAbility (dummy,Dragons_Horde_BreathRawcode() )
call SetUnitX (dummy,drgnX )
call SetUnitY (dummy,drgnY )
set frost = CreateUnit (owner,Dummy_Target_Rawcode() ,drgnX,drgnY,0.)
call UnitApplyTimedLife (frost,'BTLF',2.5 )
call UnitAddAbility (frost,Dragons_Horde_FrostArmorRawcode() )
call SetUnitX (frost,drgnX )
call SetUnitY (frost,drgnY )
call SetUnitAnimationByIndex (eDragon,0)
set dhTimer = CreateTimer ()
set DhTrig = CreateTrigger ()
set targets = CreateGroup ()
call GroupEnumUnitsInRange (targets,drgnX,drgnY,9999.,Filter(function GetTrue))
loop
set target = FirstOfGroup (targets)
exitwhen target == null
call GroupRemoveUnit (targets,target)
call TriggerRegisterUnitEvent (DhTrig,target,EVENT_UNIT_DAMAGED)
endloop
call DestroyGroup (targets)
call TriggerAddAction (DhTrig,function Dragons_Horde_Frost)
call SetHandleHandle (DhTrig,"caster",caster)
call SetHandleHandle (DhTrig,"dummy" ,dummy )
call SetHandleHandle (DhTrig,"frost" ,frost )
call SetHandleInt (DhTrig,"level" ,level )
call SetHandleHandle (dhTimer,"dhtrig",DhTrig)
call TimerStart (dhTimer,2.5,true,function Dragons_Horde_FrostEnd)
call IssuePointOrderById (dummy,852218,targX,targY)
call IssueTargetOrderById (frost,852225,frost)
endif
set attack = attack + period
call SetHandleReal (DhTimer,"dragoncool" + lString,attack)
elseif attack == 0. then
set targets = CreateGroup ()
call GroupEnumUnitsInRange (targets,drgnX,drgnY,radius,DhFilter)
if FirstOfGroup (targets) != null then
set Enum = 0
loop
set enum = FirstOfGroup (targets)
exitwhen enum == null
call GroupRemoveUnit (targets,enum)
set Enum = Enum + 1
if GetRandomInt (1,Enum) == 1 then
set target = enum
endif
endloop
set targX = GetWidgetX (target)
set targY = GetWidgetY (target)
call SetHandleReal (DhTimer,"dragontargx" + lString,targX)
call SetHandleReal (DhTimer,"dragontargy" + lString,targY)
call SetUnitFacing (eDragon,Atan2(targY - drgnY,targX - drgnX) * (180. / 3.14159))
call SetUnitAnimationByIndex (eDragon,1)
set attack = attack + period
call SetHandleReal (DhTimer,"dragoncool" + lString,attack)
endif
call DestroyGroup (targets)
endif
set multiplier = period
endif
endloop
if not buffed then
call FlushHandleLocals (DhTimer)
call PauseTimer (DhTimer)
call DestroyTimer (DhTimer)
endif
set DhTimer = null
set dhTimer = null
set DhTrig = null
set caster = null
set eDragon = null
set owner = null
set targets = null
set target = null
set enum = null
set dummy = null
set frost = null
set eDragon = null
set DhFilter = null
endfunction
function Dragons_Horde takes nothing returns nothing
local timer DhTimer
local unit caster = GetTriggerUnit ()
local integer level = GetUnitAbilityLevel (caster,Dragons_Horde_Rawcode())
local boolean buffed = GetUnitAbilityLevel (caster,Dragons_Horde_BuffRawcode()) > 0
call DestroyEffect (AddSpecialEffectTarget(Dragons_Horde_ActivateEffect(),caster,"origin"))
if not buffed then
set DhTimer = CreateTimer ()
call SetHandleHandle (DhTimer,"caster",caster)
call SetHandleInt (DhTimer,"level" ,level )
call TimerStart (DhTimer,Dragons_Horde_TimerPeriod(),true,function Dragons_Horde_Effect)
endif
set DhTimer = null
set caster = null
endfunction
//****************************************************************************************
//****************************************preloads*********************************************
//* //*
function Dragons_Horde_Preload takes nothing returns nothing //*
//*
local player neutral = Player (PLAYER_NEUTRAL_PASSIVE) //*
local unit tempUnit = CreateUnit (neutral,Dummy_Unit_Rawcode(),0.,0.,0.) //*
call DestroyEffect (AddSpecialEffectTarget(Dragons_Horde_ActivateEffect(),tempUnit,"origin"))//*
call DestroyEffect (AddSpecialEffectTarget(Dragons_Horde_BirthEffect(),tempUnit,"origin"))//*
call UnitAddAbility (tempUnit,Dragons_Horde_Rawcode()) //*
call UnitAddAbility (tempUnit,Dragons_Horde_BreathRawcode()) //*
call UnitAddAbility (tempUnit,Dragons_Horde_FrostArmorRawcode()) //*
call RemoveUnit (tempUnit) //*
call RemoveUnit (CreateUnit(neutral,Dragons_Horde_DragonRawcode(),0.,0.,0.))//*
call RemoveUnit (CreateUnit(neutral,Dummy_Visibility_Rawcode(),0.,0.,0.))//*
call RemoveUnit (CreateUnit(neutral,Dummy_Target_Rawcode(),0.,0.,0.))//*
set neutral = null //*
set tempUnit = null //*
//*
endfunction //*
//* //*
//*********************************************************************************************
//===========================================================================
function InitTrig_Dragons_Horde takes nothing returns nothing
local integer index = 0
call Dragons_Horde_Preload ()
set gg_trg_Dragons_Horde = CreateTrigger ()
loop
call TriggerRegisterPlayerUnitEvent (gg_trg_Dragons_Horde,Player(index),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function GetTrue))
set index = index + 1
exitwhen index == 16
endloop
call TriggerAddCondition (gg_trg_Dragons_Horde,Condition(function Dragons_Horde_Conditions))
call TriggerAddAction (gg_trg_Dragons_Horde,function Dragons_Horde)
endfunction
- Made uber locals for easier readings.
- Download here.