moyack
Cool Member
- Reaction score
- 9
Death Carrier
By moyack. 2009.
By moyack. 2009.
Requires:
- Jass New Gen Pack or JassHelper
- TimerUtils
Description:
A deadly mark moves randomly over the enemies in an area of effect, jumping 5 times over them before exploding and dealing damage to the nearest enemies to the explosion.
Level 1 - The explosion deals 100 damage.
Level 2 - The explosion deals 170 damage.
Level 3 - The explosion deals 240 damage.
How to install:
- Open the test map.
- Add TimerUtils to your map if you haven't it installed. (Could it be possible??).
- Copy the trigger, the ability and the effect used in this spell into you map.
- Voila!! spell installed.
JASS:
// Death Carrier (hmm probably the name is not the best but meh...)
// By moyack. 2009.
// Made for the spell contest No 13 (for the bad luck maybe??)
// Requires TimerUtils.
library DeathCarrier initializer init requires TimerUtils
// Configuration part...
globals
private constant integer SpellID = 039;A000039;
private constant real dt = 0.5 //
endglobals
private constant function Damage takes integer lvl returns real
return 100. + 70. * (lvl - 1)
endfunction
private constant function AOE takes integer lvl returns real
return 500. // I left it in this way so it can be configurable to a variable area
endfunction
private constant function Jumps takes integer lvl returns integer
return 5 // sets the number of times the maks jumps on units before explode
endfunction
// end configuration part...
private function GetEnemies takes nothing returns boolean
return GetWidgetLife(GetFilterUnit()) > 0.405 and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(bj_groupRandomCurrentPick))
endfunction
private struct data
group g
unit c
integer counter = 0
private method onDestroy takes nothing returns nothing
call GroupClear(.g)
set .c = null
endmethod
private static method PickRandomUnit takes nothing returns nothing
set bj_groupRandomConsidered = bj_groupRandomConsidered + 1
if GetWidgetLife(GetEnumUnit()) > 0.405 and GetRandomInt(1,bj_groupRandomConsidered) == 1 then
set bj_groupRandomCurrentPick = GetEnumUnit()
endif
endmethod
private static method DealDamage takes nothing returns nothing
call UnitDamageTarget(GetEnumUnit(), GetEnumUnit(), Damage(GetUnitAbilityLevel(bj_groupRandomCurrentPick, SpellID)), true, true, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_ROCK_HEAVY_BASH)
call DestroyEffect(AddSpecialEffectTarget(GetAbilityEffectById(SpellID, EFFECT_TYPE_SPECIAL, 2), GetEnumUnit(), "chest"))
endmethod
static method effect takes nothing returns nothing
local data d = data( GetTimerData(GetExpiredTimer()) )
local real x
local real y
set bj_groupRandomConsidered = 0
set bj_groupRandomCurrentPick = null
call ForGroup(d.g, function data.PickRandomUnit)
if bj_groupRandomCurrentPick == null then
call d.destroy()
call ReleaseTimer(GetExpiredTimer())
return
endif
call DestroyEffect(AddSpellEffectTargetById(SpellID, EFFECT_TYPE_SPECIAL, bj_groupRandomCurrentPick, "overhead"))
set d.counter = d.counter + 1
if d.counter > Jumps(GetUnitAbilityLevel(d.c, SpellID)) then
set x = GetUnitX(bj_groupRandomCurrentPick)
set y = GetUnitY(bj_groupRandomCurrentPick)
call GroupClear(d.g)
call DestroyEffect(AddSpecialEffect(GetAbilityEffectById(SpellID, EFFECT_TYPE_SPECIAL, 1), x, y))
set bj_groupRandomCurrentPick = d.c
call GroupEnumUnitsInRange(d.g, x, y, 0.5*AOE(GetUnitAbilityLevel(d.c, SpellID)), Condition(function GetEnemies))
call ForGroup(d.g, function data.DealDamage)
call d.destroy()
call ReleaseTimer(GetExpiredTimer())
else
call UnitDamageTarget(d.c, bj_groupRandomCurrentPick, GetRandomReal(0, Damage(GetUnitAbilityLevel(d.c, SpellID))), true, false, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_ROCK_HEAVY_BASH)
endif
endmethod
static method Start takes unit c, location l returns nothing
local data d = data.allocate()
local timer t = NewTimer()
if d.g == null then
set d.g = CreateGroup()
endif
set d.c = c
set bj_groupRandomCurrentPick = c
call GroupEnumUnitsInRangeOfLoc(d.g, l, AOE(GetUnitAbilityLevel(c, SpellID)), Condition(function GetEnemies))
call SetTimerData(t, integer(d))
call TimerStart(t, dt, true, function data.effect)
call RemoveLocation(l)
set l = null
set t = null
endmethod
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SpellID
endfunction
private function Actions takes nothing returns nothing
call data.Start(GetTriggerUnit(), GetSpellTargetLoc())
endfunction
//===========================================================================
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function Conditions ) )
call TriggerAddAction( t, function Actions )
set t = null
endfunction
endlibrary
Changelog:
(2/2/2009) Removed the timer from the struct, now it's managed via local variables.
(11/3/2009) Now every jump deals a random damage to the jumping unit.