Immolation
Member
- Reaction score
- 20
JASS:
scope ElectricalDischarge initializer Init
// Electrical Discharge
// Spell Descrpt.:
//---------------------------
// Gives a chance to release lightning bolts upon damaging an enemy that jump and deal damage to nearby targets.
// A single enemy cannot be damaged by Electrical Discharge more than once every X seconds.
globals
//Rawcodes
private constant integer SPELL_ID = 039;A000039;
private constant integer EFFECT_ID = 039;A001039;
private constant integer BUFFSPELL_ID = 039;A002039;
private constant integer DUMMY_ID = 039;u000039;
private constant integer BUFF_ID = 039;B000039;
//Effects
private constant boolean EFFECT_ON_HIT = true
private constant string EFFECT_NAME = "Abilities\\Weapons\\Bolt\\BoltImpact.mdl"
endglobals
private function ChanceToFire takes integer level returns integer
return 20 + (level * 5)
endfunction
private function Damage takes integer level returns real
return 20.00 + (level * 5.00)
endfunction
private function Targets takes integer level returns integer
return 3 + level
endfunction
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
private function Conditions takes nothing returns boolean
return GetUnitAbilityLevel(GetEventDamageSource(), 039;A000039;) >= 1 and IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetEventDamageSource())) == false
endfunction
private function GroupFilter takes nothing returns boolean
return IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(GetEventDamageSource())) == true and (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0) == false and GetUnitTypeId(GetFilterUnit()) != DUMMY_ID and GetUnitAbilityLevel(GetFilterUnit(), BUFF_ID) == 0
endfunction
private function PickRandomUnit2 takes nothing returns nothing
set bj_groupRandomConsidered = bj_groupRandomConsidered + 1
if (GetRandomInt(1,bj_groupRandomConsidered) == 1) then
set bj_groupRandomCurrentPick = GetEnumUnit()
endif
endfunction
private function PickRandomUnit takes group g returns unit
set bj_groupRandomConsidered = 0
set bj_groupRandomCurrentPick = null
call ForGroup(g, function PickRandomUnit2)
return bj_groupRandomCurrentPick
endfunction
private function Actions takes nothing returns nothing
local unit tu = GetTriggerUnit()
local real x = GetUnitX(tu)
local real y = GetUnitY(tu)
local unit att = GetEventDamageSource()
local player p = GetOwningPlayer(att)
local integer level = GetUnitAbilityLevel(att, SPELL_ID)
local integer LoopStart
local integer LoopEnd
local group g = CreateGroup()
local boolexpr f = Condition(function GroupFilter)
local unit target
local unit dummy
if GetRandomInt(1, 100) <= ChanceToFire(level) then
if EFFECT_ON_HIT == true then
call DestroyEffect(AddSpecialEffect(EFFECT_NAME, x, y))
endif
set dummy = CreateUnit(p, DUMMY_ID, x, y, 0.00)
call UnitAddAbility(dummy, BUFFSPELL_ID)
call IssueTargetOrder(dummy, "cripple", tu)
set LoopStart = 1
set LoopEnd = Targets(level)
loop
exitwhen LoopStart > LoopEnd
call GroupEnumUnitsInRange(g, x, y, 500.00, f)
set target = PickRandomUnit(g)
set dummy = CreateUnit(p, DUMMY_ID, x, y, 0.00)
call UnitAddAbility(dummy, BUFFSPELL_ID)
call IssueTargetOrder(dummy, "cripple", target)
set dummy = CreateUnit(p, DUMMY_ID, x, y, 0.00)
call UnitAddAbility(dummy, EFFECT_ID)
call IssueTargetOrder(dummy, "chainlightning", target)
call UnitDamageTarget(dummy, target, Damage(level), true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
set LoopStart = LoopStart + 1
endloop
endif
call DestroyBoolExpr(f)
call DestroyGroup(g)
set target = null
set dummy = null
set att = null
set tu = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitDamaged(t)
call TriggerAddCondition(t, Condition(function Conditions))
call TriggerAddAction(t, function Actions)
call UsefulFunctions_Load(SPELL_ID)
call UsefulFunctions_Load(BUFFSPELL_ID)
call UsefulFunctions_Load(EFFECT_ID)
set t = null
endfunction
endscope
As the description at the top of the script implies, this spell has a X% chance upon damaging an enemy to release several lightnings that damage enemies near the damaged target(not the target itself). Enemies cannot be hit every X seconds due to a buff that I add through the other ability(rawcode:'A002')
Note that the lightning created through a custom chain lightning(rawcode:'A001') is used purely for the visual effect.
I'm waiting in awe for your l33t words, pro vJASSers out there
P.S.: About -
JASS:
call TriggerRegisterAnyUnitDamaged(t)
I started making this spell with eGUI, that had the event "Any unit takes damage", after realizing this was impossible with simple, leaky, stinky GUI I moved to vJASS