call GroupAddUnit(dat.damaged, dat.target)
You damage a unit and all other units around this unit will become damaged one at a time 3 times in a second, or does it work any other way? If so you should only need to declare the damaged unit once into the group of units who won't get affected.
If I'm totally wrong here then I guess I should crawl out my cave a lil' more often.
don't you need a real of a distance to the target? that is probably what you're missing since i don't see it anywhere.
like for example. you hit first target, he gets hurt by the lightning next, then you say he won't go to another unit nearby for such and such distance away...well why don't you put that there? maybe that's why creeps very far away are getting attacked? didn't you say that happens? you must put in the min and max distance reals or something like that in there somewhere...like i said above i don't understand methods and structs but i know the only real you're using is for damage...haha.
call GroupEnumUnitsInRange(g, GetUnitX(dat.target), GetUnitY(dat.target), 500, Condition(function C2))
scope StormStrike initializer I
globals
private group G
endglobals
private struct StormStrike
real damage
unit attacker
trigger t
unit target
timer clock = CreateTimer()
group damaged = CreateGroup()
method onDestroy takes nothing returns nothing
call GroupClear(.damaged)
call DestroyGroup(.damaged)
call PauseTimer(.clock)
call ClearTimerStructA(.clock)
call DestroyTimer(.clock)
endmethod
endstruct
private function C takes nothing returns boolean
return GetUnitAbilityLevel(GetEventDamageSource(), 039;A01I039;) > 0
endfunction
private function C2 takes nothing returns boolean
if IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), udg_Player) and GetUnitAbilityLevel(GetFilterUnit(), 039;Aloc039;) == 0 and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitInGroup(GetFilterUnit(), G) != true then
return true
else
return false
endif
endfunction
private function H takes nothing returns nothing
local StormStrike dat = GetTimerStructA(GetExpiredTimer())
local group g = CreateGroup()
local unit u
call GroupAddUnit(dat.damaged, dat.target)
call BJDebugMsg(GetUnitName(dat.target) + " is damaged for " + R2S(dat.damage))
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl", dat.target, "chest"))
call DisableTrigger(dat.t)
call UnitDamageTarget(dat.attacker, dat.target, dat.damage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call EnableTrigger(dat.t)
set udg_Player = GetOwningPlayer(dat.attacker)
set G = dat.damaged
call GroupEnumUnitsInRange(g, GetUnitX(dat.target), GetUnitY(dat.target), 500, Condition(function C2))
set u = FirstOfGroup(g)
call BJDebugMsg(GetUnitName(u) + " is u")
if u == null then
call BJDebugMsg("Destroying")
call dat.destroy()
endif
call DestroyGroup(g)
set g = null
set u = null
endfunction
private function A takes nothing returns nothing
local StormStrike dat = StormStrike.create()
set dat.attacker = GetEventDamageSource()
set dat.target = GetTriggerUnit()
set dat.damage = GetEventDamage()
set dat.t = GetTriggeringTrigger()
call BJDebugMsg(GetUnitName(dat.attacker) + GetUnitName(dat.target) + R2S(dat.damage))
call SetTimerStructA(dat.clock, dat)
call TimerStart(dat.clock, 0.33, true, function H)
endfunction
//===========================================================================
private function I takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitDamaged(t)
call TriggerAddCondition(t, Condition(function C))
call TriggerAddAction(t, function A)
endfunction
endscope
local group g = CreateGroup()
local unit u
call GroupAddUnit(dat.damaged, dat.target)
call GroupEnumUnitsInRange(g, GetUnitX(dat.target), GetUnitY(dat.target), 500, Condition(function C2))
set u = FirstOfGroup(g)
loop
set u = FirstOfGroup(g)
call GroupRemoveUnit(g,u)
exitwhen u==null
// your actions...
call TriggerSleepAction(.33)
endloop
scope StormStrike initializer I
globals
private group G
endglobals
private function C takes nothing returns boolean
return GetUnitAbilityLevel(GetEventDamageSource(), 039;A01I039;) > 0
endfunction
private function C2 takes nothing returns boolean
if IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), udg_Player) and GetUnitAbilityLevel(GetFilterUnit(), 039;Aloc039;) == 0 and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitInGroup(GetFilterUnit(), G) != true then
return true
else
return false
endif
endfunction
private function A takes nothing returns nothing
local unit target = GetTriggerUnit()
local unit attacker = GetEventDamageSource()
local real damage = GetEventDamage()
local group g = CreateGroup()
local group gd = CreateGroup()
call GroupAddUnit(gd, target)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl", target, "chest"))
call DisableTrigger(GetTriggeringTrigger())
call UnitDamageTarget(attacker, target, damage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call EnableTrigger(GetTriggeringTrigger())
loop
exitwhen target == null
set G = gd
set udg_Player = GetOwningPlayer(attacker)
call GroupEnumUnitsInRange(g, GetUnitX(target), GetUnitY(target), 500, Condition(function C2))
set target = FirstOfGroup(g)
call GroupAddUnit(gd, target)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl", target, "chest"))
call DisableTrigger(GetTriggeringTrigger())
call UnitDamageTarget(attacker, target, damage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call EnableTrigger(GetTriggeringTrigger())
call TriggerSleepAction(.33)
endloop
set target = null
set attacker = null
call DestroyGroup(g)
call DestroyGroup(gd)
set g = null
set gd = null
endfunction
//===========================================================================
private function I takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitDamaged(t)
call TriggerAddCondition(t, Condition(function C))
call TriggerAddAction(t, function A)
endfunction
endscope