/* INTRODUCTIONS
To use this spell, copy all self-made spells, buffs and units into your own map.
Afterwards adjust all the IDs in the trigger to ensure they're correct.
If you are unsure if you got all stuff just check the globals, all names are mentioned there.
It is recommended to start with the buffs, followed by the spells and the units at last
(although its only important that the buffs are first. If not you have to reassign the buff in the objecteditor to the spell).
Also, make sure to always save the map befor testing it. If not the map wont work and a test/game would send you into the
Warcraft III menu instead of playing it.
Feel free to use and/or change this spell as much as you want, no credits necessary.
Greetins, Justify */
scope WanderingPlague initializer OnInit
globals
//------------------------------Wandering Plague------------------------------//
//-- IDs --//
private constant integer WANDERING_PLAGUE_ID = 'A000' //ID of the spell 'Wandering Plague'
private constant integer WANDERING_PLAGUE_SECOND_ID = 'A001' //ID of the spell 'Wandering Plague (Second)'
private constant integer WANDERING_PLAGUE_BUFF_ID = 'B000' //ID of the buff 'Wandering Plague'
private constant integer WANDERING_PLAGUE_SECOND_BUFF_ID = 'B001'//ID of the buff 'Wandering Plague (Second)'
private constant integer WANDERING_PLAGUE_DUMMY_ID = 'h001' //ID of the unit 'dummy'. Feel free to use your own dummy/XE-dummy
private constant string WANDERING_PLAGUE_ORDER = "hex" //Order string of the spell 'Wandering Plague'
//--Options--//
private constant real WANDERING_PLAGUE_PRIM_CHAIN_CHANCE = 0.5 //Chance of hexing other units around the main target, each second
private constant real WANDERING_PLAGUE_SEC_CHAIN_CHANCE = 0.3 //Chance of hexing other units around new-hexed targets, each second
private constant real WANDERING_PLAGUE_CHAIN_RANGE = 500. //Area of affected units
//---------------------------End of Wandering Plague--------------------------//
endglobals
private struct Morphed
unit tar
integer level
player orig
static Morphed AFFECTED
static boolean IS_PRIMARY
static method getEnemys takes nothing returns boolean
local unit u = GetFilterUnit()
local unit dummy
local timer t
local Morphed this
if GetWidgetLife(u) > 0.405 and /* Alive
*/ IsUnitEnemy(u, AFFECTED.orig) and /* Affects enemies
*/ GetUnitAbilityLevel(u, WANDERING_PLAGUE_BUFF_ID) == 0 and /* Not hexed primary
*/ GetUnitAbilityLevel(u, WANDERING_PLAGUE_SECOND_BUFF_ID) == 0 and /* Not infected secondary
*/ (IS_PRIMARY and GetRandomReal(0., 1.) <= WANDERING_PLAGUE_PRIM_CHAIN_CHANCE or /*
*/ not IS_PRIMARY and GetRandomReal(0., 1.) <= WANDERING_PLAGUE_SEC_CHAIN_CHANCE) then
set dummy = CreateUnit(AFFECTED.orig, WANDERING_PLAGUE_DUMMY_ID, GetUnitX(u), GetUnitY(u), 0.)
call UnitAddAbility(dummy, WANDERING_PLAGUE_SECOND_ID)
call SetUnitAbilityLevel(dummy, WANDERING_PLAGUE_SECOND_ID, AFFECTED.level)
call IssueTargetOrder(dummy, WANDERING_PLAGUE_ORDER, u)
call UnitApplyTimedLife(dummy, 'BTLF', 1.0)
set dummy = null
set t = NewTimer()
set this = Morphed.allocate()
set .tar = u
set .level = AFFECTED.level
set .orig = AFFECTED.orig
call SetTimerData(t, this)
call TimerStart(t, 1., true, function Morphed.check)
endif
set u = null
return false
endmethod
static method check takes nothing returns nothing
local timer t = GetExpiredTimer()
local Morphed this = GetTimerData(t)
set AFFECTED = this
if GetUnitAbilityLevel(.tar, WANDERING_PLAGUE_BUFF_ID) > 0 then
set IS_PRIMARY = true
elseif GetUnitAbilityLevel(.tar, WANDERING_PLAGUE_SECOND_BUFF_ID) > 0 then
set IS_PRIMARY = false
else
call ReleaseTimer(t)
call .destroy()
return
endif
call GroupEnumUnitsInArea(ENUM_GROUP, GetUnitX(.tar), GetUnitY(.tar), WANDERING_PLAGUE_CHAIN_RANGE, Condition(function Morphed.getEnemys))
endmethod
static method new takes nothing returns boolean
local timer t
local Morphed this
if GetSpellAbilityId() == WANDERING_PLAGUE_ID then
set t = NewTimer()
set this = Morphed.allocate()
set .tar = GetSpellTargetUnit()
set .level = GetUnitAbilityLevel(.tar, WANDERING_PLAGUE_ID)
set .orig = GetOwningPlayer(GetTriggerUnit())
call SetTimerData(t, this)
call TimerStart(t, 1., true, function Morphed.check)
endif
return false
endmethod
method destroy takes nothing returns nothing
set .tar = null
call .deallocate()
endmethod
endstruct
private function OnInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Morphed.new))
endfunction
endscope