Moderator
M
Moderator
16 Dec 2011
Bribe: The changes look much better. Rating changed to 4/5 (Recommended).
Bribe: The changes look much better. Rating changed to 4/5 (Recommended).
Spell DescriptionActive: Encases a unit in ice, dealing damage and disabling it. After a short duration the ice explodes, slowing the
target by 50% and sending shards of ice to all nearby enemies, dealing damage and stunning them for 3 seconds.
Level 1: 75 target damage; 0.5 second freeze; 50 shard damage
Level 2: 125 target damage; 0.75 second freeze; 75 shard damage
Level 3: 175 target damage; 1 second freeze; 100 shard damage
Cooldown: 15 seconds.
Mana cost: 125.
library ShatteringFrost /*
****************************************************************************************************
*
* S H A T T E R I N G F R O S T
*
* ~ version 2.0.1
* ~ coded by Mr_Bean
*
****************************************************************************************************
*
* */ requires /*
* ¯¯¯¯¯¯¯¯
* */ BeanDummyCaster, /* (not uploaded; available in demo map)
* */ SpellEffectEvent, /* http://www.hiveworkshop.com/forums/jass-resources-412/snippet-spelleffectevent-187193
* */ TimerUtils /* http://www.wc3c.net/showthread.php?t=101322
* */ xemissile /* http://www.wc3c.net/showthread.php?t=101150
*
****************************************************************************************************
*
* Installation
* ¯¯¯¯¯¯¯¯¯¯¯¯
* - Make sure you've got (and installed properly) the above systems.
* - Copy the 4 custom abilities. Scroll down to the "RAW IDS" section and set their raw IDs.
* - Copy the 2 custom buffs (or make your own):
* > Set the buff fields of "Slow [Shattering Frost]" to the "Shattering Frost" buff
* > Set the buff fields of "Pause [Shattering Frost]" to the "Shattering Frost [paused]" buff.
* - Go through the configurables section below and change what you want to.
*
****************************************************************************************************
*
* Adding Ability Levels
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* If you would like to add more levels to the ability, you will need to add the same amount of
* levels to the 3 dummy abilities (Pause, Stun and Slow). Configure the stun and slow values as
* desired. For the Stun and Pause dummy abilities, make sure the for each level you added:
* - Damage is set to 0.
* - Cast range is set to 99999.
* - Cooldown is set to 0.
* - Mana cost is set to 0.
* - Targets allowed is BLANK (don't worry, the code makes sure only valid targets are chosen).
*
* For the Slow dummy ability, make sure the for each level you added:
* - Cast range is set to 99999.
* - Cooldown is set to 0.
* - Mana cost is set to 0.
* - Targets allowed is BLANK (don't worry, the code makes sure only valid targets are chosen).
*
****************************************************************************************************
*
* Configuration
* ¯¯¯¯¯¯¯¯¯¯¯¯¯
*/
globals
//==================================================
//=== RAW IDS
private constant integer SPELL_ID = 'A002' // "Shattering Frost" ability.
private constant integer PAUSE_ID = 'A003' // "Pause [Shattering Frost]" ability.
private constant integer STUN_ID = 'A000' // "Stun [Shattering Frost]" ability.
private constant integer SLOW_ID = 'A001' // "Slow [Shattering Frost]" ability.
//==================================================
//=== PAUSE CONFIGURATION
private constant real PAUSE_DELAY = 1.0 // Delay between target effect creation and pause starting.
// Effect created on target while paused:
private constant string TARGET_EFFECT = "Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathTargetArt.mdl"
private constant string TARGET_ATTACH = "origin"
//==================================================
//=== EXPLOSION CONFIGURATION
private constant real EXPLODE_AOE = 400.0 // All enemies within this range of the target get a frost shard.
// Effect created at target when ice explodes:
private constant string EXPLODE_EFFECT = "Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl"
//==================================================
//=== ICE SHARD CONFIGURATION
private constant real SHARD_SCALE = 1.0 // Model scale.
private constant real SHARD_SPEED = 800.0 // Speed.
private constant real SHARD_ARC = 0.2 // Arc.
private constant real SHARD_HEIGHT = 50.0 // Height.
// Model:
private constant string SHARD_ART = "Abilities\\Spells\\Other\\FrostBolt\\FrostBoltMissile.mdl"
endglobals
//==================================================
//=== PRIMARY TARGET DAMAGE PER LEVEL
private function GetTargetDamage takes integer level returns real
return (50.0 * level) + 25.0
endfunction
//==================================================
//=== PRIMARY TARGET PAUSE PER LEVEL:
private function GetPauseDuration takes integer level returns real
return (0.25 * level) + 0.25
endfunction
//==================================================
//=== SHARD DAMAGE PER LEVEL:
private function GetShardDamage takes integer level returns real
return 50.0 * level
endfunction
//==================================================
//=== DAMAGE FUNCTION SETUP
// This is if you want to change attack/damage types or if you use a custom
// function for damage detection or something similar.
private function DealDamage takes unit source, unit target, real amount returns nothing
call UnitDamageTarget(source, target, amount, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
endfunction
/***************************************************************************************************
*
* END OF CONFIGURATION AND DOCUMENTATION
*
***************************************************************************************************/
private struct IceShard extends xemissile
unit source
integer level
//-----
/**
* Damages the target and stuns it if it's still alive.
*/
private method onHit takes nothing returns nothing
call DealDamage(source, targetUnit, GetShardDamage(level))
if (not IsUnitType(targetUnit, UNIT_TYPE_DEAD)) then
call BeanDummyCaster_SetAbility(STUN_ID, level, "thunderbolt")
call BeanDummyCaster_TargetOrder(targetUnit)
endif
set source = null
endmethod
/**
* Creates a new instance and launches the missile.
*/
static method create takes unit s, real x, real y, unit t, integer l returns thistype
local thistype this = allocate(x, y, SHARD_HEIGHT, GetUnitX(t), GetUnitY(t), SHARD_HEIGHT)
set source = s
set level = l
set targetUnit = t
set fxpath = SHARD_ART
set scale = SHARD_SCALE
call launch(SHARD_SPEED, SHARD_ARC)
return this
endmethod
endstruct
private struct ShatteringFrost
static group enumG = CreateGroup()
static unit temp
//-----
unit caster
unit target
player owner
integer level
effect fx
//-----
/**
* Cleans up and dellocates the instance.
*/
private method destroy takes nothing returns nothing
set caster = null
set target = null
set owner = null
set fx = null
call deallocate()
endmethod
/**
* This is the filter applied to units that are in range of the target.
*/
private method filterUnit takes unit u returns boolean
return IsUnitEnemy(u, owner) /* Enemy of caster.
*/ and not IsUnitType(u, UNIT_TYPE_DEAD) /* Alive
*/ and GetUnitTypeId(u) != 0 /* Alive
*/ and not IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE) /* Not magic immune.
*/ and not IsUnitType(u, UNIT_TYPE_STRUCTURE) /* Not a structure. */
endmethod
/**
* Unpauses the target and sends ice shards to all enemies in range.
* Also slows the target and destroys the effect.
*/
private static method explode takes nothing returns nothing
local thistype this = GetTimerData(GetExpiredTimer())
local real x = GetUnitX(target)
local real y = GetUnitY(target)
call ReleaseTimer(GetExpiredTimer())
call DestroyEffect(fx)
call DestroyEffect(AddSpecialEffect(EXPLODE_EFFECT, x, y))
call BeanDummyCaster_SetAbility(SLOW_ID, level, "slow")
call BeanDummyCaster_TargetOrder(target)
call GroupEnumUnitsInRange(enumG, x, y, EXPLODE_AOE, null)
call GroupRemoveUnit(enumG, target)
loop
set temp = FirstOfGroup(enumG)
exitwhen temp == null
call GroupRemoveUnit(enumG, temp)
if (filterUnit(temp)) then
call IceShard.create(caster, x, y, temp, level)
endif
endloop
call destroy()
endmethod
/**
* Pauses the target and deals damage. Waits until the pause is
* over.
*/
private static method pause takes nothing returns nothing
local thistype this = GetTimerData(GetExpiredTimer())
call BeanDummyCaster_SetAbility(PAUSE_ID, level, "thunderbolt")
call BeanDummyCaster_TargetOrder(target)
call DealDamage(caster, target, GetTargetDamage(level))
call TimerStart(GetExpiredTimer(), GetPauseDuration(level), false, function thistype.explode)
endmethod
/**
* Creates a new instance. Creates the effect on the target and
* waits until PAUSE_DELAY expires.
*/
private static method create takes nothing returns thistype
local thistype this = allocate()
set caster = GetTriggerUnit()
set owner = GetTriggerPlayer()
set level = GetUnitAbilityLevel(caster, SPELL_ID)
set target = GetSpellTargetUnit()
set fx = AddSpecialEffectTarget(TARGET_EFFECT, target, TARGET_ATTACH)
call TimerStart(NewTimerEx(this), PAUSE_DELAY, false, function thistype.pause)
return this
endmethod
/**
* Registers the spell and preloads effects and abilities.
*/
private static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(SPELL_ID, function thistype.create)
call Preload(TARGET_EFFECT)
call Preload(EXPLODE_EFFECT)
call Preload(SHARD_ART)
set temp = CreateUnit(Player(0), 'hpea', 0.0, 0.0, 0.0)
call UnitAddAbility(temp, PAUSE_ID)
call UnitAddAbility(temp, STUN_ID)
call UnitAddAbility(temp, SLOW_ID)
call RemoveUnit(temp)
endmethod
endstruct
endlibrary