- Joined
- Jun 28, 2008
- Messages
- 776
I am in the last stage of my spell, just a little tweeking here and there.
scope VeredentForce initializer Init
//----------------------------------------------------------------------------
//This spell was created for the 7th Zephyr chalange on The Hive Workshop
//The theme for the spell is nature.
//I use the following libraries :
// TimerUtils
// GroupUtils
// ParabolaMovement
//
//Credits
//Icon by : Anachron
//WillTheAllMighty
//Elenai
//----------------------------------------------------------------------------
globals
private constant integer SPELLID = 'A003'
private constant integer DUMMYID = 'n000'
private constant damagetype DAMAGETYPE = DAMAGE_TYPE_MAGIC
private constant attacktype ATTACKTYPE = ATTACK_TYPE_MAGIC
private constant real DAMAGEBASE = 0
private constant real DAMAGELEVELINC = 2.5
private constant string MODDELDRAIN1 = "Abilities\\Spells\\NightElf\\TargetArtLumber\\TargetArtLumber.mdl"
private constant string MODDELDRAIN2 = "Abilities\\Spells\\Other\\Drain\\DrainTarget.mdl"
private constant string MODDELINITEFFECT = "Objects\\Spawnmodels\\NightElf\\EntBirthTarget\\EntBirthTarget.mdl"
private constant string MODDELTRANSFER = "Abilities\\Weapons\\IllidanMissile\\IllidanMissile.mdl"
private constant string MODDELCOMBUST = "Units\\NightElf\\Wisp\\WispExplode.mdl"
private constant string MODDELHEAL = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl"
private constant real DISTANCE = 450.
private constant real EFFECTAREA = 450.
private constant real MAXHEIGHT = 275.
private constant integer MAXENTITYSUMMON = 6
private constant real TRANSFERMISSILESCALE = 0.25
private constant real DURATION = 8
private constant real ACTIVEINTERVAL = 0.5
private unit TEMPUNIT
endglobals
private function FilterUnits takes nothing returns boolean
return (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(TEMPUNIT)) == true) and (GetWidgetLife(GetFilterUnit()) > 0) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) != true) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) != true)
endfunction
private function FilterUnitsAllied takes nothing returns boolean
return (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(TEMPUNIT)) != true) and (GetWidgetLife(GetFilterUnit()) > 0) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) != true) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) != true)
endfunction
struct VFMissile
unit caster
unit target
unit entity
real angle
real oX
real oY
real d
real cd
effect e
static method create takes unit caster, unit target, real x, real y returns VFMissile
local VFMissile dat = VFMissile.allocate()
local timer t = NewTimer()
set dat.caster = caster
set dat.target = target
set dat.entity = CreateUnit(GetOwningPlayer(caster), DUMMYID, GetUnitX(target), GetUnitY(target), 0)
set dat.oX = x
set dat.oY = y
set dat.e = AddSpecialEffectTarget(MODDELTRANSFER, dat.entity, "origin")
set dat.d = SquareRoot((GetUnitX(target) - x) * (GetUnitX(target) - x) + (GetUnitY(target) - y) * (GetUnitY(target) - y))
set dat.cd = 0
call SetUnitScale(dat.entity, TRANSFERMISSILESCALE, TRANSFERMISSILESCALE, TRANSFERMISSILESCALE)
call SetTimerData(t, dat)
call TimerStart(t, 0.06, true, function VFMissile.onLoop)
set t = null
return dat
endmethod
static method onLoop takes nothing returns nothing
local timer t = GetExpiredTimer()
local VFMissile dat = GetTimerData(t)
local real x = GetUnitX(dat.entity)
local real y = GetUnitY(dat.entity)
local real a = bj_RADTODEG * Atan2(dat.oY - y, dat.oX - x)
local real nX = x + 25 * Cos(a * bj_DEGTORAD)
local real nY = y + 25 * Sin(a * bj_DEGTORAD)
local real h = ParabolaZ(MAXHEIGHT, dat.d, dat.cd)
set dat.cd = dat.cd + 25
if dat.cd < dat.d then
call SetUnitX(dat.entity, nX)
call SetUnitY(dat.entity, nY)
call SetUnitFlyHeight(dat.entity, h, 0)
else
call KillUnit(dat.entity)
call DestroyEffect(dat.e)
call PauseTimer(t)
call ReleaseTimer(t)
call dat.destroy()
endif
set t = null
endmethod
endstruct
struct VFData
unit caster
unit entity
real damagestored
real manastored
effect e1
effect e2
static method create takes unit caster, unit entity, effect e1, effect e2 returns VFData
local VFData dat = VFData.allocate()
local timer t = NewTimer()
set dat.caster = caster
set dat.entity = entity
set dat.e1 = e1
set dat.e2 = e2
call SetTimerData(t, dat)
call TimerStart(t, ACTIVEINTERVAL, true, function VFData.onLoop)
set t = null
return dat
endmethod
static method onLoop takes nothing returns nothing
local timer t = GetExpiredTimer()
local VFData dat = GetTimerData(t)
local group g = NewGroup()
local real x = GetUnitX(dat.entity)
local real y = GetUnitY(dat.entity)
local unit n = null
local real damage = (DAMAGEBASE + (GetUnitAbilityLevel(dat.caster, SPELLID) * DAMAGELEVELINC))
local real heal = 0
local real mana = 0
local integer count = 0
set TEMPUNIT = dat.caster
call GroupEnumUnitsInArea(g, x, y, EFFECTAREA, Condition(function FilterUnits))
loop
set n = FirstOfGroup(g)
exitwhen n == null
call VFMissile.create(dat.caster, n, x, y)
call UnitDamageTarget(dat.caster, n, damage, true, false, ATTACKTYPE, DAMAGETYPE, WEAPON_TYPE_WHOKNOWS)
call GroupRemoveUnit(g, n)
set dat.damagestored = dat.damagestored + damage
if GetUnitState(n, UNIT_STATE_MANA) > 0 then
set dat.manastored = dat.manastored + damage
call SetUnitState(n, UNIT_STATE_MANA, GetUnitState(n, UNIT_STATE_MANA) - damage)
endif
endloop
if GetWidgetLife(dat.entity) <= 0 then
call KillUnit(dat.entity)
call DestroyEffect(dat.e1)
call DestroyEffect(dat.e2)
call DestroyEffect(AddSpecialEffect(MODDELCOMBUST, x, y))
call PauseTimer(t)
call ReleaseTimer(t)
if (dat.damagestored > 0) or (dat.manastored > 0) then
set TEMPUNIT = dat.caster
call GroupEnumUnitsInArea(g, x, y, EFFECTAREA, Condition(function FilterUnitsAllied))
loop
set n = FirstOfGroup(g)
exitwhen n == null
set count = count + 1
call GroupRemoveUnit(g, n)
endloop
call GroupEnumUnitsInArea(g, x, y, EFFECTAREA, Condition(function FilterUnitsAllied))
set heal = dat.damagestored / count
set mana = dat.manastored / count
loop
set n = FirstOfGroup(g)
exitwhen n == null
call SetUnitState(n, UNIT_STATE_LIFE, GetUnitState(n, UNIT_STATE_LIFE) + heal)
call SetUnitState(n, UNIT_STATE_MANA, GetUnitState(n, UNIT_STATE_MANA) + mana)
call DestroyEffect(AddSpecialEffectTarget(MODDELHEAL, n, "origin"))
call GroupRemoveUnit(g, n)
endloop
endif
call dat.destroy()
endif
call ReleaseGroup(g)
set t = null
set g = null
set n = null
endmethod
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELLID
endfunction
private function Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit entity = null
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local real nX = 0
local real nY = 0
local real a = 0
local integer i = 0
local effect e1 = null
local effect e2 = null
loop
set i = i + 1
set a = a + (360 / MAXENTITYSUMMON)
set nX = x + DISTANCE * Cos(a * bj_DEGTORAD)
set nY = y + DISTANCE * Sin(a * bj_DEGTORAD)
set entity = CreateUnit(GetOwningPlayer(caster), DUMMYID, nX, nY, a)
set e1 = AddSpecialEffectTarget(MODDELDRAIN2, entity, "origin")
set e2 = AddSpecialEffect(MODDELDRAIN1, nX, nY)
call DestroyEffect(AddSpecialEffect(MODDELINITEFFECT, nX, nY))
call UnitApplyTimedLife(entity, 'BFLT', DURATION)
call VFData.create(caster, entity, e1, e2)
exitwhen i == MAXENTITYSUMMON
endloop
set caster = null
set entity = null
set e1 = null
set e2 = null
endfunction
private function Init takes nothing returns nothing
local trigger MainTrigger = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(MainTrigger, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(MainTrigger, function Actions)
call TriggerAddCondition(MainTrigger, function Conditions)
set MainTrigger = null
endfunction
endscope
Total Entrants | 16 |
[table][FONT=Palatino Linotype][SIZE=3][COLOR=red][center][B]Contestants Table[/B][/COLOR][/center][/SIZE][/FONT][r][TABLE][tr][TD][B][FONT=Palatino Linotype][SIZE=3][color=orangered]Contestant's Name[/color][/SIZE][/FONT][/B][/TD][TD][FONT=Palatino Linotype][B][SIZE=3][color=orange]Spell Name[/color][/SIZE][/B][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/eccho"][color=orangered]Eccho[/color][/URL] [/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index7.html#post1651249][color=orange]Pollination[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/klingo/"][color=orangered]Klingo[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index7.html#post1651258][color=orange]Mysterious Fruit[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/xd.schurke/"][color=orangered]xD.Schurke[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index7.html#post1651682][color=orange]Touch of Nature[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/maker/"][color=orangered]Maker[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index7.html#post1652588][color=orange]Racoon Revenge[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/gaby-boy/"][color=orangered]gaby-boy[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index7.html#post1651771][color=orange]Nature Enchantment[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/hvo-busterkomo/"][color=orangered]hvo-busterkomo[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index7.html#post1653252][color=orange]The Circle of Life[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/xiliger/"][color=orangered]Xiliger[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index8.html#post1653343][color=orange]Veredant Force[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/zir/"][color=orangered]ZIR[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index6.html#post1649914][color=orange]Tree Prison[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/infinateanswers/"][color=orangered]InfinateAnswers[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index6.html#post1648266][color=orange]Mystic Acorn[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/spencenator/"][color=orangered]Spencenator[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index6.html#post1645911][color=red]Not specified.[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/beast%28trog%29/"][color=orangered]Beast(TrOg)[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index7.html#post1651271][color=red]Not specified.[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/scorpion182/"][color=orangered]Scorpion182[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index5.html#post1642851][color=red]Not specified.[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/ash+darkside/"][color=orangered]Ash Darkside[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index6.html#post1647549][color=orange]Judgement[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/kercyn/"][color=orangered]Kercyn[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index3.html#post1626561][color=red]Not specified.[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/wherewolftherewolf/"][color=orangered]WhereWolfThereWolf[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index2.html#post1626360][color=orange]Enchanted Bloom[/color][/url][/FONT][/TD][/tr][tr][td][URL="http://www.hiveworkshop.com/forums/members/cweener/"][color=orangered]Cweener[/color][/URL][/td][TD][FONT=Palatino Linotype][url=http://www.hiveworkshop.com/forums/arena-226/zephyr-challenge-7-a-170461/index7.html#post1650329][color=orange]Nature's Reconciliation[/color][/url][/FONT][/TD][/tr][/TABLE][RIGHT][table][FONT=Palatino Linotype][COLOR=Red][B]Total Entrants[/B][/COLOR][/FONT][c][FONT=Palatino Linotype][B][SIZE=3][COLOR=orange]16[/COLOR][/SIZE][/B][/FONT][/table][/RIGHT]
[/table]